embed panorama in flash with AS3
Posted: Wed Nov 11, 2015 10:39 pm
HI,
need help with AS3. I am trying to make responsive pano tour in flash professional CC. i have used AS3 code to embed panorama swf file from this site- http://ggnome.com/wiki/Flash_API_(Pano2VR)
and its working fine, but i want it to load when i click on a button and unload and close it on clicking on a close button.
Thanks
need help with AS3. I am trying to make responsive pano tour in flash professional CC. i have used AS3 code to embed panorama swf file from this site- http://ggnome.com/wiki/Flash_API_(Pano2VR)
Code: Select all
import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
var loader:Loader = new Loader();
var url:String = "panorama.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.x=50;
vr.y=50;
vr.pano.setWindowSize(400,300);
}
}
// 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
Thanks