View Full Version : How to access custom fields on hotspots?
chrisrauh
01-29-2008, 07:03 AM
Hi,
I have noticed that when you add an custom attribute to a <spot> element node, the PanoramaPlayer recognizes that and traces a "Custom field: <fieldname>" when loading the xml.
Is there a way to access such values?
Here is the scenario: I want to load the same swf for each hotspot, but pass an id for each hotspot through the config xml. This id will be shown on that movie.
Awaiting for an answer,
Christian
zleifr
01-30-2008, 02:16 PM
Hi Christian,
Yes you can access those custom fields, assuming you already have a link to the hotspots object (see flvplayer.fla for a guide on how to write a "smart-plugin" (a swf that is loaded into a hotspot)). This is the address:
hotspots.getSpot("id").getParam("customfieldname")
I believe that in the case of a "smart-plugin" hotspot.getParam("customfieldname") would also work, and you wouldn't need to know the id of the hotspot a priori.
By the way, based on your description of what you are trying to do, you might able to use the id of the hotspot as the id to display in the swf, and not have to duplicate the information with a custom field.
And on one final note, FPP is not very friendly to capital letters, so don't use them, at least when you are testing, because they will probably be transformed into lower case letters by the time you get them. Lost me a few hours with that particular problem.
Hope that helps.
Zephyr
tamleis
02-06-2008, 11:22 PM
zleifr,
My xml looks like this:
<box id="id" url="files/Cable_Info.swf" customfieldname="test" distorted="0" pan="94" tilt="31"/>
Where do I use:
hotspots.getSpot("id").getParam("customfieldname")
Would it be in my Cable_Info.swf file? or the main .swf that calls the pano?
I just want to be able to use the Custom Field "customfieldname" in my Cable_Info.swf file. How would I do that?
Thank you, your help is much appreciated.
zleifr
02-07-2008, 05:49 AM
Hi Tamleis,
where you use:
hotspots.getSpot("id").getParam("customfieldname")
depends on the relationship between the .swf and the FPP. Basically the question you need to be asking is how you are going to get hotspots to be a defined object, or what the "address" of hotspots is. The "address" of hotspots is different depending on whether you are dealing with a plugin (loaded on a layer), a smart plugin (loaded into a hotspot), or an embedPano style wrapper .swf. I don't know of what sort your cable_info.swf file is. Let me know and I can tell you. I believe that your main .swf file is a "wrapper" in which case the "address" of hotspots is panorama.externals.hotspots. BUT you may have to wait a bit after you load pano.swf before you can define hotspots, because immediately after loading hotspots won't have yet loaded.
Zephyr
psychospiller
02-07-2008, 02:13 PM
Hi zleifr,
is there a way using a similar technique to set the parameter ?
hotspots.getSpot("id").setParam("customfieldname")
Thanks
chrisrauh
02-07-2008, 03:22 PM
Not that I know of. However, you can use:
hotspots.getSpot("spotName").movie
to access the movieclip that was loaded into the hotspot and then access it's propeties and methods - you can use dynamic variables in the MovieClip class or by casting it into the class it implements where you could define a setVariable() method or something.
Christian
zleifr
02-08-2008, 03:07 AM
Hi Tamleis,
Sure, that is easy:
hotspots.execute("id.customfieldname=1");
tamleis
02-11-2008, 08:29 PM
Sorry I'm such a newbie. Let me try to explain..
Basically my xml contains:
<?xml version = '1.0'?>
<panorama>
<parameters>
layer_1 = files/hotspots.swf
</parameters>
<hotspots>
<global onLoad="alpha=0; alpha=1,1000">
<box id="id" url="files/Cable_Info.swf" customfieldname="test" distorted="0" pan="94" tilt="31"/>
</global>
</hotspots>
</panorama>
and I want to use the customfieldname variable in the Cable_info.swf file using ActionScript 3.0.
How do I access the customfieldname custom variable in my Cable_info.swf file.
tamleis
02-11-2008, 11:23 PM
In addition to my previous post.
In my swf that contains pano I do the following:
trace(panorama.externals.hotspots);
I get [object Hotspots]
When I try:
trace(panorama.externals.hotspots.getSpot("id"));
I get a "null".
Should trace(panorama.externals.hotspots.getSpot("id")); give me my Cable_Info.swf object?
chrisrauh
02-13-2008, 03:40 PM
Use:
to get spot attribute: panorama.externals.hotspots.getSpot("id").getParam("customfieldname");
to get spot movie: panorama.externals.hotspots.getSpot("id").movie
to get spot wrapper: panorama.externals.hotspots.getSpot("id")
tamleis
02-19-2008, 09:35 PM
OH MY GOD!!!
Thanks to all that have been trying to help me.
After days of banging my head on the keyboard finally find out that:
panorama.externals.hotspots.getSpot("id").getParam ("customfieldname");
Does not work with:
<box id="id" url="files/Cable_Info.swf" customfieldname="test" distorted="0" pan="94" tilt="31"/>
It has to be a <spot> not a <box> for it to work. So the following works:
<spot id="id" url="files/Cable_Info.swf" customfieldname="test" distorted="0" pan="94" tilt="31"/>
Does anyone know if this is true or am I just spit'n hot air?
cheathamlane
02-20-2008, 03:05 PM
I'll have to test on my end to confirm it, but it seems that it would be pretty obvious pretty quick (once you know what to look for... and now you do ;) ).
I'm having difficulty getting _any_ custom attributes from my presentation -- using ExternalInterface. I've had to resort to setting an invisible spot's rotation to a number, and watching that number from my external swf.
?
zleifr
02-20-2008, 06:13 PM
Hi Patrick,
To add to that, for the benefit of the general public, if you need to use a hack like that to store text, any of the events, like onClick will store a text value.
Zephyr
cheathamlane
02-20-2008, 07:35 PM
Thanks Zephyr!
I've been getting unreliable results with doing just that, which is why I went to a number in the rotation parameter.
Sometimes my text comes back as "undefined", other times it comes back as what I have dynamically set it to, and other times it comes back as the last thing I set it to... Weird. Possibly a function of my using ExternalInterface, versus going thru a plugin?
vBulletin® v3.7.1, Copyright ©2000-2010, Jelsoft Enterprises Ltd.