PDA

View Full Version : How to acess a hotspot's loaded movie instance?


chrisrauh
01-31-2008, 09:40 PM
I sent this email to Denis but it just ocurred to me that people on the forum might know the answer. Here it is:

I still have some issues:

1 - communication between hotspots

How can I communicate between the hotspots?

Is there a preferred way of doing that? Is there some way to share data through the pano object?

The way I was doing that was using a singleton in as2 on the hotspot movies. However, because I switched to as3 to do the xml parameter solution this does not work anymore because of the diff way the classloader works (each loaded hotspot has an instance of the singleton class). I need to access some shared variable on the loading class, the pano being the only one I know about.

Something like this:

hotspots = Object(loaderInfo,loader).hotspots;
sharedObject = hotspots,getPano().getSharedObject();

2 - how to access the instance loaded into a hotspot (and thus its members and fields)?

When I use this code to retrieve a hotspot:

hotspots = Object(loaderInfo,loader).hotspots;
hotspot = getSpot("someName");

I get a wrapper object (hotspotParams or something like that). That I can call its methods to retrieve values about the hotspots, as in:

radiance = hotspot.getParam("radiance");

Now, the clip that was loaded into a hotspot implements a certain class, let's say:

class Dog extends MovieClip {
public function bark():void { trace("bark"); };
}

How can I call the Dog.bark().method from another hotspot. Something like:

hotspots = Object(loaderInfo,loader).hotspots;
dogHotspot = getSpot("dog1");
var someDog : Dog = Dog(dogHotspot.getLoadedAsset());
someDog.bark();

Could you please shed some light on the above?

zleifr
02-01-2008, 05:28 AM
Hi Chris,

You certainly ask the hard questions! There must be a direct call that would get you into the hotspot and able to access it's methods and variables, etc. But I don't know it. However, I can tell you that localconnection would allow you to communicate between objects and get everything done that you need to be able to do. The up side to that is that it doesn't rely at all on anything in FPP. You set up both sides of the localconnection in your two hotspots, and you've got everything you need. I'd suggest reading up on it.

If you must go with direct calls, the only thing I could suggest, that I suspect you've already found is the describeType command to go looking around in the hotspots object.

Zephyr

zleifr
02-01-2008, 05:51 AM
Ok, I just had another idea about how to do it. This would allow you to use direct calls (i.e. no localconnection): Use a plugin as your "shared" object.

You already have the address of the hotspots object from the hotspot.
-hotspot.getPano() gets you the pano object.
-pano._parent is the panoController object(or panoMain, or panorama as it is variously known).
-panoController.externals.myPlugin gets you a plugin

So what you need to do is work your way up that chain from each hotspot, defining the variable, and then you can "register" your all the methods of your hotspots with the plugin to call the method of another hotspot, and pass information back and forth via the plugin.

Hope that helps. Please share how you solve this. This is one area of FPP that I could learn more about.

Zephyr

chrisrauh
02-04-2008, 12:55 PM
I received this reply from Denis:

1. you can use hotspots.getSpot("spotName").movie (or you can use some global variables as references)
2. you can use hotspots.getSpot("spotName").movie :) It's a link to Loader of your loaded movie.

zleifr
02-05-2008, 03:06 PM
Fabulous, good to know.

Zephyr

clodomi
03-04-2008, 01:44 PM
I tried to send a global variable from one swf hotspot to an other one with ActionScript 3 !
The variable works inside a hotspot, but the other one can't read it !
What's the path to do that in AS 3 ?
Any help will be welcome :)