5 Replies Latest reply on May 14, 2007 10:22 AM by San_Bruno

    unloadclip does not unload everything

      I create a menu system to load an external SWF movie by using loadclip.
      no problem so far, the swf movie load.

      but when I use unloadclip to unload the external SWF movie, the movie dissapear which it is good but....

      the external SWF movie has a setinterval running, if I unload before it finish, it still running in the background even I use the unloadclip to unload it.

      I thought the unloadclip show remove everything from that external SWF movie even thought there is a setinterval running.

      I am not sure if this is a bug where the unloadclip does not unload everything.
        • 1. Re: unloadclip does not unload everything
          Rothrock Level 5
          Nope. Any setInterval, setTimeout, or addListener will remain. You will need to clear the first two and removeListener the third. It would be nice if AS did the housekeeping, but it isn't how it works. Not really a bug, just the way it is.
          • 2. Re: unloadclip does not unload everything
            Rothrock Level 5
            Oh, I forgot if you use the Tween class you better .stop() those as well!
            • 3. Re: unloadclip does not unload everything
              San_Bruno Level 1
              so are you saying any setinterval, setTimeout or removeListener need to clear out in that particularly SWF, otherwise it will carry over to the main menu.

              so if that the case, is there any other way, I could write this where the main menu when press a button will unload the swf with the setinterval. I try to get some idea.

              • 4. Re: unloadclip does not unload everything
                Rothrock Level 5
                You just have to keep track of all thing things that might need to be cleaned up and then clean them up. So without knowing the whole structure of your set up it is hard to say exactly how to implement that.

                You could put a cleanUp() function in your external swf and have the button call that. Or you could define a clean up function in the parent. It really all depends.

                You do know how to clearInterval(someIntervalID)? Remember it doesn't hurt to clear an interval that has already been cleared or finished so don't worry about calling the clearInterval.

                Also remember the setInterval returns just an integer – a lot like going to a bakery and getting your number. You can store those intervals IDs in any convenient place so that it makes doing clearInterval much easier.
                • 5. Re: unloadclip does not unload everything
                  San_Bruno Level 1
                  well, for the application that I am doing putting up a cleanUP()function in the external SWF(movie1.fla) will not work.

                  To define in the parent(main Menu) is better but how do I do it. see the code here, there are 2 FLA file, one for the Menu and the other is for the Movie file
                  also, I am unsing unloadMovie(); to unload it. and not unloadClip;

                  I don't know how to set a intervalID on the movie1.fla and then return that value to the main Menu program so I could kill it.

                  as you can see in the movie1.fla, I put "trace(bar_mc.scrub._x + " this is the videoInterval ID= "+videoInterval);" so when I unload it from the main Menu, it keep running for testing.

                  Menu program
                  var mcLoader:MovieClipLoader=new MovieClipLoader();

                  mcLoader.loadClip("movie1.swf", dummy_mc);


                  Movie file(movie1.fla)

                  //Create video stream
                  var nc:NetConnection = new NetConnection();
                  var ns:NetStream = new NetStream(nc);
                  ns.play("video/Microsoft IPOD.flv");
                  play_btn.onRelease = function() {
                  rewind_btn.onRelease = function() {

                  var videoInterval = setInterval(videoStatus,100);

                  var amountLoaded:Number;

                  var maxWidth:Number = 241;
                  var duration:Number = 175;

                  function videoStatus() {
                  amountLoaded = ns.bytesLoaded/ns.bytesTotal;
                  bar_mc.progress._width = maxWidth * amountLoaded;
                  bar_mc.scrub._x = ns.time / duration * maxWidth;
                  trace(bar_mc.scrub._x + " this is the videoInterval ID= "+videoInterval);
                  if(bar_mc.scrub._x > 241){

                  //scrubber code
                  var scrubberInterval;
                  bar_mc.scrub.onPress = function()
                  scrubberInterval = setInterval(scrubIt,10);
                  this.startDrag(false, 0 , this._y, maxWidth, this._y);

                  bar_mc.scrub.onRelease = bar_mc.scrub.onReleaseOutside = function()
                  videoInterval = setInterval(videoStatus,100);
                  function scrubIt()
                  ns.seek(Math.floor(bar_mc.scrub._x / maxWidth * duration));