以下のようなコードを前提とした場合、78行目の 「_child1.mouseChildren = false;」により、画面上の水色の矩形をドラッグしたとき、”StopDragEcho” は表示されなくなります。
実際にご利用のコードがどんな内容かによって結果は代わってくると思いますが、参考になればご利用ください。
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
/**
* ...
* @author kenics
*/
[SWF(width="400",height="300",frameRate="24",backgroundColor="0x000000")]
public class DragDrop extends Sprite
{
private var _canvas:Sprite = new Sprite();
private var _child1:Sprite = new Sprite();
private var _child2:Sprite = new Sprite();
private var _rec:Rectangle;
public function DragDrop()
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
addChild(_canvas);
_canvas.x = 0;
_canvas.y = 0;
_canvas.graphics.clear();
createChild(_canvas,_child1,0,0,150,150,0xffffff);
createChild(_child1,_child2,50,50,50,50,0x00fffff);
_child1.addEventListener(MouseEvent.MOUSE_DOWN, dragStart);
_child1.addEventListener(MouseEvent.MOUSE_UP, dragEnd);
_child2.addEventListener(MouseEvent.MOUSE_DOWN, dragStartEcho);
_child2.addEventListener(MouseEvent.MOUSE_UP, dragEndEcho);
//ドラッグ範囲のプロパティ(範囲のx座標,範囲のy座標,範囲の横幅,範囲の縦幅)
_rec = new Rectangle(0, 0,400 - _child1.width, 300 - _child1.height);
}
private function createChild(parent:Sprite,target:Sprite,x:int,y:int,w:int,h:int,color:int):void
{
target.graphics.beginFill(color);
target.graphics.drawRect(0, 0,w, h);
target.graphics.endFill();
target.x = x;
target.y = y;
target.useHandCursor = true;
target.buttonMode = true;
parent.addChild(target);
}
private function dragStart(event:MouseEvent):void
{
trace("StartDrag");
_child1.mouseChildren = false;
_child1.startDrag(false, _rec);
}
private function dragEnd(event:MouseEvent):void
{
trace("StopDrag");
_child1.mouseChildren = true;
_child1.stopDrag();
}
private function dragStartEcho(event:MouseEvent):void
{
trace("StartDragEcho");
}
private function dragEndEcho(event:MouseEvent):void
{
trace("StopDragEcho");
}
}
}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。