Reputation: 1345
I have an mp3 embedded in a Flex application with a start and stop button. Using this code...
<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>
I want to have multiple instances with different sounds though. How can I do this?
Upvotes: 0
Views: 1188
Reputation: 12527
Just make a separate class reference for each:
[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;
Upvotes: 4