Forums  

Go Back   Forums > Talk > General FPP Discussion

Reply
 
Thread Tools Display Modes
  #21  
Old 06-04-2008, 09:22 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

You're right...

I think our posts crossed over the wire...

However, it doesn't look like I'm setting the timer right...

I'm looking up the syntax now - but I have this now (near the top):

waitTimer = new Timer(50);
waitTimer.start();

Is that all I need to do?
Reply With Quote
  #22  
Old 06-04-2008, 09:30 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

Just for fun - here's my full code - again using the embedPano.fla library and stage objects, some external pano, and at least one hotspot loaded in with my XML file...

var movie:Sprite;
var hotspot:Object;
var hotspots:Object;
var spotObject:Object;

var panorama:MovieClip;
var loader:Loader = new Loader();
loader.load(new URLRequest("files/pano0.swf"));
addChild(loader);

waitTimer = new Timer(50);
waitTimer.start();



loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, loadComplete);


//Load the embedded pano...
function loadComplete (e:Event) {
swapChildren(loader, border);
panorama = loader.content;
panorama.setArea(100,50,400,300);

panorama.loadPanorama("panoName=images/mypanofile&xml_file=mypano.xml");

loaderInfo.addEventListener(Event.INIT, initHandler);

function initHandler (event:Event) {

if (loaderInfo.loader!=null) {
// get link to hotspot sprite:
movie = loaderInfo.loader.movie;

// get link to hotspot control object:
hotspot = loaderInfo.loader.hotspot;
// example how to change hotspot's properties:
// hotspot.saturation = -1;
// hotspot.rotation = 45;


// get link to hotspots plugin object:
hotspots = loaderInfo.loader.hotspots;
// example how to use it:
// hotspots.execute("pano.pan=45,1000,elastic;pano.ti lt=30,1200,elastic;");

// add your own event listener:
//movie.addEventListener(MouseEvent.CLICK, doClick);

// define remove function (will fire on unload)
loaderInfo.loader.remove = remove;

//wait for Hotspots plugin to load before arming the listeners
if (panorama.externals.hotspots!=null) {
waitTimer.stop();
waitTimer = null
hotspots = panorama.externals.hotspots;
hotspots.stage.addEventListener(MouseEvent.MOUSE_O VER, onOverFunction);
}

function onOverFunction(event:MouseEvent) {
// make sure we've got the right object
obj = event.target;
while (!obj.hasOwnProperty("attributes")) {
if (obj.hasOwnProperty("parent")) {
if (obj is Stage) { return; }
obj = obj.parent;
} else {
return;
}
}
if (obj.attributes.id =="spot..box_id...name..from..XML..file") {
down_btn.visible=false;
}
}
}
}
}

Did I miss something? It still doesn't work...

I expect that when I move my mouse over the hotspot in the pano, the down_btn graphic instance should disappear. That's presently not happening...
Reply With Quote
  #23  
Old 06-04-2008, 10:56 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

Just figured out how to use Firebug in conjunction with the ExternalInterface.call method to trace things out while in the browser... like this:

ExternalInterface.call( "console.log" , "Pano loaded...");

With that, I'm able to see how far the code is getting and see where it's getting stuck...

Presently, it looks like it never meets this condition to run the rest of the if's and associated functions:

if (loaderInfo.loader!=null)...

Even with this inside of a function (initHandler) called by this listener:
loaderInfo.addEventListener(Event.INIT, initHandler);
...that function never gets called...

What's the right way to handle that so that the rest of my code will actually get executed?

For all I know, it may have been working all along and I've been on a wild goose chase just because of some other bogus move...
Reply With Quote
  #24  
Old 06-05-2008, 01:23 AM
zleifr's Avatar
zleifr zleifr is offline
Senior Member
 
Join Date: May 2007
Posts: 609
Downloads: 0
Uploads: 0
Default

Try exactly the below, and see if it works. If it doesn't, it is just a typo.

var movie:Sprite;
var hotspot:Object;
var hotspots:Object;
var spotObject:Object;

var panorama:MovieClip;
var loader:Loader = new Loader();
loader.load(new URLRequest("files/pano0.swf"));
addChild(loader);

loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, loadComplete);


function loadComplete (e:Event) {
swapChildren(loader, border);
panorama = loader.content;
panorama.setArea(100,50,400,300);

panorama.loadPanorama("panoName=images/mypanofile&xml_file=mypano.xml");

waitTimer = new Timer(50);
waitTimer.addEventListener(TimerEvent.TIMER, waitHotspots, false, 0, true);
waitTimer.start();

}

function waitHotspots (event:Event) {
if (panorama.externals.hotspots!=null) {
// wait for XML parsing
if (panorama.externals.hotspots.ready) {
waitTimer.stop();
waitTimer = null
hotspots = panorama.externals.hotspots;
pano = panorama.pano;
// trace( describeType(hotspots) );
startPlugIn();
}
}
}

function startPlugIn () {
hotspots.stage.addEventListener(MouseEvent.MOUSE_O VER, onOverFunction);
}

function onOverFunction (event:MouseEvent) {
// make sure we've got the right object
var obj:Object = event.target;
while (!obj.hasOwnProperty("attributes")) {
if (obj.hasOwnProperty("parent")) {
if (obj is Stage) { return; }
obj = obj.parent;
} else {
return;
}
}
if ( obj.attributes.id == "down_btn" ) { hotspots.execute("down_btn.visible=0"); }
}
__________________
Zephyr Renner - AdvancedVirtualTours.com - zleifr @t yahoo

Improving the panoramic one mighty fine plug-in at a time: http://www.flashpanos.com
Reply With Quote
  #25  
Old 06-05-2008, 02:24 AM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

Dude - you ROCK!

I had to change a couple of things in the actual function that's doing things (since I'm doing things on the stage not in the pano in response to the hotspot actions)...

Anyway - I was SO close!

I didn't know about this syntax:
if (panorama.externals.hotspots.ready)

Sure would be nice to have some of that documented somewhere!

Anyway, this has been a great learning experience with AS3 and I thank you so much for the help!
Reply With Quote
  #26  
Old 06-09-2008, 01:50 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

OK - this is working great... but I have one more question:

I can send commands to hotspots from AS3 just fine using this syntax:
hotspots.execute("pano.pan....whatever")

But I've just discovered that if I have a "function" of several commands setup in my XML file for a given hotspot and then try to call that function by name in my AS3 - it doesn't work!

Here's a simplified XML example:
onClick="spotFocus()"
spotFocus="spot1.visible=0;someotherspot.visible=0 ;pano.qualityStatic=low;rotate_me"
rotate_me="pano.pan=0,500;etc - other pano movements..."

This is really simplified - but basically the functions that work from the XML alone work fine. But when I try to call them from within AS3, nothing happens.

Any ideas how to overcome this?
Reply With Quote
  #27  
Old 06-09-2008, 04:41 PM
cheathamlane cheathamlane is offline
Senior Member
 
Join Date: Mar 2007
Location: California, USA
Posts: 773
Downloads: 0
Uploads: 0
Default

Quote:
Originally Posted by djsegler View Post
I didn't know about this syntax:
if (panorama.externals.hotspots.ready)

Sure would be nice to have some of that documented somewhere!
Hey djs:

You might check out flashpanos.com, where Zephyr and I have been putting a lot of knowledge. All are encouraged to add their own.

Cheers,
__________________
Patrick
http://patrickcheatham.com
Reply With Quote
  #28  
Old 06-09-2008, 05:55 PM
zleifr's Avatar
zleifr zleifr is offline
Senior Member
 
Join Date: May 2007
Posts: 609
Downloads: 0
Uploads: 0
Default

hotspots.execute("spot_id.function_name") if the XML function is in a hotspot

or

hotspot.execute("global.function_name") if it is in global.

Zephyr
__________________
Zephyr Renner - AdvancedVirtualTours.com - zleifr @t yahoo

Improving the panoramic one mighty fine plug-in at a time: http://www.flashpanos.com
Reply With Quote
  #29  
Old 06-09-2008, 06:15 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

DOH!

Thanks!

-DJ
Reply With Quote
  #30  
Old 09-12-2008, 04:11 AM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

Time to dig up more dirt on this one...

After a hotspot.execute... how would I go about checking to see if it's actually done executing that "function" in the XML?

I have a project that occasionally hangs on the execute and I'd like to put in an error trap for that to improve reliability...
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 12:52 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.