Jump to content
Search Community

SWF Loader unload problem

DagShot test
Moderator Tag

Recommended Posts

hey guys,

 

I'm currently loading swfs witch contain mp3 loaders and timelineMaxs

via swf loader.

 

works.

 

when i unload on of them, the movie clips disappear, but the timeline and the sounds keep on playing,

 

this is annoying,

 

what should i do?

 

 

*Edit

 

i stopped them both via rawContent, but is this really the only way?

Link to comment
Share on other sites

It's impossible for LoaderMax/SWFLoader to know what code you're running inside your sub-loaded SWF and clean up after you. For example, if you start NetStreams, audio, add event listeners without weak references, etc. In order to make things eligible for garbage collection, you need to clean up after yourself. So yes, you should stop your sounds, videos, remove event listeners, etc. and then unload() or dispose() your SWFLoader. I really wish there was a way that I could make the system capable of alleviating you of that cleanup task, but unfortunately it's just impossible (at least as far as I know).

Link to comment
Share on other sites

Your right.

Im sorry, I'm a bit of a mess right now.

i should watch my touch-typing..

 

your help is highly aprreciated! I love your platform, i just can't handle it...

 

here we go:

 

along another LoaderMax "queue", witch is responsible for Mp3 Loading,

 

i have 4 SWFLoaders,:

 

var unter:SWFLoader = new SWFLoader("content/unternehmen.swf", {name:"unternehmen", container:this.contor, x:0, y:0, onProgress:progressFilm, onInit:filmInit});

var haupt:SWFLoader = new SWFLoader("content/hauptfilm.swf", {name:"hauptfilm", container:this.contor, x:0, y:0, onProgress:progressFilm,  onInit:filmInit});

var proz:SWFLoader = new SWFLoader("content/prozess.swf", {name:"prozess", container:this.contor, x:0, y:0, onProgress:progressFilm,  onInit:filmInit});

var mitA:SWFLoader = new SWFLoader("content/mitarbeiter.swf", {name:"mitarbeiter", container:this.contor, x:0, y:0, onProgress:progressFilm,  onInit:filmInit});

function filmInit(event:LoaderEvent):void {

  this.contor.alpha = 1;
  var Blenden:TimelineMax = new TimelineMax();
   //Blenden.append(TweenMax.to(loadbar, .8, {y:ladePos2, alpha:0, ease:Expo.easeOut}));
   Blenden.append(TweenMax.from(event.target.content, 3, {alpha:0}));
}	

 

i have a function that loads one of the SWFLoaders, triggered by buttons, to keep the reference to the current loader, i tried to use an Array named getMe

 

var getMe:Array = new Array();

function filmLaden(targetFilm):void{

targetFilm.load();

getMe[0] = targetFilm;

}


function mitarbeiterLaden(e:MouseEvent):void{
filmLaden(mitA);
}

function hauptLaden(e:MouseEvent):void{
filmLaden(haupt);

}


function prozessLaden(e:MouseEvent):void{
filmLaden(proz);

}
function unternehmenLaden(e:MouseEvent):void{
       filmLaden(unter);

}

 

 

this works,

 

ok now the tricky part:

 

all these sub loaded swfs contain timelineMax's witch trigger the parent movieclips "filmOut" function witch basicly should stop all sounds and unload the whole content of the movieClip:

 

Code in Subloaded SWF:

 

function itsOver():void{

	 MovieClip(parent.parent.parent).filmOut();

}

/*
...
*/

var film:TimelineMax = new TimelineMax({});

/*
...
*/
film.append(TweenMax.to(this , .01,{go:1, onComplete:itsOver})); 

 

Code in Parent SWF:

 

 

[/code]

 

function filmOut():void{

 

 

targetLoader.rawContent.film.stop();

 

//an array i keep references to the mp3loaders in the sub loaded swf, this works

getMe[0].rawContent.playingSounds[0].soundPaused = true;

//...

getMe[0].unload();

}

 

 

 

this dosent work at all,

i wonder if it is a problem, that i start loading them with a button function.

i got it to work somehow with the swfloader appended to a loadermax and then immediately started loading without waiting for a button event to be fired.

of couse i didnt have to store any reference to the current loader anywhere, witch doesn't seem to work in this example anywhere, i wonder why, because it works beautifully with mp3loaders.

 

the thing i want to achieve is, to be able to load all four films ( i could also load them all at once, if that doesn't slow down the performance) and then be able to RELOAD any of these four films from scratch, so that it starts all over again.

 

thanks a lot

Link to comment
Share on other sites

I noticed that the Init event wasn't happening.

 

i built it again from scratch and noticed, that i applied the onInit function to a LoaderMax instead of a SWFLoader...

 

sad but true, this does the trick.

 

now everything works like a charm.

 

thank you, greensock!

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...