前に、親子構造を全て選択する
http://www.sakaiden.com/?p=1010
この方法だと
共通の親を持っているかで調べているから
シーン全体のオブジェクトを調べ上げなければいけないので
ちっと効率がわるい
な~の~で~~~
ちょっとヒラメイた方法を試した
[as3]
(
–新・構造を全部選択する
with redraw off
(–再描画禁止
–階層構造を全て取得
if selection.count != 0 then
(
–変数を準備
Local objRoot = selection[1],
obj = undefined;
objectBranch = #();–回収した子供
checkObj = undefined;–チェックするオブジェクト
checkChildren = #();–チェックするオブジェクトの配列
–選択したものの階層をさかのぼり、親オブジェクトが無くなったら回収
while objRoot.parent != undefined do
(
objRoot = objRoot.parent
)–while end
–配列に格納
append objectBranch objRoot
–子供の数を入れる
numChild = objRoot.children.count;
–初期回収
for i =1 to objRoot.children.count do
(
–2つに回収
append checkChildren objRoot.children[i];
append objectBranch objRoot.children[i];
);–for end
–0になるまで繰り返す
while numChild != 0 do
(
–deleteItem checkChildren 1;
checkObj = checkChildren[numChild];
–チェック用配列からのおしりから削除
deleteItem checkChildren numChild;
numChild -= 1;
–子はあるか?
if (checkObj.children.count != 0) then
(
–print “有り”;
numChild += checkObj.children.count;–カウントアップ
for i =1 to checkObj.children.count do
(
append checkChildren checkObj.children[i];
append objectBranch checkObj.children[i];
);–for end
)else
(
–子が見つからなければ
–print “無し”
);–if end
);
–最後に選択
select objectBranch;
);–if end
)–with redraw end
);–end
[/as3]
こんな感じ
まぁ、頭からしらみつぶしに調べただけなので
大した事はしていない
ひとまず、動かした感じはいいみたい
ループ数も押さえられるから
背景入りの膨大なシーンを扱う場合は
間違いなくこっちの方が良い
あ~~そうだな
巨大なシーンいじる可能性考えて
ループから逃げ出せる用にしておいたほうがイイかも・・・
ということで
よかったらど~~ぞ~~