I’ve got container clips positioned on a map where buttons need to be placed …The container clips are named button0, button1, button2, etc. all the way up to 109, the total number of “status” entries in my XML file. I have 4 buttons in my Library which need to be assigned to lots on the map based on “status”: Sold, For Sale, Ensemble, Other. How do I go about automatically attaching movie clips to those container clips based on the info in an array?
Here’s what I have so far, with one of my hand coded buttons to show what I need it to do:
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#000000]**var**[/COLOR] lotStatus_array:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000]**new**[/COLOR] [COLOR=#0000ff]Array[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]; [COLOR=#808080]*/*this sets the variable for the array that keeps track up Lot Status (sold, Ensemble, pending, etc.)*/*[/COLOR]
[COLOR=#000000]var[/COLOR] PathToButton = [COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]mainMap[/COLOR].[COLOR=#000080]map[/COLOR].[COLOR=#000080]pan[/COLOR]; [COLOR=#808080]/path to the movie clip the Buttons are laoded into/[/COLOR]
[COLOR=#808080]/ This sets variable for the popup window function
that is called by all the buttons on the map.
This way I don’t have to type it out each time /[/COLOR]
[COLOR=#000000]var[/COLOR] popup = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]_root[/COLOR].[COLOR=#0000ff]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“lot35_mc”[/COLOR], [COLOR=#0000ff]_root[/COLOR].[COLOR=#0000ff]getNextHighestDepth[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]lot35_mc[/COLOR].[COLOR=#0000ff]_x[/COLOR]=[COLOR=#000080]20[/COLOR];
[COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]lot35_mc[/COLOR].[COLOR=#0000ff]_y[/COLOR]=[COLOR=#000080]20[/COLOR];
[COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]lot35_mc[/COLOR].[COLOR=#0000ff]attachMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“lot35”[/COLOR], [COLOR=#ff0000]“lotinfo”[/COLOR], [COLOR=#000080]1[/COLOR][COLOR=#000000])[/COLOR];[COLOR=#000000]}[/COLOR]
[COLOR=#808080]//end popup variable[/COLOR]
[COLOR=#808080]//Generate Buttons Status for lotplan, based on XML file[/COLOR]
[COLOR=#000000]function[/COLOR] GenerateButtonsCOLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
nTotalButtons = xmlData.[COLOR=#0000ff]firstChild[/COLOR].[COLOR=#0000ff]childNodes[/COLOR].[COLOR=#0000ff]length[/COLOR];
[COLOR=#808080]//fill arrays[/COLOR]
[COLOR=#0000ff]for[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#000000]var[/COLOR] i = [COLOR=#000080]0[/COLOR]; i < nTotalButtons; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
lotStatus_array.[COLOR=#0000ff]push[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#808080]//create the info buttons:[/COLOR]
[COLOR=#000000]**var**[/COLOR] button1A:[COLOR=#0000ff]MovieClip[/COLOR] = PathToButton.[COLOR=#000080]button1[/COLOR].[COLOR=#0000ff]attachMovie[/COLOR][COLOR=#000000]([/COLOR]lotStatus_array[COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR], [COLOR=#ff0000]"INFO"[/COLOR], PathToButton.[COLOR=#0000ff]getNextHighestDepth[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR];
button1A.[COLOR=#0000ff]onRollOver[/COLOR] = [COLOR=#000000]**function**[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#000000]**_global**[/COLOR].[COLOR=#000080]Xlot[/COLOR] = [COLOR=#000080]1[/COLOR]; [COLOR=#000000]}[/COLOR] [COLOR=#808080]*/*this sets the Child node value so the popup window knows which lot information to pull from the XML*/*[/COLOR]
button1A.[COLOR=#0000ff]onPress[/COLOR] = popup; [COLOR=#808080]*/*this calls the varialbe set above, which opens the info box */*[/COLOR]
[/LEFT]
[/FONT]
I’ve got 5 additional maps to do, so is there an easier way for me to attach these several hundred buttons, or do I need to go ahead an start a fresh pot of coffee and start coding? :cross-eye
Thanks in advance!
rvt
PS…why is my
code not appearing in a box? it appeared in a box, with scroll bars when I previewed the message before posting...odd... should I use
brackets instead?