GetBoundTest2
バウンド領域の描画は外側から実行してますよ
♥0 |
Line 35 |
Modified 2011-02-07 04:23:46 |
MIT License
archived:2017-03-09 21:09:17
ActionScript3 source code
/**
* Copyright matsumos ( http://wonderfl.net/user/matsumos )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/xziR
*/
package
{
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.geom.Rectangle;
/**
* ...
* @author matsumos
*/
public class GetBoundTest2 extends Sprite
{
public function GetBoundTest2()
{
const core:Sprite = new Sprite;
core.graphics.beginFill(0xFF0000);
core.graphics.drawCircle(0, 0, 50);
core.graphics.endFill();
//addChild(core);
const sp1:Sprite = new Sprite();
sp1.rotation = 40;
sp1.addChild(core);
//addChild(sp1);
const sp2:Sprite = new Sprite();
sp2.rotation = 40;
sp2.addChild(sp1);
addChild(sp2)
sp2.x = 150;
sp2.y = 150;
drawBounds(sp2, this);
drawBounds(sp1, sp2);
drawBounds(core, sp1);
}
private function drawBounds(target:DisplayObject,targeCoordinateSpace:Sprite):void
{
targeCoordinateSpace.graphics.beginFill(0x0, 0.2);
const rect:Rectangle = target.getBounds(targeCoordinateSpace);
targeCoordinateSpace.graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
targeCoordinateSpace.graphics.endFill();
}
}
}