Advertisement
Guest User

G4H uploader.swf

a guest
Jul 3rd, 2013
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.yahoo.yui
  2. {
  3.     import flash.accessibility.*;
  4.     import flash.display.*;
  5.     import flash.errors.*;
  6.     import flash.events.*;
  7.     import flash.external.*;
  8.     import flash.system.*;
  9.     import flash.text.*;
  10.  
  11.     public class YUIAdapter extends Sprite
  12.     {
  13.         protected var elementID:String;
  14.         protected var javaScriptEventHandler:String;
  15.         private var _component:DisplayObject;
  16.         private var _errorText:TextField;
  17.         private var _altText:String;
  18.  
  19.         public function YUIAdapter()
  20.         {
  21.             var swfReady:Object;
  22.             if (this.stage)
  23.             {
  24.                 this.stage.addEventListener(Event.RESIZE, this.stageResizeHandler);
  25.                 this.stage.scaleMode = StageScaleMode.NO_SCALE;
  26.                 this.stage.align = StageAlign.TOP_LEFT;
  27.             }
  28.             try
  29.             {
  30.                 ExternalInterface.marshallExceptions = true;
  31.             }
  32.             catch (error:Error)
  33.             {
  34.             }
  35.             this._errorText = new TextField();
  36.             this._errorText.defaultTextFormat = new TextFormat("_sans", 10, 16711680);
  37.             this._errorText.wordWrap = true;
  38.             this._errorText.autoSize = TextFieldAutoSize.LEFT;
  39.             this._errorText.selectable = false;
  40.             this._errorText.mouseEnabled = false;
  41.             this.addChild(this._errorText);
  42.             this.addEventListener(Event.ADDED, this.addedHandler);
  43.             if (ExternalInterface.available)
  44.             {
  45.                 this.initializeComponent();
  46.                 swfReady;
  47.                 this.dispatchEventToJavaScript(swfReady);
  48.             }
  49.             else
  50.             {
  51.                 throw new IOError("Flash YUIComponent cannot communicate with JavaScript content.");
  52.             }
  53.             return;
  54.         }// end function
  55.  
  56.         protected function get component() : DisplayObject
  57.         {
  58.             return this._component;
  59.         }// end function
  60.  
  61.         protected function set component(param1:DisplayObject) : void
  62.         {
  63.             this._component = param1;
  64.             this.refreshComponentSize();
  65.             return;
  66.         }// end function
  67.  
  68.         public function getAltText() : String
  69.         {
  70.             return this._altText;
  71.         }// end function
  72.  
  73.         public function setAltText(param1:String) : void
  74.         {
  75.             this._altText = param1;
  76.             var _loc_2:* = new AccessibilityProperties();
  77.             _loc_2.name = this._altText;
  78.             _loc_2.forceSimple = true;
  79.             _loc_2.noAutoLabeling = true;
  80.             this.component.accessibilityProperties = _loc_2;
  81.             return;
  82.         }// end function
  83.  
  84.         protected function initializeComponent() : void
  85.         {
  86.             this.elementID = this.loaderInfo.parameters.YUISwfId;
  87.             this.javaScriptEventHandler = this.loaderInfo.parameters.YUIBridgeCallback;
  88.             var jsCheck:* = /^[A-Za-z0-9.]*$/g;
  89.             if (!jsCheck.test(this.javaScriptEventHandler))
  90.             {
  91.                 this.javaScriptEventHandler = "";
  92.             }
  93.             var allowedDomain:* = this.loaderInfo.parameters.allowedDomain;
  94.             if (allowedDomain)
  95.             {
  96.                 Security.allowDomain(allowedDomain);
  97.                 this.log("allowing: " + allowedDomain);
  98.             }
  99.             try
  100.             {
  101.                 ExternalInterface.addCallback("getAltText", this.getAltText);
  102.                 ExternalInterface.addCallback("setAltText", this.setAltText);
  103.             }
  104.             catch (error:SecurityError)
  105.             {
  106.             }
  107.             return;
  108.         }// end function
  109.  
  110.         protected function log(param1:Object, param2:String = null) : void
  111.         {
  112.             if (param1 == null)
  113.             {
  114.                 param1 = "";
  115.             }
  116.             this.dispatchEventToJavaScript({type:"log", message:param1.toString(), category:param2});
  117.             return;
  118.         }// end function
  119.  
  120.         protected function showFatalError(param1:Object) : void
  121.         {
  122.             if (!param1)
  123.             {
  124.                 param1 = "";
  125.             }
  126.             if (this._errorText)
  127.             {
  128.                 this._errorText.appendText(param1.toString());
  129.                 this._errorText.scrollV = this._errorText.maxScrollV;
  130.                 this._errorText.mouseEnabled = true;
  131.                 this._errorText.selectable = true;
  132.             }
  133.             return;
  134.         }// end function
  135.  
  136.         protected function dispatchEventToJavaScript(param1:Object) : void
  137.         {
  138.             var event:* = param1;
  139.             try
  140.             {
  141.                 if (ExternalInterface.available)
  142.                 {
  143.                     ExternalInterface.call(this.javaScriptEventHandler, this.elementID, event);
  144.                 }
  145.             }
  146.             catch (error:Error)
  147.             {
  148.                 if (error is SecurityError)
  149.                 {
  150.                     this.showFatalError("Warning: Cannot establish communication between YUI Charts and JavaScript. YUI Charts must be served from HTTP and cannot be viewed locally with file:/// protocol unless location is trusted by Flash Player.\n\nFor more information see:\nhttp://www.adobe.com/products/flashplayer/articles/localcontent/\n\n");
  151.                 }
  152.             }
  153.             return;
  154.         }// end function
  155.  
  156.         protected function stageResizeHandler(event:Event) : void
  157.         {
  158.             this.refreshComponentSize();
  159.             if (this._errorText)
  160.             {
  161.                 this._errorText.width = this.stage.stageWidth;
  162.                 this._errorText.height = this.stage.stageHeight;
  163.             }
  164.             this.log("resize (width: " + this.stage.stageWidth + ", height: " + this.stage.stageHeight + ")", LoggerCategory.INFO);
  165.             return;
  166.         }// end function
  167.  
  168.         protected function refreshComponentSize() : void
  169.         {
  170.             if (this.component)
  171.             {
  172.                 var _loc_1:* = 0;
  173.                 this.component.y = 0;
  174.                 this.component.x = _loc_1;
  175.                 this.component.width = this.stage.stageWidth;
  176.                 this.component.height = this.stage.stageHeight;
  177.             }
  178.             return;
  179.         }// end function
  180.  
  181.         protected function addedHandler(event:Event) : void
  182.         {
  183.             this.setChildIndex(this._errorText, (this.numChildren - 1));
  184.             return;
  185.         }// end function
  186.  
  187.     }
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement