A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: changing instance colour

  1. #1
    Member
    Join Date
    Aug 2002
    Posts
    57
    How can I change an instance of movie clip without actually changing the movie clip?
    ...Im sure its very easy if you know how.

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    To change the colour of a movie clip you need to use the colour object

    first give the clip an instance name you can noew either use the setTransform or setRGB methods, setRGB is prbably more straight forward so i'll use that one here

    for example if you have a movie clip and a button on the main timeline and you want the clip to change colour when the button is pressed if you gave the clip the instance name myClip, this action attached to the button would change the colour of the clip to ff9900 (orange)

    on (release) {
    myColor = new Color(_root.myClip); // create a new color object
    myColor.setRGB(0xff9900); // change the color with setRGB
    }

    you could turn the clip a random colour using

    on (release) {
    myColor = new Color(_root.myClip);
    myColor.setRGB(Math.random() * 0xffffff);
    }

  3. #3
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    Hey catbert303, I'm just starting on more advanced AS, can you explain what the '0xffffff' does?

  4. #4
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    The 0xffffff is a hexidecimal value (like in html where you can set a colour using hexidecimal. for example #ffffff is white, that is red, blue and green are all set to the maximum value, ff) in flash to use a hexidecimal value you prefix it with 0x

    These values are especially useful when dealing with colours

    http://www.macromedia.com/support/fl...robject04.html

  5. #5
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    Great, thanks.

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