can anyone see where is is not working please ?
i am trying to get a sound from the imported libary to play on button click,
button_1.addEventListener(MouseEvent.CLICK, fl_ClickToPlayStopSound_2);
var fl_SC_2:SoundChannel;
var fl_ToPlay_2:Boolean = true;
function fl_ClickToPlayStopSound_2(evt:MouseEvent):void
{
if(fl_ToPlay_2)
{
var s:Sound = new Sound(new ("dog.mp3"));
fl_SC_2 = s.play();
}
else
{
fl_SC_2.stop();
}
fl_ToPlay_2 = !fl_ToPlay_2;
}
I receive this error,
Scene 1, Layer 'Actions', Frame 1, Line 21 1120: Access of undefined property dog.
I don’t think that is how you’re supposed to play a sound from the library…
var s:Sound = new Sound(new ("dog.mp3"));isn’t correct.You need to set linkage class name of the sound in the library, then create the object (and can cast into a
Soundobject), then you can play it.Example: when I have set my linkage class name to
DogSound, I can then go: