0

画像の 2 つのコピー (blurPic_mc と呼ばれるものと、sharpPic_mc と呼ばれるもの) があり、それらの両方を画面上で一緒に移動できるようにしたいと考えています。私が実行している他のいくつかの機能のために、それらが互いに正確に重なるようにする必要がありますが、現在移動するのは一番上のもの(sharpPic_mc)だけです。何か案は?以下にコードを含めました。

sharpPic_mc.addEventListener(MouseEvent.MOUSE_DOWN,Click);
sharpPic_mc.addEventListener(MouseEvent.MOUSE_UP,Release);

function Click(event:MouseEvent):void{
  event.currentTarget.startDrag();
  blurPic_mc.startDrag();
}
function Release(event:MouseEvent):void{
  event.currentTarget.stopDrag();
  blurPic_mc.startDrag();
}
4

1 に答える 1

1

startDragでは、一度に1つのMovieClipしかドラッグできないと確信しています。だからあなたはこれをしたいと思うでしょう。

sharpPic_mc.addEventListener(MouseEvent.MOUSE_DOWN,onImageDown); 
blurPic_mc.addEventListener(MouseEvent.MOUSE_DOWN,onImageDown); 


function onImageDown(e:MouseEvent):void
{
  //listening to stage
  stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
  stage.addEventListener(MouseEvent.MOUSE_UP, onImageRelease);
}

function onImageRelease(e:MouseEvent):void
{
  removeEventListener(MouseEvent.MOUSE_MOVE, onMove);
  removeEventListener(MouseEvent.MOUSE_UP, onImageRelease);
}


function onMove(e:MouseEvent):void
{
  blurPic_mc.x = e.stageX;
  blurPic_mc.y = e.stageY;

  sharpPic_mc.x = e.stageX;
  sharpPic_mc.y = e.stageY;
}
于 2009-11-15T01:17:40.480 に答える