My guess is that the AS version is more efficient, although I haven't checked this.
 
To see what the compiler is doing, you can use the -keep flag on the compiler, which will allow you to see the generated ActionScript for any particular MXML file.
 
-Sho


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Pan Troglodytes
Sent: Friday, July 21, 2006 8:50 AM
To: flexcoders
Subject: [flexcoders] better to use mxml or actionscript for new component?

Just curious, is it actually more efficient to use AS instead of MXML (or vice versa) when deriving new components?  I'm talking about where it's just as easy to code it either way.  I'm just wondering about how the guts of the compiler work.

For example, take these two:

package nes {

  import mx.controls.Label;
  import mx.controls.dataGridClasses.DataGridListData;
  import flash.display.Graphics;
  import mx.controls.DataGrid;

  public class DetailBgColorRenderer extends Label {
    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
      super.updateDisplayList(unscaledWidth, unscaledHeight);

      var g:Graphics = graphics;
      if (data != null) {
        if (data.backgroundColor != 0) {
          var grid:DataGrid = DataGrid(DataGridListData(listData).owner);
         
          g.beginFill(data.backgroundColor);
          g.drawRect(0, 0, unscaledWidth, unscaledHeight);
          g.endFill();
        }
        else
          g.clear();
      }
    }
  }
}



<?xml version="1.0" encoding="utf-8"?>
<mx:Label xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script>
    <![CDATA[
      override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
        super.updateDisplayList(unscaledWidth, unscaledHeight);
 
        var g:Graphics = graphics;
        if (data != null) {
          if (data.backgroundColor != 0) {
            var grid:DataGrid = DataGrid(DataGridListData(listData).owner);
          
            g.beginFill(data.backgroundColor);
            g.drawRect(0, 0, unscaledWidth, unscaledHeight);
            g.endFill();
          }
          else
            g.clear();
        }
      }     
    ]]>
  </mx:Script>
</mx:Label>


--
Jason

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to