Chapter 8. Buttons and Interactivity
It’s time to get interactive! Animation alone doesn’t enable the user to control anything. The Web isn’t about seeing, it’s about doing. Its real power is in the user’s ability to interact with content to buy and sell merchandise, learn something new, and communicate with people all over the world.
We touched very briefly on interactivity in Chapter 3, in which we let the user restart the animation by clicking on Box Guy. But that is just the beginning. In this chapter, we’ll learn more about making Flash movies interactive through the use of buttons and ActionScript.
The easiest way to add interactivity to Flash is to use a button to run some ActionScript. One button might run a script that opens a web page, while another triggers the loading of a product catalog listing from a database. The ActionScript executed by a button can display help information for the user, add a product to a shopping cart, or send the user to any page in an online catalog. You may be saying, “Big deal. I can do those things with HTML.” True, but buttons can be much more powerful than a link in HTML. Buttons can contain animation and sound, react to rollovers, be activated or dimmed dynamically, or be repositioned automatically when, say, the browser window is resized.
Of course, buttons are just the beginning. There is really no limit to the interactivity you can create with ActionScript, and it can be implemented in a variety of ways. A great example of this is pixeltees ...
Get Flash Out of the Box now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.