-
Adding a movieclip instance to stage at runtime?
I want to add an instance of a movieclip in my library to the stage, with Actionscript. But it seems the only methods i can find (attatchmovie ect...) , only add a movieclip into another movieclip.
Isn't there a way to create an instance of a library object directly onto the _root level?
-
incredibulus-actionscriptum
i think a simple _root.attachMovieClip("libraryname","newname",dept h)
should work
-
That was my first attempt.
It didn't seem to work...
If you can get it to work on yours, please let me know the details.
And if anyone else has the answer, Im REALLY anxtious to find out.
Last edited by Wakorobro; 01-30-2003 at 11:42 PM.
-
attachMovie is the correct command to use. Make sure that you have the linkage setup in your library and that you don't give it the same depth as anything else, otherwise it won't work.
Microsoft .NET MVP
-
Ok,
1 : how should i set up the linkage? Just export for actionscript and give it a name? And load on frame 1...
2 : After that, the correct syntax would be
_root.attatchmovie(LibObj,NewName,DisplayLevel) ?
( i ask these because its still not working )
3 : is there a simple way to dynamically get the value of the next available depth?
Thanks for the advice so far!
Last edited by Wakorobro; 01-31-2003 at 12:35 AM.
-
Senior Member
Just store some variable for the current depth and when attaching new movie increment it.
-
AAH! Nevermind i just figured what was wrong.
Stupid "expression" box in a command wasnt checked. GRR.
But now i have yet another problem. When the new instance is added, any other instance of that same Library MovieClip disappears
-
only reason that ever happens is because you gave it the same depth or the same name as one of the other items...check to make sure you didn't do that.
Microsoft .NET MVP
-
Good god! i fixed it!
turns out i needed to add quotation marks around the LibraryObject name and the NewInstance name! Jeez, they should have automated that in Simple code mode! There's not even a "expression" checkbox to suggest the engine might assume its a variable!
Anyway, it was a lot of typing, but problem solved!
Thanks again, this place rocks!
Last edited by Wakorobro; 01-31-2003 at 01:30 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|