• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 16. ActionScript Authoring Environment > Adding Scripts to Movie Clips

16.4. Adding Scripts to Movie Clips

We've already seen that we can attach code to the frames of a movie clip's timeline. It is also possible to attach code to a movie clip instance itself. To do so, we select the instance on stage and then add our code to the Script pane of the Actions panel. As with buttons, all code attached to movie clip objects must be contained within event handlers. Event handlers tell the interpreter when to execute the movie clip code. For example, the following code sets the variable x to 10 when a movie clip loads:

onClipEvent (load) {
  var x = 10;
}


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint