4 Replies Latest reply on Apr 25, 2007 9:00 AM by Newsgroup_User

    Target path to a movieclip in AS3

    Newt99 Level 1


      In AS2, I would do this to store a reference to a movie clip:
      var mc_mymovieclip:Movieclip = _root.mc_world.mc_continent;

      Thereafter, I could use mc_mymovieclip in my class.

      In AS3, doing the same thing does not work.

      How can I do that (if possible) ?

      Best regards.
        • 1. Re: Target path to a movieclip in AS3
          Rothrock Level 5
          I'm just coming to this myself. AS3 wouldn't be very useful if something like this couldn't be done. If you check the help files (which have really gone down hill!) you will notice that the MovieClip class has almost no methods or properties anymore, so I don't think you will be able to to much with a MovieClip instance anyways. For manipulating visual objects with AS3, I think you need to look at the DisplayObject class. So something along the lines of:

          var myDisplay:DisplayObject=DisplayObject(this.myPic);

          I have place at design time an imported PNG on the stage and made it into a symbol. I gave that symbol an instance name of myPic.
          • 2. Re: Target path to a movieclip in AS3
            Newt99 Level 1
            Perfect !!!

            Exactly what I was looking for. Thanks.
            • 3. Re: Target path to a movieclip in AS3
              Rothrock Level 5
              Okay, remember the part where I said I'm just coming to the myself? Well this also works:

              var mySprite:Sprite=Sprite(myPic);

              I really don't understand the difference between Sprite and DisplayObject yet so I'm a bit confused. At first I thought that it would make a difference if myPic was just a static movieclip vs having a timeline. But even when I added a timeline motion tween to myPic both codes seemed to work.

              It might be because by placing the clip on the stage at authortime it has already been added to a DisplayObject at publish time (just one I didn't explicitly create).

              But then it gets even stranger, because if you check the Sprite class it doesn't have the alpha property, but I guess it inherits from DisplayObject (several steps above) so that is where it comes from.

              So can anybody else shed any light on when to use Sprite and when to use DisplayObject?
              • 4. Re: Target path to a movieclip in AS3
                Level 7
                MovieClip inheritance is

                MovieClip -> Sprite -> DisplayObjectContainer -> InteractiveObject ->
                DisplayObject -> EventDispatcher -> Object

                The alpha property is defined in the DisplayObject class, so both MovieClip
                and Sprite inherit the property.

                http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/MovieClip.html#pro pertySummary