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, see it here. 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.