12 Replies Latest reply on May 11, 2009 12:15 PM by kglad

    easy question.. attach movie?

    esco1313

      Hey! So i'm trying to play a movieclip from the library without having it on the stage... any idea how?

       

      yeah, i suck.

        • 1. Re: easy question.. attach movie?
          kglad Adobe Community Professional & MVP

          assign your library movie a linkage id (right click, tick export for actionscript and type a link id - say linkID) and use:

           

          this.attachMovie("linkID","instanceName",depth);

           

          where depth is an integer depth and that code is attached to the timeline to which you want to attach your library movieclip.  to attach to a different parent use:

           

          parent.attachMovie("linkID","instanceName",depth);

           

          if you're not using components you can use this.getNextHighestDepth() instead of a depth variable to manage your depths.

          1 person found this helpful
          • 2. Re: easy question.. attach movie?
            esco1313 Level 1

            ok it seems to work when i put the fade Mc on the stge... but i cant seem to get it to load if its not on the stage... i think its because i cant give it an instance name.. or maybe i'm not doing it right.

            where can i give it an instance name if its not on the stage?

            • 3. Re: easy question.. attach movie?
              kglad Adobe Community Professional & MVP

              the 2nd parameter in the attachMovie() method is the instance name.  in the code i showed i used "instanceName" for the new movieclips instance name.

               

              the attachMovie() method returns the newly created instance so you can use:

               

              var mc:MovieClip=this.attachMovie("linkageID","instName",depth)

               

              and mc will reference the newly created movieclip.

              • 4. Re: easy question.. attach movie?
                esco1313 Level 1

                ok.. are you saying that its creating a new instance name from the code you wrote? or it's assuming i already gave it an instance name? (sorry i'm lost)

                 

                this is the code i put:

                 

                this.onRelease = function()

                {
                this.attachMovie("blkFadeID","blkFade",this.getNextHighestDepth(), {_x:0, _y:0});
                }

                 

                now.. the "blkFade" is the instance name... but i cant figure out how to give it this instance name !!

                i tried:

                 

                this.onRelease = function(){
                this.attachMovie("blkFadeID","blkFade",this.getNextHighestDepth(), {_x:0, _y:0});
                var blkFade:MovieClip=this.attachMovie("blkFadeID","blkFade",this.getNextHighestDepth())

                }

                 

                i MUST be really faaaarr

                • 5. Re: easy question.. attach movie?
                  kglad Adobe Community Professional & MVP

                  esco1313 wrote:

                   

                  ok.. are you saying that its creating a new instance name from the code you wrote?

                   

                  yes

                   

                  or it's assuming i already gave it an instance name? (sorry i'm lost)

                   

                  this is the code i put:

                   

                  this.onRelease = function()

                  {
                  this.attachMovie("blkFadeID","blkFade",this.getNextHighestDepth(), {_x:0, _y:0});
                  }

                   

                  now.. the "blkFade" is the instance name...

                   

                  yes

                   

                  try:

                   

                  this.onRelease = function(){
                  this.attachMovie("blkFadeID","blkFade",this.getNextHighestDepth(), {_x:0, _y:0});
                  this.blkFade._rotation =5;

                  }

                   

                   

                  • 6. Re: easy question.. attach movie?
                    esco1313 Level 1

                    i'm sorry to be persistant...

                    this is exactly what i wrote:

                     

                    this.onRelease = function(){
                    this.attachMovie("blkFadeID","blkFade",this.getNextHighestDepth(), {_x:0, _y:0});
                    this.blkFade._rotation =5;

                    }

                     

                    where blkFadeID is the identifier i gave it. The movieclip blkFade is located in the library. The button to which i'm trying to link all of that is not at the root, yet i'm writing the code in the AS frame inside the Mc where my button is.

                     

                    not working.


                    (btw...why the rotation?)

                     

                    i'm pretty sure i'm doing something very wrong.. it seems too simple to be right..

                    • 7. Re: easy question.. attach movie?
                      esco1313 Level 1

                      help?... anyone...?

                      • 8. Re: easy question.. attach movie?
                        kglad Adobe Community Professional & MVP

                        did you assign a linkage id?

                         

                        if you button a movieclip button?

                        • 9. Re: easy question.. attach movie?
                          esco1313 Level 1

                          yes on both questions.

                          • 10. Re: easy question.. attach movie?
                            esco1313 Level 1

                            ok! it worked!

                             

                            however... if i want it to play at tne root... is there a way to tell it to play at a desired place? because right now, its playing where my button is. But my button calls an animation which is at the root. so therefore, i'd like to play the animation "blkFade" at the root.

                             

                            any ideas?

                            • 11. Re: easy question.. attach movie?
                              esco1313 Level 1

                              OK GOT IT!!!!! YEEEPPIIIIII!I!I!I!I!II!

                               

                              one more question... a real one now:P

                               

                              is there a way to make this movieclip (which is in th library) playing on the main stage, to have it play at a certain layer?say under the LOGO but on top of the BackGround?

                              • 12. Re: easy question.. attach movie?
                                kglad Adobe Community Professional & MVP

                                you can use the swapDepths() method of movieclips to position the relative depths of your movieclips.