Chapter 5. LEARNING THE BASICS OF SCRIPTING

ActionScript is the glue that holds your application together. While you’ll use MXML for the layout and structure of your application, you’ll generally need (at least a little) ActionScript to make things happen. How much you’ll need depends on the application, but then, as they say, a little goes a long way.

Knowing where to optimally place scripts, how to create reusable code, and other basics of ActionScript programming will help you to build more powerful Flex applications. Also, recognizing how ActionScript and MXML work together is key to understanding the Flex framework. In this chapter, you’ll gain the knowledge you need to get going with this powerful—and surprisingly simple—programming language.

Getting Ready

In this chapter, you’ll learn to make your HelloWorld application from Chapter 3 “do something.” So go ahead and open that project again; we’ll be using some of it to do some hands-on learning.

Often, buttons are the main point of contact for making something happen, so that’s where you’ll start. The button in your HelloWorld application says “Click me,” so it makes sense to start with it.

As an example, I’ll show you how to autofill the TextInput with your name when you click this button. That means you’ll be referring to this TextInput in ActionScript to access the text properties. To do that, the TextInput will need a name. That’s where the id attribute comes into play. Using the Flex Properties panel in Flex Builder’s Design ...

Get Learning Flex 3 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.