Jump to content
Search Community

Loading and unloading

Jakob Sternberg test
Moderator Tag

Recommended Posts

Hi,

 

I'm a little new to AS3

 

Im currently creating a "presenter-app" that loads in "slides" (swf's)

I simply click next/prev to show the current slide, so only one slide is visible at a time.

So every time i "change slide" i wait for unload, and then use the same loader to load the next slide.

 

Sofar this has worked (ot at least it seems to) 

 

The Problem: Now one of the subloaded slides  uses VideoLoader to load in a video background (FLV), it seems that this does not get unloaded properly,,(when going back and forth, video gets slower each time)

I tried to add code to the main timeline of the slide.swf
 

loaderInfo.addEventListener(Event.UNLOAD, function(){
       trace("UNLOAD")
       videoBg.unload()
       });

.. But this never get's called.

Any pointers to what i could do would be great,

 

Thanks

 

 

 

 

 

 

 

Link to comment
Share on other sites

Ok, that did not work

 

I tried to trace a bit..

var i = 0
var curParent:DisplayObjectContainer = this.parent;
while (curParent) {
	i++
	trace("--"+i)
    if (curParent.hasOwnProperty("loader") && curParent.hasOwnProperty("rawContent")) {
		trace("YO!!")
        Object(curParent).loader.addEventListener("unload", dispose, false, 0, true);
    }
    curParent = curParent.parent;
}
function dispose(event:Event):void {
    //do cleanup stuff here like removing event listeners, stopping sounds, closing NetStreams, etc...
   trace("HALLELUJA!")
   videoBg.dispose();
}

No matter if the swf gets loaded or runs "standalone" the while loop runs one time, and above outputs:
 

--1
 

I know i could create a "cleanup" function in the slide, call that, then unload..
But i was actually looking for something like what you suggested Carl.
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...