Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


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

Part One: The Fundamentals > Event Management

4. Event Management

If you’ve been reading this book sequentially, you should already have a pretty sound sense of the Flex landscape. The first chapter shows how to create applications. The second introduces the basic elements of a user interface. And the third teaches the fundamentals of ActionScript programming. But in order for applications to be truly a user experience (which is to say, interactive), you need to know how to manage events. A lot of what applications do is watch for, and respond to, events.

You can develop Flash content using Flash Professional, the old standard, or Flash Builder (previously known as Flex Builder). Flash Professional tends to start with animation that runs over a timeline. Conversely, Flex development is event-driven: The application is told to respond to things that happen. This take may be different than what you’ve done before, but it’s really easy to adopt. If anything, the biggest hurdle will be making the most of what’s possible.

Flex uses an event system that’s quite close to the Document Object Model (DOM) Level 3 Event Specification present in Web browsers (to varying degrees). What this means is that if you’ve done a wee bit of JavaScript programming, much of the syntax and theory in this book will be familiar. And even if you haven’t, you may be pleasantly surprised to see how obvious much of this information is. For example, can you guess what event represents the cursor going over an element? Yes, mouseOver.

The chapter begins with several pages discussing the premise of event management and what pieces are involved. Then you’ll learn how to handle events by placing ActionScript code within MXML components. The third section of the chapter walks through using functions to handle events (the functions are called event handlers in such circumstances). After that, I discuss the types of events in a bit more detail. The chapter concludes with an alternate way to manage events in an application.