ActionScript 3 Random Color

I wanted to test something with different colors, turns out it’s easy to pick a random color:

var box:Shape = new Shape();
var random_color:Number = <strong>Math.random() * 0xffffff;</strong>
box.graphics.beginFill(random_color, 1);
box.graphics.drawRect(0, 0, 100, 100);
box.graphics.endFill();
this.addChild(box);

Comments: None so far...be the first!

Leave a reply

Your email address will not be published. Required fields are marked *

Aye, fight and you may die. Run, and you’ll live… at least a while. And dying in your beds, many years from now, would you be willin’ to trade ALL the days, from this day to that, for one chance, just one chance, to come back here and tell our enemies that they may take our lives, but they’ll never take… OUR FREEDOM!

— William Wallace