Forums  

Go Back   Forums > Talk > General FPP Discussion

Reply
 
Thread Tools Display Modes
  #1  
Old 06-03-2008, 01:32 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default How to talk or listen to Hotspots in AS3?

How do I talk or listen to hotspots in AS3?

I have a pano embedded into a flash movie and it works fine.

But - I need to interact with the hotspots in both directions...

I'm using this right now - but it's not working in the listen direction. I am able to change the state of a hotspot from AS3, however. How do I get the listen direction to work?

Here's my code:
spotObject = panorama.externals.hotspots.hotspots_obj.getSpot(" spot_id");
spotObject.addEventListener(MouseEvent.MOUSE_OVER, onOverFunction);

function onOverFunction(event:MouseEvent) {
//do something here..//
//Like make a movieclip react as a result of the pano hotspot mouseover//
}

Also - I have placed this at the top of my AS3 code:

import flash.external.*;
import flash.display.InteractiveObject.*;
import flash.net.*;
import flash.events.*;

What am I missing???
Reply With Quote
  #2  
Old 06-03-2008, 03:17 PM
zleifr's Avatar
zleifr zleifr is offline
Senior Member
 
Join Date: May 2007
Posts: 609
Downloads: 0
Uploads: 0
Default

The object returned by hotspots.getSpot("id") is not the DisplayObject associated with that spot. I believe that in order to put an event listener on it, the object you need is at: hotspots.getSpot("id").movie

Take a look at flvplayer.fla, since it does EXACTLY this, and just reuse its code.

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
  #3  
Old 06-03-2008, 04:10 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

AWESOME! I'll try that.

I'll post my results...
Reply With Quote
  #4  
Old 06-03-2008, 05:37 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

So Zephyr... Let me make sure I understand correctly...

Here's my code (with the movie path added on the end as you suggested):

spotObject=panorama.externals.hotspots.hotspots_ob j.getSpot("mySpotName").movie;

spotObject.addEventListener(MouseEvent.MOUSE_OVER, onOverFunction);

And here's my function being called:

function onOverFunction(event:MouseEvent) {
myGraphicWhatever.visible=true;
}


From this, I want to detect a mouseOver event on the hotspot called "mySpotName" and use that trigger to enable a graphic (so called myGraphicWhatever) in my flash movie that the pano is embedded within.

This code as it is, still doesn't respond to the mouseOver event.

What I am I doing wrong?
Reply With Quote
  #5  
Old 06-03-2008, 06:20 PM
AxeCrazy AxeCrazy is offline
Member
 
Join Date: May 2008
Posts: 45
Downloads: 0
Uploads: 0
Default

i also tried to use a normal image box (.jpg) in the pano to hook up a mouseover.
That did not work for me also.
So i first made a swf which i loaded into the pano (at layer_10 orso) called panointerface.
then i declared a button like so.
<box id="abutton" url="images/agraphic.png" blockMouse="1"

onOver="external.panointerface.mouse=over"
onOut="external.panointerface.mouse=out" />

i the pano interface a property was set on which i could do the mouseover/mouseoff.
Worked well, but not that great :P

Next i created a swf which loaded a graphic base on the box id
something like
<<spot id="button1" url="panobutton.swf" />


in the panoObject class somthing like

public function PanoObject() {
trace("new PanoObject");
loaderInfo.addEventListener(Event.INIT, initHandler);
}

public function initHandler(panoMain:Object=null) {
movie = (loaderInfo.loader as Object).movie;
// get link to hotspot control object:
hotspot = (loaderInfo.loader as Object).hotspot;
// get link to hotspots plugin object:
hotspots = (loaderInfo.loader as Object).hotspots;
// get link to pano object:
pano = hotspots.getPano();

var request:URLRequest=new URLRequest((hotspot.id+"pngl");
_loader.load(request);
addChild(_loader);
_loader.addEvenListener(MouseEvent.MUSE_OVER,doOve r);
}

the movie, hotspots and hotspot are locasl Objects
_loader is a Loader.

Hope this helps....
this works as i what it to work
Reply With Quote
  #6  
Old 06-03-2008, 09:47 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

I think I see what you're doing - but since actionscript should be able to communicate with actionscript - I shouldn't need to do anything with additional plugins, and bringing in code via swf's loaded as hotspots...

If I can just find the path to the components, I should be able to reference them from the main actionscript code in the flash file that has the pano embedded into it...

I did a simple test where I can control the visibility of hotspots in the pano from the main movie by using this syntax:

spotObject=panorama.externals.hotspots.hotspots_ob j.getSpot("spot_ID");
spotObject.alpha=0;

But - when I use that to "listen" for a hotspot action, I get nothing. I've tried these other ways of referencing them too - but still no luck:

spotObject = panoController.externals.hotspots.getSpot("spot_ID ");

AND

spotObject = panorama.externals.hotspots.getSpot("spot_ID");

AND

spotObject = panorama.externals.hotspots.getSpot("spot_ID").mov ie;

I've declared (and not declared - tried both ways) spotObject, hotspots, and hotspot as variables like this:

var spotObject:Object;
etc...

I've also setup my listener for a simple mouseOver for a given hotspot as follows:
spotObject.addEventListener(MouseEvent.MOUSE_OVER, onOverFunction);

function onOverFunction(event:MouseEvent) {
graphicThingy.visible=true;
}


What am I doing wrong?
Reply With Quote
  #7  
Old 06-03-2008, 10:48 PM
AxeCrazy AxeCrazy is offline
Member
 
Join Date: May 2008
Posts: 45
Downloads: 0
Uploads: 0
Default

if the hotspots element has mouseChildren set to true, you will not get the event, perhaps you should set this property in the box definition.
Reply With Quote
  #8  
Old 06-03-2008, 11:23 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

Well - the default for that setting is true according to the Flash help documents.

I tried setting it anyway as follows just for fun:

spotObject = panorama.externals.hotspots.getSpot("spot_ID").mov ie;
spotObject.mouseChildren = true;

spotObject.addEventListener(MouseEvent.MOUSE_OVER, onOverFunction);

function onOverFunction(event:MouseEvent) {
graphicThingy.visible=true;
}

Unfortunately, still nothing...

Is there something that I could be doing wrong at a higher level with regard to overall flash movie? I've basically taken the embedPano.fla file and stripped out the buttons, etc and just left in the code for loading in the pano and XML data. I then added the lines above, a graphic object that's assigned an instance name that we just call graphicThingy for now, and then added object variable declarations for the spotObject.

For fun, I've also pulled in the delay routines that were in one of the other tamplates that wait for hotspots to load before doing anything. I may not be doing that right either...

I'm hoping to find someone that's already done this that can point me in the right direction. I can't believe that I'm the first to try it.
Reply With Quote
  #9  
Old 06-04-2008, 12:03 AM
AxeCrazy AxeCrazy is offline
Member
 
Join Date: May 2008
Posts: 45
Downloads: 0
Uploads: 0
Default

in my As this reacts to a eventlistener
hotspot.loader.addEventListener(MouseEvent.MOUSE_O VER,roep);

so perhaps you should also use loader iso movie.
Reply With Quote
  #10  
Old 06-04-2008, 12:36 AM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

Cool - so knowing that you have it working, how do you refer to your hotspots? Is it one of the methods I posted above - and if so, which one?

Do I need the object declarations for hotspots, hotspots, and globalHotspot?
Do I need the function that waits for hotspots to load?

Please note that I'm still learning AS3 (and am new to AS in general), so I need a little more spoon feeding if you're willing...

Would you be willing to post an FLA example that allows communication with hotspots in an embeded pano? I'll replace the pano with my own and stuff some image into it for a hotspot - I just need to see the AS3 code since I'm apparently missing something somewhere...

I've tried adding "loader" as you described and it still didn't do anything. I'm not getting any errors either - so Flash is happy which leads me to believe that there's just a missing piece somewhere that keeps AS3 from gaining access to the embedded pano...

Thanks so much for the help so far!
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 06:06 PM.


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