Discover the Unknown Flex 4.5
       Piotr Walczyszyn | Adobe Enterprise Evangelist

       Blog: riaspace.com
       Twitter: @pwalczyszyn




©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
ls -al




                                                                            AS3 secrets
                                                                            Flex secrets
                                                                            Flash Builder secrets




                                                                                      2
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
**      ******** ****
                                                                             ****    **////// */// *
                                                                            **//** /**        /      /*
                                                                          ** //** /*********      ***
                                                                         **********////////** /// *
                                                                        /**//////**        /** *     /*
                                                                        /**      /** ******** / ****
                                                                        //       // ////////    ////



                                                                                       3
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: Short conditional statements




                                                                            var someVar:Number;


                                                                            if (someVar)
                                                                                 doSomething();




                                                                                       4
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: Short constructors




                                                                            var point:Point = new Point;




                                                                                          5
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: Throwing objects



                                                                            try
                                                                            {
                                                                               throw 1;
                                                                            } 
                                                                            catch (n:Number)
                                                                            {
                                                                              trace(n); // outputs 1
                                                                            }




                                                                                        6
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: arguments class




                                                                            dispatcher.addEventListener(
                                                                              SomeEvent.TYPE,
                                                                              function(event:SomeEvent):void
                                                                              {
                                                                                EventDispatcher(event.target).
                                                                                  removeEventListener(
                                                                                    event.type,
                                                                                     arguments.callee
                                                                                  );
                                                                              });




                                                                                              7
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: ||= logical or assignment (by Sönke Rohde)



                                                                            var num:Number;
                                                                            num ||= 10;
                                                                            trace(num); // outputs 10


                                                                            num = 5;
                                                                            trace(num); // outputs 5


                                                                            num ||= 10;
                                                                            trace(num); // outputs 5




                                                                                             8
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: Getting object class type




                                                                     var clazz:Class = Object(obj).constructor;




                                                                                        9
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: Labels & continue (by Christian Cantrell)

                                      outerLoop: for (var i:uint = 0; i < outerArray.length; ++i)
                                      {
                                        var foo:String = outerArray[i];
                                        innerLoop: for (var j:uint = 0; j < innerArray.length; ++j)
                                        {
                                            var bar:String = innerArray[j];
                                            if (foo == bar)
                                            {
                                                continue outerLoop;
                                            }
                                        }
                                        trace(foo);
                                      }




                                                                            10
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: Label & break (by Christian Cantrell)



                                                 dateCheck:
                                                {
                                                  trace("Good morning.");
                                                  var today:Date = new Date();
                                                  if (today.month == 11 && today.date == 24)   // Christmas!
                                                  {
                                                      break dateCheck;
                                                  }
                                                  trace("Time for work!");
                                                }




                                                                            11
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: with statement

                                                                            function polar(r:Number):void
                                                                            {
                                                                            
 
   var a:Number, x:Number, y:Number;
                                                                            
 
   with (Math)
                                                                            
 
   {
                                                                            
 
   
     a = PI * pow(r, 2);
                                                                            
 
   
     x = r * cos(PI);
                                                                            
 
   
     y = r * sin(PI / 2);
                                                                            
 
   }
                                                                            
 
   trace("area = " + a);
                                                                            
 
   trace("x = " + x);
                                                                            
 
   trace("y = " + y);
                                                                            }
                                                                            
 
   
     
                                                                            polar(3);



                                                                                                     12
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: global functions




                                                     // globalFunction.as file
                                                     package
                                                     {
                                                     
 public function globalFunction(text:String):void
                                                     
{
                                                     
 
 trace(text);
                                                     
}
                                                     }




                                                                             13
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: internal functions



                                    protected function someFunction():void
                                    {
                                    

             var internalFunction:Function = function(text:String):void
                                    

             {
                                    

             
          trace(text);
                                    

             };
                                    

             
          
                                    

             internalFunction("Hello World!");
                                    }




                                                                             14
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: custom namespaces (by Mihai Corlan)


                                           // online.as file
                                           package org.corlan
                                           {
                                                 public namespace online = "http://corlan.org/apps/online";
                                           }


                                           // offline.as file
                                           package org.corlan
                                           {
                                                 public namespace offline = "http://corlan.org/apps/offline";
                                           }




                                                                             15
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: custom namespaces (by Mihai Corlan)
                                                                        online function save(object:Object):void
                                                                        {
                                                                            //save the object back to server
                                                                            trace("online");
                                                                        }


                                                                        offline function save(object:Object):void
                                                                        {
                                                                            //save the object locally
                                                                            trace("offline");
                                                                        }


                                                                        ...
                                                                        online::save(obj);
                                                                        offline::save(obj);
                                                                                                16
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AS3: Proxy class
                                 dynamic class MyProxy extends Proxy
                                 {
                                                 flash_proxy override function callProperty(name:*, ...rest):*
                                                 {
                                                              // function call proxy
                                                 }
                                                 flash_proxy override function getProperty(name:*):*
                                                 {
                                                              // getter call proxy
                                                 }
                                                 flash_proxy override function setProperty(name:*, value:*):void
                                                 {
                                                              // setter call proxy
                                                 }
                                 }
                                                                                       17
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
********
                                                                            /**/////
                                                                            /**        **   **
                                                                            /******* //** **
                                                                            /**////    //***
                                                                            /**         **/**
                                                                            /**        ** //**
                                                                            //        //   //




                                                                                    18
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Fx: ObjectProxy class




                   warning: unable to bind to property 'propName' on class 'Object' (class is not an IEventDispatcher)




                                                                            19
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Fx: ObjectProxy class
                   warning: unable to bind to property 'propName' on class 'Object' (class is not an IEventDispatcher)




                                                                            19
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Fx: ObjectProxy class
                   warning: unable to bind to property 'propName' on class 'Object' (class is not an IEventDispatcher)




                                                                            var obj:Object = {propName : “prop value”};
                                                                            var objProxy:ObjectProxy = new ObjectProxy(obj);


                                                                            ...


                                                                            <s:Label text=”{objProxy.propName}” />




                                                                                                  19
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Fx: <fx:Library> & <fx:Definition>
                                                                   <?xml version="1.0" encoding="utf-8"?>
                                                                   <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                                                                            xmlns:mx="library://ns.adobe.com/flex/mx"
                                                                            xmlns:s="library://ns.adobe.com/flex/spark">
                                                                             <fx:Library>
                                                                                  <fx:Definition name="MySquare">
                                                                                       <s:Group>
                                                                                             <s:Rect width="100%" height="100%">
                                                                                                    <s:stroke>
                                                                                                         <s:SolidColorStroke color="red"/>
                                                                                                    </s:stroke>
                                                                                             </s:Rect>
                                                                                       </s:Group>
                                                                                  </fx:Definition>
                                                                             </fx:Library>


                                                                             <fx:MySquare x="0" y="0" height="20" width="20"/>
                                                                   </s:Application>

                                                                                                    20
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Fx: <fx:Private>

                                                                <?xml version="1.0" encoding="utf-8"?>
                                                                <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                                                                             xmlns:mx="library://ns.adobe.com/flex/mx"
                                                                             xmlns:s="library://ns.adobe.com/flex/spark">

                                                                
 <fx:Declarations>
                                                                
 </fx:Declarations>

                                                                      <!-- has to be last tag in MXML doc -->
                                                                      <fx:Private>
                                                                            <!-- content must be in XML format -->
                                                                            <Date>10/22/2008</Date>
                                                                            <Author>Nick Danger</Author>
                                                                      </fx:Private>

                                                                </s:Application>


                                                                                                21
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Fx: <fx:Reparent>
                                                      
 <s:states>
                                                      
 
            <s:State name="portrait" />
                                                      
 
            <s:State name="landscape" />
                                                      
 </s:states>
                                                      
 <s:VGroup includeIn="portrait" width="100%" height="100%">
                                                      
 
            <s:Rect id="redRect" includeIn="portrait" width="100%" height="100%">
                                                      
 
            
      <s:fill>
                                                      
 
            
      
   <s:SolidColor color="#FF0000" />
                                                      
 
            
      </s:fill>
                                                      
 
            </s:Rect>
                                                      
 
            <s:Rect id="blackRect" includeIn="portrait" width="100%" height="100%">
                                                      
 
            
      <s:fill>
                                                      
 
            
      
   <s:SolidColor color="#000000" />
                                                      
 
            
      </s:fill>
                                                      
 
            </s:Rect>
                                                      
 </s:VGroup>
                                                      
 <s:HGroup includeIn="landscape" width="100%" height="100%">
                                                      
 
            <fx:Reparent target="redRect" includeIn="landscape" />
                                                      
 
            <fx:Reparent target="blackRect" includeIn="landscape" />
                                                      
 </s:HGroup>
                                                                                                     22
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Fx: states (by Steve Hartley)
                                                                     <s:states>
                                                                     
 <s:State name="portrait" />
                                                                     
 <s:State name="landscape" />
                                                                     </s:states>

                                                                     <s:Group width="100%" height="100%">
                                                                     
 
    <s:layout.portrait>
                                                                     
 
    
   <s:VerticalLayout />
                                                                     
 
    </s:layout.portrait>
                                                                     
 
                                                                     
 
    <s:layout.landscape>
                                                                     
 
    
   <s:HorizontalLayout />
                                                                     
 
    </s:layout.landscape>
                                                                     
 
                                                                     
 
    <fx:RedRectangle width="100%" height="100%" />
                                                                     
 
    <fx:BlackRectangle width="100%" height="100%" />
                                                                     
 </s:Group>

                                                                                                   23
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Fx: state groups (by Narciso (nj) Jaramillo)

                      <s:states>
                      
 <s:State name="portraitPhone" stateGroups="portrait,phone" />
                      
 <s:State name="landscapePhone" stateGroups="landscape,phone" />
                      
 <s:State name="portraitTablet" stateGroups="portrait,tablet" />
                      
 <s:State name="landscapeTablet" stateGroups="landscape,tablet" />
                      </s:states>


                      <s:ViewNavigator id="mainNavigator"
                                    left="0" left.landscapeTablet="{LIST_WIDTH}"
                                    top="0" top.portraitTablet="{ACTIONBAR_HEIGHT + LIST_HEIGHT}"
                                    right="0" bottom="0" firstView="views.SummaryView"
                      
           firstView.tablet="views.DetailView”
                                                                     />          



                                                                            24
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Fx: IMXMLObject
                                       package
                                       {
                                       
 import mx.core.IMXMLObject;
                                       
                                       
 public class MyMXMLObject implements IMXMLObject
                                       
 {
                                       
 
             public function initialized(document:Object, id:String):void
                                       
 
             {
                                       
 
             
         trace("Added to:", document, "with id:", id);
                                       
 
             }
                                       
 }
                                       }
                                       ...
                                       <fx:Declarations>
                                       
 <local:MyMXMLObject id="myMXMLObject" />
                                       </fx:Declarations>


                                                                                            25
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Fx: FlexGlobals.topApplication




                                                        <?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">
                                                        
                                                        
 <fx:Declarations>
                                                        
 
             <fx:String id="myString">Hello World?!</fx:String>
                                                        
 </fx:Declarations>
                                                        
                                                        </s:Application>




                                                                                               26
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Fx: FlexGlobals.topApplication
                                     <?xml version="1.0" encoding="utf-8"?>
                                     <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
                                     
 
             xmlns:s="library://ns.adobe.com/flex/spark" title="FlexGlobals" xmlns:local="*"
                                     
 
             creationComplete="view_creationCompleteHandler(event)">
                                     
                                     
 <fx:Script>
                                     
 
             <![CDATA[
                                     
 
             
         import mx.core.FlexGlobals;
                                     
 
             
         import mx.events.FlexEvent;
                                     
 
             
                                     
 
             
         protected function view_creationCompleteHandler(event:FlexEvent):void
                                     
 
             
         {
                                     
 
             
         
            lbl.text = FlexGlobals.topLevelApplication.myString;
                                     
 
             
         }
                                     
 
             ]]>
                                     
 </fx:Script>
                                     
 <s:Label id="lbl" verticalCenter="0" horizontalCenter="0" />
                                     </s:View>

                                                                                                      27
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Fx: conditional compilation

                          CONFIG::android
                          protected function view_creationCompleteHandler(event:FlexEvent):void
                          {
                          

              lbl.text = "Android: " + FlexGlobals.topLevelApplication.myString;
                          }
                          

              
                          CONFIG::ios
                          protected function view_creationCompleteHandler(event:FlexEvent):void
                          {
                          

              lbl.text = "iOS: " + FlexGlobals.topLevelApplication.myString;
                          }




                                                                            28
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Fx: conditional compilation




                                                                            29
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
FB: keeping generated ActionScript




                                                                            30
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
******** ******
                                                                            /**///// /*////**
                                                                            /**      /*   /**
                                                                            /******* /******
                                                                            /**//// /*//// **
                                                                            /**      /*    /**
                                                                            /**      /*******
                                                                            //       ///////




                                                                                    31
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
FB: Press Ctrl+Space to invoke Content Assist.




                                                                            32
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
FB: Metadata code completion




                                                                            33
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
FB: Code completion when using states




                                                                            34
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
FB: Camel-case code hinting




                                                                            35
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
FB: Quick Assist - Press Cmd/Ctrl+1




                                                                            * Rename in file
                                                                            * Rename in workspace
                                                                            * Generate getter/setter
                                                                            * Convert local variable to field
                                                                            * Assign to variable
                                                                            * Split variable declaration
                                                                            * Organize imports



                                                                                              36
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
FB: Quick Outline - Press Cmd/Ctrl+O




                                                                            37
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
FB: Code templates




                                                                            38
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
FB: Organize imports




                                                     Place your cursor on an import statement, press
                                                     Cmd/Ctrl+1, and select Organize Imports.

                                                     To sort the import statements alphabetically by
                                                     package name, press Cmd/Ctrl+Shift+O.




                                                                             39
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
FB: Call Hierarchy (Cmd/Ctrl+Alt+H)




                                                                            40
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
FB: other shortcuts


                                                      Cmd/Ctrl+I - Fixing indentation
                                                      Cmd/Ctrl+Shift+C - Code commenting
                                                      Cmd/Ctrl+Shift+D - Adding CDATA blocks (<![CDATA[ ]]>)
                                                      Cmd/Ctrl+Shift+F - Format MXML documents


                                                                 - Block selection and edit mode



                                                      Cmd/Ctrl+Shift+L - Complete list of shortcuts




                                                                                     41
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Discover The Unknown Flex 4.5 (MAX 2011)

  • 1.
    Discover the UnknownFlex 4.5 Piotr Walczyszyn | Adobe Enterprise Evangelist Blog: riaspace.com Twitter: @pwalczyszyn ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 2.
    ls -al AS3 secrets Flex secrets Flash Builder secrets 2 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 3.
    ** ******** **** **** **////// */// * **//** /** / /* ** //** /********* *** **********////////** /// * /**//////** /** * /* /** /** ******** / **** // // //////// //// 3 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 4.
    AS3: Short conditionalstatements var someVar:Number; if (someVar)      doSomething(); 4 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 5.
    AS3: Short constructors var point:Point = new Point; 5 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 6.
    AS3: Throwing objects try { throw 1; }  catch (n:Number) { trace(n); // outputs 1 } 6 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 7.
    AS3: arguments class dispatcher.addEventListener( SomeEvent.TYPE, function(event:SomeEvent):void { EventDispatcher(event.target). removeEventListener( event.type, arguments.callee ); }); 7 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 8.
    AS3: ||= logicalor assignment (by Sönke Rohde) var num:Number; num ||= 10; trace(num); // outputs 10 num = 5; trace(num); // outputs 5 num ||= 10; trace(num); // outputs 5 8 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 9.
    AS3: Getting objectclass type var clazz:Class = Object(obj).constructor; 9 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 10.
    AS3: Labels &continue (by Christian Cantrell) outerLoop: for (var i:uint = 0; i < outerArray.length; ++i) { var foo:String = outerArray[i]; innerLoop: for (var j:uint = 0; j < innerArray.length; ++j) { var bar:String = innerArray[j]; if (foo == bar) { continue outerLoop; } } trace(foo); } 10 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 11.
    AS3: Label &break (by Christian Cantrell) dateCheck: { trace("Good morning."); var today:Date = new Date(); if (today.month == 11 && today.date == 24) // Christmas! { break dateCheck; } trace("Time for work!"); } 11 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 12.
    AS3: with statement function polar(r:Number):void { var a:Number, x:Number, y:Number; with (Math) { a = PI * pow(r, 2); x = r * cos(PI); y = r * sin(PI / 2); } trace("area = " + a); trace("x = " + x); trace("y = " + y); } polar(3); 12 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 13.
    AS3: global functions // globalFunction.as file package { public function globalFunction(text:String):void { trace(text); } } 13 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 14.
    AS3: internal functions protected function someFunction():void { var internalFunction:Function = function(text:String):void { trace(text); }; internalFunction("Hello World!"); } 14 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 15.
    AS3: custom namespaces(by Mihai Corlan) // online.as file package org.corlan { public namespace online = "http://corlan.org/apps/online"; } // offline.as file package org.corlan { public namespace offline = "http://corlan.org/apps/offline"; } 15 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 16.
    AS3: custom namespaces(by Mihai Corlan) online function save(object:Object):void { //save the object back to server trace("online"); } offline function save(object:Object):void { //save the object locally trace("offline"); } ... online::save(obj); offline::save(obj); 16 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 17.
    AS3: Proxy class dynamic class MyProxy extends Proxy { flash_proxy override function callProperty(name:*, ...rest):* { // function call proxy } flash_proxy override function getProperty(name:*):* { // getter call proxy } flash_proxy override function setProperty(name:*, value:*):void { // setter call proxy } } 17 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 18.
    ******** /**///// /** ** ** /******* //** ** /**//// //*** /** **/** /** ** //** // // // 18 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 19.
    Fx: ObjectProxy class warning: unable to bind to property 'propName' on class 'Object' (class is not an IEventDispatcher) 19 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 20.
    Fx: ObjectProxy class warning: unable to bind to property 'propName' on class 'Object' (class is not an IEventDispatcher) 19 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 21.
    Fx: ObjectProxy class warning: unable to bind to property 'propName' on class 'Object' (class is not an IEventDispatcher) var obj:Object = {propName : “prop value”}; var objProxy:ObjectProxy = new ObjectProxy(obj); ... <s:Label text=”{objProxy.propName}” /> 19 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 22.
    Fx: <fx:Library> &<fx:Definition> <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark"> <fx:Library> <fx:Definition name="MySquare"> <s:Group> <s:Rect width="100%" height="100%"> <s:stroke> <s:SolidColorStroke color="red"/> </s:stroke> </s:Rect> </s:Group> </fx:Definition> </fx:Library> <fx:MySquare x="0" y="0" height="20" width="20"/> </s:Application> 20 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 23.
    Fx: <fx:Private> <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark"> <fx:Declarations> </fx:Declarations> <!-- has to be last tag in MXML doc --> <fx:Private> <!-- content must be in XML format --> <Date>10/22/2008</Date> <Author>Nick Danger</Author> </fx:Private> </s:Application> 21 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 24.
    Fx: <fx:Reparent> <s:states> <s:State name="portrait" /> <s:State name="landscape" /> </s:states> <s:VGroup includeIn="portrait" width="100%" height="100%"> <s:Rect id="redRect" includeIn="portrait" width="100%" height="100%"> <s:fill> <s:SolidColor color="#FF0000" /> </s:fill> </s:Rect> <s:Rect id="blackRect" includeIn="portrait" width="100%" height="100%"> <s:fill> <s:SolidColor color="#000000" /> </s:fill> </s:Rect> </s:VGroup> <s:HGroup includeIn="landscape" width="100%" height="100%"> <fx:Reparent target="redRect" includeIn="landscape" /> <fx:Reparent target="blackRect" includeIn="landscape" /> </s:HGroup> 22 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 25.
    Fx: states (bySteve Hartley) <s:states> <s:State name="portrait" /> <s:State name="landscape" /> </s:states> <s:Group width="100%" height="100%"> <s:layout.portrait> <s:VerticalLayout /> </s:layout.portrait> <s:layout.landscape> <s:HorizontalLayout /> </s:layout.landscape> <fx:RedRectangle width="100%" height="100%" /> <fx:BlackRectangle width="100%" height="100%" /> </s:Group> 23 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 26.
    Fx: state groups(by Narciso (nj) Jaramillo) <s:states> <s:State name="portraitPhone" stateGroups="portrait,phone" /> <s:State name="landscapePhone" stateGroups="landscape,phone" /> <s:State name="portraitTablet" stateGroups="portrait,tablet" /> <s:State name="landscapeTablet" stateGroups="landscape,tablet" /> </s:states> <s:ViewNavigator id="mainNavigator" left="0" left.landscapeTablet="{LIST_WIDTH}" top="0" top.portraitTablet="{ACTIONBAR_HEIGHT + LIST_HEIGHT}" right="0" bottom="0" firstView="views.SummaryView" firstView.tablet="views.DetailView” /> 24 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 27.
    Fx: IMXMLObject package { import mx.core.IMXMLObject; public class MyMXMLObject implements IMXMLObject { public function initialized(document:Object, id:String):void { trace("Added to:", document, "with id:", id); } } } ... <fx:Declarations> <local:MyMXMLObject id="myMXMLObject" /> </fx:Declarations> 25 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 28.
    Fx: FlexGlobals.topApplication <?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"> <fx:Declarations> <fx:String id="myString">Hello World?!</fx:String> </fx:Declarations> </s:Application> 26 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 29.
    Fx: FlexGlobals.topApplication <?xml version="1.0" encoding="utf-8"?> <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" title="FlexGlobals" xmlns:local="*" creationComplete="view_creationCompleteHandler(event)"> <fx:Script> <![CDATA[ import mx.core.FlexGlobals; import mx.events.FlexEvent; protected function view_creationCompleteHandler(event:FlexEvent):void { lbl.text = FlexGlobals.topLevelApplication.myString; } ]]> </fx:Script> <s:Label id="lbl" verticalCenter="0" horizontalCenter="0" /> </s:View> 27 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 30.
    Fx: conditional compilation CONFIG::android protected function view_creationCompleteHandler(event:FlexEvent):void { lbl.text = "Android: " + FlexGlobals.topLevelApplication.myString; } CONFIG::ios protected function view_creationCompleteHandler(event:FlexEvent):void { lbl.text = "iOS: " + FlexGlobals.topLevelApplication.myString; } 28 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 31.
    Fx: conditional compilation 29 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 32.
    FB: keeping generatedActionScript 30 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 33.
    ******** ****** /**///// /*////** /** /* /** /******* /****** /**//// /*//// ** /** /* /** /** /******* // /////// 31 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 34.
    FB: Press Ctrl+Spaceto invoke Content Assist. 32 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 35.
    FB: Metadata codecompletion 33 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 36.
    FB: Code completionwhen using states 34 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 37.
    FB: Camel-case codehinting 35 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 38.
    FB: Quick Assist- Press Cmd/Ctrl+1 * Rename in file * Rename in workspace * Generate getter/setter * Convert local variable to field * Assign to variable * Split variable declaration * Organize imports 36 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 39.
    FB: Quick Outline- Press Cmd/Ctrl+O 37 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 40.
    FB: Code templates 38 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 41.
    FB: Organize imports Place your cursor on an import statement, press Cmd/Ctrl+1, and select Organize Imports. To sort the import statements alphabetically by package name, press Cmd/Ctrl+Shift+O. 39 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 42.
    FB: Call Hierarchy(Cmd/Ctrl+Alt+H) 40 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 43.
    FB: other shortcuts Cmd/Ctrl+I - Fixing indentation Cmd/Ctrl+Shift+C - Code commenting Cmd/Ctrl+Shift+D - Adding CDATA blocks (<![CDATA[ ]]>) Cmd/Ctrl+Shift+F - Format MXML documents - Block selection and edit mode Cmd/Ctrl+Shift+L - Complete list of shortcuts 41 ©2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 44.
    ©2011 Adobe SystemsIncorporated. All Rights Reserved. Adobe Confidential.

Editor's Notes

  • #2 \n
  • #3 \n
  • #4 \n
  • #5 \n
  • #6 \n
  • #7 Other types can be thrown also\n
  • #8 An arguments object is used to store and access a function&apos;s arguments. Within a function&apos;s body, you can access its arguments object by using the local arguments variable.\n
  • #9 Assigns expression1 the value of expression1 || expression2.\n\nhttp://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/operators.html\n
  • #10 You can also do this: Class(getDefinitionByName(getQualifiedClassName(obj)))\n
  • #11 Inspired by Christian Cantrells post: http://blogs.adobe.com/cantrell/archives/2009/12/labels_in_actionscript_3.html\n
  • #12 \n
  • #13 \n
  • #14 \n
  • #15 \n
  • #16 Inspired by Mihai Corlan: http://corlan.org/flex-for-php-developers/#c7\n
  • #17 Inspired by Mihai Corlan: http://corlan.org/flex-for-php-developers/#c7\n
  • #18 http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/Proxy.html\n
  • #19 \n
  • #20 http://help.adobe.com/pl_PL/FlashPlatform/reference/actionscript/3/mx/utils/ObjectProxy.html\n\nDynamic ObjectProxy (by Andrea Bresolin) - http://www.devahead.com/blog/2009/12/dynamic-objectproxy/\n\nExtending model objects with ObjectProxy class: http://www.riaspace.com/2010/11/extending-model-objects-with-objectproxy-class/\n
  • #21 http://help.adobe.com/pl_PL/FlashPlatform/reference/actionscript/3/mx/utils/ObjectProxy.html\n\nDynamic ObjectProxy (by Andrea Bresolin) - http://www.devahead.com/blog/2009/12/dynamic-objectproxy/\n\nExtending model objects with ObjectProxy class: http://www.riaspace.com/2010/11/extending-model-objects-with-objectproxy-class/\n
  • #22 http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mxml/definition.html\nhttp://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mxml/library.html\n
  • #23 http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mxml/private.html\n
  • #24 \n
  • #25 \n
  • #26 http://www.rictus.com/muchado/wp-content/uploads/2011/04/multiscreen-dev-with-flex-360flex-2011.pptx.pdf\n
  • #27 \n
  • #28 \n
  • #29 \n
  • #30 \n
  • #31 http://blogs.adobe.com/flexdoc/files/flexdoc/conditionalcompilation.pdf\n
  • #32 \n
  • #33 \n
  • #34 http://www.adobe.com/devnet/flash-builder/articles/tips-tricks.html\n\nCode proposal cycling - Press Ctrl+Space multiple times to filter the list of suggestions that Content Assist provides, and show only properties, events, effects, and so on.\n
  • #35 http://www.adobe.com/devnet/flash-builder/articles/tips-tricks.html\n\nCode proposal cycling - Press Ctrl+Space multiple times to filter the list of suggestions that Content Assist provides, and show only properties, events, effects, and so on.\n
  • #36 http://www.adobe.com/devnet/flash-builder/articles/tips-tricks.html\n\nCode proposal cycling - Press Ctrl+Space multiple times to filter the list of suggestions that Content Assist provides, and show only properties, events, effects, and so on.\n
  • #37 \n
  • #38 \n
  • #39 \n
  • #40 \n
  • #41 \n
  • #42 \n
  • #43 \n
  • #44 \n