明けましておめでとうございます!
コンテナとその子からイベント処理を分離したい。ご覧のとおり、私のソース コードは非常に単純です。
package {
import flash.display.Sprite;
import flash.display.*;
import flash.events.*;
public class test extends Sprite{
public function test() {
var container:Sprite = new Sprite(); // my container
container.graphics.beginFill(0, 1); // whatever the color
container.graphics.drawRect(0, 0, 100, 100); // origin at 0,0
container.graphics.endFill();
addChild(container);
var decor:Sprite = new Sprite(); // and it child
decor.graphics.beginFill(0, 1); // whatever the color
decor.graphics.drawRect(200, 200, 100, 100); // origin at 200,200
decor.graphics.endFill();
container.addChild(decor);
container.mouseChildren = false;
container.addEventListener(MouseEvent.ROLL_OVER, onOver, false, 0, true);
}
private function onOver(e: MouseEvent):void {
trace("ROLL trace");
}
}
}
コンテナー オブジェクトをロールオーバーすると、トレースが表示されます (私には問題ありません)。しかし、装飾オブジェクトをロールオーバーすると、トレースも取得されます(必要なものではありません)。コンテナを子ではなく、マウスイベントによってトリガーしたいだけです。それで、私の mouseChildren = false に何が起こったのでしょうか....? 理解できない...