I a having trouble loading an audio file from the library, I was previously loading the sound files externally like so:
var s1:Sound = new Sound(new URLRequest("Sound/Melody1.mp3"));
However I now need to load them from the library as I have encountered a looping problem with mp3 files.
Below is my attempt, however I am receiving the error: Scene 1, Layer 'Actions', Frame 1, Line 21 1061: Call to a possibly undefined method attachSound through a reference with static type flash.media:Sound.
/* Click to Play/Stop Sound 1 Clicking on the symbol instance plays the specified sound. Clicking on the symbol instance a second time stops the sound. */
Btn_Melody1.addEventListener(MouseEvent.CLICK, fl_ClickToPlayStopSound1);
var fl_SC1:SoundChannel;
//This variable keeps track of whether you want to play or stop the sound var fl_ToPlay1:Boolean = true;
function fl_ClickToPlayStopSound1(evt:MouseEvent):void
{
if (fl_ToPlay1)
{
var s1:Sound = new Sound();
s1.attachSound("Melody1");
fl_SC1 = s1.play(0,999);
}
else
{
fl_SC1.stop();
}
fl_ToPlay1 = ! fl_ToPlay1;
}
I can't see what I am doing wrong, any and all help would be appreciated.