N.B. : I called the sound variables in a different way than the one suggested as duplicate. That's why it's not the same structure to follow as a start of the question,
In my application, i have used the following lines to embed music and run in on actual devices through adobe air :
[Embed(source = '/inspiration.mp3')]
private var MyBack:Class;
private var back:Sound;
Later on, whenever i want to play it, i use the following code :
back = (new MyBack()) as Sound;
back.play(0,9999);
It works perfectly, the problem is when i want to stop that music! I've used
back.stop();
but it's always telling me
1061: Call to a possibly undefined method stop through a reference with static type flash.media:Sound.
What am i doing wrong?
You should store the resultant SoundChannel
object and then use that one to stop a playing sound.
var backPlaying:SoundChannel;
....
backPlaying=back.play(0,9999);
....
backPlaying.stop();
Of course, make it so that backPlaying
is persistent, aka define it in the class aside back
.