home *** CD-ROM | disk | FTP | other *** search
- package mx.core
- {
- import flash.display.Loader;
- import flash.events.Event;
- import flash.system.ApplicationDomain;
- import flash.system.LoaderContext;
- import flash.utils.ByteArray;
-
- use namespace mx_internal;
-
- public class MovieClipLoaderAsset extends MovieClipAsset implements IFlexAsset, IFlexDisplayObject
- {
-
- mx_internal static const VERSION:String = "2.0.1.0";
-
-
- private var requestedWidth:Number;
-
- private var loader:Loader = null;
-
- private var requestedHeight:Number;
-
- private var initialized:Boolean = false;
-
- protected var initialWidth:Number = 0;
-
- protected var initialHeight:Number = 0;
-
- public function MovieClipLoaderAsset()
- {
- var _loc1_:LoaderContext = null;
- loader = null;
- initialized = false;
- initialWidth = 0;
- initialHeight = 0;
- super();
- _loc1_ = new LoaderContext();
- _loc1_.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
- loader = new Loader();
- loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
- loader.loadBytes(movieClipData,_loc1_);
- addChild(loader);
- }
-
- private function completeHandler(param1:Event) : void
- {
- initialized = true;
- initialWidth = loader.width;
- initialHeight = loader.height;
- if(!isNaN(requestedWidth))
- {
- loader.width = requestedWidth;
- }
- if(!isNaN(requestedHeight))
- {
- loader.height = requestedHeight;
- }
- dispatchEvent(param1);
- }
-
- override public function get height() : Number
- {
- if(!initialized)
- {
- return initialHeight;
- }
- return super.height;
- }
-
- override public function set height(param1:Number) : void
- {
- if(!initialized)
- {
- requestedHeight = param1;
- }
- else
- {
- loader.height = param1;
- }
- }
-
- public function get movieClipData() : ByteArray
- {
- return null;
- }
-
- override public function set width(param1:Number) : void
- {
- if(!initialized)
- {
- requestedWidth = param1;
- }
- else
- {
- loader.width = param1;
- }
- }
-
- override public function get measuredWidth() : Number
- {
- return initialWidth;
- }
-
- override public function get measuredHeight() : Number
- {
- return initialHeight;
- }
-
- override public function get width() : Number
- {
- if(!initialized)
- {
- return initialWidth;
- }
- return super.width;
- }
- }
- }
-