yoshiweb.NET

visible = false;しても表示オブジェクトに含まれる

getBoundsのヘルプに「表示オブジェクトの領域を定義する矩形を返します。」ってあるけど
非表示にしてる visible = false; に設定してるオブジェクトも含んだ状態で返すんですね。。。

import flash.display.Sprite;
import flash.display.Shape;
import flash.display.Graphics;

// シェイプを作成
var sp:Sprite = new Sprite();
sp.x = 150;
sp.y = 150;
this.addChild(sp);

// シェイプに丸を描く
var maru:Shape = new Shape();
maru.graphics.beginFill(0xFF0000);
maru.graphics.drawCircle(0,0,100);
sp.addChild(maru);


// 表示オブジェクトの領域を出力
trace( maru.getBounds(sp) );
// (x=-100, y=-100, w=200, h=200)


// 丸を非表示にしてみる
maru.visible = false;

// 表示オブジェクトの領域を出力
trace(maru.getBounds(sp));
// (x=-100, y=-100, w=200, h=200) ← かわらない


投稿日 : 2014年09月29日 - yoshiweb - カテゴリ: Flash

コメント

コメントなし