Hi,
I am testing Pano2VR and would like to know how can I trap hotspots from a calling flash AS2 document. This is what I do:
I am running an actionscript application, which loads a pano generated by Pano2VR as a Flash8 SWF, in a movieclip container. This works fine, but then I need to know in the parent application, when the used clicks on a hotspot, because in this case I don't want to load a URL, but instead I need to take some other action, internal to the parent.
Is there a listener I can use?
Any hints? or any doc I should read to find the answer?
thanx
Silvano
trapping hotspots in Flash
You can set a function "onClickQtHotspot" that gets the following parameters: id(=Hotspot number), title, url, target. Something like
should do the trick.
Code: Select all
<movieclip>.pano.onClickQtHotspot=function(id,title,url,target) {
// do something
}
MfG, Thomas
Currently only in my source code and on this forum.... but I am preparing a document with all the collected wisdom.
MfG, Thomas
Thomas,
thanx again, well if you're the developer, then you will probably receive the email I just sent to support on this. I am really stuck on a rather project with a deadline. All I need is a method/handler to get out of a pano with info on a hotspot click. I tried the one you gave me but it doesn't seem to work. Perhaps I need a little more detailed example...
cheers
Silvano
thanx again, well if you're the developer, then you will probably receive the email I just sent to support on this. I am really stuck on a rather project with a deadline. All I need is a method/handler to get out of a pano with info on a hotspot click. I tried the one you gave me but it doesn't seem to work. Perhaps I need a little more detailed example...
cheers
Silvano
Today I had the chance to test it and it works for me as expected. Maybe I should have mentioned that you need to apply this handler after the panorama is initialized so the routine needs to be in the onInit event handler. Here is my code:
Code: Select all
var vr:MovieClip = _root.createEmptyMovieClip("vr", 1);
vr._lockroot=true;
var myLoader = new MovieClipLoader();
var myListener = new Object();
myListener.onLoadInit = function () {
// callback after the pano is fully loaded
vr.pano.onClickQtHotspot=function(id:Number,title:String,url:String,target:String)
{
// add your code here!
trace(id + "," + title);
}
};
myLoader.addListener(myListener);
myLoader.loadClip("mypanorama.swf", vr);
MfG, Thomas
The code is a bit more complicated because you need to cast the loaded object to a movie clip but most of the properties (if already implemented, e.g. point hotspots as in the tour demo are currently missing) work the same as with AS2. Here is a sample code for AS3:
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;
// This is done after the swf is loaded.
function finished_loading (e:Event) {
vr.pano.onClickQtHotspot=function(id:Number,title:String,url:String,target:String)
{
// add your code here!
trace(id + "," + title);
}
}
function initHandler(event:Event):void {
trace("initHandler: " + event);
vr = MovieClip(loader.content); // cast 'DisplayObject' to 'MovieClip'
// vr.pano.setWindowSize(200,100);
}
// Tell the loader to call 'finished_loading' after the swf is loaded.
loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, finished_loading);
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
loader.load(urlReq);
addChild(loader); // add your swf directly to the stage
MfG, Thomas
Thomas,
thanx for the code and sorry for the late post. Just got to test your code, but had no luck. I restructured it as a class, and just instanced it in the document class of an empty fla. The pano loads, but I get a lot of scary runtime errors:
thanx for the code and sorry for the late post. Just got to test your code, but had no luck. I restructured it as a class, and just instanced it in the document class of an empty fla. The pano loads, but I get a lot of scary runtime errors:
- initHandler: [Event type="init" bubbles=false cancelable=false eventPhase=2]
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@132eae61 to flash.display.MovieClip.
at panorama/::initHandler()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at panorama/::finished_loading()
ReferenceError: Error #1056: Cannot create property panomask on panorama.
ReferenceError: Error #1056: Cannot create property prebar on panorama.
ReferenceError: Error #1056: Cannot create property pretxt on panorama.
Code: Select all
package {
import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
public class panorama extends MovieClip {
var loader:Loader = new Loader();
var url:String = "CLIPS/PANOS/VP_B4S2.swf";
var urlReq:URLRequest = new URLRequest(url);
var vr:MovieClip;
public function panorama() {
// Tell the loader to call 'finished_loading' after the swf is loaded.
loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, finished_loading);
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
loader.load(urlReq);
addChild(loader); // add your swf directly to the stage
}
// This is done after the swf is loaded.
function finished_loading (e:Event) {
vr.pano.onClickQtHotspot=function(id:Number,title:String,url:String,target:String) {
// add your code here!
trace(id + "," + title);
}
}
function initHandler(event:Event):void {
trace("initHandler: " + event);
vr = MovieClip(loader.content); // cast 'DisplayObject' to 'MovieClip'
// vr.pano.setWindowSize(200,100);
}
}
}
Hmm...... Did you export a Flash 8 or Flash 9 pano? I guess the pano is still AS2/AVM1/Flash 8 because otherwise I can not understand this error message.
MfG, Thomas
Thomas,
you were right, I had mixed up folders and was running this code on a Flash8 version of the pano. However... this is what I get when I run my application of a Flash9 pano:
and here is my loadPano:
The Panorama class is instanced by an FLVPlayback class that runs into a cuePoint, which holds the name and parameters of the the pano to load. Here's how it's instanced:
Sorry it's a lot of code, but it's a huge application.
I must say that if I run just the code you gave me on a flash9 pano, it's all fine. It's just when I use it inside my Panorama class (i.e. not instanced directly by the FLA) that I get all that mess.
Can you make sense of those messages?
Thanx a million
Silvano
you were right, I had mixed up folders and was running this code on a Flash8 version of the pano. However... this is what I get when I run my application of a Flash9 pano:
Code: Select all
-- loadPano - loading : ../CLIPS/PANOS/VP_B4S.swf
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 PanoCube/setup_cube()
at PanoCube/init_cube()
at PanoCube/init()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at PanoCube/setup_cube()
at PanoCube/::init_cubefaces()
at PanoCube/init_faces()
at flash3dpano_empty_fla::MainTimeline/doEnterFrame()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at PanoCube/setup_cube()
at PanoCube/::init_cubefaces()
at PanoCube/init_faces()
at flash3dpano_empty_fla::MainTimeline/doEnterFrame()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at PanoCube/setup_cube()
at PanoCube/::init_cubefaces()
at PanoCube/init_faces()
at flash3dpano_empty_fla::MainTimeline/doEnterFrame()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at PanoCube/setup_cube()
at PanoCube/::init_cubefaces()
at PanoCube/init_faces()
at flash3dpano_empty_fla::MainTimeline/doEnterFrame()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at PanoCube/setup_cube()
at PanoCube/::init_cubefaces()
at PanoCube/init_faces()
at flash3dpano_empty_fla::MainTimeline/doEnterFrame()
-- zoomOn called.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at PanoCube/setup_cube()
at PanoCube/::init_cubefaces()
at PanoCube/init_faces()
at flash3dpano_empty_fla::MainTimeline/doEnterFrame()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at PanoCube/setup_cube()
at PanoCube/::init_cubefaces()
at PanoCube/init_faces()
at flash3dpano_empty_fla::MainTimeline/doEnterFrame()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at PanoCube/setup_cube()
at PanoCube/::init_cubefaces()
at PanoCube/init_faces()
at flash3dpano_empty_fla::MainTimeline/doEnterFrame()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at PanoCube/setup_cube()
at PanoCube/::init_cubefaces()
at PanoCube/init_faces()
at flash3dpano_empty_fla::MainTimeline/doEnterFrame()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at PanoCube/setup_cube()
at PanoCube/::init_cubefaces()
at PanoCube/init_faces()
at flash3dpano_empty_fla::MainTimeline/flash3dpano_empty_fla::frame10()
Code: Select all
package {
import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.MovieClip;
public class Panorama extends MovieClip {
public var file: String; // filename where pano is
public var pan: Number; // pan positioning on open
public var tilt: Number; // tilt positioning on open
public var fov: Number; // field of view on open
public var rot: Number; // rotation soon after open
public var mc: MovieClip;
public var texto: String;
public var type: String; // XP or VP
var loader:Loader = new Loader();
var url:String;
var urlReq:URLRequest = new URLRequest(url);
var vr:MovieClip;
public function Panorama (infoObject:Object) {
trace ("Panorama : "+infoObject.name);
panoData (infoObject);
loadPano();
}
private function panoData(infoObject:Object):void {
if (infoObject.parameters != undefined) {
for (var paramName:String in infoObject.parameters)
{
trace("-- > " + paramName + ": " + infoObject.parameters[paramName]);
switch (paramName) {
case "FILE" :
file = infoObject.parameters[paramName];
urlReq.url = Vars.pathPano+file+".swf";
break;
case "PAN" :
pan = infoObject.parameters[paramName];
break;
case "TILT" :
tilt = infoObject.parameters[paramName];
break;
case "FOV" :
fov = infoObject.parameters[paramName];
break;
case "ROT" :
rot = infoObject.parameters[paramName];
break;
case "TEXT" :
texto = infoObject.parameters[paramName];
break;
}
}
}
}
private function loadPano() {
trace("-- loadPano - loading : "+urlReq.url);
// Tell the loader to call 'finished_loading' after the swf is loaded.
loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, finished_loading);
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
loader.load(urlReq);
addChild(loader); // add your swf directly to the stage
// This is done after the swf is loaded.
function finished_loading (e:Event) {
vr.pano.onClickQtHotspot=function(id:Number,title:String,url:String,target:String) {
// add your code here!
trace("finished_loading pano: "+id + "," + title);
}
}
function initHandler(event:Event):void {
trace("initHandler: " + event);
vr = MovieClip(loader.content); // cast 'DisplayObject' to 'MovieClip'
// vr.pano.setWindowSize(200,100);
}
}
}
}
Code: Select all
public function processCue(infoObject:Object):void {
trace("-- processCue:");
switch (infoObject.name) {
case "TEXTZOOM" :
var texzoom:TextPack = new TextPack();
texzoom.zoomObject(infoObject);
break;
case "VP" :
Vars.finiteState = "VP";
new Panorama(infoObject);
break;
case "XP" :
Vars.finiteState = "XP";
break;
case "REPERE" :
var texnav:TextPack = new TextPack();
texnav.navText(infoObject);
break;
default :
trace(" --> unknown cuepoint");
}
}
I must say that if I run just the code you gave me on a flash9 pano, it's all fine. It's just when I use it inside my Panorama class (i.e. not instanced directly by the FLA) that I get all that mess.
Can you make sense of those messages?
Thanx a million
Silvano
Thomas,
forget my last reply. I gave up on porting the application to AS3. I spent over a month and wrote over 2000 lines of code in 12 packages and still can't figure out how to make it all work. I have a deadline in 4 weeks and need to get it running, so I'll just finish it off in AS2, which I know well, and then will think about converting, if ever, next year.
I will come soon to haunt you again, 'coz I'm still having problems in AS2, displaying the pano at the right size. It seems that it ignores my mc._width and _height. I'll submit a new post for that.
thanx
Silvano
forget my last reply. I gave up on porting the application to AS3. I spent over a month and wrote over 2000 lines of code in 12 packages and still can't figure out how to make it all work. I have a deadline in 4 weeks and need to get it running, so I'll just finish it off in AS2, which I know well, and then will think about converting, if ever, next year.
I will come soon to haunt you again, 'coz I'm still having problems in AS2, displaying the pano at the right size. It seems that it ignores my mc._width and _height. I'll submit a new post for that.
thanx
Silvano