1 Reply Latest reply on Aug 16, 2007 5:06 AM by Newsgroup_User

    Swap to another movieclip

    lokat Level 1
      How can I swap from a movieclip "a" to movieclip "b" if "a" (instance name "a") is already put on the stage whereas "b" is in the library.
        • 1. Re: Swap to another movieclip
          Level 7
          To swap one clip for another, you just want to attach a new clip at the same
          depth as the old clip.
          Here's a function that will swap a clip with one from the library - the
          instance name, and clip position stay the same.

          function swapClips(originalClip:MovieClip, newClipLinkage:String) {
          var d = originalClip.getDepth();
          this.attachMovie(newClipLinkage, originalClip._name, d,
          {_x:originalClip._x, _y:originalClip._y});
          }

          If clipB has a linkage name of "libraryClip_B" then you'd swap a and b with:

          swapClips(clipA, "libraryClip_B");


          HTH

          --
          Dave -
          Head Developer
          http://www.blurredistinction.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/