Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

entry level array question

Participant ,
May 21, 2013 May 21, 2013

I'm new to array, I have a bunch of color codes that I want to assign to an array,

#000000,

#00008B,

#00009C,

#0000CD,

#0000FF,

#002395,

#002E63,

#002FA7,

#00308F,

#003366

in AS2 I have so far

var i=1;

while (i<11) {

    this["icolor"+i] =

}

how do i do this within a loop, while every time 'i' imprement, it will asign the next color code on the list? I think this is pretty fundamental.. i'm still doing research on this, great if someone just point it out to me.

Thanks  a lot.

TOPICS
ActionScript
466
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , May 21, 2013 May 21, 2013

oh I got it,

var newColor = this.colorCC;

Translate
Participant ,
May 21, 2013 May 21, 2013

Trying to test with names first, what's the problem in my sample?

var names:Array = new Array("Belinda", "Gina", "Kathy", "Charlotte", "Jane");

for(i=0; i< names.length; ++i){

    var u=i+1;

    this("icolor"+i).nAme = names;  <<icolor is mc on stage

    trace(names);          << this trace is good

    trace(this("icolor"+i).nAme );  << this trace give me undefine

}


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 21, 2013 May 21, 2013

so I construct it to this point. I don't know why it doesn't work

var colorCode:Array = new Array("0xFFA83C", "0x333333", "0x666666", "0x999999", "0xCCCCCC");

for(i=0; i< colorCode.length; ++i){

    var u=i+1;

    this["icolor"+u].colorCC = colorCode;

    trace(colorCode);  

    trace(this["icolor"+u].colorCC ); << value the same as colorCode

    this["icolor"+u].onPress = function () {

    var my_color:Color = new Color(currentObjectTarget); << to change the color of currentObjectTarget

    var newColor = this["icolor"+u].colorCC;

    my_color.setRGB(newColor);  << if I substitute newColor to just  some color code , it work

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 21, 2013 May 21, 2013
LATEST

oh I got it,

var newColor = this.colorCC;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines