Chapter 5. ActionScript Basics for Flex Applications
IN THIS CHAPTER
ActionScript’s Relationship with MXML
“A good chemist is twenty times as useful as any poet.”
ActionScript is the glue that holds your application together. As you know, you’ll use MXML to establish an application’s layout and structure,; in contrast, you’ll use ActionScript to manage interaction, event handling, and processing logic.
Knowing where to place your script, how to create reusable code, and other scripting basics will help you build more powerful applications. 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 start making an impact with this powerful programming language.
Getting Ready
In this chapter, we’ll finish the HelloWorld
application by adding some interaction with ActionScript. So go ahead and open that project again; the code is shown in Example 5-1.
<?xml version="1.0" encoding="utf-8"?><s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009
" xmlns:s="library://ns.adobe.com/flex/spark
" xmlns:mx="library://ns.adobe.com/flex/mx
" width="100%
" height="100%
">
<s:Label
id="titleLabel
" x="50
" y="50
" fontFamily="Arial
" fontWeight="bold
" text="My First Flex 4 Application
"/>
<s:HGroup
x="50
" y="70
Get Learning Flex 4 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.