The code is pretty simple. This is all I am trying to do:
<mx:Script>
<![CDATA[
private function init():void{
// var p:Point = new Point(btn1.x, btn1.y);
// var pg:Point = localToGlobal(p);
with(btn1.graphics){
clear();
lineStyle(2, 0xffffff, 1);
beginFill(0x123456, 1);
// globel coordinates doesn't work too
// drawRect(pg.x, pg.y, btn1.width + 20, btn1.height+ 20);
drawRect(btn1.x, btn1.y, btn1.width + 20, btn1.height+ 20);
endFill();
}
btn2.graphics.clear();
btn2.graphics.lineStyle(2, 0xffffff, 1);
btn2.graphics.beginFill(0x123456, 1);
btn2.graphics.drawRect(btn2.x, btn2.y, btn2.width + 20, btn2.height+ 20);
btn2.graphics.endFill();
}
]]>
</mx:Script>
<mx:Button id="btn1" label="ButtonOne" x="149" y="198"/>
<mx:Button id="btn2" label="ButtonTwo" x="273" y="198"/>
The problem is that the background was drawn in a very far away.
I am wondering why the backgroundcolor depart from the buttons.