2011-01-11 50 views
0

某些只能表示一小段FLEX/AS代碼,它只播放MP3和播放按鈕,目的是播放一個樣本聲音大約5到10秒。編譯後的swf應該有在它包埋的MP3下面使用FLEX/AS的球員

回答

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> 
+0

而且哪裏的sample.mp3駐留?? – Rajeev 2011-01-13 17:42:46