FORUMS: list search recent posts

Random Sqaures changes color over time.

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Adam Zygadlo
Random Sqaures changes color over time.
on Jul 14, 2011 at 5:46:37 pm

Hello everyone,
Basically, I'm making grid of colored squares, where each square randomly changes over time from one color and blends to another from an array of five or six colors.

The Actionscript in the Timeline: (This is where I trip up as I don't have enough experience this)
myArray = ["0x111111", "0x222222", "0x333333", "0x444444", "0x555555"];

function box(mc){
picker = myArray[random(myArray.length)];
genertor = new Color(mc);

Then, I placed nine squares on the stage and then applied this actionscript on them:

Could anyone help out?
Thanks in advanced!

Adam Jozef Zygadlo
Motion Graphic Designer

07708 124 915
'Filled with brainy goodness.'

Return to posts index

Adam Ashby
Re: Random Sqaures changes color over time.
on Jul 14, 2011 at 9:24:25 pm

Colors in your array should be numbers not strings. Also, math.random returns a number between 0 and 1 so you need to times it by your array length and floor it (round down).

var myArray:Array = [0x111111, 0x990000, 0x333333, 0x444444, 0x555555];

function box(mc){
var picker:Number = myArray[Math.floor(Math.random() * myArray.length)];
var generator:Color = new Color(mc);

Adam Ashby
Multimedia Developer

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved