Cover | Table of Contents
mxmlc and compc compilers (see the section "" later in this chapter, for more details on the compilers). You can download the SDK at http://www.adobe.com/products/flex/sdk.mxmlx and compc compilers. You can download a trial version of Flex Builder 2 or purchase a license at http://www.adobe.com/go/flexbuilder.mxmlc and compc compilers (see the section "" later in this chapter, for more details on the compilers). You can download the SDK at http://www.adobe.com/products/flex/sdk.mxmlx and compc compilers. You can download a trial version of Flex Builder 2 or purchase a license at http://www.adobe.com/go/flexbuilder.mxmlc compiler. If you're using Flex Builder 2, you may want to skip directly to the section "" later in this chapter.mxmlc compiler is used to compile Flex applications (versus compc, which is used to compile components and libraries). When you use Flex Builder to compile, it automatically calls mxmlc (Flex Builder includes the SDK).mxmlc, including from the command line, from a .bat or shell script, from an IDE, and from Apache Ant. Initially we'll look at using mxmlc from the command line since it's the most basic way to use the compiler (though we'll also look at using the compiler via Apache Ant later in this chapter). All the compiler flags we'll look at from the command line also apply to any other use of the compiler.mxmlc from the command line, it's generally a good idea to make sure you add it to your system path. If you're running Windows and you're uncertain how to edit your system path, follow these steps:;) as a delimiter. If necessary, add a semicolon between the existing value and the new addition.<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM
"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="www.example.com" />
</cross-domain-policy><cross-domain-policy> node can contain one or more <allow-access-from> elements. The <allow-access-from> elements specify the domains that can access the resources on the server. You can use an * wildcard in place of the subdomain, which means that any subdomain can access the data resources. For example, the following policy allows access from www.example.com, beta.example.com, test.example.com, and so on:<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM
"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*.example.com" />
</cross-domain-policy>* wildcard in place of the entire domain to allow access from all domains:<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM
"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy><object> HTML tag, and you can add a plug-in instance using the <embed> HTML tag. The basic code to add Flash Player to a page for any browser is as follows:<object id='application' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/ swflash.cab#version=9,0,0,0' height='100%' width='100%'> <param name='src' value='application.swf'/> <embed name='application' pluginspage='http://www.macromedia.com/ shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' src='application.swf' height='100%' width='100%'/> </object>
<script type="text/javascript" src="swfobject.js"></script>
div into which you'll write the .swf content:<div id="flexApplication"> This text will be replaced with the Flex application. </div>
SWFObject instance and tell it to write to the div:<script type="text/javascript">
var so = new SWFObject("flexApplication.swf", "exampleApplication",
"600", "400", "9", "#000000");
so.write("flexApplication");
</script><?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
Application nodes as the root node. All Flex applications must have one application document that is the only type of document you can compile into an application. The following is an example of a basic application document that Flex Builder creates by default:<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> </mx:Application>
click attribute within the component tag. The value that you assign to an event attribute gets interpreted as ActionScript. The following example handles a button click event and launches an alert window:<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Button id="alertButton" label="Show Alert"
click="mx.controls.Alert.show('Example')" />
</mx:Application>String, Number, Date, and Array as well as Flash Player-specific classes such as DisplayObject, URLLoader, NetConnection, Video, and Sound.Application, VBox, etc.), controls (Button, TextInput, etc.), and other assorted data, manager, and utility classes that are discussed throughout much of this book.<mx:Button id="alertButton" label="Show Alert"
click="mx.controls.Alert.show('Example')" />click event handler attribute is ActionScript code, which calls a show( ) method of an ActionScript class called Alert.<mx:VBox>
<mx:TextInput id="input" />
<mx:Text id="output" text="{input.text}" />
</mx:VBox>input.text to evaluate the text property value for the input object (the text input control).input.text. You could use a more complex expression, such as the following:<mx:VBox>
<mx:TextInput id="input" />
<mx:Text id="output" text="{'User input: ' + input.text}" />
</mx:VBox>User input: with the user input from the text input control. You can also create even more complex expressions using inline data binding.<mx:Button id="alertButton" label="Show Alert" click="mx.controls.Alert.
show('Example');alertButton.x += 40;" />