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

  1. package mx.core
  2. {
  3.    import flash.display.Loader;
  4.    import flash.events.Event;
  5.    import flash.system.ApplicationDomain;
  6.    import flash.system.LoaderContext;
  7.    import flash.utils.ByteArray;
  8.    
  9.    use namespace mx_internal;
  10.    
  11.    public class MovieClipLoaderAsset extends MovieClipAsset implements IFlexAsset, IFlexDisplayObject
  12.    {
  13.       
  14.       mx_internal static const VERSION:String = "2.0.1.0";
  15.        
  16.       
  17.       private var requestedWidth:Number;
  18.       
  19.       private var loader:Loader = null;
  20.       
  21.       private var requestedHeight:Number;
  22.       
  23.       private var initialized:Boolean = false;
  24.       
  25.       protected var initialWidth:Number = 0;
  26.       
  27.       protected var initialHeight:Number = 0;
  28.       
  29.       public function MovieClipLoaderAsset()
  30.       {
  31.          var _loc1_:LoaderContext = null;
  32.          loader = null;
  33.          initialized = false;
  34.          initialWidth = 0;
  35.          initialHeight = 0;
  36.          super();
  37.          _loc1_ = new LoaderContext();
  38.          _loc1_.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
  39.          loader = new Loader();
  40.          loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
  41.          loader.loadBytes(movieClipData,_loc1_);
  42.          addChild(loader);
  43.       }
  44.       
  45.       private function completeHandler(param1:Event) : void
  46.       {
  47.          initialized = true;
  48.          initialWidth = loader.width;
  49.          initialHeight = loader.height;
  50.          if(!isNaN(requestedWidth))
  51.          {
  52.             loader.width = requestedWidth;
  53.          }
  54.          if(!isNaN(requestedHeight))
  55.          {
  56.             loader.height = requestedHeight;
  57.          }
  58.          dispatchEvent(param1);
  59.       }
  60.       
  61.       override public function get height() : Number
  62.       {
  63.          if(!initialized)
  64.          {
  65.             return initialHeight;
  66.          }
  67.          return super.height;
  68.       }
  69.       
  70.       override public function set height(param1:Number) : void
  71.       {
  72.          if(!initialized)
  73.          {
  74.             requestedHeight = param1;
  75.          }
  76.          else
  77.          {
  78.             loader.height = param1;
  79.          }
  80.       }
  81.       
  82.       public function get movieClipData() : ByteArray
  83.       {
  84.          return null;
  85.       }
  86.       
  87.       override public function set width(param1:Number) : void
  88.       {
  89.          if(!initialized)
  90.          {
  91.             requestedWidth = param1;
  92.          }
  93.          else
  94.          {
  95.             loader.width = param1;
  96.          }
  97.       }
  98.       
  99.       override public function get measuredWidth() : Number
  100.       {
  101.          return initialWidth;
  102.       }
  103.       
  104.       override public function get measuredHeight() : Number
  105.       {
  106.          return initialHeight;
  107.       }
  108.       
  109.       override public function get width() : Number
  110.       {
  111.          if(!initialized)
  112.          {
  113.             return initialWidth;
  114.          }
  115.          return super.width;
  116.       }
  117.    }
  118. }
  119.