Section 1
//Game (com.novelgames.multiplayerflashgames.common.Game)
package com.novelgames.multiplayerflashgames.common {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.xml.*;
import flash.geom.*;
public class Game extends MovieClip {
private var synchronizeInfos:Object;
public static var main:MovieClip;
public static var gameStage:Stage;
private function addSynchronizeCount(_arg1:String, _arg2:int, _arg3:Array):void{
var _local4:int;
if (synchronizeInfos == null){
synchronizeInfos = new Object();
};
if (!synchronizeInfos[_arg1]){
synchronizeInfos[_arg1] = new Object();
synchronizeInfos[_arg1].parameters = new Array();
_local4 = 0;
while (_local4 < Object(parent).playerNames.length) {
synchronizeInfos[_arg1].parameters[_local4] = null;
_local4++;
};
};
synchronizeInfos[_arg1].parameters[_arg2] = _arg3;
checkSynchronized(_arg1);
}
public function onRightMouseDown():void{
var _local1:DisplayObject = getMouseTarget();
_local1.dispatchEvent(new MouseEvent("mouseRightDown"));
}
public function onRightMouseUp():void{
var _local1:DisplayObject = getMouseTarget();
_local1.dispatchEvent(new MouseEvent("mouseRightUp"));
}
public function receiveMessage(_arg1:String):void{
var _local3:String;
var _local4:int;
var _local5:XMLNode;
var _local6:XMLNode;
var _local2:XMLDocument = new XMLDocument();
var _local7:Array = new Array();
_local2.ignoreWhite = true;
_local2.parseXML(_arg1);
_local5 = _local2.firstChild;
if (_local5.nodeName == "CALLFUNCTION"){
_local3 = _local5.attributes.name;
_local6 = _local5.firstChild;
while (_local6) {
if (_local6.nodeName != "PARAMETER"){
} else {
if (_local6.attributes.type == "Number"){
_local7.push(Number(_local6.attributes.value));
} else {
_local7.push(_local6.attributes.value);
};
};
_local6 = _local6.nextSibling;
};
this[_local3].apply(this, _local7);
} else {
if (_local5.nodeName == "SYNCHRONIZE"){
_local3 = _local5.attributes.name;
_local4 = int(_local5.attributes.playerIndex);
_local6 = _local5.firstChild;
while (_local6) {
if (_local6.nodeName != "PARAMETER"){
} else {
if (_local6.attributes.type == "Number"){
_local7.push(Number(_local6.attributes.value));
} else {
_local7.push(_local6.attributes.value);
};
};
_local6 = _local6.nextSibling;
};
addSynchronizeCount(_local3, _local4, _local7);
};
};
}
public function startPlay(_arg1:Array, _arg2:int):void{
}
public function sendSynchronizeMessage(_arg1:String, ... _args):void{
var _local3:String;
var _local4:int;
_local3 = (((("<SYNCHRONIZE name=\"" + _arg1) + "\" playerIndex=\"") + Object(parent).selfIndex) + "\">");
_local4 = 0;
while (_local4 < _args.length) {
if (!(_args[_local4] is String)){
_local3 = (_local3 + (("<PARAMETER type=\"Number\" value=\"" + _args[_local4]) + "\" />"));
} else {
_local3 = (_local3 + (("<PARAMETER type=\"String\" value=\"" + htmlSpecialChars(_args[_local4])) + "\" />"));
};
_local4++;
};
_local3 = (_local3 + "</SYNCHRONIZE>");
Object(parent).sendMessage(_local3);
addSynchronizeCount(_arg1, Object(parent).selfIndex, _args);
}
public function startView(_arg1:Array):void{
}
private function checkSynchronized(_arg1:String):void{
var _local3:Boolean;
var _local4:int;
var _local5:int;
var _local2:Array = new Array();
_local4 = 0;
while (_local4 < Object(parent).playerNames.length) {
if (Object(parent).playerDisconnecteds[_local4]){
} else {
if (synchronizeInfos[_arg1].parameters[_local4] == null){
return;
};
};
_local4++;
};
_local3 = true;
_local4 = 0;
while (_local4 < synchronizeInfos[_arg1].parameters.length) {
if (Object(parent).playerDisconnecteds[_local4]){
} else {
if (synchronizeInfos[_arg1].parameters[_local4].length > 0){
_local5 = 0;
while (_local5 < synchronizeInfos[_arg1].parameters[_local4].length) {
_local2[_local5] = new Array();
_local5++;
};
_local3 = false;
break;
};
};
_local4++;
};
if (!_local3){
_local4 = 0;
while (_local4 < synchronizeInfos[_arg1].parameters.length) {
if (Object(parent).playerDisconnecteds[_local4]){
} else {
_local5 = 0;
while (_local5 < synchronizeInfos[_arg1].parameters[_local4].length) {
_local2[_local5][_local4] = synchronizeInfos[_arg1].parameters[_local4][_local5];
_local5++;
};
};
_local4++;
};
};
_local4 = 0;
while (_local4 < Object(parent).playerNames.length) {
synchronizeInfos[_arg1].parameters[_local4] = null;
_local4++;
};
this[_arg1].apply(this, _local2);
}
public function unpause():void{
NewTimer.unpause();
}
private function getMouseTarget():DisplayObject{
var _local1:Point = new Point(mouseX, mouseY);
var _local2:Array = this.getObjectsUnderPoint(_local1);
return (_local2[(_local2.length - 1)]);
}
public function startReceivingMessages():void{
Object(parent).startReceivingMessages();
}
public function onMiddleMouseDown():void{
var _local1:DisplayObject = getMouseTarget();
_local1.dispatchEvent(new MouseEvent("mouseMiddleDown"));
}
public function normalizeNumber(_arg1:Number):Number{
return (Number(_arg1.toString()));
}
public function stopReceivingMessages():void{
Object(parent).stopReceivingMessages();
}
public function onMiddleMouseUp():void{
var _local1:DisplayObject = getMouseTarget();
_local1.dispatchEvent(new MouseEvent("mouseMiddleUp"));
}
public function playerDisconnected(_arg1:int):void{
var _local2:String;
trace("playerDisconnected");
for (_local2 in synchronizeInfos) {
checkSynchronized(_local2);
};
}
public function pause():void{
NewTimer.pause();
}
private function htmlSpecialChars(_arg1:String):String{
_arg1 = _arg1.replace(/&/g, "&");
_arg1 = _arg1.replace(/"/g, """);
_arg1 = _arg1.replace(/</g, "<");
_arg1 = _arg1.replace(/>/g, ">");
return (_arg1);
}
public function sendMessage(_arg1:String, ... _args):void{
var _local3:String;
var _local4:int;
_local3 = (("<CALLFUNCTION name=\"" + _arg1) + "\">");
_local4 = 0;
while (_local4 < _args.length) {
if (!(_args[_local4] is String)){
_local3 = (_local3 + (("<PARAMETER type=\"Number\" value=\"" + _args[_local4]) + "\" />"));
} else {
_local3 = (_local3 + (("<PARAMETER type=\"String\" value=\"" + htmlSpecialChars(_args[_local4])) + "\" />"));
};
_local4++;
};
_local3 = (_local3 + "</CALLFUNCTION>");
Object(parent).sendMessage(_local3);
}
}
}//package com.novelgames.multiplayerflashgames.common
Section 2
//Instructions (com.novelgames.multiplayerflashgames.common.Instructions)
package com.novelgames.multiplayerflashgames.common {
import flash.display.*;
import flash.events.*;
public dynamic class Instructions extends MovieClip {
public var startButton:SimpleButton;
private var shownFromGame:Boolean;
public function Instructions(_arg1:Boolean){
this.shownFromGame = _arg1;
startButton.addEventListener(MouseEvent.ROLL_OVER, startButtonOvered);
startButton.addEventListener(MouseEvent.CLICK, startButtonClicked);
stop();
if (this["nextPageButton"]){
this["nextPageButton"].addEventListener(MouseEvent.CLICK, nextPageButtonClicked);
this["nextPageButton"].visible = !((currentFrame == totalFrames));
};
if (this["previousPageButton"]){
this["previousPageButton"].addEventListener(MouseEvent.CLICK, previousPageButtonClicked);
this["previousPageButton"].visible = !((currentFrame == 1));
};
}
private function nextPageButtonClicked(_arg1:MouseEvent):void{
nextFrame();
this["nextPageButton"].visible = !((currentFrame == totalFrames));
this["previousPageButton"].visible = !((currentFrame == 1));
}
private function startButtonOvered(_arg1:MouseEvent):void{
if (Object(parent).buttonSoundOver){
Object(parent).buttonSoundOver.play();
};
}
private function startButtonClicked(_arg1:MouseEvent):void{
if (Object(parent).buttonSoundClick){
Object(parent).buttonSoundClick.play();
};
if (!shownFromGame){
Object(parent).gotoGamePage();
} else {
Object(parent).hideInstructionsFromGame();
};
}
private function previousPageButtonClicked(_arg1:MouseEvent):void{
prevFrame();
this["nextPageButton"].visible = !((currentFrame == totalFrames));
this["previousPageButton"].visible = !((currentFrame == 1));
}
}
}//package com.novelgames.multiplayerflashgames.common
Section 3
//InstructionsButton (com.novelgames.multiplayerflashgames.common.InstructionsButton)
package com.novelgames.multiplayerflashgames.common {
import flash.display.*;
import flash.events.*;
public class InstructionsButton extends MovieClip {
public function InstructionsButton(){
super();
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, function ():void{
Object(parent.parent).showInstructionsFromGame();
});
}
}
}//package com.novelgames.multiplayerflashgames.common
Section 4
//MainDevelopment (com.novelgames.multiplayerflashgames.common.MainDevelopment)
package com.novelgames.multiplayerflashgames.common {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.media.*;
import flash.net.*;
import flash.external.*;
public class MainDevelopment extends MovieClip {
private var titleX:Number;
private var titleY:Number;
public var buttonSoundClick:Sound;
private var shouldReceiveMessages:Boolean;
private var instructions:Instructions;
private var musicGame:Sound;
public var playerDisconnecteds:Array;
private var musicGameSoundChannel:SoundChannel;
private var queuedUpMessageInfos:Array;
private var title:Title;
private var titleIndex:int;
public var disconnectedPlayerCounts:int;
public var selfIndex:int;
public var playerNames:Array;
private var game:Game;
public var buttonSoundOver:Sound;
public function MainDevelopment(){
super();
shouldReceiveMessages = false;
queuedUpMessageInfos = new Array();
checkMute();
try {
ExternalInterface.addCallback("onRightMouseDown", onRightMouseDown);
ExternalInterface.addCallback("onRightMouseUp", onRightMouseUp);
ExternalInterface.addCallback("onMiddleMouseDown", onMiddleMouseDown);
ExternalInterface.addCallback("onMiddleMouseUp", onMiddleMouseUp);
} catch(e) {
};
this.addEventListener(Event.ENTER_FRAME, checkTitle);
this["connector"].initialize(this);
}
private function shiftQueuedUpMessageInfos(_arg1:TimerEvent=null):void{
var _local2:MessageInfo;
while (((shouldReceiveMessages) && ((queuedUpMessageInfos.length > 0)))) {
_local2 = queuedUpMessageInfos.shift();
if (_local2.type == MessageInfo.TYPE_MESSAGE){
if (game){
game.receiveMessage(_local2.xmlString);
};
} else {
playerDisconnecteds[_local2.playerIndex] = true;
disconnectedPlayerCounts++;
if (game){
game.playerDisconnected(_local2.playerIndex);
};
};
};
}
protected function getMusicGame():Sound{
return (null);
}
public function startReceivingMessages():void{
var _local1:Timer = new Timer(1, 1);
shouldReceiveMessages = true;
_local1.addEventListener(TimerEvent.TIMER, shiftQueuedUpMessageInfos);
_local1.start();
}
public function gotoMoreGamesURL2():void{
navigateToURL(new URLRequest("http://www.flashgames.de"), "_blank");
}
protected function getButtonSoundClick():Sound{
return (null);
}
public function startGameMusic():void{
stopGameMusic();
musicGame = getMusicGame();
musicGameSoundChannel = musicGame.play(0, int.MAX_VALUE);
}
public function viewEnded():void{
this["connector"].viewEnded();
}
public function showInstructionsFromGame():void{
game.visible = false;
instructions = new Instructions(true);
instructions.x = titleX;
instructions.y = titleY;
this.addChildAt(instructions, (titleIndex + 1));
}
protected function getTitle():Title{
return (null);
}
public function receiveMessage(_arg1:String):void{
var _local2:MessageInfo = new MessageInfo(MessageInfo.TYPE_MESSAGE);
_local2.xmlString = _arg1;
queuedUpMessageInfos.push(_local2);
shiftQueuedUpMessageInfos();
}
public function startView(_arg1:Array):void{
var _local2:int;
this.playerNames = _arg1;
this.selfIndex = -1;
playerDisconnecteds = new Array();
_local2 = 0;
while (_local2 < _arg1.length) {
playerDisconnecteds[_local2] = false;
_local2++;
};
disconnectedPlayerCounts = 0;
gotoGamePage();
}
public function gotoGamePage():void{
var _local1:int;
Game.gameStage = stage;
Game.main = this;
removePage();
game = getGame();
game.x = titleX;
game.y = titleY;
this.addChildAt(game, titleIndex);
if (selfIndex != -1){
game.startPlay(playerNames, selfIndex);
} else {
game.startView(playerNames);
};
_local1 = 0;
while (_local1 < playerDisconnecteds.length) {
if (playerDisconnecteds[_local1]){
game.playerDisconnected(_local1);
};
_local1++;
};
}
public function onMiddleMouseUp():void{
if (game){
game.onMiddleMouseUp();
};
}
public function startPlay(_arg1:Array, _arg2:int):void{
var _local3:int;
this.playerNames = _arg1;
this.selfIndex = _arg2;
playerDisconnecteds = new Array();
_local3 = 0;
while (_local3 < _arg1.length) {
playerDisconnecteds[_local3] = false;
_local3++;
};
disconnectedPlayerCounts = 0;
gotoGamePage();
showInstructionsFromGame();
game.pause();
}
protected function getButtonSoundOver():Sound{
return (null);
}
public function playerDisconnected(_arg1:int):void{
var _local2:MessageInfo = new MessageInfo(MessageInfo.TYPE_DISCONNECTED);
_local2.playerIndex = _arg1;
queuedUpMessageInfos.push(_local2);
shiftQueuedUpMessageInfos();
}
private function checkTitle(_arg1:Event):void{
if (!(title = getTitle())){
return;
};
titleX = title.x;
titleY = title.y;
this.removeEventListener(Event.ENTER_FRAME, checkTitle);
stop();
titleIndex = this.getChildIndex(title);
buttonSoundOver = getButtonSoundOver();
buttonSoundClick = getButtonSoundClick();
}
private function checkMute():void{
var _local2:SoundTransform;
var _local1:SharedObject = SharedObject.getLocal("mute", "/");
_local1.objectEncoding = ObjectEncoding.AMF0;
if (_local1.data.isMute){
_local2 = new SoundTransform();
_local2.volume = 0;
SoundMixer.soundTransform = _local2;
};
}
private function removePage():void{
if (title){
removeChild(title);
title = null;
};
if (instructions){
removeChild(instructions);
instructions = null;
};
if (game){
removeChild(game);
game = null;
};
if (musicGame){
};
}
public function leaveGame():void{
this["connector"].leaveGame();
}
public function sendMessage(_arg1:String):void{
this["connector"].sendMessage(_arg1);
}
public function hideInstructionsFromGame():void{
this.removeChild(instructions);
instructions = null;
game.visible = true;
game.unpause();
if (!musicGame){
musicGame = getMusicGame();
musicGameSoundChannel = musicGame.play(0, int.MAX_VALUE);
};
}
public function gameEnded(_arg1:Array):void{
this["connector"].gameEnded(_arg1);
}
public function stopReceivingMessages():void{
shouldReceiveMessages = false;
}
public function gotoTitlePage():void{
shouldReceiveMessages = false;
queuedUpMessageInfos = new Array();
removePage();
title = new Title();
title.x = titleX;
title.y = titleY;
this.addChildAt(title, titleIndex);
leaveGame();
}
public function gotoMoreGamesURL():void{
navigateToURL(new URLRequest("http://www.flashgames.de/index.php"), "_blank");
}
protected function getGame():Game{
return (null);
}
public function stopGameMusic():void{
if (musicGame){
musicGameSoundChannel.stop();
musicGame = null;
musicGameSoundChannel = null;
};
}
public function onMiddleMouseDown():void{
if (game){
game.onMiddleMouseDown();
};
}
public function showPlayers():void{
this["connector"].showPlayers();
}
public function onRightMouseDown():void{
if (game){
game.onRightMouseDown();
};
}
public function onRightMouseUp():void{
if (game){
game.onRightMouseUp();
};
}
}
}//package com.novelgames.multiplayerflashgames.common
Section 5
//MessageInfo (com.novelgames.multiplayerflashgames.common.MessageInfo)
package com.novelgames.multiplayerflashgames.common {
public class MessageInfo {
public var playerIndex:int;
public var xmlString:String;
public var type:int;
public static var TYPE_DISCONNECTED:int = 2;
public static var TYPE_MESSAGE:int = 1;
public function MessageInfo(_arg1:int){
this.type = _arg1;
}
}
}//package com.novelgames.multiplayerflashgames.common
Section 6
//MuteButton (com.novelgames.multiplayerflashgames.common.MuteButton)
package com.novelgames.multiplayerflashgames.common {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.net.*;
public class MuteButton extends MovieClip {
public function MuteButton(){
if (SoundMixer.soundTransform.volume == 0){
showOff();
} else {
showOn();
};
this.addEventListener(MouseEvent.CLICK, buttonClicked);
this.buttonMode = true;
}
private function showOff():void{
gotoAndStop("off");
}
private function showOn():void{
gotoAndStop("on");
}
private function buttonClicked(_arg1:MouseEvent):void{
var _local2:SharedObject = SharedObject.getLocal("mute", "/");
var _local3:SoundTransform = new SoundTransform();
_local2.objectEncoding = ObjectEncoding.AMF0;
if (SoundMixer.soundTransform.volume == 0){
_local2.data.isMute = false;
_local3.volume = 1;
SoundMixer.soundTransform = _local3;
showOn();
} else {
_local2.data.isMute = true;
_local3.volume = 0;
SoundMixer.soundTransform = _local3;
showOff();
};
}
}
}//package com.novelgames.multiplayerflashgames.common
Section 7
//NewTimer (com.novelgames.multiplayerflashgames.common.NewTimer)
package com.novelgames.multiplayerflashgames.common {
import flash.events.*;
import flash.utils.*;
public class NewTimer extends Timer {
private var adjustedStartTime:int;
private var originalRepeatCount:int;
private var originalDelay:int;
private var listener:Function;
private static var pauseTime:int;
private static var paused:Boolean = false;
private static var totalPausedTime:int = 0;
public function NewTimer(_arg1:Number, _arg2:int=0):void{
super(_arg1, _arg2);
originalDelay = _arg1;
originalRepeatCount = _arg2;
}
override public function start():void{
adjustedStartTime = NewTimer.getTimer();
super.start();
}
private function timerEventListener(_arg1:TimerEvent):void{
if (paused){
stop();
delay = Math.max((originalDelay - (NewTimer.getTimer() - adjustedStartTime)), 1);
if (originalRepeatCount > 0){
repeatCount++;
};
super.start();
return;
};
if ((NewTimer.getTimer() - adjustedStartTime) >= originalDelay){
adjustedStartTime = NewTimer.getTimer();
if (delay != originalDelay){
stop();
delay = originalDelay;
super.start();
};
listener(_arg1);
} else {
stop();
delay = Math.max((originalDelay - (NewTimer.getTimer() - adjustedStartTime)), 1);
if (originalRepeatCount > 0){
repeatCount++;
};
super.start();
};
}
override public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
if (_arg1 != TimerEvent.TIMER){
super.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5);
return;
};
this.listener = _arg2;
super.addEventListener(_arg1, timerEventListener);
}
public static function unpause():void{
if (!paused){
return;
};
paused = false;
totalPausedTime = (totalPausedTime + (getTimer() - pauseTime));
}
public static function getTimer():int{
if (paused){
return ((pauseTime - totalPausedTime));
};
return ((getTimer() - totalPausedTime));
}
public static function pause():void{
if (paused){
return;
};
paused = true;
pauseTime = getTimer();
}
}
}//package com.novelgames.multiplayerflashgames.common
Section 8
//Title (com.novelgames.multiplayerflashgames.common.Title)
package com.novelgames.multiplayerflashgames.common {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class Title extends MovieClip {
public var btn_logo:SimpleButton;
public var startButton:SimpleButton;
public var moreGamesButton:SimpleButton;
public function Title(){
startButton.addEventListener(MouseEvent.ROLL_OVER, startButtonOvered);
startButton.addEventListener(MouseEvent.CLICK, startButtonClicked);
moreGamesButton.addEventListener(MouseEvent.ROLL_OVER, moreGamesButtonOvered);
moreGamesButton.addEventListener(MouseEvent.CLICK, moreGamesButtonClicked);
btn_logo.addEventListener(MouseEvent.CLICK, btnLogo);
}
private function startButtonClicked(_arg1:MouseEvent):void{
if (Object(parent).buttonSoundClick){
Object(parent).buttonSoundClick.play();
};
Object(parent).showPlayers();
}
private function startButtonOvered(_arg1:MouseEvent):void{
if (Object(parent).buttonSoundOver){
Object(parent).buttonSoundOver.play();
};
}
private function moreGamesButtonClicked(_arg1:MouseEvent):void{
if (Object(parent).buttonSoundClick){
Object(parent).buttonSoundClick.play();
};
Object(parent).gotoMoreGamesURL();
}
private function moreGamesButtonOvered(_arg1:MouseEvent):void{
if (Object(parent).buttonSoundOver){
Object(parent).buttonSoundOver.play();
};
}
private function btnLogo(_arg1:MouseEvent):void{
Object(parent).gotoMoreGamesURL2();
}
}
}//package com.novelgames.multiplayerflashgames.common
Section 9
//Bubble (com.novelgames.multiplayerflashgames.connector.Bubble)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.text.*;
public class Bubble extends MovieClip {
private function drawBackground():void{
var _local1:Number = (this.width + (Config.PLAYERSDISPLAY_BUBBLEBORDER * 2));
var _local2:Number = (this.height + (Config.PLAYERSDISPLAY_BUBBLEBORDER * 2));
this.graphics.lineStyle(Config.PLAYERSDISPLAY_BUBBLELINETHICKNESS, Config.PLAYERSDISPLAY_BUBBLELINECOLOUR);
this.graphics.beginFill(Config.PLAYERSDISPLAY_BUBBLECOLOUR);
this.graphics.moveTo((-(_local1) / 2), (-(_local2) / 2));
this.graphics.lineTo((_local1 / 2), (-(_local2) / 2));
this.graphics.lineTo((_local1 / 2), (_local2 / 2));
this.graphics.lineTo((-(_local1) / 2), (_local2 / 2));
this.graphics.lineTo((-(_local1) / 2), (-(_local2) / 2));
this.graphics.endFill();
}
private function showStart(_arg1:Array):void{
var _local2:BubbleStart = new BubbleStart();
showNoOfPlayers(_local2.playersText, _arg1);
this.addChild(_local2);
}
private function showInvite(_arg1:String):void{
var _local2:BubbleInvite = new BubbleInvite();
_local2.nameText.text = _arg1;
this.addChild(_local2);
}
private function showJoin(_arg1:Array):void{
var _local2:BubbleJoin = new BubbleJoin();
showPlayerNames(_local2.namesText, _arg1);
_local2.y = (-(_local2.height) / 2);
this.addChild(_local2);
}
private function showName(_arg1:String):void{
var _local2:BubbleName = new BubbleName();
_local2.nameText.autoSize = "center";
_local2.nameText.text = _arg1;
this.addChild(_local2);
}
private function showSelf(_arg1:String):void{
var _local2:BubbleSelf = new BubbleSelf();
_local2.nameText.autoSize = "center";
_local2.nameText.text = _arg1;
this.addChild(_local2);
}
private function showPlayerNames(_arg1:TextField, _arg2:Array):void{
var _local4:int;
var _local3 = "";
_local4 = 0;
while (_local4 < _arg2.length) {
_local3 = (_local3 + _arg2[_local4].playerName);
if (_local4 < (_arg2.length - 1)){
_local3 = (_local3 + "\r");
};
_local4++;
};
_arg1.autoSize = "center";
_arg1.text = _local3;
}
private function setPosition(_arg1:PlayerGroup):void{
var _local2:Number = (_arg1.x + _arg1.parent.x);
var _local3:Number = (_arg1.y + _arg1.parent.y);
var _local4:Number = _arg1.x;
var _local5:Number = _arg1.y;
if (_local2 <= 0){
_local4 = (_local4 + (width / 2));
} else {
_local4 = (_local4 - (width / 2));
};
if (_local3 <= 0){
_local5 = (_local5 + (height / 2));
} else {
_local5 = (_local5 - (height / 2));
};
this.x = _local4;
this.y = _local5;
}
public function initialize(_arg1:PlayerGroup, _arg2:PlayerGroup, _arg3:Boolean, _arg4:Array):void{
if (_arg1 == _arg2){
if (_arg1.playID == 0){
showSelf(_arg1.players[0].playerName);
} else {
if (Util.getCanStart(_arg1.players.length, _arg4)){
if (_arg3){
showStart(_arg4);
} else {
showWait(_arg4);
};
} else {
showPlayers(_arg4);
};
};
} else {
if (_arg1.playID == 0){
if (Util.getCanInvite(_arg2.players.length, _arg4)){
showInvite(_arg1.players[0].playerName);
} else {
showName(_arg1.players[0].playerName);
};
} else {
if (!_arg1.isPlaying){
if (Util.getCanJoin(!((_arg2.playID == 0)), _arg1.players.length, _arg4)){
if (!_arg1.byInvitationOnly){
showJoin(_arg1.players);
} else {
showByInvitationOnly(_arg1.players);
};
} else {
showWaitStart(_arg1.players);
};
} else {
if (_arg1.players.length > 0){
if (_arg2.playID == 0){
showPlaying(_arg1.players, true);
} else {
showPlaying(_arg1.players, false);
};
} else {
showFinishedPlaying();
};
};
};
};
drawBackground();
setPosition(_arg1);
this.mouseEnabled = false;
this.mouseChildren = false;
}
private function showPlaying(_arg1:Array, _arg2:Boolean):void{
var _local3:BubblePlaying = new BubblePlaying();
showPlayerNames(_local3.namesText, _arg1);
if (_arg2){
_local3.clickToViewText.y = ((_local3.namesText.y + _local3.namesText.height) + (_local3.clickToViewText.width / 2));
} else {
_local3.clickToViewText.visible = false;
};
_local3.y = (-(_local3.height) / 2);
this.addChild(_local3);
}
private function showWait(_arg1:Array):void{
var _local2:BubbleWait = new BubbleWait();
showNoOfPlayers(_local2.playersText, _arg1);
this.addChild(_local2);
}
private function showPlayers(_arg1:Array):void{
var _local2:BubblePlayers = new BubblePlayers();
showNoOfPlayers(_local2.playersText, _arg1);
this.addChild(_local2);
}
private function showWaitStart(_arg1:Array):void{
var _local2:BubbleWaitStart = new BubbleWaitStart();
showPlayerNames(_local2.namesText, _arg1);
_local2.y = (-(_local2.height) / 2);
this.addChild(_local2);
}
private function showByInvitationOnly(_arg1:Array):void{
var _local2:BubbleByInvitationOnly = new BubbleByInvitationOnly();
showPlayerNames(_local2.namesText, _arg1);
_local2.y = (-(_local2.height) / 2);
this.addChild(_local2);
}
private function showNoOfPlayers(_arg1:TextField, _arg2:Array):void{
var _local3:String;
var _local4:int;
var _local5:Boolean;
var _local6:Number;
var _local7:int;
_local3 = _arg2[0];
_local4 = _arg2[0];
_local5 = false;
_local7 = 1;
while (_local7 < _arg2.length) {
if (_arg2[_local7] == (_local4 + 1)){
if (!_local5){
_local3 = (_local3 + " - ");
_local5 = true;
};
_local4 = _arg2[_local7];
} else {
if (_local5){
_local3 = (_local3 + ((_local4 + ", ") + _arg2[_local7]));
} else {
_local3 = (_local3 + (", " + _arg2[_local7]));
};
_local5 = false;
};
_local7++;
};
if (_local5){
_local3 = (_local3 + _local4);
};
_arg1.autoSize = "center";
_arg1.text = _local3;
}
private function showFinishedPlaying():void{
var _local1:BubbleFinishedPlaying = new BubbleFinishedPlaying();
this.addChild(_local1);
}
}
}//package com.novelgames.multiplayerflashgames.connector
Section 10
//BubbleByInvitationOnly (com.novelgames.multiplayerflashgames.connector.BubbleByInvitationOnly)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.text.*;
public dynamic class BubbleByInvitationOnly extends MovieClip {
public var namesText:TextField;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 11
//BubbleFinishedPlaying (com.novelgames.multiplayerflashgames.connector.BubbleFinishedPlaying)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
public dynamic class BubbleFinishedPlaying extends MovieClip {
}
}//package com.novelgames.multiplayerflashgames.connector
Section 12
//BubbleInvite (com.novelgames.multiplayerflashgames.connector.BubbleInvite)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.text.*;
public dynamic class BubbleInvite extends MovieClip {
public var nameText:TextField;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 13
//BubbleJoin (com.novelgames.multiplayerflashgames.connector.BubbleJoin)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.text.*;
public dynamic class BubbleJoin extends MovieClip {
public var namesText:TextField;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 14
//BubbleName (com.novelgames.multiplayerflashgames.connector.BubbleName)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.text.*;
public dynamic class BubbleName extends MovieClip {
public var nameText:TextField;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 15
//BubblePlayers (com.novelgames.multiplayerflashgames.connector.BubblePlayers)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.text.*;
public dynamic class BubblePlayers extends MovieClip {
public var playersText:TextField;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 16
//BubblePlaying (com.novelgames.multiplayerflashgames.connector.BubblePlaying)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.text.*;
public dynamic class BubblePlaying extends MovieClip {
public var namesText:TextField;
public var clickToViewText:MovieClip;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 17
//BubbleSelf (com.novelgames.multiplayerflashgames.connector.BubbleSelf)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.text.*;
public dynamic class BubbleSelf extends MovieClip {
public var nameText:TextField;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 18
//BubbleStart (com.novelgames.multiplayerflashgames.connector.BubbleStart)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.text.*;
public dynamic class BubbleStart extends MovieClip {
public var playersText:TextField;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 19
//BubbleWait (com.novelgames.multiplayerflashgames.connector.BubbleWait)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.text.*;
public dynamic class BubbleWait extends MovieClip {
public var playersText:TextField;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 20
//BubbleWaitStart (com.novelgames.multiplayerflashgames.connector.BubbleWaitStart)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.text.*;
public dynamic class BubbleWaitStart extends MovieClip {
public var namesText:TextField;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 21
//Config (com.novelgames.multiplayerflashgames.connector.Config)
package com.novelgames.multiplayerflashgames.connector {
public class Config {
public static var PLAYERSDISPLAY_SORTTIME:int = 500;
public static var PLAYERSDISPLAY_TABLEVIEWWIDTH:Number = 270;
public static var PLAYERSDISPLAY_SORTSPACINGY:Number = 10;
public static var PLAYERSDISPLAY_GROUPSPACINGX:Number = 160;
public static var PLAYERSDISPLAY_GROUPSPACINGY:Number = 130;
public static var PLAYERSDISPLAY_TABLEWIDTH:Number = 180;
public static var INNERDIALOG_HEIGHT:Number = 350;
public static var PLAYERSDISPLAY_SORTSPACINGX:Number = 10;
public static var PLAYERSDISPLAY_TABLEVIEWHEIGHT:Number = 120;
public static var PLAYERSDISPLAY_SCROLLSPEED:Number = 200;
public static var PLAYERSDISPLAY_TABLEVIEWSTARTANGLE:Number = -35;
public static var PLAYERSDISPLAY_BUBBLELINECOLOUR:uint = 0x666666;
public static var PLAYERSDISPLAY_BUBBLEBORDER:Number = 10;
public static var INNERDIALOG_WIDTH:Number = 400;
public static var PLAYERSDISPLAY_TABLEHEIGHT:Number = 80;
public static var PLAYERSDISPLAY_BUBBLECOLOUR:uint = 0xFFFFFF;
public static var PLAYERSDISPLAY_BUBBLELINETHICKNESS:Number = 2;
public static var NAME_DEFAULT:String = "Guest";
public static var PLAYERSDISPLAY_BUTTONMARGIN:Number = 5;
public static var PLAYERSDISPLAY_TABLESTARTANGLE:Number = -125;
public static var PLAYERSDISPLAY_GROUPSCALE:Number = 0.7;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 22
//ConnectingDialog (com.novelgames.multiplayerflashgames.connector.ConnectingDialog)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
public dynamic class ConnectingDialog extends MovieClip {
}
}//package com.novelgames.multiplayerflashgames.connector
Section 23
//Connector (com.novelgames.multiplayerflashgames.connector.Connector)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.utils.*;
import flash.media.*;
import flash.xml.*;
import flash.geom.*;
import flash.net.*;
public class Connector extends UIComponent {
private var __possibleNoOfPlayers:Array;
public var playerName:String;
public var connected:Boolean;
private var __dialogColour:Number;
private var playerInfos:Array;
private var initializeCalled:Boolean;
private var __pingInterval:Number;
private var innerDialog:MovieClip;
private var __serverPort:Number;
public var playID:int;
private var lastSendMessageTime:int;
public var key:String;
private var __dialogBorderThickness:Number;
private var __dialogBorderColour:Number;
private var __innerDialogBorderThickness:Number;
private var __serverHost:String;
private var __gameID:Number;
public var xmlSocket:XMLSocket;
private var __backgroundColour:Number;
private var __hashKey:String;
private var __innerDialogBorderColour:Number;
private var parameterSets:Object;
private var __nameSWFVariable:String;
public var playerID:int;
private var __innerDialogColour:Number;
private var gamePlayersDialog:MovieClip;
private var shouldEnterPlayerName:Boolean;
public var soundJoin:Sound;
private var invitePlayerID:int;
private var moduleTextPage:MovieClip;
public var soundLeave:Sound;
private var __backgroundAlpha:Number;
private var game:Object;
private var pingTimer:Timer;
public function set dialogBorderColour(_arg1:Number):void{
__dialogBorderColour = _arg1;
setParameterSet("dialogBorderColour");
}
private function showEnterName():void{
innerDialog = new EnterNameDialog();
innerDialog.nameText.text = Config.NAME_DEFAULT;
innerDialog.okButton.addEventListener(MouseEvent.CLICK, enterNameFinished);
this.addChild(innerDialog);
initializeInnerDialog();
if (((!((__nameSWFVariable == ""))) && (!((root.loaderInfo.parameters[__nameSWFVariable] == null))))){
shouldEnterPlayerName = false;
playerName = root.loaderInfo.parameters[__nameSWFVariable];
if (playerName == null){
playerName = "";
};
};
if (!shouldEnterPlayerName){
innerDialog.nameText.text = playerName;
enterNameFinished();
};
}
public function setPlayerName(_arg1:String):void{
this.playerName = _arg1;
shouldEnterPlayerName = false;
}
private function enterNameFinished(_arg1:MouseEvent=null):void{
playerID = 0;
playerName = innerDialog.nameText.text;
playID = 0;
removeChild(innerDialog);
showConnecting();
connected = false;
xmlSocket = new XMLSocket();
xmlSocket.addEventListener(Event.CONNECT, onSocketConnect);
xmlSocket.addEventListener(Event.CLOSE, onSocketClose);
xmlSocket.addEventListener(IOErrorEvent.IO_ERROR, onSocketIOError);
xmlSocket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSocketSecurityError);
xmlSocket.connect(serverHost, serverPort);
}
public function set serverHost(_arg1:String):void{
__serverHost = _arg1;
setParameterSet("serverHost");
}
private function onSocketIOError(_arg1:IOErrorEvent):void{
showDisconnected();
}
public function set gameID(_arg1:Number):void{
__gameID = Number(_arg1);
setParameterSet("gameID");
}
public function set innerDialogBorderThickness(_arg1:Number):void{
__innerDialogBorderThickness = _arg1;
setParameterSet("innerDialogBorderThickness");
}
private function showRegisterFailed(_arg1:String):void{
hideInner();
innerDialog = new RegisterFailedDialog();
innerDialog.nameText.text = playerName;
innerDialog.reasonText.visible = (_arg1 == "obsceneName");
innerDialog.okButton.addEventListener(MouseEvent.CLICK, enterNameFinished);
this.addChild(innerDialog);
initializeInnerDialog();
}
private function checkAllParametersSet():Boolean{
var _local1:String;
for (_local1 in parameterSets) {
if (!parameterSets[_local1]){
return (false);
};
};
return (true);
}
private function onInitializeData(_arg1:DataEvent):void{
var _local3:XMLNode;
var _local2:XMLDocument = new XMLDocument();
_local2.ignoreWhite = true;
_local2.parseXML(_arg1.text);
_local3 = _local2.firstChild;
if (_local3.nodeName != "INITIALIZE"){
return;
};
key = _local3.attributes.key;
connected = true;
xmlSocket.removeEventListener(DataEvent.DATA, onInitializeData);
xmlSocket.addEventListener(DataEvent.DATA, onRegisterData);
sendRawMessage((((("<REGISTER siteID=\"1\" gameID=\"" + gameID) + "\" playerName=\"") + encodeHTML(playerName)) + "\" />"));
pingTimer = new Timer(pingInterval, 0);
pingTimer.addEventListener(TimerEvent.TIMER, onPingTime);
pingTimer.start();
}
private function showWait():void{
if (innerDialog){
this.removeChild(innerDialog);
};
innerDialog = new WaitDialog();
this.addChild(innerDialog);
initializeInnerDialog();
}
private function showGamePlayers(_arg1:XMLNode):void{
hide();
gamePlayersDialog = new GamePlayersDialog();
this.addChildAt(gamePlayersDialog, 0);
gamePlayersDialog.initialize(_arg1, playerID, possibleNoOfPlayers);
gamePlayersDialog.x = (width / 2);
gamePlayersDialog.y = (height / 2);
gamePlayersDialog.cancelButton.addEventListener(MouseEvent.CLICK, cancelViewGamePlayers);
}
public function set nameSWFVariable(_arg1:String):void{
__nameSWFVariable = _arg1;
setParameterSet("nameSWFVariable");
}
public function showNewTable(_arg1:int=0):void{
this.invitePlayerID = _arg1;
if (innerDialog){
this.removeChild(innerDialog);
};
innerDialog = new NewTableDialog();
innerDialog.initialize(playerID, playerName);
innerDialog.okButton.addEventListener(MouseEvent.CLICK, startNewPlay);
this.addChild(innerDialog);
initializeInnerDialog();
}
public function showInvitationSent():void{
if (innerDialog){
this.removeChild(innerDialog);
};
innerDialog = new InvitationSentDialog();
innerDialog.okButton.addEventListener(MouseEvent.CLICK, hideInner);
this.addChild(innerDialog);
initializeInnerDialog();
}
public function startNewPlay(_arg1:MouseEvent):void{
var _local2:Boolean = innerDialog.byInvitationOnly;
hideInner();
xmlSocket.addEventListener(DataEvent.DATA, onStartNewPlayData);
sendRawMessage((((("<STARTNEWPLAY noOfPlayers=\"" + possibleNoOfPlayers.join(",")) + "\" byInvitationOnly=\"") + (_local2) ? "true" : "false") + "\" />"));
}
public function get dialogColour():Number{
return (__dialogColour);
}
public function get dialogBorderThickness():Number{
return (__dialogBorderThickness);
}
public function hide(_arg1:MouseEvent=null):void{
hideInner();
if (gamePlayersDialog){
this.removeChild(gamePlayersDialog);
gamePlayersDialog = null;
};
}
public function set backgroundColour(_arg1:Number):void{
__backgroundColour = Number(_arg1);
setParameterSet("backgroundColour");
}
public function leaveGame():void{
playID = 0;
sendRawMessage("<LEAVEPLAY />");
}
override protected function draw():void{
if (checkLivePreview()){
moduleTextPage.x = (width / 2);
moduleTextPage.y = (height / 2);
this.graphics.clear();
this.graphics.lineStyle(__dialogBorderThickness, __dialogBorderColour);
this.graphics.beginFill(__dialogColour);
this.graphics.moveTo(0, 0);
this.graphics.lineTo(width, 0);
this.graphics.lineTo(width, height);
this.graphics.lineTo(0, height);
this.graphics.lineTo(0, 0);
this.graphics.endFill();
};
}
public function hideInner(_arg1:MouseEvent=null):void{
if (innerDialog){
this.removeChild(innerDialog);
innerDialog = null;
};
}
public function onViewPlayData(_arg1:DataEvent):void{
var _local3:XMLNode;
var _local4:XMLNode;
var _local5:PlayerInfo;
var _local6:Array;
var _local7:int;
var _local2:XMLDocument = new XMLDocument();
_local2.ignoreWhite = true;
_local2.parseXML(_arg1.text);
_local3 = _local2.firstChild;
if (_local3.nodeName != "VIEWPLAYRESULT"){
return;
};
xmlSocket.removeEventListener(DataEvent.DATA, onViewPlayData);
if (_local3.attributes.success != "true"){
playID = 0;
if (innerDialog){
this.removeChild(innerDialog);
};
innerDialog = new ViewFailedDialog();
innerDialog.cancelButton.addEventListener(MouseEvent.CLICK, hideInner);
this.addChild(innerDialog);
initializeInnerDialog();
} else {
hide();
playerInfos = new Array();
_local4 = _local3.firstChild;
while (_local4 != null) {
_local5 = new PlayerInfo(int(_local4.attributes.playerID), _local4.attributes.playerName);
playerInfos.push(_local5);
_local4 = _local4.nextSibling;
};
_local6 = new Array();
_local7 = 0;
while (_local7 < playerInfos.length) {
_local6.push(playerInfos[_local7].playerName);
_local7++;
};
game.startView(_local6);
xmlSocket.removeEventListener(DataEvent.DATA, onUpdateGamePlayersData);
xmlSocket.addEventListener(DataEvent.DATA, onGameData);
sendRawMessage("<STOPVIEWGAMEPLAYERS />");
};
}
public function set innerDialogColour(_arg1:Number):void{
__innerDialogColour = _arg1;
setParameterSet("innerDialogColour");
}
public function get pingInterval():Number{
return (__pingInterval);
}
private function onSocketConnect(_arg1:Event):void{
xmlSocket.addEventListener(DataEvent.DATA, onInitializeData);
xmlSocket.send("<INITIALIZE />");
}
override protected function configUI():void{
super.configUI();
__gameID = 1;
__serverHost = "127.0.0.1";
__serverPort = 9123;
__hashKey = "";
__possibleNoOfPlayers = [2];
__pingInterval = 20000;
__dialogColour = 0xFFFFFF;
__dialogBorderThickness = 0;
__dialogBorderColour = 0;
__innerDialogColour = 0xFFFFFF;
__innerDialogBorderThickness = 5;
__innerDialogBorderColour = 0;
__backgroundColour = 0;
__backgroundAlpha = 0.5;
__nameSWFVariable = "";
parameterSets = new Object();
parameterSets.gameID = false;
parameterSets.serverHost = false;
parameterSets.serverPort = false;
parameterSets.hashKey = false;
parameterSets.possibleNoOfPlayers = false;
parameterSets.pingInterval = false;
parameterSets.dialogColour = false;
parameterSets.dialogBorderThickness = false;
parameterSets.dialogBorderColour = false;
parameterSets.innerDialogColour = false;
parameterSets.innerDialogBorderThickness = false;
parameterSets.innerDialogBorderColour = false;
parameterSets.backgroundColour = false;
parameterSets.backgroundAlpha = false;
parameterSets.nameSWFVariable = false;
initializeCalled = false;
shouldEnterPlayerName = true;
if (checkLivePreview()){
moduleTextPage = new ModuleTextPage();
moduleTextPage.x = (width / 2);
moduleTextPage.y = (height / 2);
this.addChild(moduleTextPage);
};
}
private function onPingTime(_arg1:TimerEvent):void{
var _local2:int = getTimer();
if ((_local2 - lastSendMessageTime) <= pingInterval){
return;
};
sendRawMessage("<PING />");
}
public function get serverPort():Number{
return (__serverPort);
}
public function set dialogColour(_arg1:Number):void{
__dialogColour = _arg1;
setParameterSet("dialogColour");
}
private function onRegisterData(_arg1:DataEvent):void{
var _local3:XMLNode;
var _local2:XMLDocument = new XMLDocument();
_local2.ignoreWhite = true;
_local2.parseXML(_arg1.text);
_local3 = _local2.firstChild;
if (_local3.nodeName != "REGISTERRESULT"){
return;
};
xmlSocket.removeEventListener(DataEvent.DATA, onRegisterData);
if (_local3.attributes.success != "true"){
showRegisterFailed(_local3.attributes.reason);
} else {
playerID = int(_local3.attributes.playerID);
xmlSocket.addEventListener(DataEvent.DATA, onInviteData);
hide();
};
}
public function get hashKey():String{
return (__hashKey);
}
private function onViewGamePlayersData(_arg1:DataEvent):void{
var _local3:XMLNode;
var _local2:XMLDocument = new XMLDocument();
_local2.ignoreWhite = true;
_local2.parseXML(_arg1.text);
_local3 = _local2.firstChild;
if (_local3.nodeName != "VIEWGAMEPLAYERSRESULT"){
return;
};
xmlSocket.removeEventListener(DataEvent.DATA, onViewGamePlayersData);
xmlSocket.addEventListener(DataEvent.DATA, onUpdateGamePlayersData);
showGamePlayers(_local3);
}
public function get innerDialogBorderColour():Number{
return (__innerDialogBorderColour);
}
public function sendMessage(_arg1:String):void{
sendRawMessage((("<GAMEMESSAGE>" + _arg1) + "</GAMEMESSAGE>"));
}
private function setParameterSet(_arg1):void{
if (parameterSets[_arg1]){
return;
};
parameterSets[_arg1] = true;
if (((checkAllParametersSet()) && (initializeCalled))){
initialize(game);
};
}
private function showInvite(_arg1:XMLNode):void{
if (playID != 0){
return;
};
if (innerDialog){
this.removeChild(innerDialog);
};
innerDialog = new InviteDialog();
innerDialog.initialize(_arg1);
innerDialog.yesButton.addEventListener(MouseEvent.CLICK, onInviteAccept);
innerDialog.noButton.addEventListener(MouseEvent.CLICK, hideInner);
this.addChild(innerDialog);
initializeInnerDialog();
}
public function sendRawMessage(_arg1:String):void{
var _local2:String;
if (!connected){
return;
};
_local2 = MD5.md5(((_arg1 + key) + __hashKey));
xmlSocket.send((((("<MESSAGE hash=\"" + _local2) + "\">") + _arg1) + "</MESSAGE>"));
lastSendMessageTime = getTimer();
}
public function set dialogBorderThickness(_arg1:Number):void{
__dialogBorderThickness = _arg1;
setParameterSet("dialogBorderThickness");
}
private function onUpdateGamePlayersData(_arg1:DataEvent):void{
var _local3:XMLNode;
var _local2:XMLDocument = new XMLDocument();
_local2.ignoreWhite = true;
_local2.parseXML(_arg1.text);
_local3 = _local2.firstChild;
if (gamePlayersDialog){
gamePlayersDialog.updateGamePlayers(_local3);
};
}
public function joinPlay(_arg1:int):void{
this.playID = _arg1;
showWait();
xmlSocket.addEventListener(DataEvent.DATA, onJoinPlayData);
sendRawMessage((("<JOINPLAY playID=\"" + _arg1) + "\" />"));
}
public function get dialogBorderColour():Number{
return (__dialogBorderColour);
}
public function get innerDialogBorderThickness():Number{
return (__innerDialogBorderThickness);
}
public function get serverHost():String{
return (__serverHost);
}
public function get gameID():Number{
return (__gameID);
}
private function initializeInnerDialog():void{
var _local1:Point = new Point(0, 0);
var _local2:Point = new Point(stage.stageWidth, stage.stageHeight);
innerDialog.x = (width / 2);
innerDialog.y = (height / 2);
_local1 = innerDialog.globalToLocal(_local1);
_local2 = innerDialog.globalToLocal(_local2);
innerDialog.graphics.clear();
innerDialog.graphics.beginFill(__backgroundColour, __backgroundAlpha);
innerDialog.graphics.moveTo(_local1.x, _local1.y);
innerDialog.graphics.lineTo(_local2.x, _local1.y);
innerDialog.graphics.lineTo(_local2.x, _local2.y);
innerDialog.graphics.lineTo(_local1.x, _local2.y);
innerDialog.graphics.lineTo(_local1.x, _local1.y);
innerDialog.graphics.endFill();
innerDialog.graphics.lineStyle(__innerDialogBorderThickness, __innerDialogBorderColour);
innerDialog.graphics.beginFill(__innerDialogColour);
innerDialog.graphics.moveTo((-(Config.INNERDIALOG_WIDTH) / 2), (-(Config.INNERDIALOG_HEIGHT) / 2));
innerDialog.graphics.lineTo((Config.INNERDIALOG_WIDTH / 2), (-(Config.INNERDIALOG_HEIGHT) / 2));
innerDialog.graphics.lineTo((Config.INNERDIALOG_WIDTH / 2), (Config.INNERDIALOG_HEIGHT / 2));
innerDialog.graphics.lineTo((-(Config.INNERDIALOG_WIDTH) / 2), (Config.INNERDIALOG_HEIGHT / 2));
innerDialog.graphics.lineTo((-(Config.INNERDIALOG_WIDTH) / 2), (-(Config.INNERDIALOG_HEIGHT) / 2));
innerDialog.graphics.endFill();
}
private function onInviteData(_arg1:DataEvent):void{
var _local3:XMLNode;
var _local2:XMLDocument = new XMLDocument();
_local2.ignoreWhite = true;
_local2.parseXML(_arg1.text);
_local3 = _local2.firstChild;
if (_local3.nodeName != "INVITETOPLAY"){
return;
};
showInvite(_local3);
}
public function get nameSWFVariable():String{
return (__nameSWFVariable);
}
private function showConnecting():void{
innerDialog = new ConnectingDialog();
this.addChild(innerDialog);
initializeInnerDialog();
}
public function initialize(_arg1:Object):void{
this.game = _arg1;
initializeCalled = true;
if (!checkAllParametersSet()){
return;
};
showEnterName();
soundLeave = new SoundLeave();
soundJoin = new SoundJoin();
}
public function viewPlay(_arg1:int):void{
this.playID = _arg1;
xmlSocket.addEventListener(DataEvent.DATA, onViewPlayData);
sendRawMessage((("<VIEWPLAY playID=\"" + _arg1) + "\" />"));
showWait();
}
private function onSocketSecurityError(_arg1:SecurityErrorEvent):void{
showDisconnected();
}
public function set backgroundAlpha(_arg1:Number):void{
__backgroundAlpha = Number(_arg1);
setParameterSet("backgroundAlpha");
}
public function get backgroundColour():Number{
return (__backgroundColour);
}
private function cancelViewGamePlayers(_arg1:MouseEvent):void{
playID = 0;
xmlSocket.removeEventListener(DataEvent.DATA, onUpdateGamePlayersData);
xmlSocket.removeEventListener(DataEvent.DATA, onWaitPlayStartData);
sendRawMessage("<LEAVEPLAY />");
sendRawMessage("<STOPVIEWGAMEPLAYERS />");
hide();
}
public function get innerDialogColour():Number{
return (__innerDialogColour);
}
public function set pingInterval(_arg1:Number):void{
__pingInterval = Number(_arg1);
setParameterSet("pingInterval");
}
public function sendInvite(_arg1:int, _arg2:int):void{
sendRawMessage((((("<INVITETOPLAY playerID=\"" + _arg1) + "\" playID=\"") + _arg2) + "\" />"));
}
public function startPlay():void{
showWait();
xmlSocket.addEventListener(DataEvent.DATA, onStartPlayData);
sendRawMessage((("<STARTPLAY playID=\"" + playID) + "\" />"));
}
private function onGameData(_arg1:DataEvent):void{
var _local3:XMLNode;
var _local4:int;
var _local5:int;
var _local6:int;
var _local2:XMLDocument = new XMLDocument();
_local2.ignoreWhite = true;
_local2.parseXML(_arg1.text);
_local3 = _local2.firstChild;
switch (_local3.nodeName){
case "PLAYERDISCONNECTED":
_local4 = int(_local3.attributes.playerID);
_local5 = 0;
while (_local5 < playerInfos.length) {
if (playerInfos[_local5].disconnected){
} else {
if (playerInfos[_local5].playerID != _local4){
} else {
playerInfos[_local5].disconnected = true;
game.playerDisconnected(_local5);
};
};
_local5++;
};
break;
case "GAMEMESSAGE":
game.receiveMessage(_local3.firstChild.toString());
break;
};
}
private function encodeHTML(_arg1:String):String{
_arg1 = _arg1.replace("&", "&");
_arg1 = _arg1.replace("<", "<");
_arg1 = _arg1.replace(">", ">");
return (_arg1);
}
private function onWaitPlayStartData(_arg1:DataEvent):void{
var _local3:XMLNode;
var _local4:XMLNode;
var _local5:PlayerInfo;
var _local6:Array;
var _local7:int;
var _local8:int;
var _local2:XMLDocument = new XMLDocument();
_local2.ignoreWhite = true;
_local2.parseXML(_arg1.text);
_local3 = _local2.firstChild;
if (_local3.nodeName != "PLAYSTARTED"){
return;
};
hide();
playerInfos = new Array();
_local4 = _local3.firstChild;
while (_local4 != null) {
_local5 = new PlayerInfo(int(_local4.attributes.playerID), _local4.attributes.playerName);
playerInfos.push(_local5);
_local4 = _local4.nextSibling;
};
_local6 = new Array();
_local8 = 0;
while (_local8 < playerInfos.length) {
_local6.push(playerInfos[_local8].playerName);
if (playerInfos[_local8].playerID == playerID){
_local7 = _local8;
};
_local8++;
};
game.startPlay(_local6, _local7);
xmlSocket.removeEventListener(DataEvent.DATA, onUpdateGamePlayersData);
xmlSocket.removeEventListener(DataEvent.DATA, onWaitPlayStartData);
xmlSocket.addEventListener(DataEvent.DATA, onGameData);
sendRawMessage("<STOPVIEWGAMEPLAYERS />");
}
public function set serverPort(_arg1:Number):void{
__serverPort = Number(_arg1);
setParameterSet("serverPort");
}
private function onJoinPlayData(_arg1:DataEvent):void{
var _local3:XMLNode;
var _local2:XMLDocument = new XMLDocument();
_local2.ignoreWhite = true;
_local2.parseXML(_arg1.text);
_local3 = _local2.firstChild;
if (_local3.nodeName != "JOINPLAYRESULT"){
return;
};
xmlSocket.removeEventListener(DataEvent.DATA, onJoinPlayData);
if (_local3.attributes.success != "true"){
playID = 0;
if (innerDialog){
this.removeChild(innerDialog);
};
innerDialog = new JoinFailedDialog();
innerDialog.cancelButton.addEventListener(MouseEvent.CLICK, hideInner);
this.addChild(innerDialog);
initializeInnerDialog();
} else {
xmlSocket.addEventListener(DataEvent.DATA, onWaitPlayStartData);
if (innerDialog){
this.removeChild(innerDialog);
innerDialog = null;
};
if (gamePlayersDialog == null){
hide();
showPlayers();
};
};
}
public function set possibleNoOfPlayers(_arg1:Array):void{
__possibleNoOfPlayers = _arg1;
setParameterSet("possibleNoOfPlayers");
}
public function get backgroundAlpha():Number{
return (__backgroundAlpha);
}
private function showDisconnected():void{
if (innerDialog){
this.removeChild(innerDialog);
};
innerDialog = new DisconnectedDialog();
this.addChild(innerDialog);
initializeInnerDialog();
}
private function onStartPlayData(_arg1:DataEvent):void{
var _local3:XMLNode;
var _local4:Boolean;
var _local5:XMLNode;
var _local6:PlayerInfo;
var _local7:Array;
var _local8:int;
var _local9:int;
var _local2:XMLDocument = new XMLDocument();
_local2.ignoreWhite = true;
_local2.parseXML(_arg1.text);
_local3 = _local2.firstChild;
if (_local3.nodeName != "STARTPLAYRESULT"){
return;
};
xmlSocket.removeEventListener(DataEvent.DATA, onStartPlayData);
_local4 = (_local3.attributes.success == "true");
if (!_local4){
if (innerDialog){
this.removeChild(innerDialog);
};
innerDialog = new StartFailedDialog();
innerDialog.cancelButton.addEventListener(MouseEvent.CLICK, hideInner);
this.addChild(innerDialog);
initializeInnerDialog();
} else {
hide();
playerInfos = new Array();
_local5 = _local3.firstChild;
while (_local5 != null) {
_local6 = new PlayerInfo(int(_local5.attributes.playerID), _local5.attributes.playerName);
playerInfos.push(_local6);
_local5 = _local5.nextSibling;
};
_local7 = new Array();
_local9 = 0;
while (_local9 < playerInfos.length) {
_local7.push(playerInfos[_local9].playerName);
if (playerInfos[_local9].playerID == playerID){
_local8 = _local9;
};
_local9++;
};
game.startPlay(_local7, _local8);
xmlSocket.removeEventListener(DataEvent.DATA, onUpdateGamePlayersData);
xmlSocket.removeEventListener(DataEvent.DATA, onWaitPlayStartData);
xmlSocket.addEventListener(DataEvent.DATA, onGameData);
sendRawMessage("<STOPVIEWGAMEPLAYERS />");
};
}
public function set hashKey(_arg1:String):void{
__hashKey = _arg1;
setParameterSet("hashKey");
}
public function get possibleNoOfPlayers():Array{
return (__possibleNoOfPlayers);
}
public function set innerDialogBorderColour(_arg1:Number):void{
__innerDialogBorderColour = _arg1;
setParameterSet("innerDialogBorderColour");
}
private function onSocketClose(_arg1:Event):void{
showDisconnected();
}
public function showPlayers():void{
showWait();
xmlSocket.addEventListener(DataEvent.DATA, onViewGamePlayersData);
sendRawMessage("<VIEWGAMEPLAYERS />");
}
public function gameEnded(_arg1:Array):void{
sendRawMessage((("<PLAYENDED ranks=\"" + _arg1.join(",")) + "\" />"));
}
private function onStartNewPlayData(_arg1:DataEvent):void{
var _local3:XMLNode;
var _local4:int;
var _local2:XMLDocument = new XMLDocument();
_local2.ignoreWhite = true;
_local2.parseXML(_arg1.text);
_local3 = _local2.firstChild;
if (_local3.nodeName != "STARTNEWPLAYRESULT"){
return;
};
xmlSocket.removeEventListener(DataEvent.DATA, onStartNewPlayData);
if (_local3.attributes.success != "true"){
return;
};
_local4 = int(_local3.attributes.playID);
if (invitePlayerID != 0){
sendInvite(invitePlayerID, _local4);
};
}
private function onInviteAccept(_arg1:MouseEvent):void{
joinPlay(innerDialog.playID);
}
}
}//package com.novelgames.multiplayerflashgames.connector
Section 24
//DisconnectedDialog (com.novelgames.multiplayerflashgames.connector.DisconnectedDialog)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
public dynamic class DisconnectedDialog extends MovieClip {
}
}//package com.novelgames.multiplayerflashgames.connector
Section 25
//EnterNameDialog (com.novelgames.multiplayerflashgames.connector.EnterNameDialog)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.text.*;
public dynamic class EnterNameDialog extends MovieClip {
public var nameText:TextField;
public var okButton:SimpleButton;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 26
//GamePlayersDialog (com.novelgames.multiplayerflashgames.connector.GamePlayersDialog)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.xml.*;
import flash.geom.*;
public class GamePlayersDialog extends MovieClip {
private var waitingPlayerGroups:Array;
private var isSorted:Boolean;
private var idlePlayerGroups:Array;
private var bubble:Bubble;
private var playerGroups:Array;
public var leftButton:SimpleButton;
private var noOfPlayers:Array;
public var upButton:SimpleButton;
private var playerID:int;
public var playersMask:MovieClip;
private var sortTimer:Timer;
public var cancelButton:SimpleButton;
private var sortStartTime:int;
private var playingPlayerGroups:Array;
private var currentPlayerGroup:PlayerGroup;
private var scrollDirectionX:Number;
private var scrollDirectionY:Number;
private var invitePlayerID:int;
public var rightButton:SimpleButton;
public var sortButton:SimpleButton;
public var bubblesHolder:MovieClip;
private var sortStartX:Number;
private var sortStartY:Number;
private var scrollLastTime:int;
public var downButton:SimpleButton;
public var playersHolder:MovieClip;
private var scrollTimer:Timer;
private function onPlayerGroupMouseDown(_arg1:MouseEvent):void{
var _local2:PlayerGroup = PlayerGroup(_arg1.currentTarget);
if (_local2 == currentPlayerGroup){
if (_local2.playID == 0){
startNewPlay();
} else {
if (Util.getCanStart(_local2.players.length, noOfPlayers)){
if (_local2.players[0].playerID == playerID){
Object(parent).startPlay();
} else {
return;
};
} else {
return;
};
};
} else {
if (_local2.playID == 0){
if (Util.getCanInvite(currentPlayerGroup.players.length, noOfPlayers)){
if (currentPlayerGroup.playID == 0){
startNewPlay(_local2.players[0].playerID);
} else {
sendInvite(_local2.players[0].playerID, currentPlayerGroup.playID);
Object(parent).showInvitationSent();
};
} else {
return;
};
} else {
if (!_local2.isPlaying){
if (Util.getCanJoin(!((currentPlayerGroup.playID == 0)), _local2.players.length, noOfPlayers)){
if (!_local2.byInvitationOnly){
Object(parent).joinPlay(_local2.playID);
} else {
return;
};
} else {
return;
};
} else {
if (_local2.players.length > 0){
if (currentPlayerGroup.playID == 0){
Object(parent).viewPlay(_local2.playID);
};
};
};
};
};
}
private function differentiatePlayerGroups():void{
var _local1:int;
idlePlayerGroups = new Array();
waitingPlayerGroups = new Array();
playingPlayerGroups = new Array();
_local1 = 0;
while (_local1 < playerGroups.length) {
if (playerGroups[_local1].isCurrentPlayer){
currentPlayerGroup = playerGroups[_local1];
} else {
if (playerGroups[_local1].playID == 0){
idlePlayerGroups.push(playerGroups[_local1]);
} else {
if (!playerGroups[_local1].isPlaying){
waitingPlayerGroups.push(playerGroups[_local1]);
} else {
playingPlayerGroups.push(playerGroups[_local1]);
};
};
};
_local1++;
};
}
private function onSortTime(_arg1:TimerEvent):void{
var _local4:int;
var _local2:int = getTimer();
var _local3:Number = ((_local2 - sortStartTime) / Config.PLAYERSDISPLAY_SORTTIME);
if (_local3 > 1){
_local3 = 1;
};
_arg1.updateAfterEvent();
_local4 = 0;
while (_local4 < playerGroups.length) {
playerGroups[_local4].x = ((playerGroups[_local4].beginX * (1 - _local3)) + (playerGroups[_local4].endX * _local3));
playerGroups[_local4].y = ((playerGroups[_local4].beginY * (1 - _local3)) + (playerGroups[_local4].endY * _local3));
_local4++;
};
playersHolder.x = (sortStartX * (1 - _local3));
playersHolder.y = (sortStartY * (1 - _local3));
bubblesHolder.x = playersHolder.x;
bubblesHolder.y = playersHolder.y;
if (_local3 >= 1){
sortTimer.stop();
showHideArrows();
};
}
private function playerJoinsPlay(_arg1:int, _arg2:int, _arg3:Boolean):void{
var _local6:int;
var _local8:int;
var _local4:PlayPlayer;
var _local5:PlayerGroup;
var _local7:PlayerGroup;
if (_arg1 == this.playerID){
Object(parent).playID = _arg2;
};
_local8 = 0;
while (_local8 < playerGroups.length) {
_local4 = playerGroups[_local8].getPlayerViewer(_arg1);
if (_local4 == null){
} else {
_local6 = _local8;
_local5 = playerGroups[_local8];
break;
};
_local8++;
};
_local8 = 0;
while (_local8 < playerGroups.length) {
if (playerGroups[_local8].playID == _arg2){
_local7 = playerGroups[_local8];
break;
};
_local8++;
};
if (_local7 == null){
_local5.startNewPlay(_arg2, _arg3);
} else {
_local5.removePlayerViewer(_arg1);
if (_local5.players.length == 0){
playersHolder.removeChild(_local5);
playerGroups.splice(_local6, 1);
};
_local7.addPlayer(_arg1, _local4.playerName, (_arg1 == this.playerID), _local4.isRobot);
if ((((_arg2 == Object(parent).playID)) && (!((_arg1 == this.playerID))))){
Object(parent).soundJoin.play();
};
};
differentiatePlayerGroups();
if (isSorted){
sortPlayers();
};
showHideArrows();
}
public function initialize(_arg1:XMLNode, _arg2:int, _arg3:Array):void{
var _local4:XMLNode;
var _local5:XMLNode;
var _local6:int;
var _local7:String;
var _local8:Boolean;
var _local9:int;
var _local10:Boolean;
var _local11:Boolean;
var _local12:PlayerGroup;
var _local13:int;
this.playerID = _arg2;
this.noOfPlayers = _arg3;
playersMask.width = parent.width;
playersMask.height = parent.height;
drawBackground();
playerGroups = new Array();
_local4 = _arg1.firstChild;
while (_local4 != null) {
if (_local4.nodeName == "PLAYER"){
_local6 = int(_local4.attributes.playerID);
_local7 = _local4.attributes.playerName;
_local8 = (_local4.attributes.isRobot == "true");
_local12 = new PlayerGroup();
_local12.initialize();
playerGroups.push(_local12);
playersHolder.addChild(_local12);
_local12.addPlayer(_local6, _local7, (_local6 == _arg2), _local8);
} else {
if (_local4.nodeName == "PLAY"){
_local9 = int(_local4.attributes.playID);
_local10 = (_local4.attributes.byInvitationOnly == "true");
_local11 = (_local4.attributes.isPlaying == "true");
_local12 = new PlayerGroup();
_local12.initialize();
_local12.showTable(_local9, _local10);
_local12.showPlaying(_local11);
playerGroups.push(_local12);
playersHolder.addChild(_local12);
_local5 = _local4.firstChild;
while (_local5 != null) {
if (((!((_local5.nodeName == "PLAYER"))) && (!((_local5.nodeName == "VIEWER"))))){
} else {
_local6 = int(_local5.attributes.playerID);
_local7 = _local5.attributes.playerName;
_local8 = (_local5.attributes.isRobot == "true");
if (_local5.nodeName == "PLAYER"){
_local12.addPlayer(_local6, _local7, (_local6 == _arg2), _local8);
} else {
_local12.addViewer(_local6, _local7, (_local6 == _arg2), _local8);
};
};
_local5 = _local5.nextSibling;
};
};
};
_local4 = _local4.nextSibling;
};
_local13 = 0;
while (_local13 < playerGroups.length) {
playerGroups[_local13].scaleX = Config.PLAYERSDISPLAY_GROUPSCALE;
playerGroups[_local13].scaleY = Config.PLAYERSDISPLAY_GROUPSCALE;
playerGroups[_local13].addEventListener(MouseEvent.MOUSE_OVER, onPlayerGroupMouseOver);
playerGroups[_local13].addEventListener(MouseEvent.MOUSE_OUT, onPlayerGroupMouseOut);
playerGroups[_local13].addEventListener(MouseEvent.MOUSE_DOWN, onPlayerGroupMouseDown);
playerGroups[_local13].buttonMode = true;
_local13++;
};
bubblesHolder.mouseEnabled = false;
bubblesHolder.mouseChildren = false;
differentiatePlayerGroups();
isSorted = false;
arrangePlayerGroups();
initializeButtons();
}
private function startScrollDown(_arg1:MouseEvent):void{
scrollDirectionX = 0;
scrollDirectionY = -1;
startScroll();
}
private function startScrollRight(_arg1:MouseEvent):void{
scrollDirectionX = -1;
scrollDirectionY = 0;
startScroll();
}
private function addGamePlayer(_arg1:int, _arg2:String, _arg3:Boolean):void{
var _local5:Object;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:int;
var _local4:PlayerGroup = new PlayerGroup();
_local4.initialize();
_local4.addPlayer(_arg1, _arg2, false, _arg3);
_local4.scaleX = Config.PLAYERSDISPLAY_GROUPSCALE;
_local4.scaleY = Config.PLAYERSDISPLAY_GROUPSCALE;
playerGroups.push(_local4);
idlePlayerGroups.push(_local4);
if (isSorted){
sortPlayers();
} else {
arrangeNextPlayerGroup(_local4);
};
_local4.addEventListener(MouseEvent.MOUSE_OVER, onPlayerGroupMouseOver);
_local4.addEventListener(MouseEvent.MOUSE_OUT, onPlayerGroupMouseOut);
_local4.addEventListener(MouseEvent.MOUSE_DOWN, onPlayerGroupMouseDown);
_local4.buttonMode = true;
playersHolder.addChild(_local4);
showHideArrows();
}
private function removeGamePlayer(_arg1:int):void{
var _local2:int;
var _local3:int;
_local2 = 0;
while (_local2 < playerGroups.length) {
if (playerGroups[_local2].removePlayerViewer(_arg1)){
break;
};
_local2++;
};
if (playerGroups[_local2].players.length > 0){
return;
};
playersHolder.removeChild(playerGroups[_local2]);
playerGroups.splice(_local2, 1);
differentiatePlayerGroups();
if (isSorted){
sortPlayers();
};
showHideArrows();
}
private function stopScroll(_arg1:MouseEvent):void{
scrollTimer.stop();
}
private function drawBackground():void{
this.graphics.clear();
this.graphics.lineStyle(Object(parent).dialogBorderThickness, Object(parent).dialogBorderColour);
this.graphics.beginFill(Object(parent).dialogColour);
this.graphics.moveTo((-(parent.width) / 2), (-(parent.height) / 2));
this.graphics.lineTo((parent.width / 2), (-(parent.height) / 2));
this.graphics.lineTo((parent.width / 2), (parent.height / 2));
this.graphics.lineTo((-(parent.width) / 2), (parent.height / 2));
this.graphics.lineTo((-(parent.width) / 2), (-(parent.height) / 2));
this.graphics.endFill();
}
private function playStatusChanged(_arg1:int, _arg2:Boolean):void{
var _local3:int;
_local3 = 0;
while (_local3 < playerGroups.length) {
if (playerGroups[_local3].playID != _arg1){
} else {
playerGroups[_local3].showPlaying(_arg2);
break;
};
_local3++;
};
differentiatePlayerGroups();
if (isSorted){
sortPlayers();
};
showHideArrows();
}
private function playerViewsPlay(_arg1:int, _arg2:int, _arg3:Boolean):void{
var _local6:int;
var _local8:int;
var _local4:PlayPlayer;
var _local5:PlayerGroup;
var _local7:PlayerGroup;
if (_arg1 == this.playerID){
Object(parent).playID = _arg2;
};
_local8 = 0;
while (_local8 < playerGroups.length) {
_local4 = playerGroups[_local8].getPlayerViewer(_arg1);
if (_local4 == null){
} else {
_local6 = _local8;
_local5 = playerGroups[_local8];
break;
};
_local8++;
};
_local8 = 0;
while (_local8 < playerGroups.length) {
if (playerGroups[_local8].playID == _arg2){
_local7 = playerGroups[_local8];
break;
};
_local8++;
};
_local5.removePlayerViewer(_arg1);
if ((((_local5.players.length == 0)) && ((_local5.viewers.length == 0)))){
playersHolder.removeChild(_local5);
playerGroups.splice(_local6, 1);
};
_local7.addViewer(_arg1, _local4.playerName, (_arg1 == this.playerID), _local4.isRobot);
differentiatePlayerGroups();
if (isSorted){
sortPlayers();
};
showHideArrows();
}
private function onPlayerGroupMouseOver(_arg1:MouseEvent):void{
var _local2:PlayerGroup = PlayerGroup(_arg1.currentTarget);
destroyBubble();
bubble = new Bubble();
bubble.initialize(_local2, currentPlayerGroup, (playerID == currentPlayerGroup.players[0].playerID), noOfPlayers);
bubblesHolder.addChild(bubble);
}
private function playerLeavesPlay(_arg1:int, _arg2:int):void{
var _local5:int;
var _local6:int;
var _local3:PlayPlayer;
var _local4:PlayerGroup;
if (_arg1 == this.playerID){
Object(parent).playID = 0;
};
_local6 = 0;
while (_local6 < playerGroups.length) {
_local3 = playerGroups[_local6].getPlayerViewer(_arg1);
if (_local3 == null){
} else {
_local5 = _local6;
_local4 = playerGroups[_local6];
break;
};
_local6++;
};
_local4.removePlayerViewer(_arg1);
if (_local4.players.length == 0){
playersHolder.removeChild(_local4);
playerGroups.splice(_local5, 1);
};
addGamePlayer(_arg1, _local3.playerName, _local3.isRobot);
differentiatePlayerGroups();
if (isSorted){
sortPlayers();
};
showHideArrows();
if ((((_arg2 == Object(parent).playID)) && (!((_arg1 == this.playerID))))){
Object(parent).soundLeave.play();
};
}
private function destroyBubble():void{
if (bubble){
bubblesHolder.removeChild(bubble);
};
bubble = null;
}
private function sendInvite(_arg1:int, _arg2:int):void{
Object(parent).sendInvite(_arg1, _arg2);
}
private function startNewPlay(_arg1:int=0):void{
Object(parent).showNewTable(_arg1);
}
private function sortPlayers():void{
var _local1:Number;
var _local2:Number;
var _local3:Rectangle;
var _local4:Array;
var _local5:Number;
var _local6:int;
var _local7:int;
_local1 = (-(parent.width) / 2);
_local2 = (-(parent.height) / 2);
_local3 = currentPlayerGroup.getBounds(currentPlayerGroup);
currentPlayerGroup.x = (_local1 - (_local3.left * Config.PLAYERSDISPLAY_GROUPSCALE));
currentPlayerGroup.y = (_local2 - (_local3.top * Config.PLAYERSDISPLAY_GROUPSCALE));
_local2 = (_local2 + (currentPlayerGroup.height + Config.PLAYERSDISPLAY_SORTSPACINGY));
_local4 = [idlePlayerGroups, waitingPlayerGroups, playingPlayerGroups];
_local6 = 0;
while (_local6 < _local4.length) {
_local5 = 0;
_local7 = 0;
while (_local7 < _local4[_local6].length) {
if (_local4[_local6][_local7].height > _local5){
_local5 = _local4[_local6][_local7].height;
};
_local7++;
};
_local7 = 0;
while (_local7 < _local4[_local6].length) {
_local3 = _local4[_local6][_local7].getBounds(_local4[_local6][_local7]);
_local4[_local6][_local7].x = (_local1 - _local3.left);
_local4[_local6][_local7].y = ((_local2 - _local3.top) + ((_local5 - _local3.height) / 2));
_local1 = (_local1 + (_local4[_local6][_local7].width + Config.PLAYERSDISPLAY_SORTSPACINGX));
_local7++;
};
_local1 = (-(parent.width) / 2);
_local2 = (_local2 + (_local5 + Config.PLAYERSDISPLAY_SORTSPACINGY));
_local6++;
};
}
private function onPlayerGroupMouseOut(_arg1:MouseEvent):void{
destroyBubble();
}
private function showHideArrows():void{
var _local1:Rectangle = playersHolder.getBounds(this);
leftButton.visible = (_local1.left < (-(parent.width) / 2));
rightButton.visible = (_local1.right > (parent.width / 2));
upButton.visible = (_local1.top < (-(parent.height) / 2));
downButton.visible = (_local1.bottom > (parent.height / 2));
}
private function startScroll():void{
scrollLastTime = getTimer();
if (scrollTimer){
scrollTimer.stop();
};
scrollTimer = new Timer(1, 0);
scrollTimer.addEventListener(TimerEvent.TIMER, onScrollTime);
scrollTimer.start();
}
public function updateGamePlayers(_arg1:XMLNode):void{
if (_arg1.nodeName == "REMOVEGAMEPLAYER"){
removeGamePlayer(int(_arg1.attributes.playerID));
} else {
if (_arg1.nodeName == "ADDGAMEPLAYER"){
addGamePlayer(int(_arg1.attributes.playerID), _arg1.attributes.playerName, (_arg1.attributes.isRobot == "true"));
} else {
if (_arg1.nodeName == "PLAYERJOINSPLAY"){
playerJoinsPlay(int(_arg1.attributes.playerID), int(_arg1.attributes.playID), (_arg1.attributes.byInvitationOnly == "true"));
} else {
if (_arg1.nodeName == "PLAYERVIEWSPLAY"){
playerViewsPlay(int(_arg1.attributes.playerID), int(_arg1.attributes.playID), (_arg1.attributes.byInvitationOnly == "true"));
} else {
if (_arg1.nodeName == "PLAYERLEAVESPLAY"){
playerLeavesPlay(int(_arg1.attributes.playerID), int(_arg1.attributes.playID));
} else {
if (_arg1.nodeName == "PLAYSTATUSCHANGED"){
playStatusChanged(int(_arg1.attributes.playID), (_arg1.attributes.isPlaying == "true"));
};
};
};
};
};
};
}
private function startScrollUp(_arg1:MouseEvent):void{
scrollDirectionX = 0;
scrollDirectionY = 1;
startScroll();
}
private function arrangeNextPlayerGroup(_arg1:PlayerGroup):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Array;
var _local11:int;
var _local12:int;
_local2 = 0;
_local3 = 0;
_local4 = 0;
_local5 = 0;
_local12 = 0;
while (_local12 < playerGroups.length) {
if ((playerGroups[_local12].x - (Config.PLAYERSDISPLAY_GROUPSPACINGX / 2)) < _local2){
_local2 = (playerGroups[_local12].x - (Config.PLAYERSDISPLAY_GROUPSPACINGX / 2));
};
if ((playerGroups[_local12].x + (Config.PLAYERSDISPLAY_GROUPSPACINGX / 2)) > _local4){
_local4 = (playerGroups[_local12].x + (Config.PLAYERSDISPLAY_GROUPSPACINGX / 2));
};
if ((playerGroups[_local12].y - (Config.PLAYERSDISPLAY_GROUPSPACINGY / 2)) < _local3){
_local3 = (playerGroups[_local12].y - (Config.PLAYERSDISPLAY_GROUPSPACINGY / 2));
};
if ((playerGroups[_local12].y + (Config.PLAYERSDISPLAY_GROUPSPACINGY / 2)) > _local5){
_local5 = (playerGroups[_local12].y + (Config.PLAYERSDISPLAY_GROUPSPACINGY / 2));
};
_local12++;
};
_local6 = Math.min(-(_local2), _local4);
_local7 = Math.min(-(_local3), _local5);
_local10 = new Array();
if (_local6 < _local7){
_local11 = ((-(_local2) < _local4)) ? -1 : 1;
_local9 = ((_local3 + (Config.PLAYERSDISPLAY_GROUPSPACINGY / 2)) + (Math.random() * ((_local5 - _local3) - Config.PLAYERSDISPLAY_GROUPSPACINGY)));
_local12 = 0;
while (_local12 < playerGroups.length) {
if (((playerGroups[_local12].x + (_local11 * Config.PLAYERSDISPLAY_GROUPSPACINGX)) * _local11) < 0){
} else {
if (Math.abs((playerGroups[_local12].y - _local9)) > Config.PLAYERSDISPLAY_GROUPSPACINGY){
} else {
_local10.push(playerGroups[_local12]);
};
};
_local12++;
};
_local8 = 0;
while (true) {
_local12 = 0;
while (_local12 < _local10.length) {
if (Math.abs((_local10[_local12].x - _local8)) >= Config.PLAYERSDISPLAY_GROUPSPACINGX){
} else {
_local8 = (_local10[_local12].x + (_local11 * (Config.PLAYERSDISPLAY_GROUPSPACINGX + 1)));
break;
};
_local12++;
};
if (_local12 >= _local10.length){
break;
};
};
} else {
_local11 = ((-(_local3) < _local5)) ? -1 : 1;
_local8 = ((_local2 + (Config.PLAYERSDISPLAY_GROUPSPACINGX / 2)) + (Math.random() * ((_local4 - _local2) - Config.PLAYERSDISPLAY_GROUPSPACINGX)));
_local12 = 0;
while (_local12 < playerGroups.length) {
if (((playerGroups[_local12].y + (_local11 * Config.PLAYERSDISPLAY_GROUPSPACINGY)) * _local11) < 0){
} else {
if (Math.abs((playerGroups[_local12].x - _local8)) > Config.PLAYERSDISPLAY_GROUPSPACINGX){
} else {
_local10.push(playerGroups[_local12]);
};
};
_local12++;
};
_local9 = 0;
while (true) {
_local12 = 0;
while (_local12 < _local10.length) {
if (Math.abs((_local10[_local12].y - _local9)) >= Config.PLAYERSDISPLAY_GROUPSPACINGY){
} else {
_local9 = (_local10[_local12].y + (_local11 * (Config.PLAYERSDISPLAY_GROUPSPACINGY + 1)));
break;
};
_local12++;
};
if (_local12 >= _local10.length){
break;
};
};
};
_arg1.x = _local8;
_arg1.y = _local9;
}
private function arrangePlayerGroups():void{
var _local2:int;
var _local1:Array = playerGroups;
playerGroups = new Array();
_local2 = 0;
while (_local2 < _local1.length) {
if (!_local1[_local2].isCurrentPlayer){
} else {
playerGroups = [_local1[_local2]];
_local1.splice(_local2, 1);
break;
};
_local2++;
};
playerGroups[0].x = 0;
playerGroups[0].y = 0;
_local2 = 0;
while (_local2 < _local1.length) {
arrangeNextPlayerGroup(_local1[_local2]);
playerGroups.push(_local1[_local2]);
_local2++;
};
}
private function initializeButtons():void{
leftButton.x = (((-(parent.width) / 2) + (leftButton.width / 2)) + Config.PLAYERSDISPLAY_BUTTONMARGIN);
rightButton.x = (((parent.width / 2) - (rightButton.width / 2)) - Config.PLAYERSDISPLAY_BUTTONMARGIN);
upButton.y = (((-(parent.height) / 2) + (upButton.height / 2)) + Config.PLAYERSDISPLAY_BUTTONMARGIN);
downButton.y = (((parent.height / 2) - (downButton.height / 2)) - Config.PLAYERSDISPLAY_BUTTONMARGIN);
sortButton.x = (sortButton.x + ((((parent.width / 2) - (cancelButton.width / 2)) - Config.PLAYERSDISPLAY_BUTTONMARGIN) - cancelButton.x));
sortButton.y = (sortButton.y + ((((-(parent.height) / 2) + (cancelButton.height / 2)) + Config.PLAYERSDISPLAY_BUTTONMARGIN) - cancelButton.y));
cancelButton.x = (((parent.width / 2) - (cancelButton.width / 2)) - Config.PLAYERSDISPLAY_BUTTONMARGIN);
cancelButton.y = (((-(parent.height) / 2) + (cancelButton.height / 2)) + Config.PLAYERSDISPLAY_BUTTONMARGIN);
sortButton.addEventListener(MouseEvent.CLICK, startSortPlayers);
leftButton.addEventListener(MouseEvent.MOUSE_DOWN, startScrollLeft);
leftButton.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
rightButton.addEventListener(MouseEvent.MOUSE_DOWN, startScrollRight);
rightButton.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
upButton.addEventListener(MouseEvent.MOUSE_DOWN, startScrollUp);
upButton.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
downButton.addEventListener(MouseEvent.MOUSE_DOWN, startScrollDown);
downButton.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
showHideArrows();
}
private function startSortPlayers(_arg1:MouseEvent):void{
var _local2:int;
isSorted = true;
sortButton.visible = false;
_local2 = 0;
while (_local2 < playerGroups.length) {
playerGroups[_local2].beginX = playerGroups[_local2].x;
playerGroups[_local2].beginY = playerGroups[_local2].y;
_local2++;
};
sortPlayers();
_local2 = 0;
while (_local2 < playerGroups.length) {
playerGroups[_local2].endX = playerGroups[_local2].x;
playerGroups[_local2].endY = playerGroups[_local2].y;
playerGroups[_local2].x = playerGroups[_local2].beginX;
playerGroups[_local2].y = playerGroups[_local2].beginY;
_local2++;
};
sortStartX = playersHolder.x;
sortStartY = playersHolder.y;
sortStartTime = getTimer();
sortTimer = new Timer(1, 0);
sortTimer.addEventListener(TimerEvent.TIMER, onSortTime);
sortTimer.start();
}
private function startScrollLeft(_arg1:MouseEvent):void{
scrollDirectionX = 1;
scrollDirectionY = 0;
startScroll();
}
private function onScrollTime(_arg1:TimerEvent):void{
var _local4:Rectangle;
var _local2:int = getTimer();
var _local3:int = (_local2 - scrollLastTime);
_arg1.updateAfterEvent();
playersHolder.x = (playersHolder.x + (((scrollDirectionX * _local3) * Config.PLAYERSDISPLAY_SCROLLSPEED) / 1000));
playersHolder.y = (playersHolder.y + (((scrollDirectionY * _local3) * Config.PLAYERSDISPLAY_SCROLLSPEED) / 1000));
_local4 = playersHolder.getBounds(this);
if ((((scrollDirectionX > 0)) && ((_local4.left > (-(parent.width) / 2))))){
playersHolder.x = (playersHolder.x - (_local4.left + (parent.width / 2)));
scrollTimer.stop();
} else {
if ((((scrollDirectionX < 0)) && ((_local4.right < (parent.width / 2))))){
playersHolder.x = (playersHolder.x + ((parent.width / 2) - _local4.right));
scrollTimer.stop();
};
};
if ((((scrollDirectionY > 0)) && ((_local4.top > (-(parent.height) / 2))))){
playersHolder.y = (playersHolder.y - (_local4.top + (parent.height / 2)));
scrollTimer.stop();
} else {
if ((((scrollDirectionY < 0)) && ((_local4.bottom < (parent.height / 2))))){
playersHolder.y = (playersHolder.y + ((parent.height / 2) - _local4.bottom));
scrollTimer.stop();
};
};
bubblesHolder.x = playersHolder.x;
bubblesHolder.y = playersHolder.y;
showHideArrows();
scrollLastTime = _local2;
}
}
}//package com.novelgames.multiplayerflashgames.connector
Section 27
//InvitationSentDialog (com.novelgames.multiplayerflashgames.connector.InvitationSentDialog)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
public dynamic class InvitationSentDialog extends MovieClip {
public var okButton:SimpleButton;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 28
//InviteDialog (com.novelgames.multiplayerflashgames.connector.InviteDialog)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.xml.*;
import flash.text.*;
public class InviteDialog extends MovieClip {
public var playerGroup:PlayerGroup;
public var playID:int;
public var noButton:SimpleButton;
public var nameText:TextField;
public var yesButton:SimpleButton;
public function initialize(_arg1:XMLNode):void{
var _local2:int;
var _local3:String;
var _local4:int;
var _local5:Array;
var _local6:Array;
var _local7:XMLNode;
var _local8:int;
_local2 = int(_arg1.attributes.playerID);
_local3 = _arg1.attributes.playerName;
_local4 = int(_arg1.attributes.playID);
_local5 = new Array();
_local6 = new Array();
_local7 = _arg1.firstChild;
while (_local7 != null) {
if (_local7.nodeName != "PLAYER"){
} else {
_local5.push(_local7.attributes.playerName);
_local6.push((_local7.attributes.isRobot == "true"));
};
_local7 = _local7.nextSibling;
};
this.playID = _local4;
nameText.text = _local3;
playerGroup.initialize();
playerGroup.showTable(_local4, false);
_local8 = 0;
while (_local8 < _local5.length) {
playerGroup.addPlayer(0, _local5[_local8], false, _local6[_local8]);
_local8++;
};
}
}
}//package com.novelgames.multiplayerflashgames.connector
Section 29
//JoinFailedDialog (com.novelgames.multiplayerflashgames.connector.JoinFailedDialog)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
public dynamic class JoinFailedDialog extends MovieClip {
public var cancelButton:SimpleButton;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 30
//MD5 (com.novelgames.multiplayerflashgames.connector.MD5)
package com.novelgames.multiplayerflashgames.connector {
public class MD5 {
private static function hexByteToString(_arg1:uint):String{
var _local2:String = _arg1.toString(16);
while (_local2.length < 2) {
_local2 = ("0" + _local2);
};
return (_local2);
}
private static function leftRotate(_arg1:uint, _arg2:int):uint{
var _local3:uint = ((1 << _arg2) - 1);
return (((_arg1 << _arg2) | ((_arg1 >> (32 - _arg2)) & _local3)));
}
private static function getUTF8Bytes(_arg1:String):Array{
var _local3:uint;
var _local4:int;
var _local2:Array = new Array();
_local4 = 0;
while (_local4 < _arg1.length) {
_local3 = _arg1.charCodeAt(_local4);
if (_local3 <= 127){
_local2.push(_local3);
} else {
_local2.push((224 | (_local3 >> 12)));
_local2.push((128 | ((_local3 >> 6) & 63)));
_local2.push((128 | (_local3 & 63)));
};
_local4++;
};
return (_local2);
}
public static function md5(_arg1:String){
var _local2:Array;
var _local3:Array;
var _local4:int;
var _local5:int;
var _local6:int;
var _local14:Array;
var _local15:uint;
var _local16:uint;
var _local17:uint;
var _local18:uint;
var _local19:uint;
var _local20:uint;
var _local21:*;
_local2 = [7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21];
_local3 = new Array(64);
_local4 = 0;
while (_local4 < 64) {
_local3[_local4] = Math.floor((Math.abs(Math.sin((_local4 + 1))) * Math.pow(2, 32)));
_local4++;
};
var _local7:uint = 1732584193;
var _local8:uint = 4023233417;
var _local9:uint = 2562383102;
var _local10:uint = 271733878;
var _local11:Array = getUTF8Bytes(_arg1);
var _local12:int = (_local11.length * 8);
_local11.push(128);
while (((_local11.length * 8) % 0x0200) != 448) {
_local11.push(0);
};
_local11.push((_local12 & 0xFF));
_local11.push(((_local12 >> 8) & 0xFF));
_local11.push(((_local12 >> 16) & 0xFF));
_local11.push(((_local12 >> 24) & 0xFF));
_local11.push(0);
_local11.push(0);
_local11.push(0);
_local11.push(0);
var _local13:int = ((_local11.length * 8) / 0x0200);
_local6 = 0;
while (_local6 < _local13) {
_local14 = new Array(16);
_local5 = 0;
while (_local5 < 16) {
_local14[_local5] = ((((_local11[(((_local6 * 64) + (_local5 * 4)) + 3)] << 24) | (_local11[(((_local6 * 64) + (_local5 * 4)) + 2)] << 16)) | (_local11[(((_local6 * 64) + (_local5 * 4)) + 1)] << 8)) | _local11[((_local6 * 64) + (_local5 * 4))]);
_local5++;
};
_local15 = _local7;
_local16 = _local8;
_local17 = _local9;
_local18 = _local10;
_local4 = 0;
while (_local4 < 64) {
if (_local4 < 16){
_local19 = ((_local16 & _local17) | (~(_local16) & _local18));
_local20 = _local4;
} else {
if (_local4 < 32){
_local19 = ((_local18 & _local16) | (~(_local18) & _local17));
_local20 = (((5 * _local4) + 1) % 16);
} else {
if (_local4 < 48){
_local19 = ((_local16 ^ _local17) ^ _local18);
_local20 = (((3 * _local4) + 5) % 16);
} else {
_local19 = (_local17 ^ (_local16 | ~(_local18)));
_local20 = ((7 * _local4) % 16);
};
};
};
_local21 = _local18;
_local18 = _local17;
_local17 = _local16;
_local16 = (_local16 + leftRotate((((_local15 + _local19) + _local3[_local4]) + _local14[_local20]), _local2[_local4]));
_local15 = _local21;
_local4++;
};
_local7 = (_local7 + _local15);
_local8 = (_local8 + _local16);
_local9 = (_local9 + _local17);
_local10 = (_local10 + _local18);
_local6++;
};
return ((((hexToString(_local7) + hexToString(_local8)) + hexToString(_local9)) + hexToString(_local10)));
}
private static function hexToString(_arg1:uint):String{
return ((((hexByteToString((_arg1 & 0xFF)) + hexByteToString(((_arg1 >> 8) & 0xFF))) + hexByteToString(((_arg1 >> 16) & 0xFF))) + hexByteToString(((_arg1 >> 24) & 0xFF))));
}
}
}//package com.novelgames.multiplayerflashgames.connector
Section 31
//ModuleTextPage (com.novelgames.multiplayerflashgames.connector.ModuleTextPage)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
public dynamic class ModuleTextPage extends MovieClip {
}
}//package com.novelgames.multiplayerflashgames.connector
Section 32
//NewTableDialog (com.novelgames.multiplayerflashgames.connector.NewTableDialog)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.events.*;
public class NewTableDialog extends MovieClip {
public var allPlayersCheckBox:MovieClip;
public var playerGroupHolder:MovieClip;
public var okButton:SimpleButton;
public var invitedPlayersCheckBox:MovieClip;
public var byInvitationOnly:Boolean;
private function allPlayersSelected(_arg1:MouseEvent):void{
byInvitationOnly = false;
allPlayersCheckBox.gotoAndStop("selected");
invitedPlayersCheckBox.gotoAndStop("normal");
}
public function initialize(_arg1:int, _arg2:String):void{
var _local3:PlayerGroup = new PlayerGroup();
_local3.initialize();
_local3.showTable(0, false);
_local3.addPlayer(_arg1, _arg2, true, false);
playerGroupHolder.addChild(_local3);
byInvitationOnly = false;
allPlayersCheckBox.gotoAndStop("selected");
invitedPlayersCheckBox.gotoAndStop("normal");
allPlayersCheckBox.addEventListener(MouseEvent.MOUSE_DOWN, allPlayersSelected);
allPlayersCheckBox.buttonMode = true;
invitedPlayersCheckBox.addEventListener(MouseEvent.MOUSE_DOWN, invitedPlayersSelected);
invitedPlayersCheckBox.buttonMode = true;
}
private function invitedPlayersSelected(_arg1:MouseEvent):void{
byInvitationOnly = true;
allPlayersCheckBox.gotoAndStop("normal");
invitedPlayersCheckBox.gotoAndStop("selected");
}
}
}//package com.novelgames.multiplayerflashgames.connector
Section 33
//PlayerGroup (com.novelgames.multiplayerflashgames.connector.PlayerGroup)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class PlayerGroup extends MovieClip {
private var things:Array;
private var table:PlayTable;
public var playID:int;
public var beginY:Number;
public var thingsHolder:MovieClip;
public var beginX:Number;
public var endX:Number;
public var viewers:Array;
public var byInvitationOnly:Boolean;
public var endY:Number;
public var isPlaying:Boolean;
public var isCurrentPlayer:Boolean;
public var players:Array;
public function getPlayerViewer(_arg1:int):PlayPlayer{
var _local2:int;
_local2 = 0;
while (_local2 < players.length) {
if (players[_local2].playerID == _arg1){
return (players[_local2]);
};
_local2++;
};
_local2 = 0;
while (_local2 < viewers.length) {
if (viewers[_local2].playerID == _arg1){
return (viewers[_local2]);
};
_local2++;
};
return (null);
}
public function addViewer(_arg1:int, _arg2:String, _arg3:Boolean, _arg4:Boolean):void{
var _local5:PlayPlayer = new PlayPlayer();
_local5.playerID = _arg1;
_local5.playerName = _arg2;
_local5.setIsRobot(_arg4);
viewers.push(_local5);
things.push(_local5);
thingsHolder.addChild(_local5);
if (_arg3){
this.isCurrentPlayer = true;
_local5.showYou();
};
if (table == null){
return;
};
arrangePlayers();
orderThings();
}
public function initialize():void{
this.playID = 0;
this.byInvitationOnly = false;
this.isPlaying = false;
players = new Array();
viewers = new Array();
things = new Array();
isCurrentPlayer = false;
}
public function showTable(_arg1:int, _arg2:Boolean):void{
this.playID = _arg1;
this.byInvitationOnly = _arg2;
table = new PlayTable();
table.gotoAndStop("normal");
thingsHolder.addChild(table);
things = [table];
}
public function getPlayer(_arg1:int):PlayPlayer{
var _local2:int;
_local2 = 0;
while (_local2 < players.length) {
if (players[_local2].playerID == _arg1){
return (players[_local2]);
};
_local2++;
};
return (null);
}
public function addPlayer(_arg1:int, _arg2:String, _arg3:Boolean, _arg4:Boolean):void{
var _local5:PlayPlayer = new PlayPlayer();
_local5.playerID = _arg1;
_local5.playerName = _arg2;
_local5.setIsRobot(_arg4);
players.push(_local5);
things.push(_local5);
thingsHolder.addChild(_local5);
if (_arg3){
this.isCurrentPlayer = true;
_local5.showYou();
};
if (table == null){
return;
};
arrangePlayers();
orderThings();
}
public function showPlaying(_arg1:Boolean):void{
this.isPlaying = _arg1;
table.gotoAndStop((_arg1) ? "playing" : "normal");
}
private function orderThings():void{
var i:int;
things.sort(function (_arg1, _arg2):int{
if (_arg1.y < _arg2.y){
return (-1);
};
if (_arg1.y > _arg2.y){
return (1);
};
if (_arg1.x < _arg2.x){
return (-1);
};
if (_arg1.x > _arg2.x){
return (1);
};
return (0);
});
i = 0;
while (i < things.length) {
thingsHolder.setChildIndex(things[i], i);
i = (i + 1);
};
}
private function arrangePlayers():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:int;
if (Config.PLAYERSDISPLAY_TABLEWIDTH > Config.PLAYERSDISPLAY_TABLEHEIGHT){
_local1 = (Config.PLAYERSDISPLAY_TABLEWIDTH / 2);
_local2 = 1;
_local3 = (Config.PLAYERSDISPLAY_TABLEHEIGHT / Config.PLAYERSDISPLAY_TABLEWIDTH);
} else {
_local1 = (Config.PLAYERSDISPLAY_TABLEHEIGHT / 2);
_local2 = (Config.PLAYERSDISPLAY_TABLEWIDTH / Config.PLAYERSDISPLAY_TABLEHEIGHT);
_local3 = 1;
};
_local4 = (360 / players.length);
_local6 = 0;
while (_local6 < players.length) {
_local5 = (Config.PLAYERSDISPLAY_TABLESTARTANGLE + (_local6 * _local4));
players[_local6].x = ((_local1 * Math.cos(((_local5 * Math.PI) / 180))) * _local2);
players[_local6].y = ((_local1 * Math.sin(((_local5 * Math.PI) / 180))) * _local3);
_local6++;
};
if (Config.PLAYERSDISPLAY_TABLEWIDTH > Config.PLAYERSDISPLAY_TABLEHEIGHT){
_local1 = (Config.PLAYERSDISPLAY_TABLEVIEWWIDTH / 2);
} else {
_local1 = (Config.PLAYERSDISPLAY_TABLEVIEWHEIGHT / 2);
};
_local4 = (360 / viewers.length);
_local6 = 0;
while (_local6 < viewers.length) {
_local5 = (Config.PLAYERSDISPLAY_TABLEVIEWSTARTANGLE + (_local6 * _local4));
viewers[_local6].x = ((_local1 * Math.cos(((_local5 * Math.PI) / 180))) * _local2);
viewers[_local6].y = ((_local1 * Math.sin(((_local5 * Math.PI) / 180))) * _local3);
_local6++;
};
}
public function removePlayerViewer(_arg1:int):Boolean{
var _local3:int;
var _local2:PlayPlayer;
_local3 = 0;
while (_local3 < players.length) {
if (players[_local3].playerID == _arg1){
_local2 = players[_local3];
players.splice(_local3, 1);
break;
};
_local3++;
};
_local3 = 0;
while (_local3 < viewers.length) {
if (viewers[_local3].playerID == _arg1){
_local2 = viewers[_local3];
viewers.splice(_local3, 1);
break;
};
_local3++;
};
if (_local2 == null){
return (false);
};
_local3 = 0;
while (_local3 < things.length) {
if (things[_local3] == _local2){
things.splice(_local3, 1);
break;
};
_local3++;
};
thingsHolder.removeChild(_local2);
arrangePlayers();
orderThings();
return (true);
}
public function startNewPlay(_arg1:int, _arg2:Boolean):void{
var _local3:int = players[0].playerID;
var _local4:String = players[0].playerName;
var _local5:Boolean = players[0].isRobot;
this.playID = _arg1;
this.byInvitationOnly = _arg2;
table = new PlayTable();
table.gotoAndStop("normal");
thingsHolder.addChild(table);
things.push(table);
removePlayerViewer(_local3);
addPlayer(_local3, _local4, isCurrentPlayer, _local5);
orderThings();
}
}
}//package com.novelgames.multiplayerflashgames.connector
Section 34
//PlayerInfo (com.novelgames.multiplayerflashgames.connector.PlayerInfo)
package com.novelgames.multiplayerflashgames.connector {
public class PlayerInfo {
public var playerID:int;
public var disconnected:Boolean;
public var playerName:String;
public function PlayerInfo(_arg1:int, _arg2:String){
this.playerID = _arg1;
this.playerName = _arg2;
disconnected = false;
}
}
}//package com.novelgames.multiplayerflashgames.connector
Section 35
//PlayPlayer (com.novelgames.multiplayerflashgames.connector.PlayPlayer)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
public class PlayPlayer extends MovieClip {
public var isRobot:Boolean;
public var playerID:int;
public var playerName:String;
public function initialize(_arg1:PlayerInfo):void{
playerName = _arg1.playerName;
}
public function showYou():void{
gotoAndStop("you");
}
public function setIsRobot(_arg1:Boolean):void{
this.isRobot = _arg1;
gotoAndStop((_arg1) ? "robot" : "human");
}
}
}//package com.novelgames.multiplayerflashgames.connector
Section 36
//PlayPlayerHighlight (com.novelgames.multiplayerflashgames.connector.PlayPlayerHighlight)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
public dynamic class PlayPlayerHighlight extends MovieClip {
}
}//package com.novelgames.multiplayerflashgames.connector
Section 37
//PlayTable (com.novelgames.multiplayerflashgames.connector.PlayTable)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
public dynamic class PlayTable extends MovieClip {
}
}//package com.novelgames.multiplayerflashgames.connector
Section 38
//RegisterFailedDialog (com.novelgames.multiplayerflashgames.connector.RegisterFailedDialog)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
import flash.text.*;
public dynamic class RegisterFailedDialog extends MovieClip {
public var reasonText:MovieClip;
public var nameText:TextField;
public var okButton:SimpleButton;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 39
//SoundJoin (com.novelgames.multiplayerflashgames.connector.SoundJoin)
package com.novelgames.multiplayerflashgames.connector {
import flash.media.*;
public dynamic class SoundJoin extends Sound {
}
}//package com.novelgames.multiplayerflashgames.connector
Section 40
//SoundLeave (com.novelgames.multiplayerflashgames.connector.SoundLeave)
package com.novelgames.multiplayerflashgames.connector {
import flash.media.*;
public dynamic class SoundLeave extends Sound {
}
}//package com.novelgames.multiplayerflashgames.connector
Section 41
//StartFailedDialog (com.novelgames.multiplayerflashgames.connector.StartFailedDialog)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
public dynamic class StartFailedDialog extends MovieClip {
public var cancelButton:SimpleButton;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 42
//Util (com.novelgames.multiplayerflashgames.connector.Util)
package com.novelgames.multiplayerflashgames.connector {
public class Util {
public static function getCanStart(_arg1:int, _arg2:Array):Boolean{
var _local3:int;
_local3 = 0;
while (_local3 < _arg2.length) {
if (_arg1 == _arg2[_local3]){
return (true);
};
_local3++;
};
return (false);
}
public static function getCanInvite(_arg1:int, _arg2:Array):Boolean{
return ((_arg1 < _arg2[(_arg2.length - 1)]));
}
public static function getCanJoin(_arg1:Boolean, _arg2:int, _arg3:Array):Boolean{
return (((!(_arg1)) && ((_arg2 < _arg3[(_arg3.length - 1)]))));
}
}
}//package com.novelgames.multiplayerflashgames.connector
Section 43
//WaitDialog (com.novelgames.multiplayerflashgames.connector.WaitDialog)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
public dynamic class WaitDialog extends MovieClip {
}
}//package com.novelgames.multiplayerflashgames.connector
Section 44
//ViewFailedDialog (com.novelgames.multiplayerflashgames.connector.ViewFailedDialog)
package com.novelgames.multiplayerflashgames.connector {
import flash.display.*;
public dynamic class ViewFailedDialog extends MovieClip {
public var cancelButton:SimpleButton;
}
}//package com.novelgames.multiplayerflashgames.connector
Section 45
//Arrow (com.novelgames.multiplayerflashgames.eightball.Arrow)
package com.novelgames.multiplayerflashgames.eightball {
import flash.display.*;
public class Arrow extends MovieClip {
private var maskLength:Number;
public var arrowMask:MovieClip;
public function Arrow(){
maskLength = arrowMask.width;
}
public function setRatio(_arg1:Number):void{
arrowMask.x = (maskLength * _arg1);
}
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 46
//Ball (com.novelgames.multiplayerflashgames.eightball.Ball)
package com.novelgames.multiplayerflashgames.eightball {
import flash.display.*;
public class Ball extends MovieClip {
public var cross:MovieClip;
public var speedY:Number;
public var number:int;
public var totalFallTime:int;
public var speed:Number;
public var fallRatio:Number;
private var __realX:Number;
private var __realY:Number;
public var isWhite:Boolean;
public var isSolid:Boolean;
public var speedX:Number;
public var isBlack:Boolean;
public var directionX:Number;
public var directionY:Number;
public function Ball(){
speedX = 0;
speedY = 0;
speed = 0;
fallRatio = 0;
totalFallTime = 0;
cross.visible = false;
this.cacheAsBitmap = true;
}
public function set realX(_arg1:Number):void{
__realX = _arg1;
x = _arg1;
}
public function setSpeed(_arg1:Number, _arg2:Number):void{
this.speedX = _arg1;
this.speedY = _arg2;
speed = Math.sqrt(((_arg1 * _arg1) + (_arg2 * _arg2)));
directionX = (_arg1 / speed);
directionY = (_arg2 / speed);
}
public function get realY():Number{
return (__realY);
}
public function resetFallTime():void{
this.scaleX = 1;
this.scaleY = 1;
fallRatio = 0;
totalFallTime = 0;
}
public function get realX():Number{
return (__realX);
}
public function setSpeedDirection(_arg1:Number, _arg2:Number, _arg3:Number):void{
this.speed = _arg1;
this.directionX = _arg2;
this.directionY = _arg3;
speedX = (_arg1 * _arg2);
speedY = (_arg1 * _arg3);
}
public function hideCross():void{
cross.visible = false;
}
public function showCross():void{
cross.visible = true;
}
public function setWhite():void{
isWhite = true;
this.number = 0;
gotoAndStop(1);
}
public function setNormal(_arg1:int):void{
var _local2:int;
isWhite = false;
isBlack = (_arg1 == Config.BALL_BLACK);
this.number = _arg1;
_local2 = 0;
while (_local2 < Config.BALL_SOLIDS.length) {
if (Config.BALL_SOLIDS[_local2] == _arg1){
break;
};
_local2++;
};
if (_local2 < Config.BALL_SOLIDS.length){
isSolid = true;
} else {
isSolid = false;
};
gotoAndStop((_arg1 + 1));
}
public function addFallTime(_arg1:int):void{
totalFallTime = (totalFallTime + _arg1);
if (totalFallTime >= Config.BALL_HOLETIME){
totalFallTime = Config.BALL_HOLETIME;
};
fallRatio = (totalFallTime / Config.BALL_HOLETIME);
this.scaleX = (1 - fallRatio);
this.scaleY = (1 - fallRatio);
}
public function set realY(_arg1:Number):void{
__realY = _arg1;
y = _arg1;
}
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 47
//Config (com.novelgames.multiplayerflashgames.eightball.Config)
package com.novelgames.multiplayerflashgames.eightball {
public class Config {
public static var LINE_DASHSPACING:Number = 4;
public static var CUE_MAXSPACING:Number = 100;
public static var TABLE_FOOTSPOTX:Number = 120;
public static var TABLE_FOOTSPOTY:Number = 0;
public static var VIEW_MINMESSAGETIME:int = 1000;
public static var BALL_BLACK:int = 8;
public static var CUE_SHOOTTIME:int = 100;
public static var BALL_MAXSPEED:Number = 1000;
public static var BALL_HOLEDECELERATION:Number = 5000;
public static var LINE_DASHLENGTH:Number = 3;
public static var LINE_EXITLENGTH:Number = 40;
public static var LINE_ALPHA:Number = 0.6;
public static var LINE_TANGENTLENGTH:Number = 50;
public static var BALL_PUTTINGALPHA:Number = 0.5;
public static var MESSAGE_RESULTTIME:int = 1000;
public static var BALL_CUSIONSPEEDLOST:Number = 0.2;
public static var LINE_THICKNESS:Number = 2;
public static var MESSAGE_ILLEGALTIME:int = 2000;
public static var BALL_HOLETIME:int = 100;
public static var BALL_RADIUS:Number = 10;
public static var MESSAGE_FOULTIME:int = 2000;
public static var BALL_DECELERATION:Number = 100;
public static var MESSAGE_DISCONNECTEDTIME:int = 2000;
public static var BALL_STRIPES:Array = [9, 10, 11, 12, 13, 14, 15];
public static var FINISHEDWAIT:int = 1000;
public static var BALL_SOLIDS:Array = [1, 2, 3, 4, 5, 6, 7];
public static var HOLE_RADIUS:Number = 15;
public static var CUE_PERIOD:Number = 2000;
public static var INITIALWAITTIME:int = 100;
public static var TABLE_HEADSTRINGX:Number = -140;
public static var LINE_COLOUR:uint = 13497542;
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 48
//Cue (com.novelgames.multiplayerflashgames.eightball.Cue)
package com.novelgames.multiplayerflashgames.eightball {
import flash.display.*;
public class Cue extends MovieClip {
public var cue:MovieClip;
private var x0:Number;
private var x1:Number;
public function Cue(){
x0 = (cue.x - Config.BALL_RADIUS);
x1 = (x0 - Config.CUE_MAXSPACING);
}
public function setRatio(_arg1:Number):void{
cue.x = ((x0 * (1 - _arg1)) + (x1 * _arg1));
}
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 49
//Game (com.novelgames.multiplayerflashgames.eightball.Game)
package com.novelgames.multiplayerflashgames.eightball {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import com.novelgames.multiplayerflashgames.common.*;
import flash.media.*;
import flash.xml.*;
import flash.text.*;
import flash.geom.*;
public class Game extends Game {
public var message:Message;
public var arrow:Arrow;
public var ballsHolder:MovieClip;
public var tableAreasHolder:MovieClip;
private var cannotPocketBlackBall:Boolean;
public var cue:Cue;
private var whiteBallTouched:Boolean;
private var currentPlayerIndex:int;
private var shrinkedCorners:Array;
private var shrinkedBorders:Array;
private var timer:Timer;
private var soundWin:Sound;
private var startTime:int;
private var balls:Array;
private var whiteBallTouchedCorrect:Boolean;
private var shootForceRatio:Number;
public var clickDetector:MovieClip;
private var blackBallPocketed:Boolean;
private var tableArea:MovieClip;
private var lastTime:int;
private var soundPocket:Sound;
public var linesHolder:MovieClip;
private var isViewing:Boolean;
private var isInitialPutBall:Boolean;
private var whiteBallPocketed:Boolean;
private var soundCue:Sound;
private var soundBall:Sound;
private var holes:Array;
private var pocketed:Boolean;
private var borderAreas:Array;
private var corners:Array;
private var soundLose:Sound;
private var ranks:Array;
private var whiteBall:Ball;
public var table:MovieClip;
private var selfIndex:int;
private var playerNames:Array;
private var shootDX:Number;
private var shootDY:Number;
public var playerNameText0:MovieClip;
public var playerNameText1:MovieClip;
private function moveBalls(_arg1:int):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Point;
var _local7:Object;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:int;
_local11 = 0;
while (_local11 < balls.length) {
if (balls[_local11].speed == 0){
} else {
_local2 = balls[_local11].realX;
_local3 = balls[_local11].realY;
_local4 = (balls[_local11].realX + ((balls[_local11].speedX * _arg1) / 1000));
_local5 = (balls[_local11].realY + ((balls[_local11].speedY * _arg1) / 1000));
_local6 = this.localToGlobal(new Point(_local4, _local5));
if (tableArea.hitTestPoint(_local6.x, _local6.y, true)){
_local7 = null;
} else {
_local7 = getHitCusionInfo(_local2, _local3, _local4, _local5);
};
if (!_local7){
balls[_local11].realX = _local4;
balls[_local11].realY = _local5;
} else {
_local8 = (((balls[_local11].speed * _arg1) / 1000) - _local7.length);
if (_local8 < 0){
_local8 = 0;
};
_local9 = Math.sin(_local7.exitAngle);
_local10 = Math.cos(_local7.exitAngle);
balls[_local11].realX = (_local7.x + (_local8 * _local10));
balls[_local11].realY = (_local7.y + (_local8 * _local9));
balls[_local11].setSpeedDirection((balls[_local11].speed * (1 - Config.BALL_CUSIONSPEEDLOST)), _local10, _local9);
};
balls[_local11].speed = (balls[_local11].speed - ((Config.BALL_DECELERATION * _arg1) / 1000));
if (balls[_local11].speed <= 0){
balls[_local11].speed = 0;
balls[_local11].speedX = 0;
balls[_local11].speedY = 0;
} else {
balls[_local11].speedX = (balls[_local11].speed * balls[_local11].directionX);
balls[_local11].speedY = (balls[_local11].speed * balls[_local11].directionY);
};
};
_local11++;
};
}
private function drawHitBorderLines(_arg1:Object):void{
var _local4:Number;
var _local2:Number = Math.atan2((_arg1.y - whiteBall.realY), (_arg1.x - whiteBall.realX));
var _local3:Number = Math.atan2((_arg1.border[1].y - _arg1.border[0].y), (_arg1.border[1].x - _arg1.border[0].x));
linesHolder.graphics.clear();
linesHolder.graphics.lineStyle(Config.LINE_THICKNESS, Config.LINE_COLOUR, Config.LINE_ALPHA);
drawLine(whiteBall.realX, whiteBall.realY, _arg1.x, _arg1.y);
drawBall(_arg1.x, _arg1.y);
if (_local3 < 0){
_local3 = (_local3 + Math.PI);
};
_local4 = ((_local3 * 2) - _local2);
drawLine(_arg1.x, _arg1.y, (_arg1.x + (Math.cos(_local4) * Config.LINE_EXITLENGTH)), (_arg1.y + (Math.sin(_local4) * Config.LINE_EXITLENGTH)));
}
private function showPlayAgain(_arg1:TimerEvent):void{
Object(parent).gameEnded(ranks);
clickDetector.visible = false;
message.showPlayAgain();
}
private function initializeTable():void{
var _local1:Point;
var _local2:int;
holes = new Array();
_local2 = 0;
while (true) {
if (!table[("hole" + _local2)]){
break;
};
_local1 = new Point(table[("hole" + _local2)].x, table[("hole" + _local2)].y);
_local1 = table.localToGlobal(_local1);
holes.push(_local1);
_local2++;
};
corners = new Array();
_local2 = 0;
while (true) {
if (!table[("corner" + _local2)]){
break;
};
_local1 = new Point(table[("corner" + _local2)].x, table[("corner" + _local2)].y);
_local1 = table.localToGlobal(_local1);
corners.push(_local1);
_local2++;
};
createShrinkedCorners();
}
private function onPutBallMouseMove(_arg1:MouseEvent):void{
_arg1.updateAfterEvent();
whiteBall.realX = mouseX;
whiteBall.realY = mouseY;
updateBallPuttable();
}
public function onOpponentShoot(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{
stopReceivingMessages();
whiteBall.realX = _arg1;
whiteBall.realY = _arg2;
this.shootDX = _arg3;
this.shootDY = _arg4;
this.shootForceRatio = _arg5;
message.hide();
whiteBall.visible = true;
whiteBallTouched = false;
whiteBallTouchedCorrect = false;
cannotPocketBlackBall = getCannotPocketBlackBall();
blackBallPocketed = false;
whiteBallPocketed = false;
pocketed = false;
cue.rotation = ((Math.atan2(_arg4, _arg3) / Math.PI) * 180);
startTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onShootTime);
timer.start();
}
override public function startView(_arg1:Array):void{
isViewing = true;
startGame(_arg1, 0);
}
private function viewMessageFinished(_arg1:TimerEvent):void{
startReceivingMessages();
}
private function getHitBorderInfo():Object{
var _local3:Point;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:int;
var _local1:Object = new Object();
var _local2:Array = [new Point(whiteBall.realX, whiteBall.realY), new Point(mouseX, mouseY)];
_local1.length = Number.MAX_VALUE;
_local7 = 0;
while (_local7 < shrinkedBorders.length) {
_local3 = getIntersection(_local2, shrinkedBorders[_local7]);
if (!_local3){
} else {
if (((!((shrinkedBorders[_local7][0].x == shrinkedBorders[_local7][1].x))) && ((((_local3.x - shrinkedBorders[_local7][0].x) * (_local3.x - shrinkedBorders[_local7][1].x)) > 0)))){
} else {
if (((!((shrinkedBorders[_local7][0].y == shrinkedBorders[_local7][1].y))) && ((((_local3.y - shrinkedBorders[_local7][0].y) * (_local3.y - shrinkedBorders[_local7][1].y)) > 0)))){
} else {
if (((whiteBall.realX - _local3.x) * (whiteBall.realX - mouseX)) < 0){
} else {
if (((whiteBall.realY - _local3.y) * (whiteBall.realY - mouseY)) < 0){
} else {
if (!getIsInsideOfBorder(whiteBall.realX, whiteBall.realY, shrinkedBorders[_local7])){
} else {
_local4 = (_local3.x - whiteBall.realX);
_local5 = (_local3.y - whiteBall.realY);
_local6 = Math.sqrt(((_local4 * _local4) + (_local5 * _local5)));
if (_local6 < _local1.length){
_local1.border = shrinkedBorders[_local7];
_local1.length = _local6;
_local1.x = _local3.x;
_local1.y = _local3.y;
};
};
};
};
};
};
};
_local7++;
};
return (_local1);
}
private function showViewWin(_arg1:TimerEvent=null):void{
stopReceivingMessages();
message.showWinPlayer(currentPlayerIndex);
soundWin.play();
timer = new NewTimer(Config.MESSAGE_RESULTTIME, 1);
timer.addEventListener(TimerEvent.TIMER, showHome);
timer.start();
}
private function getHitPoint(_arg1:Array, _arg2:Number, _arg3:Number):Point{
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local4:Number = _arg1[0].x;
var _local5:Number = _arg1[0].y;
var _local6:Number = _arg1[1].x;
var _local7:Number = _arg1[1].y;
_local8 = (((_local6 - _local4) * (_local6 - _local4)) + ((_local7 - _local5) * (_local7 - _local5)));
if (_local8 == 0){
return (null);
};
if (_local6 == _local4){
_local12 = _local4;
_local11 = (((4 * Config.BALL_RADIUS) * Config.BALL_RADIUS) - ((_local12 - _arg2) * (_local12 - _arg2)));
if (_local11 < 0){
return (null);
};
if (_local7 > _local5){
_local13 = (_arg3 - Math.sqrt(_local11));
} else {
_local13 = (_arg3 + Math.sqrt(_local11));
};
if (((_local13 - _local5) * (_local13 - _local7)) > 0){
return (null);
};
return (new Point(_local12, _local13));
};
_local9 = (2 * ((((-(_arg2) * (_local6 - _local4)) * (_local6 - _local4)) - ((_local4 * (_local7 - _local5)) * (_local7 - _local5))) + (((_local6 - _local4) * (_local7 - _local5)) * (_local5 - _arg3))));
_local10 = ((((((((_local6 - _local4) * (_local6 - _local4)) * _arg2) * _arg2) + ((((_local7 - _local5) * (_local7 - _local5)) * _local4) * _local4)) - ((((2 * (_local6 - _local4)) * (_local7 - _local5)) * (_local5 - _arg3)) * _local4)) + ((((_local5 - _arg3) * (_local5 - _arg3)) * (_local6 - _local4)) * (_local6 - _local4))) - ((((4 * Config.BALL_RADIUS) * Config.BALL_RADIUS) * (_local6 - _local4)) * (_local6 - _local4)));
_local11 = ((_local9 * _local9) - ((4 * _local8) * _local10));
if (_local11 < 0){
return (null);
};
if (_local6 > _local4){
_local12 = ((-(_local9) - Math.sqrt(_local11)) / (2 * _local8));
} else {
_local12 = ((-(_local9) + Math.sqrt(_local11)) / (2 * _local8));
};
if (((_local12 - _local4) * (_local12 - _local6)) > 0){
return (null);
};
_local13 = ((((_local12 - _local4) / (_local6 - _local4)) * (_local7 - _local5)) + _local5);
return (new Point(_local12, _local13));
}
private function onMoveTime(_arg1:TimerEvent):void{
var _local4:int;
var _local2:int = NewTimer.getTimer();
var _local3:int = (_local2 - lastTime);
_arg1.updateAfterEvent();
_local4 = 0;
while (_local4 < _local3) {
moveBalls(1);
checkBounce();
checkPockets(1);
if (checkMoveFinished()){
break;
};
_local4++;
};
lastTime = _local2;
if (_local4 < _local3){
timer.stop();
timer = new NewTimer(Config.FINISHEDWAIT, 1);
timer.addEventListener(TimerEvent.TIMER, (((!(isViewing)) && ((currentPlayerIndex == selfIndex)))) ? moveFinished : opponentMoveFinished);
timer.start();
};
}
private function getIsInsideOfBorder(_arg1:Number, _arg2:Number, _arg3:Array):Boolean{
var _local6:Number;
var _local4:Point = _arg3[0];
var _local5:Point = _arg3[1];
_local6 = (Math.atan2((_local5.y - _arg2), (_local5.x - _arg1)) - Math.atan2((_local4.y - _arg2), (_local4.x - _arg1)));
if (_local6 < -(Math.PI)){
_local6 = (_local6 + (Math.PI * 2));
} else {
if (_local6 > Math.PI){
_local6 = (_local6 - (Math.PI * 2));
};
};
return ((_local6 > 0));
}
private function onAimClick(_arg1:MouseEvent):void{
var _local2:Number;
shootDX = (mouseX - whiteBall.realX);
shootDY = (mouseY - whiteBall.realY);
if ((((shootDX == 0)) && ((shootDY == 0)))){
return;
};
this.removeEventListener(MouseEvent.MOUSE_MOVE, onAimMouseMove);
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onAimClick);
clickDetector.buttonMode = false;
_local2 = Math.sqrt(((shootDX * shootDX) + (shootDY * shootDY)));
shootDX = (shootDX / _local2);
shootDY = (shootDY / _local2);
arrow.x = (whiteBall.realX + (Config.BALL_RADIUS * shootDX));
arrow.y = (whiteBall.realY + (Config.BALL_RADIUS * shootDY));
arrow.rotation = cue.rotation;
arrow.setRatio(0);
arrow.visible = true;
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onSetForceClick);
clickDetector.buttonMode = true;
startTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onSetForceTime);
timer.start();
}
private function performBounce(_arg1:Ball, _arg2:Ball):void{
var _local3:Number = Math.atan2((_arg1.realY - _arg2.realY), (_arg1.realX - _arg2.realX));
var _local4:Number = Math.cos(_local3);
var _local5:Number = Math.sin(_local3);
var _local6:Number = ((_arg1.speedX * _local5) - (_arg1.speedY * _local4));
var _local7:Number = ((_arg1.speedX * _local4) + (_arg1.speedY * _local5));
var _local8:Number = ((_arg2.speedX * _local5) - (_arg2.speedY * _local4));
var _local9:Number = ((_arg2.speedX * _local4) + (_arg2.speedY * _local5));
if ((((_local7 > 0)) && ((_local9 < 0)))){
return;
};
checkWhiteBallTouch(_arg1, _arg2);
_arg1.setSpeed(((_local6 * _local5) + (_local9 * _local4)), ((-(_local6) * _local4) + (_local9 * _local5)));
_arg2.setSpeed(((_local8 * _local5) + (_local7 * _local4)), ((-(_local8) * _local4) + (_local7 * _local5)));
soundBall.play();
}
private function drawHitBallLines(_arg1:Object):void{
var _local2:Number = ((_arg1.x + _arg1.ball.realX) / 2);
var _local3:Number = ((_arg1.y + _arg1.ball.realY) / 2);
var _local4:Number = (_arg1.ball.realX - _arg1.x);
var _local5:Number = (_arg1.ball.realY - _arg1.y);
var _local6:Number = Math.sqrt(((_local4 * _local4) + (_local5 * _local5)));
var _local7:Number = -(_local5);
var _local8:Number = _local4;
var _local9:Number = _local6;
linesHolder.graphics.clear();
linesHolder.graphics.lineStyle(Config.LINE_THICKNESS, Config.LINE_COLOUR, Config.LINE_ALPHA);
drawLine(whiteBall.realX, whiteBall.realY, _arg1.x, _arg1.y);
drawBall(_arg1.x, _arg1.y);
drawLine(_local2, _local3, (_local2 + ((Config.LINE_EXITLENGTH * _local4) / _local6)), (_local3 + ((Config.LINE_EXITLENGTH * _local5) / _local6)));
drawLine((_local2 - (((Config.LINE_TANGENTLENGTH * _local7) / _local9) / 2)), (_local3 - (((Config.LINE_TANGENTLENGTH * _local8) / _local9) / 2)), (_local2 + (((Config.LINE_TANGENTLENGTH * _local7) / _local9) / 2)), (_local3 + (((Config.LINE_TANGENTLENGTH * _local8) / _local9) / 2)));
}
private function drawLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local9:int;
var _local5:Number = (_arg3 - _arg1);
var _local6:Number = (_arg4 - _arg2);
var _local7:Number = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
var _local8:int = Math.floor((_local7 / (Config.LINE_DASHLENGTH + Config.LINE_DASHSPACING)));
_local9 = 0;
while (_local9 < _local8) {
linesHolder.graphics.moveTo((_arg1 + (((_local9 * (Config.LINE_DASHLENGTH + Config.LINE_DASHSPACING)) * _local5) / _local7)), (_arg2 + (((_local9 * (Config.LINE_DASHLENGTH + Config.LINE_DASHSPACING)) * _local6) / _local7)));
linesHolder.graphics.lineTo((_arg1 + ((((_local9 * (Config.LINE_DASHLENGTH + Config.LINE_DASHSPACING)) + Config.LINE_DASHLENGTH) * _local5) / _local7)), (_arg2 + ((((_local9 * (Config.LINE_DASHLENGTH + Config.LINE_DASHSPACING)) + Config.LINE_DASHLENGTH) * _local6) / _local7)));
_local9++;
};
}
private function opponentMoveFinished(_arg1:TimerEvent):void{
startReceivingMessages();
}
private function drawBall(_arg1:Number, _arg2:Number):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:int;
var _local3:Number = Math.tan((Math.PI / 8));
linesHolder.graphics.moveTo((_arg1 + Config.BALL_RADIUS), _arg2);
_local9 = 0;
while (_local9 < 8) {
_local4 = (((_local9 + 1) * Math.PI) / 4);
_local7 = (_arg1 + (Config.BALL_RADIUS * Math.cos(_local4)));
_local8 = (_arg2 + (Config.BALL_RADIUS * Math.sin(_local4)));
_local5 = (_local7 + ((Config.BALL_RADIUS * _local3) * Math.sin(_local4)));
_local6 = (_local8 - ((Config.BALL_RADIUS * _local3) * Math.cos(_local4)));
linesHolder.graphics.curveTo(_local5, _local6, _local7, _local8);
_local9++;
};
}
private function getCannotPocketBlackBall():Boolean{
var _local1:int;
_local1 = 0;
while (_local1 < balls.length) {
if (balls[_local1].isWhite){
} else {
if (balls[_local1].isBlack){
} else {
if (currentPlayerIndex == 0){
if (balls[_local1].isSolid){
return (true);
};
} else {
if (!balls[_local1].isSolid){
return (true);
};
};
};
};
_local1++;
};
return (false);
}
private function moveFinished(_arg1:TimerEvent):void{
startReceivingMessages();
sendBallsStatus();
afterMoveFinished();
}
private function startGame(_arg1:Array, _arg2:int):void{
var _local3:int;
startReceivingMessages();
this.selfIndex = _arg2;
this.playerNames = _arg1;
soundBall = new SoundBall();
soundCue = new SoundCue();
soundPocket = new SoundPocket();
soundWin = new SoundWin();
soundLose = new SoundLose();
if (_arg2 == 0){
if (!isViewing){
playerNameText0.gotoAndStop("you");
} else {
playerNameText0.gotoAndStop("opponent");
playerNameText0.nameText.text = _arg1[0];
};
playerNameText1.gotoAndStop("opponent");
playerNameText1.nameText.text = _arg1[(_arg1.length - 1)];
} else {
playerNameText1.gotoAndStop("you");
playerNameText0.gotoAndStop("opponent");
playerNameText0.nameText.text = _arg1[0];
};
initializeTable();
timer = new NewTimer(Config.INITIALWAITTIME, 1);
timer.addEventListener(TimerEvent.TIMER, doInitialSync);
timer.start();
}
private function checkPockets(_arg1:int):void{
var _local2:Number;
var _local3:Number;
var _local4:int;
var _local5:int;
_local4 = 0;
while (_local4 < balls.length) {
if ((((balls[_local4].speed == 0)) && ((balls[_local4].totalFallTime == 0)))){
} else {
_local5 = 0;
while (_local5 < holes.length) {
_local2 = (balls[_local4].realX - holes[_local5].x);
_local3 = (balls[_local4].realY - holes[_local5].y);
if (((_local2 * _local2) + (_local3 * _local3)) < (Config.HOLE_RADIUS * Config.HOLE_RADIUS)){
break;
};
_local5++;
};
if (_local5 < holes.length){
balls[_local4].addFallTime(_arg1);
balls[_local4].speed = (balls[_local4].speed - ((Config.BALL_HOLEDECELERATION * _arg1) / 1000));
if (balls[_local4].speed <= 0){
balls[_local4].speed = 0;
balls[_local4].speedX = 0;
balls[_local4].speedY = 0;
};
if (balls[_local4].fallRatio == 1){
if (balls[_local4] == whiteBall){
whiteBallPocketed = true;
} else {
if (balls[_local4].number == Config.BALL_BLACK){
blackBallPocketed = true;
} else {
pocketed = true;
};
};
balls.splice(_local4, 1);
_local4--;
soundPocket.play();
};
} else {
balls[_local4].resetFallTime();
};
};
_local4++;
};
}
private function afterMoveFinished():void{
var _local1:Boolean;
if (blackBallPocketed){
if (cannotPocketBlackBall){
timer = new NewTimer(Config.MESSAGE_ILLEGALTIME, 1);
if (!isViewing){
if (currentPlayerIndex == selfIndex){
message.showIllegal();
timer.addEventListener(TimerEvent.TIMER, showLose);
} else {
message.showOpponentIllegal();
timer.addEventListener(TimerEvent.TIMER, showWin);
};
} else {
message.showIllegalPlayer(currentPlayerIndex);
timer.addEventListener(TimerEvent.TIMER, showViewWin);
};
timer.start();
} else {
if (!isViewing){
if (currentPlayerIndex == selfIndex){
showWin();
} else {
showLose();
};
} else {
showViewWin();
};
};
return;
};
if (whiteBallPocketed){
whiteBall.resetFallTime();
balls.push(whiteBall);
_local1 = true;
};
if (((!(whiteBallTouched)) || (!(whiteBallTouchedCorrect)))){
_local1 = true;
};
if (_local1){
message.showFoul();
whiteBall.visible = false;
timer = new NewTimer(Config.MESSAGE_FOULTIME, 1);
timer.addEventListener(TimerEvent.TIMER, foulFinished);
timer.start();
return;
};
if (pocketed){
if (!isViewing){
if (selfIndex == currentPlayerIndex){
startAim();
} else {
startReceivingMessages();
message.showOpponentTurn();
};
} else {
message.showTurn(currentPlayerIndex);
timer = new NewTimer(Config.VIEW_MINMESSAGETIME, 1);
timer.addEventListener(TimerEvent.TIMER, viewMessageFinished);
timer.start();
};
} else {
currentPlayerIndex = ((playerNames.length - currentPlayerIndex) - 1);
if (!isViewing){
if (selfIndex != currentPlayerIndex){
startReceivingMessages();
message.showOpponentTurn();
} else {
message.hide();
startAim();
};
} else {
message.showTurn(currentPlayerIndex);
timer = new NewTimer(Config.VIEW_MINMESSAGETIME, 1);
timer.addEventListener(TimerEvent.TIMER, viewMessageFinished);
timer.start();
};
};
}
private function checkWhiteBallTouch(_arg1:Ball, _arg2:Ball):void{
var _local3:Ball;
if (whiteBallTouched){
return;
};
if (((!((_arg1 == whiteBall))) && (!((_arg2 == whiteBall))))){
return;
};
_local3 = ((_arg1 == whiteBall)) ? _arg2 : _arg1;
if (_local3.isBlack){
whiteBallTouchedCorrect = !(cannotPocketBlackBall);
} else {
if (currentPlayerIndex == 0){
whiteBallTouchedCorrect = _local3.isSolid;
} else {
whiteBallTouchedCorrect = !(_local3.isSolid);
};
};
whiteBallTouched = true;
}
private function doInitialSync(_arg1:TimerEvent):void{
var _local3:int;
var _local2:Array = new Array();
_local2.push(Config.BALL_BLACK);
_local3 = 0;
while (_local3 < Config.BALL_SOLIDS.length) {
_local2.push(Config.BALL_SOLIDS[_local3]);
_local3++;
};
_local3 = 0;
while (_local3 < Config.BALL_STRIPES.length) {
_local2.push(Config.BALL_STRIPES[_local3]);
_local3++;
};
shuffleArray(_local2);
if (!isViewing){
sendSynchronizeMessage("layoutTable", _local2.join(","));
};
}
private function onShootTime(_arg1:TimerEvent):void{
var _local2:int = NewTimer.getTimer();
var _local3:Number = ((_local2 - startTime) / Config.CUE_SHOOTTIME);
if (_local3 > 1){
_local3 = 1;
};
_arg1.updateAfterEvent();
cue.setRatio((1 - _local3));
if (_local3 >= 1){
timer.stop();
soundCue.play();
cue.visible = false;
whiteBall.setSpeed(((Config.BALL_MAXSPEED * shootForceRatio) * shootDX), ((Config.BALL_MAXSPEED * shootForceRatio) * shootDY));
lastTime = _local2;
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onMoveTime);
timer.start();
};
}
private function startAim():void{
whiteBallTouched = false;
whiteBallTouchedCorrect = false;
cannotPocketBlackBall = getCannotPocketBlackBall();
blackBallPocketed = false;
whiteBallPocketed = false;
pocketed = false;
whiteBall.alpha = 1;
cue.x = whiteBall.x;
cue.y = whiteBall.y;
cue.setRatio(0);
updateAim();
this.addEventListener(MouseEvent.MOUSE_MOVE, onAimMouseMove);
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onAimClick);
clickDetector.buttonMode = true;
}
private function onSetForceTime(_arg1:TimerEvent):void{
var _local2:int = NewTimer.getTimer();
var _local3:Number = (((_local2 - startTime) % Config.CUE_PERIOD) / Config.CUE_PERIOD);
shootForceRatio = ((_local3 < 0.5)) ? (_local3 * 2) : (2 - (_local3 * 2));
_arg1.updateAfterEvent();
cue.setRatio(shootForceRatio);
arrow.setRatio(shootForceRatio);
}
private function showWin(_arg1:TimerEvent=null):void{
ranks = [1, 1];
ranks[selfIndex] = 0;
stopReceivingMessages();
message.showWin();
soundWin.play();
timer = new NewTimer(Config.MESSAGE_RESULTTIME, 1);
timer.addEventListener(TimerEvent.TIMER, showPlayAgain);
timer.start();
}
private function createShrinkedCorners():void{
var _local2:Point;
var _local3:Point;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Array;
var _local8:Array;
var _local9:MovieClip;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:int;
var _local1:Array = new Array();
_local14 = 0;
while (_local14 < corners.length) {
_local2 = corners[_local14].clone();
_local3 = corners[((_local14 + 1) % corners.length)].clone();
_local4 = (_local3.x - _local2.x);
_local5 = (_local3.y - _local2.y);
_local6 = Math.sqrt(((_local4 * _local4) + (_local5 * _local5)));
_local2.x = (_local2.x - ((Config.BALL_RADIUS * _local5) / _local6));
_local2.y = (_local2.y + ((Config.BALL_RADIUS * _local4) / _local6));
_local3.x = (_local3.x - ((Config.BALL_RADIUS * _local5) / _local6));
_local3.y = (_local3.y + ((Config.BALL_RADIUS * _local4) / _local6));
_local1.push([_local2, _local3]);
_local14++;
};
shrinkedCorners = new Array();
_local14 = 0;
while (_local14 < _local1.length) {
_local7 = _local1[(((_local14 + _local1.length) - 1) % _local1.length)];
_local8 = _local1[_local14];
shrinkedCorners.push(getIntersection(_local7, _local8));
_local14++;
};
shrinkedBorders = new Array();
_local10 = Number.MAX_VALUE;
_local11 = Number.MIN_VALUE;
_local12 = Number.MAX_VALUE;
_local13 = Number.MIN_VALUE;
borderAreas = new Array();
tableArea = new MovieClip();
tableArea.graphics.beginFill(0, 0);
tableArea.graphics.moveTo(shrinkedCorners[0].x, shrinkedCorners[0].y);
_local14 = 0;
while (_local14 < shrinkedCorners.length) {
if (shrinkedCorners[_local14].x < _local10){
_local10 = shrinkedCorners[_local14].x;
};
if (shrinkedCorners[_local14].x > _local11){
_local11 = shrinkedCorners[_local14].x;
};
if (shrinkedCorners[_local14].y < _local12){
_local12 = shrinkedCorners[_local14].y;
};
if (shrinkedCorners[_local14].y > _local13){
_local13 = shrinkedCorners[_local14].y;
};
shrinkedBorders.push([shrinkedCorners[_local14], shrinkedCorners[((_local14 + 1) % shrinkedCorners.length)]]);
tableArea.graphics.lineTo(shrinkedCorners[((_local14 + 1) % shrinkedCorners.length)].x, shrinkedCorners[((_local14 + 1) % shrinkedCorners.length)].y);
_local9 = new MovieClip();
_local9.graphics.beginFill(0, 0);
_local9.graphics.moveTo(corners[_local14].x, corners[_local14].y);
_local9.graphics.lineTo(corners[((_local14 + 1) % corners.length)].x, corners[((_local14 + 1) % corners.length)].y);
_local9.graphics.lineTo(shrinkedCorners[((_local14 + 1) % shrinkedCorners.length)].x, shrinkedCorners[((_local14 + 1) % shrinkedCorners.length)].y);
_local9.graphics.lineTo(shrinkedCorners[_local14].x, shrinkedCorners[_local14].y);
_local9.graphics.lineTo(corners[_local14].x, corners[_local14].y);
_local9.graphics.endFill();
borderAreas.push(_local9);
tableAreasHolder.addChild(_local9);
_local14++;
};
tableAreasHolder.addChild(tableArea);
}
private function checkMoveFinished():Boolean{
var _local1:int;
_local1 = 0;
while (_local1 < balls.length) {
if (balls[_local1].speed > 0){
return (false);
};
if (balls[_local1].fallRatio > 0){
return (false);
};
_local1++;
};
return (true);
}
private function updateBallPuttable():void{
if (!getCanPutBall(whiteBall.realX, whiteBall.realY)){
whiteBall.showCross();
} else {
whiteBall.hideCross();
};
}
private function showHome(_arg1:TimerEvent):void{
if (!isViewing){
Object(parent).gameEnded(ranks);
} else {
Object(parent).viewEnded();
};
clickDetector.visible = false;
message.showHome();
}
private function checkBounce():void{
var _local1:Number;
var _local2:Number;
var _local3:int;
var _local4:int;
_local3 = 0;
while (_local3 < balls.length) {
_local4 = (_local3 + 1);
while (_local4 < balls.length) {
if ((((balls[_local3].speed == 0)) && ((balls[_local4].speed == 0)))){
} else {
_local1 = (balls[_local3].realX - balls[_local4].realX);
_local2 = (balls[_local3].realY - balls[_local4].realY);
if (((_local1 * _local1) + (_local2 * _local2)) >= ((Config.BALL_RADIUS * Config.BALL_RADIUS) * 4)){
} else {
performBounce(balls[_local3], balls[_local4]);
};
};
_local4++;
};
_local3++;
};
}
private function getHitCusionInfo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Object{
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local11:int;
var _local5:Point = this.localToGlobal(new Point(_arg3, _arg4));
var _local10:Object;
_local11 = 0;
while (_local11 < borderAreas.length) {
if (!borderAreas[_local11].hitTestPoint(_local5.x, _local5.y, true)){
} else {
_local6 = Math.atan2((_arg4 - _arg2), (_arg3 - _arg1));
_local7 = Math.atan2((shrinkedBorders[_local11][1].y - shrinkedBorders[_local11][0].y), (shrinkedBorders[_local11][1].x - shrinkedBorders[_local11][0].x));
_local8 = ((_local7 * 2) - _local6);
_local9 = (_local8 - _local7);
if (_local9 > (Math.PI * 2)){
_local9 = (_local9 - (Math.PI * 2));
} else {
if (_local9 < 0){
_local9 = (_local9 + (Math.PI * 2));
};
};
if (_local9 >= Math.PI){
} else {
_local10 = new Object();
_local10.border = shrinkedBorders[_local11];
_local10.length = 0;
_local10.x = _arg1;
_local10.y = _arg2;
_local10.exitAngle = _local8;
break;
};
};
_local11++;
};
return (_local10);
}
private function getCanPutBall(_arg1:Number, _arg2:Number):Boolean{
var _local3:Number;
var _local4:Number;
var _local5:Point;
var _local6:int;
if (isInitialPutBall){
if ((_arg1 - table.x) > Config.TABLE_HEADSTRINGX){
return (false);
};
};
_local6 = 0;
while (_local6 < holes.length) {
_local3 = (holes[_local6].x - _arg1);
_local4 = (holes[_local6].y - _arg2);
if (((_local3 * _local3) + (_local4 * _local4)) < (Config.HOLE_RADIUS * Config.HOLE_RADIUS)){
return (false);
};
_local6++;
};
_local6 = 0;
while (_local6 < balls.length) {
if (balls[_local6] == whiteBall){
} else {
_local3 = (balls[_local6].realX - _arg1);
_local4 = (balls[_local6].realY - _arg2);
if (((_local3 * _local3) + (_local4 * _local4)) < ((Config.BALL_RADIUS * Config.BALL_RADIUS) * 4)){
return (false);
};
};
_local6++;
};
_local5 = this.localToGlobal(new Point(_arg1, _arg2));
return (tableArea.hitTestPoint(_local5.x, _local5.y, true));
}
override public function startPlay(_arg1:Array, _arg2:int):void{
isViewing = false;
startGame(_arg1, _arg2);
}
private function createBalls(_arg1:Array):void{
var _local3:Ball;
var _local4:int;
var _local5:int;
var _local8:Number;
var _local9:Number;
var _local10:int;
var _local11:int;
var _local12:int;
var _local13:int;
var _local2:Array = new Array();
var _local6:Number = (Config.BALL_RADIUS * Math.sqrt(3));
var _local7:Number = (Config.BALL_RADIUS * 2);
_local12 = 0;
while (_local12 < _arg1.length) {
_local3 = new Ball();
_local3.setNormal(int(_arg1[_local12]));
ballsHolder.addChild(_local3);
_local2.push(_local3);
_local12++;
};
_local12 = 0;
while (_local12 < _local2.length) {
if (_local2[_local12].number == Config.BALL_BLACK){
swapItems(_local2, _local12, 4);
};
_local12++;
};
_local5 = 0;
_local4 = 0;
while (true) {
_local5 = (_local5 + _local4);
if (_local5 >= _local2.length){
break;
};
_local4++;
};
if (_local2[(_local2.length - 1)].isSolid == _local2[(_local2.length - _local4)].isSolid){
_local12 = 0;
while (_local12 < _local2.length) {
if (_local2[_local12].number == Config.BALL_BLACK){
} else {
if (_local2[_local12].isSolid == _local2[(_local2.length - 1)].isSolid){
} else {
swapItems(_local2, _local12, (_local2.length - 1));
break;
};
};
_local12++;
};
};
_local8 = (table.x + Config.TABLE_FOOTSPOTX);
_local9 = (table.y + Config.TABLE_FOOTSPOTY);
_local10 = 0;
_local11 = 0;
_local12 = 0;
while (_local12 < _local2.length) {
_local2[_local12].realX = _local8;
_local2[_local12].realY = _local9;
if (_local11 >= _local10){
_local10++;
_local11 = 0;
_local8 = (_local8 + _local6);
_local9 = ((_local9 + (_local7 / 2)) - (_local10 * _local7));
} else {
_local11++;
_local9 = (_local9 + _local7);
};
_local12++;
};
balls = new Array();
whiteBall = new Ball();
whiteBall.setWhite();
whiteBall.visible = false;
ballsHolder.addChild(whiteBall);
balls.push(whiteBall);
_local12 = 0;
while (_local12 < _local2.length) {
balls.push(_local2[_local12]);
_local12++;
};
}
private function foulFinished(_arg1:TimerEvent):void{
currentPlayerIndex = ((playerNames.length - currentPlayerIndex) - 1);
if (!isViewing){
if (currentPlayerIndex != selfIndex){
startReceivingMessages();
message.showOpponentTurn();
} else {
stopReceivingMessages();
startPutBall();
};
} else {
message.showTurn(currentPlayerIndex);
timer = new NewTimer(Config.VIEW_MINMESSAGETIME, 1);
timer.addEventListener(TimerEvent.TIMER, viewMessageFinished);
timer.start();
};
}
override public function playerDisconnected(_arg1:int):void{
super.playerDisconnected(_arg1);
stopReceivingMessages();
ranks = [0, 0];
ranks[_arg1] = 1;
if (timer){
timer.stop();
};
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onPutBallClick);
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onAimClick);
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onSetForceClick);
clickDetector.buttonMode = false;
this.removeEventListener(MouseEvent.MOUSE_MOVE, onPutBallMouseMove);
this.removeEventListener(MouseEvent.MOUSE_MOVE, onAimMouseMove);
if (!isViewing){
message.showDisconnected();
} else {
message.showDisconnectedPlayer(_arg1);
};
timer = new NewTimer(Config.MESSAGE_DISCONNECTEDTIME, 1);
timer.addEventListener(TimerEvent.TIMER, showHome);
timer.start();
}
private function onSetForceClick(_arg1:MouseEvent):void{
timer.stop();
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onSetForceClick);
clickDetector.buttonMode = false;
linesHolder.graphics.clear();
arrow.visible = false;
whiteBall.realX = normalizeNumber(whiteBall.realX);
whiteBall.realY = normalizeNumber(whiteBall.realY);
shootDX = normalizeNumber(shootDX);
shootDY = normalizeNumber(shootDY);
shootForceRatio = normalizeNumber(shootForceRatio);
stopReceivingMessages();
sendMessage("onOpponentShoot", whiteBall.realX, whiteBall.realY, shootDX, shootDY, shootForceRatio);
startTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onShootTime);
timer.start();
}
private function showLose(_arg1:TimerEvent=null):void{
ranks = [0, 0];
ranks[selfIndex] = 1;
stopReceivingMessages();
message.showLose();
soundLose.play();
timer = new NewTimer(Config.MESSAGE_RESULTTIME, 1);
timer.addEventListener(TimerEvent.TIMER, showPlayAgain);
timer.start();
}
private function updateAim():void{
var _local1:Object;
var _local2:Object;
var _local3:Number;
var _local4:Number;
if ((((mouseX == whiteBall.realX)) && ((mouseY == whiteBall.realY)))){
linesHolder.graphics.clear();
cue.visible = false;
return;
};
_local1 = getHitBorderInfo();
_local2 = getHitBallInfo(_local1.x, _local1.y);
if (!_local2){
drawHitBorderLines(_local1);
} else {
drawHitBallLines(_local2);
};
_local3 = (mouseX - whiteBall.realX);
_local4 = (mouseY - whiteBall.realY);
cue.rotation = ((Math.atan2(_local4, _local3) * 180) / Math.PI);
cue.visible = true;
}
private function getHitBallInfo(_arg1:Number, _arg2:Number):Object{
var _local5:Point;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:int;
var _local3:Object;
var _local4:Array = [new Point(whiteBall.realX, whiteBall.realY), new Point(_arg1, _arg2)];
_local9 = 0;
while (_local9 < balls.length) {
if (balls[_local9] == whiteBall){
} else {
_local5 = getHitPoint(_local4, balls[_local9].realX, balls[_local9].realY);
if (!_local5){
} else {
_local6 = (_local5.x - whiteBall.realX);
_local7 = (_local5.y - whiteBall.realY);
_local8 = Math.sqrt(((_local6 * _local6) + (_local7 * _local7)));
if (((!(_local3)) || ((_local8 < _local3.length)))){
_local3 = new Object();
_local3.ball = balls[_local9];
_local3.length = _local8;
_local3.x = _local5.x;
_local3.y = _local5.y;
};
};
};
_local9++;
};
return (_local3);
}
public function layoutTable(_arg1:Array):void{
createBalls(_arg1[0].split(","));
currentPlayerIndex = 0;
if (!isViewing){
if (selfIndex == 0){
stopReceivingMessages();
isInitialPutBall = true;
startPutBall();
} else {
isInitialPutBall = false;
message.showOpponentTurn();
};
} else {
stopReceivingMessages();
message.showTurn(currentPlayerIndex);
timer = new NewTimer(Config.VIEW_MINMESSAGETIME, 1);
timer.addEventListener(TimerEvent.TIMER, viewMessageFinished);
timer.start();
};
}
private function sendBallsStatus():void{
var _local2:int;
var _local1 = "<STATUS>";
_local2 = 0;
while (_local2 < balls.length) {
balls[_local2].realX = normalizeNumber(balls[_local2].realX);
balls[_local2].realY = normalizeNumber(balls[_local2].realY);
_local1 = (_local1 + "<BALL ");
_local1 = (_local1 + (("number=\"" + balls[_local2].number) + "\" "));
_local1 = (_local1 + (("x=\"" + balls[_local2].realX) + "\" "));
_local1 = (_local1 + (("y=\"" + balls[_local2].realY) + "\" "));
_local1 = (_local1 + " />");
_local2++;
};
_local1 = (_local1 + (("<BLACKBALLPOCKETED>" + (blackBallPocketed) ? "true" : "false") + "</BLACKBALLPOCKETED>"));
_local1 = (_local1 + (("<CANNOTPOCKETBLACKBALL>" + (cannotPocketBlackBall) ? "true" : "false") + "</CANNOTPOCKETBLACKBALL>"));
_local1 = (_local1 + (("<WHITEBALLPOCKETED>" + (whiteBallPocketed) ? "true" : "false") + "</WHITEBALLPOCKETED>"));
_local1 = (_local1 + (("<WHITEBALLTOUCHED>" + (whiteBallTouched) ? "true" : "false") + "</WHITEBALLTOUCHED>"));
_local1 = (_local1 + (("<WHITEBALLTOUCHEDCORRECT>" + (whiteBallTouchedCorrect) ? "true" : "false") + "</WHITEBALLTOUCHEDCORRECT>"));
_local1 = (_local1 + (("<POCKETED>" + (pocketed) ? "true" : "false") + "</POCKETED>"));
_local1 = (_local1 + "</STATUS>");
sendMessage("updateBallsStatus", _local1);
}
private function onAimMouseMove(_arg1:MouseEvent):void{
_arg1.updateAfterEvent();
updateAim();
}
public function updateBallsStatus(_arg1:String):void{
var _local4:XMLNode;
var _local5:Ball;
var _local6:Number;
var _local7:Number;
var _local8:int;
var _local9:int;
var _local2:XMLDocument = new XMLDocument(_arg1);
var _local3:XMLNode = _local2.firstChild;
stopReceivingMessages();
_local9 = 0;
while (_local9 < balls.length) {
ballsHolder.removeChild(balls[_local9]);
_local9++;
};
balls = new Array();
_local4 = _local3.firstChild;
while (_local4) {
switch (_local4.nodeName){
case "BALL":
_local6 = Number(_local4.attributes.x);
_local7 = Number(_local4.attributes.y);
_local8 = int(_local4.attributes.number);
_local5 = new Ball();
if (_local8 == 0){
_local5.setWhite();
whiteBall = _local5;
} else {
_local5.setNormal(_local8);
};
_local5.realX = _local6;
_local5.realY = _local7;
balls.push(_local5);
ballsHolder.addChild(_local5);
break;
case "BLACKBALLPOCKETED":
blackBallPocketed = (_local4.firstChild.nodeValue == "true");
break;
case "CANNOTPOCKETBLACKBALL":
cannotPocketBlackBall = (_local4.firstChild.nodeValue == "true");
break;
case "WHITEBALLPOCKETED":
whiteBallPocketed = (_local4.firstChild.nodeValue == "true");
break;
case "WHITEBALLTOUCHED":
whiteBallTouched = (_local4.firstChild.nodeValue == "true");
break;
case "WHITEBALLTOUCHEDCORRECT":
whiteBallTouchedCorrect = (_local4.firstChild.nodeValue == "true");
break;
case "POCKETED":
pocketed = (_local4.firstChild.nodeValue == "true");
break;
};
_local4 = _local4.nextSibling;
};
afterMoveFinished();
}
private function shuffleArray(_arg1:Array):void{
var _local2:*;
var _local3:int;
var _local4:int;
_local3 = 0;
while (_local3 < _arg1.length) {
_local4 = Math.floor((Math.random() * _arg1.length));
_local2 = _arg1[_local3];
_arg1[_local3] = _arg1[_local4];
_arg1[_local4] = _local2;
_local3++;
};
}
private function startPutBall():void{
whiteBall.alpha = Config.BALL_PUTTINGALPHA;
whiteBall.visible = true;
whiteBall.realX = mouseX;
whiteBall.realY = mouseY;
updateBallPuttable();
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onPutBallClick);
clickDetector.buttonMode = true;
this.addEventListener(MouseEvent.MOUSE_MOVE, onPutBallMouseMove);
message.showClickToPlace();
}
private function onPutBallClick(_arg1:MouseEvent):void{
if (!getCanPutBall(whiteBall.x, whiteBall.y)){
return;
};
isInitialPutBall = false;
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onPutBallClick);
clickDetector.buttonMode = false;
this.removeEventListener(MouseEvent.MOUSE_MOVE, onPutBallMouseMove);
message.hide();
startAim();
}
private function swapItems(_arg1:Array, _arg2:int, _arg3:int):void{
var _local4:*;
_local4 = _arg1[_arg2];
_arg1[_arg2] = _arg1[_arg3];
_arg1[_arg3] = _local4;
}
private function getIntersection(_arg1:Array, _arg2:Array):Point{
var _local11:Number;
var _local12:Number;
var _local3:Number = _arg1[0].x;
var _local4:Number = _arg1[0].y;
var _local5:Number = _arg1[1].x;
var _local6:Number = _arg1[1].y;
var _local7:Number = _arg2[0].x;
var _local8:Number = _arg2[0].y;
var _local9:Number = _arg2[1].x;
var _local10:Number = _arg2[1].y;
if ((((_local9 - _local7) * (_local6 - _local4)) - ((_local5 - _local3) * (_local10 - _local8))) == 0){
return (null);
};
_local11 = (((((((_local9 - _local7) * (_local6 - _local4)) * _local3) - (((_local9 - _local7) * (_local5 - _local3)) * _local4)) - (((_local5 - _local3) * (_local10 - _local8)) * _local7)) + (((_local5 - _local3) * (_local9 - _local7)) * _local8)) / (((_local9 - _local7) * (_local6 - _local4)) - ((_local5 - _local3) * (_local10 - _local8))));
_local12 = (((((((_local9 - _local7) * (_local6 - _local4)) * _local8) - (((_local6 - _local4) * (_local10 - _local8)) * _local7)) - (((_local5 - _local3) * (_local10 - _local8)) * _local4)) + (((_local10 - _local8) * (_local6 - _local4)) * _local3)) / (((_local9 - _local7) * (_local6 - _local4)) - ((_local5 - _local3) * (_local10 - _local8))));
return (new Point(_local11, _local12));
}
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 50
//Main (com.novelgames.multiplayerflashgames.eightball.Main)
package com.novelgames.multiplayerflashgames.eightball {
import flash.display.*;
import mochi.as3.*;
import com.novelgames.multiplayerflashgames.common.*;
import flash.media.*;
import com.novelgames.multiplayerflashgames.connector.*;
public class Main extends MainDevelopment {
private const MOCHI_RES:String = "600x400";
private const MOCHI_ID:String = "49a717c05b37cc71";
public var connector:Connector;
private var mochiClip:Background;
public var title:Title;
public function Main(){
stage.showDefaultContextMenu = false;
showMochi();
__setProp_connector_Scene1_con_0();
}
override protected function getMusicGame():Sound{
return (new MusicGame());
}
private function showMochi():void{
mochiClip = new Background();
addChild(mochiClip);
MochiAd.showPreGameAd({clip:mochiClip, id:MOCHI_ID, res:MOCHI_RES, ad_finished:this.adFinished});
}
override protected function getGame():Game{
return (new Game());
}
override protected function getTitle():Title{
return (title);
}
function __setProp_connector_Scene1_con_0(){
try {
connector["componentInspectorSetting"] = true;
} catch(e:Error) {
};
connector.backgroundAlpha = 0.5;
connector.backgroundColour = 0;
connector.dialogBorderColour = 0;
connector.dialogBorderThickness = 0;
connector.dialogColour = 0xFFFFFF;
connector.enabled = true;
connector.gameID = 1;
connector.hashKey = "";
connector.innerDialogBorderColour = 0;
connector.innerDialogBorderThickness = 5;
connector.innerDialogColour = 0xFFFFFF;
connector.nameSWFVariable = "";
connector.pingInterval = 20000;
connector.possibleNoOfPlayers = [2];
connector.serverHost = "212.227.139.94";
connector.serverPort = 9123;
connector.visible = true;
try {
connector["componentInspectorSetting"] = false;
} catch(e:Error) {
};
}
function adFinished():void{
removeChild(mochiClip);
}
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 51
//Message (com.novelgames.multiplayerflashgames.eightball.Message)
package com.novelgames.multiplayerflashgames.eightball {
import flash.display.*;
import flash.events.*;
public class Message extends MovieClip {
public function Message(){
stop();
}
public function showWinPlayer(_arg1:int):void{
gotoAndStop(((_arg1 == 0)) ? "solidsWin" : "stripesWin");
visible = true;
}
public function showClickToPlace():void{
gotoAndStop("clickToPlace");
visible = true;
}
public function showHome():void{
var _local1:MessagePlayAgain;
gotoAndStop("playAgain");
_local1 = new MessagePlayAgain();
_local1.playAgainButton.addEventListener(MouseEvent.CLICK, playAgainButtonClicked);
_local1.homeButton.addEventListener(MouseEvent.CLICK, homeButtonClicked);
_local1.playAgainButton.visible = false;
_local1.homeButton.y = ((_local1.homeButton.y + _local1.playAgainButton.y) / 2);
this.addChild(_local1);
}
public function showDisconnectedPlayer(_arg1:int):void{
gotoAndStop(((_arg1 == 0)) ? "solidsDisconnected" : "stripesDisconnected");
visible = true;
}
public function showTurn(_arg1:int):void{
if (_arg1 == 0){
gotoAndStop("solidsTurn");
} else {
gotoAndStop("stripesTurn");
};
visible = true;
}
public function showYourTurn():void{
gotoAndStop("yourTurn");
visible = true;
}
public function showPlayAgain():void{
var _local1:MessagePlayAgain;
gotoAndStop("playAgain");
_local1 = new MessagePlayAgain();
_local1.playAgainButton.addEventListener(MouseEvent.CLICK, playAgainButtonClicked);
_local1.homeButton.addEventListener(MouseEvent.CLICK, homeButtonClicked);
this.addChild(_local1);
}
private function playAgainButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).gotoGamePage();
}
public function hide():void{
visible = false;
}
public function showLose():void{
gotoAndStop("lose");
visible = true;
}
private function homeButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).gotoTitlePage();
}
public function showOpponentTurn():void{
gotoAndStop("opponentTurn");
visible = true;
}
public function showDisconnected():void{
gotoAndStop("disconnected");
visible = true;
}
public function showIllegal():void{
gotoAndStop("illegal");
visible = true;
}
public function showIllegalPlayer(_arg1:int):void{
gotoAndStop(((_arg1 == 0)) ? "solidsIllegal" : "stripesIllegal");
visible = false;
}
public function showOpponentIllegal():void{
gotoAndStop("opponentIllegal");
visible = true;
}
public function showFoul():void{
gotoAndStop("foul");
visible = true;
}
public function showWin():void{
gotoAndStop("win");
visible = true;
}
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 52
//MessagePlayAgain (com.novelgames.multiplayerflashgames.eightball.MessagePlayAgain)
package com.novelgames.multiplayerflashgames.eightball {
import flash.display.*;
public dynamic class MessagePlayAgain extends MovieClip {
public var homeButton:SimpleButton;
public var playAgainButton:SimpleButton;
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 53
//MusicGame (com.novelgames.multiplayerflashgames.eightball.MusicGame)
package com.novelgames.multiplayerflashgames.eightball {
import flash.media.*;
public dynamic class MusicGame extends Sound {
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 54
//SoundBall (com.novelgames.multiplayerflashgames.eightball.SoundBall)
package com.novelgames.multiplayerflashgames.eightball {
import flash.media.*;
public dynamic class SoundBall extends Sound {
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 55
//SoundCue (com.novelgames.multiplayerflashgames.eightball.SoundCue)
package com.novelgames.multiplayerflashgames.eightball {
import flash.media.*;
public dynamic class SoundCue extends Sound {
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 56
//SoundLose (com.novelgames.multiplayerflashgames.eightball.SoundLose)
package com.novelgames.multiplayerflashgames.eightball {
import flash.media.*;
public dynamic class SoundLose extends Sound {
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 57
//SoundPocket (com.novelgames.multiplayerflashgames.eightball.SoundPocket)
package com.novelgames.multiplayerflashgames.eightball {
import flash.media.*;
public dynamic class SoundPocket extends Sound {
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 58
//SoundWin (com.novelgames.multiplayerflashgames.eightball.SoundWin)
package com.novelgames.multiplayerflashgames.eightball {
import flash.media.*;
public dynamic class SoundWin extends Sound {
}
}//package com.novelgames.multiplayerflashgames.eightball
Section 59
//BaseButton (fl.controls.BaseButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.utils.*;
import fl.events.*;
public class BaseButton extends UIComponent {
protected var pressTimer:Timer;
protected var _autoRepeat:Boolean;// = false
protected var _selected:Boolean;// = false
protected var background:DisplayObject;
private var unlockedMouseState:String;
protected var mouseState:String;
private var _mouseStateLocked:Boolean;// = false
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};
public function BaseButton(){
buttonMode = true;
mouseChildren = false;
useHandCursor = false;
setupMouseEvents();
setMouseState("up");
pressTimer = new Timer(1, 0);
pressTimer.addEventListener(TimerEvent.TIMER, buttonDown, false, 0, true);
}
override public function get enabled():Boolean{
return (super.enabled);
}
protected function startPress():void{
if (_autoRepeat){
pressTimer.delay = Number(getStyleValue("repeatDelay"));
pressTimer.start();
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
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 drawLayout():void{
background.width = width;
background.height = height;
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
mouseEnabled = _arg1;
}
public function set autoRepeat(_arg1:Boolean):void{
_autoRepeat = _arg1;
}
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();
};
};
};
}
protected function drawBackground():void{
var _local1:String = (enabled) ? mouseState : "disabled";
if (selected){
_local1 = (("selected" + _local1.substr(0, 1).toUpperCase()) + _local1.substr(1));
};
_local1 = (_local1 + "Skin");
var _local2:DisplayObject = background;
background = getDisplayObjectInstance(getStyleValue(_local1));
addChildAt(background, 0);
if (((!((_local2 == null))) && (!((_local2 == background))))){
removeChild(_local2);
};
}
public function get selected():Boolean{
return (_selected);
}
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 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 selected(_arg1:Boolean):void{
if (_selected == _arg1){
return;
};
_selected = _arg1;
invalidate(InvalidationType.STATE);
}
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 setMouseState(_arg1:String):void{
if (_mouseStateLocked){
unlockedMouseState = _arg1;
return;
};
if (mouseState == _arg1){
return;
};
mouseState = _arg1;
invalidate(InvalidationType.STATE);
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 60
//Button (fl.controls.Button)
package fl.controls {
import flash.display.*;
import fl.core.*;
import fl.managers.*;
public class Button extends LabelButton implements IFocusManagerComponent {
protected var _emphasized:Boolean;// = false
protected var emphasizedBorder:DisplayObject;
private static var defaultStyles:Object = {emphasizedSkin:"Button_emphasizedSkin", emphasizedPadding:2};
public static var createAccessibilityImplementation:Function;
public function set emphasized(_arg1:Boolean):void{
_emphasized = _arg1;
invalidate(InvalidationType.STYLES);
}
override protected function initializeAccessibility():void{
if (Button.createAccessibilityImplementation != null){
Button.createAccessibilityImplementation(this);
};
}
protected function drawEmphasized():void{
var _local2:Number;
if (emphasizedBorder != null){
removeChild(emphasizedBorder);
};
emphasizedBorder = null;
if (!_emphasized){
return;
};
var _local1:Object = 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));
};
}
public function get emphasized():Boolean{
return (_emphasized);
}
override protected function draw():void{
if (((isInvalid(InvalidationType.STYLES)) || (isInvalid(InvalidationType.SIZE)))){
drawEmphasized();
};
super.draw();
if (emphasizedBorder != null){
setChildIndex(emphasizedBorder, (numChildren - 1));
};
}
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 static function getStyleDefinition():Object{
return (UIComponent.mergeStyles(LabelButton.getStyleDefinition(), defaultStyles));
}
}
}//package fl.controls
Section 61
//ButtonLabelPlacement (fl.controls.ButtonLabelPlacement)
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
Section 62
//LabelButton (fl.controls.LabelButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import fl.managers.*;
import flash.text.*;
import fl.events.*;
import flash.ui.*;
public class LabelButton extends BaseButton implements IFocusManagerComponent {
protected var _toggle:Boolean;// = false
public var textField:TextField;
protected var mode:String;// = "center"
protected var _labelPlacement:String;// = "right"
protected var oldMouseState:String;
protected var _label:String;// = "Label"
protected var icon:DisplayObject;
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;
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();
}
override protected function drawLayout():void{
var _local7:Number;
var _local8:Number;
var _local1:Number = Number(getStyleValue("textPadding"));
var _local2:String = ((((icon == null)) && ((mode == "center")))) ? ButtonLabelPlacement.TOP : _labelPlacement;
textField.height = (textField.textHeight + 4);
var _local3:Number = (textField.textWidth + 4);
var _local4:Number = (textField.textHeight + 4);
var _local5:Number = ((icon)==null) ? 0 : (icon.width + _local1);
var _local6:Number = ((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();
}
protected function toggleSelected(_arg1:MouseEvent):void{
selected = !(selected);
dispatchEvent(new Event(Event.CHANGE, true));
}
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));
};
}
public function get labelPlacement():String{
return (_labelPlacement);
}
public function get toggle():Boolean{
return (_toggle);
}
protected function setEmbedFont(){
var _local1:Object = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
}
override public function get selected():Boolean{
return ((_toggle) ? _selected : false);
}
override protected function configUI():void{
super.configUI();
textField = new TextField();
textField.type = TextFieldType.DYNAMIC;
textField.selectable = false;
addChild(textField);
}
override protected function initializeAccessibility():void{
if (LabelButton.createAccessibilityImplementation != null){
LabelButton.createAccessibilityImplementation(this);
};
}
public function set labelPlacement(_arg1:String):void{
_labelPlacement = _arg1;
invalidate(InvalidationType.SIZE);
}
protected function drawIcon():void{
var _local1:DisplayObject = icon;
var _local2:String = (enabled) ? mouseState : "disabled";
if (selected){
_local2 = (("selected" + _local2.substr(0, 1).toUpperCase()) + _local2.substr(1));
};
_local2 = (_local2 + "Icon");
var _local3:Object = 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);
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
if (oldMouseState == null){
oldMouseState = mouseState;
};
setMouseState("down");
startPress();
};
}
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);
}
override public function set selected(_arg1:Boolean):void{
_selected = _arg1;
if (_toggle){
invalidate(InvalidationType.STATE);
};
}
protected function drawTextFormat():void{
var _local1:Object = UIComponent.getStyleDefinition();
var _local2:TextFormat = (enabled) ? (_local1.defaultTextFormat as TextFormat) : (_local1.defaultDisabledTextFormat as TextFormat);
textField.setTextFormat(_local2);
var _local3:TextFormat = (getStyleValue((enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (_local3 != null){
textField.setTextFormat(_local3);
} else {
_local3 = _local2;
};
textField.defaultTextFormat = _local3;
setEmbedFont();
}
public function get label():String{
return (_label);
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, BaseButton.getStyleDefinition()));
}
}
}//package fl.controls
Section 63
//InvalidationType (fl.core.InvalidationType)
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
Section 64
//UIComponent (fl.core.UIComponent)
package fl.core {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import fl.managers.*;
import flash.text.*;
import fl.events.*;
import flash.system.*;
public class UIComponent extends Sprite {
protected var _x:Number;
protected var _enabled:Boolean;// = true
protected var callLaterMethods:Dictionary;
private var _mouseFocusEnabled:Boolean;// = true
private var tempText:TextField;
private var _focusEnabled:Boolean;// = true
protected var startHeight:Number;
protected var _height:Number;
protected var invalidateFlag:Boolean;// = false
protected var _oldIMEMode:String;// = null
protected var _inspector:Boolean;// = false
protected var startWidth:Number;
public var focusTarget:IFocusManagerComponent;
protected var errorCaught:Boolean;// = false
protected var invalidHash:Object;
protected var sharedStyles:Object;
protected var uiFocusRect:DisplayObject;
protected var isLivePreview:Boolean;// = false
protected var _imeMode:String;// = null
protected var _width:Number;
protected var instanceStyles:Object;
public var version:String;// = "3.0.0.16"
protected var isFocused:Boolean;// = false
protected var _y:Number;
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);
public function UIComponent(){
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 function getStyle(_arg1:String):Object{
return (instanceStyles[_arg1]);
}
protected function checkLivePreview():Boolean{
var className:String;
if (parent == null){
return (false);
};
try {
className = getQualifiedClassName(parent);
} catch(e:Error) {
};
return ((className == "fl.livepreview::LivePreviewParent"));
}
private function callLaterDispatcher(_arg1:Event):void{
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;
var _local2:Dictionary = callLaterMethods;
for (_local3 in _local2) {
_local3();
delete _local2[_local3];
};
inCallLaterPhase = false;
}
protected function validate():void{
invalidHash = {};
}
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);
}
override public function get height():Number{
return (_height);
}
private function addedHandler(_arg1:Event):void{
removeEventListener("addedToStage", addedHandler);
initializeFocusManager();
}
protected function getStyleValue(_arg1:String):Object{
return (((instanceStyles[_arg1])==null) ? sharedStyles[_arg1] : instanceStyles[_arg1]);
}
public function invalidate(_arg1:String="all", _arg2:Boolean=true):void{
invalidHash[_arg1] = true;
if (_arg2){
this.callLater(draw);
};
}
protected function isOurFocus(_arg1:DisplayObject):Boolean{
return ((_arg1 == this));
}
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{
}
override public function get scaleY():Number{
return ((height / startHeight));
}
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;
};
};
}
protected function draw():void{
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
override public function set height(_arg1:Number):void{
if (_height == _arg1){
return;
};
setSize(width, _arg1);
}
protected function configUI():void{
isLivePreview = checkLivePreview();
var _local1:Number = rotation;
rotation = 0;
var _local2:Number = super.width;
var _local3:Number = 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 setScaleY(_arg1:Number):void{
super.scaleY = _arg1;
}
override public function get scaleX():Number{
return ((width / startWidth));
}
protected function setScaleX(_arg1:Number):void{
super.scaleX = _arg1;
}
private function initializeFocusManager():void{
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, addedHandler, false, 0, true);
} else {
createFocusManager();
};
}
protected function keyDownHandler(_arg1:KeyboardEvent):void{
}
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 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);
}
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 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);
}
public function set enabled(_arg1:Boolean):void{
if (_arg1 == _enabled){
return;
};
_enabled = _arg1;
invalidate(InvalidationType.STATE);
}
public function setSize(_arg1:Number, _arg2:Number):void{
_width = _arg1;
_height = _arg2;
invalidate(InvalidationType.SIZE);
dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, false));
}
protected function keyUpHandler(_arg1:KeyboardEvent):void{
}
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);
};
}
public function set focusEnabled(_arg1:Boolean):void{
_focusEnabled = _arg1;
}
override public function set width(_arg1:Number):void{
if (_width == _arg1){
return;
};
setSize(_arg1, height);
}
public function setFocus():void{
if (stage){
stage.focus = this;
};
}
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 skin = _arg1;
var classDef:Object;
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 initializeAccessibility():void{
if (UIComponent.createAccessibilityImplementation != null){
UIComponent.createAccessibilityImplementation(this);
};
}
public function get focusManager():IFocusManager{
var _local1:DisplayObject = 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);
}
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);
};
}
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();
}
override public function set visible(_arg1:Boolean):void{
if (super.visible == _arg1){
return;
};
super.visible = _arg1;
var _local2:String = (_arg1) ? ComponentEvent.SHOW : ComponentEvent.HIDE;
dispatchEvent(new ComponentEvent(_local2, true));
}
protected function createFocusManager():void{
if (focusManagers[stage] == null){
focusManagers[stage] = new FocusManager(stage);
};
}
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 y(_arg1:Number):void{
move(_x, _arg1);
}
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);
};
}
override public function set x(_arg1:Number):void{
move(_arg1, _y);
}
public function drawNow():void{
draw();
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
public static function mergeStyles(... _args):Object{
var _local5:Object;
var _local6:String;
var _local2:Object = {};
var _local3:uint = _args.length;
var _local4:uint;
while (_local4 < _local3) {
_local5 = _args[_local4];
for (_local6 in _local5) {
if (_local2[_local6] != null){
} else {
_local2[_local6] = _args[_local4][_local6];
};
};
_local4++;
};
return (_local2);
}
}
}//package fl.core
Section 65
//ComponentEvent (fl.events.ComponentEvent)
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
Section 66
//FocusManager (fl.managers.FocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
import fl.core.*;
import flash.events.*;
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){
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 _local7:DisplayObject;
var _local8:IFocusManagerGroup;
var _local9:int;
var _local10:DisplayObject;
var _local11:IFocusManagerGroup;
var _local5:int = focusableCandidates.length;
var _local6:int = _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);
}
private function mouseFocusChangeHandler(_arg1:FocusEvent):void{
if ((_arg1.relatedObject is TextField)){
return;
};
_arg1.preventDefault();
}
public function set form(_arg1:DisplayObjectContainer):void{
_form = _arg1;
}
private function addFocusables(_arg1:DisplayObject, _arg2:Boolean=false):void{
var focusable:IFocusManagerComponent;
var io:InteractiveObject;
var doc:DisplayObjectContainer;
var i:int;
var child:DisplayObject;
var o = _arg1;
var skipTopLevel = _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));
}
public function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject{
var _local2:InteractiveObject = _arg1;
while (_arg1) {
if ((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
};
return (_local2);
}
private function focusOutHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject = (_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);
}
private function setFocusToNextObject(_arg1:FocusEvent):void{
if (!hasFocusableObjects()){
return;
};
var _local2:InteractiveObject = getNextFocusManagerComponent(_arg1.shiftKey);
if (_local2){
setFocus(_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 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);
}
public function sendDefaultButtonEvent():void{
defButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
private function addedHandler(_arg1:Event):void{
var _local2:DisplayObject = DisplayObject(_arg1.target);
if (_local2.stage){
addFocusables(DisplayObject(_arg1.target));
};
}
private function isEnabledAndVisible(_arg1:DisplayObject):Boolean{
var _local3:TextField;
var _local4:SimpleButton;
var _local2:DisplayObjectContainer = 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);
}
private function tabChildrenChangeHandler(_arg1:Event):void{
if (_arg1.target != _arg1.currentTarget){
return;
};
calculateCandidates = true;
var _local2:DisplayObjectContainer = DisplayObjectContainer(_arg1.target);
if (_local2.tabChildren){
addFocusables(_local2, true);
} else {
removeFocusables(_local2);
};
}
private function deactivateHandler(_arg1:Event):void{
var _local2:InteractiveObject = InteractiveObject(_arg1.target);
}
public function setFocus(_arg1:InteractiveObject):void{
if ((_arg1 is IFocusManagerComponent)){
IFocusManagerComponent(_arg1).setFocus();
} else {
form.stage.focus = _arg1;
};
}
public function getFocus():InteractiveObject{
var _local1:InteractiveObject = form.stage.focus;
return (findFocusManagerComponent(_local1));
}
private function hasFocusableObjects():Boolean{
var _local1:Object;
for (_local1 in focusableObjects) {
return (true);
};
return (false);
}
private function tabIndexChangeHandler(_arg1:Event):void{
calculateCandidates = true;
}
public function set defaultButton(_arg1:Button):void{
var _local2:Button = (_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 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 = focusableCandidates.length;
var _local3:int;
_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 _local4:InteractiveObject;
var _local3:DisplayObject = 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 _local5:int;
var _local6:String;
var _local7:String;
var _local3 = "";
var _local4 = "";
var _local8 = "0000";
var _local9:DisplayObject = DisplayObject(_arg1);
var _local10:DisplayObject = 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 = 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 _local8:IFocusManagerGroup;
if (!hasFocusableObjects()){
return (null);
};
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
var _local2:DisplayObject = form.stage.focus;
_local2 = DisplayObject(findFocusManagerComponent(InteractiveObject(_local2)));
var _local3 = "";
if ((_local2 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local2);
_local3 = _local8.groupName;
};
var _local4:int = getIndexOfFocusedObject(_local2);
var _local5:Boolean;
var _local6:int = _local4;
if (_local4 == -1){
if (_arg1){
_local4 = focusableCandidates.length;
};
_local5 = true;
};
var _local7:int = getIndexOfNextObject(_local4, _arg1, _local5, _local3);
return (findFocusManagerComponent(focusableCandidates[_local7]));
}
private function mouseDownHandler(_arg1:MouseEvent):void{
if (_arg1.isDefaultPrevented()){
return;
};
var _local2:InteractiveObject = 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 = _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 _local3:Button;
var _local2:InteractiveObject = 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{
calculateCandidates = true;
var _local2:InteractiveObject = InteractiveObject(_arg1.target);
var _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 get defaultButtonEnabled():Boolean{
return (_defaultButtonEnabled);
}
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;
}
}
}//package fl.managers
Section 67
//IFocusManager (fl.managers.IFocusManager)
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 findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject;
function get nextTabIndex():int;
function get defaultButton():Button;
function get showFocusIndicator():Boolean;
function hideFocus():void;
function activate():void;
function showFocus():void;
function set defaultButtonEnabled(_arg1:Boolean):void;
function setFocus(_arg1:InteractiveObject):void;
function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject;
}
}//package fl.managers
Section 68
//IFocusManagerComponent (fl.managers.IFocusManagerComponent)
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
Section 69
//IFocusManagerGroup (fl.managers.IFocusManagerGroup)
package fl.managers {
public interface IFocusManagerGroup {
function get groupName():String;
function get selected():Boolean;
function set groupName(_arg1:String):void;
function set selected(_arg1:Boolean):void;
}
}//package fl.managers
Section 70
//StyleManager (fl.managers.StyleManager)
package fl.managers {
import fl.core.*;
import flash.utils.*;
import flash.text.*;
public class StyleManager {
private var classToInstancesDict:Dictionary;
private var globalStyles:Object;
private var styleToClassesHash:Object;
private var classToStylesDict:Dictionary;
private var classToDefaultStylesDict:Dictionary;
private static var _instance:StyleManager;
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 = getClassDef(_arg1);
var _local4:Object = 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 = getClassDef(_arg1);
var _local5:Object = 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 _local5:String;
var _local2:StyleManager = getInstance();
var _local3:Class = getClassDef(_arg1);
var _local4:Object = _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 = getClassDef(_arg1);
var _local4:Object = 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 _local4:Object;
var _local5:UIComponent;
var _local3:Dictionary = 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 _local3:Object;
var _local2:Dictionary = getInstance().styleToClassesHash[_arg1];
if (_local2 == null){
return;
};
for (_local3 in _local2) {
invalidateComponentStyle(Class(_local3), _arg1);
};
}
public static function registerInstance(_arg1:UIComponent):void{
var target:Class;
var defaultStyles:Object;
var styleToClasses:Object;
var n:String;
var instance = _arg1;
var inst:StyleManager = getInstance();
var classDef:Class = 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;
if (inst.classToStylesDict[classDef] == null){
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 = getClassDef(_arg1);
var _local4:StyleManager = getInstance();
var _local5:Object = _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 = getInstance().globalStyles;
if ((((_local3[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
_local3[_arg1] = _arg2;
invalidateStyle(_arg1);
}
}
}//package fl.managers
Section 71
//MochiAd (mochi.as3.MochiAd)
package mochi.as3 {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiAd {
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function showClickAwayAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:2000, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function ():void{
}, ad_finished:function ():void{
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
var sendHostProgress:Boolean;
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
chk["onEnterFrame"] = function ():void{
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
return;
};
var _local1:Object = this.parent._mochiad_ctr;
var _local2:Number = (getTimer() - this.started);
var _local3:Boolean;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
_local3 = true;
chk.started = getTimer();
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (this.root == null){
_local3 = true;
};
if (_local3){
delete this.onEnterFrame;
};
};
doOnEnterFrame(chk);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _allowDomains(_arg1:String):String{
var _local2:String = _arg1.split("/")[2].split(":")[0];
if (Security.sandboxType == "application"){
return (_local2);
};
Security.allowDomain("*");
Security.allowDomain(_local2);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(_local2);
return (_local2);
}
public static function unload(_arg1:Object):Boolean{
if (((_arg1.clip) && (_arg1.clip._mochiad))){
_arg1 = _arg1.clip;
};
if (_arg1.origFrameRate != undefined){
_arg1.stage.frameRate = _arg1.origFrameRate;
};
if (!_arg1._mochiad){
return (false);
};
if (_arg1._mochiad._containerLCName != undefined){
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "notify", {id:"unload"});
};
if (_arg1._mochiad.onUnload){
_arg1._mochiad.onUnload();
};
delete _arg1._mochiad_loaded;
delete _arg1._mochiad;
return (true);
}
public static function showInterLevelAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = (_arg1 - 250);
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
chk["onEnterFrame"] = function ():void{
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Object = this.parent._mochiad_ctr;
var _local2:Number = (getTimer() - this.started);
var _local3:Boolean;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (_local2 > chk.ad_msec){
_local3 = true;
};
if (_local3){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _parseOptions(_arg1:Object, _arg2:Object):Object{
var _local4:String;
var _local5:Array;
var _local6:Number;
var _local7:Array;
var _local3:Object = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
if (_arg1){
for (_local4 in _arg1) {
_local3[_local4] = _arg1[_local4];
};
};
if (_local3.clip == undefined){
throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
};
_arg1 = _local3.clip.loaderInfo.parameters.mochiad_options;
if (_arg1){
_local5 = _arg1.split("&");
_local6 = 0;
while (_local6 < _local5.length) {
_local7 = _local5[_local6].split("=");
_local3[unescape(_local7[0])] = unescape(_local7[1]);
_local6++;
};
};
if (_local3.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (_local3);
}
public static function _cleanup(_arg1:Object):void{
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = _arg1;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
try {
lc.client = null;
lc.close();
} catch(e:Error) {
};
};
setTimeout(f, 0);
};
var idx:Number = DisplayObjectContainer(mc).numChildren;
while (idx > 0) {
idx = (idx - 1);
DisplayObjectContainer(mc).removeChildAt(idx);
};
for (k in mc) {
delete mc[k];
};
}
public static function load(_arg1:Object):MovieClip{
var clip:Object;
var k:String;
var server:String;
var hostname:String;
var lc:LocalConnection;
var name:String;
var loader:Loader;
var g:Function;
var req:URLRequest;
var v:Object;
var options = _arg1;
var DEFAULTS:Object = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!(clip is DisplayObject)){
trace("Warning: Object passed as container clip not a descendant of the DisplayObject type");
return (null);
};
if (MovieClip(clip).stage == null){
trace("Warning: Container clip for ad is not attached to the stage");
return (null);
};
if (!MochiAd._isNetworkAvailable()){
return (null);
};
try {
if (clip._mochiad_loaded){
return (null);
};
} catch(e:Error) {
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
var depth:Number = options.depth;
delete options.depth;
var mc:MovieClip = createEmptyMovieClip(clip, "_mochiad", depth);
var wh:Array = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
} else {
trace("[MochiAd] NOTE: Security Sandbox Violation errors below are normal");
};
var lv:URLVariables = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
mc.lcName = name;
lv.lc = name;
lv.st = getTimer();
loader = new Loader();
g = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest(((server + ".swf?cacheBust=") + new Date().getTime()));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function (_arg1:IOErrorEvent):void{
trace("[MochiAds] Blocked URL");
});
if (!options.skip){
loader.load(req);
};
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function runMethod(_arg1:Object, _arg2:String, _arg3:Array):Object{
var _local4:Array = _arg2.split(".");
var _local5:Number = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
if (typeof(_arg1[_local4[_local5]]) == "function"){
return (_arg1[_local4[_local5]].apply(_arg1, _arg3));
};
return (undefined);
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number):MovieClip{
var _local4:MovieClip = new MovieClip();
if (((false) && (_arg3))){
_arg1.addChildAt(_local4, _arg3);
} else {
_arg1.addChild(_local4);
};
_arg1[_arg2] = _local4;
_local4["_name"] = _arg2;
return (_local4);
}
public static function _getRes(_arg1:Object, _arg2:Object):Array{
var _local6:Array;
var _local3:Object = _arg2.getBounds(_arg2.root);
var _local4:Number = 0;
var _local5:Number = 0;
if (typeof(_arg1.res) != "undefined"){
_local6 = _arg1.res.split("x");
_local4 = parseFloat(_local6[0]);
_local5 = parseFloat(_local6[1]);
} else {
_local4 = (_local3.xMax - _local3.xMin);
_local5 = (_local3.yMax - _local3.yMin);
};
if ((((_local4 == 0)) || ((_local5 == 0)))){
_local4 = _arg2.stage.stageWidth;
_local5 = _arg2.stage.stageHeight;
};
return ([_local4, _local5]);
}
public static function adShowing(_arg1:Object):void{
_arg1.origFrameRate = _arg1.stage.frameRate;
_arg1.stage.frameRate = 30;
}
public static function getValue(_arg1:Object, _arg2:String):Object{
var _local3:Array = _arg2.split(".");
var _local4:Number = 0;
while (_local4 < (_local3.length - 1)) {
if ((((_arg1[_local3[_local4]] == undefined)) || ((_arg1[_local3[_local4]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local3[_local4]];
_local4++;
};
return (_arg1[_local3[_local4]]);
}
public static function rpc(_arg1:Object, _arg2:Number, _arg3:Object):void{
var _local4:Object;
var _local5:Object;
switch (_arg3.id){
case "setValue":
MochiAd.setValue(_arg1, _arg3.objectName, _arg3.value);
break;
case "getValue":
_local4 = MochiAd.getValue(_arg1, _arg3.objectName);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local4);
break;
case "runMethod":
_local5 = MochiAd.runMethod(_arg1, _arg3.method, _arg3.args);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local5);
break;
default:
trace(("[mochiads rpc] unknown rpc id: " + _arg3.id));
};
}
public static function setValue(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Array = _arg2.split(".");
var _local5:Number = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return;
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
_arg1[_local4[_local5]] = _arg3;
}
public static function showPreGameAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var complete:Boolean;
var unloaded:Boolean;
var sendHostProgress:Boolean;
var fn:Function;
var r:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, no_progress_bar:false, ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}, ad_progress:function (_arg1:Number):void{
}, progress_override:function (_arg1:Object):Number{
return (NaN);
}, bar_offset:0};
options = MochiAd._parseOptions(options, DEFAULTS);
if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def"){
options.ad_started();
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
return;
};
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
if (options.skip){
ad_timeout = 0;
};
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
var fn:Function = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
var bar:MovieClip = createEmptyMovieClip(chk, "_mochiad_bar", 4);
if (options.no_progress_bar){
bar.visible = false;
delete options.no_progress_bar;
} else {
bar.x = (10 + options.bar_offset);
bar.y = (h - 20);
};
var bar_w:Number = ((w - bar.x) - 10);
var bar_color:Number = options.color;
delete options.color;
var bar_background:Number = options.background;
delete options.background;
var bar_outline:Number = options.outline;
delete options.outline;
var backing_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 1);
var backing:Object = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo(bar_w, 0);
backing.lineTo(bar_w, 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
var inside_mc:MovieClip = createEmptyMovieClip(bar, "_inside", 2);
var inside:Object = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo(bar_w, 0);
inside.lineTo(bar_w, 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
var outline_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 3);
var outline:Object = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo(bar_w, 0);
outline.lineTo(bar_w, 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
var progress:Number = Math.min(1, options.progress_override(clip));
var f:Function = function (_arg1:Event):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
if (!isNaN(progress)){
complete = (progress == 1);
} else {
if (clip.loaderInfo.bytesLoaded == clip.loaderInfo.bytesTotal){
complete = true;
} else {
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
} else {
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
};
} else {
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
};
};
};
mc.unloadAd = function ():void{
unloaded = true;
if (complete){
MochiAd.unload(clip);
};
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = _arg1;
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
mc.rpcTestFn = function (_arg1:String):Object{
trace(("[MOCHIAD rpcTestFn] " + _arg1));
return (_arg1);
};
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
sendHostProgress = false;
mc.sendHostLoadProgress = function (_arg1:String):void{
sendHostProgress = true;
};
chk["onEnterFrame"] = function ():void{
var _local12:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
var _local1:Object = this.parent.parent.root;
var _local2:Object = this.parent._mochiad_ctr;
var _local3:Number = (getTimer() - this.started);
var _local4:Boolean;
var _local5:Number = _local1.loaderInfo.bytesTotal;
var _local6:Number = _local1.loaderInfo.bytesLoaded;
var _local7:Number = Math.min(1, options.progress_override(_local1));
if (_local7 == 1){
complete = true;
};
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
var _local8:Number = ((100 * _local6) / _local5);
if (!isNaN(_local7)){
_local8 = (100 * _local7);
};
var _local9:Number = ((100 * _local3) / chk.ad_msec);
var _local10:Object = this._mochiad_bar._inside;
var _local11:Number = Math.min(100, Math.min(((_local8) || (0)), _local9));
_local11 = Math.max(this.last_pcnt, _local11);
this.last_pcnt = _local11;
_local10.scaleX = (_local11 * 0.01);
options.ad_progress(_local11);
if (sendHostProgress){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:_local8});
if (_local8 >= 100){
sendHostProgress = false;
};
};
if (!chk.showing){
_local12 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local12 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if ((((_local3 > chk.ad_timeout)) && ((_local8 == 100)))){
options.ad_failed();
_local4 = true;
};
};
};
if (_local3 > chk.ad_msec){
_local4 = true;
};
if (((complete) && (_local4))){
if (unloaded){
MochiAd.unload(_local1);
} else {
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
MochiAd.showPreGameAd(_arg1);
}
public static function showTimedAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
MochiAd.showInterLevelAd(_arg1);
}
public static function doOnEnterFrame(_arg1:MovieClip):void{
var mc = _arg1;
var f:Function = function (_arg1:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package mochi.as3
Section 72
//MochiCoins (mochi.as3.MochiCoins)
package mochi.as3 {
public class MochiCoins {
public static const STORE_HIDE:String = "StoreHide";
public static const NO_USER:String = "NoUser";
public static const IO_ERROR:String = "IOError";
public static const ITEM_NEW:String = "ItemNew";
public static const ITEM_OWNED:String = "ItemOwned";
public static const STORE_ITEMS:String = "StoreItems";
public static const ERROR:String = "Error";
public static const STORE_SHOW:String = "StoreShow";
public static var _inventory:MochiInventory;
public static function triggerEvent(_arg1:String, _arg2:Object):void{
MochiSocial.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
MochiSocial.removeEventListener(_arg1, _arg2);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
MochiSocial.addEventListener(_arg1, _arg2);
}
public static function getStoreItems():void{
MochiServices.send("coins_getStoreItems");
}
public static function get inventory():MochiInventory{
return (_inventory);
}
public static function showStore(_arg1:Object=null):void{
MochiServices.bringToTop();
MochiServices.send("coins_showStore", {options:_arg1}, null, null);
}
public static function showItem(_arg1:Object=null):void{
if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
trace("ERROR: showItem call must pass an Object with an item key");
return;
};
MochiServices.bringToTop();
MochiServices.send("coins_showItem", {options:_arg1}, null, null);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function showVideo(_arg1:Object=null):void{
if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
trace("ERROR: showVideo call must pass an Object with an item key");
return;
};
MochiServices.bringToTop();
MochiServices.send("coins_showVideo", {options:_arg1}, null, null);
}
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, function (_arg1:Object):void{
_inventory = new MochiInventory();
});
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, function (_arg1:Object):void{
_inventory = null;
});
}
}//package mochi.as3
Section 73
//MochiDigits (mochi.as3.MochiDigits)
package mochi.as3 {
public final class MochiDigits {
private var Sibling:MochiDigits;
private var Fragment:Number;
private var Encoder:Number;
public function MochiDigits(_arg1:Number=0, _arg2:uint=0):void{
Encoder = 0;
setValue(_arg1, _arg2);
}
public function reencode():void{
var _local1:uint = int((2147483647 * Math.random()));
Fragment = (Fragment ^ (_local1 ^ Encoder));
Encoder = _local1;
}
public function set value(_arg1:Number):void{
setValue(_arg1);
}
public function toString():String{
var _local1:String = String.fromCharCode((Fragment ^ Encoder));
if (Sibling != null){
_local1 = (_local1 + Sibling.toString());
};
return (_local1);
}
public function setValue(_arg1:Number=0, _arg2:uint=0):void{
var _local3:String = _arg1.toString();
var _temp1 = _arg2;
_arg2 = (_arg2 + 1);
Fragment = (_local3.charCodeAt(_temp1) ^ Encoder);
if (_arg2 < _local3.length){
Sibling = new MochiDigits(_arg1, _arg2);
} else {
Sibling = null;
};
reencode();
}
public function get value():Number{
return (Number(this.toString()));
}
public function addValue(_arg1:Number):void{
value = (value + _arg1);
}
}
}//package mochi.as3
Section 74
//MochiEventDispatcher (mochi.as3.MochiEventDispatcher)
package mochi.as3 {
public class MochiEventDispatcher {
private var eventTable:Object;
public function MochiEventDispatcher():void{
eventTable = {};
}
public function triggerEvent(_arg1:String, _arg2:Object):void{
var _local3:Object;
if (eventTable[_arg1] == undefined){
return;
};
for (_local3 in eventTable[_arg1]) {
var _local6 = eventTable[_arg1];
_local6[_local3](_arg2);
};
}
public function removeEventListener(_arg1:String, _arg2:Function):void{
var _local3:Object;
if (eventTable[_arg1] == undefined){
eventTable[_arg1] = [];
return;
};
for (_local3 in eventTable[_arg1]) {
if (eventTable[_arg1][_local3] != _arg2){
} else {
eventTable[_arg1].splice(Number(_local3), 1);
};
};
}
public function addEventListener(_arg1:String, _arg2:Function):void{
removeEventListener(_arg1, _arg2);
eventTable[_arg1].push(_arg2);
}
}
}//package mochi.as3
Section 75
//MochiEvents (mochi.as3.MochiEvents)
package mochi.as3 {
import flash.display.*;
public class MochiEvents {
public static const ALIGN_BOTTOM_LEFT:String = "ALIGN_BL";
public static const FORMAT_LONG:String = "LongForm";
public static const ALIGN_BOTTOM:String = "ALIGN_B";
public static const ACHIEVEMENT_RECEIVED:String = "AchievementReceived";
public static const FORMAT_SHORT:String = "ShortForm";
public static const ALIGN_TOP_RIGHT:String = "ALIGN_TR";
public static const ALIGN_BOTTOM_RIGHT:String = "ALIGN_BR";
public static const ALIGN_TOP:String = "ALIGN_T";
public static const ALIGN_LEFT:String = "ALIGN_L";
public static const ALIGN_RIGHT:String = "ALIGN_R";
public static const ALIGN_TOP_LEFT:String = "ALIGN_TL";
public static const ALIGN_CENTER:String = "ALIGN_C";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
private static var gameStart:Number;
private static var levelStart:Number;
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function startSession(_arg1:String):void{
MochiServices.send("events_beginSession", {achievementID:_arg1}, null, null);
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function setNotifications(_arg1:MovieClip, _arg2:Object):void{
var _local4:Object;
var _local3:Object = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
_local3.clip = _arg1;
MochiServices.send("events_setNotifications", _local3, null, null);
}
public static function endGame():void{
var _local1:Number = (new Date().time - gameStart);
trigger("end_game", {time:_local1});
}
public static function startGame():void{
gameStart = new Date().time;
trigger("start_game");
}
public static function trigger(_arg1:String, _arg2:Object=null):void{
if (_arg2 == null){
_arg2 = {};
} else {
if (_arg2["kind"] != undefined){
trace("WARNING: optional arguments package contains key 'id', it will be overwritten");
_arg2["kind"] = _arg1;
};
};
MochiServices.send("events_triggerEvent", {eventObject:_arg2}, null, null);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function startLevel():void{
levelStart = new Date().time;
trigger("start_level");
}
public static function endLevel():void{
var _local1:Number = (new Date().time - levelStart);
trigger("end_level", {time:_local1});
}
}
}//package mochi.as3
Section 76
//MochiInventory (mochi.as3.MochiInventory)
package mochi.as3 {
import flash.events.*;
import flash.utils.*;
public dynamic class MochiInventory extends Proxy {
private var _timer:Timer;
private var _names:Array;
private var _syncID:Number;
private var _consumableProperties:Object;
private var _storeSync:Object;
private var _outstandingID:Number;
private var _syncPending:Boolean;
public static const READY:String = "InvReady";
public static const ERROR:String = "Error";
public static const IO_ERROR:String = "IoError";
private static const KEY_SALT:String = " syncMaint";
public static const WRITTEN:String = "InvWritten";
public static const NOT_READY:String = "InvNotReady";
public static const VALUE_ERROR:String = "InvValueError";
private static const CONSUMER_KEY:String = "MochiConsumables";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public function MochiInventory():void{
MochiCoins.addEventListener(MochiCoins.ITEM_OWNED, itemOwned);
MochiCoins.addEventListener(MochiCoins.ITEM_NEW, newItems);
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, loggedIn);
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, loggedOut);
_storeSync = new Object();
_syncPending = false;
_outstandingID = 0;
_syncID = 0;
_timer = new Timer(1000);
_timer.addEventListener(TimerEvent.TIMER, sync);
_timer.start();
if (MochiSocial.loggedIn){
loggedIn();
} else {
loggedOut();
};
}
private function newItems(_arg1:Object):void{
if (!this[(_arg1.id + KEY_SALT)]){
this[(_arg1.id + KEY_SALT)] = 0;
};
if (!this[_arg1.id]){
this[_arg1.id] = 0;
};
this[(_arg1.id + KEY_SALT)] = (this[(_arg1.id + KEY_SALT)] + _arg1.count);
this[_arg1.id] = (this[_arg1.id] + _arg1.count);
if (_arg1.privateProperties.consumable){
if (!this[_arg1.privateProperties.tag]){
this[_arg1.privateProperties.tag] = 0;
};
this[_arg1.privateProperties.tag] = (this[_arg1.privateProperties.tag] + (_arg1.privateProperties.inc * _arg1.count));
};
}
public function release():void{
MochiCoins.removeEventListener(MochiCoins.ITEM_NEW, newItems);
MochiSocial.removeEventListener(MochiSocial.LOGGED_IN, loggedIn);
MochiSocial.removeEventListener(MochiSocial.LOGGED_OUT, loggedOut);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return (-1);
};
if (_consumableProperties[_arg1]){
return (MochiDigits(_consumableProperties[_arg1]).value);
};
return (undefined);
}
private function loggedIn(_arg1:Object=null):void{
MochiUserData.get(CONSUMER_KEY, getConsumableBag);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(_arg1):Boolean{
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return (false);
};
if (_consumableProperties[_arg1] == undefined){
return (false);
};
return (true);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(_arg1:int):int{
return (((_arg1)>=_names.length) ? 0 : (_arg1 + 1));
}
private function putConsumableBag(_arg1:MochiUserData):void{
_syncPending = false;
if (_arg1.error){
triggerEvent(ERROR, {type:IO_ERROR, error:_arg1.error});
_outstandingID = -1;
};
triggerEvent(WRITTEN, {});
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
var _local3:MochiDigits;
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return;
};
if (!(_arg2 is Number)){
triggerEvent(ERROR, {type:VALUE_ERROR, error:"Invalid type", arg:_arg2});
return;
};
if (_consumableProperties[_arg1]){
_local3 = MochiDigits(_consumableProperties[_arg1]);
if (_local3.value == _arg2){
return;
};
_local3.value = _arg2;
} else {
_names.push(_arg1);
_consumableProperties[_arg1] = new MochiDigits(_arg2);
};
_syncID++;
}
private function itemOwned(_arg1:Object):void{
_storeSync[_arg1.id] = {properties:_arg1.properties, count:_arg1.count};
}
private function sync(_arg1:Event=null):void{
var _local3:String;
if (((_syncPending) || ((_syncID == _outstandingID)))){
return;
};
_outstandingID = _syncID;
var _local2:Object = {};
for (_local3 in _consumableProperties) {
_local2[_local3] = MochiDigits(_consumableProperties[_local3]).value;
};
MochiUserData.put(CONSUMER_KEY, _local2, putConsumableBag);
_syncPending = true;
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(_arg1:int):String{
return (_names[(_arg1 - 1)]);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function deleteProperty(_arg1):Boolean{
if (!_consumableProperties[_arg1]){
return (false);
};
_names.splice(_names.indexOf(_arg1), 1);
delete _consumableProperties[_arg1];
return (true);
}
private function getConsumableBag(_arg1:MochiUserData):void{
var _local2:String;
var _local3:Number;
if (_arg1.error){
triggerEvent(ERROR, {type:IO_ERROR, error:_arg1.error});
return;
};
_consumableProperties = {};
_names = new Array();
if (_arg1.data){
for (_local2 in _arg1.data) {
_names.push(_local2);
_consumableProperties[_local2] = new MochiDigits(_arg1.data[_local2]);
};
};
for (_local2 in _storeSync) {
_local3 = _storeSync[_local2].count;
if (_consumableProperties[(_local2 + KEY_SALT)]){
_local3 = (_local3 - _consumableProperties[_local2]);
};
if (_local3 == 0){
} else {
newItems({id:_local2, count:_local3, properties:_storeSync[_local2].properties});
};
};
triggerEvent(READY, {});
}
private function loggedOut(_arg1:Object=null):void{
_consumableProperties = null;
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
}
}//package mochi.as3
Section 77
//MochiServices (mochi.as3.MochiServices)
package mochi.as3 {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.geom.*;
import flash.net.*;
import flash.system.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
private static var _preserved:Object;
public static var netupAttempted:Boolean = false;
private static var _sendChannel:LocalConnection;
public static var servicesSync:MochiSync = new MochiSync();
private static var _clip:MovieClip;
private static var _id:String;
private static var _services:String = "services.swf";
private static var _servURL:String = "http://www.mochiads.com/static/lib/services/";
public static var widget:Boolean = false;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _loader:Loader;
private static var _connecting:Boolean = false;
private static var _mochiLocalConnection:MovieClip;
private static var _listenChannelName:String = "__ms_";
public static var onError:Object;
public static var netup:Boolean = true;
private static var _mochiLC:String = "MochiLC.swf";
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function get connected():Boolean{
return (_connected);
}
private static function onReceive(_arg1:Object):void{
var methodName:String;
var pkg = _arg1;
var cb:String = pkg.callbackID;
var cblst:Object = _clip._callbacks[cb];
if (!cblst){
return;
};
var method:* = cblst.callbackMethod;
methodName = "";
var obj:Object = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete _clip._callbacks[cb];
}
public static function get childClip():Object{
return (_clip);
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
trace(("Error: MochiServices not connected. Please call MochiServices.connect(). Function: " + _arg1));
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_clip._queue.push({methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
};
if (_clip != null){
if (((!((_clip._callbacks == null))) && (!((_clip._nextcallbackID == null))))){
_clip._callbacks[_clip._nextcallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_clip._nextcallbackID++;
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
private static function clickMovie(_arg1:String, _arg2:Function):MovieClip{
var _local4:int;
var _local14:Loader;
var _local3:Array = [150, 21, 0, 7, 1, 0, 0, 0, 0, 98, 116, 110, 0, 7, 2, 0, 0, 0, 0, 116, 104, 105, 115, 0, 28, 150, 22, 0, 0, 99, 114, 101, 97, 116, 101, 69, 109, 112, 116, 121, 77, 111, 118, 105, 101, 67, 108, 105, 112, 0, 82, 135, 1, 0, 0, 23, 150, 13, 0, 4, 0, 0, 111, 110, 82, 101, 108, 101, 97, 115, 101, 0, 142, 8, 0, 0, 0, 0, 2, 42, 0, 114, 0, 150, 17, 0, 0, 32, 0, 7, 1, 0, 0, 0, 8, 0, 0, 115, 112, 108, 105, 116, 0, 82, 135, 1, 0, 1, 23, 150, 7, 0, 4, 1, 7, 0, 0, 0, 0, 78, 150, 8, 0, 0, 95, 98, 108, 97, 110, 107, 0, 154, 1, 0, 0, 150, 7, 0, 0, 99, 108, 105, 99, 107, 0, 150, 7, 0, 4, 1, 7, 1, 0, 0, 0, 78, 150, 27, 0, 7, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 76, 111, 99, 97, 108, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 0, 64, 150, 6, 0, 0, 115, 101, 110, 100, 0, 82, 79, 150, 15, 0, 4, 0, 0, 95, 97, 108, 112, 104, 97, 0, 7, 0, 0, 0, 0, 79, 150, 23, 0, 7, 0xFF, 0, 0xFF, 0, 7, 1, 0, 0, 0, 4, 0, 0, 98, 101, 103, 105, 110, 70, 105, 108, 108, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 109, 111, 118, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 16, 0, 7, 0, 0, 0, 0, 4, 0, 0, 101, 110, 100, 70, 105, 108, 108, 0, 82, 23];
var _local5:Array = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3];
var _local6:Array = [0, 64, 0, 0, 0];
var _local7:MovieClip = new MovieClip();
var _local8:LocalConnection = new LocalConnection();
var _local9:String = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().time));
_local8 = new LocalConnection();
_local7.lc = _local8;
_local7.click = _arg2;
_local8.client = _local7;
_local8.connect(_local9);
var _local10:ByteArray = new ByteArray();
var _local11:ByteArray = new ByteArray();
_local11.endian = Endian.LITTLE_ENDIAN;
_local11.writeShort(1);
_local11.writeUTFBytes(((_arg1 + " ") + _local9));
_local11.writeByte(0);
var _local12:uint = ((_local3.length + _local11.length) + 4);
var _local13:uint = (_local12 + 35);
_local10.endian = Endian.LITTLE_ENDIAN;
_local10.writeUTFBytes("FWS");
_local10.writeByte(8);
_local10.writeUnsignedInt(_local13);
for each (_local4 in _local5) {
_local10.writeByte(_local4);
};
_local10.writeUnsignedInt(_local12);
_local10.writeByte(136);
_local10.writeShort(_local11.length);
_local10.writeBytes(_local11);
for each (_local4 in _local3) {
_local10.writeByte(_local4);
};
for each (_local4 in _local6) {
_local10.writeByte(_local4);
};
_local14 = new Loader();
_local14.loadBytes(_local10);
_local7.addChild(_local14);
return (_local7);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function addLinkEvent(_arg1:String, _arg2:String, _arg3:DisplayObjectContainer, _arg4:Function=null):void{
var avm1Click:DisplayObject;
var x:String;
var req:URLRequest;
var loader:Loader;
var setURL:Function;
var err:Function;
var complete:Function;
var url = _arg1;
var burl = _arg2;
var btn = _arg3;
var onClick = _arg4;
var vars:Object = new Object();
vars["mav"] = getVersion();
vars["swfv"] = "9";
vars["swfurl"] = btn.loaderInfo.loaderURL;
vars["fv"] = Capabilities.version;
vars["os"] = Capabilities.os;
vars["lang"] = Capabilities.language;
vars["scres"] = ((Capabilities.screenResolutionX + "x") + Capabilities.screenResolutionY);
var s = "?";
var i:Number = 0;
for (x in vars) {
if (i != 0){
s = (s + "&");
};
i = (i + 1);
s = (((s + x) + "=") + escape(vars[x]));
};
req = new URLRequest("http://x.mochiads.com/linkping.swf");
loader = new Loader();
setURL = function (_arg1:String):void{
if (avm1Click){
btn.removeChild(avm1Click);
};
avm1Click = clickMovie(_arg1, onClick);
var _local2:Rectangle = btn.getBounds(btn);
btn.addChild(avm1Click);
avm1Click.x = _local2.x;
avm1Click.y = _local2.y;
avm1Click.scaleX = (0.01 * _local2.width);
avm1Click.scaleY = (0.01 * _local2.height);
};
err = function (_arg1:Object):void{
netup = false;
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
setURL(burl);
};
complete = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
if (netup){
setURL((url + s));
} else {
setURL(burl);
};
if (!((netupAttempted) || (_connected))){
netupAttempted = true;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, err);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.load(req);
};
}
public static function warnID(_arg1:String, _arg2:Boolean):void{
_arg1 = _arg1.toLowerCase();
if (_arg1.length != 16){
trace((("WARNING: " + (_arg2) ? "board" : "game") + " ID is not the appropriate length"));
return;
} else {
if (_arg1 == "1e113c7239048b3f"){
if (_arg2){
trace("WARNING: Using testing board ID");
} else {
trace("WARNING: Using testing board ID as game ID");
};
return;
} else {
if (_arg1 == "84993a1de4031cd8"){
if (_arg2){
trace("WARNING: Using testing game ID as board ID");
} else {
trace("WARNING: Using testing game ID");
};
return;
};
};
};
var _local3:Number = 0;
while (_local3 < _arg1.length) {
switch (_arg1.charAt(_local3)){
case "0":
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
case "a":
case "b":
case "c":
case "d":
case "e":
case "f":
break;
default:
trace(("WARNING: Board ID contains illegal characters: " + _arg1));
return;
};
_local3++;
};
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
try {
_mochiLocalConnection.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
if (Security.sandboxType != "application"){
Security.allowDomain("*");
Security.allowInsecureDomain("*");
};
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
if (Security.sandboxType != "application"){
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
};
return (_local2);
}
public static function getVersion():String{
return ("3.7 as3");
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (((_clip) && (_clip._queue))){
while (_clip._queue.length > 0) {
_local2 = _clip._queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _clip._callbacks[_local2.callbackID];
};
delete _clip._callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
}
public static function get id():String{
return (_id);
}
private static function onEvent(_arg1:Object):void{
var _local2:String = _arg1.target;
var _local3:String = _arg1.event;
switch (_local2){
case "events":
MochiEvents.triggerEvent(_arg1.event, _arg1.args);
break;
case "coins":
MochiCoins.triggerEvent(_arg1.event, _arg1.args);
break;
case "sync":
servicesSync.triggerEvent(_arg1.event, _arg1.args);
break;
};
}
private static function urlOptions(_arg1:Object):Object{
var _local3:String;
var _local4:Array;
var _local5:Number;
var _local6:Array;
var _local2:Object = {};
if (_arg1.stage){
_local3 = _arg1.stage.loaderInfo.parameters.mochiad_options;
} else {
_local3 = _arg1.loaderInfo.parameters.mochiad_options;
};
if (_local3){
_local4 = _local3.split("&");
_local5 = 0;
while (_local5 < _local4.length) {
_local6 = _local4[_local5].split("=");
_local2[unescape(_local6[0])] = unescape(_local6[1]);
_local5++;
};
};
return (_local2);
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_arg1 != null){
if ((_arg1 is Sprite)){
_container = _arg1;
};
};
if (_arg2){
if ((_container is Sprite)){
Sprite(_container).addChild(_clip);
};
};
}
private static function handleError(_arg1:Object, _arg2:Object, _arg3:Object):void{
var args = _arg1;
var callbackObject = _arg2;
var callbackMethod = _arg3;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
if (((!((args.options == null))) && (!((args.options.onError == null))))){
args.options.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
try {
var _local5 = callbackObject;
_local5[callbackMethod](args);
} catch(error:Error) {
};
} else {
if (callbackMethod != null){
try {
callbackMethod.apply(args);
} catch(error:Error) {
};
};
};
};
}
private static function loadError(_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
}
private static function initComChannels():void{
if (!_connected){
trace("[SERVICES_API] connected!");
_connecting = false;
_connected = true;
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"registerGame", preserved:_preserved, id:_id, version:getVersion(), parentURL:_container.loaderInfo.loaderURL});
_clip.onReceive = onReceive;
_clip.onEvent = onEvent;
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
while (_clip._queue.length > 0) {
_mochiLocalConnection.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function loadLCBridge(_arg1:Object):void{
var loader:Loader;
var clip = _arg1;
loader = new Loader();
var mochiLCURL:String = (_servURL + _mochiLC);
var req:URLRequest = new URLRequest(mochiLCURL);
var complete:Function = function (_arg1:Object):void{
_mochiLocalConnection = MovieClip(loader.content);
listen();
};
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
loader.load(req);
clip.addChild(loader);
}
private static function listen():void{
_mochiLocalConnection.connect(_listenChannelName);
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
trace("Waiting for MochiAds services to connect...");
}
public static function get clip():Object{
return (_container);
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
var _local3:String = ("_mochiservices_com_" + _arg1);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(_arg2).servURL){
_servURL = urlOptions(_arg2).servURL;
};
var _local4:String = (_servURL + _services);
if (urlOptions(_arg2).servicesURL){
_local4 = urlOptions(_arg2).servicesURL;
};
_listenChannelName = (_listenChannelName + ((Math.floor(new Date().time) + "_") + Math.floor((Math.random() * 99999))));
MochiServices.allowDomains(_local4);
_clip = createEmptyMovieClip(_arg2, _local3, 10336, false);
loadLCBridge(_clip);
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
var _local5:URLRequest = new URLRequest(_local4);
var _local6:URLVariables = new URLVariables();
_local6.listenLC = _listenChannelName;
_local6.mochiad_options = _arg2.loaderInfo.parameters.mochiad_options;
_local6.api_version = getVersion();
if (widget){
_local6.widget = true;
};
_local5.data = _local6;
_loader.load(_local5);
_clip.addChild(_loader);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_clip._nextcallbackID = 0;
_clip._callbacks = {};
_timer = new Timer(10000, 1);
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
return (_clip);
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
warnID(id, false);
if ((clip is DisplayObject)){
if (clip.stage == null){
trace("MochiServices connect requires the containing clip be attached to the stage");
};
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number, _arg4:Boolean=true):MovieClip{
var parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
var mc:MovieClip = new MovieClip();
if (doAdd){
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
};
try {
parent[name] = mc;
} catch(e:Error) {
throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
mc["_name"] = name;
return (mc);
}
public static function bringToTop(_arg1:Event=null):void{
var e = _arg1;
if (((!((MochiServices.clip == null))) && (!((MochiServices.childClip == null))))){
try {
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
} catch(errorObject:Error) {
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
};
}
public static function connectWait(_arg1:TimerEvent):void{
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load. (timeout)");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
}
}
}//package mochi.as3
Section 78
//MochiSocial (mochi.as3.MochiSocial)
package mochi.as3 {
public class MochiSocial {
public static const LOGGED_IN:String = "LoggedIn";
public static const PROFILE_HIDE:String = "ProfileHide";
public static const NO_USER:String = "NoUser";
public static const PROPERTIES_SIZE:String = "PropertiesSize";
public static const IO_ERROR:String = "IOError";
public static const PROPERTIES_SAVED:String = "PropertySaved";
public static const WIDGET_LOADED:String = "WidgetLoaded";
public static const USER_INFO:String = "UserInfo";
public static const ERROR:String = "Error";
public static const LOGIN_SHOW:String = "LoginShow";
public static const LOGGED_OUT:String = "LoggedOut";
public static const PROFILE_SHOW:String = "ProfileShow";
public static const LOGIN_SHOWN:String = "LoginShown";
public static const LOGIN_HIDE:String = "LoginHide";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public static var _user_info:Object = null;
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function saveUserProperties(_arg1:Object):void{
MochiServices.send("coins_saveUserProperties", _arg1);
}
public static function get loggedIn():Boolean{
return (!((_user_info == null)));
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function getUserInfo():void{
MochiServices.send("coins_getUserInfo");
}
public static function showLoginWidget(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showLoginWidget", {options:_arg1});
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function requestLogin():void{
MochiServices.send("coins_requestLogin");
}
public static function getAPIURL():String{
if (!_user_info){
return (null);
};
return (_user_info.api_url);
}
public static function hideLoginWidget():void{
MochiServices.send("coins_hideLoginWidget");
}
public static function getAPIToken():String{
if (!_user_info){
return (null);
};
return (_user_info.api_token);
}
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, function (_arg1:Object):void{
_user_info = _arg1;
});
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, function (_arg1:Object):void{
_user_info = null;
});
}
}//package mochi.as3
Section 79
//MochiSync (mochi.as3.MochiSync)
package mochi.as3 {
import flash.utils.*;
public dynamic class MochiSync extends Proxy {
private var _syncContainer:Object;
public static var SYNC_PROPERTY:String = "UpdateProperty";
public static var SYNC_REQUEST:String = "SyncRequest";
public function MochiSync():void{
_syncContainer = {};
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
if (_syncContainer[_arg1] == _arg2){
return;
};
var _local3:String = _arg1.toString();
_syncContainer[_local3] = _arg2;
MochiServices.send("sync_propUpdate", {name:_local3, value:_arg2});
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
return (_syncContainer[_arg1]);
}
public function triggerEvent(_arg1:String, _arg2:Object):void{
switch (_arg1){
case SYNC_REQUEST:
MochiServices.send("sync_syncronize", _syncContainer);
break;
case SYNC_PROPERTY:
_syncContainer[_arg2.name] = _arg2.value;
break;
};
}
}
}//package mochi.as3
Section 80
//MochiUserData (mochi.as3.MochiUserData)
package mochi.as3 {
import flash.events.*;
import flash.utils.*;
import flash.net.*;
public class MochiUserData extends EventDispatcher {
public var callback:Function;// = null
public var operation:String;// = null
public var error:Event;// = null
public var data;// = null
public var _loader:URLLoader;
public var key:String;// = null
public function MochiUserData(_arg1:String="", _arg2:Function=null){
this.key = _arg1;
this.callback = _arg2;
}
public function serialize(_arg1):ByteArray{
var _local2:ByteArray = new ByteArray();
_local2.objectEncoding = ObjectEncoding.AMF3;
_local2.writeObject(_arg1);
_local2.compress();
return (_local2);
}
public function errorHandler(_arg1:IOErrorEvent):void{
data = null;
error = _arg1;
if (callback != null){
performCallback();
} else {
dispatchEvent(_arg1);
};
close();
}
public function putEvent(_arg1):void{
request("put", serialize(_arg1));
}
public function deserialize(_arg1:ByteArray){
_arg1.objectEncoding = ObjectEncoding.AMF3;
_arg1.uncompress();
return (_arg1.readObject());
}
public function securityErrorHandler(_arg1:SecurityErrorEvent):void{
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + _arg1.toString())));
}
public function getEvent():void{
request("get", serialize(null));
}
override public function toString():String{
return ((((((((("[MochiUserData operation=" + operation) + " key=\"") + key) + "\" data=") + data) + " error=\"") + error) + "\"]"));
}
public function performCallback():void{
try {
callback(this);
} catch(e:Error) {
trace(("[MochiUserData] exception during callback: " + e));
};
}
public function request(_arg1:String, _arg2:ByteArray):void{
var _operation = _arg1;
var _data = _arg2;
operation = _operation;
var api_url:String = MochiSocial.getAPIURL();
var api_token:String = MochiSocial.getAPIToken();
if ((((api_url == null)) || ((api_token == null)))){
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, "not logged in"));
return;
};
_loader = new URLLoader();
var args:URLVariables = new URLVariables();
args.op = _operation;
args.key = key;
var req:URLRequest = new URLRequest((((MochiSocial.getAPIURL() + "/") + "MochiUserData?") + args.toString()));
req.method = URLRequestMethod.POST;
req.contentType = "application/x-mochi-userdata";
req.requestHeaders = [new URLRequestHeader("x-mochi-services-version", MochiServices.getVersion()), new URLRequestHeader("x-mochi-api-token", api_token)];
req.data = _data;
_loader.dataFormat = URLLoaderDataFormat.BINARY;
_loader.addEventListener(Event.COMPLETE, completeHandler);
_loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
_loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
try {
_loader.load(req);
} catch(e:SecurityError) {
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + e.toString())));
};
}
public function completeHandler(_arg1:Event):void{
var event = _arg1;
try {
if (_loader.data.length){
data = deserialize(_loader.data);
} else {
data = null;
};
} catch(e:Error) {
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("deserialize error: " + e.toString())));
return;
};
if (callback != null){
performCallback();
} else {
dispatchEvent(event);
};
close();
}
public function close():void{
if (_loader){
_loader.removeEventListener(Event.COMPLETE, completeHandler);
_loader.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler);
_loader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
_loader.close();
_loader = null;
};
error = null;
callback = null;
}
public static function get(_arg1:String, _arg2:Function):void{
var _local3:MochiUserData = new MochiUserData(_arg1, _arg2);
_local3.getEvent();
}
public static function put(_arg1:String, _arg2, _arg3:Function):void{
var _local4:MochiUserData = new MochiUserData(_arg1, _arg3);
_local4.putEvent(_arg2);
}
}
}//package mochi.as3
Section 81
//Background (Background)
package {
import flash.display.*;
public dynamic class Background extends MovieClip {
}
}//package