6 Replies Latest reply on May 16, 2006 11:42 AM by blemmo

    adding sub movieclip   dynamically

      could anyone tell me how to add sub movieclip dynamically , when the user continues to draw the line with LMB.
      as we need to clear the newly created line when mouse- moving !

        • 1. Re: adding sub movieclip   dynamically
          blemmo Level 1
          I think it may be better to have 2 MCs from the start: 1 for drawing stuff while it gets created, the other one for (re)drawing the things when they are finished. So when you draw a line, this is done in mc1, which gets cleared on every mousemove. Then, when the drawing stops (mouse released or clicked again), the drawn line is redrawn in mc2, and mc1 can be cleared again to draw new stuff.
          That's how I do it. If you want to create a new MC for every drawn line, you could use createEmptyMovieClip and continue drawing in this new clip. This is also good, but creates a new MC for each line, and may lead to performance issues when there are a lot of lines. It may make deleting of lines easier though.

          • 2. Re: adding sub movieclip   dynamically
            james_solo Level 1
            thank you for your help ,blemmo .now i wanna to extent it to more than 2 point . let's see:

            the main problem is , when assigning the clips instant to the array like:mc.h=new Array(); , then mc.moveTo(h ._x, h._y); or mc.moveTo(mc.h ._x, mc.h._y) ; will cause a problem !!! i cannot solve at all , please help

            • 3. Re: adding sub movieclip   dynamically
              james_solo Level 1
              where's kglad , blemmo...
              • 4. Re: adding sub movieclip   dynamically
                blemmo Level 1
                There are quite some errors and scope issues in that code. I can't go through all the code at the moment, just some hints:
                in some cases, there's just 'i' instead of '_root.i' > would be another variable
                sometimes it's 'h[ i ]', should be 'mc.h[_root.i]'
                why is _root.i incremented with every mouseMove? I guess it should be incremented when another handle is set.

                Try to fix these things and see if that helps. If you still have problems, post the new code, I can have a look at it later.

                • 6. Re: adding sub movieclip   dynamically
                  blemmo Level 1
                  Please explain what exactly you want to do, it's not clear (to me). You want to draw polygons? Then you must specify how new points should be set, and how the polygon should be finished (so that no lines are attached anymore). And what is 'i' for? I guess for the knots, right?
                  I attached some code that places a new knot on stage with each mouse click, connected by lines. It's just a starting point; there's only one line because previous lines get deleted while moving the mouse. To remedy, redraw the previous line in another MC when the mouse is clicked again (like described in the other posting).

                  If you give some more details to your problem we could provide better help