Section 1
//Game (com.novelgames.flashgames.common.Game)
package com.novelgames.flashgames.common {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.ui.*;
public class Game extends MovieClip {
private var mouseHidden:Boolean;
public static var gameStage:Stage;
public static var main:MovieClip;
public function pause():void{
NewTimer.pause();
gameStage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyEventDuringPause, false, 2147483647);
gameStage.addEventListener(KeyboardEvent.KEY_UP, onKeyEventDuringPause, false, 2147483647);
this.mouseEnabled = false;
this.mouseChildren = false;
if (mouseHidden){
Mouse.show();
};
if (Sprite.prototype.draggingSprite){
Sprite.prototype.draggingSprite.stopDrag();
};
}
public function unpause():void{
NewTimer.unpause();
gameStage.focus = gameStage;
gameStage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyEventDuringPause);
gameStage.removeEventListener(KeyboardEvent.KEY_UP, onKeyEventDuringPause);
this.mouseEnabled = true;
this.mouseChildren = true;
if (mouseHidden){
Mouse.hide();
};
if (Sprite.prototype.draggingSprite){
Sprite.prototype.draggingSprite.x = (Sprite.prototype.draggingSprite.x + (Sprite.prototype.draggingSprite.mouseX - Sprite.prototype.draggingSpriteMouseX));
Sprite.prototype.draggingSprite.y = (Sprite.prototype.draggingSprite.y + (Sprite.prototype.draggingSprite.mouseY - Sprite.prototype.draggingSpriteMouseY));
Sprite.prototype.draggingSprite.startDrag(Sprite.prototype.draggingSpriteLockCenter, Sprite.prototype.draggingSpriteBounds);
};
}
public function hideMouse():void{
mouseHidden = true;
Mouse.hide();
}
public function showMouse():void{
mouseHidden = false;
Mouse.show();
}
public function onRightMouseDown():void{
var _local1:DisplayObject = getMouseTarget();
if (!_local1){
return;
};
_local1.dispatchEvent(new MouseEvent("mouseRightDown"));
}
public function onRightMouseUp():void{
var _local1:DisplayObject = getMouseTarget();
if (!_local1){
return;
};
_local1.dispatchEvent(new MouseEvent("mouseRightUp"));
}
public function onMiddleMouseDown():void{
var _local1:DisplayObject = getMouseTarget();
if (!_local1){
return;
};
_local1.dispatchEvent(new MouseEvent("mouseMiddleDown"));
}
public function onMiddleMouseUp():void{
var _local1:DisplayObject = getMouseTarget();
if (!_local1){
return;
};
_local1.dispatchEvent(new MouseEvent("mouseMiddleUp"));
}
private function getMouseTarget():DisplayObject{
var _local3:int;
var _local1:Point = this.localToGlobal(new Point(mouseX, mouseY));
var _local2:Array = this.getObjectsUnderPoint(_local1);
_local3 = (_local2.length - 1);
while (_local3 >= 0) {
if (!_local2[_local3].parent.mouseEnabled){
} else {
if (((_local2[_local3].parent.parent) && (!(_local2[_local3].parent.parent.mouseChildren)))){
} else {
return (_local2[_local3]);
};
};
_local3--;
};
return (null);
}
private function onKeyEventDuringPause(_arg1:KeyboardEvent):void{
_arg1.stopImmediatePropagation();
}
}
}//package com.novelgames.flashgames.common
Section 2
//Instructions (com.novelgames.flashgames.common.Instructions)
package com.novelgames.flashgames.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=false){
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 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 nextPageButtonClicked(_arg1:MouseEvent):void{
nextFrame();
this["nextPageButton"].visible = !((currentFrame == totalFrames));
this["previousPageButton"].visible = !((currentFrame == 1));
}
private function previousPageButtonClicked(_arg1:MouseEvent):void{
prevFrame();
this["nextPageButton"].visible = !((currentFrame == totalFrames));
this["previousPageButton"].visible = !((currentFrame == 1));
}
}
}//package com.novelgames.flashgames.common
Section 3
//InstructionsButton (com.novelgames.flashgames.common.InstructionsButton)
package com.novelgames.flashgames.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.flashgames.common
Section 4
//MainDevelopment (com.novelgames.flashgames.common.MainDevelopment)
package com.novelgames.flashgames.common {
import flash.display.*;
import flash.events.*;
import mochi.as3.*;
import flash.media.*;
import flash.geom.*;
import flash.net.*;
import flash.external.*;
public class MainDevelopment extends MovieClip {
private var title:Title;
private var instructions:Instructions;
private var game:Game;
private var optionsDialog:OptionsDialog;
private var musicGame:Sound;
private var musicGameSoundChannel:SoundChannel;
public var buttonSoundOver:Sound;
public var buttonSoundClick:Sound;
private var titleX:Number;
private var titleY:Number;
private var titleIndex:int;
public function MainDevelopment(){
super();
if (!checkSiteLock()){
return;
};
try {
ExternalInterface.addCallback("onRightMouseDown", onRightMouseDown);
ExternalInterface.addCallback("onRightMouseUp", onRightMouseUp);
ExternalInterface.addCallback("onMiddleMouseDown", onMiddleMouseDown);
ExternalInterface.addCallback("onMiddleMouseUp", onMiddleMouseUp);
} catch(e) {
};
Sprite.prototype.startDragNew = function (_arg1:Boolean=false, _arg2:Rectangle=null):void{
Sprite.prototype.draggingSprite = this;
Sprite.prototype.draggingSpriteLockCenter = _arg1;
Sprite.prototype.draggingSpriteBounds = _arg2;
Sprite.prototype.draggingSpriteMouseX = this.mouseX;
Sprite.prototype.draggingSpriteMouseY = this.mouseY;
this.startDrag(_arg1, _arg2);
};
Sprite.prototype.stopDragNew = function ():void{
Sprite.prototype.draggingSprite = null;
this.stopDrag();
};
this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
this.addEventListener(Event.ENTER_FRAME, checkTitle);
checkTitle();
}
public function gotoTitlePage():void{
removePage();
title = new Title();
title.x = titleX;
title.y = titleY;
this.addChildAt(title, titleIndex);
}
public function gotoInstructionsPage():void{
removePage();
instructions = new Instructions();
instructions.x = titleX;
instructions.y = titleY;
this.addChildAt(instructions, titleIndex);
}
public function gotoGamePage():void{
Game.gameStage = stage;
Game.main = this;
removePage();
musicGame = getMusicGame();
musicGameSoundChannel = musicGame.play(0, int.MAX_VALUE);
game = getGame();
game.x = titleX;
game.y = titleY;
this.addChildAt(game, titleIndex);
}
public function showInstructionsFromGame():void{
game.pause();
game.visible = false;
instructions = new Instructions(true);
instructions.x = titleX;
instructions.y = titleY;
this.addChildAt(instructions, (titleIndex + 1));
}
public function hideInstructionsFromGame():void{
this.removeChild(instructions);
instructions = null;
game.visible = true;
game.unpause();
}
public function showOptions():void{
game.pause();
optionsDialog = new OptionsDialog();
optionsDialog.x = titleX;
optionsDialog.y = titleY;
this.addChildAt(optionsDialog, (titleIndex + 1));
}
public function hideOptions():void{
game.unpause();
this.removeChild(optionsDialog);
optionsDialog = null;
}
public function startGameMusic():void{
stopGameMusic();
musicGame = getMusicGame();
musicGameSoundChannel = musicGame.play(0, int.MAX_VALUE);
}
public function stopGameMusic():void{
if (musicGame){
musicGameSoundChannel.stop();
musicGame = null;
musicGameSoundChannel = null;
};
}
public function showHighScores():void{
var o:Object = {n:[8, 14, 5, 3, 5, 9, 13, 9, 13, 12, 6, 9, 14, 2, 3, 11], f:function (_arg1:Number, _arg2:String):String{
if (_arg2.length == 16){
return (_arg2);
};
return (this.f((_arg1 + 1), (_arg2 + this.n[_arg1].toString(16))));
}};
var boardID:String = o.f(0, "");
MochiScores.showLeaderboard({onClose:function (){
nextFrame();
}, boardID:boardID});
}
public function showEnterHighScore(_arg1:int):void{
var score = _arg1;
var o:Object = {n:[8, 14, 5, 3, 5, 9, 13, 9, 13, 12, 6, 9, 14, 2, 3, 11], f:function (_arg1:Number, _arg2:String):String{
if (_arg2.length == 16){
return (_arg2);
};
return (this.f((_arg1 + 1), (_arg2 + this.n[_arg1].toString(16))));
}};
var boardID:String = o.f(0, "");
MochiScores.showLeaderboard({onClose:function (){
nextFrame();
}, boardID:boardID, score:score});
}
public function gameEnded(_arg1:Object):void{
var _local3:String;
var _local2:Array = new Array();
for (_local3 in _arg1) {
_local2.push(((_local3 + ": ") + _arg1[_local3]));
};
trace((("gameEnded({" + _local2.join(", ")) + "})"));
showEnterHighScore(_arg1["score"]);
}
public function gotoMoreGamesURL():void{
navigateToURL(new URLRequest("http://www.2dfootballgames.com"), "_blank");
}
public function onRightMouseDown():void{
if (game){
game.onRightMouseDown();
};
}
public function onRightMouseUp():void{
if (game){
game.onRightMouseUp();
};
}
public function onMiddleMouseDown():void{
if (game){
game.onMiddleMouseDown();
};
}
public function onMiddleMouseUp():void{
if (game){
game.onMiddleMouseUp();
};
}
protected function getTitle():Title{
return (null);
}
protected function getGame():Game{
return (null);
}
protected function getMusicGame():Sound{
return (null);
}
protected function getButtonSoundOver():Sound{
return (null);
}
protected function getButtonSoundClick():Sound{
return (null);
}
private function onAddedToStage(_arg1:Event):void{
this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
stage.stageFocusRect = false;
}
private function checkTitle(_arg1:Event=null):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 removePage():void{
if (title){
removeChild(title);
title = null;
};
if (instructions){
removeChild(instructions);
instructions = null;
};
if (game){
removeChild(game);
game = null;
};
if (musicGame){
musicGameSoundChannel.stop();
musicGame = null;
musicGameSoundChannel = null;
};
}
private function checkSiteLock():Boolean{
var _local2:int;
var _local1:Array = [];
if (_local1.length == 0){
return (true);
};
_local2 = 0;
while (_local2 < _local1.length) {
if (getURLMatchesWebsite(_local1[_local2])){
return (true);
};
_local2++;
};
this.stop();
this.visible = false;
parent.removeChild(this);
return (false);
}
private function getURLMatchesWebsite(_arg1:String):Boolean{
var _local2:String;
var _local3:String;
if (loaderInfo == null){
return (false);
};
if (loaderInfo.url == null){
return (false);
};
_local2 = loaderInfo.url;
_local3 = getHostFromURL(_local2);
if (!getHostMatchesWebsite(_local3, _arg1)){
return (false);
};
_local2 = ExternalInterface.call("function() { return document.location.href; }");
if (_local2 != null){
_local3 = getHostFromURL(_local2);
if (!getHostMatchesWebsite(_local3, _arg1)){
return (false);
};
};
return (true);
}
private function getHostFromURL(_arg1:String):String{
var _local2:int;
var _local3:int;
_local2 = _arg1.indexOf("://");
if (_local2 == -1){
return (null);
};
_local2 = (_local2 + 3);
_local3 = _arg1.indexOf("/", _local2);
if (_local3 == -1){
_local3 = _arg1.length;
};
return (_arg1.substr(_local2, (_local3 - _local2)));
}
private function getHostMatchesWebsite(_arg1:String, _arg2:String):Boolean{
var _local3:String;
if ((((_arg1 == null)) || ((_arg2 == null)))){
return (false);
};
_arg1 = _arg1.toLowerCase();
_arg2 = _arg2.toLowerCase();
if (_arg1 == _arg2){
return (true);
};
if (_arg2.charAt(0) == "*"){
_local3 = _arg2.substr(1);
if ((((_arg1.length >= _local3.length)) && ((_arg1.substr((_arg1.length - _local3.length)) == _local3)))){
return (true);
};
};
return (false);
}
}
}//package com.novelgames.flashgames.common
Section 5
//NewMusic (com.novelgames.flashgames.common.NewMusic)
package com.novelgames.flashgames.common {
import flash.media.*;
import flash.net.*;
public class NewMusic extends Sound {
public static var volume:Number = loadVolume();
private static var allSoundChannels:Array = new Array();
override public function play(_arg1:Number=0, _arg2:int=0, _arg3:SoundTransform=null):SoundChannel{
var _local4:SoundChannel = super.play(_arg1, _arg2, new SoundTransform(volume));
allSoundChannels.push(_local4);
return (_local4);
}
private static function loadVolume():Number{
var _local1:SharedObject = SharedObject.getLocal("gameOptions", "/");
_local1.objectEncoding = ObjectEncoding.AMF0;
if (isNaN(_local1.data.musicVolume)){
_local1.data.musicVolume = 1;
};
return (_local1.data.musicVolume);
}
public static function saveVolume():void{
var _local1:SharedObject = SharedObject.getLocal("gameOptions", "/");
_local1.objectEncoding = ObjectEncoding.AMF0;
_local1.data.musicVolume = volume;
}
public static function setVolume(_arg1:Number):void{
var _local2:int;
NewMusic.volume = _arg1;
_local2 = 0;
while (_local2 < allSoundChannels.length) {
allSoundChannels[_local2].soundTransform = new SoundTransform(_arg1);
_local2++;
};
}
}
}//package com.novelgames.flashgames.common
Section 6
//NewSound (com.novelgames.flashgames.common.NewSound)
package com.novelgames.flashgames.common {
import flash.media.*;
import flash.net.*;
public class NewSound extends Sound {
public static var volume:Number = loadVolume();
private static var allSoundChannels:Array = new Array();
override public function play(_arg1:Number=0, _arg2:int=0, _arg3:SoundTransform=null):SoundChannel{
var _local4:SoundChannel = super.play(_arg1, _arg2, new SoundTransform(volume));
allSoundChannels.push(_local4);
return (_local4);
}
private static function loadVolume():Number{
var _local1:SharedObject = SharedObject.getLocal("gameOptions", "/");
_local1.objectEncoding = ObjectEncoding.AMF0;
if (isNaN(_local1.data.soundVolume)){
_local1.data.soundVolume = 1;
};
return (_local1.data.soundVolume);
}
public static function saveVolume():void{
var _local1:SharedObject = SharedObject.getLocal("gameOptions", "/");
_local1.objectEncoding = ObjectEncoding.AMF0;
_local1.data.soundVolume = volume;
}
public static function setVolume(_arg1:Number):void{
var _local2:int;
NewSound.volume = _arg1;
_local2 = 0;
while (_local2 < allSoundChannels.length) {
allSoundChannels[_local2].soundTransform = new SoundTransform(_arg1);
_local2++;
};
}
}
}//package com.novelgames.flashgames.common
Section 7
//NewTimer (com.novelgames.flashgames.common.NewTimer)
package com.novelgames.flashgames.common {
import flash.events.*;
import flash.utils.*;
public class NewTimer extends Timer {
private var originalDelay:Number;
private var listener:Function;
private var timerFactory:TimerFactory;
private var isRunning:Boolean;
private var adjustedLastEventTime:Number;
private var currentDelay:Number;
public function NewTimer(_arg1:Number, _arg2:int=0, _arg3:TimerFactory=null):void{
if (_arg3 == null){
_arg3 = TimerFactory.globalTimerFactory;
};
super(((_arg3.realSpeed == 0)) ? 2147483647 : (_arg1 / _arg3.realSpeed), _arg2);
originalDelay = _arg1;
currentDelay = originalDelay;
_arg3.addTimer(this);
this.timerFactory = _arg3;
isRunning = false;
}
override public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
this.listener = _arg2;
super.addEventListener(_arg1, timerEventListener, _arg3, _arg4, _arg5);
}
override public function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{
super.removeEventListener(_arg1, timerEventListener, _arg3);
if (_arg2 == this.listener){
this.listener = null;
};
}
override public function start():void{
adjustedLastEventTime = timerFactory.getTime();
if (timerFactory.realSpeed == 0){
return;
};
super.start();
isRunning = true;
}
override public function stop():void{
super.stop();
isRunning = false;
}
public function speedUpdated():void{
var _local1:Number;
if (listener == null){
return;
};
if (!isRunning){
return;
};
super.stop();
_local1 = timerFactory.getTime();
currentDelay = (originalDelay - (_local1 - adjustedLastEventTime));
if (currentDelay <= 0){
currentDelay = originalDelay;
};
if (timerFactory.realSpeed == 0){
return;
};
delay = (currentDelay / timerFactory.realSpeed);
super.start();
}
private function timerEventListener(_arg1:TimerEvent):void{
if (_arg1.type != TimerEvent.TIMER){
return;
};
adjustedLastEventTime = timerFactory.getTime();
listener(_arg1);
if (!isRunning){
return;
};
if (((!((repeatCount == 0))) && ((currentCount >= repeatCount)))){
isRunning = false;
return;
};
if (currentDelay != originalDelay){
super.stop();
currentDelay = originalDelay;
delay = (currentDelay / timerFactory.realSpeed);
super.start();
};
}
public static function getTimer():int{
return (TimerFactory.globalTimerFactory.getTime());
}
public static function pause():void{
TimerFactory.globalTimerFactory.pause();
}
public static function unpause():void{
TimerFactory.globalTimerFactory.unpause();
}
}
}//package com.novelgames.flashgames.common
Section 8
//ObfuscatedNumber (com.novelgames.flashgames.common.ObfuscatedNumber)
package com.novelgames.flashgames.common {
public class ObfuscatedNumber {
private var values:Array;
public function ObfuscatedNumber(){
this.value = 0;
}
public function set value(_arg1:Number):void{
var _local4:int;
var _local5:int;
var _local2:int = (2 + Math.floor((Math.random() * 9)));
var _local3:Number = _arg1;
values = new Array();
_local5 = 0;
while (_local5 < (_local2 - 1)) {
_local4 = ((-10000 + _arg1) + Math.floor((Math.random() * 20000)));
_local3 = (_local3 - _local4);
values.push(_local4);
_local5++;
};
values.push(_local3);
}
public function get value():Number{
var _local2:int;
var _local1:Number = 0;
_local2 = 0;
while (_local2 < values.length) {
_local1 = (_local1 + values[_local2]);
_local2++;
};
return (_local1);
}
public function toString():String{
return (this.value.toString());
}
}
}//package com.novelgames.flashgames.common
Section 9
//OptionsButton (com.novelgames.flashgames.common.OptionsButton)
package com.novelgames.flashgames.common {
import flash.display.*;
import flash.events.*;
public class OptionsButton extends MovieClip {
public function OptionsButton(){
super();
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, function ():void{
Object(parent.parent).showOptions();
});
}
}
}//package com.novelgames.flashgames.common
Section 10
//OptionsDialog (com.novelgames.flashgames.common.OptionsDialog)
package com.novelgames.flashgames.common {
import flash.display.*;
import flash.events.*;
public class OptionsDialog extends MovieClip {
public var okButton:SimpleButton;
public var sound:MovieClip;
public var fullScreen:MovieClip;
public var music:MovieClip;
public var separator0:MovieClip;
public var separator1:MovieClip;
private var soundOnX:Number;
private var soundOnY:Number;
private var soundOffX:Number;
private var soundOffY:Number;
private var musicOnX:Number;
private var musicOnY:Number;
private var musicOffX:Number;
private var musicOffY:Number;
private var soundSlider:MovieClip;
private var musicSlider:MovieClip;
public function OptionsDialog(){
this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onAddedToStage(_arg1:Event):void{
soundOnX = sound.onSlider.x;
soundOnY = sound.onSlider.y;
soundOffX = sound.offSlider.x;
soundOffY = sound.offSlider.y;
musicOnX = music.onSlider.x;
musicOnY = music.onSlider.y;
musicOffX = music.offSlider.x;
musicOffY = music.offSlider.y;
sound.offSlider.visible = false;
soundSlider = sound.onSlider;
music.offSlider.visible = false;
musicSlider = music.onSlider;
updateSoundSlider(NewSound.volume);
updateMusicSlider(NewMusic.volume);
soundSlider.addEventListener(MouseEvent.MOUSE_DOWN, onSoundSliderMouseDown);
soundSlider.buttonMode = true;
musicSlider.addEventListener(MouseEvent.MOUSE_DOWN, onMusicSliderMouseDown);
musicSlider.buttonMode = true;
okButton.addEventListener(MouseEvent.CLICK, okButtonClicked);
updateFullScreenButtons();
}
private function updateSoundSlider(_arg1:Number):void{
soundSlider.x = ((soundOnX * _arg1) + (soundOffX * (1 - _arg1)));
soundSlider.y = ((soundOnY * _arg1) + (soundOffY * (1 - _arg1)));
}
private function updateMusicSlider(_arg1:Number):void{
musicSlider.x = ((musicOnX * _arg1) + (musicOffX * (1 - _arg1)));
musicSlider.y = ((musicOnY * _arg1) + (musicOffY * (1 - _arg1)));
}
private function onSoundSliderMouseDown(_arg1:MouseEvent):void{
soundSlider.removeEventListener(MouseEvent.MOUSE_DOWN, onSoundSliderMouseDown);
this.addEventListener(MouseEvent.MOUSE_MOVE, onSoundSliderMouseMove);
this.addEventListener(MouseEvent.MOUSE_UP, onSoundSliderMouseUp);
}
private function onSoundSliderMouseMove(_arg1:MouseEvent):void{
var _local2:Number;
_arg1.updateAfterEvent();
_local2 = ((sound.mouseX - soundOffX) / (soundOnX - soundOffX));
if (_local2 < 0){
_local2 = 0;
};
if (_local2 > 1){
_local2 = 1;
};
updateSoundSlider(_local2);
NewSound.setVolume(_local2);
}
private function onSoundSliderMouseUp(_arg1:MouseEvent):void{
this.removeEventListener(MouseEvent.MOUSE_MOVE, onSoundSliderMouseMove);
this.removeEventListener(MouseEvent.MOUSE_UP, onSoundSliderMouseUp);
soundSlider.addEventListener(MouseEvent.MOUSE_DOWN, onSoundSliderMouseDown);
}
private function onMusicSliderMouseDown(_arg1:MouseEvent):void{
musicSlider.removeEventListener(MouseEvent.MOUSE_DOWN, onMusicSliderMouseDown);
this.addEventListener(MouseEvent.MOUSE_MOVE, onMusicSliderMouseMove);
this.addEventListener(MouseEvent.MOUSE_UP, onMusicSliderMouseUp);
}
private function onMusicSliderMouseMove(_arg1:MouseEvent):void{
var _local2:Number;
_arg1.updateAfterEvent();
_local2 = ((music.mouseX - musicOffX) / (soundOnX - musicOffX));
if (_local2 < 0){
_local2 = 0;
};
if (_local2 > 1){
_local2 = 1;
};
updateMusicSlider(_local2);
NewMusic.setVolume(_local2);
}
private function onMusicSliderMouseUp(_arg1:MouseEvent):void{
this.removeEventListener(MouseEvent.MOUSE_MOVE, onMusicSliderMouseMove);
this.removeEventListener(MouseEvent.MOUSE_UP, onMusicSliderMouseUp);
musicSlider.addEventListener(MouseEvent.MOUSE_DOWN, onMusicSliderMouseDown);
}
private function okButtonClicked(_arg1:MouseEvent):void{
NewSound.saveVolume();
NewMusic.saveVolume();
Object(parent).hideOptions();
}
private function updateFullScreenButtons():void{
if (stage.displayState == StageDisplayState.FULL_SCREEN){
fullScreen.onButton.gotoAndStop("on");
fullScreen.onButton.removeEventListener(MouseEvent.CLICK, onFullScreenOnClicked);
fullScreen.onButton.buttonMode = false;
fullScreen.offButton.gotoAndStop("off");
fullScreen.offButton.addEventListener(MouseEvent.CLICK, onFullScreenOffClicked);
fullScreen.offButton.buttonMode = true;
} else {
fullScreen.onButton.gotoAndStop("off");
fullScreen.onButton.addEventListener(MouseEvent.CLICK, onFullScreenOnClicked);
fullScreen.onButton.buttonMode = true;
fullScreen.offButton.gotoAndStop("on");
fullScreen.offButton.removeEventListener(MouseEvent.CLICK, onFullScreenOffClicked);
fullScreen.offButton.buttonMode = false;
};
}
private function onFullScreenOnClicked(_arg1:MouseEvent):void{
stage.displayState = StageDisplayState.FULL_SCREEN;
updateFullScreenButtons();
}
private function onFullScreenOffClicked(_arg1:MouseEvent):void{
stage.displayState = StageDisplayState.NORMAL;
updateFullScreenButtons();
}
}
}//package com.novelgames.flashgames.common
Section 11
//SimpleTimer (com.novelgames.flashgames.common.SimpleTimer)
package com.novelgames.flashgames.common {
import flash.events.*;
import flash.utils.*;
public class SimpleTimer {
public var delay:Number;
public var repeatCount:int;
public var duration:int;
public var listener:Function;
public var count:int;
public var startTime:int;
public var lastTime:int;
public var timer:Timer;
public var dTime:int;
public var time:int;
public var ratio:Number;
public function SimpleTimer(_arg1:Number, _arg2:int, _arg3:int, _arg4:Function){
this.delay = _arg1;
this.repeatCount = _arg2;
this.duration = _arg3;
this.listener = _arg4;
count = 0;
startTime = NewTimer.getTimer();
lastTime = startTime;
time = startTime;
dTime = (time - startTime);
ratio = 0;
timer = new NewTimer(_arg1, _arg2);
timer.addEventListener(TimerEvent.TIMER, onTime);
timer.start();
}
public function stop():void{
timer.stop();
timer.removeEventListener(TimerEvent.TIMER, onTime);
}
private function onTime(_arg1:TimerEvent):void{
_arg1.updateAfterEvent();
time = NewTimer.getTimer();
dTime = (time - startTime);
if (duration != 0){
ratio = (dTime / duration);
if (ratio >= 1){
ratio = 1;
stop();
};
};
listener(this);
lastTime = time;
count++;
if ((((repeatCount > 0)) && ((count >= repeatCount)))){
stop();
};
}
}
}//package com.novelgames.flashgames.common
Section 12
//TimerFactory (com.novelgames.flashgames.common.TimerFactory)
package com.novelgames.flashgames.common {
import flash.events.*;
import flash.utils.*;
public class TimerFactory {
private var parent:TimerFactory;
private var __speed:Number;
private var __realSpeed:Number;
private var lastSpeedChangeAdjustedTime:Number;
private var lastSpeedChangeRealTime:Number;
private var children:Array;
private var timers:Array;
private static var __globalTimerFactory:TimerFactory = new (TimerFactory);
;
public function TimerFactory(){
parent = null;
__speed = 1;
__realSpeed = 1;
lastSpeedChangeAdjustedTime = getTimer();
lastSpeedChangeRealTime = lastSpeedChangeAdjustedTime;
children = new Array();
timers = new Array();
}
public function createTimerFactory():TimerFactory{
var _local1:TimerFactory = new TimerFactory();
_local1.parent = this;
_local1.lastSpeedChangeAdjustedTime = getTime();
_local1.updateRealSpeed();
children.push(_local1);
return (_local1);
}
public function createTimer(_arg1:Number, _arg2:int=0):NewTimer{
return (new NewTimer(_arg1, _arg2, this));
}
public function addTimer(_arg1:NewTimer):void{
timers.push(_arg1);
}
public function getTime():Number{
return ((lastSpeedChangeAdjustedTime + (realSpeed * (getTimer() - lastSpeedChangeRealTime))));
}
public function pause():void{
speed = 0;
}
public function unpause():void{
speed = 1;
}
public function set speed(_arg1:Number):void{
if (_arg1 < 0){
_arg1 = 0;
};
__speed = _arg1;
updateRealSpeed();
}
public function get speed():Number{
return (__speed);
}
public function get realSpeed():Number{
return (__realSpeed);
}
public function updateRealSpeed():void{
var _local1:int;
if (__realSpeed == (getParentSpeed() * speed)){
return;
};
lastSpeedChangeAdjustedTime = getTime();
lastSpeedChangeRealTime = getTimer();
__realSpeed = (getParentSpeed() * speed);
_local1 = 0;
while (_local1 < timers.length) {
timers[_local1].speedUpdated();
_local1++;
};
_local1 = 0;
while (_local1 < children.length) {
children[_local1].updateRealSpeed();
_local1++;
};
}
private function getParentSpeed():Number{
if (parent){
return (parent.speed);
};
return (1);
}
public static function get globalTimerFactory():TimerFactory{
return (__globalTimerFactory);
}
}
}//package com.novelgames.flashgames.common
Section 13
//Title (com.novelgames.flashgames.common.Title)
package com.novelgames.flashgames.common {
import flash.display.*;
import flash.events.*;
public class Title extends MovieClip {
public var Football2dbutton:SimpleButton;
public var moreGamesButton:SimpleButton;
public var startButton:SimpleButton;
public var highScoresButton:SimpleButton;
public function Title(){
startButton.addEventListener(MouseEvent.ROLL_OVER, startButtonOvered);
startButton.addEventListener(MouseEvent.CLICK, startButtonClicked);
highScoresButton.addEventListener(MouseEvent.ROLL_OVER, highScoresButtonOvered);
highScoresButton.addEventListener(MouseEvent.CLICK, highScoresButtonClicked);
moreGamesButton.addEventListener(MouseEvent.ROLL_OVER, moreGamesButtonOvered);
moreGamesButton.addEventListener(MouseEvent.CLICK, moreGamesButtonClicked);
Football2dbutton.addEventListener(MouseEvent.CLICK, moreGamesClicked);
}
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();
};
Object(parent).gotoInstructionsPage();
}
private function highScoresButtonOvered(_arg1:MouseEvent):void{
if (Object(parent).buttonSoundOver){
Object(parent).buttonSoundOver.play();
};
}
private function highScoresButtonClicked(_arg1:MouseEvent):void{
if (Object(parent).buttonSoundClick){
Object(parent).buttonSoundClick.play();
};
Object(parent).showHighScores();
}
private function moreGamesButtonOvered(_arg1:MouseEvent):void{
if (Object(parent).buttonSoundOver){
Object(parent).buttonSoundOver.play();
};
}
private function moreGamesClicked(_arg1:MouseEvent):void{
if (Object(parent).buttonSoundClick){
Object(parent).buttonSoundClick.play();
};
Object(parent).gotoMoreGamesURL();
}
private function moreGamesButtonClicked(_arg1:MouseEvent):void{
if (Object(parent).buttonSoundClick){
Object(parent).buttonSoundClick.play();
};
Object(parent).gotoMoreGamesURL();
}
}
}//package com.novelgames.flashgames.common
Section 14
//Arrow (com.novelgames.flashgames.freekick.Arrow)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public class Arrow extends ThreeDShape {
public function Arrow(){
var _local1:Number;
var _local2:ThreeDPlane;
var _local3:int;
super();
_local1 = (Config.ARROW_LENGTH - Config.ARROW_HEADLENGTH);
vertices = new Array();
_local3 = 0;
while (_local3 < Config.ARROW_COLOURS.length) {
vertices.push(new ThreeDVector(((_local3 * _local1) / (Config.ARROW_COLOURS.length - 1)), (-(Config.ARROW_THICKNESS) / 2), 0));
vertices.push(new ThreeDVector(((_local3 * _local1) / (Config.ARROW_COLOURS.length - 1)), (Config.ARROW_THICKNESS / 2), 0));
_local3++;
};
vertices.push(new ThreeDVector(_local1, -(Config.ARROW_HEADLENGTH), 0));
vertices.push(new ThreeDVector(_local1, Config.ARROW_HEADLENGTH, 0));
vertices.push(new ThreeDVector(Config.ARROW_LENGTH, 0, 0));
planes = new Array();
_local3 = 0;
while (_local3 < (Config.ARROW_COLOURS.length - 1)) {
_local2 = new ThreeDPlane();
_local2.hasFill = true;
_local2.fillColour = Config.ARROW_COLOURS[_local3];
_local2.vertices = [vertices[(_local3 * 2)], vertices[((_local3 * 2) + 2)], vertices[((_local3 * 2) + 3)], vertices[((_local3 * 2) + 1)]];
planes.push(_local2);
_local3++;
};
_local2 = new ThreeDPlane();
_local2.hasFill = true;
_local2.fillColour = Config.ARROW_COLOURS[_local3];
_local2.vertices = [vertices[((_local3 * 2) + 2)], vertices[((_local3 * 2) + 4)], vertices[((_local3 * 2) + 3)]];
planes.push(_local2);
_local2 = new ThreeDPlane();
_local2.hasLine = true;
_local2.lineColour = Config.ARROW_BORDERCOLOUR;
_local2.lineThickness = Config.ARROW_BORDERTHICKNESS;
_local2.vertices = new Array();
_local3 = 0;
while (_local3 <= Config.ARROW_COLOURS.length) {
_local2.vertices.push(vertices[(_local3 * 2)]);
_local3++;
};
_local2.vertices.push(vertices[(_local3 * 2)]);
_local3 = 0;
while (_local3 <= Config.ARROW_COLOURS.length) {
_local2.vertices.push(vertices[(((Config.ARROW_COLOURS.length - _local3) * 2) + 1)]);
_local3++;
};
planes.push(_local2);
}
public function setCurvature(_arg1:Number):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:int;
_local2 = (Config.ARROW_LENGTH - Config.ARROW_HEADLENGTH);
_local3 = (_local2 / (Config.ARROW_COLOURS.length - 1));
_local4 = (_arg1 * _local3);
_local7 = ((Config.ARROW_THICKNESS / 2) / Math.sin(((Math.PI / 2) - _local4)));
_local5 = _local3;
_local6 = 0;
_local10 = 0;
while (_local10 < (Config.ARROW_COLOURS.length - 1)) {
_local8 = (_local7 * Math.cos((((_local4 / 2) + (Math.PI / 2)) - (_local4 * (_local10 + 1)))));
_local9 = (_local7 * Math.sin((((_local4 / 2) + (Math.PI / 2)) - (_local4 * (_local10 + 1)))));
vertices[((_local10 * 2) + 2)].x = (_local5 + _local8);
vertices[((_local10 * 2) + 2)].y = (_local6 - _local9);
vertices[((_local10 * 2) + 3)].x = (_local5 - _local8);
vertices[((_local10 * 2) + 3)].y = (_local6 + _local9);
if (_local10 < (Config.ARROW_COLOURS.length - 2)){
_local5 = (_local5 + (_local3 * Math.cos((_local4 * (_local10 + 1)))));
_local6 = (_local6 + (_local3 * Math.sin((_local4 * (_local10 + 1)))));
};
_local10++;
};
_local7 = (_local7 * (Config.ARROW_HEADLENGTH / (Config.ARROW_THICKNESS / 2)));
_local8 = (_local7 * Math.cos((((_local4 / 2) + (Math.PI / 2)) - (_local4 * (_local10 + 1)))));
_local9 = (_local7 * Math.sin((((_local4 / 2) + (Math.PI / 2)) - (_local4 * (_local10 + 1)))));
vertices[((_local10 * 2) + 2)].x = (_local5 + _local8);
vertices[((_local10 * 2) + 2)].y = (_local6 - _local9);
vertices[((_local10 * 2) + 3)].x = (_local5 - _local8);
vertices[((_local10 * 2) + 3)].y = (_local6 + _local9);
vertices[((_local10 * 2) + 4)].x = (_local5 + (Config.ARROW_HEADLENGTH * Math.cos((_local4 * (_local10 + 1)))));
vertices[((_local10 * 2) + 4)].y = (_local6 + (Config.ARROW_HEADLENGTH * Math.sin((_local4 * (_local10 + 1)))));
}
public function setForce(_arg1:Number):void{
var _local2:int;
var _local3:int;
_local2 = Math.floor((_arg1 * (Config.ARROW_COLOURS.length + 1)));
if (_local2 > Config.ARROW_COLOURS.length){
_local2 = Config.ARROW_COLOURS.length;
};
_local3 = 0;
while (_local3 < Config.ARROW_COLOURS.length) {
planes[_local3].fillColour = ((_local3 < _local2)) ? Config.ARROW_COLOURS[_local3] : Config.ARROW_BACKGROUNDCOLOUR;
_local3++;
};
}
public function reset():void{
setCurvature(0);
setForce(1);
}
}
}//package com.novelgames.flashgames.freekick
Section 15
//Ball (com.novelgames.flashgames.freekick.Ball)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public class Ball extends ThreeDBillboard {
public var theMovieClip:MovieClip;
public var speedX:Number;
public var speedY:Number;
public var speedZ:Number;
public var curveSpeed:Number;
public var curveRadians:Number;
public var sinCurveRadians:Number;
public var cosCurveRadians:Number;
public function Ball(){
plane.className = "com.novelgames.flashgames.freekick.BallGraphic";
}
public function initialize():void{
theMovieClip = plane.billboardMovieClip;
theMovieClip.rotation = 0;
theMovieClip.gotoAndStop(1);
}
public function updateCurveRadians():void{
var _local1:Number;
if ((((speedX == 0)) || ((speedY == 0)))){
return;
};
_local1 = Math.sqrt(((speedX * speedX) + (speedY * speedY)));
curveRadians = ((curveSpeed / 1000) / _local1);
sinCurveRadians = Math.sin(curveRadians);
cosCurveRadians = Math.cos(curveRadians);
}
public function updateSpin(_arg1:int):void{
if ((((speedX == 0)) && ((speedY == 0)))){
return;
};
if (curveSpeed < 0){
theMovieClip.rotation = 0;
} else {
theMovieClip.rotation = 180;
};
theMovieClip.gotoAndStop((Math.floor(((theMovieClip.totalFrames * (_arg1 % Config.BALL_SPINTIME)) / Config.BALL_SPINTIME)) + 1));
}
}
}//package com.novelgames.flashgames.freekick
Section 16
//BallGraphic (com.novelgames.flashgames.freekick.BallGraphic)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public dynamic class BallGraphic extends MovieClip {
}
}//package com.novelgames.flashgames.freekick
Section 17
//BallShadow (com.novelgames.flashgames.freekick.BallShadow)
package com.novelgames.flashgames.freekick {
public class BallShadow extends ThreeDBillboard {
public function BallShadow(){
plane.className = "com.novelgames.flashgames.freekick.BallShadowGraphic";
}
}
}//package com.novelgames.flashgames.freekick
Section 18
//BallShadowGraphic (com.novelgames.flashgames.freekick.BallShadowGraphic)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public dynamic class BallShadowGraphic extends MovieClip {
}
}//package com.novelgames.flashgames.freekick
Section 19
//Board (com.novelgames.flashgames.freekick.Board)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public class Board extends ThreeDShape {
public function Board(){
var _local1:Array;
var _local2:Number;
var _local3:Array;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:int;
super();
_local1 = new Array();
_local2 = (Config.FIELD_WIDTH + (Config.FIELD_GROUNDEXTRA * 2));
_local4 = (-(_local2) / 2);
while (_local4 < (_local2 / 2)) {
_local1.push(_local4);
_local4 = (_local4 + (Config.BOARD_MINWIDTH + (Math.random() * (Config.BOARD_MAXWIDTH - Config.BOARD_MINWIDTH))));
};
_local1.push((_local2 / 2));
_local3 = generateBoardColours((_local1.length - 1));
vertices = new Array();
_local5 = (-(Config.FIELD_GROUNDEXTRA) - (Config.BOARD_HEIGHT * Math.cos(((Config.BOARD_ANGLE * Math.PI) / 180))));
_local6 = (-(Config.BOARD_HEIGHT) * Math.sin(((Config.BOARD_ANGLE * Math.PI) / 180)));
_local7 = 0;
while (_local7 < _local1.length) {
vertices.push(new ThreeDVector(_local1[_local7], _local5, _local6));
vertices.push(new ThreeDVector(_local1[_local7], -(Config.FIELD_GROUNDEXTRA), 0));
_local7++;
};
planes = new Array();
_local7 = 0;
while (_local7 < _local3.length) {
planes[_local7] = new ThreeDPlane();
planes[_local7].hasFill = true;
planes[_local7].fillColour = _local3[_local7];
planes[_local7].vertices = [vertices[(_local7 * 2)], vertices[((_local7 * 2) + 2)], vertices[((_local7 * 2) + 3)], vertices[((_local7 * 2) + 1)]];
_local7++;
};
}
private function generateBoardColours(_arg1:int):Array{
var _local3:int;
var _local2:Array = new Array();
_local2[0] = Config.BOARD_COLOURS[Math.floor((Math.random() * Config.BOARD_COLOURS.length))];
_local3 = 1;
while (_local3 < _arg1) {
while (true) {
_local2[_local3] = Config.BOARD_COLOURS[Math.floor((Math.random() * Config.BOARD_COLOURS.length))];
if ((((_local2[_local3] == _local2[(_local3 - 1)])) && ((Config.BOARD_COLOURS.length > 1)))){
} else {
break;
};
};
_local3++;
};
return (_local2);
}
}
}//package com.novelgames.flashgames.freekick
Section 20
//ButtonSoundClick (com.novelgames.flashgames.freekick.ButtonSoundClick)
package com.novelgames.flashgames.freekick {
import com.novelgames.flashgames.common.*;
public dynamic class ButtonSoundClick extends NewSound {
}
}//package com.novelgames.flashgames.freekick
Section 21
//ButtonSoundOver (com.novelgames.flashgames.freekick.ButtonSoundOver)
package com.novelgames.flashgames.freekick {
import com.novelgames.flashgames.common.*;
public dynamic class ButtonSoundOver extends NewSound {
}
}//package com.novelgames.flashgames.freekick
Section 22
//Config (com.novelgames.flashgames.freekick.Config)
package com.novelgames.flashgames.freekick {
public class Config {
public static var METRICS_CMTOPIXEL:Number = 0.75;
public static var FIELD_GOALWIDTH:Number = 732;
public static var FIELD_GOALHEIGHT:Number = 244;
public static var FIELD_GOALDEPTH:Number = 200;
public static var FIELD_GOALBACKHEIGHT:Number = 200;
public static var FIELD_GOALPOSTCOLOUR:uint = 0xFFFFFF;
public static var FIELD_GOALNETTHICKNESS:Number = 1;
public static var FIELD_GOALNETCOLOUR:uint = 0xFFFFFF;
public static var FIELD_GOALNETSQUARESIZE:Number = 30;
public static var FIELD_SMALLBOXWIDTH:Number = 1832;
public static var FIELD_SMALLBOXHEIGHT:Number = 550;
public static var FIELD_BIGBOXWIDTH:Number = 4030;
public static var FIELD_BIGBOXHEIGHT:Number = 1650;
public static var FIELD_PENALTYSPOTDISTANCE:Number = 1100;
public static var FIELD_BOXARCRADIUS:Number = 915;
public static var FIELD_WIDTH:Number = 6800;
public static var FIELD_HEIGHT:Number = 10500;
public static var FIELD_LINETHICKNESS:Number = 15;
public static var FIELD_LINECOLOUR:uint = 0xFFFFFF;
public static var FIELD_GROUNDEXTRA:Number = 1000;
public static var FIELD_GROUNDCOLOURS:Array = [5157666, 4496670];
public static var FIELD_GROUNDSTRIPETHICKNESS:Number = 300;
public static var PROJECTION_EYEZ:Number = -3000;
public static var BOARD_COLOURS:Array = [8112089, 16238345, 14375460];
public static var BOARD_HEIGHT:Number = 150;
public static var BOARD_ANGLE:Number = 60;
public static var BOARD_MINWIDTH:Number = 300;
public static var BOARD_MAXWIDTH:Number = 400;
public static var SHOOTER_MAXANGLE:Number = 45;
public static var SHOOTER_SCREENX:Number = 300;
public static var SHOOTER_SCREENY:Number = 350;
public static var GOAL_SCREENY:Number = 170;
public static var BALL_RADIUS:Number = 26;
public static var BALL_MINSPEED:Number = 1000;
public static var BALL_MAXSPEED:Number = 4000;
public static var BALL_MAXCURVESPEED:Number = 1500;
public static var BALL_ACCELERATION:Number = 1000;
public static var BALL_BOUNCEVERTICALSPEEDLOST:Number = 0.5;
public static var BALL_BOUNCEHORIZONTALSPEEDLOST:Number = 0;
public static var BALL_BOUNCECURVESPEEDLOST:Number = 0.7;
public static var BALL_HITSPEEDLOST:Number = 0.5;
public static var BALL_EXTRATIMEALLOWANCE:int = 2000;
public static var BALL_SPINTIME:int = 200;
public static var MANWALL_DISTANCEFROMBALL:Number = 915;
public static var MANWALL_MAXDEVIATION:Number = 0.5;
public static var MANWALL_NOOFTYPES:int = 4;
public static var MANWALL_WIDTH:Number = 85;
public static var MANWALL_HEIGHT:Number = 190;
public static var KEEPER_Y:Number = 50;
public static var KEEPER_MAXDEVIATION:Number = 0.3;
public static var KEEPER_JUMPWIDTH:Number = 77;
public static var KEEPER_MINREACTIONTIME:int = 500;
public static var KEEPER_MINJUMPSPEED:Number = 200;
public static var KEEPER_MAXJUMPSPEED:Number = 400;
public static var KEEPER_MAXJUMPANGLE:Number = 60;
public static var KEEPER_ACCELERATION:Number = 1000;
public static var PLAYER_BALLDISTANCE:Number = 10;
public static var PLAYER_KICKTIME:int = 1000;
public static var PLAYER_KICKBALLTIME:int = 800;
public static var ARROW_MAXANGLE:Number = 60;
public static var ARROW_MAXELEVATION:Number = 20;
public static var ARROW_MAXELEVATIONDISTANCE:Number = 100;
public static var ARROW_MAXCURVATURE:Number = 0.1;
public static var ARROW_MAXCURVATUREDISTANCE:Number = 100;
public static var ARROW_FORCEPERIOD:Number = 1000;
public static var ARROW_LENGTH:Number = 500;
public static var ARROW_HEADLENGTH:Number = 50;
public static var ARROW_THICKNESS:Number = 50;
public static var ARROW_BORDERCOLOUR:uint = 0xFFFFFF;
public static var ARROW_BORDERTHICKNESS:Number = 2;
public static var ARROW_COLOURS:Array = [0xFF00, 0x33FF00, 0x66FF00, 0x99FF00, 0xCCFF00, 0xFFFF00, 0xFFCC00, 0xFF9900, 0xFF6600, 0xFF3300, 0xFF0000];
public static var ARROW_BACKGROUNDCOLOUR:uint = 0x333333;
public static var ARROW_SHADOWCOLOUR:uint = 3228196;
public static var ARROW_SHADOWALPHA:Number = 0.45;
public static var SHOT_TOTAL:int = 10;
public static var SHOT_INITIALDISTANCE:Number = 1650;
public static var SHOT_DISTANCEINCREASE:Number = 150;
public static var SHOT_INITIALMANWALLS:Number = 0;
public static var SHOT_MANWALLSINCREASE:Number = 0.5;
public static var MESSAGE_GOALWAITTIME:int = 2000;
public static var MESSAGE_MISSEDWAITTIME:int = 1000;
public static var MESSAGE_GOALTIME:int = 2000;
public static var MESSAGE_MISSEDTIME:int = 1500;
public static var MESSAGE_GAMEOVERTIME:int = 1000;
public static var SCORE_GOAL:int = 2000;
}
}//package com.novelgames.flashgames.freekick
Section 23
//FieldLines (com.novelgames.flashgames.freekick.FieldLines)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public class FieldLines extends ThreeDShape {
public function FieldLines(){
var _local1:Number = (Config.FIELD_WIDTH / 2);
var _local2:Number = (Config.FIELD_HEIGHT / 2);
var _local3:Number = (Config.FIELD_BIGBOXWIDTH / 2);
var _local4:Number = Config.FIELD_BIGBOXHEIGHT;
var _local5:Number = (Config.FIELD_SMALLBOXWIDTH / 2);
var _local6:Number = Config.FIELD_SMALLBOXHEIGHT;
var _local7:Number = (Config.FIELD_LINETHICKNESS / 2);
vertices = [new ThreeDVector((-(_local1) - _local7), -(_local7), 0), new ThreeDVector((_local1 + _local7), -(_local7), 0), new ThreeDVector((-(_local1) + _local7), _local7, 0), new ThreeDVector((_local1 - _local7), _local7, 0), new ThreeDVector((-(_local1) - _local7), _local2, 0), new ThreeDVector((-(_local1) + _local7), _local2, 0), new ThreeDVector((_local1 - _local7), _local2, 0), new ThreeDVector((_local1 + _local7), _local2, 0), new ThreeDVector((-(_local3) - _local7), _local7, 0), new ThreeDVector((-(_local3) + _local7), _local7, 0), new ThreeDVector((_local3 - _local7), _local7, 0), new ThreeDVector((_local3 + _local7), _local7, 0), new ThreeDVector((-(_local3) + _local7), (_local4 - _local7), 0), new ThreeDVector((_local3 - _local7), (_local4 - _local7), 0), new ThreeDVector((-(_local3) - _local7), (_local4 + _local7), 0), new ThreeDVector((_local3 + _local7), (_local4 + _local7), 0), new ThreeDVector((-(_local5) - _local7), _local7, 0), new ThreeDVector((-(_local5) + _local7), _local7, 0), new ThreeDVector((_local5 - _local7), _local7, 0), new ThreeDVector((_local5 + _local7), _local7, 0), new ThreeDVector((-(_local5) + _local7), (_local6 - _local7), 0), new ThreeDVector((_local5 - _local7), (_local6 - _local7), 0), new ThreeDVector((-(_local5) - _local7), (_local6 + _local7), 0), new ThreeDVector((_local5 + _local7), (_local6 + _local7), 0), new ThreeDVector(0, 0, 0)];
addPlane([0, 1, 3, 2]);
addPlane([0, 2, 5, 4]);
addPlane([3, 1, 7, 6]);
addPlane([8, 9, 12, 14]);
addPlane([10, 11, 15, 13]);
addPlane([12, 13, 15, 14]);
addPlane([16, 17, 20, 22]);
addPlane([18, 19, 23, 21]);
addPlane([20, 21, 23, 22]);
addPenaltySpot();
addArc();
}
private function addPlane(_arg1:Array):void{
var _local2:ThreeDPlane;
var _local3:int;
_local2 = new ThreeDPlane();
_local2.hasFill = true;
_local2.fillColour = Config.FIELD_LINECOLOUR;
_local2.vertices = new Array();
_local3 = 0;
while (_local3 < _arg1.length) {
_local2.vertices[_local3] = vertices[_arg1[_local3]];
_local3++;
};
planes.push(_local2);
}
private function addPenaltySpot():void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:ThreeDCurvedPlane;
var _local9:int;
var _local1:Array = new Array();
_local2 = Math.sin((Math.PI / 8));
_local3 = Math.cos((Math.PI / 8));
_local6 = Config.FIELD_LINETHICKNESS;
_local7 = 0;
_local9 = 0;
while (_local9 < 16) {
_local1.push(new ThreeDVector(_local6, (Config.FIELD_PENALTYSPOTDISTANCE + _local7), 0));
_local4 = _local6;
_local5 = _local7;
_local6 = (((_local4 * _local3) - (_local5 * _local2)) * (((_local9 % 2) == 1)) ? _local3 : (1 / _local3));
_local7 = (((_local4 * _local2) + (_local5 * _local3)) * (((_local9 % 2) == 1)) ? _local3 : (1 / _local3));
_local9++;
};
this.vertices = this.vertices.concat(_local1);
_local8 = new ThreeDCurvedPlane();
_local8.hasFill = true;
_local8.fillColour = Config.FIELD_LINECOLOUR;
_local8.vertices = _local1;
planes.push(_local8);
}
private function addArc():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:ThreeDCurvedPlane;
var _local11:int;
var _local1:Array = new Array();
_local2 = Math.sqrt(((Config.FIELD_BOXARCRADIUS * Config.FIELD_BOXARCRADIUS) - ((Config.FIELD_BIGBOXHEIGHT - Config.FIELD_PENALTYSPOTDISTANCE) * (Config.FIELD_BIGBOXHEIGHT - Config.FIELD_PENALTYSPOTDISTANCE))));
_local8 = (_local2 + (Config.FIELD_LINETHICKNESS / 2));
_local9 = (Config.FIELD_BIGBOXHEIGHT - Config.FIELD_PENALTYSPOTDISTANCE);
_local3 = (Math.atan2(_local8, _local9) / 2);
_local4 = Math.sin(_local3);
_local5 = Math.cos(_local3);
_local11 = 0;
while (_local11 < 5) {
_local1.push(new ThreeDVector(_local8, (Config.FIELD_PENALTYSPOTDISTANCE + _local9), 0));
_local6 = _local8;
_local7 = _local9;
_local8 = (((_local6 * _local5) - (_local7 * _local4)) * (((_local11 % 2) == 1)) ? _local5 : (1 / _local5));
_local9 = (((_local6 * _local4) + (_local7 * _local5)) * (((_local11 % 2) == 1)) ? _local5 : (1 / _local5));
_local11++;
};
_local1.push(new ThreeDVector(-(_local2), Config.FIELD_BIGBOXHEIGHT, 0));
_local8 = (-(_local2) + (Config.FIELD_LINETHICKNESS / 2));
_local9 = (Config.FIELD_BIGBOXHEIGHT - Config.FIELD_PENALTYSPOTDISTANCE);
_local3 = (Math.atan2(-(_local8), _local9) / 2);
_local4 = Math.sin(_local3);
_local5 = Math.cos(_local3);
_local11 = 0;
while (_local11 < 5) {
_local1.push(new ThreeDVector(_local8, (Config.FIELD_PENALTYSPOTDISTANCE + _local9), 0));
_local6 = _local8;
_local7 = _local9;
_local8 = (((_local6 * _local5) + (_local7 * _local4)) * (((_local11 % 2) == 1)) ? _local5 : (1 / _local5));
_local9 = (((-(_local6) * _local4) + (_local7 * _local5)) * (((_local11 % 2) == 1)) ? _local5 : (1 / _local5));
_local11++;
};
_local1.push(new ThreeDVector(_local2, Config.FIELD_BIGBOXHEIGHT, 0));
this.vertices = this.vertices.concat(_local1);
_local10 = new ThreeDCurvedPlane();
_local10.hasFill = true;
_local10.fillColour = Config.FIELD_LINECOLOUR;
_local10.vertices = _local1;
planes.push(_local10);
}
}
}//package com.novelgames.flashgames.freekick
Section 24
//Game (com.novelgames.flashgames.freekick.Game)
package com.novelgames.flashgames.freekick {
import flash.display.*;
import flash.events.*;
import com.novelgames.flashgames.common.*;
import flash.utils.*;
import flash.media.*;
import flash.geom.*;
import flash.text.*;
public class Game extends Game {
public var shotsRemainingText:TextField;
public var clickDetector:MovieClip;
public var goalsText:TextField;
public var thingsViewer:ThreeDObjectViewer;
public var fieldLinesViewer:ThreeDObjectViewer;
public var instructionsButton:InstructionsButton;
public var optionsButton:OptionsButton;
public var message:Message;
public var hintText:MovieClip;
public var shadowsViewer:ThreeDObjectViewer;
public var groundViewer:ThreeDObjectViewer;
private var __goals:ObfuscatedNumber;
private var __shotsRemaining:ObfuscatedNumber;
private var ground:Ground;
private var fieldLines:FieldLines;
private var thingsContainer:ThreeDObjectContainer;
private var board:Board;
private var goal:Goal;
private var ball:Ball;
private var manWalls:Array;
private var keeper:Keeper;
private var player:Player;
private var arrow:Arrow;
private var shadowsContainer:ThreeDObjectContainer;
private var ballShadow:BallShadow;
private var arrowShadow:ThreeDShadow;
private var ballX:Number;
private var ballY:Number;
private var ballZ:Number;
private var ballDistance:Number;
private var ballAngle:Number;
private var ballAngleRadians:Number;
private var sinBallAngle:Number;
private var cosBallAngle:Number;
private var arrowMouseX:Number;
private var arrowMouseY:Number;
private var arrowAngleRadians:Number;
private var arrowElevationRadians:Number;
private var arrowCurvatureRadians:Number;
private var arrowForce:Number;
private var shootMaxTime:int;
private var shootPassedBaseLine:Boolean;
private var shootGoaled:Boolean;
private var shootHitNet:Boolean;
private var shootIsHitting:Boolean;
private var keeperReacted:Boolean;
private var transformMatrix:ThreeDMatrix;
private var inverseTransformMatrix:ThreeDMatrix;
private var arrowForceTimer:SimpleTimer;
private var ballTimer:SimpleTimer;
private var soundSelect:Sound;
private var soundWhistle:Sound;
private var soundKick:Sound;
private var soundGoal:Sound;
private var soundMissed:Sound;
private var soundGameOver:Sound;
private var soundHitMan:Sound;
private var soundHitFrame:Sound;
private var soundHitBoard:Sound;
public function Game(){
goals = 0;
shotsRemaining = Config.SHOT_TOTAL;
initialize();
soundSelect = new SoundSelect();
soundWhistle = new SoundWhistle();
soundKick = new SoundKick();
soundGoal = new SoundGoal();
soundMissed = new SoundMissed();
soundGameOver = new SoundGameOver();
soundHitMan = new SoundHitMan();
soundHitFrame = new SoundHitFrame();
soundHitBoard = new SoundHitBoard();
startShot(0);
}
public function set goals(_arg1:int):void{
if (__goals == null){
__goals = new ObfuscatedNumber();
};
__goals.value = _arg1;
goalsText.text = _arg1.toString();
}
public function get goals():int{
if (__goals == null){
__goals = new ObfuscatedNumber();
};
return (__goals.value);
}
public function set shotsRemaining(_arg1:int):void{
if (__shotsRemaining == null){
__shotsRemaining = new ObfuscatedNumber();
};
__shotsRemaining.value = _arg1;
shotsRemainingText.text = _arg1.toString();
}
public function get shotsRemaining():int{
if (__shotsRemaining == null){
__shotsRemaining = new ObfuscatedNumber();
};
return (__shotsRemaining.value);
}
private function initialize():void{
ground = new Ground();
fieldLines = new FieldLines();
thingsContainer = new ThreeDObjectContainer();
board = new Board();
thingsContainer.addChild(board);
goal = new Goal();
thingsContainer.addChild(goal);
ball = new Ball();
thingsContainer.addChild(ball);
manWalls = new Array();
keeper = new Keeper();
thingsContainer.addChild(keeper);
player = new Player();
thingsContainer.addChild(player);
arrow = new Arrow();
thingsContainer.addChild(arrow);
shadowsContainer = new ThreeDObjectContainer();
ballShadow = new BallShadow();
shadowsContainer.addChild(ballShadow);
arrowShadow = new ThreeDShadow(arrow, Config.ARROW_SHADOWCOLOUR, Config.ARROW_SHADOWALPHA);
shadowsContainer.addChild(arrowShadow);
groundViewer.x = Config.SHOOTER_SCREENX;
groundViewer.y = Config.SHOOTER_SCREENY;
groundViewer.setObject(ground, ((1 - Config.METRICS_CMTOPIXEL) * Config.PROJECTION_EYEZ), Config.PROJECTION_EYEZ, 0, false);
fieldLinesViewer.x = Config.SHOOTER_SCREENX;
fieldLinesViewer.y = Config.SHOOTER_SCREENY;
fieldLinesViewer.setObject(fieldLines, ((1 - Config.METRICS_CMTOPIXEL) * Config.PROJECTION_EYEZ), Config.PROJECTION_EYEZ, 0, false);
thingsViewer.x = Config.SHOOTER_SCREENX;
thingsViewer.y = Config.SHOOTER_SCREENY;
thingsViewer.setObject(thingsContainer, ((1 - Config.METRICS_CMTOPIXEL) * Config.PROJECTION_EYEZ), Config.PROJECTION_EYEZ, 0, true);
shadowsViewer.x = Config.SHOOTER_SCREENX;
shadowsViewer.y = Config.SHOOTER_SCREENY;
shadowsViewer.setObject(shadowsContainer, ((1 - Config.METRICS_CMTOPIXEL) * Config.PROJECTION_EYEZ), Config.PROJECTION_EYEZ, 0, true);
hintText.stop();
hintText.visible = false;
startAngleControl();
}
private function startShot(_arg1:int):void{
var _local2:Number;
var _local3:int;
shotsRemaining = (Config.SHOT_TOTAL - _arg1);
ballAngle = (-(Config.SHOOTER_MAXANGLE) + (Math.random() * (Config.SHOOTER_MAXANGLE * 2)));
ballAngleRadians = ((ballAngle * Math.PI) / 180);
sinBallAngle = Math.sin(ballAngleRadians);
cosBallAngle = Math.cos(ballAngleRadians);
_local2 = (Config.SHOT_INITIALDISTANCE + (_arg1 * Config.SHOT_DISTANCEINCREASE));
ballDistance = (_local2 / cosBallAngle);
ballX = (-(ballDistance) * sinBallAngle);
ballY = (ballDistance * cosBallAngle);
ballZ = -(Config.BALL_RADIUS);
_local3 = Math.floor((Config.SHOT_INITIALMANWALLS + (_arg1 * Config.SHOT_MANWALLSINCREASE)));
setBall();
setManWalls(_local3);
setKeeper();
setPlayer();
setArrow();
transformMatrix = getTransformMatrix();
inverseTransformMatrix = transformMatrix.getInverse();
ground.setMatrix(transformMatrix);
fieldLines.setMatrix(transformMatrix);
thingsContainer.setMatrix(transformMatrix);
shadowsContainer.setMatrix(transformMatrix);
groundViewer.show();
fieldLinesViewer.show();
thingsViewer.show();
shadowsViewer.show();
message.hide();
hintText.visible = true;
hintText.gotoAndStop("angle");
startAngleControl();
soundWhistle.play();
}
private function setBall():void{
ball.setPosition(ballX, ballY, -(Config.BALL_RADIUS));
ball.initialize();
ballShadow.setPosition(ballX, ballY, 0);
}
private function setManWalls(_arg1:int):void{
var _local2:ManWall;
var _local3:Array;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:int;
_local8 = manWalls.length;
while (_local8 < _arg1) {
_local2 = new ManWall();
thingsContainer.addChild(_local2);
manWalls.push(_local2);
_local8++;
};
thingsViewer.setObject(thingsContainer, ((1 - Config.METRICS_CMTOPIXEL) * Config.PROJECTION_EYEZ), Config.PROJECTION_EYEZ, 0, true);
_local3 = new Array();
_local8 = 0;
while (_local8 < Config.MANWALL_NOOFTYPES) {
_local3[_local8] = _local8;
_local8++;
};
shuffleArray(_local3);
_local4 = (manWalls.length * Config.MANWALL_WIDTH);
_local5 = (_local4 * ((Math.random() * Config.MANWALL_MAXDEVIATION) - (Config.MANWALL_MAXDEVIATION / 2)));
_local6 = (-((ballDistance - Config.MANWALL_DISTANCEFROMBALL)) * sinBallAngle);
_local7 = ((ballDistance - Config.MANWALL_DISTANCEFROMBALL) * cosBallAngle);
_local6 = (_local6 - (((_local4 / 2) + _local5) * cosBallAngle));
_local7 = (_local7 - (((_local4 / 2) + _local5) * sinBallAngle));
_local8 = 0;
while (_local8 < manWalls.length) {
manWalls[_local8].initialize(_local3[(_local8 % _local3.length)]);
manWalls[_local8].setPosition(_local6, _local7, 0);
_local6 = (_local6 + (cosBallAngle * Config.MANWALL_WIDTH));
_local7 = (_local7 + (sinBallAngle * Config.MANWALL_WIDTH));
_local8++;
};
}
private function shuffleArray(_arg1:Array):void{
var _local2:int;
var _local3:int;
var _local4:*;
_local2 = 0;
while (_local2 < _arg1.length) {
_local3 = Math.floor((Math.random() * _arg1.length));
_local4 = _arg1[_local2];
_arg1[_local2] = _arg1[_local3];
_arg1[_local3] = _local4;
_local2++;
};
}
private function setKeeper():void{
var _local1:Number = ((Config.FIELD_GOALWIDTH * Config.KEEPER_MAXDEVIATION) * (Math.random() - 0.5));
keeper.setPosition(_local1, Config.KEEPER_Y, 0);
keeper.initialize();
}
private function setPlayer():void{
player.setPosition((ballX - (sinBallAngle * Config.PLAYER_BALLDISTANCE)), (ballY + (cosBallAngle * Config.PLAYER_BALLDISTANCE)), 0);
player.initialize();
}
private function setArrow():void{
var _local1:ThreeDMatrix = new ThreeDMatrix();
_local1 = _local1.rotateZ((ballAngleRadians - (Math.PI / 2)));
_local1 = _local1.translate(ballX, ballY, 0);
arrow.reset();
arrow.setMatrix(_local1);
arrowShadow.update();
arrow.visible = true;
arrowShadow.visible = true;
}
private function getTransformMatrix():ThreeDMatrix{
var _local2:Number;
var _local3:Number;
var _local1:ThreeDMatrix = new ThreeDMatrix();
_local1 = _local1.rotateZ(-(ballAngleRadians));
_local1 = _local1.translate(0, -(ballDistance), 0);
_local2 = Math.atan2(((Config.SHOOTER_SCREENY - Config.GOAL_SCREENY) / Config.METRICS_CMTOPIXEL), -(Config.PROJECTION_EYEZ));
_local3 = ((Math.PI / 2) - (Math.asin(((-(Math.sin(_local2)) * Config.PROJECTION_EYEZ) / ballDistance)) + _local2));
_local1 = _local1.rotateX(-(_local3));
return (_local1);
}
private function startAngleControl():void{
arrowAngleRadians = (ballAngleRadians - (Math.PI / 2));
clickDetector.addEventListener(MouseEvent.MOUSE_MOVE, onAngleMouseMove);
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onAngleMouseDown);
clickDetector.buttonMode = true;
}
private function onAngleMouseMove(_arg1:MouseEvent):void{
var _local3:Number;
var _local4:ThreeDMatrix;
var _local2:ThreeDVector = getMousePoint();
if (_local2 == null){
return;
};
_arg1.updateAfterEvent();
arrowAngleRadians = Math.atan2((_local2.y - ballY), (_local2.x - ballX));
_local3 = ((90 - ballAngle) + ((arrowAngleRadians * 180) / Math.PI));
_local3 = (_local3 % 360);
if (_local3 > 180){
_local3 = (_local3 - 360);
};
if (_local3 < -180){
_local3 = (_local3 + 360);
};
if (_local3 < -(Config.ARROW_MAXANGLE)){
arrowAngleRadians = (((-(Math.PI) / 2) + ballAngleRadians) - ((Config.ARROW_MAXANGLE * Math.PI) / 180));
} else {
if (_local3 > Config.ARROW_MAXANGLE){
arrowAngleRadians = ((((Config.ARROW_MAXANGLE * Math.PI) / 180) - (Math.PI / 2)) + ballAngleRadians);
};
};
_local4 = new ThreeDMatrix();
_local4 = _local4.rotateZ(arrowAngleRadians);
_local4 = _local4.translate(ballX, ballY, 0);
arrow.setMatrix(_local4);
arrowShadow.update();
thingsViewer.show();
shadowsViewer.show();
}
private function getMousePoint():ThreeDVector{
var _local3:Number;
var _local4:Number;
var _local1:ThreeDVector = new ThreeDVector(0, 0, thingsViewer.projectionEyeZ);
var _local2:ThreeDVector = new ThreeDVector(thingsViewer.mouseX, thingsViewer.mouseY, thingsViewer.projectionPlaneZ);
_local1 = inverseTransformMatrix.multiplyVector(_local1);
_local2 = inverseTransformMatrix.multiplyVector(_local2);
if (_local2.z <= _local1.z){
return (null);
};
_local3 = (_local1.x + (((_local2.x - _local1.x) * _local1.z) / (_local1.z - _local2.z)));
_local4 = (_local1.y + (((_local2.y - _local1.y) * _local1.z) / (_local1.z - _local2.z)));
return (new ThreeDVector(_local3, _local4, 0));
}
private function onAngleMouseDown(_arg1:MouseEvent):void{
clickDetector.removeEventListener(MouseEvent.MOUSE_MOVE, onAngleMouseMove);
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onAngleMouseDown);
soundSelect.play();
hintText.gotoAndStop("elevation");
arrowMouseY = clickDetector.mouseY;
arrowElevationRadians = 0;
clickDetector.addEventListener(MouseEvent.MOUSE_MOVE, onElevationMouseMove);
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onElevationMouseDown);
}
private function onElevationMouseMove(_arg1:MouseEvent):void{
var _local4:ThreeDMatrix;
var _local2:Number = (arrowMouseY - clickDetector.mouseY);
var _local3:Number = (_local2 / Config.ARROW_MAXELEVATIONDISTANCE);
if (_local3 < 0){
_local3 = 0;
} else {
if (_local3 > 1){
_local3 = 1;
};
};
arrowElevationRadians = (((_local3 * Config.ARROW_MAXELEVATION) * Math.PI) / 180);
_local4 = new ThreeDMatrix();
_local4 = _local4.rotateY(arrowElevationRadians);
_local4 = _local4.rotateZ(arrowAngleRadians);
_local4 = _local4.translate(ballX, ballY, 0);
arrow.setMatrix(_local4);
arrowShadow.update();
thingsViewer.show();
shadowsViewer.show();
}
private function onElevationMouseDown(_arg1:MouseEvent):void{
clickDetector.removeEventListener(MouseEvent.MOUSE_MOVE, onElevationMouseMove);
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onElevationMouseDown);
soundSelect.play();
hintText.gotoAndStop("curvature");
arrowMouseX = clickDetector.mouseX;
arrowCurvatureRadians = 0;
clickDetector.addEventListener(MouseEvent.MOUSE_MOVE, onCurvatureMouseMove);
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onCurvatureMouseDown);
}
private function onCurvatureMouseMove(_arg1:MouseEvent):void{
var _local2:Number = (clickDetector.mouseX - arrowMouseX);
var _local3:Number = (_local2 / Config.ARROW_MAXCURVATUREDISTANCE);
if (_local3 < -1){
_local3 = -1;
};
if (_local3 > 1){
_local3 = 1;
};
arrowCurvatureRadians = (((_local3 * Config.ARROW_MAXCURVATURE) * Math.PI) / 180);
arrow.setCurvature(arrowCurvatureRadians);
arrowShadow.update();
thingsViewer.show();
shadowsViewer.show();
}
private function onCurvatureMouseDown(_arg1:MouseEvent):void{
clickDetector.removeEventListener(MouseEvent.MOUSE_MOVE, onCurvatureMouseMove);
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onCurvatureMouseDown);
soundSelect.play();
hintText.gotoAndStop("force");
arrowForceTimer = new SimpleTimer(1, 0, 0, onForceTime);
arrowForce = 1;
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onForceMouseDown);
}
private function onForceTime(_arg1:SimpleTimer):void{
var _local2:Number = ((_arg1.dTime % Config.ARROW_FORCEPERIOD) / Config.ARROW_FORCEPERIOD);
if (_local2 <= 0.5){
arrowForce = (1 - (_local2 * 2));
} else {
arrowForce = ((_local2 - 0.5) * 2);
};
arrow.setForce(arrowForce);
thingsViewer.show();
}
private function onForceMouseDown(_arg1:MouseEvent):void{
arrowForceTimer.stop();
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onForceMouseDown);
clickDetector.buttonMode = false;
hintText.visible = false;
soundSelect.play();
new SimpleTimer(1, 0, Config.PLAYER_KICKTIME, onKickTime);
}
private function onKickTime(_arg1:SimpleTimer):void{
player.showKick(_arg1.ratio);
if ((((_arg1.dTime >= Config.PLAYER_KICKBALLTIME)) && (((_arg1.lastTime - _arg1.startTime) < Config.PLAYER_KICKBALLTIME)))){
arrow.visible = false;
arrowShadow.visible = false;
thingsViewer.show();
shadowsViewer.show();
startShootBall();
};
}
private function startShootBall():void{
var _local2:Number;
var _local1:Number = (Config.BALL_MINSPEED + (arrowForce * (Config.BALL_MAXSPEED - Config.BALL_MINSPEED)));
ball.speedZ = (-(_local1) * Math.sin(arrowElevationRadians));
_local2 = (_local1 * Math.cos(arrowElevationRadians));
ball.speedX = (_local2 * Math.cos(arrowAngleRadians));
ball.speedY = (_local2 * Math.sin(arrowAngleRadians));
ball.curveSpeed = ((Config.BALL_MAXCURVESPEED * arrowCurvatureRadians) / ((Config.ARROW_MAXCURVATURE * Math.PI) / 180));
ball.updateCurveRadians();
shootMaxTime = (((ballDistance / _local1) * 1000) + Config.BALL_EXTRATIMEALLOWANCE);
shootGoaled = false;
shootPassedBaseLine = false;
shootHitNet = false;
shootIsHitting = false;
keeperReacted = false;
soundKick.play();
ballTimer = new SimpleTimer(1, 0, 0, onBallTime);
}
private function onBallTime(_arg1:SimpleTimer):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:ThreeDMatrix;
var _local9:int;
var _local2:int = (_arg1.time - _arg1.lastTime);
_local9 = 0;
while (_local9 < _local2) {
_local3 = ballX;
_local4 = ballY;
_local5 = ballZ;
_local6 = ball.speedX;
_local7 = ball.speedY;
ballX = (ballX + (ball.speedX / 1000));
ballY = (ballY + (ball.speedY / 1000));
ballZ = (ballZ + (ball.speedZ / 1000));
ball.speedZ = (ball.speedZ + (Config.BALL_ACCELERATION / 1000));
ball.speedX = ((_local6 * ball.cosCurveRadians) - (_local7 * ball.sinCurveRadians));
ball.speedY = ((_local6 * ball.sinCurveRadians) + (_local7 * ball.cosCurveRadians));
checkHitGround();
checkHitManWalls();
checkHitKeeper(_local3, _local4, _local5);
checkHitGoalFrame();
if (((!(shootPassedBaseLine)) && ((ballY < 0)))){
shootPassedBaseLine = true;
shootGoaled = checkGoal();
if (shootGoaled){
new SimpleTimer(Config.MESSAGE_GOALWAITTIME, 1, 0, showGoal);
} else {
new SimpleTimer(Config.MESSAGE_MISSEDWAITTIME, 1, 0, showMissed);
};
};
if (((shootGoaled) && (!(shootHitNet)))){
shootHitNet = checkHitNet();
};
if (shootPassedBaseLine){
checkHitBoard(_local3, _local4, _local5);
};
if (((_arg1.lastTime - _arg1.startTime) + _local9) >= Config.KEEPER_MINREACTIONTIME){
calculateKeeperReaction();
};
moveKeeper();
_local9++;
};
if (((((((!(shootGoaled)) && (!(shootPassedBaseLine)))) && (!(getBallIsFlyingToGoal())))) && ((_arg1.dTime > shootMaxTime)))){
showMissed();
};
ball.updateSpin(_arg1.dTime);
_local8 = new ThreeDMatrix();
_local8 = _local8.translate(ballX, ballY, ballZ);
ball.setMatrix(_local8);
_local8 = new ThreeDMatrix();
_local8 = _local8.translate(ballX, ballY, 0);
ballShadow.setMatrix(_local8);
thingsViewer.show();
shadowsViewer.show();
}
private function checkHitGround():Boolean{
if (ballZ < -(Config.BALL_RADIUS)){
return (false);
};
ballZ = ((-(Config.BALL_RADIUS) * 2) - ballZ);
ball.speedZ = (-(Math.abs(ball.speedZ)) * (1 - Config.BALL_BOUNCEVERTICALSPEEDLOST));
ball.speedX = (ball.speedX * (1 - Config.BALL_BOUNCEHORIZONTALSPEEDLOST));
ball.speedY = (ball.speedY * (1 - Config.BALL_BOUNCEHORIZONTALSPEEDLOST));
ball.curveSpeed = (ball.curveSpeed * (1 - Config.BALL_BOUNCECURVESPEEDLOST));
ball.updateCurveRadians();
return (true);
}
private function checkHitManWalls():Boolean{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:int;
if (manWalls.length == 0){
return (false);
};
if (ballZ < -(Config.MANWALL_HEIGHT)){
return (false);
};
_local7 = 0;
while (_local7 < manWalls.length) {
_local1 = manWalls[_local7].matrix.tx;
_local2 = manWalls[_local7].matrix.ty;
_local3 = (ballX - _local1);
_local4 = (ballY - _local2);
_local5 = Math.sqrt(((_local3 * _local3) + (_local4 * _local4)));
if (_local5 > ((Config.MANWALL_WIDTH / 2) + Config.BALL_RADIUS)){
} else {
_local6 = ((ball.speedX * _local3) + (ball.speedY * _local4));
ballX = (ballX - ((((_local6 / 1000) / (_local5 * _local5)) * _local3) * 2));
ballY = (ballY - ((((_local6 / 1000) / (_local5 * _local5)) * _local4) * 2));
ball.speedX = (ball.speedX - (((_local6 / (_local5 * _local5)) * _local3) * 2));
ball.speedY = (ball.speedY - (((_local6 / (_local5 * _local5)) * _local4) * 2));
ball.speedX = (ball.speedX * (1 - Config.BALL_HITSPEEDLOST));
ball.speedY = (ball.speedY * (1 - Config.BALL_HITSPEEDLOST));
ball.speedZ = (ball.speedZ * (1 - Config.BALL_HITSPEEDLOST));
ball.curveSpeed = 0;
ball.updateCurveRadians();
soundHitMan.play();
return (true);
};
_local7++;
};
return (false);
}
private function checkHitKeeper(_arg1:Number, _arg2:Number, _arg3:Number):Boolean{
var _local4:Point;
if (_arg2 > (Config.KEEPER_Y + Config.BALL_RADIUS)){
if (ballY > (Config.KEEPER_Y + Config.BALL_RADIUS)){
return (false);
};
} else {
if (_arg2 < (Config.KEEPER_Y - Config.BALL_RADIUS)){
if (ballY < (Config.KEEPER_Y - Config.BALL_RADIUS)){
return (false);
};
} else {
return (false);
};
};
_local4 = new Point(0, 0);
_local4 = ball.theMovieClip.localToGlobal(_local4);
if (!keeper.theMovieClip.hitTestPoint(_local4.x, _local4.y, true)){
return (false);
};
if (_arg2 > (Config.KEEPER_Y + Config.BALL_RADIUS)){
ballY = (((Config.KEEPER_Y + Config.BALL_RADIUS) * 2) - ballY);
ball.speedY = Math.abs(ball.speedY);
} else {
ballY = (((Config.KEEPER_Y - Config.BALL_RADIUS) * 2) - ballY);
ball.speedY = -(Math.abs(ball.speedY));
};
ball.speedX = (ball.speedX * (1 - Config.BALL_HITSPEEDLOST));
ball.speedY = (ball.speedY * (1 - Config.BALL_HITSPEEDLOST));
ball.speedZ = (ball.speedZ * (1 - Config.BALL_HITSPEEDLOST));
soundHitMan.play();
return (true);
}
private function checkHitGoalFrame():Boolean{
var _local1:Array;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:int;
if (ballZ >= -(Config.FIELD_GOALHEIGHT)){
_local1 = [(-(Config.FIELD_GOALWIDTH) / 2), (Config.FIELD_GOALWIDTH / 2)];
_local7 = 0;
while (_local7 < 2) {
_local2 = (ballX - _local1[_local7]);
_local3 = ballY;
_local5 = Math.sqrt(((_local2 * _local2) + (_local3 * _local3)));
if (_local5 > Config.BALL_RADIUS){
} else {
_local6 = ((ball.speedX * _local2) + (ball.speedY * _local3));
ballX = (ballX - ((((_local6 / 1000) / (_local5 * _local5)) * _local2) * 2));
ballY = (ballY - ((((_local6 / 1000) / (_local5 * _local5)) * _local3) * 2));
ball.speedX = (ball.speedX - (((_local6 / (_local5 * _local5)) * _local2) * 2));
ball.speedY = (ball.speedY - (((_local6 / (_local5 * _local5)) * _local3) * 2));
ball.speedX = (ball.speedX * (1 - Config.BALL_HITSPEEDLOST));
ball.speedY = (ball.speedY * (1 - Config.BALL_HITSPEEDLOST));
ball.speedZ = (ball.speedZ * (1 - Config.BALL_HITSPEEDLOST));
ball.curveSpeed = 0;
ball.updateCurveRadians();
soundHitFrame.play();
return (true);
};
_local7++;
};
};
if (Math.abs(ballX) < (Config.FIELD_GOALWIDTH / 2)){
_local3 = ballY;
_local4 = (ballZ + Config.FIELD_GOALHEIGHT);
_local5 = Math.sqrt(((_local3 * _local3) + (_local4 * _local4)));
if (_local5 > Config.BALL_RADIUS){
return (false);
};
_local6 = ((ball.speedY * _local3) + (ball.speedZ * _local4));
ballY = (ballY - ((((_local6 / 1000) / (_local5 * _local5)) * _local3) * 2));
ballZ = (ballZ - ((((_local6 / 1000) / (_local5 * _local5)) * _local4) * 2));
ball.speedY = (ball.speedY - (((_local6 / (_local5 * _local5)) * _local3) * 2));
ball.speedZ = (ball.speedZ - (((_local6 / (_local5 * _local5)) * _local4) * 2));
ball.speedX = (ball.speedX * (1 - Config.BALL_HITSPEEDLOST));
ball.speedY = (ball.speedY * (1 - Config.BALL_HITSPEEDLOST));
ball.speedZ = (ball.speedZ * (1 - Config.BALL_HITSPEEDLOST));
ball.curveSpeed = 0;
ball.updateCurveRadians();
soundHitFrame.play();
return (true);
};
return (false);
}
private function checkGoal():Boolean{
if (Math.abs(ballX) >= (Config.FIELD_GOALWIDTH / 2)){
return (false);
};
return ((ballZ > -(Config.FIELD_GOALHEIGHT)));
}
private function checkHitNet():Boolean{
if ((((ballY > (-(Config.FIELD_GOALDEPTH) + Config.BALL_RADIUS))) && ((Math.abs(ballX) < ((Config.FIELD_GOALWIDTH / 2) - Config.BALL_RADIUS))))){
return (false);
};
ball.speedX = 0;
ball.speedY = 0;
ball.speedZ = 0;
return (true);
}
private function checkHitBoard(_arg1:Number, _arg2:Number, _arg3:Number):Boolean{
var _local10:Number;
var _local11:Number;
var _local4:Number = Math.sin((((90 - Config.BOARD_ANGLE) * Math.PI) / 180));
var _local5:Number = Math.cos((((90 - Config.BOARD_ANGLE) * Math.PI) / 180));
var _local6:Number = (((ballY + Config.FIELD_GROUNDEXTRA) * _local5) + (ballZ * _local4));
var _local7:Number = ((-((ballY + Config.FIELD_GROUNDEXTRA)) * _local4) + (ballZ * _local5));
var _local8:Number = (((_arg2 + Config.FIELD_GROUNDEXTRA) * _local5) + (_arg3 * _local4));
var _local9:Number = ((-((_arg2 + Config.FIELD_GROUNDEXTRA)) * _local4) + (_arg3 * _local5));
if ((((_local7 > 0)) || ((_local7 < -(Config.BOARD_HEIGHT))))){
return (false);
};
if (_local8 > -(Config.BALL_RADIUS)){
if (_local6 > -(Config.BALL_RADIUS)){
return (false);
};
} else {
if (_local8 > Config.BALL_RADIUS){
if (_local6 > Config.BALL_RADIUS){
return (false);
};
} else {
return (false);
};
};
_local10 = ((ball.speedY * _local5) + (ball.speedZ * _local4));
_local11 = ((-(ball.speedY) * _local4) + (ball.speedZ * _local5));
_local6 = ((-2 * Config.BALL_RADIUS) - _local6);
_local10 = -(_local10);
ballY = (((_local6 * _local5) - (_local7 * _local4)) - Config.FIELD_GROUNDEXTRA);
ballZ = ((_local6 * _local4) + (_local7 * _local5));
ball.speedY = ((_local10 * _local5) - (_local11 * _local4));
ball.speedZ = ((_local10 * _local4) + (_local11 * _local5));
ball.speedX = (ball.speedX * (1 - Config.BALL_HITSPEEDLOST));
ball.speedY = (ball.speedY * (1 - Config.BALL_HITSPEEDLOST));
ball.speedZ = (ball.speedZ * (1 - Config.BALL_HITSPEEDLOST));
ball.curveSpeed = 0;
ball.updateCurveRadians();
soundHitBoard.play();
return (true);
}
private function calculateKeeperReaction():void{
var _local1:Object;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Point;
var _local6:Number;
var _local7:Number;
if (keeperReacted){
return;
};
_local1 = estimateBallGoalPosition();
_local2 = (_local1.x - keeper.matrix.tx);
_local3 = (_local1.z - keeper.matrix.tz);
_local4 = Math.sqrt(((_local2 * _local2) + (_local3 * _local3)));
_local6 = ((_local4 / _local1.time) * 1000);
if (_local6 < Config.KEEPER_MINJUMPSPEED){
return;
};
if (_local6 > Config.KEEPER_MAXJUMPSPEED){
_local6 = Config.KEEPER_MAXJUMPSPEED;
};
_local5 = new Point(_local2, _local3);
_local5 = keeper.theMovieClip.localToGlobal(_local5);
if (!keeper.theMovieClip.hitTestPoint(_local5.x, _local5.y, true)){
_local7 = ((Math.atan2(_local2, -(_local3)) * 180) / Math.PI);
if (_local7 < -(Config.KEEPER_MAXJUMPANGLE)){
_local7 = -(Config.KEEPER_MAXJUMPANGLE);
} else {
if (_local7 > Config.KEEPER_MAXJUMPANGLE){
_local7 = Config.KEEPER_MAXJUMPANGLE;
};
};
keeper.jump((_local6 * Math.sin(((_local7 * Math.PI) / 180))), (-(_local6) * Math.cos(((_local7 * Math.PI) / 180))));
};
keeperReacted = true;
}
private function estimateBallGoalPosition():Object{
var _local7:Number;
var _local8:Number;
var _local1:Number = ballX;
var _local2:Number = ballY;
var _local3:Number = ballZ;
var _local4:Number = ball.speedX;
var _local5:Number = ball.speedY;
var _local6:Number = ball.speedZ;
var _local9:int;
while (_local5 < 0) {
_local9++;
_local7 = _local4;
_local8 = _local5;
_local1 = (_local1 + (_local4 / 1000));
_local2 = (_local2 + (_local5 / 1000));
_local3 = (_local3 + (_local6 / 1000));
_local6 = (_local6 + (Config.BALL_ACCELERATION / 1000));
_local4 = ((_local7 * ball.cosCurveRadians) - (_local8 * ball.sinCurveRadians));
_local5 = ((_local7 * ball.sinCurveRadians) + (_local8 * ball.cosCurveRadians));
if (_local2 <= Config.KEEPER_Y){
break;
};
};
if (_local3 > -(Config.BALL_RADIUS)){
_local3 = -(Config.BALL_RADIUS);
};
return ({x:_local1, z:_local3, time:_local9});
}
private function moveKeeper():void{
var _local1:ThreeDMatrix;
if (!keeperReacted){
return;
};
if ((((keeper.speedX == 0)) && ((keeper.speedZ == 0)))){
return;
};
keeper.realX = (keeper.realX + (keeper.speedX / 1000));
keeper.realZ = (keeper.realZ + (keeper.speedZ / 1000));
_local1 = new ThreeDMatrix();
_local1 = _local1.translate(keeper.realX, keeper.realY, ((keeper.realZ >= (-(Config.KEEPER_JUMPWIDTH) / 2))) ? (-(Config.KEEPER_JUMPWIDTH) / 2) : keeper.realZ);
keeper.setMatrix(_local1);
keeper.speedZ = (keeper.speedZ + (Config.KEEPER_ACCELERATION / 1000));
keeper.updateRotation();
if ((((keeper.speedZ > 0)) && ((keeper.realZ >= 0)))){
keeper.speedX = 0;
keeper.speedZ = 0;
};
}
private function getBallIsFlyingToGoal():Boolean{
var _local1:Number;
if (ballY <= 0){
return (false);
};
if (ball.speedY >= 0){
return (false);
};
_local1 = (ballX + ((ball.speedX * ballY) / ball.speedY));
return ((Math.abs(_local1) < (Config.FIELD_GOALWIDTH / 2)));
}
private function showGoal(_arg1:SimpleTimer):void{
ballTimer.stop();
goals++;
shotsRemaining--;
message.showGoal();
soundGoal.play();
new SimpleTimer(Config.MESSAGE_GOALTIME, 1, 0, startNextShot);
}
private function showMissed(_arg1:SimpleTimer=null):void{
ballTimer.stop();
shotsRemaining--;
message.showMissed();
soundMissed.play();
new SimpleTimer(Config.MESSAGE_MISSEDTIME, 1, 0, startNextShot);
}
private function startNextShot(_arg1:SimpleTimer):void{
if (shotsRemaining > 0){
startShot((Config.SHOT_TOTAL - shotsRemaining));
} else {
message.showGameOver();
Object(parent).stopGameMusic();
soundGameOver.play();
new SimpleTimer(Config.MESSAGE_GAMEOVERTIME, 1, 0, showPlayAgain);
};
}
private function showPlayAgain(_arg1:SimpleTimer):void{
var _local2:int = (Config.SCORE_GOAL * goals);
Object(parent).gameEnded({goals:goals, score:_local2});
message.showPlayAgain();
}
}
}//package com.novelgames.flashgames.freekick
Section 25
//Goal (com.novelgames.flashgames.freekick.Goal)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public class Goal extends ThreeDShape {
public function Goal(){
var _local1:Number = (Config.FIELD_GOALWIDTH / 2);
var _local2:Number = Config.FIELD_GOALHEIGHT;
var _local3:Number = (Config.FIELD_LINETHICKNESS / 2);
vertices = [new ThreeDVector((-(_local1) - _local3), _local3, (-(_local2) - _local3)), new ThreeDVector((_local1 + _local3), _local3, (-(_local2) - _local3)), new ThreeDVector((-(_local1) + _local3), _local3, (-(_local2) + _local3)), new ThreeDVector((_local1 - _local3), _local3, (-(_local2) + _local3)), new ThreeDVector((-(_local1) - _local3), _local3, 0), new ThreeDVector((-(_local1) + _local3), _local3, 0), new ThreeDVector((_local1 - _local3), _local3, 0), new ThreeDVector((_local1 + _local3), _local3, 0)];
addPlane([0, 1, 3, 2]);
addPlane([0, 2, 5, 4]);
addPlane([3, 1, 7, 6]);
addNets();
}
private function addPlane(_arg1:Array):void{
var _local2:ThreeDPlane;
var _local3:int;
_local2 = new ThreeDPlane();
_local2.hasFill = true;
_local2.fillColour = Config.FIELD_GOALPOSTCOLOUR;
_local2.vertices = new Array();
_local3 = 0;
while (_local3 < _arg1.length) {
_local2.vertices[_local3] = vertices[_arg1[_local3]];
_local3++;
};
planes.push(_local2);
}
private function addNets():void{
var _local5:Array;
var _local6:Array;
var _local7:Array;
var _local8:Array;
var _local9:Array;
var _local10:Array;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:int;
var _local1:Number = (Config.FIELD_GOALWIDTH / 2);
var _local2:Number = Config.FIELD_GOALHEIGHT;
var _local3:Number = Config.FIELD_GOALBACKHEIGHT;
var _local4:Number = Config.FIELD_GOALDEPTH;
_local5 = new Array();
_local11 = -(_local1);
while (_local11 < _local1) {
_local5.push(new ThreeDVector(_local11, 0, -(_local2)));
_local5.push(new ThreeDVector(_local11, -(_local4), -(_local3)));
_local5.push(new ThreeDVector(_local11, -(_local4), 0));
_local11 = (_local11 + Config.FIELD_GOALNETSQUARESIZE);
};
_local6 = new Array();
_local7 = new Array();
_local12 = 0;
while (_local12 > -(_local4)) {
_local6.push(new ThreeDVector(-(_local1), _local12, (-(_local2) + ((_local12 / _local4) * (_local3 - _local2)))));
_local6.push(new ThreeDVector(-(_local1), _local12, 0));
_local7.push(new ThreeDVector(_local1, _local12, (-(_local2) + ((_local12 / _local4) * (_local3 - _local2)))));
_local7.push(new ThreeDVector(_local1, _local12, 0));
_local12 = (_local12 - Config.FIELD_GOALNETSQUARESIZE);
};
_local8 = new Array();
_local13 = -(_local3);
while (_local13 < 0) {
_local8.push(new ThreeDVector(-(_local1), 0, _local13));
_local8.push(new ThreeDVector(-(_local1), -(_local4), _local13));
_local8.push(new ThreeDVector(_local1, -(_local4), _local13));
_local8.push(new ThreeDVector(_local1, 0, _local13));
_local13 = (_local13 + Config.FIELD_GOALNETSQUARESIZE);
};
vertices = vertices.concat(_local5).concat(_local6).concat(_local7).concat(_local8);
_local9 = new Array();
_local10 = new Array();
_local14 = 0;
while (_local14 < _local8.length) {
_local9.push(_local8[(_local14 + 1)]);
_local9.push(_local8[(_local14 + 2)]);
_local14 = (_local14 + 4);
};
_local14 = 0;
while (_local14 < _local5.length) {
_local10.push(_local5[(_local14 + 1)]);
_local10.push(_local5[(_local14 + 2)]);
_local14 = (_local14 + 3);
};
planes.push(new NetPlane(_local9, _local10));
_local9 = new Array();
_local10 = new Array();
_local14 = 0;
while (_local14 < _local6.length) {
_local9.push(_local6[_local14]);
_local9.push(_local7[_local14]);
_local14 = (_local14 + 2);
};
_local14 = 0;
while (_local14 < _local5.length) {
_local10.push(_local5[_local14]);
_local10.push(_local5[(_local14 + 1)]);
_local14 = (_local14 + 3);
};
planes.push(new NetPlane(_local9, _local10));
_local9 = new Array();
_local14 = 0;
while (_local14 < _local8.length) {
_local9.push(_local8[_local14]);
_local9.push(_local8[(_local14 + 1)]);
_local14 = (_local14 + 4);
};
planes.push(new NetPlane(_local9, _local6));
_local9 = new Array();
_local14 = 0;
while (_local14 < _local8.length) {
_local9.push(_local8[(_local14 + 2)]);
_local9.push(_local8[(_local14 + 3)]);
_local14 = (_local14 + 4);
};
planes.push(new NetPlane(_local9, _local7));
}
}
}//package com.novelgames.flashgames.freekick
Section 26
//Ground (com.novelgames.flashgames.freekick.Ground)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public class Ground extends ThreeDShape {
public function Ground(){
var _local1:int;
var _local2:Number;
var _local4:ThreeDPlane;
var _local5:int;
var _local6:int;
super();
_local1 = Math.ceil((((Config.FIELD_HEIGHT / 2) + Config.FIELD_GROUNDEXTRA) / Config.FIELD_GROUNDSTRIPETHICKNESS));
_local2 = ((Config.FIELD_WIDTH / 2) + Config.FIELD_GROUNDEXTRA);
var _local3:Number = -(Config.FIELD_GROUNDEXTRA);
vertices = new Array();
planes = new Array();
vertices.push(new ThreeDVector(-(_local2), _local3, 0));
vertices.push(new ThreeDVector(_local2, _local3, 0));
_local3 = (_local3 + Config.FIELD_GROUNDSTRIPETHICKNESS);
_local5 = 0;
while (_local5 < _local1) {
vertices.push(new ThreeDVector(-(_local2), _local3, 0));
vertices.push(new ThreeDVector(_local2, _local3, 0));
_local3 = (_local3 + Config.FIELD_GROUNDSTRIPETHICKNESS);
_local4 = new ThreeDPlane();
_local4.hasFill = true;
_local4.fillColour = Config.FIELD_GROUNDCOLOURS[(_local5 % Config.FIELD_GROUNDCOLOURS.length)];
_local4.vertices = [vertices[(_local5 * 2)], vertices[((_local5 * 2) + 1)], vertices[((_local5 * 2) + 3)], vertices[((_local5 * 2) + 2)]];
planes.push(_local4);
_local5++;
};
}
}
}//package com.novelgames.flashgames.freekick
Section 27
//Keeper (com.novelgames.flashgames.freekick.Keeper)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public class Keeper extends ThreeDBillboard {
public var theMovieClip:MovieClip;
public var realX:Number;
public var realY:Number;
public var realZ:Number;
public var speedX:Number;
public var speedZ:Number;
public function Keeper(){
plane.className = "com.novelgames.flashgames.freekick.KeeperGraphic";
}
public function initialize():void{
theMovieClip = plane.billboardMovieClip;
realX = matrix.tx;
realY = matrix.ty;
realZ = matrix.tz;
speedX = 0;
speedZ = 0;
theMovieClip.gotoAndStop("normal");
theMovieClip.rotation = 0;
}
public function jump(_arg1:Number, _arg2:Number):void{
this.speedX = _arg1;
this.speedZ = _arg2;
theMovieClip.gotoAndStop("jump");
updateRotation();
}
public function updateRotation():void{
var _local1:Number;
if (speedZ >= 0){
theMovieClip.rotation = ((speedX > 0)) ? 90 : -90;
return;
};
_local1 = Math.atan2(speedX, -(speedZ));
theMovieClip.rotation = ((_local1 * 180) / Math.PI);
}
}
}//package com.novelgames.flashgames.freekick
Section 28
//KeeperGraphic (com.novelgames.flashgames.freekick.KeeperGraphic)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public dynamic class KeeperGraphic extends MovieClip {
}
}//package com.novelgames.flashgames.freekick
Section 29
//Main (com.novelgames.flashgames.freekick.Main)
package com.novelgames.flashgames.freekick {
import com.novelgames.flashgames.common.*;
import mochi.as3.*;
import flash.media.*;
public class Main extends MainDevelopment {
public var title:Title;
public function Main(){
addFrameScript(0, frame1);
}
override protected function getTitle():Title{
return (title);
}
override protected function getGame():Game{
return (new Game());
}
override protected function getMusicGame():Sound{
return (new MusicGame());
}
override protected function getButtonSoundOver():Sound{
return (new ButtonSoundOver());
}
override protected function getButtonSoundClick():Sound{
return (new ButtonSoundClick());
}
function frame1(){
MochiServices.connect("0d4913d5f1ad5c28", root);
}
}
}//package com.novelgames.flashgames.freekick
Section 30
//ManWall (com.novelgames.flashgames.freekick.ManWall)
package com.novelgames.flashgames.freekick {
public class ManWall extends ThreeDBillboard {
public function ManWall(){
plane.className = "com.novelgames.flashgames.freekick.ManWallGraphic";
}
public function initialize(_arg1:int):void{
plane.billboardMovieClip.gotoAndStop((_arg1 + 1));
}
}
}//package com.novelgames.flashgames.freekick
Section 31
//ManWallGraphic (com.novelgames.flashgames.freekick.ManWallGraphic)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public dynamic class ManWallGraphic extends MovieClip {
}
}//package com.novelgames.flashgames.freekick
Section 32
//Message (com.novelgames.flashgames.freekick.Message)
package com.novelgames.flashgames.freekick {
import flash.display.*;
import flash.events.*;
public class Message extends MovieClip {
public function Message(){
stop();
}
public function hide():void{
gotoAndStop("hide");
}
public function showGoal():void{
gotoAndStop("goal");
}
public function showMissed():void{
gotoAndStop("missed");
}
public function showGameOver():void{
gotoAndStop("gameOver");
}
public function showPlayAgain():void{
var _local1:MessagePlayAgain = new MessagePlayAgain();
hide();
_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();
}
private function homeButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).gotoTitlePage();
}
}
}//package com.novelgames.flashgames.freekick
Section 33
//MessagePlayAgain (com.novelgames.flashgames.freekick.MessagePlayAgain)
package com.novelgames.flashgames.freekick {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public dynamic class MessagePlayAgain extends MovieClip {
public var playAgainButton:SimpleButton;
public var homeButton:SimpleButton;
public var sitebutton:SimpleButton;
public function MessagePlayAgain(){
addFrameScript(0, frame1);
}
public function siteClicked(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.2dfootballgames.com"), "_blank");
}
function frame1(){
sitebutton.addEventListener(MouseEvent.CLICK, siteClicked);
}
}
}//package com.novelgames.flashgames.freekick
Section 34
//MusicGame (com.novelgames.flashgames.freekick.MusicGame)
package com.novelgames.flashgames.freekick {
import com.novelgames.flashgames.common.*;
public dynamic class MusicGame extends NewMusic {
}
}//package com.novelgames.flashgames.freekick
Section 35
//NetPlane (com.novelgames.flashgames.freekick.NetPlane)
package com.novelgames.flashgames.freekick {
import flash.display.*;
import flash.geom.*;
public class NetPlane extends ThreeDPlane {
public var horizontalVertices:Array;
public var verticalVertices:Array;
public function NetPlane(_arg1:Array, _arg2:Array){
this.horizontalVertices = _arg1;
this.verticalVertices = _arg2;
}
override public function updateAverageTransformedXYZ():void{
var _local3:Number;
var _local1:Number = 0;
var _local2:Number = 0;
_local3 = 0;
_local1 = (_local1 + verticalVertices[0].transformedX);
_local2 = (_local2 + verticalVertices[0].transformedY);
_local3 = (_local3 + verticalVertices[0].transformedZ);
_local1 = (_local1 + verticalVertices[1].transformedX);
_local2 = (_local2 + verticalVertices[1].transformedY);
_local3 = (_local3 + verticalVertices[1].transformedZ);
_local1 = (_local1 + verticalVertices[(verticalVertices.length - 2)].transformedX);
_local2 = (_local2 + verticalVertices[(verticalVertices.length - 2)].transformedY);
_local3 = (_local3 + verticalVertices[(verticalVertices.length - 2)].transformedZ);
_local1 = (_local1 + verticalVertices[(verticalVertices.length - 1)].transformedX);
_local2 = (_local2 + verticalVertices[(verticalVertices.length - 1)].transformedY);
_local3 = (_local3 + verticalVertices[(verticalVertices.length - 1)].transformedZ);
averageTransformedX = (_local1 / 4);
averageTransformedY = (_local2 / 4);
averageTransformedZ = (_local3 / 4);
}
override public function draw(_arg1:Number, _arg2:Number):void{
var _local5:int;
var _local3:Array = getTransformedPoints(_arg1, _arg2, verticalVertices);
var _local4:Array = getTransformedPoints(_arg1, _arg2, horizontalVertices);
canvas.graphics.lineStyle(Config.FIELD_GOALNETTHICKNESS, Config.FIELD_GOALNETCOLOUR);
_local5 = 0;
while (_local5 < _local3.length) {
canvas.graphics.moveTo(_local3[_local5].x, _local3[_local5].y);
canvas.graphics.lineTo(_local3[(_local5 + 1)].x, _local3[(_local5 + 1)].y);
_local5 = (_local5 + 2);
};
_local5 = 0;
while (_local5 < _local4.length) {
canvas.graphics.moveTo(_local4[_local5].x, _local4[_local5].y);
canvas.graphics.lineTo(_local4[(_local5 + 1)].x, _local4[(_local5 + 1)].y);
_local5 = (_local5 + 2);
};
}
private function getTransformedPoints(_arg1:Number, _arg2:Number, _arg3:Array):Array{
var _local5:int;
var _local4:Array = new Array();
_local5 = 0;
while (_local5 < _arg3.length) {
if (_arg3[_local5].transformedZ < _arg2){
return (_local4);
};
_local5++;
};
_local5 = 0;
while (_local5 < _arg3.length) {
_local4[_local5] = new Point(((_arg3[_local5].transformedX * (_arg1 - _arg2)) / (_arg3[_local5].transformedZ - _arg2)), ((_arg3[_local5].transformedY * (_arg1 - _arg2)) / (_arg3[_local5].transformedZ - _arg2)));
_local5++;
};
return (_local4);
}
}
}//package com.novelgames.flashgames.freekick
Section 36
//Player (com.novelgames.flashgames.freekick.Player)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public class Player extends ThreeDBillboard {
private var theMovieClip:MovieClip;
public function Player(){
plane.className = "com.novelgames.flashgames.freekick.PlayerGraphic";
}
public function initialize():void{
theMovieClip = plane.billboardMovieClip;
theMovieClip.gotoAndStop(1);
}
public function showKick(_arg1:Number):void{
theMovieClip.gotoAndStop((Math.floor((_arg1 * theMovieClip.totalFrames)) + 1));
}
}
}//package com.novelgames.flashgames.freekick
Section 37
//PlayerGraphic (com.novelgames.flashgames.freekick.PlayerGraphic)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public dynamic class PlayerGraphic extends MovieClip {
}
}//package com.novelgames.flashgames.freekick
Section 38
//SoundGameOver (com.novelgames.flashgames.freekick.SoundGameOver)
package com.novelgames.flashgames.freekick {
import com.novelgames.flashgames.common.*;
public dynamic class SoundGameOver extends NewSound {
}
}//package com.novelgames.flashgames.freekick
Section 39
//SoundGoal (com.novelgames.flashgames.freekick.SoundGoal)
package com.novelgames.flashgames.freekick {
import com.novelgames.flashgames.common.*;
public dynamic class SoundGoal extends NewSound {
}
}//package com.novelgames.flashgames.freekick
Section 40
//SoundHitBoard (com.novelgames.flashgames.freekick.SoundHitBoard)
package com.novelgames.flashgames.freekick {
import com.novelgames.flashgames.common.*;
public dynamic class SoundHitBoard extends NewSound {
}
}//package com.novelgames.flashgames.freekick
Section 41
//SoundHitFrame (com.novelgames.flashgames.freekick.SoundHitFrame)
package com.novelgames.flashgames.freekick {
import com.novelgames.flashgames.common.*;
public dynamic class SoundHitFrame extends NewSound {
}
}//package com.novelgames.flashgames.freekick
Section 42
//SoundHitMan (com.novelgames.flashgames.freekick.SoundHitMan)
package com.novelgames.flashgames.freekick {
import com.novelgames.flashgames.common.*;
public dynamic class SoundHitMan extends NewSound {
}
}//package com.novelgames.flashgames.freekick
Section 43
//SoundKick (com.novelgames.flashgames.freekick.SoundKick)
package com.novelgames.flashgames.freekick {
import com.novelgames.flashgames.common.*;
public dynamic class SoundKick extends NewSound {
}
}//package com.novelgames.flashgames.freekick
Section 44
//SoundMissed (com.novelgames.flashgames.freekick.SoundMissed)
package com.novelgames.flashgames.freekick {
import com.novelgames.flashgames.common.*;
public dynamic class SoundMissed extends NewSound {
}
}//package com.novelgames.flashgames.freekick
Section 45
//SoundSelect (com.novelgames.flashgames.freekick.SoundSelect)
package com.novelgames.flashgames.freekick {
import com.novelgames.flashgames.common.*;
public dynamic class SoundSelect extends NewSound {
}
}//package com.novelgames.flashgames.freekick
Section 46
//SoundWhistle (com.novelgames.flashgames.freekick.SoundWhistle)
package com.novelgames.flashgames.freekick {
import com.novelgames.flashgames.common.*;
public dynamic class SoundWhistle extends NewSound {
}
}//package com.novelgames.flashgames.freekick
Section 47
//ThreeDBillboard (com.novelgames.flashgames.freekick.ThreeDBillboard)
package com.novelgames.flashgames.freekick {
public class ThreeDBillboard extends ThreeDObject {
public var vertex:ThreeDVector;
public var plane:ThreeDBillboardPlane;
public function ThreeDBillboard(){
vertex = new ThreeDVector(0, 0, 0);
plane = new ThreeDBillboardPlane();
plane.vertices = [vertex];
}
public function setPosition(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:ThreeDMatrix = new ThreeDMatrix();
_local4 = _local4.translate(_arg1, _arg2, _arg3);
setMatrix(_local4);
}
override public function getPlanes():Array{
return ([plane]);
}
override public function getPlanesForDrawing():Array{
var _local2:int;
var _local1:Array = new Array();
if (!visible){
return (_local1);
};
if (!plane.visible){
return (_local1);
};
vertex.updateTransformedXYZ(concatenatedMatrix);
plane.updateAverageTransformedXYZ();
_local1.push(plane);
return (_local1);
}
}
}//package com.novelgames.flashgames.freekick
Section 48
//ThreeDBillboardPlane (com.novelgames.flashgames.freekick.ThreeDBillboardPlane)
package com.novelgames.flashgames.freekick {
import flash.display.*;
import flash.utils.*;
public class ThreeDBillboardPlane extends ThreeDPlane {
public var className:String;
public var billboardMovieClip:MovieClip;
override public function setCanvas(_arg1:MovieClip):void{
var _local2:Class;
super.setCanvas(_arg1);
if (className != null){
_local2 = Class(getDefinitionByName(className));
billboardMovieClip = new (_local2);
_arg1.addChild(billboardMovieClip);
billboardMovieClip.visible = false;
};
}
override public function draw(_arg1:Number, _arg2:Number):void{
var _local3:Number = ((_arg1 - _arg2) / (vertices[0].transformedZ - _arg2));
billboardMovieClip.x = (vertices[0].transformedX * _local3);
billboardMovieClip.y = (vertices[0].transformedY * _local3);
billboardMovieClip.scaleX = _local3;
billboardMovieClip.scaleY = _local3;
billboardMovieClip.visible = true;
}
}
}//package com.novelgames.flashgames.freekick
Section 49
//ThreeDCurvedPlane (com.novelgames.flashgames.freekick.ThreeDCurvedPlane)
package com.novelgames.flashgames.freekick {
import flash.display.*;
import flash.geom.*;
public class ThreeDCurvedPlane extends ThreeDPlane {
override public function draw(_arg1:Number, _arg2:Number):void{
var _local3:Array;
var _local4:int;
if (this.vertices.length == 0){
return;
};
_local3 = getPoints(_arg1, _arg2);
if (_local3.length == 0){
return;
};
if (this.hasLine){
canvas.graphics.lineStyle(this.lineThickness, this.lineColour);
} else {
canvas.graphics.lineStyle();
};
if (this.hasFill){
canvas.graphics.beginFill(this.fillColour, this.fillAlpha);
};
canvas.graphics.moveTo(_local3[0].x, _local3[0].y);
_local4 = 0;
while (_local4 < _local3.length) {
canvas.graphics.curveTo(_local3[(_local4 + 1)].x, _local3[(_local4 + 1)].y, _local3[((_local4 + 2) % _local3.length)].x, _local3[((_local4 + 2) % _local3.length)].y);
_local4 = (_local4 + 2);
};
if (this.hasFill){
canvas.graphics.endFill();
};
}
}
}//package com.novelgames.flashgames.freekick
Section 50
//ThreeDMatrix (com.novelgames.flashgames.freekick.ThreeDMatrix)
package com.novelgames.flashgames.freekick {
public class ThreeDMatrix {
public var a:Number;
public var b:Number;
public var c:Number;
public var d:Number;
public var e:Number;
public var f:Number;
public var g:Number;
public var h:Number;
public var i:Number;
public var tx:Number;
public var ty:Number;
public var tz:Number;
public function ThreeDMatrix(){
b = (c = (d = (f = (g = (h = (tx = (ty = (tz = 0))))))));
a = (e = (i = 1));
}
public function multiplyVector(_arg1:ThreeDVector):ThreeDVector{
var _local2:Number = ((((_arg1.x * a) + (_arg1.y * d)) + (_arg1.z * g)) + tx);
var _local3:Number = ((((_arg1.x * b) + (_arg1.y * e)) + (_arg1.z * h)) + ty);
var _local4:Number = ((((_arg1.x * c) + (_arg1.y * f)) + (_arg1.z * i)) + tz);
return (new ThreeDVector(_local2, _local3, _local4));
}
public function multiplyDirection(_arg1:ThreeDVector):ThreeDVector{
var _local2:Number = (((_arg1.x * a) + (_arg1.y * d)) + (_arg1.z * g));
var _local3:Number = (((_arg1.x * b) + (_arg1.y * e)) + (_arg1.z * h));
var _local4:Number = (((_arg1.x * c) + (_arg1.y * f)) + (_arg1.z * i));
return (new ThreeDVector(_local2, _local3, _local4));
}
public function multiplyMatrix(_arg1:ThreeDMatrix):ThreeDMatrix{
var _local2:ThreeDMatrix = new ThreeDMatrix();
_local2.a = (((a * _arg1.a) + (d * _arg1.b)) + (g * _arg1.c));
_local2.b = (((b * _arg1.a) + (e * _arg1.b)) + (h * _arg1.c));
_local2.c = (((c * _arg1.a) + (f * _arg1.b)) + (i * _arg1.c));
_local2.d = (((a * _arg1.d) + (d * _arg1.e)) + (g * _arg1.f));
_local2.e = (((b * _arg1.d) + (e * _arg1.e)) + (h * _arg1.f));
_local2.f = (((c * _arg1.d) + (f * _arg1.e)) + (i * _arg1.f));
_local2.g = (((a * _arg1.g) + (d * _arg1.h)) + (g * _arg1.i));
_local2.h = (((b * _arg1.g) + (e * _arg1.h)) + (h * _arg1.i));
_local2.i = (((c * _arg1.g) + (f * _arg1.h)) + (i * _arg1.i));
_local2.tx = ((((a * _arg1.tx) + (d * _arg1.ty)) + (g * _arg1.tz)) + tx);
_local2.ty = ((((b * _arg1.tx) + (e * _arg1.ty)) + (h * _arg1.tz)) + ty);
_local2.tz = ((((c * _arg1.tx) + (f * _arg1.ty)) + (i * _arg1.tz)) + tz);
return (_local2);
}
public function getDeterminant():Number{
return ((((((((a * e) * i) + ((d * h) * c)) + ((g * b) * f)) - ((c * e) * g)) - ((f * h) * a)) - ((i * b) * d)));
}
public function getInverse():ThreeDMatrix{
var _local1:ThreeDMatrix = new ThreeDMatrix();
var _local2:Number = getDeterminant();
_local1.a = (((e * i) - (f * h)) / _local2);
_local1.b = (((h * c) - (b * i)) / _local2);
_local1.c = (((b * f) - (c * e)) / _local2);
_local1.d = (((f * g) - (d * i)) / _local2);
_local1.e = (((a * i) - (c * g)) / _local2);
_local1.f = (((c * d) - (a * f)) / _local2);
_local1.g = (((d * h) - (e * g)) / _local2);
_local1.h = (((g * b) - (a * h)) / _local2);
_local1.i = (((a * e) - (b * d)) / _local2);
_local1.tx = (((-(tx) * _local1.a) - (ty * _local1.d)) - (tz * _local1.g));
_local1.ty = (((-(tx) * _local1.b) - (ty * _local1.e)) - (tz * _local1.h));
_local1.tz = (((-(tx) * _local1.c) - (ty * _local1.f)) - (tz * _local1.i));
return (_local1);
}
public function translate(_arg1:Number, _arg2:Number, _arg3:Number):ThreeDMatrix{
var _local4:ThreeDMatrix = new ThreeDMatrix();
_local4.tx = _arg1;
_local4.ty = _arg2;
_local4.tz = _arg3;
return (_local4.multiplyMatrix(this));
}
public function rotateX(_arg1:Number):ThreeDMatrix{
var _local2:ThreeDMatrix = new ThreeDMatrix();
_local2.e = Math.cos(_arg1);
_local2.f = Math.sin(_arg1);
_local2.h = -(_local2.f);
_local2.i = _local2.e;
return (_local2.multiplyMatrix(this));
}
public function rotateY(_arg1:Number):ThreeDMatrix{
var _local2:ThreeDMatrix = new ThreeDMatrix();
_local2.a = Math.cos(_arg1);
_local2.c = -(Math.sin(_arg1));
_local2.g = -(_local2.c);
_local2.i = _local2.a;
return (_local2.multiplyMatrix(this));
}
public function rotateZ(_arg1:Number):ThreeDMatrix{
var _local2:ThreeDMatrix = new ThreeDMatrix();
_local2.a = Math.cos(_arg1);
_local2.b = Math.sin(_arg1);
_local2.d = -(_local2.b);
_local2.e = _local2.a;
return (_local2.multiplyMatrix(this));
}
public function rotate(_arg1:Number, _arg2:ThreeDVector, _arg3:ThreeDVector):ThreeDMatrix{
var _local4:Number = Math.sqrt((((_arg2.x * _arg2.x) + (_arg2.y * _arg2.y)) + (_arg2.z * _arg2.z)));
var _local5:Number = (_arg2.x / _local4);
var _local6:Number = (_arg2.y / _local4);
var _local7:Number = (_arg2.z / _local4);
var _local8:Number = Math.cos(_arg1);
var _local9:Number = Math.sin(_arg1);
var _local10:ThreeDMatrix = new ThreeDMatrix();
var _local11:ThreeDMatrix = new ThreeDMatrix();
var _local12:ThreeDMatrix = new ThreeDMatrix();
_local10.tx = _arg3.x;
_local10.ty = _arg3.y;
_local10.tz = _arg3.z;
_local11.tx = -(_arg3.x);
_local11.ty = -(_arg3.y);
_local11.tz = -(_arg3.z);
_local12.a = ((_local5 * _local5) + ((1 - (_local5 * _local5)) * _local8));
_local12.b = (((_local5 * _local6) * (1 - _local8)) + (_local7 * _local9));
_local12.c = (((_local5 * _local7) * (1 - _local8)) - (_local6 * _local9));
_local12.d = (((_local5 * _local6) * (1 - _local8)) - (_local7 * _local9));
_local12.e = ((_local6 * _local6) + ((1 - (_local6 * _local6)) * _local8));
_local12.f = (((_local6 * _local7) * (1 - _local8)) + (_local5 * _local9));
_local12.g = (((_local5 * _local7) * (1 - _local8)) + (_local6 * _local9));
_local12.h = (((_local6 * _local7) * (1 - _local8)) - (_local5 * _local9));
_local12.i = ((_local7 * _local7) + ((1 - (_local7 * _local7)) * _local8));
return (_local10.multiplyMatrix(_local12).multiplyMatrix(_local11).multiplyMatrix(this));
}
public function clone():ThreeDMatrix{
var _local1:ThreeDMatrix = new ThreeDMatrix();
_local1.a = a;
_local1.b = b;
_local1.c = c;
_local1.d = d;
_local1.e = e;
_local1.f = f;
_local1.g = g;
_local1.h = h;
_local1.i = i;
_local1.tx = tx;
_local1.ty = ty;
_local1.tz = tz;
return (_local1);
}
public function toString():String{
var _local1:String;
_local1 = (((((((("| " + a) + " ") + d) + " ") + g) + " ") + tx) + " |\n");
_local1 = (_local1 + (((((((("| " + b) + " ") + e) + " ") + h) + " ") + ty) + " |\n"));
_local1 = (_local1 + (((((((("| " + c) + " ") + f) + " ") + i) + " ") + tz) + " |\n"));
_local1 = (_local1 + (((((((("| " + 0) + " ") + 0) + " ") + 0) + " ") + 1) + " |\n"));
return (_local1);
}
}
}//package com.novelgames.flashgames.freekick
Section 51
//ThreeDObject (com.novelgames.flashgames.freekick.ThreeDObject)
package com.novelgames.flashgames.freekick {
public class ThreeDObject {
public var parent:ThreeDObjectContainer;
public var matrix:ThreeDMatrix;
public var concatenatedMatrix:ThreeDMatrix;
public var visible:Boolean;
public function ThreeDObject(){
parent = null;
matrix = new ThreeDMatrix();
concatenatedMatrix = new ThreeDMatrix();
visible = true;
}
public function getPlanes():Array{
return (new Array());
}
public function getPlanesForDrawing():Array{
return (new Array());
}
public function setMatrix(_arg1:ThreeDMatrix):void{
this.matrix = _arg1;
updateConcatenatedMatrix();
}
public function updateConcatenatedMatrix():void{
if (parent == null){
concatenatedMatrix = matrix;
} else {
concatenatedMatrix = parent.concatenatedMatrix.multiplyMatrix(matrix);
};
}
public function translate(_arg1:Number, _arg2:Number, _arg3:Number):void{
setMatrix(matrix.translate(_arg1, _arg2, _arg3));
}
public function rotateX(_arg1:Number):void{
setMatrix(matrix.rotateX(_arg1));
}
public function rotateY(_arg1:Number):void{
setMatrix(matrix.rotateY(_arg1));
}
public function rotateZ(_arg1:Number):void{
setMatrix(matrix.rotateZ(_arg1));
}
public function rotate(_arg1:Number, _arg2:ThreeDVector, _arg3:ThreeDVector):void{
setMatrix(matrix.rotate(_arg1, _arg2, _arg3));
}
}
}//package com.novelgames.flashgames.freekick
Section 52
//ThreeDObjectContainer (com.novelgames.flashgames.freekick.ThreeDObjectContainer)
package com.novelgames.flashgames.freekick {
public class ThreeDObjectContainer extends ThreeDObject {
public var children:Array;
public function ThreeDObjectContainer(){
children = new Array();
}
override public function getPlanes():Array{
var _local2:int;
var _local1:Array = new Array();
_local2 = 0;
while (_local2 < children.length) {
_local1 = _local1.concat(children[_local2].getPlanes());
_local2++;
};
return (_local1);
}
override public function getPlanesForDrawing():Array{
var _local2:int;
var _local1:Array = new Array();
if (!visible){
return (_local1);
};
_local2 = 0;
while (_local2 < children.length) {
_local1 = _local1.concat(children[_local2].getPlanesForDrawing());
_local2++;
};
return (_local1);
}
override public function updateConcatenatedMatrix():void{
var _local1:int;
super.updateConcatenatedMatrix();
_local1 = 0;
while (_local1 < children.length) {
children[_local1].updateConcatenatedMatrix();
_local1++;
};
}
public function addChild(_arg1:ThreeDObject):void{
_arg1.parent = this;
children.push(_arg1);
_arg1.updateConcatenatedMatrix();
}
}
}//package com.novelgames.flashgames.freekick
Section 53
//ThreeDObjectViewer (com.novelgames.flashgames.freekick.ThreeDObjectViewer)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public class ThreeDObjectViewer extends MovieClip {
public var threeDObject:ThreeDObject;
public var projectionPlaneZ:Number;
public var projectionEyeZ:Number;
public var sortPlaneTolerance:Number;
public var separateIntoMovieClips:Boolean;
public function setObject(_arg1:ThreeDObject, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Boolean):void{
var _local6:Array;
var _local7:MovieClip;
var _local8:int;
this.threeDObject = _arg1;
this.projectionPlaneZ = _arg2;
this.projectionEyeZ = _arg3;
this.sortPlaneTolerance = _arg4;
this.separateIntoMovieClips = _arg5;
_local6 = _arg1.getPlanes();
_local8 = 0;
for (;_local8 < _local6.length;_local8++) {
if (_arg5){
if (_local6[_local8].canvas != null){
continue;
};
_local7 = new MovieClip();
this.addChild(_local7);
_local6[_local8].setCanvas(_local7);
} else {
_local6[_local8].setCanvas(this);
};
};
}
public function show():void{
var _local1:Array = threeDObject.getPlanesForDrawing();
sortPlanes(_local1);
drawPlanes(_local1);
}
public function clearAll():void{
var _local1:int;
if (!separateIntoMovieClips){
this.graphics.clear();
} else {
_local1 = 0;
while (_local1 < this.numChildren) {
this.getChildAt(_local1).visible = false;
_local1++;
};
};
}
private function sortPlanes(_arg1:Array):void{
_arg1.sort(comparePlanesFunction);
}
private function comparePlanesFunction(_arg1:ThreeDPlane, _arg2:ThreeDPlane):int{
if (_arg1.averageTransformedZ > (_arg2.averageTransformedZ + sortPlaneTolerance)){
return (-1);
};
if (_arg1.averageTransformedZ < (_arg2.averageTransformedZ - sortPlaneTolerance)){
return (1);
};
if (Math.abs(_arg1.averageTransformedX) > (Math.abs(_arg2.averageTransformedX) + sortPlaneTolerance)){
return (-1);
};
if (Math.abs(_arg1.averageTransformedX) < (Math.abs(_arg2.averageTransformedX) - sortPlaneTolerance)){
return (1);
};
if (Math.abs(_arg1.averageTransformedY) > Math.abs(_arg2.averageTransformedY)){
return (-1);
};
if (Math.abs(_arg1.averageTransformedY) < Math.abs(_arg2.averageTransformedY)){
return (1);
};
return (0);
}
private function drawPlanes(_arg1:Array):void{
var _local2:MovieClip;
var _local3:int;
var _local4:int;
clearAll();
if (separateIntoMovieClips){
_local3 = 0;
while (_local3 < _arg1.length) {
_arg1[_local3].canvas.graphics.clear();
this.setChildIndex(_arg1[_local3].canvas, _local3);
_arg1[_local3].canvas.visible = true;
_local3++;
};
};
_local3 = 0;
while (_local3 < _arg1.length) {
_arg1[_local3].draw(projectionPlaneZ, projectionEyeZ);
_local3++;
};
}
}
}//package com.novelgames.flashgames.freekick
Section 54
//ThreeDPlane (com.novelgames.flashgames.freekick.ThreeDPlane)
package com.novelgames.flashgames.freekick {
import flash.display.*;
import flash.geom.*;
public class ThreeDPlane {
public var vertices:Array;
public var averageTransformedX:Number;
public var averageTransformedY:Number;
public var averageTransformedZ:Number;
public var hasFill:Boolean;
public var fillColour:uint;
public var fillAlpha:Number;
public var hasLine:Boolean;
public var lineColour:uint;
public var lineThickness:Number;
public var visible:Boolean;
public var canvas:MovieClip;
public function ThreeDPlane(){
vertices = new Array();
hasFill = false;
fillColour = 0;
fillAlpha = 1;
hasLine = false;
lineColour = 0;
lineThickness = 0;
visible = true;
canvas = null;
}
public function updateAverageTransformedXYZ():void{
var _local4:int;
var _local1:Number = 0;
var _local2:Number = 0;
var _local3:Number = 0;
_local4 = 0;
while (_local4 < vertices.length) {
_local1 = (_local1 + vertices[_local4].transformedX);
_local2 = (_local2 + vertices[_local4].transformedY);
_local3 = (_local3 + vertices[_local4].transformedZ);
_local4++;
};
averageTransformedX = (_local1 / vertices.length);
averageTransformedY = (_local2 / vertices.length);
averageTransformedZ = (_local3 / vertices.length);
}
public function setCanvas(_arg1:MovieClip):void{
this.canvas = _arg1;
}
public function draw(_arg1:Number, _arg2:Number):void{
var _local3:Array;
var _local4:int;
if (this.vertices.length == 0){
return;
};
_local3 = getPoints(_arg1, _arg2);
if (_local3.length == 0){
return;
};
if (this.hasLine){
canvas.graphics.lineStyle(this.lineThickness, this.lineColour);
} else {
canvas.graphics.lineStyle();
};
if (this.hasFill){
canvas.graphics.beginFill(this.fillColour, this.fillAlpha);
};
canvas.graphics.moveTo(_local3[0].x, _local3[0].y);
_local4 = 1;
while (_local4 < _local3.length) {
canvas.graphics.lineTo(_local3[_local4].x, _local3[_local4].y);
_local4++;
};
canvas.graphics.lineTo(_local3[0].x, _local3[0].y);
if (this.hasFill){
canvas.graphics.endFill();
};
}
protected function getPoints(_arg1:Number, _arg2:Number):Array{
var _local4:int;
var _local3:Array = new Array();
_local4 = 0;
while (_local4 < vertices.length) {
if (vertices[_local4].transformedZ < _arg2){
return (_local3);
};
_local4++;
};
_local4 = 0;
while (_local4 < vertices.length) {
_local3[_local4] = new Point(((vertices[_local4].transformedX * (_arg1 - _arg2)) / (vertices[_local4].transformedZ - _arg2)), ((vertices[_local4].transformedY * (_arg1 - _arg2)) / (vertices[_local4].transformedZ - _arg2)));
_local4++;
};
return (_local3);
}
}
}//package com.novelgames.flashgames.freekick
Section 55
//ThreeDShadow (com.novelgames.flashgames.freekick.ThreeDShadow)
package com.novelgames.flashgames.freekick {
import flash.display.*;
public class ThreeDShadow extends ThreeDShape {
public var threeDShape:ThreeDShape;
public function ThreeDShadow(_arg1:ThreeDShape, _arg2:Number, _arg3:Number){
var _local4:int;
var _local5:int;
super();
this.threeDShape = _arg1;
vertices = new Array();
_local4 = 0;
while (_local4 < _arg1.vertices.length) {
vertices[_local4] = new ThreeDVector(_arg1.vertices[_local4].x, _arg1.vertices[_local4].y, _arg1.vertices[_local4].z);
_local4++;
};
planes = new Array();
_local4 = 0;
while (_local4 < _arg1.planes.length) {
planes[_local4] = new ThreeDPlane();
planes[_local4].hasFill = true;
planes[_local4].fillColour = _arg2;
planes[_local4].fillAlpha = _arg3;
planes[_local4].vertices = new Array();
_local5 = 0;
while (_local5 < _arg1.planes[_local4].vertices.length) {
planes[_local4].vertices[_local5] = vertices[getVertexIndex(_arg1.planes[_local4].vertices[_local5])];
_local5++;
};
_local4++;
};
}
public function update():void{
var _local1:ThreeDMatrix;
var _local2:int;
_local2 = 0;
while (_local2 < threeDShape.vertices.length) {
vertices[_local2].x = threeDShape.vertices[_local2].x;
vertices[_local2].y = threeDShape.vertices[_local2].y;
vertices[_local2].z = threeDShape.vertices[_local2].z;
_local2++;
};
_local1 = new ThreeDMatrix();
_local1.i = 0;
setMatrix(_local1.multiplyMatrix(threeDShape.matrix));
}
private function getVertexIndex(_arg1:ThreeDVector):int{
var _local2:int;
_local2 = 0;
while (_local2 < threeDShape.vertices.length) {
if (_arg1 == threeDShape.vertices[_local2]){
return (_local2);
};
_local2++;
};
return (-1);
}
}
}//package com.novelgames.flashgames.freekick
Section 56
//ThreeDShape (com.novelgames.flashgames.freekick.ThreeDShape)
package com.novelgames.flashgames.freekick {
public class ThreeDShape extends ThreeDObject {
public var vertices:Array;
public var planes:Array;
public function ThreeDShape(){
vertices = new Array();
planes = new Array();
}
override public function getPlanes():Array{
return (planes);
}
override public function getPlanesForDrawing():Array{
var _local2:int;
var _local1:Array = new Array();
if (!visible){
return (_local1);
};
_local2 = 0;
while (_local2 < vertices.length) {
vertices[_local2].updateTransformedXYZ(concatenatedMatrix);
_local2++;
};
_local2 = 0;
while (_local2 < planes.length) {
if (!planes[_local2].visible){
} else {
planes[_local2].updateAverageTransformedXYZ();
_local1.push(planes[_local2]);
};
_local2++;
};
return (_local1);
}
}
}//package com.novelgames.flashgames.freekick
Section 57
//ThreeDVector (com.novelgames.flashgames.freekick.ThreeDVector)
package com.novelgames.flashgames.freekick {
public class ThreeDVector {
public var x:Number;
public var y:Number;
public var z:Number;
public var transformedX:Number;
public var transformedY:Number;
public var transformedZ:Number;
public function ThreeDVector(_arg1:Number, _arg2:Number, _arg3:Number){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
}
public function getUnitVector():ThreeDVector{
var _local1:Number = Math.sqrt((((x * x) + (y * y)) + (z * z)));
return (new ThreeDVector((x / _local1), (y / _local1), (z / _local1)));
}
public function getDotProduct(_arg1:ThreeDVector):Number{
return ((((x * _arg1.x) + (y * _arg1.y)) + (z * _arg1.z)));
}
public function getCrossProduct(_arg1:ThreeDVector):ThreeDVector{
return (new ThreeDVector(((y * _arg1.z) - (z * _arg1.y)), ((z * _arg1.x) - (x * _arg1.z)), ((x * _arg1.y) - (y * _arg1.x))));
}
public function updateTransformedXYZ(_arg1:ThreeDMatrix):void{
var _local2:ThreeDVector = _arg1.multiplyVector(this);
transformedX = _local2.x;
transformedY = _local2.y;
transformedZ = _local2.z;
}
public function toString():String{
return ((((((("(" + x) + ",") + y) + ",") + z) + ")"));
}
}
}//package com.novelgames.flashgames.freekick
Section 58
//Logo (com.novelgames.flashgames.preloader.Logo)
package com.novelgames.flashgames.preloader {
import flash.display.*;
import flash.text.*;
public dynamic class Logo extends MovieClip {
public var preloaderlink:TextField;
}
}//package com.novelgames.flashgames.preloader
Section 59
//Preloader (com.novelgames.flashgames.preloader.Preloader)
package com.novelgames.flashgames.preloader {
import flash.display.*;
import flash.events.*;
import fl.core.*;
import flash.utils.*;
import flash.net.*;
public class Preloader extends UIComponent {
private var __completeAction:String;
private var __completeLabel:String;
private var __completeFunction:String;
private var __minShowTime:Number;
private var __noOfStages:int;
private var __stageCompleteFunction:String;
private var __clickToComplete:Boolean;
private var __clickToURL:String;
private var logo:Logo;
private var logoProgressBeginFrame:int;
private var logoProgressEndFrame:int;
private var logoHasLoadFinished:Boolean;
private var logoLoadFinishedBeginFrame:int;
private var logoLoadFinishedEndFrame:int;
private var logoHasLoadFailed:Boolean;
private var logoLoadFailedBeginFrame:int;
private var logoLoadFailedEndFrame:int;
private var drawCalled:Boolean;
private var stageProgresses:Array;
private var stageCompleteds:Array;
private var startTime:Number;
private var timer:Timer;
override protected function configUI():void{
super.configUI();
__completeAction = "play";
__completeLabel = "";
__completeFunction = "";
__minShowTime = 1000;
__noOfStages = 1;
__stageCompleteFunction = "";
__clickToComplete = true;
__clickToURL = "";
Object(parent).stop();
drawCalled = false;
}
public function set completeAction(_arg1:String):void{
__completeAction = _arg1;
}
public function get completeAction():String{
return (__completeAction);
}
public function set completeLabel(_arg1:String):void{
__completeLabel = _arg1;
}
public function get completeLabel():String{
return (__completeLabel);
}
public function set completeFunction(_arg1:String):void{
__completeFunction = _arg1;
}
public function get completeFunction():String{
return (__completeFunction);
}
public function set minShowTime(_arg1:Number):void{
__minShowTime = _arg1;
}
public function get minShowTime():Number{
return (__minShowTime);
}
public function set noOfStages(_arg1:int):void{
__noOfStages = _arg1;
}
public function get noOfStages():int{
return (__noOfStages);
}
public function set stageCompleteFunction(_arg1:String):void{
__stageCompleteFunction = _arg1;
}
public function get stageCompleteFunction():String{
return (__stageCompleteFunction);
}
public function set clickToComplete(_arg1:Boolean):void{
__clickToComplete = _arg1;
}
public function get clickToComplete():Boolean{
return (__clickToComplete);
}
public function set clickToURL(_arg1:String):void{
__clickToURL = _arg1;
}
public function get clickToURL():String{
return (__clickToURL);
}
public function setProgress(_arg1:int, _arg2:Number):void{
if (!drawCalled){
draw();
};
if ((((_arg1 == 0)) || ((_arg1 >= stageProgresses.length)))){
return;
};
if (_arg2 < 0){
_arg2 = 0;
};
if (_arg2 > 1){
_arg2 = 1;
};
stageProgresses[_arg1] = _arg2;
}
public function showLoadFailed():void{
if (!drawCalled){
draw();
};
timer.stop();
if (logoHasLoadFailed){
logo.gotoAndPlay("loadFailedBegin");
logo.addEventListener(Event.ENTER_FRAME, onLoadFailedEnterFrame);
};
}
override protected function draw():void{
var _local1:int;
var _local2:int;
if (drawCalled){
return;
};
drawCalled = true;
stageProgresses = new Array();
stageCompleteds = new Array();
_local2 = 0;
while (_local2 < noOfStages) {
stageProgresses[_local2] = 0;
stageCompleteds[_local2] = false;
_local2++;
};
logo = new Logo();
logo.gotoAndStop("progressBegin");
logoProgressBeginFrame = logo.currentFrame;
logo.gotoAndStop("progressEnd");
logoProgressEndFrame = logo.currentFrame;
_local1 = logo.currentFrame;
logo.gotoAndStop("loadFinishedBegin");
if (logo.currentFrame == _local1){
logoHasLoadFinished = false;
} else {
logoHasLoadFinished = true;
logoLoadFinishedBeginFrame = logo.currentFrame;
logo.gotoAndStop("loadFinishedEnd");
logoLoadFinishedEndFrame = logo.currentFrame;
_local1 = logo.currentFrame;
};
logo.gotoAndStop("loadFailedBegin");
if (logo.currentFrame == _local1){
logoHasLoadFailed = false;
} else {
logoHasLoadFailed = true;
logoLoadFailedBeginFrame = logo.currentFrame;
logo.gotoAndStop("loadFailedEnd");
logoLoadFailedEndFrame = logo.currentFrame;
};
logo.gotoAndStop("progressBegin");
this.addChild(logo);
if (clickToURL != ""){
this.addEventListener(MouseEvent.MOUSE_DOWN, onLoadingMouseDown);
};
startTime = getTimer();
timer = new Timer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onLoadTime);
timer.start();
}
private function onLoadingMouseDown(_arg1:MouseEvent):void{
if (clickToURL != ""){
navigateToURL(new URLRequest(clickToURL), "_blank");
};
}
private function onLoadTime(_arg1:TimerEvent):void{
var _local2:Number;
_arg1.updateAfterEvent();
_local2 = (root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal);
stageProgresses[0] = _local2;
updateProgress();
}
private function updateProgress():void{
var _local1:Number;
var _local3:int;
var _local4:int;
var _local2:Number = 0;
_local1 = ((getTimer() - startTime) / minShowTime);
if (_local1 > 1){
_local1 = 1;
};
_local4 = 0;
while (_local4 < stageProgresses.length) {
_local2 = (_local2 + stageProgresses[_local4]);
_local4++;
};
_local2 = (_local2 / stageProgresses.length);
_local2 = (_local2 * _local1);
_local3 = (logoProgressBeginFrame + Math.floor((((logoProgressEndFrame - logoProgressBeginFrame) + 1) * _local2)));
if (_local3 > logoProgressEndFrame){
_local3 = logoProgressEndFrame;
};
logo.gotoAndStop(_local3);
if (logo.percentText){
logo.percentText.text = Math.floor((_local2 * 100)).toString();
};
_local4 = 0;
while (_local4 < stageProgresses.length) {
if (stageProgresses[_local4] != 1){
} else {
if (stageCompleteds[_local4]){
} else {
stageCompleteds[_local4] = true;
if (stageCompleteFunction != ""){
var _local5 = Object(parent);
_local5[stageCompleteFunction](_local4);
};
};
};
_local4++;
};
if (_local2 >= 1){
timer.stop();
if (logoHasLoadFinished){
logo.gotoAndPlay("loadFinishedBegin");
logo.addEventListener(Event.ENTER_FRAME, onLoadFinishedEnterFrame);
if (clickToComplete){
this.addEventListener(MouseEvent.MOUSE_DOWN, onLoadFinishedMouseDown);
};
} else {
preloaderCompleted();
};
};
}
private function onLoadFinishedEnterFrame(_arg1:Event=null):void{
if (logo.currentFrame != (logoLoadFinishedEndFrame + 1)){
return;
};
logo.removeEventListener(Event.ENTER_FRAME, onLoadFinishedEnterFrame);
if (clickToComplete){
this.removeEventListener(MouseEvent.MOUSE_DOWN, onLoadFinishedMouseDown);
};
logo.gotoAndStop(logoLoadFinishedEndFrame);
preloaderCompleted();
}
private function onLoadFinishedMouseDown(_arg1:MouseEvent):void{
if (clickToComplete){
logo.gotoAndStop((logoLoadFinishedEndFrame + 1));
onLoadFinishedEnterFrame();
};
}
private function preloaderCompleted():void{
visible = false;
switch (completeAction){
case "doNothing":
break;
case "play":
Object(parent).play();
break;
case "gotoAndPlay":
Object(parent).gotoAndPlay(completeLabel);
break;
case "gotoAndStop":
Object(parent).gotoAndStop(completeLabel);
break;
case "callFunction":
var _local1 = Object(parent);
_local1[completeFunction]();
break;
};
}
private function onLoadFailedEnterFrame(_arg1:Event):void{
if (logo.currentFrame != (logoLoadFailedEndFrame + 1)){
return;
};
logo.removeEventListener(Event.ENTER_FRAME, onLoadFailedEnterFrame);
logo.gotoAndStop(logoLoadFailedEndFrame);
}
}
}//package com.novelgames.flashgames.preloader
Section 60
//BaseButton (fl.controls.BaseButton)
package fl.controls {
import flash.display.*;
import flash.events.*;
import fl.core.*;
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 61
//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 62
//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 63
//LabelButton (fl.controls.LabelButton)
package fl.controls {
import flash.display.*;
import flash.events.*;
import fl.core.*;
import fl.managers.*;
import fl.events.*;
import flash.text.*;
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 64
//ComponentShim (fl.core.ComponentShim)
package fl.core {
import flash.display.*;
public dynamic class ComponentShim extends MovieClip {
}
}//package fl.core
Section 65
//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 66
//UIComponent (fl.core.UIComponent)
package fl.core {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import fl.managers.*;
import fl.events.*;
import flash.text.*;
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 67
//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 68
//FocusManager (fl.managers.FocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
import flash.events.*;
import fl.core.*;
import flash.utils.*;
import flash.text.*;
import flash.ui.*;
public class FocusManager implements IFocusManager {
private var focusableObjects:Dictionary;
private var _showFocusIndicator:Boolean;// = true
private var defButton:Button;
private var focusableCandidates:Array;
private var _form:DisplayObjectContainer;
private var _defaultButtonEnabled:Boolean;// = true
private var activated:Boolean;// = false
private var _defaultButton:Button;
private var calculateCandidates:Boolean;// = true
private var lastFocus:InteractiveObject;
private var lastAction:String;
public function FocusManager(_arg1:DisplayObjectContainer){
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 69
//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 70
//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 71
//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 72
//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 73
//MochiCoins (mochi.as3.MochiCoins)
package mochi.as3 {
public class MochiCoins {
public static const STORE_SHOW:String = "StoreShow";
public static const STORE_HIDE:String = "StoreHide";
public static const ITEM_OWNED:String = "ItemOwned";
public static const ITEM_NEW:String = "ItemNew";
public static const STORE_ITEMS:String = "StoreItems";
public static const ERROR:String = "Error";
public static const IO_ERROR:String = "IOError";
public static const NO_USER:String = "NoUser";
public static var _inventory:MochiInventory;
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public static function get inventory():MochiInventory{
return (_inventory);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function showStore(_arg1:Object=null):void{
MochiServices.setContainer();
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.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showItem", {options:_arg1}, null, null);
}
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.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showVideo", {options:_arg1}, null, null);
}
public static function getStoreItems():void{
MochiServices.send("coins_getStoreItems");
}
public static function requestFunding(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_requestFunding", _arg1);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
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);
}
addEventListener(MochiSocial.LOGGED_IN, function (_arg1:Object):void{
_inventory = new MochiInventory();
});
addEventListener(MochiSocial.LOGGED_OUT, function (_arg1:Object):void{
_inventory = null;
});
}
}//package mochi.as3
Section 74
//MochiDigits (mochi.as3.MochiDigits)
package mochi.as3 {
public final class MochiDigits {
private var Fragment:Number;
private var Sibling:MochiDigits;
private var Encoder:Number;
public function MochiDigits(_arg1:Number=0, _arg2:uint=0):void{
Encoder = 0;
setValue(_arg1, _arg2);
}
public function get value():Number{
return (Number(this.toString()));
}
public function set value(_arg1:Number):void{
setValue(_arg1);
}
public function addValue(_arg1:Number):void{
value = (value + _arg1);
}
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 reencode():void{
var _local1:uint = int((2147483647 * Math.random()));
Fragment = (Fragment ^ (_local1 ^ Encoder));
Encoder = _local1;
}
public function toString():String{
var _local1:String = String.fromCharCode((Fragment ^ Encoder));
if (Sibling != null){
_local1 = (_local1 + Sibling.toString());
};
return (_local1);
}
}
}//package mochi.as3
Section 75
//MochiEventDispatcher (mochi.as3.MochiEventDispatcher)
package mochi.as3 {
public class MochiEventDispatcher {
private var eventTable:Object;
public function MochiEventDispatcher():void{
eventTable = {};
}
public function addEventListener(_arg1:String, _arg2:Function):void{
removeEventListener(_arg1, _arg2);
eventTable[_arg1].push(_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 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);
};
}
}
}//package mochi.as3
Section 76
//MochiEvents (mochi.as3.MochiEvents)
package mochi.as3 {
import flash.display.*;
public class MochiEvents {
public static const ACHIEVEMENT_RECEIVED:String = "AchievementReceived";
public static const ALIGN_TOP_LEFT:String = "ALIGN_TL";
public static const ALIGN_TOP:String = "ALIGN_T";
public static const ALIGN_TOP_RIGHT:String = "ALIGN_TR";
public static const ALIGN_LEFT:String = "ALIGN_L";
public static const ALIGN_CENTER:String = "ALIGN_C";
public static const ALIGN_RIGHT:String = "ALIGN_R";
public static const ALIGN_BOTTOM_LEFT:String = "ALIGN_BL";
public static const ALIGN_BOTTOM:String = "ALIGN_B";
public static const ALIGN_BOTTOM_RIGHT:String = "ALIGN_BR";
public static const FORMAT_SHORT:String = "ShortForm";
public static const FORMAT_LONG:String = "LongForm";
private static var gameStart:Number;
private static var levelStart:Number;
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function startSession(_arg1:String):void{
MochiServices.send("events_beginSession", {achievementID:_arg1}, null, null);
}
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 addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
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 startPlay(_arg1:String="gameplay"):void{
MochiServices.send("events_setRoundID", {tag:String(_arg1)}, null, null);
}
public static function endPlay():void{
MochiServices.send("events_clearRoundID", null, null, null);
}
public static function trackEvent(_arg1:String, _arg2=null):void{
MochiServices.send("events_trackEvent", {tag:_arg1, value:_arg2}, null, null);
}
}
}//package mochi.as3
Section 77
//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 _consumableProperties:Object;
private var _syncPending:Boolean;
private var _outstandingID:Number;
private var _syncID:Number;
private var _names:Array;
private var _storeSync:Object;
private static const CONSUMER_KEY:String = "MochiConsumables";
private static const KEY_SALT:String = " syncMaint";
public static const READY:String = "InvReady";
public static const WRITTEN:String = "InvWritten";
public static const ERROR:String = "Error";
public static const IO_ERROR:String = "IoError";
public static const VALUE_ERROR:String = "InvValueError";
public static const NOT_READY:String = "InvNotReady";
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();
};
}
public function release():void{
MochiCoins.removeEventListener(MochiCoins.ITEM_NEW, newItems);
MochiSocial.removeEventListener(MochiSocial.LOGGED_IN, loggedIn);
MochiSocial.removeEventListener(MochiSocial.LOGGED_OUT, loggedOut);
}
private function loggedOut(_arg1:Object=null):void{
_consumableProperties = null;
}
private function loggedIn(_arg1:Object=null):void{
MochiUserData.get(CONSUMER_KEY, getConsumableBag);
}
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) && (_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));
};
}
private function itemOwned(_arg1:Object):void{
_storeSync[_arg1.id] = {properties:_arg1.properties, count:_arg1.count};
}
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 + KEY_SALT)].value);
};
if (_local3 == 0){
} else {
newItems({id:_local2, count:_local3, properties:_storeSync[_local2].properties});
};
};
triggerEvent(READY, {});
}
private function putConsumableBag(_arg1:MochiUserData):void{
_syncPending = false;
if (_arg1.error){
triggerEvent(ERROR, {type:IO_ERROR, error:_arg1.error});
_outstandingID = -1;
};
triggerEvent(WRITTEN, {});
}
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 getProperty(_arg1){
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return (-1);
};
if (_consumableProperties[_arg1]){
return (MochiDigits(_consumableProperties[_arg1]).value);
};
return (undefined);
}
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);
}
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 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++;
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(_arg1:int):int{
return (((_arg1)>=_names.length) ? 0 : (_arg1 + 1));
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(_arg1:int):String{
return (_names[(_arg1 - 1)]);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
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);
}
}
}//package mochi.as3
Section 78
//MochiScores (mochi.as3.MochiScores)
package mochi.as3 {
import flash.display.*;
import flash.text.*;
public class MochiScores {
public static var onCloseHandler:Object;
public static var onErrorHandler:Object;
private static var boardID:String;
public static function onClose(_arg1:Object=null):void{
if (((((_arg1) && ((_arg1.error == true)))) && (onErrorHandler))){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiServices.warnID(_arg1, true);
MochiScores.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
public static function showLeaderboard(_arg1:Object=null):void{
var n:Number;
var options = _arg1;
if (options != null){
delete options.clip;
MochiServices.setContainer();
MochiServices.bringToTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
} else {
if ((options.score is MochiDigits)){
options.score = options.score.value;
};
};
n = Number(options.score);
if (isNaN(n)){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((n == Number.NEGATIVE_INFINITY)) || ((n == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(n) != n){
trace((("WARNING: Submitted score '" + options.score) + "' will be truncated"));
};
options.score = n;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
MochiServices.warnID(options.boardID, true);
trace("[MochiScores] NOTE: Security Sandbox Violation errors below are normal");
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, _arg1, _arg2);
}
public static function submit(_arg1:Number, _arg2:String, _arg3:Object=null, _arg4:Object=null):void{
_arg1 = Number(_arg1);
if (isNaN(_arg1)){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((_arg1 == Number.NEGATIVE_INFINITY)) || ((_arg1 == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(_arg1) != _arg1){
trace((("WARNING: Submitted score '" + String(_arg1)) + "' will be truncated"));
};
_arg1 = Number(_arg1);
};
};
MochiServices.send("scores_submit", {score:_arg1, name:_arg2}, _arg3, _arg4);
}
public static function requestList(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_requestList", null, _arg1, _arg2);
}
public static function scoresArrayToObjects(_arg1:Object):Object{
var _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
var _local2:Object = {};
for (_local7 in _arg1) {
if (typeof(_arg1[_local7]) == "object"){
if (((!((_arg1[_local7].cols == null))) && (!((_arg1[_local7].rows == null))))){
_local2[_local7] = [];
_local5 = _arg1[_local7];
_local4 = 0;
while (_local4 < _local5.rows.length) {
_local6 = {};
_local3 = 0;
while (_local3 < _local5.cols.length) {
_local6[_local5.cols[_local3]] = _local5.rows[_local4][_local3];
_local3++;
};
_local2[_local7].push(_local6);
_local4++;
};
} else {
_local2[_local7] = {};
for (_local8 in _arg1[_local7]) {
_local2[_local7][_local8] = _arg1[_local7][_local8];
};
};
} else {
_local2[_local7] = _arg1[_local7];
};
};
return (_local2);
}
}
}//package mochi.as3
Section 79
//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 {
public static const CONNECTED:String = "onConnected";
private static var _id:String;
private static var _container:Object;
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _timer:Timer;
private static var _preserved:Object;
private static var _servURL:String = "http://www.mochiads.com/static/lib/services/";
private static var _services:String = "services.swf";
private static var _mochiLC:String = "MochiLC.swf";
private static var _swfVersion:String;
private static var _listenChannelName:String = "__ms_";
private static var _sendChannel:LocalConnection;
private static var _sendChannelName:String;
private static var _connecting:Boolean = false;
private static var _connected:Boolean = false;
public static var netup:Boolean = true;
public static var netupAttempted:Boolean = false;
public static var onError:Object;
public static var widget:Boolean = false;
private static var _mochiLocalConnection:MovieClip;
private static var _queue:Array;
private static var _nextCallbackID:Number;
private static var _callbacks:Object;
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public static function get id():String{
return (_id);
}
public static function get clip():Object{
return (_container);
}
public static function get childClip():Object{
return (_clip);
}
public static function getVersion():String{
return ("3.9.1 as3");
}
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 isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
initComChannels();
};
};
}
public static function get connected():Boolean{
return (_connected);
}
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 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 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();
_timer.removeEventListener(TimerEvent.TIMER, connectWait);
_timer = null;
} catch(error:Error) {
};
};
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
}
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);
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_clip.parent){
_clip.parent.removeChild(_clip);
};
if (_arg1 != null){
if ((_arg1 is DisplayObjectContainer)){
_container = _arg1;
};
};
if (_arg2){
if ((_container is DisplayObjectContainer)){
DisplayObjectContainer(_container).addChild(_clip);
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(_arg2).servURL){
_servURL = urlOptions(_arg2).servURL;
};
var _local3:String = (_servURL + _services);
if (urlOptions(_arg2).servicesURL){
_local3 = urlOptions(_arg2).servicesURL;
};
_listenChannelName = (_listenChannelName + ((Math.floor(new Date().time) + "_") + Math.floor((Math.random() * 99999))));
MochiServices.allowDomains(_local3);
_clip = new MovieClip();
loadLCBridge(_clip);
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, detach);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, detach);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
var _local4:URLRequest = new URLRequest(_local3);
var _local5:URLVariables = new URLVariables();
_local5.listenLC = _listenChannelName;
_local5.mochiad_options = _arg2.loaderInfo.parameters.mochiad_options;
_local5.api_version = getVersion();
if (widget){
_local5.widget = true;
};
_local4.data = _local5;
_loader.load(_local4);
_clip.addChild(_loader);
_sendChannel = new LocalConnection();
_queue = [];
_nextCallbackID = 0;
_callbacks = {};
_timer = new Timer(10000, 1);
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
return (_clip);
}
private static function detach(_arg1:Event):void{
var _local2:LoaderInfo = LoaderInfo(_arg1.target);
_local2.removeEventListener(Event.COMPLETE, detach);
_local2.removeEventListener(IOErrorEvent.IO_ERROR, detach);
_local2.removeEventListener(Event.COMPLETE, loadLCBridgeComplete);
_local2.removeEventListener(IOErrorEvent.IO_ERROR, loadError);
}
private static function loadLCBridge(_arg1:Object):void{
var _local2:Loader = new Loader();
var _local3:String = (_servURL + _mochiLC);
var _local4:URLRequest = new URLRequest(_local3);
_local2.contentLoaderInfo.addEventListener(Event.COMPLETE, detach);
_local2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, detach);
_local2.contentLoaderInfo.addEventListener(Event.COMPLETE, loadLCBridgeComplete);
_local2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
_local2.load(_local4);
_arg1.addChild(_local2);
}
private static function loadLCBridgeComplete(_arg1:Event):void{
var _local2:Loader = LoaderInfo(_arg1.target).loader;
_mochiLocalConnection = MovieClip(_local2.content);
listen();
}
private static function loadError(_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
}
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");
} else {
_timer.stop();
_timer.removeEventListener(TimerEvent.TIMER, connectWait);
_timer = null;
};
}
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...");
}
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 (_queue.length > 0) {
_mochiLocalConnection.send(_sendChannelName, "onReceive", _queue.shift());
};
};
}
private static function onReceive(_arg1:Object):void{
var methodName:String;
var pkg = _arg1;
var cb:String = pkg.callbackID;
var cblst:Object = _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 _callbacks[cb];
}
private static function onEvent(_arg1:Object):void{
var _local2:String = _arg1.target;
var _local3:String = _arg1.event;
switch (_local2){
case "services":
MochiServices.triggerEvent(_arg1.event, _arg1.args);
break;
case "events":
MochiEvents.triggerEvent(_arg1.event, _arg1.args);
break;
case "coins":
MochiCoins.triggerEvent(_arg1.event, _arg1.args);
break;
case "social":
MochiSocial.triggerEvent(_arg1.event, _arg1.args);
break;
};
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (((_clip) && (_queue))){
while (_queue.length > 0) {
_local2 = _queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _callbacks[_local2.callbackID];
};
delete _callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
}
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) {
};
};
};
};
}
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:_nextCallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
trace(("Error: MochiServices not connected. Please call MochiServices.connect(). Function: " + _arg1));
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_queue.push({methodName:_arg1, args:_arg2, callbackID:_nextCallbackID});
};
if (_clip != null){
if (_callbacks != null){
_callbacks[_nextCallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_nextCallbackID++;
};
};
}
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 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://link.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);
};
}
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 addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
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);
}
}
}//package mochi.as3
Section 80
//MochiSocial (mochi.as3.MochiSocial)
package mochi.as3 {
public class MochiSocial {
public static const LOGGED_IN:String = "LoggedIn";
public static const LOGGED_OUT:String = "LoggedOut";
public static const LOGIN_SHOW:String = "LoginShow";
public static const LOGIN_HIDE:String = "LoginHide";
public static const LOGIN_SHOWN:String = "LoginShown";
public static const PROFILE_SHOW:String = "ProfileShow";
public static const PROFILE_HIDE:String = "ProfileHide";
public static const PROPERTIES_SAVED:String = "PropertySaved";
public static const WIDGET_LOADED:String = "WidgetLoaded";
public static const FRIEND_LIST:String = "FriendsList";
public static const PROFILE_DATA:String = "ProfileData";
public static const GAMEPLAY_DATA:String = "GameplayData";
public static const ACTION_CANCELED:String = "onCancel";
public static const ACTION_COMPLETE:String = "onComplete";
public static const USER_INFO:String = "UserInfo";
public static const ERROR:String = "Error";
public static const IO_ERROR:String = "IOError";
public static const NO_USER:String = "NoUser";
public static const PROPERTIES_SIZE:String = "PropertiesSize";
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 getAPIURL():String{
if (!_user_info){
return (null);
};
return (_user_info.api_url);
}
public static function getAPIToken():String{
if (!_user_info){
return (null);
};
return (_user_info.api_token);
}
public static function showLoginWidget(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_showLoginWidget", {options:_arg1});
}
public static function hideLoginWidget():void{
MochiServices.send("social_hideLoginWidget");
}
public static function requestLogin(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_requestLogin", _arg1);
}
public static function saveUserProperties(_arg1:Object):void{
MochiServices.send("social_saveUserProperties", _arg1);
}
public static function getFriendsList(_arg1:Object=null):void{
MochiServices.send("social_getFriendsList", _arg1);
}
public static function postToStream(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_postToStream", _arg1);
}
public static function inviteFriends(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_inviteFriends", _arg1);
}
public static function requestFan(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_requestFan", _arg1);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
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 removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
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 81
//MochiUserData (mochi.as3.MochiUserData)
package mochi.as3 {
import flash.events.*;
import flash.utils.*;
import flash.net.*;
public class MochiUserData extends EventDispatcher {
public var _loader:URLLoader;
public var key:String;// = null
public var data;// = null
public var error:Event;// = null
public var operation:String;// = null
public var callback:Function;// = 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 deserialize(_arg1:ByteArray){
_arg1.objectEncoding = ObjectEncoding.AMF3;
_arg1.uncompress();
return (_arg1.readObject());
}
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 errorHandler(_arg1:IOErrorEvent):void{
data = null;
error = _arg1;
if (callback != null){
performCallback();
} else {
dispatchEvent(_arg1);
};
close();
}
public function securityErrorHandler(_arg1:SecurityErrorEvent):void{
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + _arg1.toString())));
}
public function performCallback():void{
try {
callback(this);
} catch(e:Error) {
trace(("[MochiUserData] exception during callback: " + e));
};
}
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 function getEvent():void{
request("get", serialize(null));
}
public function putEvent(_arg1):void{
request("put", serialize(_arg1));
}
override public function toString():String{
return ((((((((("[MochiUserData operation=" + operation) + " key=\"") + key) + "\" data=") + data) + " error=\"") + error) + "\"]"));
}
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