globalToLocal座標空間轉換
<?xml version="1.0" encoding="utf-8"?>
<mx:Application applicationComplete="init();" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" >
<mx:Script>
<![CDATA[
import mx.containers.Panel;
private function init():void
{
var p:Point;
//將btn所在的空間座標轉換成c1上的對應空間座標
p = c1.globalToLocal(new Point(btn.x , btn.y));
l.x = p.x;
l.y = p.y;
}
]]>
</mx:Script>
<mx:Canvas id="c1" rotation="45" x="300" y="100" backgroundColor= "#00ff00" width="200" height="200" clipContent="false" >
<mx:Canvas id="c2" backgroundColor="#ff0000" width="100" height="100" alpha="0.7" x="20" y="0" />
<mx:Canvas id="l" backgroundColor="#0000ff" width="50" height="50" />
</mx:Canvas>
<mx:Button id="btn" width="30" height="30" x="350" y="250" />
</mx:Application>
沒有留言:
張貼留言