I'm (still!) re-making my home page in flash. It shows thumbnails which open the corresponding panorama in a central area of the page. I've noticed the the first time you load a panorama it runs smoothly but each panorama you load afterwards gradually scrolls less and less smoothly.
After search these pages, I've narrowed the problem down to memory usage building up each time a new panorama is loaded. I've confirmed this by opening Task manager and viewing the memory usage stats. It goes up by about 30MB with each pan you load.
The panoramas load via a container swf which has the following code in frame 1
Code: Select all
import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
var loader:Loader;
loader = new Loader();
var url:String="mp10.swf";
var urlReq:URLRequest = new URLRequest(url);
var vr:MovieClip; // panorama movieclip
// This is done after the swf is loaded.
function finished_loading (e:Event) {
}
function initHandler(event:Event):void {
trace("initHandler: " + event);
vr = MovieClip(loader.content); // cast 'DisplayObject' to 'MovieClip'
}
function initPanorama(e:Event) {
// check if the panorama object is available and initialize it
if ((vr!=null) && (vr.pano!=null)) {
removeEventListener( Event.ENTER_FRAME , initPanorama);
vr.pano.setWindowSize(900,412); // resize the window
vr.pano.setWindowPos(0,63); // reposition
}
}
// call initPanorama every frame
addEventListener( Event.ENTER_FRAME , initPanorama);
// Tell the loader to call 'finished_loading' after the swf is loaded.
loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, finished_loading);
// Tell the loader to call 'initHandler' after the swf is initialized.
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
loader.load(urlReq);
addChild(loader); // add your swf directly to the stage
Code: Select all
stop();
close.addEventListener(MouseEvent.CLICK,close_pano);
function close_pano(e:Event):void {
removeChild(loader);
gotoAndStop(3)
}
full.addEventListener(MouseEvent.CLICK,close_pano_and_full);
function close_pano_and_full(e:Event):void {
removeChild(loader);
gotoAndStop(4)
}
and frame 4:
Code: Select all
import flash.net.URLVariables;
import flash.net.URLRequest;
stop();
var link:URLRequest = new URLRequest("http://www.visual360.co.uk/southamerica/machupicchu/mp10_full.html");
navigateToURL(link);
Any suggestions as to how I can sort this out? I haven't looked into using skins as going down this route wouldn't permit navigation around my portfolio from my initial flash homepage.
Thanks in advance,
Nick