<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/08/24/setting-the-duration-of-a-sound-effect-in-flex/ -->
<mx:Application name="SoundEffect_useDuration_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white" viewSourceURL="srcview/index.html">

    <mx:SoundEffect id="soundEffect"
            source="http://www.helpexamples.com/flash/sound/song1.mp3"
            useDuration="{checkBox.selected}"
            duration="{slider.value}" />

    <mx:ApplicationControlBar dock="true">
        <mx:Form styleName="plain">
            <mx:FormItem label="useDuration:">
                <mx:CheckBox id="checkBox"
                        selected="true" />
            </mx:FormItem>
            <mx:FormItem label="duration:">
                <mx:HSlider id="slider"
                        minimum="0"
                        maximum="5000"
                        value="500"
                        snapInterval="100"
                        tickInterval="100"
                        liveDragging="true"
                        showTrackHighlight="true"
                        enabled="{checkBox.selected}" />
            </mx:FormItem>
            <mx:FormItem>
                <mx:Button id="btn"
                        label="Play sound effect"
                        mouseDown="soundEffect.stop();"
                        mouseDownEffect="soundEffect" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

</mx:Application>