Thursday, July 9, 2009

Masking and Drawing Shape.

private function add_Shape(type:String=""):void
{
removeOrMaskUI();
var bxShared:Sprite = new Sprite()
bxShared.graphics.beginFill(0xffffff, 100);
if(type=="circle")
bxShared.graphics.drawEllipse(0,0,xSize,ySize);
else if(type=="square")
bxShared.graphics.drawRect(0,0,xSize,ySize);
var ui:UIComponent = new UIComponent();
ui.name="currentui";
ui.addChild(bxShared);
ui.setStyle("right",xSize);
ui.setStyle("top",0);
container_object.addChild(ui);
}
public function removeOrMaskUI(isMasking:Boolean=false):void
{
var curUI:UIComponent=container_object.getChildByName("currentui") as UIComponent;
if(curUI)
{
if(isMasking)
container_object.mask=curUI;
else
container_object.removeChild(curUI);
}
}

No comments: