can't setPan

Using Pano2VR/Object2VR SWF files with your own Flash projects
Post Reply
skaddi
Posts: 24
Joined: Thu Aug 20, 2009 2:24 pm

Hello to everyone.

i need some help setting the pan of a panorama to the next that is loaded.

What im doin so far:
I have multiple panos which are organized by a swf file. After one pano is loaded it is possible to load another one whis the same pan/tilt/fov. Everything works so far, but i have to delay the setPan etc. commands. If i call them instant in the "finished_loading" function, as suggested in the flash API, the pano isn't fully loaded/initialized and i get the TypeError: Error #1009
To fix that i have delay the set commands by 1 second. But this isn't a nice workaround.

So what i'm doin wrong?

This is my code without the delay:

*Edit

I copy pasted the flash AS3 PanoVR2.2 Code to flash and just added this line in the "finished_loading" function. (http://gardengnomesoftware.com/wiki/Pan ... script_3.0)

Code: Select all

function finished_loading (e:Event) {
		vr.pano.setPan(200);

}
I get the same result. Flash tells me that this is a zero link. (Do i call this line by a mouse up event, everything works fine)
skaddi
Posts: 24
Joined: Thu Aug 20, 2009 2:24 pm

Ok i found my mistake. I have to call vr.pano.setPan(200); at the initPanorama function. But that brings me to another quest.

Atm the initPanorama if loop runs via ENTER_FRAME Event all the time till true returns. So how can i start several panos by clicking on their buttons? So that i can switch over to the another and back again.. ?

/Edit

No, in this case i can not use the embed switch function
skaddi
Posts: 24
Joined: Thu Aug 20, 2009 2:24 pm

Thanks to my self, i've found the answer:

Code: Select all

import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;

var vr:MovieClip = new MovieClip;
var loader:Loader = new Loader();

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) {
	if (vr.pano!=null) {
		vr.pano.setWindowSize(200,100); // resize the window
		vr.pano.setWindowPos(50,0); // reposition
		removeEventListener( Event.ENTER_FRAME , initPanorama);
	}
}

function load_swf(evt:MouseEvent) {
	addEventListener( Event.ENTER_FRAME , initPanorama);
	loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
	loader.load(new URLRequest("mein pano.swf"));
	addChild(loader);
}

btn1.addEventListener(MouseEvent.CLICK,load_swf);
But this brings me again to another question. How to remove the pano completly

Code: Select all

vr.cleanup();
removeChild(loader);
isn't enough. vr is still not zero.
skaddi
Posts: 24
Joined: Thu Aug 20, 2009 2:24 pm

It could be so simple vr = null;

Thanks to zero support anyway...
Post Reply