# Ease back to original position

**URL:** <https://forum.kirupa.com/t/ease-back-to-original-position/19702>\
**Category:** flash\
**Created:** [April 30, 2003, 6:05pm UTC](https://forum.kirupa.com/t/ease-back-to-original-position/19702 "2003-04-30T18:05:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Voetsjoeba](https://avatars.discourse-cdn.com/v4/letter/v/ac91a4/32.png) [@Voetsjoeba](https://forum.kirupa.com/u/Voetsjoeba)\
**Post date:** [April 30, 2003, 6:05pm UTC](https://forum.kirupa.com/t/ease-back-to-original-position/19702/1 "2003-04-30T18:05:45Z")

</div>

Hi,

I’m playing around with mac os x-like dock in flash, but I’ve got a problem with it. I found this at [flashkit.com](http://flashkit.com), [see it here](http://www.flashkit.com/tutorials/Interactivity/Navigation/Mac_OS_X-Aaron_Ha-722/index.php). For your convenience i’ll post the entire code below (it’s quite long though).

Now what i want it to do: if the mouse is not ‘on’ the menu, i want the buttons to ease back to their original position instead of just spawning there. How can i do this via AS ? The \_xscale and \_yscale values should also ease back to original state.

Actions applied on the first (and only) frame:  
[AS]startDrag ("\_root.drag", true);  
stop ();[/AS]

Actions applied on the control movieclip:  
[AS]onClipEvent (load) {  
function checkOffset (coffset) {  
if (coffset\<-175) {  
coffset = -175;  
} else if (coffset\>175) {  
coffset = 175;  
}  
return coffset;  
}  
function setScale (soffset) {  
return 100\*(3-(2\*(Math.abs(soffset)/175)));  
}  
}  
onClipEvent (mouseMove) {  
// Get cursor x and y coordinates  
y = getProperty("\_root.drag", \_y);  
x = getProperty("\_root.drag", \_x);  
// Find cursor offset for each icon based on icon’s starting location  
HomeOffset = x-200;  
NewsEventsOffset = x-250;  
ScheduleOffset = x-300;  
ManualOffset = x-350;  
DirectionsOffset = x-400;  
LessonOffset = x-450;  
ContactUsOffset = x-500;  
MP3CollectionOffset = x-550;  
BookmarkOffset = x-600;  
LinksOffset = x-650;  
// If cursor is inside menu  
if (y\>=0 and y\<=50 and x\>=150 and x\<=700) {  
// Make sure the offsets are within acceptable limits  
HomeOffset = checkOffset(HomeOffset);  
NewsEventsOffset = checkOffset(NewsEventsOffset);  
ScheduleOffset = checkOffset(ScheduleOffset);  
ManualOffset = checkOffset(ManualOffset);  
DirectionsOffset = checkOffset(DirectionsOffset);  
LessonOffset = checkOffset(LessonOffset);  
ContactUsOffset = checkOffset(ContactUsOffset);  
MP3CollectionOffset = checkOffset(MP3CollectionOffset);  
BookmarkOffset = checkOffset(BookmarkOffset);  
LinksOffset = checkOffset(LinksOffset);  
// Move the Home Icon  
setProperty ("\_root.Home", \_x, 200-HomeOffset);  
setProperty ("\_root.Home", \_xscale, setScale(HomeOffset));  
setProperty ("\_root.Home", \_yscale, setScale(HomeOffset));  
// Move the News and Events Icon  
setProperty ("\_root.NewsEvents", \_x, 250-NewsEventsOffset);  
setProperty ("\_root.NewsEvents", \_xscale, setScale(NewsEventsOffset));  
setProperty ("\_root.NewsEvents", \_yscale, setScale(NewsEventsOffset));  
// Move the Schedule Icon  
setProperty ("\_root.Schedule", \_x, 300-ScheduleOffset);  
setProperty ("\_root.Schedule", \_xscale, setScale(ScheduleOffset));  
setProperty ("\_root.Schedule", \_yscale, setScale(ScheduleOffset));  
// Move the Manual Icon  
setProperty ("\_root.Manual", \_x, 350-ManualOffset);  
setProperty ("\_root.Manual", \_xscale, setScale(ManualOffset));  
setProperty ("\_root.Manual", \_yscale, setScale(ManualOffset));  
// Move the Directions Icon  
setProperty ("\_root.Directions", \_x, 400-DirectionsOffset);  
setProperty ("\_root.Directions", \_xscale, setScale(DirectionsOffset));  
setProperty ("\_root.Directions", \_yscale, setScale(DirectionsOffset));  
// Move the Lesson Icon  
setProperty ("\_root.Lesson", \_x, 450-LessonOffset);  
setProperty ("\_root.Lesson", \_xscale, setScale(LessonOffset));  
setProperty ("\_root.Lesson", \_yscale, setScale(LessonOffset));  
// Move the Contact Us Icon  
setProperty ("\_root.ContactUs", \_x, 500-ContactUsOffset);  
setProperty ("\_root.ContactUs", \_xscale, setScale(ContactUsOffset));  
setProperty ("\_root.ContactUs", \_yscale, setScale(ContactUsOffset));  
// Move the MP3 Collection Icon  
setProperty ("\_root.MP3Collection", \_x, 550-MP3CollectionOffset);  
setProperty ("\_root.MP3Collection", \_xscale, setScale(MP3CollectionOffset));  
setProperty ("\_root.MP3Collection", \_yscale, setScale(MP3CollectionOffset));  
// Move the Bookmark Icon  
setProperty ("\_root.Bookmark", \_x, 600-BookmarkOffset);  
setProperty ("\_root.Bookmark", \_xscale, setScale(BookmarkOffset));  
setProperty ("\_root.Bookmark", \_yscale, setScale(BookmarkOffset));  
// Move the Links Icon  
setProperty ("\_root.Links", \_x, 650-LinksOffset);  
setProperty ("\_root.Links", \_xscale, setScale(LinksOffset));  
setProperty ("\_root.Links", \_yscale, setScale(LinksOffset));  
} else {  
setProperty ("\_root.Home", \_x, 200);  
setProperty ("\_root.Home", \_xscale, 100);  
setProperty ("\_root.Home", \_yscale, 100);  
setProperty ("\_root.NewsEvents", \_x, 250);  
setProperty ("\_root.NewsEvents", \_xscale, 100);  
setProperty ("\_root.NewsEvents", \_yscale, 100);  
setProperty ("\_root.Schedule", \_x, 300);  
setProperty ("\_root.Schedule", \_xscale, 100);  
setProperty ("\_root.Schedule", \_yscale, 100);  
setProperty ("\_root.Manual", \_x, 350);  
setProperty ("\_root.Manual", \_xscale, 100);  
setProperty ("\_root.Manual", \_yscale, 100);  
setProperty ("\_root.Directions", \_x, 400);  
setProperty ("\_root.Directions", \_xscale, 100);  
setProperty ("\_root.Directions", \_yscale, 100);  
setProperty ("\_root.Lesson", \_x, 450);  
setProperty ("\_root.Lesson", \_xscale, 100);  
setProperty ("\_root.Lesson", \_yscale, 100);  
setProperty ("\_root.ContactUs", \_x, 500);  
setProperty ("\_root.ContactUs", \_xscale, 100);  
setProperty ("\_root.ContactUs", \_yscale, 100);  
setProperty ("\_root.MP3Collection", \_x, 550);  
setProperty ("\_root.MP3Collection", \_xscale, 100);  
setProperty ("\_root.MP3Collection", \_yscale, 100);  
setProperty ("\_root.Bookmark", \_x, 600);  
setProperty ("\_root.Bookmark", \_xscale, 100);  
setProperty ("\_root.Bookmark", \_yscale, 100);  
setProperty ("\_root.Links", \_x, 650);  
setProperty ("\_root.Links", \_xscale, 100);  
setProperty ("\_root.Links", \_yscale, 100);  
}  
}[/AS]

Thanx in advance, Voetsjoeba.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2003, 9:22pm UTC](https://forum.kirupa.com/t/ease-back-to-original-position/19702/2 "2003-04-30T21:22:11Z")

</div>

I’m not an expert at actionscript by any means…actually I just started using AS fully about 2 weeks ago. But in that retrospect you should be able to ‘ease’ back into position by changing the code in the else statement. I’m not sure which version of Flash you are using, but the setProperty function was depreciated in Flash 5. So I am not going to be using any legacy code like you.

Grrr…this window is to narrow… code looks like crap. Pasted from BBedit…

```auto

..... } else {
 var linkArray = new array ["HomeOffset", "NewsEventsOffset", "ScheduleOffset", "ManualOffset", "DirectionsOffset", "LessonOffset", "ContactUsOffset", "MP3CollectionOffset", "BookmarkOffset", "LinksOffset"]
 
 for (n=0; n<=linkArray.length; n++) {
 	var targetClip = linkArray[n];
 		if (_root.targetClip._x != 200 || _root.targetClip._yscale >= 100) {
 		_root.targetClip._x -= 10;
 		_root.targetClip._yscale -= 2;
 		_root.targetClip._xscale -= 2;
 		}
 }
}

```

Once again this is not tested but the syntax is correct I think it should but I am also a newbie. I am sure their is a better way to code it as well, but this is what I got.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 1, 2003, 6:19am UTC](https://forum.kirupa.com/t/ease-back-to-original-position/19702/3 "2003-05-01T06:19:08Z")

</div>

Thank you for your answer, i’ll try it out right away. I’m using Flash MX, and I know the code is deprecated but I got it from [Flashkit.com](http://Flashkit.com) and it’s a waste of time to change all that code if it works 🙂

Thank you for your answer, it’s very much appreciated :beam:

Voetsjoeba.
