2 Replies Latest reply on May 28, 2006 9:45 AM by Rothrock

    duplicateMovieClip Questions

    takabean
      I am trying to duplicate a movieclip on the stage, and also set its properties.

      1. Does an instance of the "main" movie clip need to exist on the stage, or can I not dynamically create/duplicate movieclips on the stage from the Library?
      2. Why does onRelease not get called if the mouse button is released while above the other instances?
      3. In my code, I'm trying to set each duplicate instance's onRelease and onPress event handlers. I am unable to get it working if I use the variable 'i' (more efficient) than directly using the instance names:

      This works:
      mcQuestion0.onPress = onPressMe;
      This does not work:
      set("mcQuestion"+i+".onPress", "onPressMe");

      Any clues why?

      The array was used just to try something different - but that didnt work either (using the variable 'i').

        • 1. Re: duplicateMovieClip Questions
          takabean Level 1
          The following did work:
          this["mcQuestion"+i].onPress=onPressMe;
          BUT, why does this not work?
          set("mcQuestion"+i+".onPress", "onPressMe");

          So now 2 questions remain:
          1. Does an instance of the movie clip have to exist for me to be able to duplicate it, or can I just not dynamically create duplicates of a movie clip that exists only in the Library?
          2. How do I get onRelease to be called on a dragged movieclip, even when (the dragged clip) is under another object on the stage?

          thanks for any help.
          • 2. Re: duplicateMovieClip Questions
            Rothrock Level 5
            1. Check the help files for MovieClip.attachMovie(). While you are at it you might want to review duplicateMovie while you are at it!

            2. You might want to read the entry for MovieClip.onReleaseOutside. (I actually don't know for sure on this one, but I'm guessing that will be a good place to start!) I generally do these kinds of things like this:

            myClip.onRelease=myClip.onReleaseOutside=function(){
            //mycode goes here
            }

            It is a good idea to get in the habit of defining a onReleaseOutside because there are lots of ways the user can move out of the clip.