Hi Guys! I’m new here. This is actually my first post. I really need help.
I’m using enterframe to move/ease movie clips into position after dragging them. I already have a code for this which I got from Bill Trikojus at Swinburne.My problem is, I also want to be able to reset all movie clips to their original position with a button. I tried creating another enterframe function for the movie clip but it contradicts with the first enterframe function. Is there a proper way to do this?
Here’s a part of the code I’m using
clip.myHomeX = clip.x;
clip.myHomeY = clip.y;
clip.myFinalX = targ.x;
clip.myFinalY = targ.y;
clip.scaleX = .8;
clip.scaleY = .8;
function slide(e:Event):void{
if (!e.target.beingDragged && !e.target.onTarget) {
e.target.x -= (e.target.x-e.target.myHomeX)/5;
e.target.y -= (e.target.y-e.target.myHomeY)/5;
clip.scaleX += (.8-clip.scaleX)/5;
clip.scaleY += (.8-clip.scaleY)/5;
} else if (!e.target.beingDragged && e.target.onTarget) {
e.target.x -= (e.target.x-e.target.myFinalX)/5;
e.target.y -= (e.target.y-e.target.myFinalY)/5;
clip.scaleX += (1-clip.scaleX)/5;
clip.scaleY += (1-clip.scaleY)/5;
}
}
clip.addEventListener(Event.ENTER_FRAME,slide)
save_btn.addEventListener(MouseEvent.CLICK, saveClick);
function saveClick(e:MouseEvent):void{
clip.addEventListener(Event.ENTER_FRAME, slideAgain)
}
function slideAgain(e:Event):void{
if (!clip.beingDragged && clip.onTarget) {
clip.x -= (clip.x-clip.myHomeX)/5;
clip.y -= (clip.y-clip.myHomeY)/5;
clip.scaleX += (.8-clip.scaleX)/5;
clip.scaleY += (.8-clip.scaleY)/5;
}
}