home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / filler.swf / scripts / mx / core / LayoutContainer.as < prev    next >
Text File  |  2008-09-02  |  4KB  |  131 lines

  1. package mx.core
  2. {
  3.    import flash.events.Event;
  4.    import flash.system.ApplicationDomain;
  5.    import mx.containers.BoxDirection;
  6.    import mx.containers.utilityClasses.BoxLayout;
  7.    import mx.containers.utilityClasses.CanvasLayout;
  8.    import mx.containers.utilityClasses.Layout;
  9.    import mx.resources.ResourceBundle;
  10.    
  11.    use namespace mx_internal;
  12.    
  13.    public class LayoutContainer extends Container
  14.    {
  15.       
  16.       private static var viewSourceMenuItem:String;
  17.       
  18.       mx_internal static var useProgressiveLayout:Boolean = false;
  19.       
  20.       mx_internal static const VERSION:String = "2.0.1.0";
  21.       
  22.       private static var packageResources:ResourceBundle = ResourceBundle.getResourceBundle("core",ApplicationDomain.currentDomain);
  23.       
  24.       {
  25.          loadResources();
  26.       }
  27.       
  28.       private var _layout:String = "vertical";
  29.       
  30.       private var processingCreationQueue:Boolean = false;
  31.       
  32.       private var creationQueue:Array;
  33.       
  34.       protected var boxLayoutClass:Class;
  35.       
  36.       private var preloadObj:Object;
  37.       
  38.       private var resizeHandlerAdded:Boolean = false;
  39.       
  40.       protected var layoutObject:Layout;
  41.       
  42.       protected var canvasLayoutClass:Class;
  43.       
  44.       public function LayoutContainer()
  45.       {
  46.          layoutObject = new BoxLayout();
  47.          canvasLayoutClass = CanvasLayout;
  48.          boxLayoutClass = BoxLayout;
  49.          resizeHandlerAdded = false;
  50.          creationQueue = [];
  51.          processingCreationQueue = false;
  52.          _layout = ContainerLayout.VERTICAL;
  53.          super();
  54.          layoutObject.target = this;
  55.       }
  56.       
  57.       private static function loadResources() : void
  58.       {
  59.          viewSourceMenuItem = packageResources.getString("viewSource");
  60.       }
  61.       
  62.       override mx_internal function get usePadding() : Boolean
  63.       {
  64.          return layout != ContainerLayout.ABSOLUTE;
  65.       }
  66.       
  67.       override protected function measure() : void
  68.       {
  69.          super.measure();
  70.          layoutObject.measure();
  71.       }
  72.       
  73.       override protected function layoutChrome(param1:Number, param2:Number) : void
  74.       {
  75.          super.layoutChrome(param1,param2);
  76.          if(!mx_internal::doingLayout)
  77.          {
  78.             createBorder();
  79.          }
  80.       }
  81.       
  82.       public function set layout(param1:String) : void
  83.       {
  84.          if(_layout != param1)
  85.          {
  86.             _layout = param1;
  87.             if(layoutObject)
  88.             {
  89.                layoutObject.target = null;
  90.             }
  91.             if(_layout == ContainerLayout.ABSOLUTE)
  92.             {
  93.                layoutObject = new canvasLayoutClass();
  94.             }
  95.             else
  96.             {
  97.                layoutObject = new boxLayoutClass();
  98.                if(_layout == ContainerLayout.VERTICAL)
  99.                {
  100.                   BoxLayout(layoutObject).direction = BoxDirection.VERTICAL;
  101.                }
  102.                else
  103.                {
  104.                   BoxLayout(layoutObject).direction = BoxDirection.HORIZONTAL;
  105.                }
  106.             }
  107.             if(layoutObject)
  108.             {
  109.                layoutObject.target = this;
  110.             }
  111.             invalidateSize();
  112.             invalidateDisplayList();
  113.             dispatchEvent(new Event("layoutChanged"));
  114.          }
  115.       }
  116.       
  117.       [Bindable("layoutChanged")]
  118.       public function get layout() : String
  119.       {
  120.          return _layout;
  121.       }
  122.       
  123.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  124.       {
  125.          super.updateDisplayList(param1,param2);
  126.          layoutObject.updateDisplayList(param1,param2);
  127.          createBorder();
  128.       }
  129.    }
  130. }
  131.