I am trying to have the function toggleClick return powerData. I need to store powerData in a variable and have it passed to another function to do calculations.
Inside the function toggleClick, I am assigning powerData to houseArray[e.currentTarget.name.toLowerCase()];
var powerData:int = houseArray[e.currentTarget.name.toLowerCase()];
I tried just to write return powerData--but it breaks the program.
// function toggleClick
function toggleClick(e:MouseEvent) {
// Store "Power" Values of House Objects in Array
var houseArray:Object = {lightA: 1, lightB: 1, lightC: 1,lightD: 1, lightE: 1,
comp: 2,
tv: 3,
stove: 4,
laundry: 5};
// Store User Power in Variable called powerData
// The currentTarget will equal powerData
var powerData:int = houseArray[e.currentTarget.name.toLowerCase()];
//return powerData;
trace("movieClip Instance Name = " + e.currentTarget); // [object Comp]
//trace(houseArray[e.currentTarget.name]); // comp
trace("using currentTarget: " + e.currentTarget.name); // comp
trace("powerData: " + powerData); // the amount of power that I clicked on
//trace("houseArray: " + houseArray[0]); // the 0 index of house array
trace(houseArray[e.currentTarget.name]); // currentTarget inside Array
// how to find out which object selected
if (e.currentTarget.currentFrame == 2)
{
e.currentTarget.gotoAndStop(3);
e.currentTarget.bstate = 1;
}
if (e.currentTarget.currentFrame == 4)
{
e.currentTarget.gotoAndStop(1);
e.currentTarget.bstate = 0;
}
}