我在Flex应用程序中嵌入了一个带有启动和停止按钮的mp3。使用此代码...
<fx:Script>
<![CDATA[
import mx.core.SoundAsset;
import flash.media.*;
[Embed(source="assets/pie-yan-knee.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();
}
public function stopSound():void
{
if ( channel != null ) channel.stop();
}
]]>
</fx:Script>
<s:HGroup>
<s:Button label="play" click="playSound();"/> <s:Button label="stop"
click="stopSound();"/>
</s:HGroup>
我希望有多个不同声音的实例。 我怎么能这样做?
答案 0 :(得分:4)
为每个提供单独的类引用:
[Embed(source="assets/song1.mp3")]
[Bindable]
public var Song1:Class;
[Embed(source="assets/song2.mp3")]
[Bindable]
public var Song2:Class;
[Embed(source="assets/song3.mp3")]
[Bindable]
public var Song3:Class;