This is getting a bit off topic now...
Actually what I want to do is connecting two panoramas with an animation that is not panoramic. So I want to unload the current pano by clicking a hotspot and load another SWF which contains the animation and loads the new pano at the and of the animation.
I took a look at the other threads about AS3 Hotspot callbacks. But I am sorry I just didn't understand how to tell e.g. the hotspot with the id 1 to do anything.
I tried the following code:
Code: Select all
import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
var loader:Loader;
loader = new Loader();
var url:String = "pan_laden.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) {
// hotspot event
vr.pano.onClickQtHotspot=function(id:Number,title:String,url:String,target:String){
vr.pano.cleanup();
removeChild(vr);
var request:URLRequest = new URLRequest("pano_schrank.swf");
navigateToURL(request, "_self");
trace(id + title);
}
}
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(800,500); // resize the window
vr.pano.setWindowPos(0,0); // 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 here is what I get:
init panorama player
initHandler: [Event type="init" bubbles=false cancelable=false eventPhase=2]
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at preloader_showroom_2_fla::MainTimeline/finished_loading()
init skin
ReferenceError: Error #1065: Variable ImageRepository is not defined.
at flash.system::ApplicationDomain/getDefinition()
at PanoCube/nextPanoLoaderInit()
I am using AS3 the first time for this project so maybe it's just a syntax problem.
Best