2 Replies Latest reply on Apr 14, 2008 4:21 AM by arpatupuropo

    Please Help me simplify this Script


      I did a magnyfying menu based on this Tutorial: http://www.flashkit.com/tutorials/Interactivity/Navigation/Mac_OS_X-Aaron_Ha-722/index.php

      The problem : is that I have 20 Menu Items. Each time I want to modify something, there are too much things to modify.

      The answer I'm lloking for: I guess there is a much more intelligent and short way of doing this using just a few script lines and a few xml or txt files:

      1-Creates Movie Clip with button inside
      2-Get the list of items to create in this txt file (lets say "list_of_movies_containing_a_button.txt")
      3-Put the butons separated by 40px on Y and X=0
      4-Name each button instance with this other txt file
      5-Put inside each bouton the text on this third file. text_appearing_in_each_button.txt
      6-For all buttons, use this colour on Over and this other color on mouse up style.css (?)
      7-Each button links to the url defined in Links.txt file.
      8-All buttons behave in such manner....

      Do you understand what I mean?
      Can you please help me? Thanks a lot

      Here's the 17th century script I'm using now (with only 10 items in this example)

      onClipEvent (load) {
      function checkOffset (coffset) {
      if (coffset<-120) {
      coffset = -120;
      } else if (coffset>120) {
      coffset = 120;

      return coffset;
      function setScale (soffset) {
      return 100*(2-(1*(Math.abs(soffset)/120)));
      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 = y-200;
      NewsEventsOffset = y-240;
      ScheduleOffset = y-280;
      ManualOffset = y-320;
      DirectionsOffset = y-360;
      LessonOffset = y-400;
      ContactUsOffset = y-440;
      MP3CollectionOffset = y-460;
      BookmarkOffset = y-500;
      LinksOffset = y-540;
      // If cursor is inside menu
      if (x>=0 and x<=100 and y>=100 and y<=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", _y, 200-HomeOffset);
      setProperty ("_root.Home", _xscale, setScale(HomeOffset));
      setProperty ("_root.Home", _yscale, setScale(HomeOffset));
      // Move the News and Events Icon
      // setProperty ("_root.NewsEvents", _y, 230-NewsEventsOffset);
      setProperty ("_root.NewsEvents", _xscale, setScale(NewsEventsOffset));
      setProperty ("_root.NewsEvents", _yscale, setScale(NewsEventsOffset));
      // Move the Schedule Icon
      //setProperty ("_root.Schedule", _y, 260-ScheduleOffset);
      setProperty ("_root.Schedule", _xscale, setScale(ScheduleOffset));
      setProperty ("_root.Schedule", _yscale, setScale(ScheduleOffset));
      // Move the Manual Icon
      // setProperty ("_root.Manual", _y, 290-ManualOffset);
      setProperty ("_root.Manual", _xscale, setScale(ManualOffset));
      setProperty ("_root.Manual", _yscale, setScale(ManualOffset));
      // Move the Directions Icon
      //setProperty ("_root.Directions", _y, 320-DirectionsOffset);
      setProperty ("_root.Directions", _xscale, setScale(DirectionsOffset));
      setProperty ("_root.Directions", _yscale, setScale(DirectionsOffset));
      // Move the Lesson Icon
      //setProperty ("_root.Lesson", _y, 350-LessonOffset);
      setProperty ("_root.Lesson", _xscale, setScale(LessonOffset));
      setProperty ("_root.Lesson", _yscale, setScale(LessonOffset));
      // Move the Contact Us Icon
      // setProperty ("_root.ContactUs", _y, 380-ContactUsOffset);
      setProperty ("_root.ContactUs", _xscale, setScale(ContactUsOffset));
      setProperty ("_root.ContactUs", _yscale, setScale(ContactUsOffset));
      // Move the MP3 Collection Icon
      // setProperty ("_root.MP3Collection", _y, 410-MP3CollectionOffset);
      setProperty ("_root.MP3Collection", _xscale, setScale(MP3CollectionOffset));
      setProperty ("_root.MP3Collection", _yscale, setScale(MP3CollectionOffset));
      // Move the Bookmark Icon
      //setProperty ("_root.Bookmark", _y, 440-BookmarkOffset);
      setProperty ("_root.Bookmark", _xscale, setScale(BookmarkOffset));
      setProperty ("_root.Bookmark", _yscale, setScale(BookmarkOffset));
      // Move the Links Icon
      //setProperty ("_root.Links", _y, 470-LinksOffset);
      setProperty ("_root.Links", _xscale, setScale(LinksOffset));
      setProperty ("_root.Links", _yscale, setScale(LinksOffset));
      } else {
      //setProperty ("_root.Home", _y, 200);
      setProperty ("_root.Home", _xscale, 100);
      setProperty ("_root.Home", _yscale, 100);
      // setProperty ("_root.NewsEvents", _y, 240);
      setProperty ("_root.NewsEvents", _xscale, 100);
      setProperty ("_root.NewsEvents", _yscale, 100);
      // setProperty ("_root.Schedule", _y, 280);
      setProperty ("_root.Schedule", _xscale, 100);
      setProperty ("_root.Schedule", _yscale, 100);
      //setProperty ("_root.Manual", _y, 290);
      setProperty ("_root.Manual", _xscale, 100);
      setProperty ("_root.Manual", _yscale, 100);
      // setProperty ("_root.Directions", _y, 320);
      setProperty ("_root.Directions", _xscale, 100);
      setProperty ("_root.Directions", _yscale, 100);
      //setProperty ("_root.Lesson", _y, 350);
      setProperty ("_root.Lesson", _xscale, 100);
      setProperty ("_root.Lesson", _yscale, 100);
      // setProperty ("_root.ContactUs", _y, 380);
      setProperty ("_root.ContactUs", _xscale, 100);
      setProperty ("_root.ContactUs", _yscale, 100);
      // setProperty ("_root.MP3Collection", _y, 410);
      setProperty ("_root.MP3Collection", _xscale, 100);
      setProperty ("_root.MP3Collection", _yscale, 100);
      //setProperty ("_root.Bookmark", _y, 440);
      setProperty ("_root.Bookmark", _xscale, 100);
      setProperty ("_root.Bookmark", _yscale, 100);
      //setProperty ("_root.Links", _y, 470);
      setProperty ("_root.Links", _xscale, 100);
      setProperty ("_root.Links", _yscale, 100);