简体   繁体   中英

How to randomly change color of an object using colors in an array? Actionscript 3.0

I have "characters" which are movieclips, placed to the stage and positioned in an array; in Actioscript 3.0.

I am trying to create an array which will contain 4 of my chosen colors, Red, Blue, Green and Grey.

My characters should change color every couple of seconds to a random color from the array. The end goal is to have the characters clickable and if they are grey then they will be deleted and if they are one of the colors then they will not.

Can anyone help me at all please?

This is relatively simple issue, so I'd like to see you demonstrate an attempt at doing this. If it's not working, then post your question; otherwise, you're asking others to program for you (or teach you, which is not the goal of StackOverflow). In short: research -> attempt -> fail -> research/ask -> attempt -> success , not: ask > success .

Try this:

Have fun!

For red, green and blue:

[0xFF0000,0x00FF00,0x0000FF][int(Math.random()*3)]

user:Pixel Elephant

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM