0

Having a problem with AS3, Flash player 9: When using the following code.

I cant stop the sounds on the unloaded swf from playing back after a new SWF is loaded??

I've tried putting a sound mixer stop all code on the actions panel of the opening frame for all my swf's. I have this code in my main swf, the sounds are in the loaded swf's.

I'm using Flash player 9, AS3, Flash CS5

var Xpos:Number = 53;
var Ypos:Number = 17;
var swf:MovieClip;
var loader:Loader = new Loader();

var defaultSWF:URLRequest = new URLRequest("swfs/Animation1.swf");

loader.load(defaultSWF);
loader.x = Xpos;
loader.y = Ypos;
addChild(loader);


 Btns Universal function
 function btnClick(event:MouseEvent):void {

removeChild(loader);
    var newSWFRequest:URLRequest = 
 new URLRequest("swfs/" + event.target.name + ".swf");
loader.load(newSWFRequest);
loader.x = Xpos;
     loader.y = Ypos;
addChild(loader);

 }
 // Btn listeners
ActivatePart1.addEventListener(MouseEvent.CLICK, btnClick);
ActivatePart2.addEventListener(MouseEvent.CLICK, btnClick);
ActivatePart3.addEventListener(MouseEvent.CLICK, btnClick);
Certificates.addEventListener(MouseEvent.CLICK, btnClick);
gideon
  • 19,329
  • 11
  • 72
  • 113
Ian
  • 1
  • i'm curious why you are targeting FP9? – Chunky Chunk Mar 28 '11 at 18:25
  • Flash 10 will not load swf's without exported text or embeded text... i did embed and it still wouldnt work. so i published at FP9 and that fixed the issue. thats the only reason i used the FP9 setting... – Ian Mar 28 '11 at 19:39
  • i don't understand that problem without further detail but it's a bad idea to target FP9 over FP10.2. i would suggest posting a new question to solve that issue instead. – Chunky Chunk Mar 28 '11 at 21:33

1 Answers1

0

Do you call Loader.unloadAndStop() before loading a new swf in your Loader?

Kodiak
  • 5,978
  • 17
  • 35
  • Looks like they're targeting Flash player 9 which doesn't support unloadAndStop – jpea Mar 28 '11 at 17:38
  • Im using loader.load(newSWFRequest); should I change that? – Ian Mar 28 '11 at 18:12
  • jpea is right. @Ian, you should at least try unloading before reloading. Or you could compile for Flash 10 by selecting ActionScript Settings > Default Linkage > Merged into code. – Kodiak Mar 29 '11 at 07:44