开发者

Player using FLEX/AS

Can some only indicate a small piece of FLE开发者_StackOverflow中文版X/AS code which plays mp3 and with play button only,the objective is to play a sample sound for around 5 to 10 seconds.And the compiled swf should have the mp3 embeded in it


Example below copied and pasted from: 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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜