Its really easy. Lets have soundfile sound.mp3 in folder music.
[Embed(source='../music/sound.mp3')]
private var musicClass : Class;
private var mymusic : Sound;
And then this:
myMusic = (new musicClass) as Sound;
myMusic.play();
Here is the full sourcecode:
package
{
public class MusicTest
{
[Embed(source='../music/sound.mp3')]
private var musicClass : Class;
private var myMusic : Sound;
public function MusicTest()
{
myMusic = (new musicClass) as Sound;
}
public function playMusic():void {
myMusic.play();
}
}
}
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment