1 Reply Latest reply on May 17, 2007 7:47 AM by MotionMaker

    Cleaner Scripting

    Rick Gerard Adobe Community Professional & MVP
      I think the code says it all. For a current project I need to use a hit area to start an animation when a mouse rolls over a _mc.

      If I use the movie clip instead of a button I can simplify the script by using the first section of the attached code. In the simplified code I only have to define one over and one out state and then I can use a this statement to control the action.
      For any number of _mc's I just need one set of functions.

      Using buttons, each _mc needs it's own over and out definition and it's own unique set of functions.

      I've tried using a bunch of if (grnMC_button.onRollOver = true) {this statements apply only to grn_mc} (not really code) but I can't find anything that works. It would be a great time saver if I could because in the final project I've got about 75 movie clips to control with over functions.

      One more thing. I can't use the movie based code because the animations move out from under the buttons and the mouse over area gets big and overlaps the other "buttons". I guess I'm really looking for a way to define a hit area and still keep the code simple.

        • 1. Re: Cleaner Scripting
          MotionMaker Level 1
          I would create a generic class and link the class in the library window to each of the 75 clips. I included two versions of sample class depending if the events need to be handled outside the MovieClip or not.

          In the Library
          1. Select the MovieClip symbol.
          2. Open the MovieClip symbol properties. Icon at bottom of library window or right Click and select Properties.
          3. Open the Advanced dialog. Use toggle button Basic | Advanced.
          4. Check Export for Actionscript
          5. In AS 2.0 Class type the name of the class. The attached code uses EmbeddedMovieClipClassExample. Leave other options unchanged.

          In the example each of my clips had a stop() action on frame 1. Frame 1 had the label Stop. Frame 2 had the label Start. The last frame had the action gotoAndPlay("Start").