PDA

View Full Version : How to access attributes on hotspots?


chrisrauh
01-29-2008, 07:15 AM
After posting the previous question, I realized that another thing I would like to do is access the attributes of a hotspot in the hotspot itself.

On the simple compass tutorial (http://flashpanoramas.com/forum/showthread.php?t=390&highlight=compass), jaaaab uses this call to get an specifically named hotspot:

// get link to deltarotation hotspot
deltaRotation = hotspots.getSpot('deltarotation');

and then this code to change the rotation of another specific and previously named hotspot:

// setting fov new rotation:
hotspots.execute("fov.rotation="+fovRotation);

The problem with this is that the names "deltarotation" and "fov" are statically declared on the config.xml and the loaded swfs need to know these names. This creates an unnecessary dependency.

This is particularly unnecessary since the "fov" swf is actually the one that contains the clip that is calling this code.

I would prefer that each swf had a way to access the hotspot that it's associated with, such as:

this.asHotspot().rotation = fovRotation;

Is this possible? What is the best practice to do something like this?

I've noticed that the PanoramaPlayer is targetted to end users and instead of implementing and exposing an API, it hides the functionality on the config xml file - which is not well documented btw. I would urge the developers to please expose the API so that developers can use the player like any other library.

Yours,

Christian

Trausti Hraunfjord
01-29-2008, 07:28 AM
Welcome Christian.

HERE (http://www.google.com/search?hl=en&q=%22API%22+site%3Aflashpanoramas.com&btnG=Google+Search)you might find something of interest, and yes, there is need for more info on the functions.

zleifr
01-30-2008, 02:07 PM
Hi Christian,

You are right, the API is not super well documented, but there is a LOT of information floating around. I believe that this is what you are looking for (note this line: hotspot = loaderInfo.loader.hotspot;):

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.tilt=30,1200,elastic ;");

// flv player uses dynamic sound channel, use timer to bind it to panorama soundTransform.
sTimer = new Timer(50);
sTimer.addEventListener("timer", copyParams);
sTimer.start();

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

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

The above comes straight from the source of flvplayer.swf. I suggest you take a look at it, and you should be able to get all the information you need.

Zephyr