[thelist] Flash MX Action Script HELP NEEDED!
matthew garrett
matthew.garrett at snet.net
Wed Nov 26 23:43:11 CST 2003
> From: Shae Hawkins shae at web-connect.net
> I have a map of the United States. Each state is it's own button. I am
> trying to program it so that when a user clicks on a state, the
> abbreviation for that state is placed in a text field below the map. So,
> if a user clicks on Georgia, California, and Colorado, then in a text
> field below the map, the user would see GA, CA, and CO.
>
> I am trying to use the LoadVariable in the action scripting, but I am
> having no luck.
Hi,
Sent this 5 hours ago and it never showed up...
You don't need loadVariable.
You need a dynamic text field with a var name assigned.
The following assumes that the map, and the text field which will display
the state names are all at the _root level. You can re-work this to any
arrangement you like, but hopefully the general idea will come across enough
to get you going.
Place a text field on the stage in the first fram of the _root level. In the
text field inspector, assign the dynamic text field a "Var" name. I'll use
"stateText" for this example. Once you've done that, put code like this into
an otherwise blank layer in the first frame of the movie.
_root.stateText = ' ';
_global.stateCount = 0;
function addState(newState) {
_global.stateCount = _global.stateCount + 1;
trace("current state count: "+_global.stateCount);
if (_global.stateCount > 1) {
_root.stateText = _root.stateText + ', '
}
trace(_root.stateText);
_root.stateText = _root.stateText + newState;
trace(_root.stateText);
}
Now, assign/attach the following script to each button on the map. Just
change the 'CA' to the appropriate state abbreviation.
on (release) {
trace("add CA button clicked");
addState('CA');
}
I don't guarantee that the code will work as is, but it's a start. I've
added some traces to help you figure out where it's not working.
If it doesn't work at all, I'll try to create a working sample.
Good luck,
Matt
More information about the thelist
mailing list