Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fl.motion.easing {
- public class Back {
- public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0):Number{
- if (!_arg5){
- _arg5 = 1.70158;
- };
- _arg1 = (_arg1 / _arg4);
- return (((((_arg3 * _arg1) * _arg1) * (((_arg5 + 1) * _arg1) - _arg5)) + _arg2));
- }
- public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0):Number{
- if (!_arg5){
- _arg5 = 1.70158;
- };
- _arg1 = ((_arg1 / _arg4) - 1);
- return (((_arg3 * (((_arg1 * _arg1) * (((_arg5 + 1) * _arg1) + _arg5)) + 1)) + _arg2));
- }
- public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0):Number{
- if (!_arg5){
- _arg5 = 1.70158;
- };
- _arg1 = (_arg1 / (_arg4 / 2));
- if (_arg1 < 1){
- _arg5 = (_arg5 * 1.525);
- return ((((_arg3 / 2) * ((_arg1 * _arg1) * (((_arg5 + 1) * _arg1) - _arg5))) + _arg2));
- };
- _arg1 = (_arg1 - 2);
- _arg5 = (_arg5 * 1.525);
- return ((((_arg3 / 2) * (((_arg1 * _arg1) * (((_arg5 + 1) * _arg1) + _arg5)) + 2)) + _arg2));
- }
- }
- }//package fl.motion.easing
- package fl.motion.easing {
- public class Quartic {
- public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
- _arg1 = (_arg1 / _arg4);
- return ((((((_arg3 * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
- }
- public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
- _arg1 = ((_arg1 / _arg4) - 1);
- return (((-(_arg3) * ((((_arg1 * _arg1) * _arg1) * _arg1) - 1)) + _arg2));
- }
- public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
- _arg1 = (_arg1 / (_arg4 / 2));
- if (_arg1 < 1){
- return (((((((_arg3 / 2) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
- };
- _arg1 = (_arg1 - 2);
- return ((((-(_arg3) / 2) * ((((_arg1 * _arg1) * _arg1) * _arg1) - 2)) + _arg2));
- }
- }
- }//package fl.motion.easing
- package fl.motion.easing {
- public class Linear {
- public static function easeNone(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
- return ((((_arg3 * _arg1) / _arg4) + _arg2));
- }
- public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
- return ((((_arg3 * _arg1) / _arg4) + _arg2));
- }
- public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
- return ((((_arg3 * _arg1) / _arg4) + _arg2));
- }
- public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
- return ((((_arg3 * _arg1) / _arg4) + _arg2));
- }
- }
- }//package fl.motion.easing
- package fl.managers {
- import fl.controls.*;
- import flash.display.*;
- import flash.events.*;
- import fl.core.*;
- import flash.utils.*;
- import flash.text.*;
- import flash.ui.*;
- public class FocusManager implements IFocusManager {
- private var focusableObjects:Dictionary;
- private var _showFocusIndicator:Boolean = true;
- private var defButton:Button;
- private var focusableCandidates:Array;
- private var _form:DisplayObjectContainer;
- private var _defaultButtonEnabled:Boolean = true;
- private var activated:Boolean = false;
- private var _defaultButton:Button;
- private var calculateCandidates:Boolean = true;
- private var lastFocus:InteractiveObject;
- private var lastAction:String;
- public function FocusManager(_arg1:DisplayObjectContainer){
- activated = false;
- calculateCandidates = true;
- _showFocusIndicator = true;
- _defaultButtonEnabled = true;
- super();
- focusableObjects = new Dictionary(true);
- if (_arg1 != null){
- _form = _arg1;
- addFocusables(DisplayObject(_arg1));
- _arg1.addEventListener(Event.ADDED, addedHandler);
- _arg1.addEventListener(Event.REMOVED, removedHandler);
- activate();
- };
- }
- public function get showFocusIndicator():Boolean{
- return (_showFocusIndicator);
- }
- private function getIndexOfNextObject(_arg1:int, _arg2:Boolean, _arg3:Boolean, _arg4:String):int{
- var _local5:int;
- var _local6:int;
- var _local7:DisplayObject;
- var _local8:IFocusManagerGroup;
- var _local9:int;
- var _local10:DisplayObject;
- var _local11:IFocusManagerGroup;
- _local5 = focusableCandidates.length;
- _local6 = _arg1;
- while (true) {
- if (_arg2){
- _arg1--;
- } else {
- _arg1++;
- };
- if (_arg3){
- if (((_arg2) && ((_arg1 < 0)))){
- break;
- };
- if (((!(_arg2)) && ((_arg1 == _local5)))){
- break;
- };
- } else {
- _arg1 = ((_arg1 + _local5) % _local5);
- if (_local6 == _arg1){
- break;
- };
- };
- if (isValidFocusCandidate(focusableCandidates[_arg1], _arg4)){
- _local7 = DisplayObject(findFocusManagerComponent(focusableCandidates[_arg1]));
- if ((_local7 is IFocusManagerGroup)){
- _local8 = IFocusManagerGroup(_local7);
- _local9 = 0;
- while (_local9 < focusableCandidates.length) {
- _local10 = focusableCandidates[_local9];
- if ((_local10 is IFocusManagerGroup)){
- _local11 = IFocusManagerGroup(_local10);
- if ((((_local11.groupName == _local8.groupName)) && (_local11.selected))){
- _arg1 = _local9;
- break;
- };
- };
- _local9++;
- };
- };
- return (_arg1);
- };
- };
- return (_arg1);
- }
- public function set form(_arg1:DisplayObjectContainer):void{
- _form = _arg1;
- }
- private function addFocusables(_arg1:DisplayObject, _arg2:Boolean=false):void{
- var focusable:* = null;
- var io:* = null;
- var doc:* = null;
- var i:* = 0;
- var child:* = null;
- var o:* = _arg1;
- var skipTopLevel:Boolean = _arg2;
- if (!skipTopLevel){
- if ((o is IFocusManagerComponent)){
- focusable = IFocusManagerComponent(o);
- if (focusable.focusEnabled){
- if (((focusable.tabEnabled) && (isTabVisible(o)))){
- focusableObjects[o] = true;
- calculateCandidates = true;
- };
- o.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
- o.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
- };
- } else {
- if ((o is InteractiveObject)){
- io = (o as InteractiveObject);
- if (((((io) && (io.tabEnabled))) && ((findFocusManagerComponent(io) == io)))){
- focusableObjects[io] = true;
- calculateCandidates = true;
- };
- io.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
- io.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
- };
- };
- };
- if ((o is DisplayObjectContainer)){
- doc = DisplayObjectContainer(o);
- o.addEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
- if ((((((doc is Stage)) || ((doc.parent is Stage)))) || (doc.tabChildren))){
- i = 0;
- while (i < doc.numChildren) {
- try {
- child = doc.getChildAt(i);
- if (child != null){
- addFocusables(doc.getChildAt(i));
- };
- } catch(error:SecurityError) {
- };
- i = (i + 1);
- };
- };
- };
- }
- private function getChildIndex(_arg1:DisplayObjectContainer, _arg2:DisplayObject):int{
- return (_arg1.getChildIndex(_arg2));
- }
- private function mouseFocusChangeHandler(_arg1:FocusEvent):void{
- if ((_arg1.relatedObject is TextField)){
- return;
- };
- _arg1.preventDefault();
- }
- private function focusOutHandler(_arg1:FocusEvent):void{
- var _local2:InteractiveObject;
- _local2 = (_arg1.target as InteractiveObject);
- }
- private function isValidFocusCandidate(_arg1:DisplayObject, _arg2:String):Boolean{
- var _local3:IFocusManagerGroup;
- if (!isEnabledAndVisible(_arg1)){
- return (false);
- };
- if ((_arg1 is IFocusManagerGroup)){
- _local3 = IFocusManagerGroup(_arg1);
- if (_arg2 == _local3.groupName){
- return (false);
- };
- };
- return (true);
- }
- public function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject{
- var _local2:InteractiveObject;
- _local2 = _arg1;
- while (_arg1) {
- if ((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))){
- return (_arg1);
- };
- _arg1 = _arg1.parent;
- };
- return (_local2);
- }
- private function sortFocusableObjectsTabIndex():void{
- var _local1:Object;
- var _local2:InteractiveObject;
- focusableCandidates = [];
- for (_local1 in focusableObjects) {
- _local2 = InteractiveObject(_local1);
- if (((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))){
- focusableCandidates.push(_local2);
- };
- };
- focusableCandidates.sort(sortByTabIndex);
- }
- private function removeFocusables(_arg1:DisplayObject):void{
- var _local2:Object;
- var _local3:DisplayObject;
- if ((_arg1 is DisplayObjectContainer)){
- _arg1.removeEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
- _arg1.removeEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
- for (_local2 in focusableObjects) {
- _local3 = DisplayObject(_local2);
- if (DisplayObjectContainer(_arg1).contains(_local3)){
- if (_local3 == lastFocus){
- lastFocus = null;
- };
- _local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
- delete focusableObjects[_local2];
- calculateCandidates = true;
- };
- };
- };
- }
- private function addedHandler(_arg1:Event):void{
- var _local2:DisplayObject;
- _local2 = DisplayObject(_arg1.target);
- if (_local2.stage){
- addFocusables(DisplayObject(_arg1.target));
- };
- }
- private function getTopLevelFocusTarget(_arg1:InteractiveObject):InteractiveObject{
- while (_arg1 != InteractiveObject(form)) {
- if ((((((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))) && (IFocusManagerComponent(_arg1).mouseFocusEnabled))) && (UIComponent(_arg1).enabled))){
- return (_arg1);
- };
- _arg1 = _arg1.parent;
- if (_arg1 == null){
- break;
- };
- };
- return (null);
- }
- private function tabChildrenChangeHandler(_arg1:Event):void{
- var _local2:DisplayObjectContainer;
- if (_arg1.target != _arg1.currentTarget){
- return;
- };
- calculateCandidates = true;
- _local2 = DisplayObjectContainer(_arg1.target);
- if (_local2.tabChildren){
- addFocusables(_local2, true);
- } else {
- removeFocusables(_local2);
- };
- }
- public function sendDefaultButtonEvent():void{
- defButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
- }
- public function getFocus():InteractiveObject{
- var _local1:InteractiveObject;
- _local1 = form.stage.focus;
- return (findFocusManagerComponent(_local1));
- }
- private function isEnabledAndVisible(_arg1:DisplayObject):Boolean{
- var _local2:DisplayObjectContainer;
- var _local3:TextField;
- var _local4:SimpleButton;
- _local2 = DisplayObject(form).parent;
- while (_arg1 != _local2) {
- if ((_arg1 is UIComponent)){
- if (!UIComponent(_arg1).enabled){
- return (false);
- };
- } else {
- if ((_arg1 is TextField)){
- _local3 = TextField(_arg1);
- if ((((_local3.type == TextFieldType.DYNAMIC)) || (!(_local3.selectable)))){
- return (false);
- };
- } else {
- if ((_arg1 is SimpleButton)){
- _local4 = SimpleButton(_arg1);
- if (!_local4.enabled){
- return (false);
- };
- };
- };
- };
- if (!_arg1.visible){
- return (false);
- };
- _arg1 = _arg1.parent;
- };
- return (true);
- }
- public function set defaultButton(_arg1:Button):void{
- var _local2:Button;
- _local2 = ((_arg1) ? Button(_arg1) : null);
- if (_local2 != _defaultButton){
- if (_defaultButton){
- _defaultButton.emphasized = false;
- };
- if (defButton){
- defButton.emphasized = false;
- };
- _defaultButton = _local2;
- defButton = _local2;
- if (_local2){
- _local2.emphasized = true;
- };
- };
- }
- private function deactivateHandler(_arg1:Event):void{
- var _local2:InteractiveObject;
- _local2 = InteractiveObject(_arg1.target);
- }
- public function setFocus(_arg1:InteractiveObject):void{
- if ((_arg1 is IFocusManagerComponent)){
- IFocusManagerComponent(_arg1).setFocus();
- } else {
- form.stage.focus = _arg1;
- };
- }
- private function setFocusToNextObject(_arg1:FocusEvent):void{
- var _local2:InteractiveObject;
- if (!hasFocusableObjects()){
- return;
- };
- _local2 = getNextFocusManagerComponent(_arg1.shiftKey);
- if (_local2){
- setFocus(_local2);
- };
- }
- private function hasFocusableObjects():Boolean{
- var _local1:Object;
- for (_local1 in focusableObjects) {
- return (true);
- };
- return (false);
- }
- private function tabIndexChangeHandler(_arg1:Event):void{
- calculateCandidates = true;
- }
- private function sortFocusableObjects():void{
- var _local1:Object;
- var _local2:InteractiveObject;
- focusableCandidates = [];
- for (_local1 in focusableObjects) {
- _local2 = InteractiveObject(_local1);
- if (((((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))) && ((_local2.tabIndex > 0)))){
- sortFocusableObjectsTabIndex();
- return;
- };
- focusableCandidates.push(_local2);
- };
- focusableCandidates.sort(sortByDepth);
- }
- private function keyFocusChangeHandler(_arg1:FocusEvent):void{
- showFocusIndicator = true;
- if ((((((_arg1.keyCode == Keyboard.TAB)) || ((_arg1.keyCode == 0)))) && (!(_arg1.isDefaultPrevented())))){
- setFocusToNextObject(_arg1);
- _arg1.preventDefault();
- };
- }
- private function getIndexOfFocusedObject(_arg1:DisplayObject):int{
- var _local2:int;
- var _local3:int;
- _local2 = focusableCandidates.length;
- _local3 = 0;
- _local3 = 0;
- while (_local3 < _local2) {
- if (focusableCandidates[_local3] == _arg1){
- return (_local3);
- };
- _local3++;
- };
- return (-1);
- }
- public function hideFocus():void{
- }
- private function removedHandler(_arg1:Event):void{
- var _local2:int;
- var _local3:DisplayObject;
- var _local4:InteractiveObject;
- _local3 = DisplayObject(_arg1.target);
- if ((((_local3 is IFocusManagerComponent)) && ((focusableObjects[_local3] == true)))){
- if (_local3 == lastFocus){
- IFocusManagerComponent(lastFocus).drawFocus(false);
- lastFocus = null;
- };
- _local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
- delete focusableObjects[_local3];
- calculateCandidates = true;
- } else {
- if ((((_local3 is InteractiveObject)) && ((focusableObjects[_local3] == true)))){
- _local4 = (_local3 as InteractiveObject);
- if (_local4){
- if (_local4 == lastFocus){
- lastFocus = null;
- };
- delete focusableObjects[_local4];
- calculateCandidates = true;
- };
- _local3.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
- };
- };
- removeFocusables(_local3);
- }
- private function sortByDepth(_arg1:InteractiveObject, _arg2:InteractiveObject):Number{
- var _local3:String;
- var _local4:String;
- var _local5:int;
- var _local6:String;
- var _local7:String;
- var _local8:String;
- var _local9:DisplayObject;
- var _local10:DisplayObject;
- _local3 = "";
- _local4 = "";
- _local8 = "0000";
- _local9 = DisplayObject(_arg1);
- _local10 = DisplayObject(_arg2);
- while (((!((_local9 == DisplayObject(form)))) && (_local9.parent))) {
- _local5 = getChildIndex(_local9.parent, _local9);
- _local6 = _local5.toString(16);
- if (_local6.length < 4){
- _local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
- };
- _local3 = (_local7 + _local3);
- _local9 = _local9.parent;
- };
- while (((!((_local10 == DisplayObject(form)))) && (_local10.parent))) {
- _local5 = getChildIndex(_local10.parent, _local10);
- _local6 = _local5.toString(16);
- if (_local6.length < 4){
- _local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
- };
- _local4 = (_local7 + _local4);
- _local10 = _local10.parent;
- };
- return ((((_local3 > _local4)) ? 1 : (((_local3 < _local4)) ? -1 : 0)));
- }
- public function get defaultButton():Button{
- return (_defaultButton);
- }
- private function activateHandler(_arg1:Event):void{
- var _local2:InteractiveObject;
- _local2 = InteractiveObject(_arg1.target);
- if (lastFocus){
- if ((lastFocus is IFocusManagerComponent)){
- IFocusManagerComponent(lastFocus).setFocus();
- } else {
- form.stage.focus = lastFocus;
- };
- };
- lastAction = "ACTIVATE";
- }
- public function showFocus():void{
- }
- public function set defaultButtonEnabled(_arg1:Boolean):void{
- _defaultButtonEnabled = _arg1;
- }
- public function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject{
- var _local2:DisplayObject;
- var _local3:String;
- var _local4:int;
- var _local5:Boolean;
- var _local6:int;
- var _local7:int;
- var _local8:IFocusManagerGroup;
- if (!hasFocusableObjects()){
- return (null);
- };
- if (calculateCandidates){
- sortFocusableObjects();
- calculateCandidates = false;
- };
- _local2 = form.stage.focus;
- _local2 = DisplayObject(findFocusManagerComponent(InteractiveObject(_local2)));
- _local3 = "";
- if ((_local2 is IFocusManagerGroup)){
- _local8 = IFocusManagerGroup(_local2);
- _local3 = _local8.groupName;
- };
- _local4 = getIndexOfFocusedObject(_local2);
- _local5 = false;
- _local6 = _local4;
- if (_local4 == -1){
- if (_arg1){
- _local4 = focusableCandidates.length;
- };
- _local5 = true;
- };
- _local7 = getIndexOfNextObject(_local4, _arg1, _local5, _local3);
- return (findFocusManagerComponent(focusableCandidates[_local7]));
- }
- private function mouseDownHandler(_arg1:MouseEvent):void{
- var _local2:InteractiveObject;
- if (_arg1.isDefaultPrevented()){
- return;
- };
- _local2 = getTopLevelFocusTarget(InteractiveObject(_arg1.target));
- if (!_local2){
- return;
- };
- showFocusIndicator = false;
- if (((((!((_local2 == lastFocus))) || ((lastAction == "ACTIVATE")))) && (!((_local2 is TextField))))){
- setFocus(_local2);
- };
- lastAction = "MOUSEDOWN";
- }
- private function isTabVisible(_arg1:DisplayObject):Boolean{
- var _local2:DisplayObjectContainer;
- _local2 = _arg1.parent;
- while (((((_local2) && (!((_local2 is Stage))))) && (!(((_local2.parent) && ((_local2.parent is Stage))))))) {
- if (!_local2.tabChildren){
- return (false);
- };
- _local2 = _local2.parent;
- };
- return (true);
- }
- public function get nextTabIndex():int{
- return (0);
- }
- private function keyDownHandler(_arg1:KeyboardEvent):void{
- if (_arg1.keyCode == Keyboard.TAB){
- lastAction = "KEY";
- if (calculateCandidates){
- sortFocusableObjects();
- calculateCandidates = false;
- };
- };
- if (((((((defaultButtonEnabled) && ((_arg1.keyCode == Keyboard.ENTER)))) && (defaultButton))) && (defButton.enabled))){
- sendDefaultButtonEvent();
- };
- }
- private function focusInHandler(_arg1:FocusEvent):void{
- var _local2:InteractiveObject;
- var _local3:Button;
- _local2 = InteractiveObject(_arg1.target);
- if (form.contains(_local2)){
- lastFocus = findFocusManagerComponent(InteractiveObject(_local2));
- if ((lastFocus is Button)){
- _local3 = Button(lastFocus);
- if (defButton){
- defButton.emphasized = false;
- defButton = _local3;
- _local3.emphasized = true;
- };
- } else {
- if (((defButton) && (!((defButton == _defaultButton))))){
- defButton.emphasized = false;
- defButton = _defaultButton;
- _defaultButton.emphasized = true;
- };
- };
- };
- }
- private function tabEnabledChangeHandler(_arg1:Event):void{
- var _local2:InteractiveObject;
- var _local3:Boolean;
- calculateCandidates = true;
- _local2 = InteractiveObject(_arg1.target);
- _local3 = (focusableObjects[_local2] == true);
- if (_local2.tabEnabled){
- if (((!(_local3)) && (isTabVisible(_local2)))){
- if (!(_local2 is IFocusManagerComponent)){
- _local2.focusRect = false;
- };
- focusableObjects[_local2] = true;
- };
- } else {
- if (_local3){
- delete focusableObjects[_local2];
- };
- };
- }
- public function set showFocusIndicator(_arg1:Boolean):void{
- _showFocusIndicator = _arg1;
- }
- public function get form():DisplayObjectContainer{
- return (_form);
- }
- private function sortByTabIndex(_arg1:InteractiveObject, _arg2:InteractiveObject):int{
- return ((((_arg1.tabIndex > _arg2.tabIndex)) ? 1 : (((_arg1.tabIndex < _arg2.tabIndex)) ? -1 : sortByDepth(_arg1, _arg2))));
- }
- public function activate():void{
- if (activated){
- return;
- };
- form.stage.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler, false, 0, true);
- form.stage.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler, false, 0, true);
- form.addEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
- form.addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
- form.stage.addEventListener(Event.ACTIVATE, activateHandler, false, 0, true);
- form.stage.addEventListener(Event.DEACTIVATE, deactivateHandler, false, 0, true);
- form.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
- form.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
- activated = true;
- if (lastFocus){
- setFocus(lastFocus);
- };
- }
- public function deactivate():void{
- form.stage.removeEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler);
- form.stage.removeEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler);
- form.removeEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
- form.removeEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
- form.stage.removeEventListener(Event.ACTIVATE, activateHandler);
- form.stage.removeEventListener(Event.DEACTIVATE, deactivateHandler);
- form.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
- form.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
- activated = false;
- }
- public function get defaultButtonEnabled():Boolean{
- return (_defaultButtonEnabled);
- }
- }
- }//package fl.managers
- package fl.managers {
- import fl.core.*;
- import flash.utils.*;
- import flash.text.*;
- public class StyleManager {
- private static var _instance:StyleManager;
- private var globalStyles:Object;
- private var classToDefaultStylesDict:Dictionary;
- private var styleToClassesHash:Object;
- private var classToStylesDict:Dictionary;
- private var classToInstancesDict:Dictionary;
- public function StyleManager(){
- styleToClassesHash = {};
- classToInstancesDict = new Dictionary(true);
- classToStylesDict = new Dictionary(true);
- classToDefaultStylesDict = new Dictionary(true);
- globalStyles = UIComponent.getStyleDefinition();
- }
- public static function clearComponentStyle(_arg1:Object, _arg2:String):void{
- var _local3:Class;
- var _local4:Object;
- _local3 = getClassDef(_arg1);
- _local4 = getInstance().classToStylesDict[_local3];
- if (((!((_local4 == null))) && (!((_local4[_arg2] == null))))){
- delete _local4[_arg2];
- invalidateComponentStyle(_local3, _arg2);
- };
- }
- private static function getClassDef(_arg1:Object):Class{
- var component:* = _arg1;
- if ((component is Class)){
- return ((component as Class));
- };
- try {
- return ((getDefinitionByName(getQualifiedClassName(component)) as Class));
- } catch(e:Error) {
- if ((component is UIComponent)){
- try {
- return ((component.loaderInfo.applicationDomain.getDefinition(getQualifiedClassName(component)) as Class));
- } catch(e:Error) {
- };
- };
- };
- return (null);
- }
- public static function clearStyle(_arg1:String):void{
- setStyle(_arg1, null);
- }
- public static function setComponentStyle(_arg1:Object, _arg2:String, _arg3:Object):void{
- var _local4:Class;
- var _local5:Object;
- _local4 = getClassDef(_arg1);
- _local5 = getInstance().classToStylesDict[_local4];
- if (_local5 == null){
- _local5 = (getInstance().classToStylesDict[_local4] = {});
- };
- if (_local5 == _arg3){
- return;
- };
- _local5[_arg2] = _arg3;
- invalidateComponentStyle(_local4, _arg2);
- }
- private static function setSharedStyles(_arg1:UIComponent):void{
- var _local2:StyleManager;
- var _local3:Class;
- var _local4:Object;
- var _local5:String;
- _local2 = getInstance();
- _local3 = getClassDef(_arg1);
- _local4 = _local2.classToDefaultStylesDict[_local3];
- for (_local5 in _local4) {
- _arg1.setSharedStyle(_local5, getSharedStyle(_arg1, _local5));
- };
- }
- public static function getComponentStyle(_arg1:Object, _arg2:String):Object{
- var _local3:Class;
- var _local4:Object;
- _local3 = getClassDef(_arg1);
- _local4 = getInstance().classToStylesDict[_local3];
- return (((_local4)==null) ? null : _local4[_arg2]);
- }
- private static function getInstance(){
- if (_instance == null){
- _instance = new (StyleManager)();
- };
- return (_instance);
- }
- private static function invalidateComponentStyle(_arg1:Class, _arg2:String):void{
- var _local3:Dictionary;
- var _local4:Object;
- var _local5:UIComponent;
- _local3 = getInstance().classToInstancesDict[_arg1];
- if (_local3 == null){
- return;
- };
- for (_local4 in _local3) {
- _local5 = (_local4 as UIComponent);
- if (_local5 == null){
- } else {
- _local5.setSharedStyle(_arg2, getSharedStyle(_local5, _arg2));
- };
- };
- }
- private static function invalidateStyle(_arg1:String):void{
- var _local2:Dictionary;
- var _local3:Object;
- _local2 = getInstance().styleToClassesHash[_arg1];
- if (_local2 == null){
- return;
- };
- for (_local3 in _local2) {
- invalidateComponentStyle(Class(_local3), _arg1);
- };
- }
- public static function registerInstance(_arg1:UIComponent):void{
- var inst:* = null;
- var classDef:* = null;
- var target:* = null;
- var defaultStyles:* = null;
- var styleToClasses:* = null;
- var n:* = null;
- var instance:* = _arg1;
- inst = getInstance();
- classDef = getClassDef(instance);
- if (classDef == null){
- return;
- };
- if (inst.classToInstancesDict[classDef] == null){
- inst.classToInstancesDict[classDef] = new Dictionary(true);
- target = classDef;
- while (defaultStyles == null) {
- if (target["getStyleDefinition"] != null){
- defaultStyles = target["getStyleDefinition"]();
- break;
- };
- try {
- target = (instance.loaderInfo.applicationDomain.getDefinition(getQualifiedSuperclassName(target)) as Class);
- } catch(err:Error) {
- try {
- target = (getDefinitionByName(getQualifiedSuperclassName(target)) as Class);
- } catch(e:Error) {
- defaultStyles = UIComponent.getStyleDefinition();
- break;
- };
- };
- };
- styleToClasses = inst.styleToClassesHash;
- for (n in defaultStyles) {
- if (styleToClasses[n] == null){
- styleToClasses[n] = new Dictionary(true);
- };
- styleToClasses[n][classDef] = true;
- };
- inst.classToDefaultStylesDict[classDef] = defaultStyles;
- inst.classToStylesDict[classDef] = {};
- };
- inst.classToInstancesDict[classDef][instance] = true;
- setSharedStyles(instance);
- }
- public static function getStyle(_arg1:String):Object{
- return (getInstance().globalStyles[_arg1]);
- }
- private static function getSharedStyle(_arg1:UIComponent, _arg2:String):Object{
- var _local3:Class;
- var _local4:StyleManager;
- var _local5:Object;
- _local3 = getClassDef(_arg1);
- _local4 = getInstance();
- _local5 = _local4.classToStylesDict[_local3][_arg2];
- if (_local5 != null){
- return (_local5);
- };
- _local5 = _local4.globalStyles[_arg2];
- if (_local5 != null){
- return (_local5);
- };
- return (_local4.classToDefaultStylesDict[_local3][_arg2]);
- }
- public static function setStyle(_arg1:String, _arg2:Object):void{
- var _local3:Object;
- _local3 = getInstance().globalStyles;
- if ((((_local3[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
- return;
- };
- _local3[_arg1] = _arg2;
- invalidateStyle(_arg1);
- }
- }
- }//package fl.managers
- package fl.managers {
- public interface IFocusManagerComponent {
- function set focusEnabled(_arg1:Boolean):void;
- function drawFocus(_arg1:Boolean):void;
- function setFocus():void;
- function get focusEnabled():Boolean;
- function get tabEnabled():Boolean;
- function get tabIndex():int;
- function get mouseFocusEnabled():Boolean;
- }
- }//package fl.managers
- package fl.managers {
- import fl.controls.*;
- import flash.display.*;
- public interface IFocusManager {
- function getFocus():InteractiveObject;
- function deactivate():void;
- function set defaultButton(_arg1:Button):void;
- function set showFocusIndicator(_arg1:Boolean):void;
- function get defaultButtonEnabled():Boolean;
- function get nextTabIndex():int;
- function get defaultButton():Button;
- function get showFocusIndicator():Boolean;
- function setFocus(_arg1:InteractiveObject):void;
- function activate():void;
- function showFocus():void;
- function set defaultButtonEnabled(_arg1:Boolean):void;
- function hideFocus():void;
- function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject;
- function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject;
- }
- }//package fl.managers
- package fl.managers {
- public interface IFocusManagerGroup {
- function set groupName(_arg1:String):void;
- function set selected(_arg1:Boolean):void;
- function get groupName():String;
- function get selected():Boolean;
- }
- }//package fl.managers
- package fl.containers {
- import flash.display.*;
- import flash.events.*;
- import fl.core.*;
- import flash.net.*;
- import flash.utils.*;
- import flash.system.*;
- import fl.events.*;
- public class UILoader extends UIComponent {
- private static var defaultStyles:Object = {};
- protected var loader:Loader;
- protected var _autoLoad:Boolean = true;
- protected var _source:Object;
- protected var contentClip:Sprite;
- protected var _maintainAspectRatio:Boolean = true;
- protected var contentInited:Boolean = false;
- protected var _scaleContent:Boolean = true;
- public function UILoader(){
- _scaleContent = true;
- _autoLoad = true;
- contentInited = false;
- _maintainAspectRatio = true;
- super();
- }
- public static function getStyleDefinition():Object{
- return (defaultStyles);
- }
- public function get maintainAspectRatio():Boolean{
- return (_maintainAspectRatio);
- }
- public function set maintainAspectRatio(_arg1:Boolean):void{
- _maintainAspectRatio = _arg1;
- invalidate(InvalidationType.SIZE);
- }
- public function get source():Object{
- return (_source);
- }
- protected function _unload(_arg1:Boolean=false):void{
- var throwError:Boolean = _arg1;
- if (loader != null){
- clearLoadEvents();
- contentClip.removeChild(loader);
- try {
- loader.close();
- } catch(e:Error) {
- };
- try {
- loader.unload();
- } catch(e) {
- if (throwError){
- throw (e);
- };
- };
- loader = null;
- return;
- };
- contentInited = false;
- if (contentClip.numChildren){
- contentClip.removeChildAt(0);
- };
- }
- public function get bytesLoaded():uint{
- return ((((((loader == null)) || ((loader.contentLoaderInfo == null)))) ? 0 : loader.contentLoaderInfo.bytesLoaded));
- }
- public function set source(_arg1:Object):void{
- if (_arg1 == ""){
- return;
- };
- _source = _arg1;
- _unload();
- if (((_autoLoad) && (!((_source == null))))){
- load();
- };
- }
- public function set autoLoad(_arg1:Boolean):void{
- _autoLoad = _arg1;
- if (((((((_autoLoad) && ((loader == null)))) && (!((_source == null))))) && (!((_source == ""))))){
- load();
- };
- }
- public function get content():DisplayObject{
- if (loader != null){
- return (loader.content);
- };
- if (contentClip.numChildren){
- return (contentClip.getChildAt(0));
- };
- return (null);
- }
- public function get percentLoaded():Number{
- return (((bytesTotal)<=0) ? 0 : ((bytesLoaded / bytesTotal) * 100));
- }
- protected function handleError(_arg1:Event):void{
- passEvent(_arg1);
- clearLoadEvents();
- loader.contentLoaderInfo.removeEventListener(Event.INIT, handleInit);
- }
- public function load(_arg1:URLRequest=null, _arg2:LoaderContext=null):void{
- var _local3:DisplayObject;
- _unload();
- if ((((((_arg1 == null)) || ((_arg1.url == null)))) && ((((_source == null)) || ((_source == "")))))){
- return;
- };
- _local3 = getDisplayObjectInstance(source);
- if (_local3 != null){
- contentClip.addChild(_local3);
- contentInited = true;
- invalidate(InvalidationType.SIZE);
- return;
- };
- if (_arg1 == null){
- _arg1 = new URLRequest(_source.toString());
- };
- if (_arg2 == null){
- _arg2 = new LoaderContext(false, ApplicationDomain.currentDomain);
- };
- initLoader();
- loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, handleError, false, 0, true);
- loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, handleError, false, 0, true);
- loader.contentLoaderInfo.addEventListener(Event.OPEN, passEvent, false, 0, true);
- loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, passEvent, false, 0, true);
- loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleComplete, false, 0, true);
- loader.contentLoaderInfo.addEventListener(Event.INIT, handleInit, false, 0, true);
- loader.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, passEvent, false, 0, true);
- loader.load(_arg1, _arg2);
- }
- public function unload():void{
- _source = null;
- _unload(true);
- }
- protected function passEvent(_arg1:Event):void{
- dispatchEvent(_arg1);
- }
- public function loadBytes(_arg1:ByteArray, _arg2:LoaderContext=null):void{
- var bytes:* = _arg1;
- var context = _arg2;
- _unload();
- initLoader();
- try {
- loader.loadBytes(bytes, context);
- } catch(error) {
- throw (error);
- };
- }
- public function get autoLoad():Boolean{
- return (_autoLoad);
- }
- protected function sizeContent(_arg1:DisplayObject, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{
- var _local6:Number;
- var _local7:Number;
- var _local8:Number;
- var _local9:Number;
- _local6 = _arg4;
- _local7 = _arg5;
- if (_maintainAspectRatio){
- _local8 = (_arg4 / _arg5);
- _local9 = (_arg2 / _arg3);
- if (_local8 < _local9){
- _local7 = (_local6 / _local9);
- } else {
- _local6 = (_local7 * _local9);
- };
- };
- _arg1.width = _local6;
- _arg1.height = _local7;
- _arg1.x = ((_arg4 / 2) - (_local6 / 2));
- _arg1.y = ((_arg5 / 2) - (_local7 / 2));
- }
- protected function initLoader():void{
- loader = new Loader();
- contentClip.addChild(loader);
- }
- override protected function draw():void{
- if (isInvalid(InvalidationType.SIZE)){
- drawLayout();
- };
- super.draw();
- }
- override protected function configUI():void{
- super.configUI();
- contentClip = new Sprite();
- addChild(contentClip);
- }
- protected function handleInit(_arg1:Event):void{
- loader.contentLoaderInfo.removeEventListener(Event.INIT, handleInit);
- contentInited = true;
- passEvent(_arg1);
- invalidate(InvalidationType.SIZE);
- }
- protected function handleComplete(_arg1:Event):void{
- clearLoadEvents();
- passEvent(_arg1);
- }
- override public function setSize(_arg1:Number, _arg2:Number):void{
- if (((!(_scaleContent)) && ((_width > 0)))){
- return;
- };
- super.setSize(_arg1, _arg2);
- }
- protected function drawLayout():void{
- var _local1:Boolean;
- var _local2:Number;
- var _local3:Number;
- var _local4:Number;
- var _local5:Number;
- var _local6:LoaderInfo;
- if (!contentInited){
- return;
- };
- _local1 = false;
- if (loader){
- _local6 = loader.contentLoaderInfo;
- _local2 = _local6.width;
- _local3 = _local6.height;
- } else {
- _local2 = contentClip.width;
- _local3 = contentClip.height;
- };
- _local4 = _width;
- _local5 = _height;
- if (!_scaleContent){
- _width = contentClip.width;
- _height = contentClip.height;
- } else {
- sizeContent(contentClip, _local2, _local3, _width, _height);
- };
- if (((!((_local4 == _width))) || (!((_local5 == _height))))){
- dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, true));
- };
- }
- public function get bytesTotal():uint{
- return ((((((loader == null)) || ((loader.contentLoaderInfo == null)))) ? 0 : loader.contentLoaderInfo.bytesTotal));
- }
- public function set scaleContent(_arg1:Boolean):void{
- if (_scaleContent == _arg1){
- return;
- };
- _scaleContent = _arg1;
- invalidate(InvalidationType.SIZE);
- }
- protected function clearLoadEvents():void{
- loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, handleError);
- loader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, handleError);
- loader.contentLoaderInfo.removeEventListener(Event.OPEN, passEvent);
- loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, passEvent);
- loader.contentLoaderInfo.removeEventListener(HTTPStatusEvent.HTTP_STATUS, passEvent);
- loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, handleComplete);
- }
- public function get scaleContent():Boolean{
- return (_scaleContent);
- }
- public function close():void{
- try {
- loader.close();
- } catch(error) {
- throw (error);
- };
- }
- }
- }//package fl.containers
- package fl.events {
- import flash.events.*;
- public class ComponentEvent extends Event {
- public static const HIDE:String = "hide";
- public static const BUTTON_DOWN:String = "buttonDown";
- public static const MOVE:String = "move";
- public static const RESIZE:String = "resize";
- public static const ENTER:String = "enter";
- public static const LABEL_CHANGE:String = "labelChange";
- public static const SHOW:String = "show";
- public function ComponentEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
- super(_arg1, _arg2, _arg3);
- }
- override public function toString():String{
- return (formatToString("ComponentEvent", "type", "bubbles", "cancelable"));
- }
- override public function clone():Event{
- return (new ComponentEvent(type, bubbles, cancelable));
- }
- }
- }//package fl.events
- package fl.core {
- import flash.display.*;
- public dynamic class ComponentShim extends MovieClip {
- }
- }//package fl.core
- package fl.core {
- import flash.display.*;
- import flash.events.*;
- import fl.managers.*;
- import flash.utils.*;
- import flash.system.*;
- import flash.text.*;
- import fl.events.*;
- public class UIComponent extends Sprite {
- public static var inCallLaterPhase:Boolean = false;
- private static var defaultStyles:Object = {
- focusRectSkin:"focusRectSkin",
- focusRectPadding:2,
- textFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0),
- disabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0),
- defaultTextFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0),
- defaultDisabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0)
- };
- public static var createAccessibilityImplementation:Function;
- private static var focusManagers:Dictionary = new Dictionary(false);
- protected var _enabled:Boolean = true;
- private var _mouseFocusEnabled:Boolean = true;
- protected var startHeight:Number;
- protected var _height:Number;
- protected var _oldIMEMode:String = null;
- protected var startWidth:Number;
- public var focusTarget:IFocusManagerComponent;
- protected var errorCaught:Boolean = false;
- protected var uiFocusRect:DisplayObject;
- protected var _width:Number;
- public var version:String = "3.0.0.15";
- protected var isFocused:Boolean = false;
- protected var callLaterMethods:Dictionary;
- private var _focusEnabled:Boolean = true;
- private var tempText:TextField;
- protected var invalidateFlag:Boolean = false;
- protected var _inspector:Boolean = false;
- protected var sharedStyles:Object;
- protected var invalidHash:Object;
- protected var isLivePreview:Boolean = false;
- protected var _imeMode:String = null;
- protected var instanceStyles:Object;
- protected var _x:Number;
- protected var _y:Number;
- public function UIComponent(){
- version = "3.0.0.15";
- isLivePreview = false;
- invalidateFlag = false;
- _enabled = true;
- isFocused = false;
- _focusEnabled = true;
- _mouseFocusEnabled = true;
- _imeMode = null;
- _oldIMEMode = null;
- errorCaught = false;
- _inspector = false;
- super();
- instanceStyles = {};
- sharedStyles = {};
- invalidHash = {};
- callLaterMethods = new Dictionary();
- StyleManager.registerInstance(this);
- configUI();
- invalidate(InvalidationType.ALL);
- tabEnabled = (this is IFocusManagerComponent);
- focusRect = false;
- if (tabEnabled){
- addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
- addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
- addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
- addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
- };
- initializeFocusManager();
- addEventListener(Event.ENTER_FRAME, hookAccessibility, false, 0, true);
- }
- public static function getStyleDefinition():Object{
- return (defaultStyles);
- }
- public static function mergeStyles(... _args):Object{
- var _local2:Object;
- var _local3:uint;
- var _local4:uint;
- var _local5:Object;
- var _local6:String;
- _local2 = {};
- _local3 = _args.length;
- _local4 = 0;
- while (_local4 < _local3) {
- _local5 = _args[_local4];
- for (_local6 in _local5) {
- if (_local2[_local6] != null){
- } else {
- _local2[_local6] = _args[_local4][_local6];
- };
- };
- _local4++;
- };
- return (_local2);
- }
- public function drawFocus(_arg1:Boolean):void{
- var _local2:Number;
- isFocused = _arg1;
- if (((!((uiFocusRect == null))) && (contains(uiFocusRect)))){
- removeChild(uiFocusRect);
- uiFocusRect = null;
- };
- if (_arg1){
- uiFocusRect = (getDisplayObjectInstance(getStyleValue("focusRectSkin")) as Sprite);
- if (uiFocusRect == null){
- return;
- };
- _local2 = Number(getStyleValue("focusRectPadding"));
- uiFocusRect.x = -(_local2);
- uiFocusRect.y = -(_local2);
- uiFocusRect.width = (width + (_local2 * 2));
- uiFocusRect.height = (height + (_local2 * 2));
- addChildAt(uiFocusRect, 0);
- };
- }
- private function callLaterDispatcher(_arg1:Event):void{
- var _local2:Dictionary;
- var _local3:Object;
- if (_arg1.type == Event.ADDED_TO_STAGE){
- removeEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher);
- stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
- stage.invalidate();
- return;
- };
- _arg1.target.removeEventListener(Event.RENDER, callLaterDispatcher);
- if (stage == null){
- addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
- return;
- };
- inCallLaterPhase = true;
- _local2 = callLaterMethods;
- for (_local3 in _local2) {
- _local3();
- delete _local2[_local3];
- };
- inCallLaterPhase = false;
- }
- private function addedHandler(_arg1:Event):void{
- removeEventListener("addedToStage", addedHandler);
- initializeFocusManager();
- }
- protected function getStyleValue(_arg1:String):Object{
- return (((instanceStyles[_arg1])==null) ? sharedStyles[_arg1] : instanceStyles[_arg1]);
- }
- protected function isOurFocus(_arg1:DisplayObject):Boolean{
- return ((_arg1 == this));
- }
- override public function get scaleX():Number{
- return ((width / startWidth));
- }
- override public function get scaleY():Number{
- return ((height / startHeight));
- }
- override public function set height(_arg1:Number):void{
- if (_height == _arg1){
- return;
- };
- setSize(width, _arg1);
- }
- protected function keyDownHandler(_arg1:KeyboardEvent):void{
- }
- protected function focusInHandler(_arg1:FocusEvent):void{
- var _local2:IFocusManager;
- if (isOurFocus((_arg1.target as DisplayObject))){
- _local2 = focusManager;
- if (((_local2) && (_local2.showFocusIndicator))){
- drawFocus(true);
- isFocused = true;
- };
- };
- }
- public function setStyle(_arg1:String, _arg2:Object):void{
- if ((((instanceStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
- return;
- };
- instanceStyles[_arg1] = _arg2;
- invalidate(InvalidationType.STYLES);
- }
- override public function get visible():Boolean{
- return (super.visible);
- }
- public function get componentInspectorSetting():Boolean{
- return (_inspector);
- }
- override public function get x():Number{
- return (((isNaN(_x)) ? super.x : _x));
- }
- override public function get y():Number{
- return (((isNaN(_y)) ? super.y : _y));
- }
- protected function setIMEMode(_arg1:Boolean){
- var enabled:* = _arg1;
- if (_imeMode != null){
- if (enabled){
- IME.enabled = true;
- _oldIMEMode = IME.conversionMode;
- try {
- if (((!(errorCaught)) && (!((IME.conversionMode == IMEConversionMode.UNKNOWN))))){
- IME.conversionMode = _imeMode;
- };
- errorCaught = false;
- } catch(e:Error) {
- errorCaught = true;
- throw (new Error(("IME mode not supported: " + _imeMode)));
- };
- } else {
- if (((!((IME.conversionMode == IMEConversionMode.UNKNOWN))) && (!((_oldIMEMode == IMEConversionMode.UNKNOWN))))){
- IME.conversionMode = _oldIMEMode;
- };
- IME.enabled = false;
- };
- };
- }
- public function set enabled(_arg1:Boolean):void{
- if (_arg1 == _enabled){
- return;
- };
- _enabled = _arg1;
- invalidate(InvalidationType.STATE);
- }
- public function setSharedStyle(_arg1:String, _arg2:Object):void{
- if ((((sharedStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
- return;
- };
- sharedStyles[_arg1] = _arg2;
- if (instanceStyles[_arg1] == null){
- invalidate(InvalidationType.STYLES);
- };
- }
- protected function keyUpHandler(_arg1:KeyboardEvent):void{
- }
- public function set focusEnabled(_arg1:Boolean):void{
- _focusEnabled = _arg1;
- }
- override public function set scaleX(_arg1:Number):void{
- setSize((startWidth * _arg1), height);
- }
- public function get mouseFocusEnabled():Boolean{
- return (_mouseFocusEnabled);
- }
- override public function set scaleY(_arg1:Number):void{
- setSize(width, (startHeight * _arg1));
- }
- protected function getDisplayObjectInstance(_arg1:Object):DisplayObject{
- var classDef:* = null;
- var skin:* = _arg1;
- classDef = null;
- if ((skin is Class)){
- return ((new (skin)() as DisplayObject));
- };
- if ((skin is DisplayObject)){
- (skin as DisplayObject).x = 0;
- (skin as DisplayObject).y = 0;
- return ((skin as DisplayObject));
- };
- try {
- classDef = getDefinitionByName(skin.toString());
- } catch(e:Error) {
- try {
- classDef = (loaderInfo.applicationDomain.getDefinition(skin.toString()) as Object);
- } catch(e:Error) {
- };
- };
- if (classDef == null){
- return (null);
- };
- return ((new (classDef)() as DisplayObject));
- }
- protected function copyStylesToChild(_arg1:UIComponent, _arg2:Object):void{
- var _local3:String;
- for (_local3 in _arg2) {
- _arg1.setStyle(_local3, getStyleValue(_arg2[_local3]));
- };
- }
- protected function beforeComponentParameters():void{
- }
- protected function callLater(_arg1:Function):void{
- if (inCallLaterPhase){
- return;
- };
- callLaterMethods[_arg1] = true;
- if (stage != null){
- stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
- stage.invalidate();
- } else {
- addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
- };
- }
- protected function createFocusManager():void{
- if (focusManagers[stage] == null){
- focusManagers[stage] = new FocusManager(stage);
- };
- }
- override public function set visible(_arg1:Boolean):void{
- var _local2:String;
- if (super.visible == _arg1){
- return;
- };
- super.visible = _arg1;
- _local2 = ((_arg1) ? ComponentEvent.SHOW : ComponentEvent.HIDE);
- dispatchEvent(new ComponentEvent(_local2, true));
- }
- protected function hookAccessibility(_arg1:Event):void{
- removeEventListener(Event.ENTER_FRAME, hookAccessibility);
- initializeAccessibility();
- }
- public function set componentInspectorSetting(_arg1:Boolean):void{
- _inspector = _arg1;
- if (_inspector){
- beforeComponentParameters();
- } else {
- afterComponentParameters();
- };
- }
- override public function set x(_arg1:Number):void{
- move(_arg1, _y);
- }
- public function drawNow():void{
- draw();
- }
- override public function set y(_arg1:Number):void{
- move(_x, _arg1);
- }
- protected function checkLivePreview():Boolean{
- var className:* = null;
- if (parent == null){
- return (false);
- };
- try {
- className = getQualifiedClassName(parent);
- } catch(e:Error) {
- };
- return ((className == "fl.livepreview::LivePreviewParent"));
- }
- protected function focusOutHandler(_arg1:FocusEvent):void{
- if (isOurFocus((_arg1.target as DisplayObject))){
- drawFocus(false);
- isFocused = false;
- };
- }
- public function set mouseFocusEnabled(_arg1:Boolean):void{
- _mouseFocusEnabled = _arg1;
- }
- public function getFocus():InteractiveObject{
- if (stage){
- return (stage.focus);
- };
- return (null);
- }
- protected function validate():void{
- invalidHash = {};
- }
- override public function get height():Number{
- return (_height);
- }
- public function invalidate(_arg1:String="all", _arg2:Boolean=true):void{
- invalidHash[_arg1] = true;
- if (_arg2){
- this.callLater(draw);
- };
- }
- public function get enabled():Boolean{
- return (_enabled);
- }
- protected function getScaleX():Number{
- return (super.scaleX);
- }
- protected function getScaleY():Number{
- return (super.scaleY);
- }
- public function get focusEnabled():Boolean{
- return (_focusEnabled);
- }
- protected function afterComponentParameters():void{
- }
- protected function draw():void{
- if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
- if (((isFocused) && (focusManager.showFocusIndicator))){
- drawFocus(true);
- };
- };
- validate();
- }
- protected function configUI():void{
- var _local1:Number;
- var _local2:Number;
- var _local3:Number;
- isLivePreview = checkLivePreview();
- _local1 = rotation;
- rotation = 0;
- _local2 = super.width;
- _local3 = super.height;
- var _local4 = 1;
- super.scaleY = _local4;
- super.scaleX = _local4;
- setSize(_local2, _local3);
- move(super.x, super.y);
- rotation = _local1;
- startWidth = _local2;
- startHeight = _local3;
- if (numChildren > 0){
- removeChildAt(0);
- };
- }
- protected function setScaleX(_arg1:Number):void{
- super.scaleX = _arg1;
- }
- protected function setScaleY(_arg1:Number):void{
- super.scaleY = _arg1;
- }
- private function initializeFocusManager():void{
- if (stage == null){
- addEventListener(Event.ADDED_TO_STAGE, addedHandler, false, 0, true);
- } else {
- createFocusManager();
- };
- }
- public function set focusManager(_arg1:IFocusManager):void{
- UIComponent.focusManagers[this] = _arg1;
- }
- public function clearStyle(_arg1:String):void{
- setStyle(_arg1, null);
- }
- protected function isInvalid(_arg1:String, ... _args):Boolean{
- if (((invalidHash[_arg1]) || (invalidHash[InvalidationType.ALL]))){
- return (true);
- };
- while (_args.length > 0) {
- if (invalidHash[_args.pop()]){
- return (true);
- };
- };
- return (false);
- }
- public function setSize(_arg1:Number, _arg2:Number):void{
- _width = _arg1;
- _height = _arg2;
- invalidate(InvalidationType.SIZE);
- dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, false));
- }
- override public function set width(_arg1:Number):void{
- if (_width == _arg1){
- return;
- };
- setSize(_arg1, height);
- }
- public function setFocus():void{
- if (stage){
- stage.focus = this;
- };
- }
- protected function initializeAccessibility():void{
- if (UIComponent.createAccessibilityImplementation != null){
- UIComponent.createAccessibilityImplementation(this);
- };
- }
- public function get focusManager():IFocusManager{
- var _local1:DisplayObject;
- _local1 = this;
- while (_local1) {
- if (UIComponent.focusManagers[_local1] != null){
- return (IFocusManager(UIComponent.focusManagers[_local1]));
- };
- _local1 = _local1.parent;
- };
- return (null);
- }
- override public function get width():Number{
- return (_width);
- }
- public function move(_arg1:Number, _arg2:Number):void{
- _x = _arg1;
- _y = _arg2;
- super.x = Math.round(_arg1);
- super.y = Math.round(_arg2);
- dispatchEvent(new ComponentEvent(ComponentEvent.MOVE));
- }
- public function validateNow():void{
- invalidate(InvalidationType.ALL, false);
- draw();
- }
- public function getStyle(_arg1:String):Object{
- return (instanceStyles[_arg1]);
- }
- }
- }//package fl.core
- package fl.core {
- public class InvalidationType {
- public static const SIZE:String = "size";
- public static const ALL:String = "all";
- public static const DATA:String = "data";
- public static const SCROLL:String = "scroll";
- public static const STATE:String = "state";
- public static const STYLES:String = "styles";
- public static const SELECTED:String = "selected";
- public static const RENDERER_STYLES:String = "rendererStyles";
- }
- }//package fl.core
- package fl.transitions.easing {
- public class Strong {
- public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
- _arg1 = (_arg1 / _arg4);
- return (((((((_arg3 * _arg1) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
- }
- public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
- _arg1 = ((_arg1 / _arg4) - 1);
- return (((_arg3 * (((((_arg1 * _arg1) * _arg1) * _arg1) * _arg1) + 1)) + _arg2));
- }
- public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
- _arg1 = (_arg1 / (_arg4 / 2));
- if (_arg1 < 1){
- return ((((((((_arg3 / 2) * _arg1) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
- };
- _arg1 = (_arg1 - 2);
- return ((((_arg3 / 2) * (((((_arg1 * _arg1) * _arg1) * _arg1) * _arg1) + 2)) + _arg2));
- }
- }
- }//package fl.transitions.easing
- package fl.transitions.easing {
- public class Back {
- public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0):Number{
- if (!_arg5){
- _arg5 = 1.70158;
- };
- _arg1 = (_arg1 / _arg4);
- return (((((_arg3 * _arg1) * _arg1) * (((_arg5 + 1) * _arg1) - _arg5)) + _arg2));
- }
- public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0):Number{
- if (!_arg5){
- _arg5 = 1.70158;
- };
- _arg1 = ((_arg1 / _arg4) - 1);
- return (((_arg3 * (((_arg1 * _arg1) * (((_arg5 + 1) * _arg1) + _arg5)) + 1)) + _arg2));
- }
- public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0):Number{
- if (!_arg5){
- _arg5 = 1.70158;
- };
- _arg1 = (_arg1 / (_arg4 / 2));
- if (_arg1 < 1){
- _arg5 = (_arg5 * 1.525);
- return ((((_arg3 / 2) * ((_arg1 * _arg1) * (((_arg5 + 1) * _arg1) - _arg5))) + _arg2));
- };
- _arg1 = (_arg1 - 2);
- _arg5 = (_arg5 * 1.525);
- return ((((_arg3 / 2) * (((_arg1 * _arg1) * (((_arg5 + 1) * _arg1) + _arg5)) + 2)) + _arg2));
- }
- }
- }//package fl.transitions.easing
- package fl.transitions {
- import flash.events.*;
- public class TweenEvent extends Event {
- public static const MOTION_START:String = "motionStart";
- public static const MOTION_STOP:String = "motionStop";
- public static const MOTION_FINISH:String = "motionFinish";
- public static const MOTION_CHANGE:String = "motionChange";
- public static const MOTION_RESUME:String = "motionResume";
- public static const MOTION_LOOP:String = "motionLoop";
- public var time:Number = NaN;
- public var position:Number = NaN;
- public function TweenEvent(_arg1:String, _arg2:Number, _arg3:Number, _arg4:Boolean=false, _arg5:Boolean=false){
- super(_arg1, _arg4, _arg5);
- this.time = _arg2;
- this.position = _arg3;
- }
- override public function clone():Event{
- return (new TweenEvent(this.type, this.time, this.position, this.bubbles, this.cancelable));
- }
- }
- }//package fl.transitions
- package fl.transitions {
- import flash.display.*;
- import flash.events.*;
- import flash.utils.*;
- public class Tween extends EventDispatcher {
- protected static var _mc:MovieClip = new MovieClip();
- public var isPlaying:Boolean = false;
- public var obj:Object = null;
- public var prop:String = "";
- public var func:Function;
- public var begin:Number = NaN;
- public var change:Number = NaN;
- public var useSeconds:Boolean = false;
- public var prevTime:Number = NaN;
- public var prevPos:Number = NaN;
- public var looping:Boolean = false;
- private var _duration:Number = NaN;
- private var _time:Number = NaN;
- private var _fps:Number = NaN;
- private var _position:Number = NaN;
- private var _startTime:Number = NaN;
- private var _intervalID:uint = 0;
- private var _finish:Number = NaN;
- private var _timer:Timer = null;
- public function Tween(_arg1:Object, _arg2:String, _arg3:Function, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Boolean=false){
- this.func = function (_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
- return ((((_arg3 * _arg1) / _arg4) + _arg2));
- };
- super();
- if (!arguments.length){
- return;
- };
- this.obj = _arg1;
- this.prop = _arg2;
- this.begin = _arg4;
- this.position = _arg4;
- this.duration = _arg6;
- this.useSeconds = _arg7;
- if ((_arg3 is Function)){
- this.func = _arg3;
- };
- this.finish = _arg5;
- this._timer = new Timer(100);
- this.start();
- }
- public function get time():Number{
- return (this._time);
- }
- public function set time(_arg1:Number):void{
- this.prevTime = this._time;
- if (_arg1 > this.duration){
- if (this.looping){
- this.rewind((_arg1 - this._duration));
- this.update();
- this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_LOOP, this._time, this._position));
- } else {
- if (this.useSeconds){
- this._time = this._duration;
- this.update();
- };
- this.stop();
- this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_FINISH, this._time, this._position));
- };
- } else {
- if (_arg1 < 0){
- this.rewind();
- this.update();
- } else {
- this._time = _arg1;
- this.update();
- };
- };
- }
- public function get duration():Number{
- return (this._duration);
- }
- public function set duration(_arg1:Number):void{
- this._duration = ((_arg1)<=0) ? Infinity : _arg1;
- }
- public function get FPS():Number{
- return (this._fps);
- }
- public function set FPS(_arg1:Number):void{
- var _local2:Boolean = this.isPlaying;
- this.stopEnterFrame();
- this._fps = _arg1;
- if (_local2){
- this.startEnterFrame();
- };
- }
- public function get position():Number{
- return (this.getPosition(this._time));
- }
- public function set position(_arg1:Number):void{
- this.setPosition(_arg1);
- }
- public function getPosition(_arg1:Number=NaN):Number{
- if (isNaN(_arg1)){
- _arg1 = this._time;
- };
- return (this.func(_arg1, this.begin, this.change, this._duration));
- }
- public function setPosition(_arg1:Number):void{
- this.prevPos = this._position;
- if (this.prop.length){
- this.obj[this.prop] = (this._position = _arg1);
- };
- this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_CHANGE, this._time, this._position));
- }
- public function get finish():Number{
- return ((this.begin + this.change));
- }
- public function set finish(_arg1:Number):void{
- this.change = (_arg1 - this.begin);
- }
- public function continueTo(_arg1:Number, _arg2:Number):void{
- this.begin = this.position;
- this.finish = _arg1;
- if (!isNaN(_arg2)){
- this.duration = _arg2;
- };
- this.start();
- }
- public function yoyo():void{
- this.continueTo(this.begin, this.time);
- }
- protected function startEnterFrame():void{
- var _local1:Number;
- if (isNaN(this._fps)){
- _mc.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, false, 0, true);
- } else {
- _local1 = (1000 / this._fps);
- this._timer.delay = _local1;
- this._timer.addEventListener(TimerEvent.TIMER, this.timerHandler, false, 0, true);
- this._timer.start();
- };
- this.isPlaying = true;
- }
- protected function stopEnterFrame():void{
- if (isNaN(this._fps)){
- _mc.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
- } else {
- this._timer.stop();
- };
- this.isPlaying = false;
- }
- public function start():void{
- this.rewind();
- this.startEnterFrame();
- this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_START, this._time, this._position));
- }
- public function stop():void{
- this.stopEnterFrame();
- this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_STOP, this._time, this._position));
- }
- public function resume():void{
- this.fixTime();
- this.startEnterFrame();
- this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_RESUME, this._time, this._position));
- }
- public function rewind(_arg1:Number=0):void{
- this._time = _arg1;
- this.fixTime();
- this.update();
- }
- public function fforward():void{
- this.time = this._duration;
- this.fixTime();
- }
- public function nextFrame():void{
- if (this.useSeconds){
- this.time = ((getTimer() - this._startTime) / 1000);
- } else {
- this.time = (this._time + 1);
- };
- }
- protected function onEnterFrame(_arg1:Event):void{
- this.nextFrame();
- }
- protected function timerHandler(_arg1:TimerEvent):void{
- this.nextFrame();
- _arg1.updateAfterEvent();
- }
- public function prevFrame():void{
- if (!this.useSeconds){
- this.time = (this._time - 1);
- };
- }
- private function fixTime():void{
- if (this.useSeconds){
- this._startTime = (getTimer() - (this._time * 1000));
- };
- }
- private function update():void{
- this.setPosition(this.getPosition(this._time));
- }
- }
- }//package fl.transitions
- package fl.controls {
- import flash.display.*;
- import flash.events.*;
- import fl.core.*;
- import fl.managers.*;
- import flash.text.*;
- import fl.events.*;
- import flash.ui.*;
- public class LabelButton extends BaseButton implements IFocusManagerComponent {
- private static var defaultStyles:Object = {
- icon:null,
- upIcon:null,
- downIcon:null,
- overIcon:null,
- disabledIcon:null,
- selectedDisabledIcon:null,
- selectedUpIcon:null,
- selectedDownIcon:null,
- selectedOverIcon:null,
- textFormat:null,
- disabledTextFormat:null,
- textPadding:5,
- embedFonts:false
- };
- public static var createAccessibilityImplementation:Function;
- protected var _labelPlacement:String = "right";
- protected var _toggle:Boolean = false;
- protected var icon:DisplayObject;
- protected var oldMouseState:String;
- protected var mode:String = "center";
- public var textField:TextField;
- protected var _label:String = "Label";
- public function LabelButton(){
- _labelPlacement = ButtonLabelPlacement.RIGHT;
- _toggle = false;
- _label = "Label";
- mode = "center";
- super();
- }
- public static function getStyleDefinition():Object{
- return (mergeStyles(defaultStyles, BaseButton.getStyleDefinition()));
- }
- protected function toggleSelected(_arg1:MouseEvent):void{
- selected = !(selected);
- dispatchEvent(new Event(Event.CHANGE, true));
- }
- public function get labelPlacement():String{
- return (_labelPlacement);
- }
- override protected function keyDownHandler(_arg1:KeyboardEvent):void{
- if (!enabled){
- return;
- };
- if (_arg1.keyCode == Keyboard.SPACE){
- if (oldMouseState == null){
- oldMouseState = mouseState;
- };
- setMouseState("down");
- startPress();
- };
- }
- protected function setEmbedFont(){
- var _local1:Object;
- _local1 = getStyleValue("embedFonts");
- if (_local1 != null){
- textField.embedFonts = _local1;
- };
- }
- override protected function keyUpHandler(_arg1:KeyboardEvent):void{
- if (!enabled){
- return;
- };
- if (_arg1.keyCode == Keyboard.SPACE){
- setMouseState(oldMouseState);
- oldMouseState = null;
- endPress();
- dispatchEvent(new MouseEvent(MouseEvent.CLICK));
- };
- }
- override public function get selected():Boolean{
- return (((_toggle) ? _selected : false));
- }
- public function set labelPlacement(_arg1:String):void{
- _labelPlacement = _arg1;
- invalidate(InvalidationType.SIZE);
- }
- public function set toggle(_arg1:Boolean):void{
- if (((!(_arg1)) && (super.selected))){
- selected = false;
- };
- _toggle = _arg1;
- if (_toggle){
- addEventListener(MouseEvent.CLICK, toggleSelected, false, 0, true);
- } else {
- removeEventListener(MouseEvent.CLICK, toggleSelected);
- };
- invalidate(InvalidationType.STATE);
- }
- public function get label():String{
- return (_label);
- }
- override public function set selected(_arg1:Boolean):void{
- _selected = _arg1;
- if (_toggle){
- invalidate(InvalidationType.STATE);
- };
- }
- override protected function draw():void{
- if (textField.text != _label){
- label = _label;
- };
- if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
- drawBackground();
- drawIcon();
- drawTextFormat();
- invalidate(InvalidationType.SIZE, false);
- };
- if (isInvalid(InvalidationType.SIZE)){
- drawLayout();
- };
- if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
- if (((isFocused) && (focusManager.showFocusIndicator))){
- drawFocus(true);
- };
- };
- validate();
- }
- public function get toggle():Boolean{
- return (_toggle);
- }
- override protected function configUI():void{
- super.configUI();
- textField = new TextField();
- textField.type = TextFieldType.DYNAMIC;
- textField.selectable = false;
- addChild(textField);
- }
- override protected function drawLayout():void{
- var _local1:Number;
- var _local2:String;
- var _local3:Number;
- var _local4:Number;
- var _local5:Number;
- var _local6:Number;
- var _local7:Number;
- var _local8:Number;
- _local1 = Number(getStyleValue("textPadding"));
- _local2 = (((((icon == null)) && ((mode == "center")))) ? ButtonLabelPlacement.TOP : _labelPlacement);
- textField.height = (textField.textHeight + 4);
- _local3 = (textField.textWidth + 4);
- _local4 = (textField.textHeight + 4);
- _local5 = ((icon)==null) ? 0 : (icon.width + _local1);
- _local6 = ((icon)==null) ? 0 : (icon.height + _local1);
- textField.visible = (label.length > 0);
- if (icon != null){
- icon.x = Math.round(((width - icon.width) / 2));
- icon.y = Math.round(((height - icon.height) / 2));
- };
- if (textField.visible == false){
- textField.width = 0;
- textField.height = 0;
- } else {
- if ((((_local2 == ButtonLabelPlacement.BOTTOM)) || ((_local2 == ButtonLabelPlacement.TOP)))){
- _local7 = Math.max(0, Math.min(_local3, (width - (2 * _local1))));
- if ((height - 2) > _local4){
- _local8 = _local4;
- } else {
- _local8 = (height - 2);
- };
- _local3 = _local7;
- textField.width = _local3;
- _local4 = _local8;
- textField.height = _local4;
- textField.x = Math.round(((width - _local3) / 2));
- textField.y = Math.round(((((height - textField.height) - _local6) / 2) + ((_local2)==ButtonLabelPlacement.BOTTOM) ? _local6 : 0));
- if (icon != null){
- icon.y = Math.round(((_local2)==ButtonLabelPlacement.BOTTOM) ? (textField.y - _local6) : ((textField.y + textField.height) + _local1));
- };
- } else {
- _local7 = Math.max(0, Math.min(_local3, ((width - _local5) - (2 * _local1))));
- _local3 = _local7;
- textField.width = _local3;
- textField.x = Math.round(((((width - _local3) - _local5) / 2) + ((_local2)!=ButtonLabelPlacement.LEFT) ? _local5 : 0));
- textField.y = Math.round(((height - textField.height) / 2));
- if (icon != null){
- icon.x = Math.round(((_local2)!=ButtonLabelPlacement.LEFT) ? (textField.x - _local5) : ((textField.x + _local3) + _local1));
- };
- };
- };
- super.drawLayout();
- }
- override protected function initializeAccessibility():void{
- if (LabelButton.createAccessibilityImplementation != null){
- LabelButton.createAccessibilityImplementation(this);
- };
- }
- protected function drawIcon():void{
- var _local1:DisplayObject;
- var _local2:String;
- var _local3:Object;
- _local1 = icon;
- _local2 = ((enabled) ? mouseState : "disabled");
- if (selected){
- _local2 = (("selected" + _local2.substr(0, 1).toUpperCase()) + _local2.substr(1));
- };
- _local2 = (_local2 + "Icon");
- _local3 = getStyleValue(_local2);
- if (_local3 == null){
- _local3 = getStyleValue("icon");
- };
- if (_local3 != null){
- icon = getDisplayObjectInstance(_local3);
- };
- if (icon != null){
- addChildAt(icon, 1);
- };
- if (((!((_local1 == null))) && (!((_local1 == icon))))){
- removeChild(_local1);
- };
- }
- public function set label(_arg1:String):void{
- _label = _arg1;
- if (textField.text != _label){
- textField.text = _label;
- dispatchEvent(new ComponentEvent(ComponentEvent.LABEL_CHANGE));
- };
- invalidate(InvalidationType.SIZE);
- invalidate(InvalidationType.STYLES);
- }
- protected function drawTextFormat():void{
- var _local1:Object;
- var _local2:TextFormat;
- var _local3:TextFormat;
- _local1 = UIComponent.getStyleDefinition();
- _local2 = ((enabled) ? (_local1.defaultTextFormat as TextFormat) : (_local1.defaultDisabledTextFormat as TextFormat));
- textField.setTextFormat(_local2);
- _local3 = (getStyleValue(((enabled) ? "textFormat" : "disabledTextFormat")) as TextFormat);
- if (_local3 != null){
- textField.setTextFormat(_local3);
- } else {
- _local3 = _local2;
- };
- textField.defaultTextFormat = _local3;
- setEmbedFont();
- }
- }
- }//package fl.controls
- package fl.controls {
- import flash.display.*;
- import flash.events.*;
- import fl.core.*;
- import flash.utils.*;
- import fl.events.*;
- public class BaseButton extends UIComponent {
- private static var defaultStyles:Object = {
- upSkin:"Button_upSkin",
- downSkin:"Button_downSkin",
- overSkin:"Button_overSkin",
- disabledSkin:"Button_disabledSkin",
- selectedDisabledSkin:"Button_selectedDisabledSkin",
- selectedUpSkin:"Button_selectedUpSkin",
- selectedDownSkin:"Button_selectedDownSkin",
- selectedOverSkin:"Button_selectedOverSkin",
- focusRectSkin:null,
- focusRectPadding:null,
- repeatDelay:500,
- repeatInterval:35
- };
- protected var _selected:Boolean = false;
- private var unlockedMouseState:String;
- protected var pressTimer:Timer;
- protected var mouseState:String;
- protected var background:DisplayObject;
- private var _mouseStateLocked:Boolean = false;
- protected var _autoRepeat:Boolean = false;
- public function BaseButton(){
- _selected = false;
- _autoRepeat = false;
- _mouseStateLocked = false;
- super();
- buttonMode = true;
- mouseChildren = false;
- useHandCursor = false;
- setupMouseEvents();
- setMouseState("up");
- pressTimer = new Timer(1, 0);
- pressTimer.addEventListener(TimerEvent.TIMER, buttonDown, false, 0, true);
- }
- public static function getStyleDefinition():Object{
- return (defaultStyles);
- }
- protected function endPress():void{
- pressTimer.reset();
- }
- public function set mouseStateLocked(_arg1:Boolean):void{
- _mouseStateLocked = _arg1;
- if (_arg1 == false){
- setMouseState(unlockedMouseState);
- } else {
- unlockedMouseState = mouseState;
- };
- }
- public function get autoRepeat():Boolean{
- return (_autoRepeat);
- }
- public function set autoRepeat(_arg1:Boolean):void{
- _autoRepeat = _arg1;
- }
- override public function set enabled(_arg1:Boolean):void{
- super.enabled = _arg1;
- mouseEnabled = _arg1;
- }
- public function get selected():Boolean{
- return (_selected);
- }
- protected function mouseEventHandler(_arg1:MouseEvent):void{
- if (_arg1.type == MouseEvent.MOUSE_DOWN){
- setMouseState("down");
- startPress();
- } else {
- if ((((_arg1.type == MouseEvent.ROLL_OVER)) || ((_arg1.type == MouseEvent.MOUSE_UP)))){
- setMouseState("over");
- endPress();
- } else {
- if (_arg1.type == MouseEvent.ROLL_OUT){
- setMouseState("up");
- endPress();
- };
- };
- };
- }
- public function setMouseState(_arg1:String):void{
- if (_mouseStateLocked){
- unlockedMouseState = _arg1;
- return;
- };
- if (mouseState == _arg1){
- return;
- };
- mouseState = _arg1;
- invalidate(InvalidationType.STATE);
- }
- protected function startPress():void{
- if (_autoRepeat){
- pressTimer.delay = Number(getStyleValue("repeatDelay"));
- pressTimer.start();
- };
- dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
- }
- protected function buttonDown(_arg1:TimerEvent):void{
- if (!_autoRepeat){
- endPress();
- return;
- };
- if (pressTimer.currentCount == 1){
- pressTimer.delay = Number(getStyleValue("repeatInterval"));
- };
- dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
- }
- public function set selected(_arg1:Boolean):void{
- if (_selected == _arg1){
- return;
- };
- _selected = _arg1;
- invalidate(InvalidationType.STATE);
- }
- override public function get enabled():Boolean{
- return (super.enabled);
- }
- override protected function draw():void{
- if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
- drawBackground();
- invalidate(InvalidationType.SIZE, false);
- };
- if (isInvalid(InvalidationType.SIZE)){
- drawLayout();
- };
- super.draw();
- }
- protected function setupMouseEvents():void{
- addEventListener(MouseEvent.ROLL_OVER, mouseEventHandler, false, 0, true);
- addEventListener(MouseEvent.MOUSE_DOWN, mouseEventHandler, false, 0, true);
- addEventListener(MouseEvent.MOUSE_UP, mouseEventHandler, false, 0, true);
- addEventListener(MouseEvent.ROLL_OUT, mouseEventHandler, false, 0, true);
- }
- protected function drawLayout():void{
- background.width = width;
- background.height = height;
- }
- protected function drawBackground():void{
- var _local1:String;
- var _local2:DisplayObject;
- _local1 = ((enabled) ? mouseState : "disabled");
- if (selected){
- _local1 = (("selected" + _local1.substr(0, 1).toUpperCase()) + _local1.substr(1));
- };
- _local1 = (_local1 + "Skin");
- _local2 = background;
- background = getDisplayObjectInstance(getStyleValue(_local1));
- addChildAt(background, 0);
- if (((!((_local2 == null))) && (!((_local2 == background))))){
- removeChild(_local2);
- };
- }
- }
- }//package fl.controls
- package fl.controls {
- public class ButtonLabelPlacement {
- public static const TOP:String = "top";
- public static const LEFT:String = "left";
- public static const BOTTOM:String = "bottom";
- public static const RIGHT:String = "right";
- }
- }//package fl.controls
- package fl.controls {
- import flash.display.*;
- import fl.core.*;
- import fl.managers.*;
- public class Button extends LabelButton implements IFocusManagerComponent {
- private static var defaultStyles:Object = {
- emphasizedSkin:"Button_emphasizedSkin",
- emphasizedPadding:2
- };
- public static var createAccessibilityImplementation:Function;
- protected var emphasizedBorder:DisplayObject;
- protected var _emphasized:Boolean = false;
- public function Button(){
- _emphasized = false;
- super();
- }
- public static function getStyleDefinition():Object{
- return (UIComponent.mergeStyles(LabelButton.getStyleDefinition(), defaultStyles));
- }
- override public function drawFocus(_arg1:Boolean):void{
- var _local2:Number;
- var _local3:*;
- super.drawFocus(_arg1);
- if (_arg1){
- _local2 = Number(getStyleValue("emphasizedPadding"));
- if ((((_local2 < 0)) || (!(_emphasized)))){
- _local2 = 0;
- };
- _local3 = getStyleValue("focusRectPadding");
- _local3 = ((_local3)==null) ? 2 : _local3;
- _local3 = (_local3 + _local2);
- uiFocusRect.x = -(_local3);
- uiFocusRect.y = -(_local3);
- uiFocusRect.width = (width + (_local3 * 2));
- uiFocusRect.height = (height + (_local3 * 2));
- };
- }
- public function set emphasized(_arg1:Boolean):void{
- _emphasized = _arg1;
- invalidate(InvalidationType.STYLES);
- }
- override protected function draw():void{
- if (((isInvalid(InvalidationType.STYLES)) || (isInvalid(InvalidationType.SIZE)))){
- drawEmphasized();
- };
- super.draw();
- if (emphasizedBorder != null){
- setChildIndex(emphasizedBorder, (numChildren - 1));
- };
- }
- public function get emphasized():Boolean{
- return (_emphasized);
- }
- override protected function initializeAccessibility():void{
- if (Button.createAccessibilityImplementation != null){
- Button.createAccessibilityImplementation(this);
- };
- }
- protected function drawEmphasized():void{
- var _local1:Object;
- var _local2:Number;
- if (emphasizedBorder != null){
- removeChild(emphasizedBorder);
- };
- emphasizedBorder = null;
- if (!_emphasized){
- return;
- };
- _local1 = getStyleValue("emphasizedSkin");
- if (_local1 != null){
- emphasizedBorder = getDisplayObjectInstance(_local1);
- };
- if (emphasizedBorder != null){
- addChildAt(emphasizedBorder, 0);
- _local2 = Number(getStyleValue("emphasizedPadding"));
- emphasizedBorder.x = (emphasizedBorder.y = -(_local2));
- emphasizedBorder.width = (width + (_local2 * 2));
- emphasizedBorder.height = (height + (_local2 * 2));
- };
- }
- }
- }//package fl.controls
- package {
- import flash.display.*;
- public dynamic class QuickPlayerBackground extends MovieClip {
- }
- }//package
- package {
- import flash.display.*;
- public dynamic class GrayStrip extends MovieClip {
- }
- }//package
- package {
- import flash.text.*;
- public dynamic class Font2 extends Font {
- }
- }//package
- package {
- import flash.display.*;
- public dynamic class TopBottomShadow extends MovieClip {
- }
- }//package
- package {
- import flash.display.*;
- public dynamic class ImageBackground extends MovieClip {
- public function ImageBackground(){
- addFrameScript(0, this.frame1);
- }
- function frame1(){
- stop();
- }
- }
- }//package
- package {
- import flash.display.*;
- public dynamic class image_carousel_item extends MovieClip {
- }
- }//package
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import flash.text.*;
- public class MovieShowTimeButton extends MovieClip {
- public var _movieshowtimeHover:MovieClip;
- public var _title:TextField;
- public function MovieShowTimeButton():void{
- super();
- mouseChildren = false;
- this.buttonMode = true;
- this.useHandCursor = true;
- this._movieshowtimeHover.visible = false;
- this.addEventListener(MouseEvent.MOUSE_OVER, this.onHover);
- this.addEventListener(MouseEvent.MOUSE_OUT, this.onOut);
- }
- private function onHover(e:Event):void{
- this._movieshowtimeHover.visible = true;
- }
- private function onOut(e:Event):void{
- this._movieshowtimeHover.visible = false;
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import fl.transitions.*;
- import fl.transitions.easing.*;
- public class QuickPlayButton extends MovieClip {
- public var hover_show:MovieClip;
- public var hover_hide:MovieClip;
- private var _onShow:Function;
- private var _onHide:Function;
- private var _isClicked:Boolean = false;
- private var _tween:Tween;
- public function QuickPlayButton(callbacks:Array){
- super();
- addFrameScript(0, this.frame1, 1, this.frame2);
- mouseChildren = false;
- this._onShow = callbacks[0];
- this._onHide = callbacks[1];
- this[("hover_" + this.currentLabel)].alpha = 0;
- this.addEventListener(MouseEvent.MOUSE_DOWN, this.onClick);
- this.addEventListener(MouseEvent.MOUSE_OVER, this.onOver);
- this.addEventListener(MouseEvent.MOUSE_OUT, this.onOut);
- }
- public function reset(){
- this.gotoAndStop("show");
- this.hover_show.alpha = 0;
- this.hover_show.visible = true;
- }
- public function onClick(event){
- if (this._isClicked == false){
- this._isClicked = true;
- root.dispatchEvent(new Event("stopAutoScroll"));
- };
- if (this.currentLabel == "show"){
- this.gotoAndStop("hide");
- this.hover_hide.visible = true;
- this._onShow();
- } else {
- this.gotoAndStop("show");
- this.hover_show.visible = true;
- this._onHide();
- };
- }
- private function onOver(event:MouseEvent){
- if (((this._tween) && (this._tween.isPlaying))){
- this._tween.fforward();
- };
- var hover:* = this[("hover_" + this.currentLabel)];
- hover.visible = true;
- this._tween = new Tween(hover, "alpha", Strong.easeOut, hover.alpha, 1, 14);
- }
- private function onOut(event:MouseEvent){
- if (((this._tween) && (this._tween.isPlaying))){
- this._tween.fforward();
- };
- var hover:* = this[("hover_" + this.currentLabel)];
- this._tween = new Tween(hover, "alpha", Strong.easeOut, hover.alpha, 0, 14);
- }
- function frame1(){
- stop();
- }
- function frame2(){
- stop();
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import fl.transitions.*;
- import flash.utils.*;
- import fl.motion.easing.*;
- public class AS3QuickPlayer extends Sprite {
- private static var __instance:AS3QuickPlayer;
- private static var __playerHost:String;
- private static var __playerEnv:String;
- private var _player:AS3VideoContainer;
- private var _background:QuickPlayerBackground;
- private var _playerContainer:Sprite;
- private var _playerMask:Sprite;
- private var _closeButton:CloseButton;
- private var _watchInHiResButton:WatchInHiResButton;
- private var _style:Object;
- private var _eid:String;
- private var _playerState:String = "none";
- private var _init:Boolean = false;
- private var _tweens:Array;
- private var _showTween:Tween;
- private var _timeoutId:Number = -1;
- public function AS3QuickPlayer(style:Object, stageWidth:Number, watchHiResCall:Function, eid:String, container:Sprite){
- this._tweens = new Array();
- super();
- this._style = style;
- this._eid = eid;
- this._playerContainer = container;
- this._background = new QuickPlayerBackground();
- this._watchInHiResButton = new WatchInHiResButton(watchHiResCall);
- this._watchInHiResButton.buttonMode = true;
- this._closeButton = new CloseButton();
- this._closeButton.buttonMode = true;
- mouseChildren = true;
- this._playerMask = new Sprite();
- this._playerMask.graphics.beginFill(2298401, 0.5);
- this._playerMask.graphics.drawRect(0, 0, (this._style.QuickPlayer.playerWidth + 1.2), (this._style.QuickPlayer.playerHeight + 1.2));
- this._playerMask.graphics.endFill();
- this._player = new AS3VideoContainer(this._style, this._eid, __playerHost, __playerEnv);
- this._player.addEventListener("onInitializeSucceeded", this.onInitSucc);
- this._player.mask = this._playerMask;
- this.addChild(this._playerMask);
- this.addChild(this._background);
- this.addChild(this._closeButton);
- this.addChild(this._player);
- this.addChild(this._watchInHiResButton);
- this.layoutObjects();
- this.attachEvents();
- }
- public static function getInstance(style:Object, stageWidth:Number, watchHiResCall:Function, eid:String, container:Sprite){
- if (!__instance){
- __instance = new AS3QuickPlayer(style, stageWidth, watchHiResCall, eid, container);
- };
- __instance.update(watchHiResCall, eid, container);
- return (__instance);
- }
- public static function get hasInstance():Boolean{
- return (!((__instance == null)));
- }
- public static function set playerHost(url:String){
- __playerHost = url;
- }
- public static function set playerEnv(env:String){
- __playerEnv = env;
- }
- public function update(watchHiResCall:Function, eid:String, container:Sprite){
- this._playerState = "none";
- if (this._eid != eid){
- this._eid = eid;
- };
- if (null == watchHiResCall){
- this._watchInHiResButton.visible = false;
- } else {
- this._watchInHiResButton.visible = true;
- this._watchInHiResButton.callbacks = watchHiResCall;
- };
- this._playerContainer = container;
- this.layoutObjects();
- }
- public function layoutObjects(){
- this._background.width = this._style.ImageItem.width;
- this._closeButton.x = (this._background.width - this._style.QuickPlayer.closeBtnRightMargin);
- this._closeButton.y = this._style.QuickPlayer.closeBtnTopMargin;
- this._closeButton.light_mc.visible = false;
- this._player.x = ((this._style.ImageItem.width - this._style.QuickPlayer.playerWidth) / 2);
- this._playerMask.x = (this._player.x - 0.2);
- this._player.y = ((-(this._style.QuickPlayer.playerHeight) + this._style.QuickPlayer.playerMarginTop) + this._style.QuickPlayer.playerHeight);
- this._playerMask.y = (this._player.y - 0.2);
- this._watchInHiResButton.x = (this._style.ImageItem.width / 2);
- this._watchInHiResButton.y = (this._style.ImageItem.height - (this._style.QuickPlayer.playerMarginBottom / 2));
- }
- private function attachEvents(){
- this._closeButton.mouseChildren = false;
- this._closeButton.addEventListener(MouseEvent.ROLL_OVER, function (e){
- e.target.light_mc.visible = true;
- });
- this._closeButton.addEventListener(MouseEvent.ROLL_OUT, function (e){
- e.target.light_mc.visible = false;
- });
- this._closeButton.addEventListener(MouseEvent.MOUSE_DOWN, function (e){
- hide(false);
- __instance.dispatchEvent(new Event("closeQuickPlayer"));
- });
- }
- public function pause(){
- this._player.pausePlayer();
- }
- public function play(){
- this._player.playPlayer();
- }
- public function stop(){
- this._player.stopPlayer();
- (this._playerState == "none");
- }
- public function load(eid:String, manual:Boolean){
- this._player.load(eid);
- }
- public function get eid(){
- return (this._eid);
- }
- public function show(hardset:Boolean){
- var hardset:* = hardset;
- this.stopTweens();
- trace(((("SHOW" + hardset) + ":") + this._playerContainer));
- if (!hardset){
- if ((((this._playerState == "none")) && (this._init))){
- };
- this._showTween = new Tween(this._playerContainer, "scaleX", Quartic.easeOut, this._playerContainer.scaleX, 1, 10);
- this._showTween.addEventListener(TweenEvent.MOTION_STOP, function (e){
- if (_timeoutId != -1){
- clearTimeout(_timeoutId);
- _timeoutId = -1;
- };
- });
- this._showTween.addEventListener(TweenEvent.MOTION_FINISH, function (e){
- if (_playerState == "none"){
- _playerState = "playing";
- load(_eid, false);
- } else {
- play();
- };
- });
- this.addTween(this._showTween);
- this.addTween(new Tween(this._playerContainer, "scaleY", Quartic.easeOut, this._playerContainer.scaleY, 1, 10));
- this.addTween(new Tween(this._playerContainer, "alpha", Quartic.easeOut, this.alpha, 1, 10));
- } else {
- var _local3 = this._playerContainer;
- with (_local3) {
- scaleX = 1;
- scaleY = 1;
- alpha = 1;
- };
- };
- }
- public function hide(hardset:Boolean){
- var hardset:* = hardset;
- this.stopTweens();
- this.pause();
- trace(((("HIDE" + hardset) + ":") + this._playerContainer));
- if (!hardset){
- this.addTween(new Tween(this._playerContainer, "scaleX", Quartic.easeOut, this._playerContainer.scaleX, 0, 10));
- this.addTween(new Tween(this._playerContainer, "scaleY", Quartic.easeOut, this._playerContainer.scaleY, 0, 10));
- this.addTween(new Tween(this._playerContainer, "alpha", Quartic.easeOut, this._playerContainer.alpha, 0, 10));
- } else {
- var _local3 = this._playerContainer;
- with (_local3) {
- scaleX = 0;
- scaleY = 0;
- alpha = 0;
- };
- };
- }
- private function stopTweens():void{
- if (this._tweens == null){
- return;
- };
- var i:* = 0;
- while (i < this._tweens.length) {
- if (this._tweens[i] != null){
- this._tweens[i].stop();
- this._tweens[i] = null;
- };
- i++;
- };
- this._tweens = null;
- }
- private function addTween(tween:Tween):void{
- if (this._tweens == null){
- this._tweens = new Array();
- };
- this._tweens.push(tween);
- }
- private function get available(){
- if (((this._playerContainer) && (this._eid))){
- return (true);
- };
- return (false);
- }
- private function onInitSucc(e:Event){
- this._init = true;
- this._playerState = "playing";
- this._player.removeEventListener("onInitializeSucceeded", this.onInitSucc);
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import flash.net.*;
- import fl.transitions.*;
- import flash.utils.*;
- import com.hulu.masthead.utils.*;
- import fl.motion.easing.*;
- import flash.text.*;
- public class MoreBoard extends Sprite {
- public var _moreBackground:ImageBackground;
- public var _caption:TextField;
- public var _btnHideMore:HideMoreButton;
- private var _logoImage:Sprite;
- private var _description:String;
- private var _logoUrl:String;
- private var _style:Object;
- public var _fadeInTween:Tween;
- public var defaultY:Number;
- public function MoreBoard(style:Object, description:String, logoUrl:String){
- super();
- buttonMode = false;
- this.visible = false;
- this._style = style;
- this._description = ((description) || (""));
- this._logoUrl = ((logoUrl) || (""));
- this._moreBackground.mouseChildren = false;
- this.createObjects();
- this.attachEvents();
- }
- private function createObjects(){
- this._caption.autoSize = "left";
- this._caption.setTextFormat(new TextFormat(null, this._style.DetailsOverlay.captionFontSize, null, true));
- this._caption.text = this._description;
- this._caption.cacheAsBitmap = true;
- this._logoImage = new Sprite();
- addChild(this._logoImage);
- if (!this._logoUrl){
- this.layoutObjects((this._btnHideMore.height + this._style.DetailsOverlay.logoTopMargin));
- } else {
- this._logoImage.addChild(Utility.loadImage(this._logoUrl, this.loadSucceed, this.loadError));
- };
- }
- private function attachEvents(){
- var self:* = this;
- this._btnHideMore.onClick = function (){
- slideOut(true);
- };
- }
- private function loadSucceed(event:Event){
- this._logoImage.x = ((this._style.DetailsOverlay.borderWidth - this._logoImage.width) / 2);
- this._logoImage.y = (this._btnHideMore.height + this._style.DetailsOverlay.logoTopMargin);
- this.layoutObjects(((this._logoImage.y + this._logoImage.height) + this._style.DetailsOverlay.logoHeaderMargin));
- }
- private function loadError(event:IOErrorEvent){
- this.layoutObjects((this._btnHideMore.height + this._style.DetailsOverlay.logoTopMargin));
- }
- private function layoutObjects(ystart){
- this._caption.y = (ystart + this._style.DetailsOverlay.headerCaptionMargin);
- }
- public function slideIn(isGradully:Boolean){
- var isGradully:* = isGradully;
- if (isGradully){
- this._fadeInTween = new Tween(this, "y", Quartic.easeOut, y, this.defaultY, 1, true);
- setTimeout(function (){
- _caption.visible = false;
- _caption.visible = true;
- }, 24);
- } else {
- this.y = this.defaultY;
- };
- }
- public function slideOut(isGradully:Boolean){
- if (isGradully){
- this._fadeInTween = new Tween(this, "y", Quartic.easeOut, y, (this.defaultY + this._style.ImageItem.height), 0.8, true);
- } else {
- this.y = (this.defaultY + this._style.ImageItem.height);
- };
- }
- public function turnLight(){
- }
- public function turnDark(){
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- public class SliderControl extends Sprite {
- protected var _controller:Object;
- protected var _style:Object;
- protected var _stage:Sprite;
- protected var _currentPage:Number = 0;
- protected var _totalPages:Number = 10;
- protected var _stageWidth:Number;
- public function SliderControl(controller:Object, stage:Sprite){
- super();
- this._controller = controller;
- this._stage = stage;
- this.createObjects();
- this.layoutObjects();
- this.attachEvents();
- }
- public function createObjects(){
- this._style = this._controller.style;
- this._totalPages = this._controller.totalPages;
- }
- protected function layoutObjects(){
- this._stageWidth = this._controller.stageWidth;
- }
- protected function attachEvents(){
- }
- public function enable(){
- this.createSliders();
- this.attachEvents();
- }
- public function disable(){
- }
- protected function createSliders(){
- }
- protected function switchPage(event:MouseEvent){
- }
- protected function endArrowPress(event:MouseEvent){
- }
- protected function over(event:MouseEvent){
- }
- protected function out(event:MouseEvent){
- }
- protected function onResize(event:Event){
- this.layoutObjects();
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import flash.net.*;
- import fl.transitions.*;
- import flash.system.*;
- import com.hulu.masthead.utils.*;
- import fl.motion.easing.*;
- import com.hulu.masthead.controller.*;
- public class MovieShowTimeContainer extends Sprite {
- public static var playerenv:String;
- private const swfPath:String = "/movieshowtime.swf";
- private var _movieShowTimeObj:Object;
- private var _movieShowTimeLdr:Loader;
- private var _data:String = "";
- private var _instance:MovieShowTimeContainer;
- private var _bg:Sprite;
- private var _mask:Sprite;
- private var _zipcodeBeacon:Function;
- private var _buyticketBeacon:Function;
- private var _controller;
- private var _loadingAni:LoadingImage;
- private var _style:Object;
- private var _showTween:Tween;
- private var _hideTween:Tween;
- public function MovieShowTimeContainer(zipcodeBeacon:Function, buyTicketBeacon:Function, con):void{
- super();
- this._controller = con;
- this._style = this._controller.style;
- this._zipcodeBeacon = zipcodeBeacon;
- this._buyticketBeacon = buyTicketBeacon;
- this._bg = new Sprite();
- this._bg.graphics.beginFill(0, 0.5);
- this._bg.graphics.drawRect(0, 0, this._style.ImageItem.width, this._style.ImageItem.height);
- this._bg.graphics.endFill();
- addChild(this._bg);
- this._mask = new Sprite();
- this._mask.graphics.beginFill(0xFF0000, 1);
- this._mask.graphics.drawRect(0, 0, this._style.ImageItem.width, this._style.ImageItem.height);
- this._mask.graphics.endFill();
- addChild(this._mask);
- this.mask = this._mask;
- this._loadingAni = new LoadingImage();
- addChild(this._loadingAni);
- this._loadingAni.clickArea.x = (-(this._controller.stageWidth) / 2);
- this._loadingAni.clickArea.y = (-(this._style.Carousel.height) / 2);
- this._loadingAni.clickArea.width = (this._controller.stageWidth - (this._style.Carousel.leftMargin * 2));
- this._loadingAni.clickArea.height = this._style.ImageItem.height;
- this._loadingAni.x = (this._bg.width / 2);
- this._loadingAni.y = (this._style.Carousel.height / 2);
- this._movieShowTimeLdr = new Loader();
- this._movieShowTimeLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, this.onComplete);
- this._movieShowTimeLdr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, this.onError);
- this._movieShowTimeLdr.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.onError);
- this._movieShowTimeLdr.load(new URLRequest(this.swfPath), new LoaderContext(true, new ApplicationDomain()));
- }
- public function showMST():void{
- if (!this._movieShowTimeObj){
- return;
- };
- if (((this._hideTween) && (this._hideTween.isPlaying))){
- this._hideTween.stop();
- this._hideTween = null;
- };
- this._bg.visible = true;
- new Tween(this._movieShowTimeObj, "alpha", Quartic.easeOut, this._movieShowTimeObj.alpha, 1, 10);
- this._showTween = new Tween(this._movieShowTimeObj, "y", Quartic.easeOut, this._movieShowTimeObj.y, 0, 10);
- this._showTween.addEventListener(TweenEvent.MOTION_FINISH, this.onFinishShow);
- }
- private function hideMST(e:Event=null):void{
- if (((this._showTween) && (this._showTween.isPlaying))){
- this._showTween.stop();
- this._showTween = null;
- };
- this._bg.visible = false;
- if (this._controller){
- (this._controller as HuluCarousel).switchNextAutomatic();
- };
- new Tween(this._movieShowTimeObj, "alpha", Quartic.easeOut, 1, 0, 10);
- this._hideTween = new Tween(this._movieShowTimeObj, "y", Quartic.easeOut, this._movieShowTimeObj.y, this._bg.height, 10);
- this._hideTween.addEventListener(TweenEvent.MOTION_FINISH, this.onFinishHide);
- }
- public function set data(v:String):void{
- var v:* = v;
- this._data = v;
- if (this._movieShowTimeObj){
- try {
- this._movieShowTimeObj.movieID = v;
- } catch(e) {
- trace(e);
- };
- };
- }
- private function onFinishShow(e:Event):void{
- if (!this._movieShowTimeObj){
- return;
- };
- this._movieShowTimeObj.alpha = 1;
- this._movieShowTimeObj.y = 0;
- this._showTween = null;
- }
- private function onFinishHide(e:Event):void{
- if (!this._movieShowTimeObj){
- return;
- };
- this._movieShowTimeObj.alpha = 0;
- this._movieShowTimeObj.y = this._bg.height;
- this._hideTween = null;
- }
- private function onComplete(e:Event=null):void{
- var e = e;
- this._loadingAni.visible = false;
- this._movieShowTimeObj = this._movieShowTimeLdr.content;
- try {
- this._movieShowTimeObj.playerenv = playerenv;
- this._movieShowTimeObj.addEventListener("CLICK_CLOSE", this.hideMST);
- if (this._data){
- this._movieShowTimeObj.movieID = this._data;
- };
- this._movieShowTimeObj.setBeaconCallBack(this._zipcodeBeacon, this._buyticketBeacon);
- addChild((this._movieShowTimeObj as DisplayObject));
- } catch(e) {
- trace("zError MovieShowTimeContainer->onComplete");
- };
- }
- private function onError(e:Event):void{
- this._loadingAni.visible = false;
- this._bg.visible = false;
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import fl.transitions.*;
- import fl.transitions.easing.*;
- public class WatchInHiResButton extends MovieClip {
- public var light_mc:MovieClip;
- private var _callbacks:Function;
- private var _tween:Tween;
- public function WatchInHiResButton(callbacks:Function){
- super();
- this.mouseChildren = false;
- this.light_mc.alpha = 0;
- this._callbacks = callbacks;
- this.addEventListener(MouseEvent.MOUSE_DOWN, this.onClicked);
- this.addEventListener(MouseEvent.MOUSE_OVER, this.onOver);
- this.addEventListener(MouseEvent.MOUSE_OUT, this.onOut);
- }
- public function set callbacks(val:Function){
- this._callbacks = val;
- }
- private function onClicked(e){
- if ((this._callbacks is Function)){
- this._callbacks();
- };
- }
- private function onOver(event:MouseEvent){
- if (this._tween){
- this._tween.fforward();
- };
- this._tween = new Tween(this.light_mc, "alpha", Strong.easeOut, this.light_mc.alpha, 1, 14);
- }
- private function onOut(event:MouseEvent){
- if (this._tween){
- this._tween.fforward();
- };
- this._tween = new Tween(this.light_mc, "alpha", Strong.easeOut, this.light_mc.alpha, 0, 14);
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import com.hulu.masthead.utils.*;
- import fl.motion.easing.*;
- public class HuluSliderControl extends SliderControl {
- static var BUTTONSCALE:Number = 170;
- protected var _leftArrow:LeftArrowButton;
- protected var _rightArrow:RightArrowButton;
- private var _jumpButtons:Array;
- private var _jumpButton:JumpButton;
- private var _jumpBtnMargin:Number;
- public function HuluSliderControl(controller:Object, stage:Sprite){
- this._jumpButtons = new Array();
- super(controller, stage);
- }
- private function createArrowButtons(){
- this._leftArrow = new LeftArrowButton();
- this._rightArrow = new RightArrowButton();
- addChild(this._leftArrow);
- addChild(this._rightArrow);
- var _local2 = this._leftArrow;
- with (_local2) {
- buttonMode = true;
- mouseChildren = false;
- graphics.beginFill(0, 0);
- graphics.drawRect((-(_style.SliderControl.buttonPaddingWidth) / 2), (-(_style.SliderControl.buttonPaddingHeight) / 2), _style.SliderControl.buttonPaddingWidth, _style.SliderControl.buttonPaddingHeight);
- graphics.endFill();
- };
- _local2 = this._rightArrow;
- with (_local2) {
- buttonMode = true;
- mouseChildren = false;
- graphics.beginFill(0, 0);
- graphics.drawRect((-(_style.SliderControl.buttonPaddingWidth) / 2), (-(_style.SliderControl.buttonPaddingHeight) / 2), _style.SliderControl.buttonPaddingWidth, _style.SliderControl.buttonPaddingHeight);
- graphics.endFill();
- };
- _local2 = this._leftArrow;
- with (_local2) {
- addEventListener(MouseEvent.MOUSE_DOWN, switchPage);
- addEventListener(MouseEvent.MOUSE_UP, endArrowPress);
- addEventListener(MouseEvent.ROLL_OVER, over);
- addEventListener(MouseEvent.ROLL_OUT, out);
- };
- _local2 = this._rightArrow;
- with (_local2) {
- addEventListener(MouseEvent.MOUSE_DOWN, switchPage);
- addEventListener(MouseEvent.MOUSE_UP, endArrowPress);
- addEventListener(MouseEvent.ROLL_OVER, over);
- addEventListener(MouseEvent.ROLL_OUT, out);
- };
- this._leftArrow.x = _style.SliderControl.buttonLeftMargin;
- this._rightArrow.x = (_stageWidth - _style.SliderControl.buttonLeftMargin);
- this._leftArrow.y = (this._rightArrow.y = _style.SliderControl.buttonHeaderMargin);
- }
- override protected function attachEvents(){
- super.attachEvents();
- _controller.stage.addEventListener("stageResize", onResize);
- addEventListener("resetJumpBtns", this.resetJumpBtns);
- }
- private function resetJumpBtns(event:Event){
- var i:* = 0;
- while (i < this._jumpButtons.length) {
- this._jumpButtons[i].selectedMark.visible = false;
- i++;
- };
- this._jumpButtons[(_controller.currentPage % _controller.totalItems)].selectedMark.visible = true;
- }
- override protected function layoutObjects(){
- var i:* = undefined;
- super.layoutObjects();
- if (((this._leftArrow) && (this._rightArrow))){
- this._leftArrow.x = _style.SliderControl.buttonLeftMargin;
- this._rightArrow.x = (_stageWidth - _style.SliderControl.buttonLeftMargin);
- this._leftArrow.y = (this._rightArrow.y = _style.SliderControl.buttonHeaderMargin);
- };
- if (this._jumpButtons.length > 0){
- i = 0;
- while (i < _totalPages) {
- try {
- var _local2 = this._jumpButtons[i];
- with (_local2) {
- x = (((_stageWidth / 2) - ((_jumpBtnMargin * (_totalPages - 1)) / 2)) + (_jumpBtnMargin * i));
- };
- } catch(e) {
- };
- i = (i + 1);
- };
- };
- }
- override protected function createSliders(){
- this.createArrowButtons();
- this._rightArrow.arrow_mc.alpha = (this._leftArrow.arrow_mc.alpha = 0.4);
- this.createJumpButtons();
- }
- private function createJumpButtons(){
- this._jumpBtnMargin = _style.ImageItem.jumpBtnMargin;
- var i:* = 0;
- while (i < _controller.totalItems) {
- this._jumpButton = new JumpButton();
- this._jumpButtons.push(this._jumpButton);
- addChild(this._jumpButtons[i]);
- var _local2 = this._jumpButtons[i];
- with (_local2) {
- mouseChildren = false;
- buttonMode = true;
- light_mc.visible = true;
- light_mc.alpha = 0;
- selectedMark.visible = false;
- x = (((_stageWidth / 2) - ((_jumpBtnMargin * (_totalPages - 1)) / 2)) + (_jumpBtnMargin * i));
- y = (_style.Carousel.height - (_style.Carousel.baseGradientHeight / 2));
- addEventListener(MouseEvent.MOUSE_DOWN, switchPage);
- addEventListener(MouseEvent.ROLL_OVER, over);
- addEventListener(MouseEvent.ROLL_OUT, out);
- };
- this._jumpButton = null;
- i = (i + 1);
- };
- this._jumpButtons[_controller.currentPage].selectedMark.visible = true;
- }
- override public function disable(){
- this.createJumpButtons();
- }
- override protected function over(event:MouseEvent){
- if ((event.target is JumpButton)){
- event.target.light_mc.alpha = 1;
- } else {
- Utility.tweenTo(event.target.arrow_mc, {
- alpha:1,
- scaleX:1.3,
- scaleY:1.3
- }, Back.easeOut, 9, null);
- };
- }
- override protected function out(event:MouseEvent){
- if ((event.target is JumpButton)){
- event.target.light_mc.alpha = 0;
- } else {
- Utility.tweenTo(event.target.arrow_mc, {
- alpha:0.4,
- scaleX:1,
- scaleY:1
- }, Back.easeOut, 9, null);
- };
- }
- override protected function switchPage(event:MouseEvent){
- var i:*;
- if (_controller.intvAutoscroll != -1){
- dispatchEvent(new Event("stopAutoScroll"));
- };
- if (event.target == this._leftArrow){
- _controller.pageTo((_controller.currentPage - 1), -1);
- } else {
- if (event.target == this._rightArrow){
- _controller.pageTo((_controller.currentPage + 1), 1);
- } else {
- i = 0;
- while (i < this._jumpButtons.length) {
- if (event.target == this._jumpButtons[i]){
- if ((((_controller.totalItems < 4)) && ((_controller.currentPage >= _controller.totalItems)))){
- _controller.pageTo((_controller.totalItems + i), null);
- } else {
- _controller.pageTo(i, null);
- };
- break;
- };
- i++;
- };
- };
- };
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import flash.net.*;
- import com.hulu.masthead.utils.*;
- import com.hulu.masthead.controller.*;
- import flash.external.*;
- public class ImageItem extends Sprite {
- protected static var beaconLoadTraceAllowed:Number = 100;
- protected var _style:Object;
- protected var _data:Object;
- protected var _imageContainer:Sprite;
- protected var _imageClip:Loader;
- protected var _loadState:String = "none";
- protected var _imageUrl:String;
- protected var _linkUrl:String;
- protected var _loadingClip:LoadingImage;
- protected var _controller;
- protected var _bgClip:Sprite;
- protected var _bgLoader:Loader;
- protected var _imageMask:Sprite;
- protected var _id:Number;
- protected var _videoId:Number;
- protected var _showId:Number;
- protected var _mastheadclickBeaconDisabled:Boolean = false;
- public function ImageItem(controller:Object, data:Object, id:Number){
- super();
- this._controller = controller;
- this._style = this._controller.style;
- this._id = id;
- this.initData(data);
- }
- protected function initData(data:Object){
- this._data = data;
- this._imageUrl = this._data["imageUrl"];
- this._linkUrl = this._data["linkUrl"];
- if (((this._data["salesforcePlacementTag"]) && ((this._data["salesforcePlacementTag"].indexOf("http://") >= 0)))){
- this._data["xmlUrl"] = this._data["salesforcePlacementTag"];
- };
- this._videoId = -1;
- if (this._data["videoId"]){
- this._videoId = this._data["videoId"];
- };
- this._showId = -1;
- if (this._data["showId"]){
- this._showId = this._data["showId"];
- };
- }
- public function get videoId():Number{
- return (this._videoId);
- }
- public function set videoId(videoId:Number):void{
- this._videoId = videoId;
- }
- public function get showId():Number{
- return (this._showId);
- }
- public function show(){
- trace(("ImageItem.show: " + this._loadState));
- switch (this._loadState){
- case "none":
- this.createObjects();
- this._loadState = "loading";
- break;
- case "loading":
- break;
- case "loaded":
- this.traceLoadedAnd3rdPartyBeacon();
- break;
- };
- }
- protected function traceLoadedAnd3rdPartyBeacon():void{
- var i:*;
- trace("ImageItem.traceLoadedAnd3rdPartyBeacon");
- var fired:Boolean = this.beaconEventTrace("mastheadload", null);
- this._mastheadclickBeaconDisabled = false;
- if (fired){
- if (this._data["xmlUrl"]){
- for (i in this._data["impressionURLs"]) {
- Utility.callService(Utility.upidReplace(this._data["impressionURLs"][i]));
- };
- };
- };
- }
- protected function createObjects(){
- this._bgClip = new Sprite();
- this._imageContainer = new Sprite();
- this._loadingClip = new LoadingImage();
- this._loadingClip.addEventListener(MouseEvent.MOUSE_DOWN, this.onClick);
- this.layoutLoadingClip();
- addChild(this._bgClip);
- addChild(this._imageContainer);
- addChild(this._loadingClip);
- this.loadImage();
- }
- protected function layoutLoadingClip(){
- }
- public function layoutObjects(){
- this.getRealWidth();
- this.layoutOthers();
- }
- protected function getRealWidth(){
- this.width = this._style.ImageItem.width;
- }
- protected function layoutOthers(){
- }
- protected function attachEvents(){
- this._imageContainer.buttonMode = true;
- this._imageContainer.mouseChildren = false;
- this._imageContainer.addEventListener(MouseEvent.CLICK, this.onClick);
- this._imageContainer.addEventListener(MouseEvent.MOUSE_OVER, this.onMouseOver);
- this._imageContainer.addEventListener(MouseEvent.MOUSE_OUT, this.onMouseOut);
- }
- protected function loadImage(){
- trace(("ImageItem.loadImage " + this._imageUrl));
- this._imageClip = Utility.loadImage(this._imageUrl, this.onImageLoaded, this.ioErrorHandler);
- }
- protected function onImageLoaded(event:Event){
- this.removeLoading();
- }
- protected function removeLoading(){
- this.beaconEventTrace("mastheadload", null);
- this._loadState = "loaded";
- this._imageMask = new Sprite();
- this._imageMask.graphics.beginFill(0, 0);
- this._imageMask.graphics.drawRect(0, 0, this._style.ImageItem.width, this._style.ImageItem.height);
- this._imageMask.graphics.endFill();
- this._imageContainer.addChild(this._imageMask);
- this._imageClip.mask = this._imageMask;
- this._imageContainer.addChild(this._imageClip);
- try {
- this.removeChild(this._loadingClip);
- } catch(e) {
- };
- this._loadingClip = null;
- this.addOthers();
- this.layoutObjects();
- this.attachEvents();
- }
- protected function ioErrorHandler(event:IOErrorEvent){
- }
- protected function addOthers(){
- }
- public function beaconEventTrace(event:String, callback:Function):Boolean{
- if (event == "mastheadload"){
- if (--beaconLoadTraceAllowed < 0){
- return (false);
- };
- } else {
- if (event == "mastheadclick"){
- if (!this._mastheadclickBeaconDisabled){
- this._mastheadclickBeaconDisabled = true;
- } else {
- callback();
- return (false);
- };
- };
- };
- var target:String = escape(this.targetString);
- this.beaconTrace(event, target, callback);
- return (true);
- }
- protected function get targetString():String{
- var tmp:String;
- if (this.linkUrl == null){
- tmp = this._controller.smilHost;
- } else {
- tmp = (((this.linkUrl.indexOf("http://") == 0)) ? this.linkUrl : (this._controller.smilHost + this.linkUrl)).replace(/([^http:])\/\//g, "$1/");
- };
- return (tmp);
- }
- public function beaconMouseClick(url:String, callback:Function){
- var target:String = escape((((url.indexOf("http://") == 0)) ? url : (this._controller.smilHost + url)).replace(/([^http:])\/\//g, "$1/"));
- this.beaconTrace("mastheadclick", target, callback);
- }
- public function beaconTrace(beaconEvent:String, target:String, callback:Function, additionString:String=null, overrideHost:String=null){
- var loader:* = null;
- var url:* = null;
- var request:* = null;
- var beaconEvent:* = beaconEvent;
- var target:* = target;
- var callback:* = callback;
- var additionString = additionString;
- var overrideHost = overrideHost;
- if (Carousel.TYPE != null){
- loader = new URLLoader();
- url = ((((((((overrideHost) || (Utility.getBeaconHost(this._controller.smilHost))) + "/") + beaconEvent) + "?value=") + this._id) + "&") + Utility.getBeaconParams(Carousel.TYPE, target, this._data["mastheadItemId"], this._data["salesforcePlacementTag"]));
- if (additionString != null){
- url = (url + ("&" + additionString));
- };
- request = new URLRequest(url);
- loader.addEventListener(IOErrorEvent.IO_ERROR, function (e){
- trace(e);
- });
- loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function (e){
- trace(e);
- });
- if (callback != null){
- loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, callback);
- };
- try {
- loader.load(request);
- } catch(error:Error) {
- trace(error);
- if (callback != null){
- callback();
- };
- };
- } else {
- if (callback != null){
- callback();
- };
- };
- }
- public function beaconAction(params:Object):void{
- var key:* = null;
- var request:* = null;
- var params:* = params;
- var loader:* = new URLLoader();
- var url:* = (((((((Utility.getBeaconHost(this._controller.smilHost) + "/mastheadaction") + "?value=") + this._id) + "&") + Utility.getBeaconParams(Carousel.TYPE, null, this._data["mastheadItemId"], this._data["salesforcePlacementTag"])) + "&mastheadtype=") + ((this._data["swfType"]) || ("default")));
- for (key in params) {
- url = (url + ((("&" + key) + "=") + params[key]));
- };
- request = new URLRequest(url);
- loader.addEventListener(IOErrorEvent.IO_ERROR, function (e){
- });
- loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function (e){
- });
- try {
- loader.load(request);
- } catch(error:Error) {
- trace(error);
- };
- }
- public function updateItemData(field:String, val){
- this._data[field] = val;
- }
- public function getItemData(field:String){
- return (this._data[field]);
- }
- public function get linkUrl(){
- return (this._linkUrl);
- }
- public function get jscall(){
- if (this._data.hasOwnProperty("jscall")){
- return (this._data["jscall"]);
- };
- return (null);
- }
- protected function onClick(event:MouseEvent){
- var tmpFun:* = null;
- var clickThroughURLs:* = undefined;
- var event:* = event;
- if (this._data["targetingId"]){
- Utility.saveFSO("MastheadSponsor", "sitelocationOverride", this._data["targetingId"]);
- };
- if (this.jscall != null){
- tmpFun = (("function() {" + this.jscall) + "}");
- ExternalInterface.call(tmpFun);
- };
- if (this._data["clickThroughBeaconURLs"]){
- clickThroughURLs = this._data["clickThroughBeaconURLs"];
- Utility.callServices(clickThroughURLs, function (){
- beaconEventTrace("mastheadclick", function (){
- if (jscall != null){
- } else {
- trace(("goto " + linkUrl));
- navigateToURL(new URLRequest(linkUrl), "_self");
- };
- });
- });
- } else {
- this.beaconEventTrace("mastheadclick", function (){
- if (jscall != null){
- } else {
- trace(("goto " + linkUrl));
- if (linkUrl){
- navigateToURL(new URLRequest(linkUrl), "_self");
- };
- };
- });
- };
- }
- protected function onResize(event:Event){
- this.layoutObjects();
- this._controller.stage.dispatchEvent(new Event("imageResizeFinish"));
- }
- protected function onMouseOver(event:MouseEvent){
- }
- protected function onMouseOut(event:MouseEvent){
- }
- public function get loadState(){
- return (this._loadState);
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import flash.net.*;
- import fl.transitions.*;
- import com.hulu.masthead.model.*;
- import flash.system.*;
- import com.hulu.masthead.utils.*;
- import fl.motion.easing.*;
- import flash.text.*;
- import flash.external.*;
- public class CerebroSalesLogoUnit extends Sprite {
- private var _banner:Sprite;
- private var _currentFrame:Number = -1;
- private var _totalFrame:Number;
- private var _container:HuluImageItem;
- private var _frame:Array;
- private var _ad:Object;
- private var _creative:Object;
- private var _asset:Object;
- private var _isActive:Function;
- private var _updatePosition:Function;
- private var _moveUpLogoUnit:Function;
- private var _auditParameters:TextField;
- private var _auditParameterSeparator:String = "?";
- private var _yStart:Number;
- private var _rotationTimeout:Number = -1;
- private var _primaryAuditHost:String = "t2.hulu.com";
- private var _clickTrackingURL:String = "/v3/adinteraction/click";
- private var _assetImpressionTrackingURL:String = "/v3/revenue/assetimpression";
- public function CerebroSalesLogoUnit(container:HuluImageItem, ad:Object, isActive:Function, updatePosition:Function, moveUpLogoUnit:Function, yStart:Number){
- this._frame = [];
- this._auditParameters = new TextField();
- super();
- this._container = container;
- this._ad = ad;
- this._creative = this._ad["creatives"][0];
- this._asset = this._creative["assets"][0];
- this._isActive = isActive;
- this._yStart = yStart;
- this._updatePosition = updatePosition;
- this._moveUpLogoUnit = moveUpLogoUnit;
- this.loadBanner();
- }
- private static function getCacheBuster():String{
- return (String((new Date().valueOf() + Math.round((Math.random() * 1000)))));
- }
- private function appendAuditParameters(auditParams:Object):void{
- var key:String;
- if (auditParams){
- for (key in auditParams) {
- this.appendSingleAuditParameter(key, auditParams[key]);
- };
- };
- }
- private function appendSingleAuditParameter(key:String, value:String):void{
- this._auditParameters.appendText(this._auditParameterSeparator);
- this._auditParameters.appendText(escape(key));
- this._auditParameters.appendText("=");
- this._auditParameters.appendText(escape(value));
- this._auditParameterSeparator = "&";
- }
- public function get browser():String{
- var detectedBrowser:* = "An unknown browser";
- try {
- detectedBrowser = ExternalInterface.call("eval", "BrowserDetect.browser");
- } catch(e:Error) {
- };
- return (((detectedBrowser) ? detectedBrowser : "An unknown browser"));
- }
- private function loadBanner():void{
- var i:Number;
- this._banner = new Sprite();
- this._banner.mouseChildren = false;
- if (((!((this._asset == null))) && (!((this._asset["format"] == "Tracking Only"))))){
- this._banner.addChild(Utility.loadImage(Utility.upidReplace(this._asset["path"]), this.onImageLoaded, this.ioErrorHandler));
- this.addChild(this._banner);
- this._frame.push(this._banner);
- };
- this.appendSingleAuditParameter("os", Capabilities.os);
- this.appendSingleAuditParameter("flash", Capabilities.version);
- this.appendSingleAuditParameter("pod", "-2");
- this.appendSingleAuditParameter("distro", "hulu");
- this.appendSingleAuditParameter("distroplatform", "hulu");
- this.appendSingleAuditParameter("computerguid", GUID.getComputerGuid());
- this.appendSingleAuditParameter("cb", getCacheBuster());
- this.appendSingleAuditParameter("client", this.browser);
- this.appendSingleAuditParameter("placementId", this._creative["placementId"]);
- this.appendSingleAuditParameter("creativeId", this._creative["creativeId"]);
- this.appendAuditParameters(this._ad["auditParams"]);
- this.appendAuditParameters(this._creative["auditParams"]);
- var impressionURLs:Array = [];
- impressionURLs.push((((("http://" + this._primaryAuditHost) + this._assetImpressionTrackingURL) + this._auditParameters.text) + "&beaconevent=assetimpression"));
- var auditUrls:Array = (this._creative["auditUrls"] as Array);
- if (auditUrls != null){
- i = 0;
- while (i < auditUrls.length) {
- impressionURLs.push(auditUrls[i]["url"]);
- i++;
- };
- };
- var adGroupId:String = this._ad["adGroupId"];
- var metadata:Array = (this._creative["metadata"] as Array);
- if (metadata != null){
- i = 0;
- while (i < metadata.length) {
- if (metadata[i]["key"] == "AdGroupId"){
- adGroupId = metadata[i]["value"];
- } else {
- if (metadata[i]["key"] == "WatchNowOverride"){
- this._container.updateItemData("watchNowOverride", metadata[i]["value"]);
- };
- };
- i++;
- };
- };
- this._container.updateItemData("salesforcePlacementTag", this._creative["placementId"]);
- this._container.updateItemData("adGroupId", adGroupId);
- this._container.updateItemData("impressionURLs", impressionURLs);
- var clickUrl:String = this._creative["clickUrl"];
- if (((!((clickUrl == null))) && ((clickUrl.length > 0)))){
- this.addEventListener(MouseEvent.CLICK, this._container.onSponsorLogoClicked);
- this.buttonMode = true;
- this._container.updateItemData("sponsorLogoClickTracker", (((("http://" + this._primaryAuditHost) + this._clickTrackingURL) + this._auditParameters.text) + "&beaconevent=click&type=Banner"));
- this._container.updateItemData("sponsorTargetURL", clickUrl);
- if ((this._moveUpLogoUnit is Function)){
- this._moveUpLogoUnit();
- };
- } else {
- this._container.updateItemData("sponsorTargetURL", null);
- };
- i = 0;
- while (i < impressionURLs.length) {
- Utility.callService(Utility.upidReplace(impressionURLs[i]));
- i++;
- };
- }
- private function onImageLoaded(e){
- if (this.width <= 234){
- this.x = ((234 - this.width) / 2);
- } else {
- this.x = (234 - this.width);
- };
- }
- private function ioErrorHandler(e){
- trace(e);
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import fl.transitions.*;
- import fl.motion.easing.*;
- import fl.transitions.easing.*;
- public class MediumButton extends MovieClip {
- public var _hover:MovieClip;
- private var _callbacks:Function;
- private var _tween:Tween;
- public function MediumButton(){
- super();
- this._hover.alpha = 0;
- buttonMode = true;
- this.addEventListener(MouseEvent.MOUSE_DOWN, this.onClicked);
- this.addEventListener(MouseEvent.MOUSE_OVER, this.onOver);
- this.addEventListener(MouseEvent.MOUSE_OUT, this.onOut);
- }
- public function set onClick(call:Function){
- this._callbacks = call;
- }
- public function onClicked(e){
- if ((this._callbacks is Function)){
- this._callbacks();
- };
- }
- public function onOver(event:MouseEvent){
- if (this._tween){
- this._tween.fforward();
- };
- this._tween = new Tween(this._hover, "alpha", Strong.easeOut, this._hover.alpha, 1, 12);
- }
- public function onOut(event:MouseEvent){
- if (this._tween){
- this._tween.fforward();
- };
- this._tween = new Tween(this._hover, "alpha", Strong.easeOut, this._hover.alpha, 0, 12);
- }
- public function fadeIn(isGradully:Boolean){
- if (isGradully){
- new Tween(this, "alpha", Quartic.easeOut, alpha, 1, 12);
- } else {
- this.alpha = 1;
- };
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import flash.net.*;
- import fl.transitions.*;
- import flash.utils.*;
- import com.hulu.masthead.utils.*;
- import fl.motion.easing.*;
- import com.hulu.masthead.controller.*;
- import flash.text.*;
- import flash.external.*;
- import flash.geom.*;
- import flash.filters.*;
- public class HuluImageItem extends ImageItem {
- private var _detailsOverlay:DetailsOverlay;
- private var _customQuickPlayButton:Boolean = false;
- private var _quickPlayButton:QuickPlayButton;
- private var _quickPlayer:AS3QuickPlayer;
- private var _quickPlayerContainer:Sprite = null;
- private var _movieShowTimeButton:MovieShowTimeButton;
- private var _movieShowTimeContainer:MovieShowTimeContainer;
- private var _movieShowTimeImpressionBeaconFired:Boolean = false;
- private var _moreLink:MoreLink;
- private var _moreBoardMask:Sprite;
- private var _moreBoard:MoreBoard;
- private var _fadeInTween:Tween;
- private var _fadeOutTween:Tween;
- private var _detailsTimer:Timer;
- private var _realWidth:Number;
- private var _eid:String;
- private var _quickplaySpecialBeaconURL:String = "";
- private var _swfKeyArt:Boolean;
- private var _swfType:String;
- private var _imageLoaded:Boolean = false;
- private var _adXMLLoaded:Boolean = false;
- public var detatailsOverLayClickableLayer:Sprite;
- private var _copyrightTf:TextField;
- private var _quickPlaying:Boolean = false;
- public function HuluImageItem(controller:Object, data:Object, id:Number){
- super(controller, data, id);
- this._swfKeyArt = false;
- if (((_imageUrl) && ((_imageUrl.indexOf(".swf") > 0)))){
- this._swfKeyArt = true;
- this._swfType = data["swfType"];
- if ((((this._swfType == "AnimatedSwf")) && ((_imageUrl.indexOf("hulu_marquis.swf") == -1)))){
- this._swfKeyArt = false;
- };
- };
- _controller.stage.addEventListener("stageResize", onResize);
- if (!_data["xmlUrl"]){
- this._adXMLLoaded = true;
- };
- }
- public function get quickPlayerContainer():Sprite{
- return (this._quickPlayerContainer);
- }
- public function get movieShowtimeContainer():Sprite{
- return (this._movieShowTimeButton);
- }
- override protected function attachEvents(){
- if (!this._swfKeyArt){
- super.attachEvents();
- if (this._swfType == "AnimatedSwf"){
- _imageContainer.mouseChildren = true;
- };
- } else {
- buttonMode = false;
- _imageContainer.mouseChildren = true;
- _imageContainer.addEventListener(MouseEvent.MOUSE_DOWN, function (){
- root.dispatchEvent(new Event("stopAutoScroll"));
- });
- if ((((((this._swfType == "VideoRecommendation")) || ((this._swfType == "ShowRecommendation")))) || ((this._swfType == "HollywoodHeadlines")))){
- _imageContainer.addEventListener(MouseEvent.MOUSE_OVER, function (){
- root.dispatchEvent(new Event("stopAutoScroll"));
- });
- };
- };
- addEventListener("imageAnimationStop", function (e){
- removePlayer();
- tweenFforward();
- });
- }
- override protected function getRealWidth(){
- var alp:Number;
- if (width){
- this._realWidth = Math.max(_style.ImageItem.width, (_controller.stageWidth - (_style.Carousel.leftMargin * 2)));
- if (((!(_data["backgroundUrl"])) || (_data["backgroundColor"]))){
- alp = ((_data["backgroundColor"]) ? 1 : 0);
- if (_loadState != "loaded"){
- alp = 0;
- };
- _bgClip.graphics.clear();
- _bgClip.graphics.beginFill(((_data["backgroundColor"]) || (0)), alp);
- _bgClip.graphics.drawRect(0, 0, this._realWidth, _style.ImageItem.height);
- _bgClip.graphics.endFill();
- _bgClip.width = this._realWidth;
- _bgClip.height = _style.ImageItem.height;
- } else {
- if (_bgLoader){
- _bgClip.graphics.clear();
- _bgLoader.width = this._realWidth;
- _bgLoader.height = _style.ImageItem.height;
- };
- };
- };
- }
- override protected function addOthers(){
- var format:TextFormat;
- var filter:DropShadowFilter;
- if (this._swfType != "AnimatedSwf"){
- if (_data["embed"]){
- this._quickPlayButton.visible = true;
- };
- if (this._detailsOverlay){
- this.setDetailsOverlay();
- };
- if (_data["showtime_movie_ids"]){
- this._movieShowTimeButton.visible = true;
- this.fireShowtimeImpressionBeacon();
- };
- } else {
- if (((((((((this._detailsOverlay) && (this._detailsOverlay.sponsorLogo))) && (_data["linkUrl"]))) && (this.linkUrl))) && (!((this.linkUrl.indexOf("/plus") == -1))))){
- _imageContainer.addChild(this._detailsOverlay.sponsorLogo);
- if (this._detailsOverlay.sponsorLogo.width <= _style.DetailsOverlay.borderWidth){
- this._detailsOverlay.sponsorLogo.x = ((_style.ImageItem.width - _style.DetailsOverlay.borderWidth) - 10);
- } else {
- this._detailsOverlay.sponsorLogo.x = ((_style.ImageItem.width - this._detailsOverlay.sponsorLogo.width) - 10);
- };
- this._detailsOverlay.sponsorLogo.y = ((this.height - _style.DetailsOverlay.salesLogoHeight) - 10);
- };
- };
- if (_data["copyrightInfo"]){
- format = new TextFormat();
- format.font = "Helvetica Neue LT Pro 55 Roman";
- format.size = 8;
- format.color = 0xFFFFFF;
- format.align = TextFormatAlign.RIGHT;
- this._copyrightTf = new TextField();
- this._copyrightTf.antiAliasType = AntiAliasType.ADVANCED;
- this._copyrightTf.defaultTextFormat = format;
- this._copyrightTf.alpha = 0.7;
- this._copyrightTf.embedFonts = true;
- this._copyrightTf.mouseEnabled = false;
- this._copyrightTf.rotation = 90;
- this._copyrightTf.text = _data["copyrightInfo"];
- _imageContainer.addChild(this._copyrightTf);
- this._copyrightTf.width = (_style.ImageItem.height - 6);
- this._copyrightTf.x = _style.ImageItem.width;
- this._copyrightTf.y = 2;
- filter = new DropShadowFilter(1, 90, 0, 1, 3, 3, 0.9, BitmapFilterQuality.HIGH, false, false);
- this._copyrightTf.filters = [filter];
- };
- this.addBackground();
- }
- override protected function createObjects(){
- _bgClip = new Sprite();
- _imageContainer = new Sprite();
- _loadingClip = new LoadingImage();
- _loadingClip.addEventListener(MouseEvent.MOUSE_DOWN, this.onClick);
- if (_data["embed"]){
- this._eid = _data["embed"];
- if (this._eid.indexOf(",") > 0){
- this._quickplaySpecialBeaconURL = this._eid.substr((this._eid.indexOf(",") + 1));
- this._eid = this._eid.substr(0, this._eid.indexOf(","));
- };
- this._quickPlayButton = new QuickPlayButton([this.showQuickPlayer, this.hideQuickPlayer]);
- this._quickPlayButton.y = _style.ImageItem.height;
- this._quickPlayButton.visible = false;
- this._quickPlayButton.buttonMode = true;
- this._quickPlayerContainer = new Sprite();
- this._quickPlayerContainer.y = this._quickPlayButton.y;
- this._quickPlayerContainer.visible = false;
- };
- if (_data["showtime_movie_ids"]){
- this._movieShowTimeButton = new MovieShowTimeButton();
- this._movieShowTimeButton.y = _style.ImageItem.height;
- this._movieShowTimeButton.x = 6;
- this._movieShowTimeButton.visible = false;
- };
- this.layoutLoadingClip();
- addChild(_bgClip);
- addChild(_imageContainer);
- if (!this._swfKeyArt){
- this.detatailsOverLayClickableLayer = new Sprite();
- this.detatailsOverLayClickableLayer.visible = false;
- this._detailsOverlay = new DetailsOverlay(_style, this, _data["title"], _data["description"], _data["logoUrl"], _data["promotionBannerUrl"], _data["xmlUrl"], _data["ad"]);
- this._detailsOverlay.alpha = 0;
- this.detatailsOverLayClickableLayer.alpha = 0;
- this._detailsOverlay.showCallback = this.showDetails;
- if (_data["moreDescription"]){
- this._moreLink = new MoreLink();
- this._moreBoard = new MoreBoard(_style, _data["moreDescription"], _data["moreLogoURL"]);
- this._moreBoardMask = new Sprite();
- this._moreBoardMask.graphics.beginFill(0, 0);
- this._moreBoardMask.graphics.drawRect(0, 0, 2, 2);
- this._moreBoardMask.graphics.endFill();
- this._moreBoardMask.width = this._moreBoard.width;
- this._moreBoardMask.height = _style.ImageItem.height;
- this._moreBoard.mask = this._moreBoardMask;
- this._moreLink.onClick = function (){
- root.dispatchEvent(new Event("stopAutoScroll"));
- _moreBoard.defaultY = 0;
- _moreBoard.slideOut(false);
- _moreBoard.visible = true;
- _moreBoard.slideIn(true);
- };
- this.addChild(this._moreLink);
- this.addChild(this._moreBoard);
- this.addChild(this._moreBoardMask);
- this._moreLink.alpha = 0;
- this._moreLink.visible = true;
- this._moreBoard.visible = false;
- };
- if (this.detatailsOverLayClickableLayer){
- this.addChild(this.detatailsOverLayClickableLayer);
- };
- };
- if (_data["embed"]){
- addChild(this._quickPlayerContainer);
- addChild(this._quickPlayButton);
- };
- if (_data["showtime_movie_ids"]){
- addChild(this._movieShowTimeButton);
- this._movieShowTimeButton.addEventListener(MouseEvent.CLICK, this.showMovieShowTime);
- };
- addChild(_loadingClip);
- loadImage();
- }
- override protected function onImageLoaded(event:Event){
- var event:* = event;
- trace(("HuluImageItem.onImageLoaded: " + [_imageUrl, this._swfType, this._swfKeyArt]));
- if (this._swfKeyArt){
- try {
- _imageClip.content["quickPlay"] = this.quickPlay;
- } catch(e) {
- };
- try {
- _imageClip.content["beaconMouseClick"] = this.beaconMouseClick;
- } catch(e) {
- };
- try {
- _imageClip.content["onSponsorLogoClicked"] = this.onSponsorLogoClicked;
- } catch(e) {
- };
- try {
- _imageClip.content["updateItemData"] = this.updateItemData;
- } catch(e) {
- };
- try {
- _imageClip.content["onADDataReady"] = this.onADDataReady;
- } catch(e) {
- _adXMLLoaded = true;
- };
- try {
- var _local3 = _imageClip.content;
- _local3["setDataFromMasthead"](this._data);
- } catch(e) {
- };
- try {
- _imageClip.content["beaconAction"] = this.beaconAction;
- } catch(e) {
- };
- try {
- _imageClip.content["AnimationSwfCallback"] = this.onAnimationSwfCallback;
- } catch(e) {
- trace("error");
- };
- };
- if (this._swfType == "AnimatedSwf"){
- try {
- _imageClip.content["AnimationSwfCallback"] = this.onAnimationSwfCallback;
- } catch(e) {
- trace("error");
- };
- try {
- _imageClip.content["Callback"] = this.onSwfCallback;
- } catch(e) {
- trace("error");
- };
- try {
- _imageClip.content["onADDataReady"] = this.onADDataReady;
- } catch(e) {
- _adXMLLoaded = true;
- };
- if (!this._swfKeyArt){
- try {
- _local3 = _imageClip.content;
- _local3["setDataFromMasthead"](this._data);
- } catch(e) {
- };
- };
- };
- this._imageLoaded = true;
- this.onImageOrAdXMLLoaded();
- }
- private function onAnimationSwfCallback(options:Object){
- var _local2:Object;
- var _local3:String;
- var _local4:String;
- var _local5:String;
- var _local6:String;
- var _local7:String;
- if (options == null){
- return;
- };
- trace("HuluImageItem.onAnimationSwfCallback");
- trace(options["command"]);
- switch (options["command"]){
- case "animation_end":
- _local2 = {
- showQuickPlay:false,
- showMovieShowTime:false,
- showDetailOverlay:false,
- showAdLogo:true,
- mouseChildren:false
- };
- _local2.showQuickPlay = (options["showQuickPlay"] == true);
- _local2.showMovieShowTime = (options["showMovieShowTime"] == true);
- _local2.showDetailOverlay = (options["showDetailOverlay"] == true);
- _local2.mouseChildren = (options["mouseChildren"] == true);
- _local2.showAdLogo = !((options["showAdLogo"] == false));
- this.onSwfCallback(_local2);
- break;
- case "quickplay":
- this._quickPlayButton.onClick(null);
- break;
- case "movie_show_time":
- this.createMovieShowTime(options["movieId"]);
- break;
- case "open_new_window":
- _local3 = options["url"];
- navigateToURL(new URLRequest(_local3), "_blank");
- break;
- case "track_beacon":
- _local4 = ((options["beacontype"]) || ("mastheadclick"));
- _local5 = options["additionString"];
- _local6 = escape(targetString);
- _local7 = options["overrideHost"];
- beaconTrace(_local4, _local6, null, _local5, _local7);
- break;
- case "goto_watch_page":
- if (this.linkUrl){
- navigateToURL(new URLRequest(this.linkUrl), "_self");
- };
- break;
- case "track_click_ad_logo":
- this.handleSponsorLogoClick();
- break;
- };
- }
- private function onSwfCallback(options:Object=null):void{
- var showQuickPlay:Boolean = (((options == null)) || (!((options["showQuickPlay"] == false))));
- var showMovieShowTime:Boolean = (((options == null)) || (!((options["showMovieShowTime"] == false))));
- var showDetailOverlay:Boolean = (((options == null)) || (!((options["showDetailOverlay"] == false))));
- var mouseChildren:Boolean = (((options == null)) || (!((options["mouseChildren"] == false))));
- var showAdLogo:Boolean = (((options == null)) || (!((options["showAdLogo"] == false))));
- if (((_data["embed"]) && (showQuickPlay))){
- this._quickPlayButton.visible = true;
- };
- if (((_data["showtime_movie_ids"]) && (showMovieShowTime))){
- this._movieShowTimeButton.visible = true;
- this.fireShowtimeImpressionBeacon();
- };
- if (((this._detailsOverlay) && (showDetailOverlay))){
- this.setDetailsOverlay();
- };
- if (!showAdLogo){
- this._detailsOverlay.sponsorLogo.visible = false;
- };
- if (mouseChildren){
- _imageContainer.removeEventListener(MouseEvent.CLICK, this.onClick);
- _imageContainer.removeEventListener(MouseEvent.MOUSE_OVER, this.onMouseOver);
- _imageContainer.removeEventListener(MouseEvent.MOUSE_OUT, this.onMouseOut);
- _imageContainer.buttonMode = false;
- };
- _imageContainer.mouseChildren = mouseChildren;
- layoutObjects();
- }
- public function onADDataReady():void{
- this._adXMLLoaded = true;
- this.onImageOrAdXMLLoaded();
- }
- private function onImageOrAdXMLLoaded():void{
- if (((this._imageLoaded) && (this._adXMLLoaded))){
- removeLoading();
- };
- }
- override protected function layoutOthers(){
- if (_imageContainer){
- _imageContainer.x = ((this._realWidth - _style.ImageItem.width) / 2);
- };
- if (_loadingClip){
- this.layoutLoadingClip();
- };
- if (this._quickPlayButton){
- this._quickPlayButton.x = (6 + (((_controller.stageWidth - (_style.Carousel.leftMargin * 2)) - _style.ImageItem.width) / 2));
- };
- if (this._movieShowTimeButton){
- this._movieShowTimeButton.x = (6 + (((_controller.stageWidth - (_style.Carousel.leftMargin * 2)) - _style.ImageItem.width) / 2));
- if (this._quickPlayButton){
- this._quickPlayButton.x = (this._movieShowTimeButton.x + 151);
- };
- };
- if (this._quickPlayerContainer){
- this._quickPlayerContainer.x = (((_controller.stageWidth - (_style.Carousel.leftMargin * 2)) - _style.ImageItem.width) / 2);
- };
- if (this._moreLink){
- this._moreBoardMask.x = (this._moreBoard.x = (this._moreLink.x = (this._detailsOverlay.x + _imageContainer.x)));
- this._moreLink.y = ((this._detailsOverlay.y + _style.ImageItem.height) - this._moreLink.height);
- };
- if (this.detatailsOverLayClickableLayer){
- this.detatailsOverLayClickableLayer.x = (this._detailsOverlay.x + _imageContainer.x);
- this.detatailsOverLayClickableLayer.visible = true;
- };
- if (this._movieShowTimeContainer){
- this.layoutMovieShowTime();
- };
- }
- override protected function layoutLoadingClip(){
- _loadingClip.clickArea.x = (-(_controller.stageWidth) / 2);
- _loadingClip.clickArea.y = (-(_style.Carousel.height) / 2);
- _loadingClip.clickArea.width = (_controller.stageWidth - (_style.Carousel.leftMargin * 2));
- _loadingClip.clickArea.height = _style.ImageItem.height;
- _loadingClip.x = (_controller.stageWidth / 2);
- _loadingClip.y = (_style.Carousel.height / 2);
- }
- public function onSponsorLogoClicked(event:MouseEvent=null){
- this.handleSponsorLogoClick();
- }
- private function handleSponsorLogoClick():void{
- var request:URLRequest;
- trace("handleSponsorLogoClick");
- trace(_data["sponsorTargetURL"]);
- root.dispatchEvent(new Event("stopAutoScroll"));
- beaconTrace("mastheadsponsorclick", escape(_data["sponsorTargetURL"]), null);
- if (_data["sponsorLogoClickTracker"] != null){
- Utility.callService(Utility.upidReplace(_data["sponsorLogoClickTracker"]));
- };
- var url:String = _data["sponsorTargetURL"];
- if (url.indexOf("hulu.com/plus") != -1){
- request = new URLRequest(url);
- navigateToURL(request, "_self");
- } else {
- if (ExternalInterface.available){
- ExternalInterface.call("showLink", _data["sponsorTargetURL"]);
- };
- };
- }
- private function addQuickPlayer(){
- var url:* = null;
- url = ((_data["watchPageURL"]) || (this.linkUrl));
- var watchInHiResCall:* = function ():void{
- beaconEventTrace("mastheadclick", function (){
- var tmpFun:String;
- if (((!((url == null))) && (!((url == ""))))){
- navigateToURL(new URLRequest(url), "_self");
- } else {
- if (((!((jscall == null))) && (!((jscall == ""))))){
- tmpFun = (("function() {" + jscall) + "}");
- ExternalInterface.call(tmpFun);
- };
- };
- });
- };
- if (((((this.linkUrl) && ((this.linkUrl.indexOf("watch/") < 0)))) || (("null" == _data["watchPageURL"])))){
- watchInHiResCall = null;
- };
- this._quickPlayer = AS3QuickPlayer.getInstance(_style, _controller.stageWidth, watchInHiResCall, this._eid, this._quickPlayerContainer);
- this._quickPlayer.addEventListener("closeQuickPlayer", function (e){
- if (_quickPlayButton){
- _quickPlayButton.reset();
- };
- });
- this._quickPlayerContainer.addChild(this._quickPlayer);
- this._quickPlayer.y = -(this._quickPlayerContainer.y);
- this._quickPlayerContainer.visible = true;
- }
- private function showMovieShowTime(e:Event):void{
- if (this._quickPlaying){
- this.hideQuickPlayer();
- this._quickPlayButton.reset();
- setTimeout(this.createMovieShowTime, (10000 / stage.frameRate));
- } else {
- this.createMovieShowTime();
- };
- }
- private function createMovieShowTime(movieId:String=null):void{
- if (!this._movieShowTimeContainer){
- this._movieShowTimeContainer = new MovieShowTimeContainer(this.fireShowtimeSearchBeacon, this.fireShowtimeTicketBeacon, _controller);
- this._movieShowTimeContainer.data = ((((_data["showtime_movie_ids"]) || (movieId))) || (""));
- addChild(this._movieShowTimeContainer);
- this.layoutMovieShowTime();
- } else {
- if (movieId != null){
- this._movieShowTimeContainer.data = movieId;
- this._movieShowTimeContainer.showMST();
- } else {
- this._movieShowTimeContainer.showMST();
- };
- this.layoutMovieShowTime();
- };
- (_controller as HuluCarousel).stopAnimation();
- }
- private function layoutMovieShowTime():void{
- this._movieShowTimeContainer.x = (((_controller.stageWidth - (_style.Carousel.leftMargin * 2)) - _style.ImageItem.width) / 2);
- this._movieShowTimeContainer.y = 0;
- }
- private function hideQuickPlayer(){
- if (this._quickPlayer){
- this._quickPlaying = false;
- this._quickPlayer.hide(false);
- this._quickPlayer.soundTransform.volume = 0;
- };
- }
- private function showQuickPlayer(){
- beaconEventTrace("quickplay", null);
- this.fireQuickplaySpecialBeacon();
- if (stage.frameRate != 15){
- stage.frameRate = 15;
- };
- var hasLoaded:* = AS3QuickPlayer.hasInstance;
- if (((!(this._quickPlayer)) || (!(this._quickPlayerContainer.contains(this._quickPlayer))))){
- this.addQuickPlayer();
- };
- if (hasLoaded){
- this._quickPlayer.show(false);
- this._quickPlayer.soundTransform.volume = 1;
- };
- this._quickPlaying = true;
- }
- private function fireQuickplaySpecialBeacon(){
- if (this._quickplaySpecialBeaconURL.length < 1){
- return;
- };
- var sponsorTrackID:String = ((new Date().getTime() + "") + Math.random());
- Utility.callService((this._quickplaySpecialBeaconURL + sponsorTrackID));
- }
- private function fireShowtimeImpressionBeacon():void{
- if (this._movieShowTimeImpressionBeaconFired){
- return;
- };
- this._movieShowTimeImpressionBeaconFired = true;
- var req:String = ((((Utility.getBeaconHost(_controller.smilHost) + "/showtimeimpression?computerguid=") + GUID.getComputerGuid()) + "&cb=") + Math.random());
- req = (req + ("&eid=" + this.eid));
- Utility.callService(req);
- }
- private function fireShowtimeSearchBeacon(movieID:String, zipcode:String=""):void{
- var req:String = ((((Utility.getBeaconHost(_controller.smilHost) + "/showtimesearch?computerguid=") + GUID.getComputerGuid()) + "&cb=") + Math.random());
- req = (req + ("&eid=" + this.eid));
- req = (req + ("&movie_id=" + movieID));
- if (zipcode){
- req = (req + ("&zipcode=" + zipcode));
- };
- Utility.callService(req);
- }
- private function fireShowtimeTicketBeacon(movieID:String, theaterID:String, anchor:String):void{
- var req:String = ((((Utility.getBeaconHost(_controller.smilHost) + "/showtimeticket?computerguid=") + GUID.getComputerGuid()) + "&cb=") + Math.random());
- req = (req + ("&eid=" + this.eid));
- req = (req + ((((("&movie_id=" + movieID) + "&theater_id=") + theaterID) + "&anchor=") + anchor));
- Utility.callService(req);
- }
- public function quickPlay(embedded_id:String, watchPageURL:String){
- var embedded_id:* = embedded_id;
- var watchPageURL:* = watchPageURL;
- this._eid = embedded_id;
- trace(this._eid);
- if (!this._quickPlayerContainer){
- this._quickPlayerContainer = new Sprite();
- addChild(this._quickPlayerContainer);
- this._quickPlayerContainer.y = _style.ImageItem.height;
- this._quickPlayerContainer.visible = false;
- this._quickPlayerContainer.x = (((_controller.stageWidth - (_style.Carousel.leftMargin * 2)) - _style.ImageItem.width) / 2);
- };
- if (!this._quickPlayer){
- this.addQuickPlayer();
- };
- var watchInHiResCall:* = function (){
- beaconEventTrace("mastheadclick", function (){
- navigateToURL(new URLRequest(watchPageURL), "_self");
- });
- };
- this._quickPlayer.update(watchInHiResCall, this._eid, this._quickPlayerContainer);
- this.showQuickPlayer();
- }
- override protected function onClick(event:MouseEvent){
- if (((((this._detailsOverlay) && (this._detailsOverlay.sponsorLogo))) && ((((this._detailsOverlay.sponsorLogo == event.target)) || (this._detailsOverlay.sponsorLogo.contains((event.target as DisplayObject))))))){
- return;
- };
- if (this.brandGroupId != null){
- ExternalInterface.call("setOneShotBrandVar", this.brandGroupId);
- };
- super.onClick(event);
- }
- override protected function onMouseOver(event:MouseEvent){
- if (this._detailsOverlay){
- this._detailsOverlay.turnLight();
- };
- }
- override protected function onMouseOut(event:MouseEvent){
- if (this._detailsOverlay){
- this._detailsOverlay.turnDark();
- };
- }
- private function setDetailsOverlay(){
- this._detailsTimer = new Timer(270, 1);
- this._detailsTimer.addEventListener("timer", function (e:Event){
- _detailsOverlay.fadeIn(true);
- if (_moreLink){
- _moreLink.fadeIn(true);
- };
- });
- if (this.visible){
- this.showDetails(null);
- };
- _imageContainer.addChild(this._detailsOverlay);
- this._detailsOverlay.x = ((_style.ImageItem.width - _style.DetailsOverlay.rightMargin) - _style.DetailsOverlay.borderWidth);
- }
- private function addBackground(){
- if (_data["backgroundUrl"]){
- _bgLoader = new Loader();
- _bgLoader = Utility.loadImage(_data["backgroundUrl"], function (e){
- addChildAt(_bgLoader, 1);
- getRealWidth();
- }, null);
- };
- }
- public function fadeOut(isGradually:Boolean){
- var isGradually:* = isGradually;
- if (this._detailsOverlay){
- this._detailsOverlay.deactive();
- };
- if (!isGradually){
- this.alpha = 0.4;
- } else {
- this._fadeOutTween = new Tween(this, "alpha", Linear.easeOut, this.alpha, 0.4, 28);
- };
- if (this._swfKeyArt){
- try {
- var _local3 = _imageClip.content;
- _local3["onFadeOut"]();
- } catch(e:Error) {
- };
- };
- }
- public function fadeIn(isGradually:Boolean){
- this.tweenFforward();
- if (this._detailsOverlay){
- this._detailsOverlay.alpha = 0;
- if (this._moreLink){
- this._moreLink.alpha = 0;
- };
- if (this._moreBoard){
- this._moreBoard.visible = false;
- };
- };
- if (this.detatailsOverLayClickableLayer){
- this.detatailsOverLayClickableLayer.alpha = 0;
- };
- if (!isGradually){
- this._detailsOverlay.fadeIn(false);
- if (this._moreLink){
- this._moreLink.fadeIn(false);
- };
- this.alpha = 1;
- } else {
- this._fadeInTween = new Tween(this, "alpha", Linear.easeOut, alpha, 1, 28);
- this._fadeInTween.addEventListener(TweenEvent.MOTION_FINISH, this.showDetails);
- };
- }
- private function showDetails(event:TweenEvent){
- if (((!(this._detailsOverlay)) || (!(this._detailsOverlay.visible)))){
- return;
- };
- if (((((!(_style)) || (!(_style.Carousel)))) || (!(_style.Carousel.leftMargin)))){
- return;
- };
- if (!this._detailsTimer){
- return;
- };
- if ((((this._fadeInTween == null)) || (!(this._fadeInTween.isPlaying)))){
- this._detailsTimer.reset();
- this._detailsTimer.start();
- };
- }
- private function tweenFforward(){
- if (((this._fadeInTween) && (this._fadeInTween.isPlaying))){
- this._fadeInTween.removeEventListener(TweenEvent.MOTION_FINISH, this.showDetails);
- this._fadeInTween.fforward();
- };
- if (((this._fadeOutTween) && (this._fadeOutTween.isPlaying))){
- this._fadeOutTween.fforward();
- };
- if (this._detailsTimer){
- this._detailsTimer.reset();
- };
- if (((((this._detailsOverlay) && (this._detailsOverlay._fadeInTween))) && (this._detailsOverlay._fadeInTween.isPlaying))){
- this._detailsOverlay._fadeInTween.fforward();
- this._detailsOverlay.alpha = 0.4;
- if (((this._detailsOverlay._clickableLayerFadeInTween) && (this._detailsOverlay._clickableLayerFadeInTween.isPlaying))){
- this._detailsOverlay._clickableLayerFadeInTween.fforward();
- };
- this.detatailsOverLayClickableLayer.alpha = 0.4;
- };
- }
- public function get eid(){
- return (this._eid);
- }
- public function removePlayer(){
- if (stage.frameRate != 30){
- stage.frameRate = 30;
- };
- if (((((this._quickPlayerContainer) && (this._quickPlayer))) && (this._quickPlayerContainer.contains(this._quickPlayer)))){
- this._quickPlayer.stop();
- if (this._quickPlayButton){
- this._quickPlayButton.reset();
- };
- this._quickPlayerContainer.removeChild(this._quickPlayer);
- this._quickPlayer = null;
- trace("QUICK PLAYER REMOVED");
- };
- }
- public function userLogin(id:Number){
- var id:* = id;
- if (this._swfKeyArt){
- try {
- var _local3 = _imageClip.content;
- _local3["userLogin"](id);
- } catch(e) {
- };
- };
- if (this._detailsOverlay){
- this._detailsOverlay.userLogin(id);
- };
- }
- public function redraw(){
- if (this._swfKeyArt){
- try {
- var _local2 = _imageClip.content;
- _local2["redraw"]();
- } catch(e) {
- };
- };
- }
- override protected function traceLoadedAnd3rdPartyBeacon():void{
- var fired:* = false;
- if (this._swfKeyArt){
- fired = beaconEventTrace("mastheadload", null);
- _mastheadclickBeaconDisabled = false;
- if (fired){
- try {
- var _local2 = _imageClip.content;
- _local2["trackLoadedBeacon"]();
- } catch(e) {
- };
- };
- } else {
- super.traceLoadedAnd3rdPartyBeacon();
- };
- }
- private function get brandGroupId(){
- if (_data["adGroupId"] != null){
- return (_data["adGroupId"]);
- };
- if (this._detailsOverlay){
- if (this._detailsOverlay.sponsorBanner){
- if (this._detailsOverlay.sponsorBanner.brandGroupId != null){
- return (this._detailsOverlay.sponsorBanner.brandGroupId);
- };
- };
- };
- return (null);
- }
- override public function get linkUrl(){
- if (_data["watchNowOverride"] != null){
- return (_data["watchNowOverride"]);
- };
- if (this._detailsOverlay){
- if (this._detailsOverlay.sponsorBanner){
- if (this._detailsOverlay.sponsorBanner.watchNowOverride){
- return (this._detailsOverlay.sponsorBanner.watchNowOverride);
- };
- };
- };
- return (super.linkUrl);
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import flash.net.*;
- import flash.system.*;
- import com.hulu.masthead.utils.*;
- import flash.external.*;
- public class HuluItemsContainer extends ItemsContainer {
- public function HuluItemsContainer(controller:Object){
- super(controller);
- ExternalInterface.addCallback("addFacepile", this.addFacepile);
- }
- override protected function createObjects(itemsModel:Array){
- var obj:ImageItem;
- var i:* = 0;
- while (i < itemsModel.length) {
- _controller.autoScrollCounter.push(((itemsModel[i]["embed"]) ? 1 : -1));
- obj = new HuluImageItem(_controller, itemsModel[i], i);
- addChild(obj);
- _imageItems.push(obj);
- i++;
- };
- if (_showFacepile){
- this.addFacepile();
- };
- }
- public function addFacepile():void{
- var loadUrl:* = null;
- var endIndex:* = 0;
- var urlFacepile:* = null;
- if (!_isFacepileLoaded){
- _isFacepileLoaded = true;
- loadUrl = _controller.stage.loaderInfo.loaderURL;
- endIndex = loadUrl.lastIndexOf("/", loadUrl.length);
- urlFacepile = loadUrl.substr(0, (endIndex + 1));
- urlFacepile = (urlFacepile + "Facepile.swf?v20");
- trace(("Loading: " + urlFacepile));
- _loaderFacepile = new Loader();
- _loaderFacepile.contentLoaderInfo.addEventListener(Event.COMPLETE, this.onLoadFacepileComplete);
- try {
- _loaderFacepile.load(new URLRequest(urlFacepile), new LoaderContext(true, ApplicationDomain.currentDomain));
- } catch(e) {
- trace(("Error: HuluItemsContainer.addFacepile" + e));
- };
- };
- }
- public function preloadObjects(items:Array){
- items.forEach(this.preloadObject);
- }
- private function preloadObject(obj, index:int, array:Array):void{
- if (((obj["imageUrl"]) && (!((obj["type"] == "animationswf"))))){
- Utility.loadImage(obj["imageUrl"], null, null);
- };
- if (obj["logoUrl"]){
- Utility.loadImage(obj["logoUrl"], null, null);
- if (Utility.upidReplace(obj["logoUrl"])){
- Utility.loadImage(Utility.upidReplace(obj["logoUrl"]), null, null);
- };
- };
- }
- protected function onLoadFacepileComplete(event:Event){
- var event:* = event;
- _loaderFacepile.content["baseUrl"] = _controller.stage.loaderInfo.loaderURL;
- _facepile = new Sprite();
- _facepile.addChild(_loaderFacepile);
- var urlVideos:* = ((_loaderFacepile.content["baseUrl"] + "social/masthead_data?limit=10&uid=") + _uid);
- var isFirst:* = true;
- var count:* = 0;
- while (count < _imageItems.length) {
- if ((((_imageItems[count].videoId < 0)) && ((_imageItems[count].showId >= 0)))){
- if (isFirst){
- isFirst = false;
- urlVideos = (urlVideos + "&show_ids=");
- } else {
- urlVideos = (urlVideos + ",");
- };
- urlVideos = (urlVideos + _imageItems[count].showId.toString());
- };
- count = (count + 1);
- };
- isFirst = true;
- count = 0;
- while (count < _imageItems.length) {
- if (_imageItems[count].videoId >= 0){
- if (isFirst){
- isFirst = false;
- urlVideos = (urlVideos + "&video_ids=");
- } else {
- urlVideos = (urlVideos + ",");
- };
- urlVideos = (urlVideos + _imageItems[count].videoId.toString());
- };
- count = (count + 1);
- };
- var loaderVideos:* = new URLLoader();
- loaderVideos.addEventListener(Event.COMPLETE, this.onMastheadDataComplete);
- try {
- loaderVideos.load(new URLRequest(urlVideos));
- } catch(e:ErrorEvent) {
- trace(e);
- };
- }
- protected function onMastheadDataComplete(event:Event){
- var event:* = event;
- var str:* = event.target.data;
- try {
- var _local3 = _loaderFacepile.content;
- _local3["setData"](_uid, str);
- } catch(e) {
- trace(("Error: HuluItemsContainer.oncComplete" + e));
- };
- displayFacepile();
- }
- private function onError(event:Event){
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import flash.net.*;
- import flash.utils.*;
- import fl.motion.easing.*;
- import fl.transitions.easing.*;
- import fl.containers.*;
- public class AS3VideoContainer extends Sprite {
- private var _style:Object;
- private var _player;
- private var _playerLoader:UILoader;
- private var _loadingClip:LoadingImage;
- private var _timer:Timer;
- private var _eid:String;
- private var _playerHost:String;
- private var _env:String;
- private var _playerState:String = "none";
- public function AS3VideoContainer(style:Object, eid:String, playerHost:String, env:String){
- super();
- this._playerHost = ((playerHost) || ("http://www.hulu.com/embed/"));
- this._style = style;
- this._eid = eid;
- this._env = env;
- this.initialize();
- }
- private function initialize():void{
- trace("AS3VideoContainer.initialize");
- this._playerLoader = new UILoader();
- this._playerLoader.addEventListener(Event.COMPLETE, this.onInitializeSucceeded);
- this._loadingClip = new LoadingImage();
- addChild(this._playerLoader);
- addChild(this._loadingClip);
- this._loadingClip.x = ((this._style.QuickPlayer.playerWidth / 2) + 45);
- this._loadingClip.y = (this._style.ImageItem.height / 2);
- var playerURL:String = HuluMasthead.stage.loaderInfo.url;
- var baseURL:String = playerURL.substr(0, playerURL.search(/\/[^\/]*\.swf/));
- var url = (baseURL + "/embedplayer.swf?flaWidth=920&flaHeight=377&stageWidth=512&stageHeight=296");
- url = ((this._playerHost + "site-player/playerembed.swf?extContainer=masthead&env=") + this._env);
- this._playerLoader.load(new URLRequest(url));
- }
- private function onInitializeSucceeded(e:Event):void{
- trace("AS3VideoContainer.onInitializeSucceeded");
- this._player = (e.target as UILoader).content;
- addChild(this._player);
- this._player.addEventListener("player_ready", this.onPlayerReady);
- this._player.initPlayer(true);
- }
- private function onPlayerReady(evt:Event):void{
- trace("AS3VideoContainer.onPlayerReady");
- if (((!((this._loadingClip == null))) && (this.contains(this._loadingClip)))){
- this.removeChild(this._loadingClip);
- this._loadingClip = null;
- };
- dispatchEvent(new Event("onInitializeSucceeded"));
- this._player.setEnablePreroll(false);
- if (this._eid != null){
- this.loadInternal(this._eid);
- };
- }
- private function onInitializeFailed(e:Event):void{
- }
- public function load(eid:String):void{
- trace(("AS3VideoContainer.load " + [eid]));
- if (eid == null){
- return;
- };
- this._eid = eid;
- this._playerState = "play";
- this.loadInternal(eid);
- }
- public function loadInternal(eid:String):void{
- if (eid == null){
- return;
- };
- if (this._player){
- this._player.playVideo(("e:" + eid), 0, 0);
- switch (this._playerState){
- case "stop":
- this.stopPlayer();
- break;
- case "pause":
- this.pausePlayer();
- break;
- };
- };
- }
- public function pausePlayer():void{
- this._playerState = "pause";
- if (this._player){
- this._player.pause();
- };
- }
- public function playPlayer():void{
- this._playerState = "play";
- if (this._player){
- this._player.resume();
- };
- }
- public function stopPlayer():void{
- this._playerState = "stop";
- if (this._player){
- this._player.stop();
- };
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- public dynamic class MoreLink extends MediumButton {
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import flash.net.*;
- import fl.transitions.*;
- import com.hulu.masthead.model.*;
- import com.hulu.masthead.utils.*;
- import fl.motion.easing.*;
- public class SalesLogoUnit extends Sprite {
- private var _banner:Sprite;
- private var _currentFrame:Number = -1;
- private var _totalFrame:Number;
- private var _container:HuluImageItem;
- private var _frame:Array;
- private var _model:Array;
- private var _companionIndex:Number = -1;
- private var _isActive:Function;
- private var _updatePosition:Function;
- private var _moveUpLogoUnit:Function;
- private var _displayed:Array;
- private var _yStart:Number;
- private var _rotationTimeout:Number = -1;
- public function SalesLogoUnit(container:HuluImageItem, model:Array, isActive:Function, updatePosition:Function, moveUpLogoUnit:Function, yStart:Number){
- this._frame = [];
- this._model = [];
- this._displayed = [];
- super();
- this._container = container;
- this._model = model;
- this._isActive = isActive;
- this._totalFrame = this._model.length;
- this._yStart = yStart;
- this._updatePosition = updatePosition;
- this._moveUpLogoUnit = moveUpLogoUnit;
- this.checkToLoadBanner();
- }
- private function checkToLoadBanner(evt=null):void{
- trace(("SalesLogoUnit.checkToLoadBanner " + [UserConfig.getInstance().isUserLoggedIn, UserConfig.getInstance().getUserId()]));
- var containMatureBanner:Boolean;
- var matureBannerIndex:Number = -1;
- var i:int;
- while (i < this._model.length) {
- if (((this._model[i].isMatureRated) && ((this._model[i].duration > 0)))){
- containMatureBanner = true;
- matureBannerIndex = i;
- break;
- };
- i++;
- };
- if (((containMatureBanner) && (UserConfig.getInstance().isUserLoggedIn))){
- if (UserConfig.getInstance().userConfigAvailable){
- if (UserConfig.getInstance().allowMatureContent){
- this.loadBanner(this.randomBanner(true));
- } else {
- this.loadBanner(this.randomBanner(false));
- };
- } else {
- UserConfig.getInstance().addEventListener("userConfigReady", this.checkToLoadBanner);
- UserConfig.getInstance().loadUserConfig();
- };
- } else {
- this.loadBanner(this.randomBanner(false));
- };
- }
- private function randomBanner(allowMatureContent:Boolean):Number{
- var total:Number = 0;
- var range:Array = [0];
- var i:int;
- while (i < this._model.length) {
- if (((!(allowMatureContent)) && (this._model[i].isMatureRated))){
- this._model[i].duration = 0;
- };
- range.push((this._model[i].duration + range[i]));
- total = (total + this._model[i].duration);
- i++;
- };
- if (total <= 0){
- return (-1);
- };
- i = 0;
- while (i < range.length) {
- range[i] = (range[i] / total);
- i++;
- };
- var rand:Number = Math.random();
- i = 0;
- while (i < (range.length - 1)) {
- if (((!(allowMatureContent)) && (this._model[i].isMatureRated))){
- } else {
- if ((((range[i] <= rand)) && ((rand < range[(i + 1)])))){
- return (i);
- };
- };
- i++;
- };
- return (-1);
- }
- private function loadBanner(item:Number):void{
- var i:*;
- if (item < 0){
- return;
- };
- this._companionIndex = item;
- this._banner = new Sprite();
- this._banner.mouseChildren = false;
- this._banner.addChild(Utility.loadImage(Utility.upidReplace(this._model[item].logoURL), this.onImageLoaded, this.ioErrorHandler));
- this.addChild(this._banner);
- this._frame.push(this._banner);
- this._displayed[item] = false;
- this._container.updateItemData("salesforcePlacementTag", this._model[item].placementId);
- this._container.updateItemData("targetingId", this._model[item].targetingId);
- this._container.updateItemData("clickThroughBeaconURLs", this._model[item].clickThroughURLs);
- this._container.updateItemData("impressionURLs", this._model[item].impressionURLs);
- if (this._model[item].sponsorTargetURL.indexOf("http") == 0){
- this.addEventListener(MouseEvent.CLICK, this._container.onSponsorLogoClicked);
- this.buttonMode = true;
- this._container.updateItemData("sponsorTargetURL", this._model[item].sponsorTargetURL);
- if ((this._moveUpLogoUnit is Function)){
- this._moveUpLogoUnit();
- };
- } else {
- this._container.updateItemData("sponsorTargetURL", null);
- };
- for (i in this._model[item].impressionURLs) {
- Utility.callService(Utility.upidReplace(this._model[item].impressionURLs[i]));
- };
- }
- private function onImageLoaded(e){
- if (this.width <= 234){
- this.x = ((234 - this.width) / 2);
- } else {
- this.x = (234 - this.width);
- };
- }
- private function ioErrorHandler(e){
- trace(e);
- }
- public function get watchNowOverride():String{
- if (this._companionIndex == -1){
- return (null);
- };
- return (this._model[this._companionIndex].watchNowOverride);
- }
- public function get brandGroupId():String{
- if (this._companionIndex == -1){
- return (null);
- };
- return (this._model[this._companionIndex].brandGroupId);
- }
- private function onLogoClicked(e){
- }
- public function reset(){
- this.hideAll();
- this._currentFrame = -1;
- }
- private function hideAll(){
- var i:*;
- for (i in this._frame) {
- this._frame[i].visible = false;
- };
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import com.hulu.masthead.utils.*;
- import fl.motion.easing.*;
- import com.hulu.masthead.controller.*;
- import flash.external.*;
- public class ItemsContainer extends Sprite {
- protected var _imageItems:Array;
- protected var _style:Object;
- protected var _controller:Object;
- protected var _currentPage:Number = 0;
- protected var _visiblePages:Number;
- protected var _uid:Number = -1;
- protected var _facepile:Sprite;
- protected var _loaderFacepile:Loader;
- protected var _isFacepileLoaded:Boolean = false;
- protected var _loadFacepile:Boolean = false;
- protected var _showFacepile:Boolean = false;
- public function ItemsContainer(controller:Object){
- this._imageItems = [];
- super();
- this._controller = controller;
- this._style = this._controller.style;
- if (this._loadFacepile){
- this._uid = ExternalInterface.call("Behaviors.getUserId");
- if (((ExternalInterface.call("Behaviors.isFacebookConnected")) && ((this._uid >= 0)))){
- this._showFacepile = true;
- };
- };
- this._controller.stage.addEventListener("stageResize", this.onResize);
- }
- public function addItems(itemsModel:Array){
- this._visiblePages = this._style.Carousel.visiblePages;
- this.createObjects(itemsModel);
- }
- public function show(startpage:Number){
- this._currentPage = startpage;
- this._imageItems[this._currentPage].show();
- this.layoutItem();
- this.displayFacepile();
- }
- public function displayFacepile(){
- if (((this._showFacepile) && (this._facepile))){
- var _local2 = this._loaderFacepile.content;
- _local2["clearDisplay"]();
- if ((((this._imageItems[this._currentPage].videoId >= 0)) || ((this._imageItems[this._currentPage].showId >= 0)))){
- if (this._imageItems[this._currentPage].contains(this._facepile)){
- try {
- this._imageItems[this._currentPage].removeChild(this._facepile);
- } catch(e) {
- trace(("Error: 1 ItemsContainer.showFacepile " + e));
- };
- };
- this._imageItems[this._currentPage].addChild(this._facepile);
- if ((((this._imageItems[this._currentPage].quickPlayerContainer == null)) && ((this._imageItems[this._currentPage].movieShowtimeContainer == null)))){
- try {
- if (this._imageItems[this._currentPage].videoId >= 0){
- _local2 = this._loaderFacepile.content;
- _local2["display"](this._imageItems[this._currentPage].videoId, "video");
- } else {
- _local2 = this._loaderFacepile.content;
- _local2["display"](this._imageItems[this._currentPage].showId, "show");
- };
- } catch(e) {
- trace(("Error: 2 ItemsContainer.showFacepile " + e));
- };
- };
- };
- this.layoutFacepile();
- };
- }
- protected function createObjects(itemsModel:Array){
- var obj:ImageItem;
- var i:* = 0;
- while (i < itemsModel.length) {
- obj = new ImageItem(this._controller, itemsModel[i], i);
- addChild(obj);
- this._imageItems.push(obj);
- i++;
- };
- }
- public function layoutItem(){
- var itemPerchWidth:Number = (this._imageItems[this._currentPage].width + this._style.Carousel.gutterWidth);
- this._imageItems[this._currentPage].x = this._style.Carousel.leftMargin;
- }
- public function layoutFacepile(){
- var widthImage:Number = Math.max(this._style.ImageItem.width, (this._controller.stageWidth - (this._style.Carousel.leftMargin * 2)));
- this._facepile.x = ((widthImage - this._style.ImageItem.width) / 2);
- this._facepile.y = (this._style.ImageItem.height - 55);
- }
- public function get imageItems(){
- return (this._imageItems);
- }
- public function userLogin(id:Number){
- var i:* = 0;
- var id:* = id;
- if (id < 0){
- this._showFacepile = false;
- if (this._facepile){
- i = 0;
- while (i < this._imageItems.length) {
- try {
- this._imageItems[i].removeChild(this._facepile);
- } catch(e) {
- trace(("Error: ItemsContainer.imageItems " + e));
- };
- i = (i + 1);
- };
- try {
- this._facepile.removeChild(this._loaderFacepile);
- } catch(e) {
- trace(("Error: ItemsContainer.imageItems " + e));
- };
- this._facepile = null;
- this._loaderFacepile = null;
- };
- this._isFacepileLoaded = false;
- } else {
- this._uid = ExternalInterface.call("Behaviors.getUserId");
- this._showFacepile = true;
- };
- }
- public function onResize(event:Event){
- this.layoutItem();
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- public dynamic class HideMoreButton extends MediumButton {
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.view {
- import flash.display.*;
- import flash.events.*;
- import fl.transitions.*;
- import com.hulu.masthead.model.*;
- import com.hulu.masthead.utils.*;
- import fl.motion.easing.*;
- import fl.transitions.easing.*;
- import flash.text.*;
- public class DetailsOverlay extends Sprite {
- public var _header:TextField;
- public var _caption:TextField;
- private var _watchButton:WatchButton;
- private var _logoImage:Sprite;
- private var _promotation:Sprite;
- private var _title:String;
- private var _description:String;
- private var _logoUrl:String;
- private var _xmlUrl:String;
- private var _style:Object;
- private var _isActive:Boolean;
- private var _container:HuluImageItem;
- private var _logoUnit:Sprite;
- private var _promotionUrl:String;
- private var _promotionLoaded:Boolean = false;
- private var _logoUnitOntop:Boolean = false;
- private var _ad:Object;
- public var _fadeInTween:Tween;
- public var _clickableLayerFadeInTween:Tween;
- public var showCallback:Function;
- public function DetailsOverlay(style:Object, container:HuluImageItem, title:String, description:String, logoUrl:String, promotionUrl:String, xmlUrl:String, ad:Object){
- super();
- this.visible = false;
- this._style = style;
- this._container = container;
- this._title = ((title) || (""));
- this._description = ((description) || (""));
- this._logoUrl = ((logoUrl) || (""));
- this._xmlUrl = ((xmlUrl) || (""));
- this._promotionUrl = ((promotionUrl) || (""));
- this._ad = ad;
- this.createObjects();
- this.layoutObjects(this._style.DetailsOverlay.logoTopMargin);
- }
- private function createObjects(){
- var salesLogo:* = null;
- var self:* = undefined;
- this._header.autoSize = "left";
- this._caption.autoSize = "left";
- this._header.setTextFormat(new TextFormat(null, this._style.DetailsOverlay.titleFontSize, null, true));
- this._caption.setTextFormat(new TextFormat(null, this._style.DetailsOverlay.captionFontSize, null, true));
- this._header.text = this._title;
- this._caption.text = this._description;
- this._header.cacheAsBitmap = true;
- this._caption.cacheAsBitmap = true;
- this._watchButton = new WatchButton();
- this._watchButton.light_mc.alpha = 0;
- this._logoImage = new Sprite();
- this._promotation = new Sprite();
- addChild(this._logoImage);
- addChild(this._promotation);
- addChild(this._watchButton);
- if (this._ad != null){
- this._isActive = true;
- this._logoUnit = new Sprite();
- this._logoUnit.graphics.beginFill(0, 0);
- this._logoUnit.graphics.drawRect(0, 0, this._style.DetailsOverlay.borderWidth, this._style.DetailsOverlay.salesLogoHeight);
- this._logoUnit.graphics.endFill();
- salesLogo = new CerebroSalesLogoUnit(this._container, this._ad, this.isActive, this.layoutObjects, this.moveUpLogoUnit, this._style.DetailsOverlay.logoTopMargin);
- this._logoUnit.addChild(salesLogo);
- this._logoImage.addChild(Utility.loadImage(this._logoUrl, this.loadSucceed, this.loadError));
- if (this._promotionUrl != ""){
- this._promotation.addChild(Utility.loadImage(this._promotionUrl, this.promotionLoaded, null));
- };
- if (!!(this._container.getItemData("sponsorTargetURL"))){
- if (!this._logoUnitOntop){
- this._logoUnitOntop = true;
- this._container.detatailsOverLayClickableLayer.addChild(this._logoUnit);
- };
- } else {
- if (!this._logoUnitOntop){
- addChild(this._logoUnit);
- };
- };
- this._container.onADDataReady();
- this.visible = true;
- } else {
- if (!this._xmlUrl){
- if (!this._logoUrl){
- this.visible = true;
- this.layoutObjects(this._style.DetailsOverlay.logoTopMargin);
- } else {
- this._logoImage.addChild(Utility.loadImage(this._logoUrl, this.loadSucceed, this.loadError));
- if (this._promotionUrl != ""){
- this._promotation.addChild(Utility.loadImage(this._promotionUrl, this.promotionLoaded, null));
- };
- };
- this._container.onADDataReady();
- } else {
- self = this;
- this._isActive = true;
- new MastheadXML(this._xmlUrl, function (model){
- var salesLogo:SalesLogoUnit;
- _logoUnit = new Sprite();
- _logoUnit.graphics.beginFill(0, 0);
- _logoUnit.graphics.drawRect(0, 0, _style.DetailsOverlay.borderWidth, _style.DetailsOverlay.salesLogoHeight);
- _logoUnit.graphics.endFill();
- if (((!(!(model))) && ((model.length > 0)))){
- salesLogo = new SalesLogoUnit(_container, model, self.isActive, self.layoutObjects, self.moveUpLogoUnit, _style.DetailsOverlay.logoTopMargin);
- _logoUnit.addChild(salesLogo);
- } else {
- _container.updateItemData("salesforcePlacementTag", null);
- _container.updateItemData("xmlUrl", null);
- };
- _logoImage.addChild(Utility.loadImage(_logoUrl, loadSucceed, loadError));
- if (_promotionUrl != ""){
- _promotation.addChild(Utility.loadImage(_promotionUrl, promotionLoaded, null));
- };
- if (!!(_container.getItemData("sponsorTargetURL"))){
- if (!_logoUnitOntop){
- _logoUnitOntop = true;
- _container.detatailsOverLayClickableLayer.addChild(_logoUnit);
- };
- } else {
- if (!_logoUnitOntop){
- self.addChild(_logoUnit);
- };
- };
- _container.onADDataReady();
- });
- this.visible = true;
- };
- };
- }
- private function promotionLoaded(e:Event):void{
- this._promotation.x = ((this._style.DetailsOverlay.borderWidth - this._promotation.width) / 2);
- this._promotation.y = this._style.DetailsOverlay.logoTopMargin;
- this._logoImage.y = ((this._promotation.y + this._promotation.height) + this._style.DetailsOverlay.promoPadding);
- this._promotionLoaded = true;
- if (((!(!(this._xmlUrl))) || (!((this._ad == null))))){
- this._logoUnit.y = (this._style.ImageItem.height - this._style.DetailsOverlay.salesLogoHeight);
- };
- this.layoutObjects(((this._logoImage.y + this._logoImage.height) + this._style.DetailsOverlay.logoHeaderMargin));
- }
- public function loadSucceed(event:Event){
- this._logoImage.x = ((this._style.DetailsOverlay.borderWidth - this._logoImage.width) / 2);
- this._logoImage.y = this._style.DetailsOverlay.logoTopMargin;
- if (this._promotionLoaded){
- this._logoImage.y = ((this._promotation.y + this._promotation.height) + this._style.DetailsOverlay.promoPadding);
- };
- if (((!(!(this._xmlUrl))) || (!((this._ad == null))))){
- this._logoUnit.y = (this._style.ImageItem.height - this._style.DetailsOverlay.salesLogoHeight);
- };
- this.layoutObjects(((this._logoImage.y + this._logoImage.height) + this._style.DetailsOverlay.logoHeaderMargin));
- this.visible = true;
- this.showCallback(null);
- }
- private function loadError(event:IOErrorEvent){
- if (((!(!(this._xmlUrl))) || (!((this._ad == null))))){
- this._logoUnit.y = (this._style.ImageItem.height - this._style.DetailsOverlay.salesLogoHeight);
- };
- this.layoutObjects(this._style.DetailsOverlay.logoTopMargin);
- this.visible = true;
- this.showCallback(null);
- }
- public function layoutObjects(ystart){
- this._header.y = ystart;
- this._caption.y = ((this._header.y + this._header.height) + this._style.DetailsOverlay.headerCaptionMargin);
- this._watchButton.y = ((this._caption.y + this._caption.height) + this._style.DetailsOverlay.captionWatchBtnMargin);
- if ((this._watchButton.y + this._watchButton.height) > this._style.ImageItem.height){
- this._watchButton.y = (this._style.ImageItem.height - this._watchButton.height);
- };
- this._watchButton.x = ((this.width - this._watchButton.width) - this._style.DetailsOverlay.watchBtnRightMargin);
- }
- public function fadeIn(isGradully:Boolean){
- if (isGradully){
- this._fadeInTween = new Tween(this, "alpha", Quartic.easeOut, alpha, 1, 120);
- if (!!(this._container.getItemData("sponsorTargetURL"))){
- this._clickableLayerFadeInTween = new Tween(this._container.detatailsOverLayClickableLayer, "alpha", Quartic.easeOut, alpha, 1, 120);
- };
- } else {
- this.alpha = 1;
- this._container.detatailsOverLayClickableLayer.alpha = 1;
- };
- this._isActive = true;
- }
- public function turnLight(){
- new Tween(this._watchButton.light_mc, "alpha", Back.easeOut, 0, 1, 12, false);
- }
- public function turnDark(){
- new Tween(this._watchButton.light_mc, "alpha", Back.easeOut, 1, 0, 12, false);
- }
- public function isActive(){
- return (this._isActive);
- }
- public function moveUpLogoUnit(){
- if (this._logoUnitOntop){
- return;
- };
- this._logoUnitOntop = true;
- if (this.contains(this._logoUnit)){
- this.removeChild(this._logoUnit);
- };
- this._container.detatailsOverLayClickableLayer.addChild(this._logoUnit);
- }
- public function deactive(){
- this._isActive = false;
- }
- public function get sponsorLogo():Sprite{
- return (this._logoUnit);
- }
- public function get sponsorBanner():SalesLogoUnit{
- if (this._logoUnit){
- if (this._logoUnit.numChildren > 0){
- if (this._logoUnit.getChildAt(0)){
- return ((this._logoUnit.getChildAt(0) as SalesLogoUnit));
- };
- };
- };
- return (null);
- }
- public function userLogin(id:Number){
- }
- }
- }//package com.hulu.masthead.view
- package com.hulu.masthead.utils {
- import flash.display.*;
- import flash.events.*;
- import flash.net.*;
- import fl.transitions.*;
- import flash.utils.*;
- import flash.system.*;
- public class Utility {
- private static var disableFSO:Boolean = false;
- public static function setTimeOut(func:Function, delay:Number){
- var repeatTime:Number = ((arguments[2]) || (1));
- var timer:Timer = new Timer(delay, repeatTime);
- timer.addEventListener("timer", func);
- timer.start();
- }
- public static function loadImage(url:String, init:Function, error:Function):Loader{
- var url:* = url;
- var init:* = init;
- var error:* = error;
- var request:* = new URLRequest(url);
- var loader:* = new Loader();
- try {
- if (((url) && ((url.indexOf(".swf") > 0)))){
- loader.load(new URLRequest(url), new LoaderContext(true, new ApplicationDomain()));
- } else {
- loader.load(request);
- };
- } catch(e) {
- trace(e);
- };
- if (init != null){
- loader.contentLoaderInfo.addEventListener(Event.COMPLETE, init);
- };
- if (error == null){
- error = function (event:IOErrorEvent){
- };
- };
- loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, error);
- loader.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, function (e){
- });
- loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function (e){
- });
- return (loader);
- }
- public static function tweenTo(myObject:Object, atrributeObj:Object, tween:Function, frame:Number, afterFun:Function){
- var i:*;
- var myTween:Tween;
- for (i in atrributeObj) {
- myTween = new Tween(myObject, i, tween, myObject[i], atrributeObj[i], frame, false);
- if (arguments[4]){
- myTween.addEventListener(TweenEvent.MOTION_FINISH, arguments[4]);
- };
- };
- }
- public static function smilHostFromClip(baseUrl:String):String{
- var hostArray:Array = baseUrl.split("/");
- var host = ([hostArray[0], hostArray[1], hostArray[2]].join("/") + "/");
- var smilHost:String = "";
- if (host.indexOf("file://") != -1){
- smilHost = "http://www.qa.hulu.com/";
- } else {
- if (((!((host.indexOf("www.hulu.com") == -1))) || (!((host.indexOf("origin-www.hulu.com") == -1))))){
- smilHost = "http://www.hulu.com/";
- } else {
- if (((((!((host.indexOf("staging.hulu.com") == -1))) || (!((host.indexOf("origin-qa-www.hulu.com") == -1))))) || (!((host.indexOf("www.qa.hulu.com") == -1))))){
- smilHost = "http://www.qa.hulu.com/";
- } else {
- smilHost = host;
- };
- };
- };
- return (smilHost);
- }
- public static function playerHostFromClip(baseUrl:String):String{
- var hostArray:Array = baseUrl.split("/");
- var host = ([hostArray[0], hostArray[1], hostArray[2]].join("/") + "/");
- var smilHost:String = "";
- if (((!((host.indexOf("file://") == -1))) || (!((host.indexOf("demo.staging.hulu.com") == -1))))){
- smilHost = "http://player.dev.hulu.com/";
- } else {
- if (((!((host.indexOf("www.hulu.com") == -1))) || (!((host.indexOf("origin-www.hulu.com") == -1))))){
- smilHost = "http://player.hulu.com/";
- } else {
- if (((((!((host.indexOf("staging.hulu.com") == -1))) || (!((host.indexOf("origin-qa-www.hulu.com") == -1))))) || (!((host.indexOf("www.qa.hulu.com") == -1))))){
- smilHost = "http://player.qa.hulu.com/";
- } else {
- smilHost = host;
- };
- };
- };
- return (smilHost);
- }
- public static function playerEnvFromClip(baseUrl:String):String{
- var hostArray:Array = baseUrl.split("/");
- var host = ([hostArray[0], hostArray[1], hostArray[2]].join("/") + "/");
- var env:String = "";
- if (((!((host.indexOf("file://") == -1))) || (!((host.indexOf("demo.staging.hulu.com") == -1))))){
- env = "dev";
- } else {
- if (((!((host.indexOf("www.hulu.com") == -1))) || (!((host.indexOf("origin-www.hulu.com") == -1))))){
- env = "prod";
- } else {
- if (((((!((host.indexOf("staging.hulu.com") == -1))) || (!((host.indexOf("origin-qa-www.hulu.com") == -1))))) || (!((host.indexOf("www.qa.hulu.com") == -1))))){
- env = "qa";
- } else {
- env = "prod";
- };
- };
- };
- return (env);
- }
- public static function getBeaconHost(baseUrl:String):String{
- if (baseUrl.indexOf("http://www.hulu.com") == 0){
- return ("http://t2.hulu.com/v3/siteinteraction");
- };
- return ("http://t2.qa.hulu.com/v3/siteinteraction");
- }
- public static function getBeaconParams(type:String, linkUrl:String, mastheadItemId:String, salesforceid:String):String{
- var type:* = type;
- var linkUrl:* = linkUrl;
- var mastheadItemId:* = mastheadItemId;
- var salesforceid:* = salesforceid;
- var param:* = [["param", type], ["target", linkUrl], ["computerguid", GUID.getComputerGuid()], ["cb", Math.random()]];
- if (((!(!(salesforceid))) && ((salesforceid.indexOf("http://") < 0)))){
- param.push(["salesforceid", escape(salesforceid)]);
- };
- if (!!(mastheadItemId)){
- param.push(["mastheaditemid", mastheadItemId]);
- };
- param.forEach(function (e, idx, arr){
- arr[idx] = e.join("=");
- });
- return (param.join("&"));
- }
- public static function deepCopy(source:Object){
- var myBA:ByteArray = new ByteArray();
- myBA.writeObject(source);
- myBA.position = 0;
- return (myBA.readObject());
- }
- public static function upidReplace(originalURL:String):String{
- return (originalURL.replace("${upid}", Math.random()));
- }
- public static function callService(url:String){
- var url:* = url;
- var loader:* = new URLLoader();
- var serviceRequest:* = new URLRequest(url);
- loader.addEventListener(IOErrorEvent.IO_ERROR, function (event:IOErrorEvent){
- trace(("ioErrorHandler: " + event));
- });
- loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function (event:SecurityErrorEvent){
- trace(("securityErrorHandler: " + event));
- });
- trace(("callService: " + url));
- try {
- loader.load(serviceRequest);
- } catch(error:Error) {
- trace(error);
- };
- }
- public static function callServiceAndRun(url:String, callback:Function){
- var url:* = url;
- var callback:* = callback;
- var loader:* = new URLLoader();
- var serviceRequest:* = new URLRequest(url);
- loader.addEventListener(IOErrorEvent.IO_ERROR, function (event:IOErrorEvent){
- trace(("ioErrorHandler: " + event));
- if (callback != null){
- callback();
- };
- });
- loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function (event:SecurityErrorEvent){
- trace(("securityErrorHandler: " + event));
- if (callback != null){
- callback();
- };
- });
- if (callback != null){
- loader.addEventListener(Event.OPEN, function (){
- callback();
- });
- };
- trace((("callServiceAndRun: " + url) + callback));
- try {
- loader.load(serviceRequest);
- } catch(error:Error) {
- trace(error);
- if (callback != null){
- callback();
- };
- };
- }
- public static function callServices(urls:Array, callback:Function){
- var url:* = null;
- var urls:* = urls;
- var callback:* = callback;
- if (urls.length > 0){
- url = urls.shift();
- callServiceAndRun(upidReplace(url), function (){
- callServices(urls, callback);
- });
- } else {
- callback();
- };
- }
- public static function saveFSO(objname:String, field:String, val:Object){
- var so:* = null;
- var objname:* = objname;
- var field:* = field;
- var val:* = val;
- if (disableFSO){
- return;
- };
- SharedObject.defaultObjectEncoding = ObjectEncoding.AMF0;
- try {
- so = SharedObject.getLocal(objname, "/");
- so.setProperty(field, val);
- so.flush();
- } catch(e) {
- disableFSO = true;
- };
- }
- }
- }//package com.hulu.masthead.utils
- package com.hulu.masthead.utils {
- import flash.net.*;
- import flash.system.*;
- public class GUID {
- public static var savedGUID:String;
- static var counter = 0;
- static var hexcase = 0;
- static var b64pad = "";
- static var chrsz = 8;
- public static function getNewGUID(){
- var _loc1:* = new Date();
- var _loc4:* = _loc1.getTime();
- var _loc3:* = (Math.random() * Number.MAX_VALUE);
- var _loc2:* = Capabilities.serverString;
- counter = ++GUID.counter;
- return (GUID.hex_md5((((_loc4 + _loc2) + _loc3) + GUID.counter)).toUpperCase());
- }
- public static function getComputerGuid(){
- var errorCode:* = undefined;
- var so:* = null;
- SharedObject.defaultObjectEncoding = ObjectEncoding.AMF0;
- errorCode = "00000000000000000000000000000000";
- try {
- if (!savedGUID){
- so = SharedObject.getLocal("BeaconService", "/");
- savedGUID = so.data["computerguid"];
- if (((!(savedGUID)) || (!((savedGUID.length == 32))))){
- savedGUID = GUID.getNewGUID();
- so.setProperty("computerguid", savedGUID);
- so.flush();
- };
- };
- } catch(e) {
- savedGUID = errorCode;
- };
- return (savedGUID);
- }
- static function hex_md5(s){
- return (GUID.binl2hex(GUID.core_md5(GUID.str2binl(s), (s.length * GUID.chrsz))));
- }
- static function b64_md5(s){
- return (GUID.binl2b64(GUID.core_md5(GUID.str2binl(s), (s.length * GUID.chrsz))));
- }
- static function str_md5(s){
- return (GUID.binl2str(GUID.core_md5(GUID.str2binl(s), (s.length * GUID.chrsz))));
- }
- static function hex_hmac_md5(key, data){
- return (GUID.binl2hex(GUID.core_hmac_md5(key, data)));
- }
- static function b64_hmac_md5(key, data){
- return (GUID.binl2b64(GUID.core_hmac_md5(key, data)));
- }
- static function str_hmac_md5(key, data){
- return (GUID.binl2str(GUID.core_hmac_md5(key, data)));
- }
- static function md5_vm_test(){
- return ((GUID.hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"));
- }
- static function core_md5(x, len){
- var _loc10:*;
- var _loc9:*;
- var _loc8:*;
- var _loc7:*;
- x[(len >> 5)] = (x[(len >> 5)] | (128 << (len % 32)));
- x[((((len + 64) >>> 9) << 4) + 14)] = len;
- var _loc4:* = 1732584193;
- var _loc3:* = -271733879;
- var _loc2:* = -1732584194;
- var _loc1:* = 271733878;
- var _loc5:* = 0;
- while (_loc5 < x.length) {
- _loc10 = _loc4;
- _loc9 = _loc3;
- _loc8 = _loc2;
- _loc7 = _loc1;
- _loc4 = GUID.md5_ff(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 0)], 7, -680876936);
- _loc1 = GUID.md5_ff(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 1)], 12, -389564586);
- _loc2 = GUID.md5_ff(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 2)], 17, 606105819);
- _loc3 = GUID.md5_ff(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 3)], 22, -1044525330);
- _loc4 = GUID.md5_ff(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 4)], 7, -176418897);
- _loc1 = GUID.md5_ff(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 5)], 12, 1200080426);
- _loc2 = GUID.md5_ff(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 6)], 17, -1473231341);
- _loc3 = GUID.md5_ff(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 7)], 22, -45705983);
- _loc4 = GUID.md5_ff(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 8)], 7, 1770035416);
- _loc1 = GUID.md5_ff(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 9)], 12, -1958414417);
- _loc2 = GUID.md5_ff(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 10)], 17, -42063);
- _loc3 = GUID.md5_ff(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 11)], 22, -1990404162);
- _loc4 = GUID.md5_ff(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 12)], 7, 1804603682);
- _loc1 = GUID.md5_ff(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 13)], 12, -40341101);
- _loc2 = GUID.md5_ff(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 14)], 17, -1502002290);
- _loc3 = GUID.md5_ff(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 15)], 22, 1236535329);
- _loc4 = GUID.md5_gg(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 1)], 5, -165796510);
- _loc1 = GUID.md5_gg(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 6)], 9, -1069501632);
- _loc2 = GUID.md5_gg(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 11)], 14, 643717713);
- _loc3 = GUID.md5_gg(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 0)], 20, -373897302);
- _loc4 = GUID.md5_gg(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 5)], 5, -701558691);
- _loc1 = GUID.md5_gg(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 10)], 9, 38016083);
- _loc2 = GUID.md5_gg(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 15)], 14, -660478335);
- _loc3 = GUID.md5_gg(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 4)], 20, -405537848);
- _loc4 = GUID.md5_gg(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 9)], 5, 568446438);
- _loc1 = GUID.md5_gg(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 14)], 9, -1019803690);
- _loc2 = GUID.md5_gg(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 3)], 14, -187363961);
- _loc3 = GUID.md5_gg(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 8)], 20, 1163531501);
- _loc4 = GUID.md5_gg(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 13)], 5, -1444681467);
- _loc1 = GUID.md5_gg(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 2)], 9, -51403784);
- _loc2 = GUID.md5_gg(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 7)], 14, 1735328473);
- _loc3 = GUID.md5_gg(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 12)], 20, -1926607734);
- _loc4 = GUID.md5_hh(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 5)], 4, -378558);
- _loc1 = GUID.md5_hh(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 8)], 11, -2022574463);
- _loc2 = GUID.md5_hh(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 11)], 16, 1839030562);
- _loc3 = GUID.md5_hh(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 14)], 23, -35309556);
- _loc4 = GUID.md5_hh(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 1)], 4, -1530992060);
- _loc1 = GUID.md5_hh(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 4)], 11, 1272893353);
- _loc2 = GUID.md5_hh(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 7)], 16, -155497632);
- _loc3 = GUID.md5_hh(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 10)], 23, -1094730640);
- _loc4 = GUID.md5_hh(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 13)], 4, 681279174);
- _loc1 = GUID.md5_hh(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 0)], 11, -358537222);
- _loc2 = GUID.md5_hh(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 3)], 16, -722521979);
- _loc3 = GUID.md5_hh(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 6)], 23, 76029189);
- _loc4 = GUID.md5_hh(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 9)], 4, -640364487);
- _loc1 = GUID.md5_hh(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 12)], 11, -421815835);
- _loc2 = GUID.md5_hh(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 15)], 16, 530742520);
- _loc3 = GUID.md5_hh(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 2)], 23, -995338651);
- _loc4 = GUID.md5_ii(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 0)], 6, -198630844);
- _loc1 = GUID.md5_ii(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 7)], 10, 1126891415);
- _loc2 = GUID.md5_ii(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 14)], 15, -1416354905);
- _loc3 = GUID.md5_ii(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 5)], 21, -57434055);
- _loc4 = GUID.md5_ii(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 12)], 6, 1700485571);
- _loc1 = GUID.md5_ii(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 3)], 10, -1894986606);
- _loc2 = GUID.md5_ii(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 10)], 15, -1051523);
- _loc3 = GUID.md5_ii(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 1)], 21, -2054922799);
- _loc4 = GUID.md5_ii(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 8)], 6, 1873313359);
- _loc1 = GUID.md5_ii(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 15)], 10, -30611744);
- _loc2 = GUID.md5_ii(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 6)], 15, -1560198380);
- _loc3 = GUID.md5_ii(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 13)], 21, 1309151649);
- _loc4 = GUID.md5_ii(_loc4, _loc3, _loc2, _loc1, x[(_loc5 + 4)], 6, -145523070);
- _loc1 = GUID.md5_ii(_loc1, _loc4, _loc3, _loc2, x[(_loc5 + 11)], 10, -1120210379);
- _loc2 = GUID.md5_ii(_loc2, _loc1, _loc4, _loc3, x[(_loc5 + 2)], 15, 718787259);
- _loc3 = GUID.md5_ii(_loc3, _loc2, _loc1, _loc4, x[(_loc5 + 9)], 21, -343485551);
- _loc4 = GUID.safe_add(_loc4, _loc10);
- _loc3 = GUID.safe_add(_loc3, _loc9);
- _loc2 = GUID.safe_add(_loc2, _loc8);
- _loc1 = GUID.safe_add(_loc1, _loc7);
- _loc5 = (_loc5 + 16);
- };
- return (new Array(_loc4, _loc3, _loc2, _loc1));
- }
- static function md5_cmn(q, a, b, x, s, t){
- return (GUID.safe_add(GUID.bit_rol(GUID.safe_add(GUID.safe_add(a, q), GUID.safe_add(x, t)), s), b));
- }
- static function md5_ff(a, b, c, d, x, s, t){
- return (GUID.md5_cmn(((b & c) | (b ^ (0xFFFFFED8 & d))), a, b, x, s, t));
- }
- static function md5_gg(a, b, c, d, x, s, t){
- return (GUID.md5_cmn(((b & d) | ((c & d) ^ 0xFFFFFED8)), a, b, x, s, t));
- }
- static function md5_hh(a, b, c, d, x, s, t){
- return (GUID.md5_cmn(((b ^ c) ^ d), a, b, x, s, t));
- }
- static function md5_ii(a, b, c, d, x, s, t){
- return (GUID.md5_cmn(((c ^ b) | (d ^ 0xFFFFFED8)), a, b, x, s, t));
- }
- static function core_hmac_md5(key, data){
- var _loc2:* = GUID.str2binl(key);
- if (_loc2.length > 16){
- _loc2 = GUID.core_md5(_loc2, (key.length * GUID.chrsz));
- };
- var _loc3:* = new Array(16);
- var _loc4:* = new Array(16);
- var _loc1:* = 0;
- while (_loc1 < 16) {
- _loc3[_loc1] = (_loc2[_loc1] ^ 0x36363636);
- _loc4[_loc1] = (_loc2[_loc1] ^ 0x5C5C5C5C);
- _loc1++;
- };
- var _loc5:* = GUID.core_md5(_loc3.concat(GUID.str2binl(data)), (0x0200 + (data.length * GUID.chrsz)));
- return (GUID.core_md5(_loc4.concat(_loc5), 640));
- }
- static function safe_add(x, y){
- var _loc1:* = ((x & 0xFFFF) + (y & 0xFFFF));
- var _loc2:* = (((x >> 16) + (y >> 16)) + (_loc1 >> 16));
- return (((_loc2 << 16) | (_loc1 & 0xFFFF)));
- }
- static function bit_rol(num, cnt){
- return (((num << cnt) | (num >>> (32 - cnt))));
- }
- static function str2binl(str){
- var _loc3:* = new Array();
- var _loc4:* = ((1 << GUID.chrsz) - 1);
- var _loc1:* = 0;
- while (_loc1 < (str.length * GUID.chrsz)) {
- _loc3[(_loc1 >> 5)] = (_loc3[(_loc1 >> 5)] | ((str.charCodeAt((_loc1 / GUID.chrsz)) & _loc4) << (_loc1 % 32)));
- _loc1 = (_loc1 + GUID.chrsz);
- };
- return (_loc3);
- }
- static function binl2str(bin){
- var _loc3:* = "";
- var _loc4:* = ((1 << GUID.chrsz) - 1);
- var _loc1:* = 0;
- while (_loc1 < (bin.length * 32)) {
- _loc3 = (_loc3 + String.fromCharCode(((bin[(_loc1 >> 5)] >>> (_loc1 % 32)) & _loc4)));
- _loc1 = (_loc1 + GUID.chrsz);
- };
- return (_loc3);
- }
- static function binl2hex(binarray){
- var _loc3:* = ((GUID.hexcase) ? "0123456789ABCDEF" : "0123456789abcdef");
- var _loc4:* = "";
- var _loc1:* = 0;
- while (_loc1 < (binarray.length * 4)) {
- _loc4 = (_loc4 + (_loc3.charAt(((binarray[(_loc1 >> 2)] >> (((_loc1 % 4) * 8) + 4)) & 15)) + _loc3.charAt(((binarray[(_loc1 >> 2)] >> ((_loc1 % 4) * 8)) & 15))));
- _loc1++;
- };
- return (_loc4);
- }
- static function binl2b64(binarray){
- var _loc5:*;
- var _loc1:*;
- var _loc6:* = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
- var _loc4:* = "";
- var _loc2:* = 0;
- while (_loc2 < (binarray.length * 4)) {
- _loc5 = (((((binarray[(_loc2 >> 2)] >> (8 * (_loc2 % 4))) & 0xFF) << 16) | (((binarray[((_loc2 + 1) >> 2)] >> (8 * ((_loc2 + 1) % 4))) & 0xFF) << 8)) | ((binarray[((_loc2 + 2) >> 2)] >> (8 * ((_loc2 + 2) % 4))) & 0xFF));
- _loc1 = 0;
- while (_loc1 < 4) {
- if (((_loc2 * 8) + (_loc1 * 6)) > (binarray.length * 32)){
- _loc4 = (_loc4 + GUID.b64pad);
- } else {
- _loc4 = (_loc4 + _loc6.charAt(((_loc5 >> (6 * (3 - _loc1))) & 63)));
- };
- _loc1++;
- };
- _loc2 = (_loc2 + 3);
- };
- return (_loc4);
- }
- }
- }//package com.hulu.masthead.utils
- package com.hulu.masthead.controller {
- import flash.display.*;
- import flash.events.*;
- import com.adobe.serialization.json.*;
- import flash.net.*;
- import fl.transitions.*;
- import com.hulu.masthead.view.*;
- import com.hulu.masthead.model.*;
- import flash.utils.*;
- import com.hulu.masthead.utils.*;
- import fl.motion.easing.*;
- import flash.external.*;
- public class HuluCarousel extends Carousel {
- public static var SCROLL_INTERVAL = 15000;
- private var _animationTween1:Tween;
- private var _animationTween2:Tween;
- private var _animationTween3:Tween;
- private var _animationTween4:Tween;
- private var _extraImage:HuluImageItem;
- private var _currentVideoEid:String;
- public var autoScrollCounter:Array;
- private var dataType:Array;
- public function HuluCarousel(stage:Sprite, style:Object){
- this.autoScrollCounter = [];
- this.dataType = ["backgroundUrl", "description", "logoUrl", "imageUrl", "linkUrl", "title", "backgroundColor", "embed", "moreDescription", "moreLogoURL", "salesforcePlacementTag", "watchPageURL", "type", "collection_id", "playlist_id", "fsoName", "copyrightInfo", "showtime_movie_ids", "promotionBannerUrl", "mastheadItemId", "videoId", "showId"];
- _section = ((stage.loaderInfo.parameters["section"])!=undefined) ? true : false;
- super(stage, style);
- }
- override protected function setStageModel(){
- _stageWidth = Math.max(_stage.stage.stageWidth, _style.Carousel.width);
- _zeroOffset = ((_stage.stage.stageWidth - _style.Carousel.width) / 2);
- _stageWidth = (_oldWidth = _stage.stage.stageWidth);
- _stage.x = -(_zeroOffset);
- _stage.stage.scaleMode = StageScaleMode.NO_SCALE;
- _stage.addEventListener("imageResizeFinish", this.resize);
- _stage.addEventListener("stopAutoScroll", this.stopAutoScroll);
- _stage.stage.addEventListener(Event.RESIZE, this.onResize);
- this.onResize(null);
- }
- private function getFeedbackInfoFromFSO(so:SharedObject, userId:Number):String{
- var queue:Array;
- var a:Array;
- var o:Object;
- var info:Object = so.data["userAdFeedback"];
- if (((!((info == null))) && (!((info[userId] == null))))){
- queue = info[userId];
- a = new Array();
- for each (o in queue) {
- a.push(((o.id + ",") + o.score));
- };
- return (a.join("|"));
- };
- return ("");
- }
- private function getUserAdState(so:SharedObject, userId:Number):String{
- var info:Object = so.data["userAdState"];
- if (((!((info == null))) && (!((info[userId] == null))))){
- return (info[userId]);
- };
- return ("");
- }
- private function getEnvironment():String{
- if (ExternalInterface.call("function(){ return window.location.hostname;}") == "www.hulu.com"){
- return ("prod");
- };
- trace("qa");
- return ("qa");
- }
- private function getSiteSharedObject():SharedObject{
- SharedObject.defaultObjectEncoding = ObjectEncoding.AMF0;
- var so:SharedObject = SharedObject.getLocal("NewSitePlayer", "/");
- so.objectEncoding = ObjectEncoding.AMF0;
- return (so);
- }
- private function getQueryStringParameters():Object{
- var parameterSplit:*;
- var parameter:String;
- var queryStringParameters:Object = {};
- var queryString:String = ExternalInterface.call("function(){ return window.location.search.substring(1);}");
- if (queryString != null){
- for each (parameter in queryString.split("&")) {
- parameter = parameter.replace(/^\s+|\s+$/gs, "");
- parameterSplit = parameter.split("=");
- queryStringParameters[unescape(parameterSplit[0])] = unescape(parameterSplit[1]);
- };
- };
- return (queryStringParameters);
- }
- private function constructCerebroMastheadRequest(){
- var queryStringParameters:Object;
- var mastheadRequestXML:XML = new XML("<AdRequest></AdRequest>");
- var distributor:XMLList = new XMLList("<Distributor></Distributor>");
- var visitor:XMLList = new XMLList("<Visitor></Visitor>");
- var keyValues:XMLList = new XMLList("<KeyValues></KeyValues>");
- var siteLocation:XMLList = new XMLList("<SiteLocation><VideoPlayer><VideoAsset></VideoAsset></VideoPlayer></SiteLocation>");
- var diagnostics:XMLList = new XMLList("<Diagnostics></Diagnostics>");
- var currentUserConfig:UserConfig = UserConfig.getInstance();
- mastheadRequestXML.@Pod = 0;
- mastheadRequestXML.@ResponseType = "JSON";
- distributor.@Name = "hulu";
- distributor.@Platform = "hulu";
- visitor.@ComputerGuid = GUID.getComputerGuid();
- visitor.@PlanId = (currentUserConfig.getPlanId() as Number);
- var userId:Number = (currentUserConfig.getUserId() as Number);
- visitor.@UserId = userId;
- var so:SharedObject = this.getSiteSharedObject();
- visitor.@State = this.getUserAdState(so, userId);
- visitor.@AdFeedback = this.getFeedbackInfoFromFSO(so, userId);
- siteLocation.@Path = ("/Masthead/" + TYPE);
- var environment:String = this.getEnvironment();
- keyValues.appendChild(new XML((("<KeyValue Key=\"env\" Value=\"" + environment) + "\"></KeyValue>")));
- keyValues.appendChild(new XML("<KeyValue Key=\"version\" Value=\"Voltron\"></KeyValue>"));
- mastheadRequestXML.appendChild(distributor);
- mastheadRequestXML.appendChild(visitor);
- mastheadRequestXML.appendChild(keyValues);
- mastheadRequestXML.appendChild(siteLocation);
- if (environment != "prod"){
- queryStringParameters = this.getQueryStringParameters();
- if (queryStringParameters["overrideMastheadItems"] != null){
- diagnostics.@MastheadItemIds = queryStringParameters["overrideMastheadItems"];
- };
- if (queryStringParameters["overrideAdUnits"] != null){
- diagnostics.@AdUnitIds = queryStringParameters["overrideAdUnits"];
- };
- mastheadRequestXML.appendChild(diagnostics);
- };
- _urlRequest = new URLRequest("http://p.hulu.com/masthead");
- _urlRequest.data = mastheadRequestXML;
- _urlRequest.method = URLRequestMethod.POST;
- }
- override protected function attachEvents(){
- var url:* = null;
- var pageURL:* = null;
- _smilHost = Utility.smilHostFromClip(_stage.loaderInfo.url);
- AS3QuickPlayer.playerHost = _smilHost;
- MovieShowTimeContainer.playerenv = (AS3QuickPlayer.playerEnv = Utility.playerEnvFromClip(_stage.loaderInfo.url));
- ExternalInterface.addCallback("getTime", this.getTime);
- ExternalInterface.addCallback("stopAnimation", this.stopAnimation);
- ExternalInterface.addCallback("startAnimation", this.switchNextAutomatic);
- ExternalInterface.addCallback("userLogin", this.userLogin);
- if (_section){
- TYPE = ((_stage.loaderInfo.parameters["section"]) || ("home"));
- if (_stage.loaderInfo.parameters["useCerebro"] == "true"){
- this.constructCerebroMastheadRequest();
- } else {
- url = _smilHost;
- url = (url + "home/featured");
- if (_stage.loaderInfo.parameters["section"]){
- url = (url + ("/" + _stage.loaderInfo.parameters["section"]));
- };
- if (_stage.loaderInfo.parameters["local"] != null){
- url = _stage.loaderInfo.parameters["local"];
- };
- if (UserConfig.getInstance().isPlusUser()){
- url = (url + "?p=1");
- };
- _urlRequest = new URLRequest(url);
- };
- _urlLoader = new URLLoader();
- _urlLoader.addEventListener(Event.COMPLETE, this.onComplete);
- _urlLoader.addEventListener(IOErrorEvent.IO_ERROR, this.onError);
- _urlLoader.addEventListener(NetStatusEvent.NET_STATUS, function (e){
- });
- _urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function (e){
- });
- try {
- _urlLoader.load(_urlRequest);
- } catch(error) {
- };
- ExternalInterface.call("ready");
- ExternalInterface.call("Masthead.ready");
- } else {
- pageURL = String(ExternalInterface.call("function(){ return location.href || window.location.href;}"));
- if (pageURL.indexOf("http://") == 0){
- TYPE = ((pageURL.split("http://")[1].split("/")[1]) || ("home"));
- if (TYPE){
- TYPE = TYPE.split("?")[0];
- };
- } else {
- if (pageURL.indexOf("https://") == 0){
- TYPE = ((pageURL.split("https://")[1].split("/")[1]) || ("home"));
- if (TYPE){
- TYPE = TYPE.split("?")[0];
- };
- };
- };
- super.attachEvents();
- };
- if (TYPE != null){
- TYPE = TYPE.replace("/", "");
- };
- _stage.stage.addEventListener(Event.MOUSE_LEAVE, this.onMouseLeave);
- }
- private function onMouseLeave(event:Event){
- this.observeMouseMove(false);
- _stage.stage.addEventListener(MouseEvent.MOUSE_OVER, this.onMouseOver);
- }
- public function onMouseOver(event:Event){
- _stage.stage.removeEventListener(MouseEvent.MOUSE_OVER, this.onMouseOver);
- if (!this.checkMousePos(null)){
- this.observeMouseMove(true);
- };
- }
- private function checkMousePos(event:MouseEvent){
- if (_stage.stage.mouseY > 130){
- this.observeMouseMove(false);
- if (_stage.stage.mouseY < _stage.stage.height){
- if (ExternalInterface.available){
- ExternalInterface.call("ChannelDock.close");
- };
- };
- } else {
- return (false);
- };
- return (true);
- }
- public function observeMouseMove(val:Boolean){
- if (val){
- if (!_stage.stage.hasEventListener(MouseEvent.MOUSE_MOVE)){
- _stage.stage.addEventListener(MouseEvent.MOUSE_MOVE, this.checkMousePos);
- };
- } else {
- if (_stage.stage.hasEventListener(MouseEvent.MOUSE_MOVE)){
- _stage.stage.removeEventListener(MouseEvent.MOUSE_MOVE, this.checkMousePos);
- };
- };
- }
- private function flushFSO(fso:SharedObject):void{
- var fso:* = fso;
- try {
- fso.flush();
- } catch(e) {
- };
- }
- private function verifyItemByFsoName(item:Object):Boolean{
- var fsoName:* = undefined;
- var fso:* = undefined;
- var now:* = NaN;
- var token_birth:* = NaN;
- var MAX_TOKEN_LIFE:* = NaN;
- var userId:* = NaN;
- var fsoType:* = null;
- var token_life:* = NaN;
- var item:* = item;
- if (item.hasOwnProperty("fsoName")){
- fsoName = item.fsoName.toUpperCase();
- fso = SharedObject.getLocal(fsoName, "/");
- now = new Date().valueOf();
- token_birth = Number(fso.data.token_birth);
- if (fsoName == "FPT"){
- MAX_TOKEN_LIFE = (((48 * 60) * 60) * 1000);
- if (((!(isNaN(token_birth))) && (((now - token_birth) < MAX_TOKEN_LIFE)))){
- return (true);
- };
- } else {
- if (fsoName.indexOf("USER_CAP_") != -1){
- trace(("verifyItemByFsoName USER_CAP_ " + [UserConfig.getInstance().isUserLoggedIn]));
- userId = UserConfig.getInstance().getUserId();
- fsoType = fsoName.split("_CAP_")[1].split("_")[0];
- token_life = ((((Number(fsoName.split("_CAP_")[1].split("_")[1]) * 24) * 60) * 60) * 1000);
- trace(("verifyItemByFsoName userId " + [fso.data[userId]]));
- if (fso.data.hasOwnProperty(userId)){
- trace("1");
- if (fso.data[userId].hasOwnProperty(fsoType)){
- trace("2");
- token_birth = Number(fso.data[userId][fsoType].token_birth);
- if (((!(isNaN(token_birth))) && (((now - token_birth) > token_life)))){
- trace("3");
- fso.data[userId][fsoType].token_birth = now;
- this.flushFSO(fso);
- return (true);
- };
- trace("4");
- return (false);
- var _slot1:* = e;
- trace("5");
- fso.data[userId][fsoType].token_birth = now;
- flushFSO(fso);
- return (true);
- };
- trace("6");
- fso.data[userId][fsoType] = {};
- fso.data[userId][fsoType].token_birth = now;
- this.flushFSO(fso);
- return (true);
- };
- trace("7");
- trace("verifyItemByFsoName -- no user id");
- fso.data[userId] = {};
- fso.data[userId][fsoType] = {};
- fso.data[userId][fsoType].token_birth = now;
- this.flushFSO(fso);
- return (true);
- };
- };
- return (false);
- };
- return (true);
- }
- private function verifyItems(itemsModel:Array):Array{
- var item:Object;
- var lowerCaseType:String;
- var res:Array = [];
- var i:int;
- while (i < itemsModel.length) {
- item = itemsModel[i];
- if (!item.hasOwnProperty("type")){
- item["type"] = "default";
- };
- if ((((item.swfType == "AnimatedSwf")) && ((item.imageUrl == null)))){
- } else {
- if (!this.verifyItemByFsoName(item)){
- } else {
- if (!this.verifyItembyLinkURL(item.linkUrl)){
- } else {
- lowerCaseType = item.type.toLowerCase();
- if (lowerCaseType == "recommendation"){
- res.push(item);
- } else {
- if (lowerCaseType == "collection"){
- if (item.hasOwnProperty("collection_id")){
- res.push(item);
- };
- } else {
- if (lowerCaseType == "playlist"){
- if (item.hasOwnProperty("playlist_id")){
- res.push(item);
- };
- } else {
- res.push(item);
- };
- };
- };
- };
- };
- };
- i++;
- };
- return (res);
- }
- private function verifyItembyLinkURL(linkURL:String):Boolean{
- var linkURL:* = linkURL;
- if (((ExternalInterface.available) && (!((linkURL == null))))){
- return (!(ExternalInterface.call("isIgnoredMasthead", linkURL)));
- var _slot1:* = e;
- };
- return (true);
- }
- private function regularItems(itemsModel:Array){
- var item:Object;
- var url:String;
- var baseURL:String;
- var i:int;
- while (i < itemsModel.length) {
- item = itemsModel[i];
- if (!item.hasOwnProperty("type")){
- item["type"] = "default";
- };
- url = stage.loaderInfo.url;
- baseURL = url.substr(0, url.search(/\/[^\/]*\.swf/));
- trace(("HuluCarousel.regularItems: " + item.type));
- switch (item.type.toLowerCase()){
- case "recommendation":
- item.imageUrl = (baseURL + "/ShowRecommendation.swf");
- item.swfType = "ShowRecommendation";
- break;
- case "collection":
- item.imageUrl = (baseURL + "/VideoRecommendationV2.swf");
- item.swfType = "VideoRecommendation";
- break;
- case "playlist":
- item.imageUrl = (baseURL + "/VideoRecommendationV3.swf");
- item.swfType = "VideoRecommendation";
- break;
- case "hollywood":
- item.imageUrl = (baseURL + "/HollywoodHeadlines.swf");
- item.swfType = "HollywoodHeadlines";
- break;
- case "hollywood_playlist":
- item.imageUrl = (baseURL + "/HollywoodHeadlinesV2.swf");
- item.swfType = "HollywoodHeadlines";
- break;
- case "animationswf":
- item.swfType = "AnimatedSwf";
- break;
- };
- i++;
- };
- return (itemsModel);
- }
- override protected function onComplete(event:Event){
- var str:* = undefined;
- var ary:* = null;
- var itemsModel:* = null;
- var i:* = undefined;
- var event:* = event;
- if (_stage.loaderInfo.parameters["useCerebro"] == "true"){
- this.onCompleteCerebro(event);
- } else {
- try {
- str = event.target.data.split(/Masthead\.update\s*\(\s*\[\s*\{\s*/)[1].split(/\s*\}\s*\]\s*\)/)[0];
- ary = str.split(/\}\s*,\s*\{/g);
- itemsModel = [];
- i = 0;
- while (i < ary.length) {
- itemsModel.push(this.stringToObject(ary[i]));
- i = (i + 1);
- };
- itemsModel = this.regularItems(itemsModel);
- itemsModel = this.verifyItems(itemsModel);
- super.addCarouselItem(itemsModel);
- this.preloadObjects(itemsModel);
- } catch(e) {
- trace(e.toString());
- };
- };
- }
- private function onCompleteCerebro(event:Event){
- var str:* = undefined;
- var ary:* = null;
- var itemsModel:* = null;
- var i:* = undefined;
- var event:* = event;
- try {
- str = event.target.data.split(/Masthead\.update\s*\(/)[1].split(/\)\s*;/)[0];
- ary = (JSON.decode(str, true) as Array);
- itemsModel = [];
- i = 0;
- while (i < ary.length) {
- itemsModel.push(this.postprocessMastheadItem(ary[i]));
- i = (i + 1);
- };
- itemsModel = this.regularItems(itemsModel);
- itemsModel = this.verifyItems(itemsModel);
- super.addCarouselItem(itemsModel);
- this.preloadObjects(itemsModel);
- } catch(e) {
- trace(e.toString());
- };
- }
- override protected function addCarouselItem(itemsModel:Array){
- itemsModel = this.regularItems(itemsModel);
- itemsModel = this.verifyItems(itemsModel);
- super.addCarouselItem(itemsModel);
- this.preloadObjects(itemsModel);
- }
- override protected function onError(error:IOErrorEvent){
- var error:* = error;
- var timer:* = new Timer(2000, 1);
- timer.addEventListener("timer", function (){
- try {
- _urlLoader.load(_urlRequest);
- } catch(error) {
- };
- });
- timer.start();
- }
- private function postprocessMastheadItem(mastheadItem:Object):Object{
- var index:Number;
- if (mastheadItem.hasOwnProperty("linkUrl")){
- index = mastheadItem["linkUrl"].indexOf("javascript:");
- if (index == 0){
- mastheadItem["jscall"] = mastheadItem["linkUrl"].substring(11);
- mastheadItem["linkUrl"] = "";
- };
- };
- var url:String = stage.loaderInfo.url;
- var baseURL:String = url.substr(0, url.search(/\/[^\/]*\.swf/));
- if (((((mastheadItem["linkUrl"]) && (!((mastheadItem["linkUrl"].substr(0, 7) == "http://"))))) && (!((mastheadItem["linkUrl"].substr(0, 8) == "https://"))))){
- mastheadItem["linkUrl"] = (baseURL + mastheadItem["linkUrl"]);
- };
- if (((((((mastheadItem["watchPageURL"]) && (!((mastheadItem["watchPageURL"].substr(0, 7) == "http://"))))) && (!((mastheadItem["linkUrl"].substr(0, 8) == "https://"))))) && (!(("null" == mastheadItem["watchPageURL"]))))){
- mastheadItem["watchPageURL"] = (baseURL + mastheadItem["watchPageURL"]);
- };
- return (mastheadItem);
- }
- private function stringToObject(str:String):Object{
- var d:* = undefined;
- var str:* = str;
- var unicodePattern:* = /\u([a-e,0-9,A-E]{1,4})/g;
- var escPattern:* = /\\([\",\\,\',n,t,r,b,f])/g;
- var unicodeRepFN:* = function (){
- return (String.fromCharCode(parseInt(("0x" + arguments[1]))));
- };
- var escRepFN:* = function (){
- switch (arguments[1]){
- case "n":
- return ("\n");
- case "t":
- return ("\t");
- case "r":
- return ("\r");
- case "f":
- return ("\f");
- case "b":
- return ("\b");
- default:
- return (arguments[1]);
- };
- };
- var obj:* = new Object();
- var ary:* = str.replace(/\\\"/g, "\\u0022").split("\"");
- var aryLength:* = (ary.length - 1);
- var i:* = 0;
- while (i < aryLength) {
- for each (d in this.dataType) {
- if (ary[i].indexOf(d) != -1){
- obj[d] = ary[(i + 1)];
- obj[d] = obj[d].replace(unicodePattern, unicodeRepFN).replace(escPattern, escRepFN);
- };
- };
- i = (i + 2);
- };
- this.postprocessMastheadItem(obj);
- return (obj);
- }
- override protected function checkItemLength(itemsModel:Array):Array{
- _totalItems = itemsModel.length;
- if ((((itemsModel.length == 2)) || ((itemsModel.length == 3)))){
- return (itemsModel.concat(itemsModel));
- };
- return (itemsModel);
- }
- override protected function createKeyArts(){
- _itemsContainer = new HuluItemsContainer(this);
- _imageItems = _itemsContainer.imageItems;
- _sliderControl = new HuluSliderControl(this, _stage);
- _sliderControl.addEventListener("stopAutoScroll", this.stopAutoScroll);
- }
- override protected function layoutObjects(){
- if (_loadingClip){
- layoutLoadingClip();
- };
- _itemDistance = Math.max(_style.ImageItem.width, (_stageWidth - (_style.SliderControl.buttonPaddingWidth * 2)));
- _background.width = _stage.stage.stageWidth;
- if (_foreground){
- _foreground.width = _stage.stage.stageWidth;
- };
- }
- override protected function addBackground(){
- _stageWidth = Math.max(_stage.stage.stageWidth, _style.Carousel.width);
- _background = new Sprite();
- _loadingClip = new LoadingImage();
- _stage.addChild(_background);
- layoutLoadingClip();
- var bg:ImageBackground = new ImageBackground();
- bg.height = _style.ImageItem.height;
- var grayStrip:GrayStrip = new GrayStrip();
- grayStrip.y = (_style.Carousel.height - grayStrip.height);
- _background.addChild(bg);
- _background.addChild(grayStrip);
- _background.width = _stage.stage.stageWidth;
- _stage.addChild(_loadingClip);
- }
- override protected function addForeground(){
- var topShadow:TopBottomShadow = new TopBottomShadow();
- var bottomShadow:TopBottomShadow = new TopBottomShadow();
- bottomShadow.rotation = 180;
- bottomShadow.y = (_style.Carousel.height - _style.Carousel.baseGradientHeight);
- bottomShadow.x = 1;
- _foreground.addChild(topShadow);
- _foreground.addChild(bottomShadow);
- _foreground.mouseEnabled = false;
- _foreground.mouseChildren = false;
- }
- override public function pageTo(id:Number, argu){
- if (_currentPage == id){
- return;
- };
- id = ((id + _totalPages) % _totalPages);
- var newNextItemId:Number = ((id + 1) % _totalPages);
- var newPrevItemId:Number = (((id - 1) + _totalPages) % _totalPages);
- var nextItemId:Number = ((_currentPage + 1) % _totalPages);
- var prevItemId:Number = (((_currentPage - 1) + _totalPages) % _totalPages);
- _imageItems[prevItemId].visible = (_imageItems[_currentPage].visible = (_imageItems[nextItemId].visible = false));
- _imageItems[newPrevItemId].visible = (_imageItems[id].visible = (_imageItems[newNextItemId].visible = true));
- _imageItems[_currentPage].dispatchEvent(new Event("imageAnimationStop"));
- if (this._extraImage){
- this._extraImage = null;
- };
- showItems(id);
- var currentX:Number = NaN;
- var direction:Number = ((argu) || (((id - _currentPage) / Math.abs((id - _currentPage)))));
- if (((!((this._animationTween1 == null))) && (this._animationTween1.isPlaying))){
- this._extraImage = _imageItems[(((id - (2 * direction)) + _totalPages) % _totalPages)];
- currentX = _imageItems[_currentPage].x;
- if (Math.abs(currentX) > (_style.Carousel.leftMargin + _itemDistance)){
- currentX = (currentX - (direction * _itemDistance));
- };
- this._animationTween1.fforward();
- this._animationTween2.fforward();
- this._animationTween3.fforward();
- if (this._animationTween4){
- this._animationTween4.fforward();
- };
- };
- if (currentX){
- _imageItems[id].x = (currentX + (_itemDistance * direction));
- this._extraImage.visible = true;
- this._extraImage.fadeOut(true);
- this._extraImage.x = (currentX - (direction * _itemDistance));
- } else {
- _imageItems[id].x = (_imageItems[_currentPage].x + (_itemDistance * direction));
- };
- _imageItems[newPrevItemId].x = (_imageItems[id].x - _itemDistance);
- _imageItems[newNextItemId].x = (_imageItems[id].x + _itemDistance);
- _imageItems[id].fadeIn(true);
- _imageItems[newNextItemId].fadeOut(true);
- _imageItems[newPrevItemId].fadeOut(true);
- if (((this._animationTween1) && (this._animationTween1.hasEventListener(TweenEvent.MOTION_FINISH)))){
- this._animationTween1.removeEventListener(TweenEvent.MOTION_FINISH, this.redraw);
- };
- this._animationTween1 = new Tween(_imageItems[id], "x", Quartic.easeOut, _imageItems[id].x, _style.Carousel.leftMargin, 45);
- this._animationTween2 = new Tween(_imageItems[newNextItemId], "x", Quartic.easeOut, _imageItems[newNextItemId].x, (_style.Carousel.leftMargin + _itemDistance), 45);
- this._animationTween3 = new Tween(_imageItems[newPrevItemId], "x", Quartic.easeOut, _imageItems[newPrevItemId].x, (_style.Carousel.leftMargin - _itemDistance), 45);
- if (this._extraImage){
- this._animationTween4 = new Tween(this._extraImage, "x", Quartic.easeOut, this._extraImage.x, (_style.Carousel.leftMargin - ((2 * _itemDistance) * direction)), 45);
- };
- _currentPage = id;
- this._animationTween1.addEventListener(TweenEvent.MOTION_FINISH, this.redraw);
- _sliderControl.dispatchEvent(new Event("resetJumpBtns"));
- }
- private function redraw(e:TweenEvent):void{
- _imageItems[_currentPage].redraw();
- }
- override public function switchNextAutomatic(){
- if (_intvAutoscroll != -1){
- clearInterval(_intvAutoscroll);
- };
- _intvAutoscroll = setInterval(function (){
- pageTo((_currentPage + 1), 1);
- }, SCROLL_INTERVAL);
- }
- override protected function stopAutoScroll(event:Event){
- if (_intvAutoscroll == -1){
- return;
- };
- clearInterval(_intvAutoscroll);
- _intvAutoscroll = -1;
- }
- public function stopAnimation(){
- this.stopAutoScroll(null);
- }
- private function onResize(event:Event){
- _newWidth = _stage.stage.stageWidth;
- _zeroOffset = (_zeroOffset + ((_newWidth - _oldWidth) / 2));
- _stage.x = -(_zeroOffset);
- _oldWidth = _newWidth;
- _stageWidth = Math.max(_newWidth, _style.Carousel.width);
- this.layoutObjects();
- _stage.dispatchEvent(new Event("stageResize"));
- }
- override protected function resize(event:Event){
- if (((this._animationTween1) && (this._animationTween1.isPlaying))){
- this._animationTween1.fforward();
- this._animationTween2.fforward();
- this._animationTween3.fforward();
- if (this._animationTween4){
- this._animationTween4.fforward();
- };
- };
- _sliderControl.dispatchEvent(new Event("resetJumpBtns"));
- var imageDistance:* = Math.max(_style.ImageItem.width, (_stageWidth - (_style.Carousel.leftMargin * 2)));
- _imageItems[_currentPage].x = _style.Carousel.leftMargin;
- _imageItems[((_currentPage + 1) % _totalPages)].x = (_imageItems[currentPage].x + imageDistance);
- _imageItems[(((_currentPage - 1) + _totalPages) % _totalPages)].x = (_imageItems[currentPage].x - imageDistance);
- }
- private function preloadObjects(itemsModel:Array):void{
- if (_itemsContainer){
- _itemsContainer.preloadObjects(itemsModel);
- };
- }
- }
- }//package com.hulu.masthead.controller
- package com.hulu.masthead.controller {
- import flash.display.*;
- import flash.events.*;
- import flash.net.*;
- import com.hulu.masthead.view.*;
- import flash.utils.*;
- import flash.external.*;
- public class Carousel {
- public static var TYPE:String;
- protected var _stage:Sprite;
- protected var _itemsContainer;
- protected var _sliderControl;
- protected var _background:Sprite;
- protected var _foreground:Sprite;
- protected var _loadingClip;
- protected var _imageItems:Array;
- protected var _imageMask:Sprite;
- protected var _style:Object;
- protected var _urlRequest:URLRequest;
- protected var _urlLoader:URLLoader;
- protected var _intvAutoscroll:Number = -1;
- protected var _intvReqJSON:Number = -1;
- protected var _section:Boolean;
- protected var _smilHost:String;
- protected var _currentPage:Number = 0;
- protected var _totalPages:Number = 5;
- protected var _stageWidth:Number;
- protected var _newWidth:Number;
- protected var _oldWidth:Number;
- protected var _zeroOffset:Number = 0;
- protected var _itemDistance:Number;
- protected var _totalItems:Number;
- public function Carousel(stage:Sprite, style:Object){
- super();
- this._stage = stage;
- this._style = style;
- this.addBackground();
- this.setStageModel();
- this.attachEvents();
- }
- protected function setStageModel(){
- }
- public function createObjects(){
- this.createKeyArts();
- this._foreground = new Sprite();
- this._stage.addChild(this._itemsContainer);
- this._stage.addChild(this._sliderControl);
- this._stage.addChild(this._foreground);
- this.addForeground();
- }
- protected function createKeyArts(){
- this._itemsContainer = new ItemsContainer(this);
- this._imageItems = this._itemsContainer.imageItems;
- this._sliderControl = new SliderControl(this, this._stage);
- }
- protected function addBackground(){
- }
- protected function addForeground(){
- }
- protected function layoutObjects(){
- }
- protected function layoutLoadingClip(){
- this._loadingClip.x = (this._style.Carousel.leftMargin + (this._stageWidth / 2));
- this._loadingClip.y = (this._style.Carousel.height / 2);
- }
- protected function attachEvents(){
- ExternalInterface.addCallback("getTime", this.getTime);
- ExternalInterface.addCallback("addCarouselItem", this.addCarouselItem);
- ExternalInterface.addCallback("userLogin", this.userLogin);
- if (ExternalInterface.available){
- ExternalInterface.call("ready");
- if (this._intvReqJSON != -1){
- clearInterval(this._intvReqJSON);
- this._intvReqJSON = -1;
- };
- ExternalInterface.call("Masthead.ready");
- this._intvReqJSON = setInterval(function (){
- ExternalInterface.call("Masthead.ready");
- }, 2000);
- };
- }
- protected function onComplete(event:Event){
- }
- protected function onError(event:IOErrorEvent){
- trace("load failed");
- }
- protected function addCarouselItem(itemsModel:Array){
- if ((((this._intvReqJSON == -1)) && ((this._section == false)))){
- return;
- };
- clearInterval(this._intvReqJSON);
- this._intvReqJSON = -1;
- if (this._loadingClip){
- this._stage.removeChild(this._loadingClip);
- this._loadingClip = null;
- };
- itemsModel = this.checkItemLength(itemsModel);
- this._totalPages = ((itemsModel.length - this._style.Carousel.visiblePages) + 1);
- this.createObjects();
- this.layoutObjects();
- this._itemsContainer.addItems(itemsModel);
- this.showItems(0);
- if (this._totalPages > 1){
- this.switchNextAutomatic();
- this._sliderControl.enable();
- } else {
- this._sliderControl.disable();
- };
- }
- protected function userLogin(id:Number=-1){
- if (this._imageItems == null){
- return;
- };
- var i:int;
- while (i < this._imageItems.length) {
- this._imageItems[i].userLogin(id);
- i++;
- };
- this._itemsContainer.userLogin(id);
- }
- protected function getTime(){
- var serverTimeLoader:* = new URLLoader();
- var request:* = new URLRequest(("http://assets.hulu.com/time?" + Math.random()));
- serverTimeLoader.addEventListener(Event.COMPLETE, this.completeHandler);
- serverTimeLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.securityErrorHandler);
- serverTimeLoader.addEventListener(IOErrorEvent.IO_ERROR, this.ioErrorHandler);
- try {
- serverTimeLoader.load(request);
- } catch(error:Error) {
- onServerTimeUnavailable();
- };
- }
- protected function onServerTimeUnavailable(){
- ExternalInterface.call("setServerTime", Math.round((new Date().getTime() / 1000)));
- }
- protected function completeHandler(event:Event):void{
- var loader:URLLoader = URLLoader(event.target);
- var serverTime:Number = parseInt(new XML(loader.data)["time"]);
- if (isNaN(serverTime)){
- this.onServerTimeUnavailable();
- } else {
- ExternalInterface.call("setServerTime", serverTime);
- };
- }
- protected function securityErrorHandler(event:SecurityErrorEvent):void{
- this.onServerTimeUnavailable();
- }
- protected function ioErrorHandler(event:IOErrorEvent):void{
- this.onServerTimeUnavailable();
- }
- protected function checkItemLength(itemsModel:Array):Array{
- this._totalItems = itemsModel.length;
- return (itemsModel);
- }
- public function showItems(startpage:Number){
- this._itemsContainer.show(startpage);
- }
- public function switchNextAutomatic(){
- }
- protected function stopAutoScroll(event:Event){
- }
- public function pageTo(id:Number, argu){
- if (this._currentPage == id){
- return;
- };
- trace(id);
- this._currentPage = id;
- }
- protected function resize(event:Event){
- }
- public function get style(){
- return (this._style);
- }
- public function get totalPages(){
- return (this._totalPages);
- }
- public function get zeroOffset(){
- return (this._zeroOffset);
- }
- public function get stageWidth(){
- return (this._stageWidth);
- }
- public function get stage(){
- return (this._stage);
- }
- public function get currentPage(){
- return (this._currentPage);
- }
- public function get intvAutoscroll(){
- return (this._intvAutoscroll);
- }
- public function get smilHost(){
- return (this._smilHost);
- }
- public function get totalItems(){
- return (this._totalItems);
- }
- }
- }//package com.hulu.masthead.controller
- package com.hulu.masthead.model {
- import flash.display.*;
- import flash.events.*;
- import flash.net.*;
- import flash.external.*;
- public class UserConfig extends Sprite {
- private static var _instance:UserConfig;
- private var _config:Object;
- private var _loader:URLLoader;
- public function UserConfig(){
- super();
- trace("UserConfig.UserConfig");
- this._config = null;
- }
- public static function getInstance():UserConfig{
- if (_instance == null){
- _instance = new (UserConfig)();
- };
- return (_instance);
- }
- public function loadUserConfig(){
- trace("UserConfig.loadUserConfig");
- var url:* = ("http://www.hulu.com/users/age_check/" + this.getUserId());
- var request:* = new URLRequest(url);
- if (this._loader != null){
- this._loader.close();
- this._loader.removeEventListener(IOErrorEvent.IO_ERROR, this.errorHandler);
- this._loader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, this.errorHandler);
- this._loader.removeEventListener(Event.COMPLETE, this.loaderCompleteHandler);
- };
- this._loader = new URLLoader();
- this._loader.addEventListener(IOErrorEvent.IO_ERROR, this.errorHandler);
- this._loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.errorHandler);
- this._loader.addEventListener(Event.COMPLETE, this.loaderCompleteHandler);
- try {
- this._loader.load(request);
- } catch(e) {
- errorHandler(null);
- };
- }
- private function errorHandler(e):void{
- trace("UserConfig.errorHandler");
- this._config = {ao:"not-ok"};
- dispatchEvent(new Event("userConfigReady"));
- }
- private function loaderCompleteHandler(event:Event):void{
- var xml:* = undefined;
- var event:* = event;
- trace(("UserConfig.loaderCompleteHandler " + this._loader.data));
- try {
- xml = new XML(this._loader.data);
- this._config = {};
- this._config.ao = xml["ao"];
- } catch(e:TypeError) {
- };
- dispatchEvent(new Event("userConfigReady"));
- }
- public function get userConfigAvailable():Boolean{
- return (!((this._config == null)));
- }
- public function get allowMatureContent():Boolean{
- if (this._config.ao == "ok"){
- return (true);
- };
- return (false);
- _slot1 = e;
- return (false);
- }
- public function get isUserLoggedIn():Boolean{
- return ((this.getUserId() > 0));
- }
- public function getUserId(){
- var uid:* = ExternalInterface.call("getUserId");
- if ((((typeof(uid) == "undefined")) || ((uid <= 0)))){
- uid = -1;
- };
- return (uid);
- }
- public function getPlanId(){
- var planId:* = ExternalInterface.call("getUserPlanId");
- if ((((typeof(planId) == "undefined")) || ((planId <= 0)))){
- planId = -1;
- };
- return (planId);
- }
- public function isPlusUser():Boolean{
- return (ExternalInterface.call("Behaviors.isPlusUser"));
- _slot1 = e;
- return (false);
- }
- }
- }//package com.hulu.masthead.model
- package com.hulu.masthead.model {
- public class CompanionItem {
- public var isMatureRated:Boolean;
- public var logoURL:String = "";
- public var watchNowOverride:String = null;
- public var width:Number = 185;
- public var height:Number = 50;
- public var impressionURLs:Array;
- public var clickThroughURLs:Array;
- public var sponsorTargetURL:String = "";
- public var placementId:String = "";
- public var targetingId:String = "";
- public var brandGroupId:String = null;
- public var duration:Number = -1;
- public function CompanionItem(xmlData:XML){
- var item:XML;
- var settingsList:XMLList;
- this.impressionURLs = [];
- this.clickThroughURLs = [];
- super();
- trace(("CompanionItem.CompanionItem " + xmlData["Settings"]));
- this.logoURL = ((this.logoURL) || (xmlData["URL"]));
- this.isMatureRated = false;
- if (((xmlData["Settings"]) && (xmlData["Settings"]["Rated"]))){
- if (xmlData["Settings"]["Rated"].toString().toLowerCase().indexOf("mature") != -1){
- this.isMatureRated = true;
- };
- };
- if (((xmlData["Settings"]) && (xmlData["Settings"].hasOwnProperty("BrandGroupId")))){
- this.brandGroupId = xmlData["Settings"]["BrandGroupId"];
- };
- if (((xmlData["Settings"]) && (xmlData["Settings"].hasOwnProperty("WatchNowOverride")))){
- trace("CompanionItem.CompanionItem 1");
- trace(xmlData["Settings"]["WatchNowOverride"]);
- this.watchNowOverride = xmlData["Settings"]["WatchNowOverride"];
- };
- this.width = ((xmlData.attribute("width")) || (this.width));
- this.height = ((xmlData.attribute("height")) || (this.height));
- if (xmlData["Impression"]){
- for each (item in xmlData["Impression"].children()) {
- this.impressionURLs.push(item.toString());
- };
- };
- if (xmlData["TrackingEvents"]){
- for each (item in xmlData["TrackingEvents"].children()) {
- if (((item["URL"]) && ((item["URL"].toString().indexOf("http") == 0)))){
- this.clickThroughURLs.push(item["URL"].toString());
- };
- };
- };
- if (xmlData["CompanionClickThrough"]){
- this.sponsorTargetURL = ((xmlData["CompanionClickThrough"]["URL"].toString()) || (this.sponsorTargetURL));
- };
- if (xmlData["Settings"]){
- settingsList = xmlData["Settings"];
- this.targetingId = ((settingsList["TargetingId"]) || (this.targetingId));
- this.placementId = ((settingsList["PlacementId"]) || (this.placementId));
- this.duration = ((parseFloat(settingsList["Rotation"])) || (this.duration));
- if (((UserConfig.getInstance().isPlusUser()) && (!(isNaN(parseFloat(settingsList["PlusRotation"])))))){
- this.duration = parseFloat(settingsList["PlusRotation"]);
- };
- };
- }
- }
- }//package com.hulu.masthead.model
- package com.hulu.masthead.model {
- public class Style {
- public static var Carousel:Object = {
- width:0,
- height:0,
- visiblePages:0,
- gutterWidth:0,
- leftMargin:0
- };
- public static var SliderControl:Object = {
- buttonPaddingWidth:0,
- buttonPaddingHeight:0,
- buttonLeftMargin:0,
- buttonHeaderMargin:0
- };
- public static var ImageItem:Object = {
- width:0,
- height:0
- };
- }
- }//package com.hulu.masthead.model
- package com.hulu.masthead.model {
- import flash.events.*;
- import flash.net.*;
- public class MastheadXML {
- private var _callback:Function;
- private var externalXML:XML;
- private var loader:URLLoader;
- public function MastheadXML(url:String, callback:Function){
- var url:* = url;
- var callback:* = callback;
- super();
- trace(("MastheadXML.MastheadXML " + url));
- this._callback = callback;
- var request:* = new URLRequest(url);
- this.loader = new URLLoader();
- try {
- this.loader.load(request);
- } catch(e) {
- errorHandler(null);
- };
- this.loader.addEventListener(IOErrorEvent.IO_ERROR, this.errorHandler);
- this.loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.errorHandler);
- this.loader.addEventListener(Event.COMPLETE, this.loaderCompleteHandler);
- }
- private function loaderCompleteHandler(event:Event):void{
- var event:* = event;
- try {
- this.externalXML = new XML(this.loader.data);
- this.readNodes(this.externalXML);
- } catch(e:TypeError) {
- trace(("Could not parse the XML file." + e));
- _callback(null);
- };
- }
- private function readNodes(node:XML):void{
- var item:* = null;
- var contentList:* = null;
- var companionItem:* = null;
- var node:* = node;
- try {
- contentList = node.Ad.InLine.CompanionAds.elements();
- } catch(e) {
- trace(e);
- };
- var companionItems:* = [];
- for each (item in contentList) {
- companionItem = new CompanionItem(item);
- if (companionItem.duration > 0){
- companionItems.push(companionItem);
- };
- };
- this._callback(companionItems);
- }
- private function errorHandler(e):void{
- trace("Could not access the XML file.");
- this._callback(null);
- }
- }
- }//package com.hulu.masthead.model
- package com.hulu.masthead.model {
- public final class HuluStyle extends Style {
- public var Carousel:Object;
- public var SliderControl:Object;
- public var ImageItem:Object;
- public var DetailsOverlay:Object;
- public var QuickPlayer:Object;
- public function HuluStyle(){
- this.Carousel = {
- width:920,
- height:377,
- visiblePages:1,
- gutterWidth:0,
- leftMargin:60,
- baseGradientHeight:27
- };
- this.SliderControl = {
- buttonPaddingWidth:60,
- buttonPaddingHeight:350,
- buttonLeftMargin:30,
- buttonHeaderMargin:175
- };
- this.ImageItem = {
- width:800,
- height:350,
- jumpBtnMargin:20
- };
- this.DetailsOverlay = {
- borderWidth:234,
- logoWidth:204,
- rightMargin:25,
- bottomMargin:25,
- logoTopMargin:25,
- logoLeftMargin:15,
- logoRightMargin:15,
- logoHeaderMargin:20,
- headerCaptionMargin:4,
- captionWatchBtnMargin:10,
- watchBtnRightMargin:15,
- textLeftMargin:24,
- textRightMargin:15,
- titleFontSize:15,
- captionFontSize:13,
- salesLogoHeight:60,
- promoPadding:5
- };
- this.QuickPlayer = {
- backgroundColor:0x222222,
- backgroundAlpha:0.9,
- playerWidth:0x0200,
- playerHeight:288,
- playerMarginBottom:34,
- playerMarginTop:20,
- closeBtnRightMargin:25,
- closeBtnTopMargin:10,
- playButtonWidth:94,
- playButtonHeight:82
- };
- super();
- }
- }
- }//package com.hulu.masthead.model
- package com.adobe.serialization.json {
- public class JSONToken {
- private var _type:int;
- private var _value:Object;
- public function JSONToken(type:int=-1, value:Object=null){
- super();
- this._type = type;
- this._value = value;
- }
- public function get type():int{
- return (this._type);
- }
- public function set type(value:int):void{
- this._type = value;
- }
- public function get value():Object{
- return (this._value);
- }
- public function set value(v:Object):void{
- this._value = v;
- }
- }
- }//package com.adobe.serialization.json
- package com.adobe.serialization.json {
- public class JSONDecoder {
- private var strict:Boolean;
- private var value;
- private var tokenizer:JSONTokenizer;
- private var token:JSONToken;
- public function JSONDecoder(s:String, strict:Boolean){
- super();
- this.strict = strict;
- this.tokenizer = new JSONTokenizer(s, strict);
- this.nextToken();
- this.value = this.parseValue();
- if (((strict) && (!((this.nextToken() == null))))){
- this.tokenizer.parseError("Unexpected characters left in input stream");
- };
- }
- public function getValue(){
- return (this.value);
- }
- private function nextToken():JSONToken{
- return ((this.token = this.tokenizer.getNextToken()));
- }
- private function parseArray():Array{
- var a:Array = new Array();
- this.nextToken();
- if (this.token.type == JSONTokenType.RIGHT_BRACKET){
- return (a);
- };
- if (((!(this.strict)) && ((this.token.type == JSONTokenType.COMMA)))){
- this.nextToken();
- if (this.token.type == JSONTokenType.RIGHT_BRACKET){
- return (a);
- };
- this.tokenizer.parseError(("Leading commas are not supported. Expecting ']' but found " + this.token.value));
- };
- a.push(this.parseValue());
- this.nextToken();
- if (this.token.type == JSONTokenType.RIGHT_BRACKET){
- return (a);
- };
- if (this.token.type == JSONTokenType.COMMA){
- this.nextToken();
- if (!this.strict){
- if (this.token.type == JSONTokenType.RIGHT_BRACKET){
- return (a);
- };
- };
- } else {
- this.tokenizer.parseError(("Expecting ] or , but found " + this.token.value));
- };
- //unresolved jump
- }
- private function parseObject():Object{
- var key:String;
- var o:Object = new Object();
- this.nextToken();
- if (this.token.type == JSONTokenType.RIGHT_BRACE){
- return (o);
- };
- if (((!(this.strict)) && ((this.token.type == JSONTokenType.COMMA)))){
- this.nextToken();
- if (this.token.type == JSONTokenType.RIGHT_BRACE){
- return (o);
- };
- this.tokenizer.parseError(("Leading commas are not supported. Expecting '}' but found " + this.token.value));
- };
- if (this.token.type == JSONTokenType.STRING){
- key = String(this.token.value);
- this.nextToken();
- if (this.token.type == JSONTokenType.COLON){
- this.nextToken();
- o[key] = this.parseValue();
- this.nextToken();
- if (this.token.type == JSONTokenType.RIGHT_BRACE){
- return (o);
- };
- if (this.token.type == JSONTokenType.COMMA){
- this.nextToken();
- if (!this.strict){
- if (this.token.type == JSONTokenType.RIGHT_BRACE){
- return (o);
- };
- };
- } else {
- this.tokenizer.parseError(("Expecting } or , but found " + this.token.value));
- };
- } else {
- this.tokenizer.parseError(("Expecting : but found " + this.token.value));
- };
- } else {
- this.tokenizer.parseError(("Expecting string but found " + this.token.value));
- };
- //unresolved jump
- }
- private function parseValue():Object{
- if (this.token == null){
- this.tokenizer.parseError("Unexpected end of input");
- };
- switch (this.token.type){
- case JSONTokenType.LEFT_BRACE:
- return (this.parseObject());
- case JSONTokenType.LEFT_BRACKET:
- return (this.parseArray());
- case JSONTokenType.STRING:
- case JSONTokenType.NUMBER:
- case JSONTokenType.TRUE:
- case JSONTokenType.FALSE:
- case JSONTokenType.NULL:
- return (this.token.value);
- case JSONTokenType.NAN:
- if (!this.strict){
- return (this.token.value);
- };
- this.tokenizer.parseError(("Unexpected " + this.token.value));
- default:
- this.tokenizer.parseError(("Unexpected " + this.token.value));
- };
- return (null);
- }
- }
- }//package com.adobe.serialization.json
- package com.adobe.serialization.json {
- public class JSONTokenType {
- public static const UNKNOWN:int = -1;
- public static const COMMA:int = 0;
- public static const LEFT_BRACE:int = 1;
- public static const RIGHT_BRACE:int = 2;
- public static const LEFT_BRACKET:int = 3;
- public static const RIGHT_BRACKET:int = 4;
- public static const COLON:int = 6;
- public static const TRUE:int = 7;
- public static const FALSE:int = 8;
- public static const NULL:int = 9;
- public static const STRING:int = 10;
- public static const NUMBER:int = 11;
- public static const NAN:int = 12;
- }
- }//package com.adobe.serialization.json
- package com.adobe.serialization.json {
- public class JSON {
- public static function encode(o:Object):String{
- return (new JSONEncoder(o).getString());
- }
- public static function decode(s:String, strict:Boolean=true){
- return (new JSONDecoder(s, strict).getValue());
- }
- }
- }//package com.adobe.serialization.json
- package com.adobe.serialization.json {
- import flash.utils.*;
- public class JSONEncoder {
- private var jsonString:String;
- public function JSONEncoder(value){
- super();
- this.jsonString = this.convertToString(value);
- }
- public function getString():String{
- return (this.jsonString);
- }
- private function convertToString(value):String{
- if ((value is String)){
- return (this.escapeString((value as String)));
- };
- if ((value is Number)){
- return (((isFinite((value as Number))) ? value.toString() : "null"));
- };
- if ((value is Boolean)){
- return (((value) ? "true" : "false"));
- };
- if ((value is Array)){
- return (this.arrayToString((value as Array)));
- };
- if ((((value is Object)) && (!((value == null))))){
- return (this.objectToString(value));
- };
- return ("null");
- }
- private function escapeString(str:String):String{
- var ch:String;
- var hexCode:String;
- var zeroPad:String;
- var s:String = "";
- var len:Number = str.length;
- var i:int;
- while (i < len) {
- ch = str.charAt(i);
- switch (ch){
- case "\"":
- s = (s + "\\\"");
- break;
- case "\\":
- s = (s + "\\\\");
- break;
- case "\b":
- s = (s + "\\b");
- break;
- case "\f":
- s = (s + "\\f");
- break;
- case "\n":
- s = (s + "\\n");
- break;
- case "\r":
- s = (s + "\\r");
- break;
- case "\t":
- s = (s + "\\t");
- break;
- default:
- if (ch < " "){
- hexCode = ch.charCodeAt(0).toString(16);
- zeroPad = (((hexCode.length == 2)) ? "00" : "000");
- s = (s + (("\\u" + zeroPad) + hexCode));
- } else {
- s = (s + ch);
- };
- };
- i++;
- };
- return ((("\"" + s) + "\""));
- }
- private function arrayToString(a:Array):String{
- var s:String = "";
- var i:int;
- while (i < a.length) {
- if (s.length > 0){
- s = (s + ",");
- };
- s = (s + this.convertToString(a[i]));
- i++;
- };
- return ((("[" + s) + "]"));
- }
- private function objectToString(o:Object):String{
- var value:* = null;
- var key:* = null;
- var v:* = null;
- var o:* = o;
- var s:* = "";
- var classInfo:* = describeType(o);
- if (classInfo.@name.toString() == "Object"){
- for (key in o) {
- value = o[key];
- if ((value is Function)){
- } else {
- if (s.length > 0){
- s = (s + ",");
- };
- s = (s + ((this.escapeString(key) + ":") + this.convertToString(value)));
- };
- };
- } else {
- var _local3:int;
- var _local6:int;
- var _local7:* = classInfo..*;
- var _local5 = new XMLList("");
- for each (var _local8 in classInfo..*) {
- var _local9 = _local8;
- with (_local9) {
- if ((((name() == "variable")) || ((((name() == "accessor")) && ((attribute("access").charAt(0) == "r")))))){
- _local5[_local6] = _local8;
- };
- };
- };
- var _local4:* = _local5;
- for each (v in _local5) {
- if (((v.metadata) && ((v.metadata.(@name == "Transient").length() > 0)))){
- } else {
- if (s.length > 0){
- s = (s + ",");
- };
- s = (s + ((this.escapeString(v.@name.toString()) + ":") + this.convertToString(o[v.@name])));
- };
- };
- };
- return ((("{" + s) + "}"));
- }
- }
- }//package com.adobe.serialization.json
- package com.adobe.serialization.json {
- public class JSONTokenizer {
- private var strict:Boolean;
- private var obj:Object;
- private var jsonString:String;
- private var loc:int;
- private var ch:String;
- private var controlCharsRegExp:RegExp;
- public function JSONTokenizer(s:String, strict:Boolean){
- this.controlCharsRegExp = /[\x00-\x1F]/;
- super();
- this.jsonString = s;
- this.strict = strict;
- this.loc = 0;
- this.nextChar();
- }
- public function getNextToken():JSONToken{
- var _local2:String;
- var _local3:String;
- var _local4:String;
- var _local5:String;
- var token:JSONToken = new JSONToken();
- this.skipIgnored();
- switch (this.ch){
- case "{":
- token.type = JSONTokenType.LEFT_BRACE;
- token.value = "{";
- this.nextChar();
- break;
- case "}":
- token.type = JSONTokenType.RIGHT_BRACE;
- token.value = "}";
- this.nextChar();
- break;
- case "[":
- token.type = JSONTokenType.LEFT_BRACKET;
- token.value = "[";
- this.nextChar();
- break;
- case "]":
- token.type = JSONTokenType.RIGHT_BRACKET;
- token.value = "]";
- this.nextChar();
- break;
- case ",":
- token.type = JSONTokenType.COMMA;
- token.value = ",";
- this.nextChar();
- break;
- case ":":
- token.type = JSONTokenType.COLON;
- token.value = ":";
- this.nextChar();
- break;
- case "t":
- _local2 = ((("t" + this.nextChar()) + this.nextChar()) + this.nextChar());
- if (_local2 == "true"){
- token.type = JSONTokenType.TRUE;
- token.value = true;
- this.nextChar();
- } else {
- this.parseError(("Expecting 'true' but found " + _local2));
- };
- break;
- case "f":
- _local3 = (((("f" + this.nextChar()) + this.nextChar()) + this.nextChar()) + this.nextChar());
- if (_local3 == "false"){
- token.type = JSONTokenType.FALSE;
- token.value = false;
- this.nextChar();
- } else {
- this.parseError(("Expecting 'false' but found " + _local3));
- };
- break;
- case "n":
- _local4 = ((("n" + this.nextChar()) + this.nextChar()) + this.nextChar());
- if (_local4 == "null"){
- token.type = JSONTokenType.NULL;
- token.value = null;
- this.nextChar();
- } else {
- this.parseError(("Expecting 'null' but found " + _local4));
- };
- break;
- case "N":
- _local5 = (("N" + this.nextChar()) + this.nextChar());
- if (_local5 == "NaN"){
- token.type = JSONTokenType.NAN;
- token.value = NaN;
- this.nextChar();
- } else {
- this.parseError(("Expecting 'NaN' but found " + _local5));
- };
- break;
- case "\"":
- token = this.readString();
- break;
- default:
- if (((this.isDigit(this.ch)) || ((this.ch == "-")))){
- token = this.readNumber();
- } else {
- if (this.ch == ""){
- return (null);
- };
- this.parseError((("Unexpected " + this.ch) + " encountered"));
- };
- };
- return (token);
- }
- private function readString():JSONToken{
- var backspaceCount:int;
- var backspaceIndex:int;
- var quoteIndex:int = this.loc;
- do {
- quoteIndex = this.jsonString.indexOf("\"", quoteIndex);
- if (quoteIndex >= 0){
- backspaceCount = 0;
- backspaceIndex = (quoteIndex - 1);
- while (this.jsonString.charAt(backspaceIndex) == "\\") {
- backspaceCount++;
- backspaceIndex--;
- };
- if ((backspaceCount % 2) == 0){
- break;
- };
- quoteIndex++;
- } else {
- this.parseError("Unterminated string literal");
- };
- } while (true);
- var token:JSONToken = new JSONToken();
- token.type = JSONTokenType.STRING;
- token.value = this.unescapeString(this.jsonString.substr(this.loc, (quoteIndex - this.loc)));
- this.loc = (quoteIndex + 1);
- this.nextChar();
- return (token);
- }
- public function unescapeString(input:String):String{
- var afterBackslashIndex:int;
- var escapedChar:String;
- var _local8:String;
- var i:int;
- var possibleHexChar:String;
- if (((this.strict) && (this.controlCharsRegExp.test(input)))){
- this.parseError("String contains unescaped control character (0x00-0x1F)");
- };
- var result:String = "";
- var backslashIndex:int;
- var nextSubstringStartPosition:int;
- var len:int = input.length;
- do {
- backslashIndex = input.indexOf("\\", nextSubstringStartPosition);
- if (backslashIndex >= 0){
- result = (result + input.substr(nextSubstringStartPosition, (backslashIndex - nextSubstringStartPosition)));
- nextSubstringStartPosition = (backslashIndex + 2);
- afterBackslashIndex = (backslashIndex + 1);
- escapedChar = input.charAt(afterBackslashIndex);
- switch (escapedChar){
- case "\"":
- result = (result + "\"");
- break;
- case "'":
- result = (result + "'");
- break;
- case "\\":
- result = (result + "\\");
- break;
- case "n":
- result = (result + "\n");
- break;
- case "r":
- result = (result + "\r");
- break;
- case "t":
- result = (result + "\t");
- break;
- case "u":
- _local8 = "";
- if ((nextSubstringStartPosition + 4) > len){
- this.parseError("Unexpected end of input. Expecting 4 hex digits after \\u.");
- };
- i = nextSubstringStartPosition;
- while (i < (nextSubstringStartPosition + 4)) {
- possibleHexChar = input.charAt(i);
- if (!this.isHexDigit(possibleHexChar)){
- this.parseError(("Excepted a hex digit, but found: " + possibleHexChar));
- };
- _local8 = (_local8 + possibleHexChar);
- i++;
- };
- result = (result + String.fromCharCode(parseInt(_local8, 16)));
- nextSubstringStartPosition = (nextSubstringStartPosition + 4);
- break;
- case "f":
- result = (result + "\f");
- break;
- case "/":
- result = (result + "/");
- break;
- case "b":
- result = (result + "\b");
- break;
- default:
- result = (result + ("\\" + escapedChar));
- };
- } else {
- result = (result + input.substr(nextSubstringStartPosition));
- break;
- };
- } while (nextSubstringStartPosition < len);
- return (result);
- }
- private function readNumber():JSONToken{
- var token:JSONToken;
- var input:String = "";
- if (this.ch == "-"){
- input = (input + "-");
- this.nextChar();
- };
- if (!this.isDigit(this.ch)){
- this.parseError("Expecting a digit");
- };
- if (this.ch == "0"){
- input = (input + this.ch);
- this.nextChar();
- if (this.isDigit(this.ch)){
- this.parseError("A digit cannot immediately follow 0");
- } else {
- if (((!(this.strict)) && ((this.ch == "x")))){
- input = (input + this.ch);
- this.nextChar();
- if (this.isHexDigit(this.ch)){
- input = (input + this.ch);
- this.nextChar();
- } else {
- this.parseError("Number in hex format require at least one hex digit after \"0x\"");
- };
- while (this.isHexDigit(this.ch)) {
- input = (input + this.ch);
- this.nextChar();
- };
- };
- };
- } else {
- while (this.isDigit(this.ch)) {
- input = (input + this.ch);
- this.nextChar();
- };
- };
- if (this.ch == "."){
- input = (input + ".");
- this.nextChar();
- if (!this.isDigit(this.ch)){
- this.parseError("Expecting a digit");
- };
- while (this.isDigit(this.ch)) {
- input = (input + this.ch);
- this.nextChar();
- };
- };
- if ((((this.ch == "e")) || ((this.ch == "E")))){
- input = (input + "e");
- this.nextChar();
- if ((((this.ch == "+")) || ((this.ch == "-")))){
- input = (input + this.ch);
- this.nextChar();
- };
- if (!this.isDigit(this.ch)){
- this.parseError("Scientific notation number needs exponent value");
- };
- while (this.isDigit(this.ch)) {
- input = (input + this.ch);
- this.nextChar();
- };
- };
- var num:Number = Number(input);
- if (((isFinite(num)) && (!(isNaN(num))))){
- token = new JSONToken();
- token.type = JSONTokenType.NUMBER;
- token.value = num;
- return (token);
- };
- this.parseError((("Number " + num) + " is not valid!"));
- return (null);
- }
- private function nextChar():String{
- return ((this.ch = this.jsonString.charAt(this.loc++)));
- }
- private function skipIgnored():void{
- var originalLoc:int;
- do {
- originalLoc = this.loc;
- this.skipWhite();
- this.skipComments();
- } while (originalLoc != this.loc);
- }
- private function skipComments():void{
- if (this.ch == "/"){
- this.nextChar();
- switch (this.ch){
- case "/":
- do {
- this.nextChar();
- } while (((!((this.ch == "\n"))) && (!((this.ch == "")))));
- this.nextChar();
- break;
- case "*":
- this.nextChar();
- while (true) {
- if (this.ch == "*"){
- this.nextChar();
- if (this.ch == "/"){
- this.nextChar();
- break;
- };
- } else {
- this.nextChar();
- };
- if (this.ch == ""){
- this.parseError("Multi-line comment not closed");
- };
- };
- break;
- default:
- this.parseError((("Unexpected " + this.ch) + " encountered (expecting '/' or '*' )"));
- };
- };
- }
- private function skipWhite():void{
- while (this.isWhiteSpace(this.ch)) {
- this.nextChar();
- };
- }
- private function isWhiteSpace(ch:String):Boolean{
- if ((((((((ch == " ")) || ((ch == "\t")))) || ((ch == "\n")))) || ((ch == "\r")))){
- return (true);
- };
- if (((!(this.strict)) && ((ch.charCodeAt(0) == 160)))){
- return (true);
- };
- return (false);
- }
- private function isDigit(ch:String):Boolean{
- return ((((ch >= "0")) && ((ch <= "9"))));
- }
- private function isHexDigit(ch:String):Boolean{
- return (((((this.isDigit(ch)) || ((((ch >= "A")) && ((ch <= "F")))))) || ((((ch >= "a")) && ((ch <= "f"))))));
- }
- public function parseError(message:String):void{
- throw (new JSONParseError(message, this.loc, this.jsonString));
- }
- }
- }//package com.adobe.serialization.json
- package com.adobe.serialization.json {
- public class JSONParseError extends Error {
- private var _location:int;
- private var _text:String;
- public function JSONParseError(message:String="", location:int=0, text:String=""){
- super(message);
- name = "JSONParseError";
- this._location = location;
- this._text = text;
- }
- public function get location():int{
- return (this._location);
- }
- public function get text():String{
- return (this._text);
- }
- }
- }//package com.adobe.serialization.json
- package {
- import flash.display.*;
- import flash.text.*;
- public dynamic class Copyright extends MovieClip {
- public var _tf:TextField;
- }
- }//package
- package {
- import flash.display.*;
- public dynamic class JumpButton extends MovieClip {
- public var light_mc:MovieClip;
- public var selectedMark:MovieClip;
- }
- }//package
- package hulu_masthead_fla {
- import flash.display.*;
- public dynamic class loading_18 extends MovieClip {
- public function loading_18(){
- addFrameScript(0, this.frame1);
- }
- function frame1(){
- stop();
- }
- }
- }//package hulu_masthead_fla
- package hulu_masthead_fla {
- import flash.display.*;
- public dynamic class line_20 extends MovieClip {
- public function line_20(){
- addFrameScript(0, this.frame1);
- }
- function frame1(){
- stop();
- }
- }
- }//package hulu_masthead_fla
- package {
- import flash.display.*;
- public dynamic class LeftArrowButton extends MovieClip {
- public var arrow_mc:MovieClip;
- }
- }//package
- package {
- import flash.display.*;
- public dynamic class CloseButton extends MovieClip {
- public var light_mc:MovieClip;
- }
- }//package
- package {
- import flash.text.*;
- public dynamic class Font1 extends Font {
- }
- }//package
- package {
- import flash.display.*;
- import com.hulu.masthead.model.*;
- import flash.system.*;
- import com.hulu.masthead.controller.*;
- public class HuluMasthead extends Sprite {
- public static var stage:Stage;
- private var _carousel:HuluCarousel = null;
- private var _style:HuluStyle;
- public function HuluMasthead(){
- this._style = new HuluStyle();
- super();
- Security.allowDomain("*");
- HuluMasthead.stage = this.stage;
- this._carousel = new HuluCarousel(this, this._style);
- }
- }
- }//package
- package {
- import flash.display.*;
- public dynamic class WatchButton extends MovieClip {
- public var light_mc:MovieClip;
- public function WatchButton(){
- addFrameScript(0, this.frame1);
- }
- function frame1(){
- stop();
- }
- }
- }//package
- package {
- import flash.display.*;
- public dynamic class LoadingImage extends MovieClip {
- public var clickArea:MovieClip;
- public function LoadingImage(){
- addFrameScript(0, this.frame1);
- }
- function frame1(){
- stop();
- }
- }
- }//package
- package {
- import flash.display.*;
- public dynamic class RightArrowButton extends MovieClip {
- public var arrow_mc:MovieClip;
- }
- }//package
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement