Skip to main content
Known Participant
July 27, 2011
Question

How to detect if a movieClip position changes or stays the same?

  • July 27, 2011
  • 2 replies
  • 459 views

Hoping someone can point me in the right direction here. I think the solution is simple but I don't know how to code it. Basically what happens in my code below is the following:

- If the movieClip called 'tiles' is at 2048 pixels when the screen is dragged, remove the movieClip on stage called workSamples_mc.

What I actually want to do is say

- if the position of movieClip 'tiles' is changed, then remove the movieClip on stage called workSamples_mc, BUT if the screen is only tapped and the position is NOT changed, then DON'T remove workSamples_mc.

Please note that I've already called workSamples_mc to stage, I just didn't include the code.

Thanks, Mike

tiles.addEventListener(TouchEvent.TOUCH_BEGIN, homeTouchBegin);

tiles.addEventListener(TouchEvent.TOUCH_END, homeTouchEnd);

var homeDragBounds:Rectangle = new Rectangle(0, 0, 3072, stage.stageHeight-768);

function homeTouchBegin(event:TouchEvent):void {

event.target.startTouchDrag(event.touchPointID, false, homeDragBounds);

if (tiles.x == 2048)

     // remove sample work icons from screen

     TweenLite.to(workSamples_mc, .5, {alpha:0, onComplete:workSamplesGone});

     function workSamplesGone():void {

     workSamples_mc.visible = false;

     }

}

This topic has been closed for replies.

2 replies

Known Participant
July 27, 2011

Ideally, I only want the workSamples_mc to dissapear IF the tiles.x position changes, otherwise nothing happen...

It works fine, except that it is also affected by a tap of the screen, which doesn't change the tiles.x value

relaxatraja
Inspiring
July 27, 2011

var defxpos:Number=tile.x;

the condition should be:

if (tile.x!=defxpos){

     removeChild(workSamples_mc); (or)

     workSamples_mc.visible=false;

}

Known Participant
July 27, 2011

Thanks for responding... it doesn't seem to be effecting the workSamples_mc though