|
-
Apply Action Scipt to a Movie Clip in the Library
I use this clever script I got from this site to make a Movie Clip go forward and backward and it works great. Normally I click on the movie clip in my work area and put in the code.
Now I'm getting a little more tricky and loading Movie clips dynamically with code like attachmovie or loadmovie.
What I'd like to know is how to apply code to movies that are originally in the library and once I call it out, I need to apply my clever code to it.
Thanks
-
Like whenever you want to target a movieclip, use their instance names.
gparis
-
Thanks for the quick reply.
I want to actually put the script on the movie clip itself. Normally I would click on the movie clip and then put the action script directly on the clip. But since the movie clip is in the library until I call it dynamically, how do I put the code directly on the movie clip?
Thanks,
-
You can't. Actionscript needs to go on a frame. Since you going to attach the movieclip, you will give it a new name, it's that new name you use to target it.
So instead of the onClipEvent() handler, use instance.onEnterFrame = function(){//actions}
gparis
-
That's perfect! Thanks so much for that.
I'll play around with that code but the concept is the solution I was looking for. And coincidentally onEnterFrame is the exact code I was trying to apply to the movie clip so I think this will work perfectly.
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
|