6 Replies Latest reply on Aug 10, 2007 1:23 PM by clbeech

    losing movie clip

    jwize
      You are supposed to be able to drag an object from the side bar and it duplicates on the main screen.

      There are two problems first the movie clip only persists one at a time and second the newly created clip doesn't release when the mouse button is released the first time.
        • 1. Re: losing movie clip
          >Vee<
          check me on this but isnt stopdrag(); supposed to be stopDrag();?

          • 2. Re: losing movie clip
            _name
            am not clear on what you mean when you state, "the movie clip only persists one at a time;" if you want more than one, set an interval with params.
            • 3. Re: losing movie clip
              Rothrock Level 5
              My guess is that you have a scope problem.

              You haven't specified where you want getNextHighestDepth() to get the next highest depth from. So consequently it is getting it from the clip you have attached this code to.

              But since you aren't attaching the clip to the same clip that this code is called from each time it is getting the same depth and attaching the new clip at the same depth – which replaces any clip that exists at that depth.

              Personally I am totally opposed to getNextHighestDepth() and the use of _root, but here is most likely the answer. (I can't believe I'm typing these words! Please don't tell anybody!)

              _root.getNextHighestDepth()

              • 4. losing movie clip
                clbeech Level 3
                I agree with you Rothrock, it says right in the documentation that calls to getNextHighestDepth() can cause problems, particularly when using v2 Components, and with the use of _root in the event of loaded swf files.

                I like to use '_level0' , instead of _root, and is absolute relative to the swf.
                Also since jwize is already tracking the clips by number with 'objectCounter' it could be used as the depth assignment.

                I'm thinking that the duplication of the on handlers might be the cuase of the release issue, maybe a moving the newClip's handlers to it's timeframe would solve this? or removing the 'outside' on(release) to stopDrag() (you're right there V) because the second 'set' of them are taking control of the newClip?
                • 5. Re: losing movie clip
                  >Vee< Level 1
                  Simplifying this script sounds like a good start. Pass to a func. on the timeline:

                  dupThisClip, currentX, currentY

                  and I like the what was just mentioned about the depth assignment.
                  • 6. Re: losing movie clip
                    clbeech Level 3
                    right on Vee, also jwize to further simplify you could assign the XY properties in the attachMovie method by passing an Object.

                    var newClip = attachMovie("TableSquare", "TableSquare"+objectCounter, objectCounter, {_x:currentX, _y:currentY});

                    But in a function on the main timeline like Vee suggests.