Skip to main content
May 11, 2009
Answered

easy question.. attach movie?

  • May 11, 2009
  • 1 reply
  • 1277 views

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

yeah, i suck.

This topic has been closed for replies.
Correct answer kglad

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..


did you assign a linkage id?

if you button a movieclip button?

1 reply

kglad
Community Expert
Community Expert
May 11, 2009

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.

May 11, 2009

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?

kglad
Community Expert
Community Expert
May 11, 2009

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.