0

有些只能表示一小段 FLEX/AS 代码播放 mp3 并且只有播放按钮,目标是播放大约 5 到 10 秒的样本声音。编译的 swf 应该有 mp3 嵌入其中

4

1 回答 1

2

下面的示例复制并粘贴自: http://livedocs.adobe.com/flex/3/html/help.html?content= embed_4.html

<?xml version="1.0"?>
<!-- embed/EmbedSound.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Script>
        <![CDATA[

            import flash.media.*; 

            [Embed(source="sample.mp3")]
            [Bindable]
            public var sndCls:Class;

            public var snd:Sound = new sndCls() as Sound; 
            public var sndChannel:SoundChannel;

            public function playSound():void {
                sndChannel=snd.play();
            }   

            public function stopSound():void {
                sndChannel.stop();
            }   
        ]]>
    </mx:Script>

    <mx:HBox>
        <mx:Button label="play" click="playSound();"/>
        <mx:Button label="stop" click="stopSound();"/>
    </mx:HBox>
</mx:Application>
于 2011-01-13T17:08:20.337 回答