package { import flash.display.Sprite; import flash.events.Event; /** * 重なったオブジェクトのコンテキストメニューのテスト. * →重なったエリアで、下のオブジェクトのコンテキストメニューを呼び出すことは出来ない? */ public class Main extends Sprite { public function Main():void { // まず赤い矩形を描画. var rectRed:CMRect = new CMRect( 0xFF3333, 200, 200, "red" ); addChild( rectRed ); rectRed.x = 10; rectRed.y = 10; // その上に青い矩形を描画. var rectBlue:CMRect = new CMRect( 0x3333FF, 200, 200, "blue" ); addChild( rectBlue ); rectBlue.x = 80; rectBlue.y = 80; rectBlue.alpha = 0.5; // 重なったエリアでのコンテキストメニューは赤い矩形のものを出したい.. //rectBlue.mouseEnabled = false; // ↑こうしても赤い矩形のコンテキストメニューは出ないし、 // 青い矩形のコンテキストメニューも出てこなくなる。 } } } import flash.display.Shape; import flash.display.Sprite; import flash.ui.ContextMenu; import flash.ui.ContextMenuItem; /* コンテキストメニュー付き矩形. */ class CMRect extends Sprite { public function CMRect( color:uint, w:int, h:int, str:String ) { var square:Shape = new Shape(); square.graphics.beginFill( color ); square.graphics.drawRect(0, 0, w, h); square.graphics.endFill(); addChild(square); // コンテキストメニュー処理. this.contextMenu = new ContextMenu(); this.contextMenu.hideBuiltInItems(); var menuItemColor:ContextMenuItem = new ContextMenuItem( "str["+str+"]" ); this.contextMenu.customItems.push( menuItemColor ); } } 重なったオブジェクトのコンテキストメニューのテスト