A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Apply Action Scipt to a Movie Clip in the Library

Hybrid View

  1. #1
    Junior Member
    Join Date
    Jul 2007
    Location
    Hawaii
    Posts
    8

    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

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Like whenever you want to target a movieclip, use their instance names.

    gparis

  3. #3
    Junior Member
    Join Date
    Jul 2007
    Location
    Hawaii
    Posts
    8
    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,

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    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

  5. #5
    Junior Member
    Join Date
    Jul 2007
    Location
    Hawaii
    Posts
    8
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center