flash - How can I get fill color of sprite? -
i'm randomly creating circles on stage , listening clicks on circles. when click circle, want trace circle's fill color. how can data?
this i'm using create circle:
// create circle var circle:sprite = new sprite(); circle.graphics.clear(); var circlecolor = randomcolor(); circle.graphics.beginfill(circlecolor, 1); circle.graphics.drawcircle(0, 0, circleradius); circle.graphics.endfill();
and function fires when circle clicked:
private function clickcircle(event:mouseevent): void { var currentcirclename = event.currenttarget.name; // hide circle event.currenttarget.visible = false; // update stats clickcount++; txt_clickscount.text = string(clickcount); }
ok, discovered cannot add data sprite via question+answer.
what decided create new class extends sprite.
package { import flash.display.sprite; public class altsprite extends sprite { public var color:string; } }
so changed sprite call to:
var circle:altsprite = new altsprite();
and store color altsprite doing:
circle.color = circlecolor;
and can call color in function:
trace(event.currenttarget.color);
Comments
Post a Comment