all groups > flash actionscript > may 2004 >
You're in the

flash actionscript

group:

Create dynamic buttons on a map


Create dynamic buttons on a map Bonsch
5/6/2004 11:10:22 PM
flash actionscript: Hi,
My program loads GPS points from a Xml file and displays them on a map. The
dots representing different cities are simply drawn using a DrawCircle function
I found online.
Is there any way I can replace those dots by round buttons so that when the
user clicks on them, more information appears in a TextArea component? I would
also like to create a small popup box showing the GPS coordinates when the user
rolls over a specific point. Please help.
Here is a link to what i've done so far:
[L=http://traftech2000.no-ip.com/IEG/map/circles4.html]check it out![/L]
thank you
Bonsch
Re: Create dynamic buttons on a map rlc5611
5/7/2004 5:23:36 AM
If it were me I would read in all the info you are trying to capture into an
array and then use the array index to dynamically duplicate a movie clip using
the array's index as part of the name for easy retrieval later. Ideally you
would think that you could take your GPS points and calculate their relative X
and Y on the main stage and locate these duplicated clips accordingly with the
setProperty() script. If your map was generated in the correct projection, you
can do this. If it is drawn in a different projection you can still do it but
some more math will be required to convert to a flat x,y system.

This movie clip you duplicate would have a button inside it. I would make the
button have the up state the size of the dot you want to display and the over
and down states could be the same size or slightly larger or different color or
both just to give some feedback. In the hit state, make the circle even bigger
so it is easier to hit but not so big that it might overlap an adjacent
city/place dot. In the actionscript of the MC (same timeline as the button),
put myname = getProperty(this,_name); so that the dot immediately knows its
name (such as mycityx where "x" is the array index number used to create it
(i.e. 0,1,2,3...). For the button action, strip out the "mycity" from the name
so you know the "number" of the duplicated clip and use this number to access
its info from the array.

Alternatively, if you load the MC's at consecutive depths, the MC could
retrieve its depth rather than its name and correlate that to its position in
the array.
AddThis Social Bookmark Button