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;
}
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
Code: Select all
//If you like to remove the panorama use the following code:
vr.pano.cleanup();
removeChild(vr);
Thanks