home *** CD-ROM | disk | FTP | other *** search
- package fl.livepreview
- {
- import flash.display.*;
- import flash.external.*;
- import flash.utils.*;
-
- public class LivePreviewParent extends MovieClip
- {
-
-
- public var myInstance:DisplayObject;
-
- public function LivePreviewParent()
- {
- super();
- try
- {
- stage.align = StageAlign.TOP_LEFT;
- stage.scaleMode = StageScaleMode.NO_SCALE;
- myInstance = getChildAt(0);
- onResize(stage.width,stage.height);
- if(ExternalInterface.available)
- {
- ExternalInterface.addCallback("onResize",onResize);
- ExternalInterface.addCallback("onUpdate",onUpdate);
- }
- }
- catch(e:*)
- {
- }
- }
-
- private function updateCollection(param1:Object, param2:String) : void
- {
- var _loc3_:Class = null;
- var _loc4_:Class = null;
- var _loc5_:Object = null;
- var _loc6_:int = 0;
- var _loc7_:Object = null;
- var _loc8_:Object = null;
- var _loc9_:* = undefined;
- _loc3_ = Class(getDefinitionByName(param1.collectionClass));
- _loc4_ = Class(getDefinitionByName(param1.collectionItemClass));
- _loc5_ = new _loc3_();
- _loc6_ = 0;
- while(_loc6_ < param1.collectionArray.length)
- {
- _loc7_ = new _loc4_();
- _loc8_ = param1.collectionArray[_loc6_];
- for(_loc9_ in _loc8_)
- {
- _loc7_[_loc9_] = _loc8_[_loc9_];
- }
- _loc5_.addItem(_loc7_);
- _loc6_++;
- }
- myInstance[param2] = _loc5_ as _loc3_;
- }
-
- public function onResize(param1:Number, param2:Number) : void
- {
- var setSizeFn:Function = null;
- var width:Number = param1;
- var height:Number = param2;
- setSizeFn = null;
- try
- {
- setSizeFn = myInstance["setSize"];
- }
- catch(e:Error)
- {
- setSizeFn = null;
- }
- if(setSizeFn != null)
- {
- setSizeFn(width,height);
- }
- else
- {
- myInstance.width = width;
- myInstance.height = height;
- }
- }
-
- public function onUpdate(... rest) : void
- {
- var i:int = 0;
- var name:String = null;
- var value:* = undefined;
- var updateArray:Array = rest;
- i = 0;
- while(i + 1 < updateArray.length)
- {
- try
- {
- name = String(updateArray[i]);
- value = updateArray[i + 1];
- if(typeof value == "object" && Boolean(value.__treatAsCollectionSpecialSauce__))
- {
- updateCollection(value,name);
- }
- else
- {
- myInstance[name] = value;
- }
- }
- catch(e:Error)
- {
- }
- i += 2;
- }
- }
- }
- }
-