I'm using the code below to unload & load vrs from a .swf but it's not releasing the vr from memory. The code in the function removeCurrentVR does the job when a single vr is loaded in a container but doesn't work as I've used it below.
Does anyone know why this is(n't) happening?
Thanks in advance,
MrT
Code: Select all
// enable retailer buttons
berg_l4.addEventListener(MouseEvent.MOUSE_DOWN,removeCurrentVr);
berg_l4.addEventListener(MouseEvent.MOUSE_UP,go_bergl4);
berg_m2.addEventListener(MouseEvent.MOUSE_DOWN,removeCurrentVr);
berg_m2.addEventListener(MouseEvent.MOUSE_UP,go_bergm2);
//define retailer functions
function removeCurrentVr(e:Event):void {
if (vr.pano) {
vr.pano.bmpTile[0].dispose();
vr.pano.bmpTile[0] = null;
vr.pano.bmpTile[1].dispose();
vr.pano.bmpTile[1] = null;
vr.pano.bmpTile[2].dispose();
vr.pano.bmpTile[2] = null;
vr.pano.bmpTile[3].dispose();
vr.pano.bmpTile[3] = null;
vr.pano.bmpTile[4].dispose();
vr.pano.bmpTile[4] = null;
vr.pano.bmpTile[5].dispose();
vr.pano.bmpTile[5] = null;
loader.mouseChildren = false;
vr.pano.cleanup();
removeChild(loader);
vr.pano = null;
loader.unloadAndStop();
}
}
function go_bergl4(e:Event):void {
var loader:Loader;
loader = new Loader();
var url:String="mp3.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
}
function go_bergm2(e:Event):void {
var loader:Loader;
loader = new Loader();
var url:String="mp6.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
}