10 Replies Latest reply on Jun 25, 2009 9:54 PM by kglad

# multi-array question

Hello

I find this hard to explain so I will use an example...

Here is the data:

wir = Array("twelveVolt", "ignition", "ignition_2", "accessory", "starter", "keySense", "arm", "parkingLights", "clutchSwitch");
dmm = Array("acv", "dcv", "ohm");
key = Array("koff", "kacc", "kign", "kstr");

eng = Array(wir, dmm, key);

Here is an example with some of the above data:

eng[twelveVolt][acv][wir] = "12";

I have all of the data combinations, I just cannot, for the life of me, figure out how to output the data

Any help is greatly appreciated

Thanks

• ###### 1. Re: multi-array question

christoon_ca wrote:

Hello

I find this hard to explain so I will use an example...

Here is the data:

wir = Array("twelveVolt", "ignition", "ignition_2", "accessory", "starter", "keySense", "arm", "parkingLights", "clutchSwitch");
dmm = Array("acv", "dcv", "ohm");
key = Array("koff", "kacc", "kign", "kstr");

eng = Array(wir, dmm, key);

trace(eng[0][0]);  // twelveVolt

trace(eng[1][0]):  // acv

trace(eng[2][0]);  // koff;

• ###### 2. Re: multi-array question

Thanks for the reply kglad. I don't think I explained myself well enough though. I gues what I'm after is something more like this:

```if (wir = twelveVolt, dmm = acv, key = koff) {
text.text = "12"
}
```

but...

```if (wir = twelveVolt, dmm = acv, key = kon) {
text.text = "13"
}
```

and all the rest of the combos for all the variables... Do I use a loop, or something else maybe?

Thank you

• ###### 3. Re: multi-array question

how can it be deduced that "12" has something to do with the first array elements of wir,dmm and key?

• ###### 4. Re: multi-array question

kglad: Right, I would need to declare all the data first. So instead of my "if" example, I would need to declare:

``(wir[twelveVolt], dmm[acv], key[koff]) = "12";``

I don't even know the syntax for that!

• ###### 5. Re: multi-array question

i have a feeling you're trying to use an associative array but, so far, i can't determine just what it is that you're trying to do.  you might try explaining what you need.

var obj:Object={};

// assigns "twelveVolt" as a property of obj

obj["twelveVolt"]="12";

// assigns wir[0] as a property of obj.  if wir[0]="twelveVolt", this is the same as above

obj[wir[0]]="12";

etc

• ###### 6. Re: multi-array question

hmmm, that does help me in other area

I'm getting better with the array stuff as I go, but now I hit another seemingly strange wall

```var onOff = "koff";

key.onPress = function() {
if (onOff == "koff") {
key.gotoAndStop ("kacc");
onOff = "kacc";
}else if (onOff == "kacc") {
key.gotoAndStop ("kon");
onOff = "kon";
}else if (onOff == "kignB") {
key.gotoAndStop ("koff");
onOff = "koff";
}
};

key.onMouseDown = function() {
if (onOff == "kon") {
key.gotoAndPlay ("kign");
onOff = "kign";
}
};

key.onMouseUp = function() {
if (onOff == "kign") {
key.gotoAndPlay ("kignB");
onOff = "kignB";
}
};

check_mc.onRelease = function() {
trace(onOff);
}
```

"check_mc" works normally until "key"  is on the "kon" frame, then when I press "check_mc" it sends "key" to the "kignb" frame. I don't get it.

I attached the file as well, if that's easier.

Thanks again

• ###### 7. Re: multi-array question

I've just realized it doesn't matter where I click and hold down, the "key" thinks it's on "key".

?

• ###### 8. Re: multi-array question

i'm not sure what you're trying to do with that code.  if you're trying to detect keyboard presses check the Key class.  you'll need to add a listener object.

onMouseDown and onMouseUp execute whenever the mouse is down and up no matter its location.  use onPress and onRelease to detect those mouse events when the mouse is over your object.