I have multiple toggle buttons on my flash stage. These toggle buttons are MovieClips. If a user clicks on one of the MovieClips, I want to be able to find a way to go through the Object below–get the appropriate value based on what the User clicked–and store that value in a new value called var powerData which will then be passed to a function to perform calculations.
var houseArray:Object = {lightA:"1",
lightB:"1",
lightC: "1"
lightD: "1"
lightE: "1"
comp: "2"
tv: "3"
stove: "4"
laundry: "5"};
For example:
If the user clicked on “Comp” MovieClip
then–> var powerData = 2; (because in houseArray:Object–> comp: “2”)
You will need to name your MovieClips instances after the properties of the houseArray object. In your example, the Comp instance should be named “comp” , the TV “tv” and so on…
I assume you have good reasons to have the properties in houseArray as Strings…