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

Chapter 10. Events and Event Handling > Flash 5's on( ) and onClipEvent( ) Hand...

10.7. Flash 5's on( ) and onClipEvent( ) Handlers

Earlier in this chapter, we discussed how to assign callback functions to the event handler properties MovieClip.onEnterFrame( ) and TextField.onSetFocus( ). In Flash 5, these kinds of event handler properties were available on XML and XMLSocket only. Movie clips and buttons used idiosyncratic event handler syntax attached directly to physical clips or buttons in the Flash authoring tool. Button event handlers were defined using on(eventName), and movie clip event handlers were defined using onClipEvent(eventName), where eventName specified the event to be handled. As of Flash MX, use of these older forms is generally discouraged. Event handler properties and event listeners are preferred because they promote the separation of code from the visual elements of a movie. However, the older syntax is still supported, and there are a few special cases where it is actually required (for examples, see MovieClip.onLoad( ) and Button keyPress in the Language Reference).

Flash 5-style button on( ) event handlers take the form:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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