About Flex files
147
<!-- button that triggers the copy -->
<mx:Button id="myButton" label="Copy Text"
click="myText.text=myInput.text" />
<!-- output text box -->
<mx:TextArea id="myText" width="150" height="20" />
</mx:VBox>
</mx:Application>
The content between the starting and closing
<mx:Application>
tags defines a Flex application.
Related topics
•
“Creating MXML or ActionScript files” on page 75
•
“Testing and debugging Flex files” on page 83
•
Flex ActionScript and MXML API Reference help
About ActionScript files in Flex applications
Although MXML is the primary authoring language for Flex applications, you use ActionScript
to manipulate and extend Flex applications. ActionScript is a procedural-based language similar
to JavaScript for manipulating Flash. For more information, see “Using ActionScript” in
Developing Flex Applications Help.
To use ActionScript in Flex applications, you must either add script blocks to the MXML file
using the
<mx:Script>
tag, or reference external ActionScript files using the same tag. The
following example shows both methods.
<mx:Script>
var myVar:Number;
function doSomething() {
myVar = myVar + 1;
}
</mx:Script>
<mx:Script source="myscripts/file1.as"></mx:Script>
In general, maintaining an application is easier if you place the ActionScript in a separate file and
use the
source
property of the
<mx:Script>
tag to import it in the MXML file.
If you add script blocks to an MXML file using the
<mx:Script>
tag, you must be careful about
using special characters within the script block.
A good coding practice is to “escape” all ActionScript blocks in your MXML files so that the
MXML parser ignores them. Because MXML is an XML-based language, the MXML parser will
interpret special XML characters such as angled brackets as MXML, not ActionScript.
Summary of Contents for FLEX BUILDER-USING FLEX BUILDER
Page 1: ...Using Flex Builder...
Page 116: ...116 Chapter 4 Building a Flex User Interface Visually...
Page 144: ...144 Chapter 6 Working with Data...
Page 154: ...154 Appendix A Basic Flex Concepts...