A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: How to change the Color ?

  1. #1
    Junior Member
    Join Date
    Feb 2002
    Posts
    24
    Ok, I have made a function to change the color (combineRGB), it works well with the following stuff, changing the color of "ball1"

    ball1Color = new Color ( "ball1" );
    ball1Color.setRGB (combineRGB ( 201, 0, 0 ));

    but now I want to change the color of "ballx" (x = int)

    x = 1;
    theName = eval ( "ball" + x)
    objectColor = eval ( theName + "Color" );
    objectColor = new Color ( theName );
    objectColor.setRGB (combineRGB ( 201, 0, 0 ));

    why doesnt it work?
    whats wrong?

    thx

  2. #2
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    What exactly isn't working?

    the only thing wrong that i can find is this:

    objectColor = eval ( theName + "Color" );

    it doesnt do anything since the next line overwrites the content in objectColor:

    objectColor = new Color ( theName );


    /Mirandir

  3. #3
    Junior Member
    Join Date
    Feb 2002
    Posts
    24
    this one is working:
    ball1Color = new Color ( "ball1" );
    ball1Color.setRGB (combineRGB ( 201, 0, 0 ));


    the other stuff doesnt work

  4. #4
    Junior Member
    Join Date
    Feb 2002
    Posts
    24
    ok, thx, I corrected it and it works now

    looks like this now:

    x = 1;
    object = eval ( "ball" + x)
    object.objectColor = new Color ( object );
    object.objectColor.setRGB (combineRGB ( 201, 0, 0 ));


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center