Thanks Manish! That works. drawRect(0, 0, btn1.width + 20, btn1.height+ 20); Is the 0,0 point is the ContentPoint of the btn1 ?
在2009-06-03,"Manish Jethani" <manish.jeth...@gmail.com> 写道: 2009/6/2 j2me_soul <j2me_s...@163.com>: > 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); var p:Point = new Point(btn1.x, btn1.y); p = this.localToGlobal(p); p = btn1.globalToLocal(p); That works. First you convert from the Application's co-ordinate space to the global co-ordinate space, and then you convert from there to to button's local co-ordinate space. It is of course pointless. You might as well use 0,0 as your x,y co-ordinates. > 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(); > } Manish