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

    multi-array question

    christoon_ca

      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
          kglad Adobe Community Professional & MVP

          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
            christoon_ca Level 1

            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
              kglad Adobe Community Professional & MVP

              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
                christoon_ca Level 1

                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!

                Sorry for my fuzzy head. Thanks for your help.

                • 5. Re: multi-array question
                  kglad Adobe Community Professional & MVP

                  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.

                   

                  but, it may help you to see the following:

                   

                  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

                  1 person found this helpful
                  • 6. Re: multi-array question
                    christoon_ca Level 1

                    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
                      christoon_ca Level 1

                      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
                        kglad Adobe Community Professional & MVP

                        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.

                        1 person found this helpful
                        • 9. Re: multi-array question
                          christoon_ca Level 1

                          thanks for the reply

                           

                          is there no way to have an onMouseDown/Up on just a single mc? I just want to be able to hold it down, then release.

                          • 10. Re: multi-array question
                            kglad Adobe Community Professional & MVP

                            use the onRelease method.