I have a map of the US with icons over a number of cities (about 12). When the user hovers their mouse over one of these icons a movieclip with two dynamic text fields pop-up over the icon.
Each city's icon movieclip is named after it's home state: state_(abbreviation)
ie: state_TX
The pop-up text balloon is named: cityTag_mc
Inside that is two dynamic text fields: title_txt
& subTitle_txt
The logic is to add the cityTag_mc
when the user hovers over state_TX
and input that state's title and sub title.
My main hang-up is how to feed text into the fields (and animate the balloon). I don't quite know where to start. I would like to just set the text for each state in the Action Script. Where do I start? What is the best practice?
Best Answer
Once you have created all the city icons and placed them on stage and given them instance names then put them in an array. This is just to make things easier to manage.
cityIcons.push(state_tx), cityIcons.push(state_ca)
etcNow we need to add the code to get the balloon to show. You mentioned animating it as well. Place your animation of a balloon growing in the cityTag_mc underneath your textfields. Give it an instance name for example balloon_mc.
Now we need to add the listeners. We will loop over our array so we only have to write it once.
You can place an instance of the balloon called cityTag_mc already on stage and set visible to false, or you can create and remove as needed. This is just a guide don't take it as 100% as this is just off the top of my head.