5 Replies Latest reply on Feb 8, 2010 6:51 AM by kglad

    Replacing a movieclip without changing it's children/depth/tweens

    Roland684-oqZIvV

      I would like to be able to draw a simple box as a background/placeholder, dress it up with buttons and movie clips at design time, and at runtime call a function to replace the simple box with a new design. How would I go about doing this?

      I have a graphic design that is too complicated to make with flash. So i made a piece of actionscript that can restyle any existing movieclip. This piece of code works.

      It basically gets the coordinates of the specified mc, creates a new one in it's place and deletes the original.

      Unfortunately this also removes any nested movieclips and buttons and breaks animation tweens of this mc. So if the original mc would have a button on it and animates from left to right, the new one doesn't.

      • mc.clear(); looked very promising, but it only clears stuff you put on it at runtime while I need to clear the stuff from design-time. (= the simple box drawing object)
      • Creating a movieclip with the same name, at the same depth doesn't seem to work.
        oldbox.parent.createEmptyMovieClip(oldbox._name, oldbox.getDepth());
        The old movieclip keeps existing and neither of them animates.

      So I'm searching for a way to replace a movieclip or clear it's content at runtime.

       

       

      Or am I thinking in the wrong direction and are there other ways to restyle a movie clip?

        • 1. Re: Replacing a movieclip without changing it's children/depth/tweens
          kglad Adobe Community Professional & MVP

          i'm not sure what you're trying to do but, if you're trying to re-parent a movieclip you should consider using as3.

          • 2. Re: Replacing a movieclip without changing it's children/depth/tweens
            Roland684-oqZIvV Level 1

            AS3 is not an option, the hardware doesn't support it. But I don't think it would be required.

             

            I would like to clear the canvas of a movieclip, so to speak. Remove any drawing objects on it, but not remove any movieclips that I placed in the movieclip. I want to keep its position (x, y, width, height and depth), but clear it's aprearance so I can draw someting nice (lines, shapes, etc.) in its place.

             

            Drawing the nice stuff isn't the problem, clearing the canvas is.

             

            I would like to create a blue movieclip, just as a marker where actionscript should draw a nicer grey window. But I would like to be able to place other movieclips on it at design time.

            At runtime I then would clear the blue box and draw the nice design. But clearing the blue box is exactly what I can't get done. mc.clear(); clears anything I draw on the movieclip it at runtime, but it doesn't clear the graphic shapes I placed on it at runtime

             

            I could make the blue box completely transparent at design time, so it doesn't need to be cleared before actionscript draws the nice design, but that would make the box allmost impossible to use as a placeholder, because I can't see it while designing.

             

            Also deleting the blue movieclip and placing a brand new one in it's place could be an option, if there were a way to keep the motion tweens, children etc. Can I add/move the child mc's of one movieclip to another movieclip? and what about the motion tweens?

             

            These are the two thing I'm thinking of, but I need some help. Or maybe there is a better way?

            • 3. Re: Replacing a movieclip without changing it's children/depth/tweens
              kglad Adobe Community Professional & MVP

              if you convert your blue box to a movieclip, you can control it with actionscript during runtime including but not limited to, removing it, making its _visible property false, changing it's _alpha to zero and moving it off-stage.

              • 4. Re: Replacing a movieclip without changing it's children/depth/tweens
                Roland684-oqZIvV Level 1

                I do indeed make the blue box into a movieclip, otherwise there woud be no way to manipulate it. Or is there?

                 

                But I do not wish to remove the movieclip from screen (by making it transparent, invisible or moving it off stage) because all this would also affect it's children. I just want to clear the blue box.

                 

                - blue_box

                  - hello_world

                  - ok-button

                 

                I could get the desired effect by putting the blue box in yet another mc next to the other content, this way I can remove the blue box without affecting the other content. But that only complicates things, because at designtime I now have to manipulate and empty (thus invisible) container movieclip.

                 

                - empty container movieclip

                  - blue box

                  - hello world

                  - ok-button

                 

                 

                Simply put:

                At runtime I can draw a line on a movieclip and clear that using mc.clear();

                but how can I clear (at runtime) a line I drew on that same movieclip at design time?

                • 5. Re: Replacing a movieclip without changing it's children/depth/tweens
                  kglad Adobe Community Professional & MVP

                  you can't do exactly what you want.