-
dynamic color
I want to set the color of setPixel in bitmapData dynamicaly. What I mean is that I find a value for red, green and blue, convert to hex and then use setPixel(x,y,c); to draw. The problem is that if I try
Code:
r=255;
g=0;
b=20;
var c:String = "0x"+r.toString(16)+g.toString(16)+b.toString(16);
myBitmapData.setPixel(x, y, c);
I get the following error:
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 143: Type mismatch.
myBitmapData.setPixel(x, y, c);
I have tried with the color object but I can't get it to work.
-
Answer:
That's because c should be a number according to Flash's documetation.
Solution:
I have no idea. >_<
-
Try doing: myBitmapData.setPixel(x, y, Number(c));
-
That should work because it's requring a number and not a String.
-