Commit 694b2c27 authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

README.md

0 → 100644
+15 −0
Changes for README.md: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
## Example files for the title:  
  
# Programming Flex 3, by Joey Lott
  
[![Programming Flex 3, by Joey Lott](http://akamaicovers.oreilly.com/images/9780596516215/cat.gif)](https://www.safaribooksonline.com/library/view/title/9780596516215//)
  
The following applies to example files from material published by O’Reilly Media, Inc. Content from other publishers may include different rules of usage. Please refer to any additional usage rights explained in the actual example files or refer to the publisher’s website.
  
O'Reilly books are here to help you get your job done. In general, you may use the code in O'Reilly books in your programs and documentation. You do not need to contact us for permission unless you're reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from our books does not require permission. Answering a question by citing our books and quoting example code does not require permission. On the other hand, selling or distributing a CD-ROM of examples from O'Reilly books does require permission. Incorporating a significant amount of example code from our books into your product's documentation does require permission.
  
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN.
  
If you think your use of code examples falls outside fair use or the permission given here, feel free to contact us at <permissions@oreilly.com>.
  
Please note that the examples are not production code and have not been carefully testing. They are provided "as-is" and come with no warranty of any kind.

example_code/ch02.txt

0 → 100644
+268 −0
Changes for example_code/ch02.txt: 268 added lines, 0 removed lines.
Original line number Diff line number Diff line
chapter: Building Applications with the Flex Framework
==================
export PATH=$PATH:/Users/username/FlexSDK/bin
    
    
====================================
export PATH=$PATH:/existing/directories:/Users/username/FlexSDK/bin
    
    
====================================
source ~/.profile
    
    
====================================
mxmlc -file-specs SampleApplication.mxml
    
    
====================================
mxmlc -help
    
    
====================================
mxmlc SampleApplication.mxml
    
    
====================================
mxmlc SampleApplication.mxml -output bin/main.swf
    
    
====================================
mxmlc -source-path . C:\FlexApplicationCommonLibraries -file-specs
SampleApplication.mxml
    
    
====================================
mxmlc -default-background-color=0xFFFFFF SampleApplication.mxml
    
    
====================================
mxmlc -default-script-limits 200 15 -file-specs SampleApplication.mxml
    
    
====================================
mxmlc -title "Sample Application" -description "A Flex Sample Application" -file-
specs SampleApplication.mxml
    
    
====================================
mxmlc -incremental=true -file-specs SampleApplication.mxml
    
    
====================================
mxmlc -load-config=configuration.xml SampleApplication.mxml
    
    
====================================
mxmlc -load-config+=configuration.xml SampleApplication.mxml
    
    
====================================
<flex-config xmlns="http://www.adobe.com/2006/flex-config">
</flex-config>
    
    
====================================
-benchmark
-compiler.accessible
-compiler.actionscript-file-encoding <string>
-compiler.allow-source-path-overlap
-compiler.as3
-compiler.context-root <context-path>
-compiler.debug
-compiler.defaults-css-files [filename] [...]
-compiler.defaults-css-url <string>
-compiler.define <name> <value>
-compiler.es
-compiler.external-library-path [path-element] [...]
-compiler.fonts.advanced-anti-aliasing
-compiler.fonts.flash-type
-compiler.fonts.languages.language-range <lang> <range>
-compiler.fonts.local-fonts-snapshot <string>
-compiler.fonts.managers [manager-class] [...]
-compiler.fonts.max-cached-fonts <string>
-compiler.fonts.max-glyphs-per-face <string>
-compiler.headless-server
-compiler.include-libraries [library] [...]
-compiler.incremental
-compiler.keep-all-type-selectors
-compiler.keep-as3-metadata [name] [...]
-compiler.keep-generated-actionscript
-compiler.library-path [path-element] [...]
-compiler.locale [locale-element] [...]
-compiler.mxml.compatibility-version <version>
-compiler.namespaces.namespace <uri> <manifest>
-compiler.optimize
-compiler.services <filename>
-compiler.show-actionscript-warnings
-compiler.show-binding-warnings
-compiler.show-shadowed-device-font-warnings
-compiler.show-unused-type-selector-warnings
-compiler.source-path [path-element] [...]
-compiler.strict
-compiler.theme [filename] [...]
-compiler.use-resource-bundle-metadata
-compiler.verbose-stacktraces
-compiler.warn-array-tostring-changes
-compiler.warn-assignment-within-conditional
-compiler.warn-bad-array-cast
-compiler.warn-bad-bool-assignment
-compiler.warn-bad-date-cast
-compiler.warn-bad-es3-type-method
-compiler.warn-bad-es3-type-prop
-compiler.warn-bad-nan-comparison
-compiler.warn-bad-null-assignment
-compiler.warn-bad-null-comparison
-compiler.warn-bad-undefined-comparison
-compiler.warn-boolean-constructor-with-no-args
-compiler.warn-changes-in-resolve
-compiler.warn-class-is-sealed
-compiler.warn-const-not-initialized
-compiler.warn-constructor-returns-value
-compiler.warn-deprecated-event-handler-error
-compiler.warn-deprecated-function-error
-compiler.warn-deprecated-property-error
-compiler.warn-duplicate-argument-names
-compiler.warn-duplicate-variable-def
-compiler.warn-for-var-in-changes
-compiler.warn-import-hides-class
-compiler.warn-instance-of-changes
-compiler.warn-internal-error
-compiler.warn-level-not-supported
-compiler.warn-missing-namespace-decl
-compiler.warn-negative-uint-literal
-compiler.warn-no-constructor
-compiler.warn-no-explicit-super-call-in-constructor
-compiler.warn-no-type-decl
-compiler.warn-number-from-string-changes
-compiler.warn-scoping-change-in-this
-compiler.warn-slow-text-field-addition
-compiler.warn-unlikely-function-value
-compiler.warn-xml-class-has-changed
-debug-password <string>
-default-background-color <int>
-default-frame-rate <int>
-default-script-limits <max-recursion-depth> <max-execution-time>
-default-size <width> <height>
-dump-config <filename>
-externs [symbol] [...]
-frames.frame [label] [classname] [...]
-help [keyword] [...]
-include-resource-bundles [bundle] [...]
-includes [symbol] [...]
-licenses.license <product> <serial-number>
-link-report <filename>
-load-config <filename>
-load-externs <filename>
-metadata.contributor <name>
-metadata.creator <name>
-metadata.date <text>
-metadata.description <text>
-metadata.language <code>
-metadata.localized-description <text> <lang>
-metadata.localized-title <title> <lang>
-metadata.publisher <name>
-metadata.title <text>
-output <filename>
-raw-metadata <text>
-resource-bundle-list <filename>
-runtime-shared-libraries [url] [...]
-runtime-shared-library-path [path-element] [rsl-url] [policy-file-url] 
[rsl-url] [policy-file-url]
-static-link-runtime-shared-libraries
-target-player <version>
-use-network
-verify-digests
-version
-warnings
    
    
====================================
<flex-config xmlns="http://www.adobe.com/2006/flex-config">
  <compiler>
    <incremental>true</incremental>
  </compiler>
  <metadata>
    <title>Example</title>
  </metadata>
</flex-config>
    
    
====================================
<flex-config xmlns="http://www.adobe.com/2006/flex-config">
  <metadata>
    <localized-title>
      <text>Example</text>
      <lang>en_US</lang>
    </localized-title>
  </metadata>
</flex-config>
    
    
====================================
<flex-config xmlns="http://www.adobe.com/2006/flex-config">
  <file-specs>
    <path-element>Example.mxml</path-element>
  </file-specs>
</flex-config>
    
    
====================================
<flex-config xmlns="http://www.adobe.com/2006/flex-config">
  <file-specs>
    <path-element>Example.mxml</path-element>
    <path-element>Example2.mxml</path-element>
    <path-element>Example3.mxml</path-element>
    <path-element>Example4.mxml</path-element>
  </file-specs>
</flex-config>
    
    
====================================
mxmlc -help use-network
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<project name="FlexTest" default="compile" basedir="./">
</project>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<project name="FlexTest" default="compile" basedir="./">
    <taskdef resource="flexTasks.tasks"
classpath="${basedir}/flexTasks/lib/flexTasks.jar"/>
    <property name="FLEX_HOME" value="C:/flex/sdk"/>
    <property name="APP_ROOT" value="myApp"/>
</project>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<project name="FlexTest" default="compile" basedir="./">
    <taskdef resource="flexTasks.tasks"
classpath="${basedir}/flexTasks/lib/flexTasks.jar"/>
    <property name="FLEX_HOME" value="C:/flex/sdk"/>
    <property name="APP_ROOT" value="myApp"/>
    <target name="compile">
        <mxmlc file="${APP_ROOT}/FlexTest.mxm">
        <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
        <source-path path-element="${FLEX_HOME}/frameworks"/>
    </target>
</project>
    
    
====================================
ant
    
    
====================================
ant target1 target2
    
    
====================================
ViewSource.addMenuItem(this, "sourcecode/index.html");
    
    
==================
 No newline at end of file

example_code/ch03.txt

0 → 100644
+153 −0
Changes for example_code/ch03.txt: 153 added lines, 0 removed lines.
Original line number Diff line number Diff line
chapter: MXML
==================
<?xml version="1.0" encoding="utf-8"?>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

</mx:Application>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">

</mx:Canvas>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml">

</mx:Module>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  <mx:Button label="Example Button"></mx:Button>
</mx:Application>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Button label="Example Button" />
</mx:Application>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://www.adobe.com/2006/mxml" layout="absolute">
  <Button label="Example Button" />
</Application>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  <mx:Button label="Example Button" />
</mx:Application>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                xmlns:example="http://www.example.com" layout="absolute">
  <mx:Button label="Example Button" />
  <example:Button />
</mx:Application>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  <mx:VBox>
    <mx:Button label="Example Button 1" />
    <mx:Button label="Example Button 2" />
  </mx:VBox>
</mx:Application>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  <mx:VBox>
    <mx:Button label="Example Button 1" />
    <mx:Button label="Example Button 2" />
    <mx:HBox>
      <mx:Button label="Example Button 3" />
      <mx:Button label="Example Button 4" />
    </mx:HBox>
  </mx:VBox>
</mx:Application>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

</mx:Application>
    
    
====================================
<mx:Button id="exampleButton" label="Example Button" />
    
    
====================================
<mx:Button id="exampleButton">
  <mx:label>Example Button</mx:label>
</mx:Button>
    
    
====================================
<mx:ComboBox id="exampleComboBox">
  <mx:dataProvider>
    <mx:ArrayCollection>
      <mx:Array>
        <mx:String>A</mx:String>
        <mx:String>B</mx:String>
        <mx:String>C</mx:String>
        <mx:String>D</mx:String>
      </mx:Array>
    </mx:ArrayCollection>
  </mx:dataProvider>
</mx:ComboBox>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  <mx:Script>
  <![CDATA[
    import mx.controls.Alert;
  ]]>
  </mx:Script>
  <mx:Button id="alertButton" label="Show Alert"
             click="Alert.show('Example')" />
</mx:Application>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  <mx:VBox>
    <mx:Text id="output" text="Example" width="200" height="200"  />
    <mx:TextInput id="input" />
  </mx:VBox>
</mx:Application>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  <mx:VBox>
    <mx:Text id="output" text="{input.text}" width="200" height="200" />
    <mx:TextInput id="input" />
  </mx:VBox>
</mx:Application>
    
    
==================
 No newline at end of file

example_code/ch04.txt

0 → 100644
+895 −0

File added.

Preview size limit exceeded, changes collapsed.

example_code/ch05.txt

0 → 100644
+298 −0
Changes for example_code/ch05.txt: 298 added lines, 0 removed lines.
Original line number Diff line number Diff line
chapter: Framework Fundamentals
==================
Example: Displaying the description of the parent of an
        application<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="creationCompleteHandler();">
    <mx:Script>
         <![CDATA[
              import flash.utils.describeType;

              private function creationCompleteHandler():void {
                   textArea.text = flash.utils.describeType(parent);
              }

         ]]>
    </mx:Script>
    <mx:TextArea id="textArea" width="100%" height="100%" />
</mx:Application>
    
    
====================================
<mx:SWFLoader source="application.swf" />
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
        <![CDATA[

            public function setBackground(color:Number):void {
                canvas.setStyle("backgroundColor", color);
            }

        ]]>
    </mx:Script>
    <mx:Canvas id="canvas" backgroundColor="#FFFFFF" width="100" height="100" />
</mx:Application>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
        <![CDATA[
            import mx.managers.SystemManager;
            import mx.events.FlexEvent;

            private function initHandler(event:Event):void {
                event.target.content.addEventListener(FlexEvent.APPLICATION_COMPLETE,
applicationCompleteHandler);
            }

            private function applicationCompleteHandler(event:Event):void {
                event.target.application.setBackground(0xFFFF00);
            }

        ]]>
    </mx:Script>
    <mx:SWFLoader source="B.swf" init="initHandler(event)" />
</mx:Application>
    
    
====================================
var context:LoaderContext = new LoaderContext();
context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
var request:URLRequest = new URLRequest("RuntimeLoadingExample.swf");
var loader:Loader = new Loader();
loader.load(request, context);
    
    
====================================
var context:LoaderContext = new LoaderContext();
context.applicationDomain = new ApplicationDomain();
var request:URLRequest = new URLRequest("RuntimeLoadingExample.swf");
var loader:Loader = new Loader();
loader.load(request, context);
    
    
====================================
var context:LoaderContext = new LoaderContext();
context.applicationDomain = ApplicationDomain.currentDomain;
var request:URLRequest = new URLRequest("RuntimeLoadingExample.swf");
var loader:Loader = new Loader();
loader.load(request, context);
    
    
====================================
instruction=Select a value
color=Color
send=Send
    
    
====================================
instruction=Select a value
color=Color
send=Send
flag=Embed('../../usa.jpg')
    
    
====================================
Example: U.S. English resource bundleinstruction=Select a value
color=Color
send=Send
flag=Embed('../../assets/usa.jpg')
    
    
====================================
Example: Canadian English resource bundleinstruction=Select a value
color=Colour
send=Send
flag=Embed('../../assets/canada.jpg')
    
    
====================================
Example: Spanish (Spain) resource bundleinstruction=Seleccione un valor
color=Color
send=Envíe
flag=Embed('../../assets/spain.jpg')
    
    
====================================
copylocale existingLocale newLocale
    
    
====================================
copylocale en_US fr_FR
    
    
====================================
<mx:Label text="@Resource(bundle='languageResources', key='color')" />
    
    
====================================
var color:uint = ResourceManager.getInstance().getInt("languageResources", "color");
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
    <mx:Form>
         <mx:FormHeading label="@Resource(key='instruction', bundle=
'languageResources')" />
         <mx:FormItem label="@Resource(bundle='languageResources', key='color')">
              <mx:ColorPicker id="color" />
         </mx:FormItem>
         <mx:FormItem>
              <mx:Button label="@Resource(bundle='languageResources', key='send')" />
         </mx:FormItem>
    </mx:Form>
    <mx:Image source="@Resource(bundle='languageResources', key='flag')" />
</mx:Application>
    
    
====================================
mxmlc -locale en_CA -source-path=../locale/{locale} Example.mxml
    
    
====================================
-local en_CA -source-path=../locale/{locale}
    
    
====================================
-locale en_US en_CA es_ES -source-path=../locales/{locale}
    
    
====================================
resourceManager.localeChain = ["en_US"];
    
    
====================================
<mx:Metadata>
    [ResourceBundle("languageResources")]
</mx:Metadata>
    
    
====================================
Example: Selecting a locale at runtime<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
    <mx:Metadata>
         [ResourceBundle("languageResources")]
    </mx:Metadata>
    <mx:Script>
         <![CDATA[

              private function selectLanguage():void {
                   resourceManager.localeChain = [language.value];
              }

         ]]>
    </mx:Script>
    <mx:ComboBox id="language" change="selectLanguage();">
         <mx:dataProvider>
              <mx:ArrayCollection>
                   <mx:Object label="English (US)" data="en_US" />
                   <mx:Object label="English (Canada)" data="en_CA" />
                   <mx:Object label="Espanol (Espana)" data="es_ES" />
              </mx:ArrayCollection>
         </mx:dataProvider>
    </mx:ComboBox>
    <mx:Form>
         <mx:FormHeading
label="{resourceManager.getString('languageResources', 'instruction')}" />
         <mx:FormItem
label="{resourceManager.getString('languageResources', 'color')}">
              <mx:ColorPicker id="color" />
         </mx:FormItem>
         <mx:FormItem>
              <mx:Button
label="{resourceManager.getString('languageResources', 'send')}" />
         </mx:FormItem>
    </mx:Form>
    <mx:Image
source="{resourceManager.getClass('languageResources', 'flag')}" />
</mx:Application>
    
    
====================================
mxmlc -locale= -resource-bundle-list=listOfResourceBundles.txt Example.mxml
    
    
====================================
bundles = collections containers controls core effects languageResources skins styles
    
    
====================================
mxmlc -locale=locale -source-path=locale/{locale} -include-resource-
bundles=commaDelimitedListOfResourceBundles -output resourceModuleName.swf
    
    
====================================
mxmlc -locale=en_US -source-path=locale/{locale}
-include-resource-bundles=languageResources,collections,containers,
controls,core,effects,skins,styles -output en_US_ResourceModule.swf
    
    
====================================
localeChain=en_US&resourceModuleURLs=en_US_ResourceModule.swf
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
    <mx:Metadata>
         [ResourceBundle("languageResources")]
    </mx:Metadata>
    <mx:Script>
         <![CDATA[

              import mx.events.ResourceEvent;

              private var _selectedResourceName:String;

              private function changeResourceHandler(resourceName:String):void {
                   _selectedResourceName = resourceName;
                   var eventDispatcher:IEventDispatcher = resourceManager.
loadResourceModule(resourceName + "_ResourceModule.swf");
                   eventDispatcher.addEventListener(ResourceEvent.COMPLETE,
languageModuleLoadedHandler);
              }

              private function languageModuleLoadedHandler(event:Event):void {
                   resourceManager.localeChain = [_selectedResourceName];
              }

              private function selectLanguage():void {
                   changeResourceHandler(language.value as String);
              }

         ]]>
    </mx:Script>
    <mx:ComboBox id="language" change="selectLanguage();">
         <mx:dataProvider>
              <mx:ArrayCollection>
                   <mx:Object label="English (US)" data="en_US" />
                   <mx:Object label="English (Canada)" data="en_CA" />
                   <mx:Object label="Espanol (Espana)" data="es_ES" />
              </mx:ArrayCollection>
         </mx:dataProvider>
    </mx:ComboBox>
    <mx:Form>
         <mx:FormHeading
label="{resourceManager.getString('languageResources', 'instruction')}" />
         <mx:FormItem label="{resourceManager.getString('resources', 'color')}">
              <mx:ColorPicker id="color" />
         </mx:FormItem>
         <mx:FormItem>
              <mx:Button
label="{resourceManager.getString('languageResources', 'send')}" />
         </mx:FormItem>
    </mx:Form>
    <mx:Image
source="{resourceManager.getClass('languageResources', 'flag')}"
width="60" height="40" />
</mx:Application>
    
    
==================
 No newline at end of file
Loading