I have a loader SWF that runs some code in the background and loads other SWFs. Using this code:
private function loadScreensaver():void {
screensaverSWF = new Loader();
var req:URLRequest;
switch(areaNumber){
case 1 :
req = new URLRequest("exNorthernFrontierScreensaver.swf");
break;
case 2 :
req = new URLRequest("exRomanEmpireScreensaver.swf");
break;
case 3 :
req = new URLRequest("exRomanCarlisleScreensaver.swf");
break;
case 4 :
req = new URLRequest("exRomanBritainScreensaver.swf");
break;
}
screensaverSWF.load(req);
addChild(screensaverSWF);
GAME_STATE = SCREENSAVER;
}
I load the screensaver and add it to the stage. Using MonsterDebugger I can see that memory steadily rises from around 80mb upwards until the application exits (Im using windows projector). What I can’t work out is why, there is no code attached to the screensaver SWF, just some timeline animations of things fading in and out.
Any idea what’s going on here?
EDIT:
I’ve kept testing and found where I have an image that starts of stage then tweens on and off and is removed. When it loops it adds to memory again, as if the first image is still kept. This is all done on the timeline.
EDIT2:
http://www.rezmason.net/blog/caching-timeline-objects-in-flash This appears to be the problem but doesn’t give a solution. This screensaver could run up to 6 hours a day, at the moment it exits after 2.
OK sorted the problem. It appears removing images towards the end of an animation and then looping the animation causes them to be added to memory repeatedly. Images are now either made invisible or moved off stage towards the end so they are reused.