mardi 22 septembre 2015

How to assign value to Numbers in Array?

Hey everyone so I have an Array private var frames:Array; which I give value and initiate in my constructor function like so frames = [2, 3, 4, 5, 6, 7, 8];

Now I am trying to give a string value to each number in the array for my hitTest Function. I was thinking something on the lines of a for loop and giving them values there but having some issues here is what I have so far:

for (var i:int = 0; i < frames.length; i++)
        {
           var currentFrameNumber = frames[i];

            //assign values to numbers in array
           if (currentFrameNumber == 2)
           {
               trace("2_RED");
               currentWires.sRed = "RED";
           }
           if (currentFrameNumber == 3)
           {
               trace("GREEN");
               currentWires.sGreen = "GREEN";
           }
           if (currentFrameNumber == 4)
           {
               trace("BLUE");
               currentWires.sBlue = "BLUE";
           }
           if (currentFrameNumber == 5)
           {
               trace("YELLOW");
               currentWires.sYellow = "YELLOW";
           }
           if (currentFrameNumber == 6)
           {
               trace("WHITE");
               currentWires.sWhite = "WHITE";
           }
           if (currentFrameNumber == 7)
           {
               trace("PURPLE");
               currentWires.sPurple = "PURPLE";
           }
           if (currentFrameNumber == 8)
           {
               trace("BLACK");
               currentWires.sBlack = "BLACK";
           }
        }

this doesn't work at all. I know I Am missing something crucial. Please any help would be appreciated thanks!

Aucun commentaire:

Enregistrer un commentaire