Chapter 1. Flex and ActionScript Basics
A Flex application consists primarily of code written in two different languages: ActionScript and MXML. Now in its 3.0 incarnation, ActionScript has gone from a prototype-based scripting language to a fully object-oriented, strictly typed, ECMAScript language. MXML is a markup language that will feel comfortable immediately to anyone who has spent time working with Hypertext Markup Language (HTML), Extensible Markup Language (XML), or a host of newer markup-based languages.
How do MXML and ActionScript relate to one another? The compiler, after parsing through the different idioms, translates them into the same objects, so that
<mx:Button id="btn" label="My Button" height="100"/>
and
var btn:Button = new Button(); btn.label = "My Button"; btn.height = 100;
produce the same object. The major difference is that whereas creating that object in ActionScript (second example) creates the button and nothing else, creating the object in MXML adds the button to whatever component contains the MXML code. The Flex Framework handles calling the constructor of the object described in MXML and either adding it to the parent or setting it as a property of a parent.
MXML files can include ActionScript within an <mx:Script> tag, but ActionScript files cannot include MXML. Although it’s tempting to think of MXML as the description of the appearance and components that make up your application, and of ActionScript as the description of the event handlers and custom ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access