PDA

View Full Version : Dynamic Colour Selection


BlueInkAlchemist
12-02-2008, 05:47 PM
I have a function in which I draw a circle:

function drawGoal(sprite:Sprite):void{
sprite.graphics.lineStyle(0.5,0x00FF00);
sprite.graphics.beginFill(0xFFFFFF);
sprite.graphics.drawCircle(5, 5, 5);
sprite.graphics.endFill();
}

What I want to do is dynamically select the colours of the line and fill of the object, essentially changing the hex values of the colours to variables. My question is, would these variables be strings or numbers?

Thanks in advance!

stolex
12-02-2008, 06:45 PM
Numbers (uints), but if you have strings you can convert them:

var i:uint = 0xffffff;
if (i == uint("0xffffff")) trace("equals")
else trace("error")