以下是制作简单mp3播放器的核心代码。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    width="400" height="110" layout="vertical"
    horizontalAlign="center" verticalAlign="center"
>
    <mx:Script>
        <![CDATA[
            import mx.core.SoundAsset;
            import flash.media.*;

            [Embed(source="song.mp3")]
            [Bindable]
            public var Song:Class;
            public var mySong:SoundAsset = new Song() as SoundAsset;
            public var channel:SoundChannel;
           
            public function playSound():void
            {
                // 先 停止
                stopSound();
               
                // 在播放
                channel = mySong.play(0,int.MAX_VALUE);
            }
           
            public function stopSound():void
            {
                // 停止
                if ( channel != null ) channel.stop();
            }
        ]]>
    </mx:Script>
    <mx:HBox>
        <mx:Button label="play" click="playSound();"/>
        <mx:Button label="stop" click="stopSound();"/>       
    </mx:HBox>
</mx:Application>