Pano2vr embeded flash with load/unload button in AS3

Q&A about the latest versions
Post Reply
minskonair
Posts: 2
Joined: Sun May 17, 2009 4:24 pm

Hello
I try since 5 days to make working load and unloading a pano2vr .swf with 2 buttons without sucess
I have no idea how implement them
Usually i use that code to load and unload an external movie with button

Code: Select all

//360
var loader:Loader = new Loader();
var mcExternal:MovieClip;
mc360.visible=true;
visit_bt.addEventListener(MouseEvent.MOUSE_DOWN,swfIn);
function swfIn(e:Event):void {
loader.x=10;
loader.y=40;
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,swfIn);
mcExternal=loader.content as MovieClip;
	this.addChild(loader);
loader.load(new URLRequest("rotateTool.swf"));
	
}
btnUnload.addEventListener(MouseEvent.CLICK,unloadSwf);
function unloadSwf(e:MouseEvent):void {
	loader.unload();
	mcExternal=null;
	mc360.visible=true;
	}

But to make working with the PAno2vr its another deal
Didnt success to make it working with the Pano2vr AS3 Api following

Code: Select all

import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
var loader:Loader;
loader = new Loader();
var url:String = "park.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'
	vr.isFlash10=false; // Disable Flash 10 rendering if the container is Flash 9
}

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(200,100); // resize the window
		vr.pano.setWindowPos(200,200); // 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
and for unload

Code: Select all

//If you like to remove the panorama use the following code:

vr.pano.cleanup();
removeChild(vr);

I really need help to make the load and unload button working in AS3
Thanks
minskonair
Posts: 2
Joined: Sun May 17, 2009 4:24 pm

i put the code for my button here replacing the code

Code: Select all

addEventListener( Event.ENTER_FRAME , initPanorama);
by
visit_bt.addEventListener(MouseEvent.MOUSE_DOWN, initPanorama);
The swf is still loaded directly on the stage in the wrong place but
when i push the button the swf move to the right place on the stage ...
SO THE BUTTON WORKS but need to stop the direct load
Its all what i success to do
need help
thanks
Post Reply