home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / filler.swf / scripts / fl / livepreview / LivePreviewParent.as
Encoding:
Text File  |  2008-09-02  |  3.1 KB  |  115 lines

  1. package fl.livepreview
  2. {
  3.    import flash.display.*;
  4.    import flash.external.*;
  5.    import flash.utils.*;
  6.    
  7.    public class LivePreviewParent extends MovieClip
  8.    {
  9.        
  10.       
  11.       public var myInstance:DisplayObject;
  12.       
  13.       public function LivePreviewParent()
  14.       {
  15.          super();
  16.          try
  17.          {
  18.             stage.align = StageAlign.TOP_LEFT;
  19.             stage.scaleMode = StageScaleMode.NO_SCALE;
  20.             myInstance = getChildAt(0);
  21.             onResize(stage.width,stage.height);
  22.             if(ExternalInterface.available)
  23.             {
  24.                ExternalInterface.addCallback("onResize",onResize);
  25.                ExternalInterface.addCallback("onUpdate",onUpdate);
  26.             }
  27.          }
  28.          catch(e:*)
  29.          {
  30.          }
  31.       }
  32.       
  33.       private function updateCollection(param1:Object, param2:String) : void
  34.       {
  35.          var _loc3_:Class = null;
  36.          var _loc4_:Class = null;
  37.          var _loc5_:Object = null;
  38.          var _loc6_:int = 0;
  39.          var _loc7_:Object = null;
  40.          var _loc8_:Object = null;
  41.          var _loc9_:* = undefined;
  42.          _loc3_ = Class(getDefinitionByName(param1.collectionClass));
  43.          _loc4_ = Class(getDefinitionByName(param1.collectionItemClass));
  44.          _loc5_ = new _loc3_();
  45.          _loc6_ = 0;
  46.          while(_loc6_ < param1.collectionArray.length)
  47.          {
  48.             _loc7_ = new _loc4_();
  49.             _loc8_ = param1.collectionArray[_loc6_];
  50.             for(_loc9_ in _loc8_)
  51.             {
  52.                _loc7_[_loc9_] = _loc8_[_loc9_];
  53.             }
  54.             _loc5_.addItem(_loc7_);
  55.             _loc6_++;
  56.          }
  57.          myInstance[param2] = _loc5_ as _loc3_;
  58.       }
  59.       
  60.       public function onResize(param1:Number, param2:Number) : void
  61.       {
  62.          var setSizeFn:Function = null;
  63.          var width:Number = param1;
  64.          var height:Number = param2;
  65.          setSizeFn = null;
  66.          try
  67.          {
  68.             setSizeFn = myInstance["setSize"];
  69.          }
  70.          catch(e:Error)
  71.          {
  72.             setSizeFn = null;
  73.          }
  74.          if(setSizeFn != null)
  75.          {
  76.             setSizeFn(width,height);
  77.          }
  78.          else
  79.          {
  80.             myInstance.width = width;
  81.             myInstance.height = height;
  82.          }
  83.       }
  84.       
  85.       public function onUpdate(... rest) : void
  86.       {
  87.          var i:int = 0;
  88.          var name:String = null;
  89.          var value:* = undefined;
  90.          var updateArray:Array = rest;
  91.          i = 0;
  92.          while(i + 1 < updateArray.length)
  93.          {
  94.             try
  95.             {
  96.                name = String(updateArray[i]);
  97.                value = updateArray[i + 1];
  98.                if(typeof value == "object" && Boolean(value.__treatAsCollectionSpecialSauce__))
  99.                {
  100.                   updateCollection(value,name);
  101.                }
  102.                else
  103.                {
  104.                   myInstance[name] = value;
  105.                }
  106.             }
  107.             catch(e:Error)
  108.             {
  109.             }
  110.             i += 2;
  111.          }
  112.       }
  113.    }
  114. }
  115.