A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: How to change a MC's color

  1. #1
    Member
    Join Date
    Nov 2005
    Posts
    94

    How to change a MC's color

    Hello everybody...

    I have a mc on my stage and it's duplicated several times. I want to give each instance a different color, and instead of having several movieClips, how can I assign them a color with AS?

    Thanks for your help.

    Halanis

  2. #2
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    Assuming the movie clip is just a fill color inside it, and not some picture, then give each movie clip a new instance name like myColor1, myColor2, and so on. Then, in an actions layer, you can use this code;

    myColor1 = new Color(myColor1);
    myColor1.setRGB(0x0000FF);

    myColor2 = new Color(myColor2);
    myColor2.setRGB(0xFF0000);

  3. #3
    Senior Member
    Join Date
    Dec 2000
    Posts
    620

    making a button change its colofr

    how do i make a button change its color?

    thanks!
    -manny
    -could just be me though

    mannyme80

  4. #4
    Senior Member b18269's Avatar
    Join Date
    Jan 2006
    Location
    London, UK
    Posts
    167
    just change the tint of the mc. Look in the properties panle

  5. #5
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    A button symbol is one of Flash's automatic built in objects. It has 4 frames. The first is the static frame, what you see when it's not rolled over. Second is the over frame, third the down frame. The fourth frame is just the hit area and never visible in the flash movie.

    To make a button symbol change color or anything else when it's rolled over or pressed, just build the static look in frame 1. Convert frame 2 to a Blank Keyframe and build the over look in that, The same for frame 3, blank keyframe, then put what you want in it. The blank keyframes kill anything on a layer timeline that came before it.

    In frame 4, especially if you only use text, you need to put a color fill in it, with no outline, to act as a hit area, otherwise when you mouse over the button, only the text is the hit area and it's only chance that rolling over the lines of the text will make it change.

  6. #6
    Senior Member
    Join Date
    Dec 2000
    Posts
    620
    I have quite a few buttons.. making all these frames is not the smartest way to go about it...

    I'd like to have a button that just says.. "Change to this color"
    -could just be me though

    mannyme80

  7. #7
    Senior Member
    Join Date
    Dec 2000
    Posts
    620
    sorry for the confusion... I'm trying to make a button change the color of a MC
    -could just be me though

    mannyme80

  8. #8
    OGC creativeinsomnia's Avatar
    Join Date
    Apr 2001
    Location
    mn
    Posts
    658
    If all you're trying to do is make a button change the color of an MC...the above code will work.

    on(release){
    myColor1 = new Color(myColor1);
    myColor1.setRGB(0x0000FF);
    }

  9. #9
    Senior Member
    Join Date
    Nov 2005
    Location
    Michigan
    Posts
    119
    Take a look at this file, it demonstrates what you are looking for.

    It was made in MX2004, AS2.

    Hope it helps.
    Attached Files Attached Files

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