186 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has sold $5,000+ on Envato Market
  • Has collected 1+ items on Envato Market
+4 more
scottrockers says

Hey guys,

I usually don’t ask too many coding questions but I am stumped. I am loading a swf (that has a enter_frame event listener in it) into a movieclip , and when I go to remove that swf I use unloadAndStop(), but the enterframe event is still firing and throwing a #1009 Error .

It is deleting the swf, but I am told that it will get rid of everything in the loader including the event listeners, and Its not. Anyone experience something like this before or have a solution. I am using CS5 , AS3.

Thanks Scott

412 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+5 more
patrickjansen says

did you try adding a removed from stage listener in the loaded swf to brute-kill the frame listener. might work

Weird that it doesn’t work though, should do so according to specs

1677 posts Envato Elite Author
  • Has referred 10+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
Tean says

I have never tested unloadAndStop() myself, but when I heard about it I thought this is just a collection of generic commands like SoundMixer.stopAll and such.

I am not sure how is it suppose to remove the events, timers, tweens and other stuff you added internally in your application.

186 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has sold $5,000+ on Envato Market
  • Has collected 1+ items on Envato Market
+4 more
scottrockers says

PJ,

Thanks for your suggestion, I implemented the REMOVED _FROM_STAGE event and it worked like a charm, here is what I used if anyone has the similar problem.

this.addEventListener(Event.REMOVED_FROM_STAGE, removed);

function removed(e:Event):void { if (e != null) { //here remove any listeners //moviecilpname.removeEventListener(Event.ENTER_FRAME, functionname); this.removeEventListener(Event.REMOVED_FROM_STAGE, removed); } }

Thanks again Patrick and Tean.

Scott

412 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+5 more
patrickjansen says

no sweat… i’ve run into unloading issue myself before. Event.UNLOAD gave me some unfair errors and now I simply use both and make sure that on unload i also remove the child from stage right away. Seems to work ok.

by
by
by
by
by
by