Section 1
//Game (com.novelgames.flashgames.common.Game)
package com.novelgames.flashgames.common {
import flash.display.*;
public class Game extends MovieClip {
public static var gameStage:Stage;
public function unpause():void{
NewTimer.unpause();
}
public function pause():void{
NewTimer.pause();
}
}
}//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 class Instructions extends MovieClip {
public var startButton:SimpleButton;
private var shownFromGame:Boolean;
public function Instructions(_arg1:Boolean=false){
this.shownFromGame = _arg1;
startButton.addEventListener(MouseEvent.CLICK, startButtonClicked);
}
private function startButtonClicked(_arg1:MouseEvent):void{
if (!shownFromGame){
Object(parent).gotoGamePage();
} else {
Object(parent).hideInstructionsFromGame();
};
}
}
}//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 flash.media.*;
public class MainDevelopment extends MovieClip {
private var title:Title;
private var musicGameSoundChannel:SoundChannel;
private var titleIndex:int;
private var instructions:Instructions;
private var musicGame:Sound;
private var game:Game;
public function MainDevelopment(){
this.addEventListener(Event.ENTER_FRAME, checkTitle);
}
protected function getMusicGame():Sound{
return (null);
}
public function hideInstructionsFromGame():void{
this.removeChild(instructions);
instructions = null;
game.visible = true;
game.unpause();
}
public function showInstructionsFromGame():void{
game.pause();
game.visible = false;
instructions = new Instructions(true);
this.addChildAt(instructions, (titleIndex + 1));
}
public function gotoGamePage():void{
Game.gameStage = stage;
removePage();
game = getGame();
this.addChildAt(game, titleIndex);
musicGame = getMusicGame();
musicGameSoundChannel = musicGame.play(0, int.MAX_VALUE);
}
private function checkTitle(_arg1:Event):void{
if (!(title = getTitle())){
return;
};
this.removeEventListener(Event.ENTER_FRAME, checkTitle);
stop();
titleIndex = this.getChildIndex(title);
}
public function gotoTitlePage():void{
removePage();
title = new Title();
this.addChildAt(title, titleIndex);
}
public function gotoInstructionsPage():void{
removePage();
instructions = new Instructions();
this.addChildAt(instructions, titleIndex);
}
public function showHighScores():void{
this["highScores"].showHighScores();
}
public function showEnterHighScore(_arg1:int):void{
this["highScores"].showEnterHighScore(_arg1);
}
protected function getGame():Game{
return (null);
}
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;
};
}
protected function getTitle():Title{
return (null);
}
}
}//package com.novelgames.flashgames.common
Section 5
//MuteButton (com.novelgames.flashgames.common.MuteButton)
package com.novelgames.flashgames.common {
import flash.display.*;
import flash.events.*;
import flash.media.*;
public class MuteButton extends MovieClip {
private var gameSoundTransform:SoundTransform;
public function MuteButton(){
if (SoundMixer.soundTransform.volume == 0){
showOff();
} else {
showOn();
};
this.addEventListener(MouseEvent.CLICK, buttonClicked);
this.buttonMode = true;
}
private function showOff():void{
gotoAndStop("off");
}
private function buttonClicked(_arg1:MouseEvent):void{
var _local2:SoundTransform;
_local2 = new SoundTransform();
if (SoundMixer.soundTransform.volume == 0){
_local2.volume = 1;
SoundMixer.soundTransform = _local2;
showOn();
} else {
_local2.volume = 0;
SoundMixer.soundTransform = _local2;
showOff();
};
}
private function showOn():void{
gotoAndStop("on");
}
}
}//package com.novelgames.flashgames.common
Section 6
//NewTimer (com.novelgames.flashgames.common.NewTimer)
package com.novelgames.flashgames.common {
import flash.events.*;
import flash.utils.*;
public class NewTimer extends Timer {
private var adjustedStartTime:int;
private var listener:Function;
private var originalRepeatCount:int;
private var originalDelay:int;
private static var pauseTime:int;
private static var paused:Boolean = false;
private static var totalPausedTime:int = 0;
public function NewTimer(_arg1:Number, _arg2:int=0):void{
super(_arg1, _arg2);
originalDelay = _arg1;
originalRepeatCount = _arg2;
}
override public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
if (_arg1 != TimerEvent.TIMER){
super.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5);
return;
};
this.listener = _arg2;
super.addEventListener(_arg1, timerEventListener);
}
override public function start():void{
adjustedStartTime = NewTimer.getTimer();
super.start();
}
private function timerEventListener(_arg1:TimerEvent):void{
if (paused){
stop();
delay = Math.max((originalDelay - (NewTimer.getTimer() - adjustedStartTime)), 1);
if (originalRepeatCount > 0){
repeatCount++;
};
super.start();
return;
};
if ((NewTimer.getTimer() - adjustedStartTime) >= originalDelay){
adjustedStartTime = NewTimer.getTimer();
if (delay != originalDelay){
stop();
delay = originalDelay;
super.start();
};
listener(_arg1);
} else {
stop();
delay = Math.max((originalDelay - (NewTimer.getTimer() - adjustedStartTime)), 1);
if (originalRepeatCount > 0){
repeatCount++;
};
super.start();
};
}
public static function unpause():void{
if (!paused){
return;
};
paused = false;
totalPausedTime = (totalPausedTime + (getTimer() - pauseTime));
}
public static function getTimer():int{
if (paused){
return ((pauseTime - totalPausedTime));
};
return ((getTimer() - totalPausedTime));
}
public static function pause():void{
if (paused){
return;
};
paused = true;
pauseTime = getTimer();
}
}
}//package com.novelgames.flashgames.common
Section 7
//Title (com.novelgames.flashgames.common.Title)
package com.novelgames.flashgames.common {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class Title extends MovieClip {
public var startButton:SimpleButton;
public var highScoresButton:SimpleButton;
public var moreGamesButton:SimpleButton;
public function Title(){
startButton.addEventListener(MouseEvent.CLICK, startButtonClicked);
highScoresButton.addEventListener(MouseEvent.CLICK, highScoresButtonClicked);
moreGamesButton.addEventListener(MouseEvent.CLICK, moreGamesButtonClicked);
}
private function startButtonClicked(_arg1:MouseEvent):void{
Object(parent).gotoInstructionsPage();
}
private function moreGamesButtonClicked(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.mygamesworld.com"), "_blank");
}
private function highScoresButtonClicked(_arg1:MouseEvent):void{
Object(parent).showHighScores();
}
}
}//package com.novelgames.flashgames.common
Section 8
//Config (com.novelgames.flashgames.highscores.Config)
package com.novelgames.flashgames.highscores {
public class Config {
public static var HIGHSCORES_UPARROW_FROMBOTTOM:Number = 40;
public static var HIGHSCORES_UPARROW_FROMRIGHT:Number = 34;
public static var ENTER_NAMEFIELDORDER:Number = 20;
public static var HIGHSCORES_DOWNARROW_FROMBOTTOM:Number = 40;
public static var HIGHSCORES_LIST_BUTTONFROMBOTTOM:Number = 20;
public static var ENTER_LABELFIELDSPACING:Number = 5;
public static var HIGHSCORES_LIST_FROMBOTTOM:Number = 50;
public static var HIGHSCORES_TITLEY:Number = 20;
public static var HIGHSCORES_DOWNARROW_FROMRIGHT:Number = 18;
public static var ENTER_SECTIONSPACING:Number = 30;
public static var HIGHSCORES_LIST_FROMTOP:Number = 50;
public static var HIGHSCORES_LIST_COLUMNSPACING:Number = 10;
public static var FAILED_TEXTBUTTONSPACING:Number = 50;
public static var ENTER_BUTTONSSPACING:Number = 70;
public static var HIGHSCORES_LIST_FROMRIGHT:Number = 10;
public static var HIGHSCORES_LIST_ROWSPACING:Number = 15;
public static var HIGHSCORES_NONEDISPLAY:String = "-";
public static var HIGHSCORES_LIST_FROMLEFT:Number = 10;
public static var HIGHSCORES_SCROLLSPEED:Number = 100;
}
}//package com.novelgames.flashgames.highscores
Section 9
//HighScores (com.novelgames.flashgames.highscores.HighScores)
package com.novelgames.flashgames.highscores {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.geom.*;
import flash.xml.*;
public class HighScores extends UIComponent {
private var __saveScoreURL:String;
private var scrollStartTime:Number;
private var showingHighScores:Boolean;
private var __dialogBorderAlpha:Number;
private var __maxNoOfScores:Number;
private var __dialogBorderThickness:Number;
private var __dialogBorderColour:Number;
private var __gameID:Number;
private var records:Array;
private var scrollTimer:Timer;
private var page:MovieClip;
private var score:Number;
private var isInitializing:Boolean;
private var __backgroundColour:Number;
private var loadingHighScores:Boolean;
private var playerName:String;
private var __dialogColour:Number;
private var __backgroundAlpha:Number;
private var scrollDirection:Number;
private var __dialogAlpha:Number;
private var __loadScoresURL:String;
private var scrollStartY:Number;
private var __loadScoresAtStart:Boolean;
private var scoreRange:Number;
public static var SCORERANGE_PASTWEEK:Number = 3;
public static var SCORERANGE_PASTYEAR:Number = 5;
public static var SCROLL_UP:Number = 1;
public static var SCROLL_DOWN:Number = 2;
public static var SCORERANGE_THISDAY:Number = 6;
public static var SCORERANGE_THISMONTH:Number = 8;
public static var SCORERANGE_THISYEAR:Number = 9;
public static var SCORERANGE_ETERNITY:Number = 1;
public static var SCORERANGE_THISWEEK:Number = 7;
public static var SCORERANGE_PASTDAY:Number = 2;
public static var SCORERANGE_PASTMONTH:Number = 4;
public function get saveScoreURL():String{
return (__saveScoreURL);
}
private function showLoadHighScoresFailed():void{
if (page){
this.removeChild(page);
};
page = new HighScoresLoadFailedPage();
drawBackground();
page.loadHighScoresFailedText.x = (width / 2);
page.loadHighScoresFailedText.y = ((height / 2) - (Config.FAILED_TEXTBUTTONSPACING / 2));
page.okButton.x = (width / 2);
page.okButton.y = ((height / 2) + (Config.FAILED_TEXTBUTTONSPACING / 2));
page.okButton.addEventListener(MouseEvent.CLICK, hide);
this.addChild(page);
visible = true;
}
public function get dialogBorderAlpha():Number{
return (__dialogBorderAlpha);
}
public function set saveScoreURL(_arg1:String):void{
__saveScoreURL = _arg1;
}
public function get maxNoOfScores():Number{
return (__maxNoOfScores);
}
public function get dialogBorderThickness():Number{
return (__dialogBorderThickness);
}
public function set dialogBorderAlpha(_arg1:Number):void{
__dialogBorderAlpha = _arg1;
}
private function drawRecords():void{
var _local1:Array;
var _local2:Array;
var _local3:Array;
var _local4:Number;
var _local5:Number;
var _local6:*;
var _local7:*;
var _local8:MovieClip;
var _local9:*;
_local1 = new Array();
_local2 = new Array();
_local3 = new Array();
_local4 = 0;
_local5 = 0;
_local9 = 0;
while (_local9 < __maxNoOfScores) {
if (_local9 < records.length){
_local6 = records[_local9].name;
_local7 = records[_local9].score;
} else {
_local6 = Config.HIGHSCORES_NONEDISPLAY;
_local7 = Config.HIGHSCORES_NONEDISPLAY;
};
_local8 = new TextText();
_local8.textText.autoSize = "left";
_local8.textText.text = (_local9 + 1);
if (_local8.width > _local4){
_local4 = _local8.width;
};
page.ranksHolder.addChild(_local8);
_local1.push(_local8);
_local8 = new TextText();
_local8.textText.autoSize = "left";
_local8.textText.text = _local6;
page.namesHolder.addChild(_local8);
_local2.push(_local8);
_local8 = new TextText();
_local8.textText.autoSize = "left";
_local8.textText.text = _local7;
if (_local8.width > _local5){
_local5 = _local8.width;
};
page.scoresHolder.addChild(_local8);
_local3.push(_local8);
_local9++;
};
_local9 = 0;
while (_local9 < __maxNoOfScores) {
_local1[_local9].x = Config.HIGHSCORES_LIST_FROMLEFT;
_local1[_local9].y = (Config.HIGHSCORES_LIST_FROMTOP + (_local9 * Config.HIGHSCORES_LIST_ROWSPACING));
_local2[_local9].x = ((Config.HIGHSCORES_LIST_FROMLEFT + _local4) + Config.HIGHSCORES_LIST_COLUMNSPACING);
_local2[_local9].y = (Config.HIGHSCORES_LIST_FROMTOP + (_local9 * Config.HIGHSCORES_LIST_ROWSPACING));
_local3[_local9].x = ((width - Config.HIGHSCORES_LIST_FROMRIGHT) - _local3[_local9].width);
_local3[_local9].y = (Config.HIGHSCORES_LIST_FROMTOP + (_local9 * Config.HIGHSCORES_LIST_ROWSPACING));
_local9++;
};
page.ranksMask.x = Config.HIGHSCORES_LIST_FROMLEFT;
page.ranksMask.y = Config.HIGHSCORES_LIST_FROMTOP;
page.ranksMask.width = ((((width - Config.HIGHSCORES_LIST_FROMRIGHT) - Config.HIGHSCORES_LIST_FROMLEFT) - _local5) - Config.HIGHSCORES_LIST_COLUMNSPACING);
page.ranksMask.height = ((height - Config.HIGHSCORES_LIST_FROMBOTTOM) - Config.HIGHSCORES_LIST_FROMTOP);
page.namesMask.x = Config.HIGHSCORES_LIST_FROMLEFT;
page.namesMask.y = Config.HIGHSCORES_LIST_FROMTOP;
page.namesMask.width = ((((width - Config.HIGHSCORES_LIST_FROMRIGHT) - Config.HIGHSCORES_LIST_FROMLEFT) - _local5) - Config.HIGHSCORES_LIST_COLUMNSPACING);
page.namesMask.height = ((height - Config.HIGHSCORES_LIST_FROMBOTTOM) - Config.HIGHSCORES_LIST_FROMTOP);
page.scoresMask.x = ((width - Config.HIGHSCORES_LIST_FROMRIGHT) - _local5);
page.scoresMask.y = Config.HIGHSCORES_LIST_FROMTOP;
page.scoresMask.width = _local5;
page.scoresMask.height = ((height - Config.HIGHSCORES_LIST_FROMBOTTOM) - Config.HIGHSCORES_LIST_FROMTOP);
page.ranksHolder.mask = page.ranksMask;
page.namesHolder.mask = page.namesMask;
page.scoresHolder.mask = page.scoresMask;
}
public function set dialogColour(_arg1:Number):void{
__dialogColour = _arg1;
}
public function showEnterHighScore(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
showingHighScores = false;
this.score = _arg1;
if (page){
this.removeChild(page);
};
page = new HighScoresEnterPage();
page.scoreText.text = _arg1.toString();
page.nameText.text = ((playerName)!=null) ? playerName : "";
drawBackground();
_local2 = ((((((((page.yourScoreText.height + Config.ENTER_LABELFIELDSPACING) + page.scoreText.height) + Config.ENTER_SECTIONSPACING) + page.enterText.height) + Config.ENTER_LABELFIELDSPACING) + page.nameText.height) + Config.ENTER_SECTIONSPACING) + page.okButton.height);
_local3 = ((height - _local2) / 2);
page.yourScoreText.x = (width / 2);
page.yourScoreText.y = (_local3 + (page.yourScoreText.height / 2));
_local3 = (_local3 + (page.yourScoreText.height + Config.ENTER_LABELFIELDSPACING));
page.scoreText.autoSize = "center";
page.scoreText.x = ((width - page.scoreText.width) / 2);
page.scoreText.y = _local3;
_local3 = (_local3 + (page.scoreText.height + Config.ENTER_SECTIONSPACING));
page.enterText.x = (width / 2);
page.enterText.y = (_local3 + (page.enterText.height / 2));
_local3 = (_local3 + (page.enterText.height + Config.ENTER_LABELFIELDSPACING));
page.nameText.width = (width - (Config.ENTER_NAMEFIELDORDER * 2));
page.nameText.x = ((width - page.nameText.width) / 2);
page.nameText.y = _local3;
_local3 = (_local3 + (page.nameText.height + Config.ENTER_SECTIONSPACING));
page.okButton.x = ((width - Config.ENTER_BUTTONSSPACING) / 2);
page.okButton.y = (_local3 + (page.okButton.height / 2));
page.cancelButton.x = ((width + Config.ENTER_BUTTONSSPACING) / 2);
page.cancelButton.y = (_local3 + (page.cancelButton.height / 2));
page.okButton.addEventListener(MouseEvent.CLICK, saveScore);
page.cancelButton.addEventListener(MouseEvent.CLICK, hide);
this.addChild(page);
visible = true;
}
public function set dialogBorderThickness(_arg1:Number):void{
__dialogBorderThickness = _arg1;
}
public function get dialogBorderColour():Number{
return (__dialogBorderColour);
}
public function get backgroundColour():Number{
return (__backgroundColour);
}
public function set loadScoresURL(_arg1:String):void{
__loadScoresURL = _arg1;
}
public function get gameID():Number{
return (__gameID);
}
public function loadScores():void{
var _local1:URLRequest;
var _local2:URLLoader;
_local1 = new URLRequest(((__loadScoresURL + ((__loadScoresURL.indexOf("?") == -1)) ? "?id=" : "&id=") + __gameID));
_local2 = new URLLoader();
loadingHighScores = true;
_local1.method = "GET";
_local2.addEventListener(IOErrorEvent.IO_ERROR, failedLoadingScores);
_local2.addEventListener(Event.COMPLETE, finishedLoadingScores);
_local2.load(_local1);
if (showingHighScores){
showLoadingHighScores();
};
}
public function set loadScoresAtStart(_arg1:Boolean):void{
__loadScoresAtStart = _arg1;
}
private function showSavingScore():void{
if (page){
this.removeChild(page);
};
page = new HighScoresSavingPage();
drawBackground();
page.savingScoreText.x = (width / 2);
page.savingScoreText.y = (height / 2);
this.addChild(page);
visible = true;
}
private function setArrowButtons():void{
if (page.ranksHolder.height > page.namesMask.height){
page.upArrowButton.x = (width - Config.HIGHSCORES_UPARROW_FROMRIGHT);
page.upArrowButton.y = (height - Config.HIGHSCORES_UPARROW_FROMBOTTOM);
page.downArrowButton.x = (width - Config.HIGHSCORES_DOWNARROW_FROMRIGHT);
page.downArrowButton.y = (height - Config.HIGHSCORES_DOWNARROW_FROMBOTTOM);
page.upArrowButton.addEventListener(MouseEvent.MOUSE_DOWN, startScrollUp);
page.downArrowButton.addEventListener(MouseEvent.MOUSE_DOWN, startScrollDown);
page.upArrowButton.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
page.downArrowButton.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
page.upArrowButton.visible = false;
} else {
page.upArrowButton.visible = false;
page.downArrowButton.visible = false;
};
}
private function startScrollUp(_arg1:MouseEvent):void{
startScroll(_slot1.SCROLL_UP);
}
public function set maxNoOfScores(_arg1:Number):void{
__maxNoOfScores = Number(_arg1);
}
private function parseScoreRange(_arg1:String):void{
switch (_arg1){
case "eternity":
scoreRange = SCORERANGE_ETERNITY;
break;
case "pastDay":
scoreRange = SCORERANGE_PASTDAY;
break;
case "pastWeek":
scoreRange = SCORERANGE_PASTWEEK;
break;
case "pastMonth":
scoreRange = SCORERANGE_PASTMONTH;
break;
case "pastYear":
scoreRange = SCORERANGE_PASTYEAR;
break;
case "thisDay":
scoreRange = SCORERANGE_THISDAY;
break;
case "thisWeek":
scoreRange = SCORERANGE_THISWEEK;
break;
case "thisMonth":
scoreRange = SCORERANGE_THISMONTH;
break;
case "thisYear":
scoreRange = SCORERANGE_THISYEAR;
break;
};
}
override public function set visible(_arg1:Boolean):void{
if (isInitializing){
return;
};
super.visible = _arg1;
}
public function get backgroundAlpha():Number{
return (__backgroundAlpha);
}
private function showSaveScoreFailed():void{
if (page){
this.removeChild(page);
};
page = new HighScoresSaveFailedPage();
drawBackground();
page.saveScoreFailedText.x = (width / 2);
page.saveScoreFailedText.y = ((height / 2) - (Config.FAILED_TEXTBUTTONSPACING / 2));
page.okButton.x = (width / 2);
page.okButton.y = ((height / 2) + (Config.FAILED_TEXTBUTTONSPACING / 2));
page.okButton.addEventListener(MouseEvent.CLICK, hide);
this.addChild(page);
visible = true;
}
public function get dialogAlpha():Number{
return (__dialogAlpha);
}
public function set dialogBorderColour(_arg1:Number):void{
__dialogBorderColour = _arg1;
}
private function startScrollDown(_arg1:MouseEvent):void{
startScroll(_slot1.SCROLL_DOWN);
}
private function saveScore(_arg1:MouseEvent=null):void{
var _local2:URLVariables;
var _local3:URLRequest;
var _local4:URLLoader;
var _local5:*;
_local2 = new URLVariables();
_local3 = new URLRequest(__saveScoreURL);
_local4 = new URLLoader();
playerName = page.nameText.text;
if (records != null){
_local5 = 0;
while (_local5 < records.length) {
if (records[_local5].score <= score){
break;
};
_local5++;
};
records.splice(_local5, 0, new Record(playerName, score));
records.splice(__maxNoOfScores);
};
_local2.id = __gameID;
_local2.name = playerName;
_local2.score = score;
_local3.data = _local2;
_local3.method = "POST";
_local4.addEventListener(Event.COMPLETE, finishedSavingScore);
_local4.addEventListener(IOErrorEvent.IO_ERROR, failedSavingScore);
_local4.load(_local3);
showSavingScore();
}
public function set gameID(_arg1:Number):void{
__gameID = Number(_arg1);
}
private function finishedLoadingScores(_arg1:Event):void{
var _local2:URLLoader;
var _local3:XMLDocument;
var _local4:XMLNode;
var _local5:XMLNode;
_local2 = URLLoader(_arg1.currentTarget);
_local3 = new XMLDocument();
_local3.ignoreWhite = true;
_local3.parseXML(_local2.data);
_local4 = _local3.firstChild;
loadingHighScores = false;
parseScoreRange(_local4.attributes.scoreRange);
records = new Array();
_local5 = _local4.firstChild;
while (_local5) {
if (_local5.nodeName != "RECORD"){
} else {
records.push(new Record(_local5.attributes.name, Number(_local5.attributes.score)));
if (records.length >= __maxNoOfScores){
break;
};
};
_local5 = _local5.nextSibling;
};
if (showingHighScores){
showHighScores();
};
}
public function get dialogColour():Number{
return (__dialogColour);
}
public function hide(_arg1:MouseEvent=null):void{
showingHighScores = false;
if (page){
this.removeChild(page);
};
page = null;
visible = false;
}
public function set backgroundColour(_arg1:Number):void{
__backgroundColour = Number(_arg1);
}
public function get loadScoresURL():String{
return (__loadScoresURL);
}
override protected function draw():void{
isInitializing = false;
page.highScoresModuleText.x = (width / 2);
page.highScoresModuleText.y = (height / 2);
drawBackground();
}
override protected function configUI():void{
super.configUI();
__gameID = 1;
__loadScoresURL = "loadScores.php";
__saveScoreURL = "saveScore.php";
__loadScoresAtStart = false;
__dialogColour = 0xFFFFFF;
__dialogAlpha = 1;
__dialogBorderThickness = 1;
__dialogBorderColour = 0;
__dialogBorderAlpha = 1;
__backgroundColour = 0;
__backgroundAlpha = 0.5;
__maxNoOfScores = 50;
loadingHighScores = false;
showingHighScores = false;
records = null;
if (!checkLivePreview()){
visible = false;
};
if (__loadScoresAtStart){
loadScores();
};
page = new HighScoresTextPage();
page.highScoresModuleText.x = (width / 2);
page.highScoresModuleText.y = (height / 2);
this.addChild(page);
isInitializing = true;
}
private function showLoadingHighScores():void{
if (page){
this.removeChild(page);
};
page = new HighScoresLoadingPage();
drawBackground();
page.loadingHighScoresText.x = (width / 2);
page.loadingHighScoresText.y = (height / 2);
this.addChild(page);
visible = true;
}
private function failedSavingScore(_arg1:IOErrorEvent):void{
showSaveScoreFailed();
}
public function showHighScores():void{
showingHighScores = true;
if (loadingHighScores){
showLoadingHighScores();
return;
};
if (records == null){
loadScores();
return;
};
if (page){
this.removeChild(page);
};
page = new HighScoresTablePage();
drawBackground();
setTitleText();
drawRecords();
setArrowButtons();
page.okButton.x = (width / 2);
page.okButton.y = (height - Config.HIGHSCORES_LIST_BUTTONFROMBOTTOM);
page.okButton.addEventListener(MouseEvent.CLICK, hide);
this.addChild(page);
visible = true;
}
private function setTitleText():void{
switch (scoreRange){
case SCORERANGE_ETERNITY:
page.titleText.gotoAndStop("eternity");
break;
case SCORERANGE_PASTDAY:
page.titleText.gotoAndStop("pastDay");
break;
case SCORERANGE_PASTWEEK:
page.titleText.gotoAndStop("pastWeek");
break;
case SCORERANGE_PASTMONTH:
page.titleText.gotoAndStop("pastMonth");
break;
case SCORERANGE_PASTYEAR:
page.titleText.gotoAndStop("pastYear");
break;
case SCORERANGE_THISDAY:
page.titleText.gotoAndStop("thisDay");
break;
case SCORERANGE_THISWEEK:
page.titleText.gotoAndStop("thisWeek");
break;
case SCORERANGE_THISMONTH:
page.titleText.gotoAndStop("thisMonth");
break;
case SCORERANGE_THISYEAR:
page.titleText.gotoAndStop("thisYear");
break;
};
page.titleText.x = (width / 2);
page.titleText.y = Config.HIGHSCORES_TITLEY;
}
public function get loadScoresAtStart():Boolean{
return (__loadScoresAtStart);
}
private function stopScroll(_arg1:MouseEvent=null):void{
if (scrollTimer){
scrollTimer.stop();
};
}
private function failedLoadingScores(_arg1:IOErrorEvent):void{
loadingHighScores = false;
if (showingHighScores){
showLoadHighScoresFailed();
};
}
private function drawBackground():void{
var _local1:Point;
var _local2:Point;
_local1 = new Point(0, 0);
_local2 = new Point(stage.stageWidth, stage.stageHeight);
_local1 = this.globalToLocal(_local1);
_local2 = this.globalToLocal(_local2);
page.backgroundHolder.graphics.clear();
page.backgroundHolder.graphics.beginFill(__backgroundColour, __backgroundAlpha);
page.backgroundHolder.graphics.moveTo(_local1.x, _local1.y);
page.backgroundHolder.graphics.lineTo(_local2.x, _local1.y);
page.backgroundHolder.graphics.lineTo(_local2.x, _local2.y);
page.backgroundHolder.graphics.lineTo(_local1.x, _local2.y);
page.backgroundHolder.graphics.lineTo(_local1.x, _local1.y);
page.backgroundHolder.graphics.endFill();
page.backgroundHolder.graphics.lineStyle(__dialogBorderThickness, __dialogBorderColour, __dialogBorderAlpha);
page.backgroundHolder.graphics.beginFill(__dialogColour, __dialogAlpha);
page.backgroundHolder.graphics.moveTo(0, 0);
page.backgroundHolder.graphics.lineTo(width, 0);
page.backgroundHolder.graphics.lineTo(width, height);
page.backgroundHolder.graphics.lineTo(0, height);
page.backgroundHolder.graphics.lineTo(0, 0);
page.backgroundHolder.graphics.endFill();
}
private function performScroll(_arg1:TimerEvent):void{
var _local2:Number;
_arg1.updateAfterEvent();
if (scrollDirection == SCROLL_DOWN){
_local2 = (scrollStartY - (((getTimer() - scrollStartTime) * Config.HIGHSCORES_SCROLLSPEED) / 1000));
if (((_local2 + Config.HIGHSCORES_LIST_FROMTOP) + (__maxNoOfScores * Config.HIGHSCORES_LIST_ROWSPACING)) <= (height - Config.HIGHSCORES_LIST_FROMBOTTOM)){
_local2 = (((height - Config.HIGHSCORES_LIST_FROMBOTTOM) - (__maxNoOfScores * Config.HIGHSCORES_LIST_ROWSPACING)) - Config.HIGHSCORES_LIST_FROMTOP);
stopScroll();
page.downArrowButton.visible = false;
};
page.ranksHolder.y = _local2;
page.namesHolder.y = _local2;
page.scoresHolder.y = _local2;
page.upArrowButton.visible = true;
} else {
_local2 = (scrollStartY + (((getTimer() - scrollStartTime) * Config.HIGHSCORES_SCROLLSPEED) / 1000));
if (_local2 >= 0){
_local2 = 0;
stopScroll();
page.upArrowButton.visible = false;
};
page.ranksHolder.y = _local2;
page.namesHolder.y = _local2;
page.scoresHolder.y = _local2;
page.downArrowButton.visible = true;
};
}
public function set backgroundAlpha(_arg1:Number):void{
__backgroundAlpha = Number(_arg1);
}
private function startScroll(_arg1:Number):void{
scrollDirection = _arg1;
scrollStartTime = getTimer();
scrollStartY = page.ranksHolder.y;
if (scrollTimer){
scrollTimer.stop();
};
scrollTimer = new Timer(1, 0);
scrollTimer.addEventListener(TimerEvent.TIMER, performScroll);
scrollTimer.start();
}
private function finishedSavingScore(_arg1:Event):void{
var _local2:URLLoader;
var _local3:URLVariables;
_local2 = URLLoader(_arg1.currentTarget);
_local3 = new URLVariables(_local2.data);
if (_local3.success != "true"){
showSaveScoreFailed();
return;
};
showHighScores();
}
public function set dialogAlpha(_arg1:Number):void{
__dialogAlpha = _arg1;
}
}
}//package com.novelgames.flashgames.highscores
Section 10
//HighScoresEnterPage (com.novelgames.flashgames.highscores.HighScoresEnterPage)
package com.novelgames.flashgames.highscores {
import flash.display.*;
import flash.text.*;
public dynamic class HighScoresEnterPage extends MovieClip {
public var yourScoreText:MovieClip;
public var enterText:MovieClip;
public var okButton:SimpleButton;
public var cancelButton:SimpleButton;
public var nameText:TextField;
public var backgroundHolder:MovieClip;
public var scoreText:TextField;
}
}//package com.novelgames.flashgames.highscores
Section 11
//HighScoresLoadFailedPage (com.novelgames.flashgames.highscores.HighScoresLoadFailedPage)
package com.novelgames.flashgames.highscores {
import flash.display.*;
public dynamic class HighScoresLoadFailedPage extends MovieClip {
public var okButton:SimpleButton;
public var backgroundHolder:MovieClip;
public var loadHighScoresFailedText:MovieClip;
}
}//package com.novelgames.flashgames.highscores
Section 12
//HighScoresLoadingPage (com.novelgames.flashgames.highscores.HighScoresLoadingPage)
package com.novelgames.flashgames.highscores {
import flash.display.*;
public dynamic class HighScoresLoadingPage extends MovieClip {
public var backgroundHolder:MovieClip;
public var loadingHighScoresText:MovieClip;
}
}//package com.novelgames.flashgames.highscores
Section 13
//HighScoresSaveFailedPage (com.novelgames.flashgames.highscores.HighScoresSaveFailedPage)
package com.novelgames.flashgames.highscores {
import flash.display.*;
public dynamic class HighScoresSaveFailedPage extends MovieClip {
public var okButton:SimpleButton;
public var backgroundHolder:MovieClip;
public var saveScoreFailedText:MovieClip;
}
}//package com.novelgames.flashgames.highscores
Section 14
//HighScoresSavingPage (com.novelgames.flashgames.highscores.HighScoresSavingPage)
package com.novelgames.flashgames.highscores {
import flash.display.*;
public dynamic class HighScoresSavingPage extends MovieClip {
public var savingScoreText:MovieClip;
public var backgroundHolder:MovieClip;
}
}//package com.novelgames.flashgames.highscores
Section 15
//HighScoresTablePage (com.novelgames.flashgames.highscores.HighScoresTablePage)
package com.novelgames.flashgames.highscores {
import flash.display.*;
public dynamic class HighScoresTablePage extends MovieClip {
public var upArrowButton:SimpleButton;
public var namesHolder:MovieClip;
public var scoresHolder:MovieClip;
public var okButton:SimpleButton;
public var namesMask:MovieClip;
public var ranksHolder:MovieClip;
public var ranksMask:MovieClip;
public var downArrowButton:SimpleButton;
public var backgroundHolder:MovieClip;
public var titleText:MovieClip;
public var scoresMask:MovieClip;
}
}//package com.novelgames.flashgames.highscores
Section 16
//HighScoresTextPage (com.novelgames.flashgames.highscores.HighScoresTextPage)
package com.novelgames.flashgames.highscores {
import flash.display.*;
public dynamic class HighScoresTextPage extends MovieClip {
public var highScoresModuleText:MovieClip;
public var backgroundHolder:MovieClip;
}
}//package com.novelgames.flashgames.highscores
Section 17
//Record (com.novelgames.flashgames.highscores.Record)
package com.novelgames.flashgames.highscores {
public class Record {
public var score:Number;
public var name:String;
public function Record(_arg1:String, _arg2:Number){
this.name = _arg1;
this.score = _arg2;
}
}
}//package com.novelgames.flashgames.highscores
Section 18
//TextText (com.novelgames.flashgames.highscores.TextText)
package com.novelgames.flashgames.highscores {
import flash.display.*;
import flash.text.*;
public dynamic class TextText extends MovieClip {
public var textText:TextField;
}
}//package com.novelgames.flashgames.highscores
Section 19
//Bar (com.novelgames.flashgames.preloader.Bar)
package com.novelgames.flashgames.preloader {
import flash.display.*;
import flash.geom.*;
public class Bar extends MovieClip {
private var colourBottom:Number;
private var barHeight:Number;
private var border:MovieClip;
private var borderColour:Number;
private var percent:Number;
private var barWidth:Number;
private var borderThickness:Number;
private var colourTop:Number;
public function setHeight(_arg1:Number):void{
this.barHeight = _arg1;
updateBorder();
updateBar();
}
private function updateBorder():void{
border.graphics.clear();
border.graphics.lineStyle(borderThickness, borderColour, 100, false, "normal", "square", "miter");
border.graphics.moveTo(0, 0);
border.graphics.lineTo(barWidth, 0);
border.graphics.lineTo(barWidth, barHeight);
border.graphics.lineTo(0, barHeight);
border.graphics.lineTo(0, 0);
}
public function setPercent(_arg1:Number):void{
this.percent = _arg1;
updateBar();
}
public function setWidth(_arg1:Number):void{
this.barWidth = _arg1;
updateBorder();
updateBar();
}
public function initialize(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number, _arg8:Number):void{
this.x = _arg1;
this.y = _arg2;
this.barWidth = _arg3;
this.barHeight = _arg4;
this.colourTop = _arg5;
this.colourBottom = _arg6;
this.borderThickness = _arg7;
this.borderColour = _arg8;
border = new MovieClip();
this.addChild(border);
updateBorder();
updateBar();
}
private function updateBar():void{
var _local1:Number;
var _local2:Matrix;
_local1 = ((barWidth * percent) / 100);
_local2 = new Matrix();
_local2.createGradientBox(_local1, barHeight, (Math.PI / 2), 0, 0);
this.graphics.clear();
this.graphics.beginGradientFill("linear", [colourTop, colourBottom], [100, 100], [0, 0xFF], _local2);
this.graphics.moveTo(0, 0);
this.graphics.lineTo(_local1, 0);
this.graphics.lineTo(_local1, barHeight);
this.graphics.lineTo(0, barHeight);
this.graphics.lineTo(0, 0);
this.graphics.endFill();
}
public function setColourBottom(_arg1:Number):void{
this.colourBottom = _arg1;
updateBar();
}
public function setBorderColour(_arg1:Number):void{
this.borderColour = _arg1;
updateBorder();
}
public function setColourTop(_arg1:Number):void{
this.colourTop = _arg1;
updateBar();
}
public function setBorderThickness(_arg1:Number):void{
this.borderThickness = _arg1;
updateBorder();
}
}
}//package com.novelgames.flashgames.preloader
Section 20
//Preloader (com.novelgames.flashgames.preloader.Preloader)
package com.novelgames.flashgames.preloader {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.utils.*;
public class Preloader extends UIComponent {
private var __minShowTime:Number;
private var bytesLoaded:Number;
private var startTime:Number;
private var __barY:Number;
private var __barX:Number;
private var __playOrStop:String;
private var __barColourBottom:Number;
private var __barColourTop:Number;
private var __barBorderColour:Number;
private var __background:String;
private var backgroundMovieClip:MovieClip;
private var preloaderReal:MovieClip;
private var __barHeight:Number;
private var timer:Timer;
private var __barWidth:Number;
private var __startLabel:String;
private var bytesTotal:Number;
private var __barBorderThickness:Number;
public function set barColourTop(_arg1:Number):void{
__barColourTop = _arg1;
invalidate();
}
public function get barBorderThickness():Number{
return (__barBorderThickness);
}
public function set barBorderThickness(_arg1:Number):void{
__barBorderThickness = _arg1;
invalidate();
}
public function set barHeight(_arg1:Number):void{
__barHeight = _arg1;
invalidate();
}
public function set background(_arg1:String):void{
__background = _arg1;
invalidate();
}
public function get barX():Number{
return (__barX);
}
public function get barY():Number{
return (__barX);
}
public function get barColourBottom():Number{
return (__barColourBottom);
}
public function get barBorderColour():Number{
return (__barBorderColour);
}
public function get playOrStop():String{
return (__playOrStop);
}
public function set barWidth(_arg1:Number):void{
__barWidth = _arg1;
invalidate();
}
public function get barHeight():Number{
return (__barHeight);
}
public function get background():String{
return (__background);
}
public function get barColourTop():Number{
return (__barColourTop);
}
override protected function draw():void{
var theClass:Class;
var temp:MovieClip;
temp = null;
try {
theClass = Class(getDefinitionByName(__background));
temp = new (theClass);
} catch(e) {
};
if (!temp){
if (preloaderReal.backgroundMovieClip){
preloaderReal.backgroundHolder.removeChild(preloaderReal.backgroundMovieClip);
preloaderReal.backgroundMovieClip = null;
};
preloaderReal.white.visible = true;
preloaderReal.text.visible = true;
} else {
preloaderReal.backgroundMovieClip = temp;
preloaderReal.white.visible = false;
preloaderReal.text.visible = false;
preloaderReal.backgroundHolder.addChild(temp);
};
preloaderReal.white.width = width;
preloaderReal.white.height = height;
preloaderReal.text.x = (width / 2);
preloaderReal.text.y = (height / 2);
preloaderReal.bar.x = __barX;
preloaderReal.bar.y = __barY;
preloaderReal.bar.setWidth(__barWidth);
preloaderReal.bar.setHeight(__barHeight);
preloaderReal.bar.setColourTop(__barColourTop);
preloaderReal.bar.setColourBottom(__barColourBottom);
preloaderReal.bar.setBorderThickness(__barBorderThickness);
preloaderReal.bar.setBorderColour(__barBorderColour);
}
override protected function configUI():void{
super.configUI();
__background = "";
__barX = 250;
__barY = 300;
__barWidth = 100;
__barHeight = 20;
__barColourTop = 0xCCCCCC;
__barColourBottom = 0x333333;
__barBorderThickness = 2;
__barBorderColour = 0;
__startLabel = "game";
__playOrStop = "stop";
__minShowTime = 1000;
Object(parent).stop();
bytesLoaded = stage.loaderInfo.bytesLoaded;
bytesTotal = stage.loaderInfo.bytesTotal;
startTime = getTimer();
timer = new Timer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onTime);
timer.start();
preloaderReal = new PreloaderReal();
preloaderReal.white.width = width;
preloaderReal.white.height = height;
preloaderReal.text.x = (width / 2);
preloaderReal.text.y = (height / 2);
preloaderReal.bar.initialize(__barX, __barY, __barWidth, __barHeight, __barColourTop, __barColourBottom, __barBorderThickness, __barBorderColour);
preloaderReal.bar.setPercent(((bytesLoaded * 100) / bytesTotal));
this.addChild(preloaderReal);
}
public function set barY(_arg1:Number):void{
__barY = _arg1;
invalidate();
}
public function set barX(_arg1:Number):void{
__barX = _arg1;
invalidate();
}
private function onTime(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
_arg1.updateAfterEvent();
bytesLoaded = stage.loaderInfo.bytesLoaded;
_local2 = ((bytesLoaded * 100) / bytesTotal);
_local3 = (((getTimer() - startTime) * 100) / minShowTime);
_local4 = Math.min(_local2, _local3);
preloaderReal.bar.setPercent(_local4);
if (_local4 >= 100){
timer.stop();
if (__playOrStop == "play"){
Object(parent).gotoAndPlay(__startLabel);
} else {
Object(parent).gotoAndStop(__startLabel);
};
};
}
public function get barWidth():Number{
return (__barWidth);
}
public function set startLabel(_arg1:String):void{
__startLabel = _arg1;
}
public function set barColourBottom(_arg1:Number):void{
__barColourBottom = _arg1;
invalidate();
}
public function set barBorderColour(_arg1:Number):void{
__barBorderColour = _arg1;
invalidate();
}
public function get startLabel():String{
return (__startLabel);
}
public function set playOrStop(_arg1:String):void{
__playOrStop = _arg1;
}
public function set minShowTime(_arg1:Number):void{
__minShowTime = _arg1;
}
public function get minShowTime():Number{
return (__minShowTime);
}
}
}//package com.novelgames.flashgames.preloader
Section 21
//PreloaderReal (com.novelgames.flashgames.preloader.PreloaderReal)
package com.novelgames.flashgames.preloader {
import flash.display.*;
public dynamic class PreloaderReal extends MovieClip {
public var bar:Bar;
public var white:MovieClip;
public var text:MovieClip;
public var backgroundHolder:MovieClip;
}
}//package com.novelgames.flashgames.preloader
Section 22
//Cannon (com.novelgames.flashgames.snowball.Cannon)
package com.novelgames.flashgames.snowball {
import flash.display.*;
public class Cannon extends MovieClip {
public var arrow:CannonArrow;
public function Cannon(){
stop();
}
public function showArrow():void{
gotoAndStop("arrow");
}
public function updatePower(_arg1:Number):void{
arrow.updateHighlight(_arg1);
}
public function hideArrow():void{
gotoAndStop("normal");
}
}
}//package com.novelgames.flashgames.snowball
Section 23
//CannonArrow (com.novelgames.flashgames.snowball.CannonArrow)
package com.novelgames.flashgames.snowball {
import flash.display.*;
public class CannonArrow extends MovieClip {
public var arrowMask:MovieClip;
public function updateHighlight(_arg1:Number):void{
arrowMask.x = (-(arrowMask.width) * _arg1);
}
}
}//package com.novelgames.flashgames.snowball
Section 24
//Config (com.novelgames.flashgames.snowball.Config)
package com.novelgames.flashgames.snowball {
public class Config {
public static var SNOWBALL_MAXSPEED:Number = 1000;
public static var LIFE:Number = 3;
public static var SWITCHTURNTIME:Number = 1000;
public static var MESSAGE_WINTIME:Number = 3000;
public static var LEVEL_INITIALANGLEACCURACY:Number = 40;
public static var TANK_CANNONMOVEPERIOD:Number = 2000;
public static var LEVEL_POWERACCURACYINCREASE:Number = 0.08;
public static var WIND_MAX:Number = 200;
public static var SPARK_DISAPPEARTIME:Number = 1000;
public static var SNOWBALL_MINSPEED:Number = 600;
public static var LEVEL_ANGLEACCURACYINCREASE:Number = 8;
public static var TANK_CANNONLENGTH:Number = 60;
public static var MESSAGE_LEVELTIME:Number = 1500;
public static var SNOWBALL_ACCELERATION:Number = 1000;
public static var MESSAGE_GAMEOVERTIME:Number = 2000;
public static var WINDMETER_ARROWTIME:Number = 1000;
public static var WINDMETER_SPINACCELERATION:Number = 180;
public static var TANK_CANNONMAXANGLE:Number = 90;
public static var TANK_POWERMOVEPERIOD:Number = 2000;
public static var SNOWBALL_STEPSIZE:Number = 20;
public static var SCORE_HIT:Number = 1000;
public static var GROUNDY:Number = 320;
public static var TANK_CANNONMINANGLE:Number = 0;
public static var LEVEL_INITIALPOWERACCURACY:Number = 0.4;
public static var WINDMETER_MAXSPINSPEED:Number = 720;
}
}//package com.novelgames.flashgames.snowball
Section 25
//EnemyTank (com.novelgames.flashgames.snowball.EnemyTank)
package com.novelgames.flashgames.snowball {
import flash.display.*;
public class EnemyTank extends MovieClip {
public var life:Number;
public var cannon:MovieClip;
public function EnemyTank(){
stop();
}
public function updateCannonAngle(_arg1:Number):void{
cannon.rotation = -(_arg1);
}
public function setLife(_arg1:Number):void{
this.life = _arg1;
gotoAndStop(("snow" + (Config.LIFE - _arg1)));
}
}
}//package com.novelgames.flashgames.snowball
Section 26
//Game (com.novelgames.flashgames.snowball.Game)
package com.novelgames.flashgames.snowball {
import flash.display.*;
import flash.events.*;
import com.novelgames.flashgames.common.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
public class Game extends Game {
public var snowball:Snowball;
private var soundHit:Sound;
public var message:Message;
private var wind:Number;
private var soundGameOver:Sound;
private var powerAccuracy:Number;
private var angleAccuracy:Number;
private var power:Number;
public var windMeter:WindMeter;
private var startTime:Number;
public var clickDetector:MovieClip;
private var level:Number;
public var enemyTank:EnemyTank;
private var soundWin:Sound;
private var intervalID:Timer;
private var __score:Number;
private var isPlayerTurn:Boolean;
private var cannonAngle:Number;
public var spark:Spark;
private var soundFire:Sound;
public var scoreText:TextField;
public var tank:Tank;
public function Game(){
score = 0;
soundFire = new SoundFire();
soundHit = new SoundHit();
soundWin = new SoundWin();
soundGameOver = new SoundGameOver();
startLevel(1);
}
private function hitGround(_arg1:Number, _arg2:Number):void{
spark.showMiss(_arg1, _arg2);
startDissapearSpark();
soundFire.play();
}
private function onFireTime(_arg1:TimerEvent):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:Number;
var _local11:Number;
var _local12:*;
_local2 = NewTimer.getTimer();
_local3 = snowball.x;
_local4 = snowball.y;
snowball.move(_local2);
_local5 = snowball.x;
_local6 = snowball.y;
_local7 = Math.ceil((Math.abs((_local3 - _local5)) / Config.SNOWBALL_STEPSIZE));
_local8 = Math.ceil((Math.abs((_local4 - _local6)) / Config.SNOWBALL_STEPSIZE));
_local9 = Math.max(_local7, _local8);
_local12 = 1;
while (_local12 <= _local9) {
_local10 = (_local3 + ((_local12 * (_local5 - _local3)) / _local9));
_local11 = (_local4 + ((_local12 * (_local6 - _local4)) / _local9));
if (enemyTank.hitTestPoint(_local10, _local11, true)){
hitEnemyTank(_local10, _local11);
return;
};
if (tank.hitTestPoint(_local10, _local11, true)){
hitTank(_local10, _local11);
return;
};
if (windMeter.hitTestPoint(_local10, _local11, true)){
hitWindMeter(_local10, _local11);
return;
};
if (_local11 >= Config.GROUNDY){
hitGround(_local10, _local11);
return;
};
_local12++;
};
_arg1.updateAfterEvent();
}
public function set score(_arg1:Number):void{
__score = _arg1;
scoreText.text = _arg1.toString();
}
private function hitTank(_arg1:Number, _arg2:Number):void{
tank.setLife((tank.life - 1));
spark.showHit(_arg1, _arg2);
startDissapearSpark();
soundHit.play();
}
public function get score():Number{
return (__score);
}
private function startMoveCannon():void{
enemyTank.updateCannonAngle(0);
tank.showArrow();
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, startMovePower);
startTime = NewTimer.getTimer();
onTankCannonMoveTime(null);
intervalID = new NewTimer(1, 0);
intervalID.addEventListener(TimerEvent.TIMER, onTankCannonMoveTime);
intervalID.start();
}
private function hitEnemyTank(_arg1:Number, _arg2:Number):void{
score = (score + Config.SCORE_HIT);
enemyTank.setLife((enemyTank.life - 1));
spark.showHit(_arg1, _arg2);
startDissapearSpark();
soundHit.play();
}
private function onTankCannonMoveTime(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number;
_local2 = ((NewTimer.getTimer() - startTime) % Config.TANK_CANNONMOVEPERIOD);
if (_local2 < (Config.TANK_CANNONMOVEPERIOD / 2)){
_local3 = (_local2 / (Config.TANK_CANNONMOVEPERIOD / 2));
} else {
_local3 = ((Config.TANK_CANNONMOVEPERIOD - _local2) / (Config.TANK_CANNONMOVEPERIOD / 2));
};
cannonAngle = ((Config.TANK_CANNONMINANGLE * (1 - _local3)) + (Config.TANK_CANNONMAXANGLE * _local3));
tank.updateCannonAngle(cannonAngle);
if (_arg1){
_arg1.updateAfterEvent();
};
}
private function onDisappearSparkTime(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number;
_local2 = NewTimer.getTimer();
_local3 = ((_local2 - startTime) / Config.SPARK_DISAPPEARTIME);
if (_local3 > 1){
_local3 = 1;
};
spark.alpha = (1 - _local3);
if (_local3 == 1){
intervalID.stop();
if (!checkDestroy()){
intervalID = new NewTimer(Config.SWITCHTURNTIME, 0);
intervalID.addEventListener(TimerEvent.TIMER, switchTurn);
intervalID.start();
};
};
_arg1.updateAfterEvent();
}
private function startNextLevel(_arg1:TimerEvent):void{
intervalID.stop();
message.hide();
startLevel((level + 1));
}
private function startLevel(_arg1:Number):void{
this.level = _arg1;
angleAccuracy = (Config.LEVEL_INITIALANGLEACCURACY - ((_arg1 - 1) * Config.LEVEL_ANGLEACCURACYINCREASE));
if (angleAccuracy < 0){
angleAccuracy = 0;
};
powerAccuracy = (Config.LEVEL_INITIALPOWERACCURACY - ((_arg1 - 1) * Config.LEVEL_POWERACCURACYINCREASE));
if (powerAccuracy < 0){
powerAccuracy = 0;
};
isPlayerTurn = true;
windMeter.initialize();
tank.setLife(Config.LIFE);
enemyTank.setLife(Config.LIFE);
message.showLevel(_arg1);
intervalID = new NewTimer(Config.MESSAGE_LEVELTIME, 0);
intervalID.addEventListener(TimerEvent.TIMER, startPlay);
intervalID.start();
}
private function setWind():void{
wind = (-(Config.WIND_MAX) + ((Math.random() * Config.WIND_MAX) * 2));
windMeter.setWind(wind);
}
private function startMovePower(_arg1:MouseEvent):void{
intervalID.stop();
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, startMovePower);
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, startFire);
startTime = NewTimer.getTimer();
intervalID = new NewTimer(1, 0);
intervalID.addEventListener(TimerEvent.TIMER, onTankPowerMoveTime);
intervalID.start();
}
private function onMoveEnemyCannonTime(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number;
_local2 = NewTimer.getTimer();
_local3 = ((((_local2 - startTime) * (Config.TANK_CANNONMAXANGLE - Config.TANK_CANNONMINANGLE)) / (Config.TANK_CANNONMOVEPERIOD / 2)) / cannonAngle);
if (_local3 > 1){
_local3 = 1;
};
enemyTank.updateCannonAngle((cannonAngle * _local3));
if (_local3 == 1){
startEnemyFire();
};
_arg1.updateAfterEvent();
}
private function onTankPowerMoveTime(_arg1:TimerEvent):void{
var _local2:Number;
_local2 = ((NewTimer.getTimer() - startTime) % Config.TANK_POWERMOVEPERIOD);
if (_local2 < (Config.TANK_POWERMOVEPERIOD / 2)){
power = (_local2 / (Config.TANK_POWERMOVEPERIOD / 2));
} else {
power = ((Config.TANK_POWERMOVEPERIOD - _local2) / (Config.TANK_POWERMOVEPERIOD / 2));
};
tank.updatePower(power);
_arg1.updateAfterEvent();
}
private function startEnemyTurn():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
_local1 = ((tank.x - enemyTank.x) - ((Config.TANK_CANNONLENGTH + (snowball.width / 2)) * Math.SQRT2));
_local2 = ((-(wind) + Math.sqrt(((wind * wind) + ((2 * Config.SNOWBALL_ACCELERATION) * _local1)))) / Config.SNOWBALL_ACCELERATION);
_local3 = (((_local1 / _local2) - wind) * Math.SQRT2);
tank.updateCannonAngle(0);
cannonAngle = 45;
power = ((_local3 - Config.SNOWBALL_MINSPEED) / (Config.SNOWBALL_MAXSPEED - Config.SNOWBALL_MINSPEED));
cannonAngle = (cannonAngle + (angleAccuracy - ((Math.random() * angleAccuracy) * 2)));
if (cannonAngle < Config.TANK_CANNONMINANGLE){
cannonAngle = Config.TANK_CANNONMINANGLE;
} else {
if (cannonAngle > Config.TANK_CANNONMAXANGLE){
cannonAngle = Config.TANK_CANNONMAXANGLE;
};
};
power = (power + (powerAccuracy - ((Math.random() * powerAccuracy) * 2)));
if (power < 0){
power = 0;
} else {
if (power > 1){
power = 1;
};
};
startTime = NewTimer.getTimer();
intervalID = new NewTimer(1, 0);
intervalID.addEventListener(TimerEvent.TIMER, onMoveEnemyCannonTime);
intervalID.start();
}
private function hitWindMeter(_arg1:Number, _arg2:Number):void{
spark.showMiss(_arg1, _arg2);
startDissapearSpark();
soundFire.play();
}
private function startPlay(_arg1:TimerEvent):void{
intervalID.stop();
message.hide();
setWind();
startMoveCannon();
}
private function startEnemyFire():void{
intervalID.stop();
startTime = NewTimer.getTimer();
snowball.x = (enemyTank.x + ((Config.TANK_CANNONLENGTH + (snowball.width / 2)) * Math.cos(((cannonAngle * Math.PI) / 180))));
snowball.y = (enemyTank.y - ((Config.TANK_CANNONLENGTH + (snowball.width / 2)) * Math.sin(((cannonAngle * Math.PI) / 180))));
snowball.initialize(-(cannonAngle), power, wind, startTime);
soundFire.play();
intervalID = new NewTimer(1, 0);
intervalID.addEventListener(TimerEvent.TIMER, onFireTime);
intervalID.start();
}
private function startDissapearSpark():void{
snowball.visible = false;
intervalID.stop();
startTime = NewTimer.getTimer();
intervalID = new NewTimer(1, 0);
intervalID.addEventListener(TimerEvent.TIMER, onDisappearSparkTime);
intervalID.start();
}
private function startFire(_arg1:MouseEvent):void{
intervalID.stop();
tank.hideArrow();
startTime = NewTimer.getTimer();
snowball.x = (tank.x - ((Config.TANK_CANNONLENGTH + (snowball.width / 2)) * Math.cos(((cannonAngle * Math.PI) / 180))));
snowball.y = (tank.y - ((Config.TANK_CANNONLENGTH + (snowball.width / 2)) * Math.sin(((cannonAngle * Math.PI) / 180))));
snowball.initialize((cannonAngle - 180), power, wind, startTime);
soundFire.play();
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, startFire);
intervalID = new NewTimer(1, 0);
intervalID.addEventListener(TimerEvent.TIMER, onFireTime);
intervalID.start();
}
private function switchTurn(_arg1:TimerEvent):void{
intervalID.stop();
setWind();
if (isPlayerTurn){
startEnemyTurn();
} else {
startMoveCannon();
};
isPlayerTurn = !(isPlayerTurn);
}
private function checkDestroy():Boolean{
if (enemyTank.life <= 0){
message.showWin();
soundWin.play();
intervalID = new NewTimer(Config.MESSAGE_WINTIME, 0);
intervalID.addEventListener(TimerEvent.TIMER, startNextLevel);
intervalID.start();
return (true);
};
if (tank.life <= 0){
message.showGameOver();
soundGameOver.play();
intervalID = new NewTimer(Config.MESSAGE_GAMEOVERTIME, 0);
intervalID.addEventListener(TimerEvent.TIMER, showPlayAgain);
intervalID.start();
return (true);
};
return (false);
}
private function showPlayAgain(_arg1:TimerEvent):void{
intervalID.stop();
message.showPlayAgain();
Object(parent).showEnterHighScore(score);
}
}
}//package com.novelgames.flashgames.snowball
Section 27
//Logo (com.novelgames.flashgames.snowball.Logo)
package com.novelgames.flashgames.snowball {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class Logo extends MovieClip {
public function Logo(){
super();
this.addEventListener(MouseEvent.CLICK, function (_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.mygamesworld.com"), "_blank");
});
this.buttonMode = true;
}
}
}//package com.novelgames.flashgames.snowball
Section 28
//Main (com.novelgames.flashgames.snowball.Main)
package com.novelgames.flashgames.snowball {
import com.novelgames.flashgames.common.*;
import flash.media.*;
import flash.utils.*;
import com.novelgames.flashgames.highscores.*;
import com.novelgames.flashgames.preloader.*;
public class Main extends MainDevelopment {
public var __setPropDict:Dictionary;
public var title:Title;
public var highScores:HighScores;
public var __id0_:Preloader;
public function Main(){
__setPropDict = new Dictionary(true);
super();
addFrameScript(20, frame21, 21, frame22, 22, frame23, 23, frame24, 24, frame25, 25, frame26, 26, frame27, 27, frame28, 28, frame29, 29, frame30, 0, frame1, 1, frame2, 2, frame3, 3, frame4, 4, frame5, 5, frame6, 6, frame7, 7, frame8, 8, frame9, 9, frame10);
}
override protected function getMusicGame():Sound{
return (new MusicGame());
}
function __setProp_highScores_Scene1_highScores_21(){
try {
highScores["componentInspectorSetting"] = true;
} catch(e:Error) {
};
highScores.backgroundAlpha = 0.5;
highScores.backgroundColour = 0;
highScores.dialogAlpha = 1;
highScores.dialogBorderAlpha = 1;
highScores.dialogBorderColour = 0;
highScores.dialogBorderThickness = 5;
highScores.dialogColour = 0xFFFFFF;
highScores.enabled = true;
highScores.gameID = 107;
highScores.loadScoresAtStart = false;
highScores.loadScoresURL = "loadScores.php";
highScores.maxNoOfScores = 50;
highScores.saveScoreURL = "saveScore.php";
highScores.visible = true;
try {
highScores["componentInspectorSetting"] = false;
} catch(e:Error) {
};
}
function frame10(){
if ((((__setPropDict[__id0_] == undefined)) || (!((((int(__setPropDict[__id0_]) >= 1)) && ((int(__setPropDict[__id0_]) <= 10))))))){
__setPropDict[__id0_] = currentFrame;
__setProp___id0__Scene1_preloader_1();
};
}
function frame3(){
if ((((__setPropDict[__id0_] == undefined)) || (!((((int(__setPropDict[__id0_]) >= 1)) && ((int(__setPropDict[__id0_]) <= 10))))))){
__setPropDict[__id0_] = currentFrame;
__setProp___id0__Scene1_preloader_1();
};
}
function frame6(){
if ((((__setPropDict[__id0_] == undefined)) || (!((((int(__setPropDict[__id0_]) >= 1)) && ((int(__setPropDict[__id0_]) <= 10))))))){
__setPropDict[__id0_] = currentFrame;
__setProp___id0__Scene1_preloader_1();
};
}
function frame1(){
if ((((__setPropDict[__id0_] == undefined)) || (!((((int(__setPropDict[__id0_]) >= 1)) && ((int(__setPropDict[__id0_]) <= 10))))))){
__setPropDict[__id0_] = currentFrame;
__setProp___id0__Scene1_preloader_1();
};
}
function frame25(){
if ((((__setPropDict[highScores] == undefined)) || (!((((int(__setPropDict[highScores]) >= 21)) && ((int(__setPropDict[highScores]) <= 30))))))){
__setPropDict[highScores] = currentFrame;
__setProp_highScores_Scene1_highScores_21();
};
}
function frame26(){
if ((((__setPropDict[highScores] == undefined)) || (!((((int(__setPropDict[highScores]) >= 21)) && ((int(__setPropDict[highScores]) <= 30))))))){
__setPropDict[highScores] = currentFrame;
__setProp_highScores_Scene1_highScores_21();
};
}
function frame24(){
if ((((__setPropDict[highScores] == undefined)) || (!((((int(__setPropDict[highScores]) >= 21)) && ((int(__setPropDict[highScores]) <= 30))))))){
__setPropDict[highScores] = currentFrame;
__setProp_highScores_Scene1_highScores_21();
};
}
override protected function getGame():Game{
return (new Game());
}
function frame21(){
if ((((__setPropDict[highScores] == undefined)) || (!((((int(__setPropDict[highScores]) >= 21)) && ((int(__setPropDict[highScores]) <= 30))))))){
__setPropDict[highScores] = currentFrame;
__setProp_highScores_Scene1_highScores_21();
};
}
function frame22(){
if ((((__setPropDict[highScores] == undefined)) || (!((((int(__setPropDict[highScores]) >= 21)) && ((int(__setPropDict[highScores]) <= 30))))))){
__setPropDict[highScores] = currentFrame;
__setProp_highScores_Scene1_highScores_21();
};
}
function frame4(){
if ((((__setPropDict[__id0_] == undefined)) || (!((((int(__setPropDict[__id0_]) >= 1)) && ((int(__setPropDict[__id0_]) <= 10))))))){
__setPropDict[__id0_] = currentFrame;
__setProp___id0__Scene1_preloader_1();
};
}
function frame29(){
if ((((__setPropDict[highScores] == undefined)) || (!((((int(__setPropDict[highScores]) >= 21)) && ((int(__setPropDict[highScores]) <= 30))))))){
__setPropDict[highScores] = currentFrame;
__setProp_highScores_Scene1_highScores_21();
};
}
function frame9(){
if ((((__setPropDict[__id0_] == undefined)) || (!((((int(__setPropDict[__id0_]) >= 1)) && ((int(__setPropDict[__id0_]) <= 10))))))){
__setPropDict[__id0_] = currentFrame;
__setProp___id0__Scene1_preloader_1();
};
}
function frame2(){
if ((((__setPropDict[__id0_] == undefined)) || (!((((int(__setPropDict[__id0_]) >= 1)) && ((int(__setPropDict[__id0_]) <= 10))))))){
__setPropDict[__id0_] = currentFrame;
__setProp___id0__Scene1_preloader_1();
};
}
function frame27(){
if ((((__setPropDict[highScores] == undefined)) || (!((((int(__setPropDict[highScores]) >= 21)) && ((int(__setPropDict[highScores]) <= 30))))))){
__setPropDict[highScores] = currentFrame;
__setProp_highScores_Scene1_highScores_21();
};
}
function frame23(){
if ((((__setPropDict[highScores] == undefined)) || (!((((int(__setPropDict[highScores]) >= 21)) && ((int(__setPropDict[highScores]) <= 30))))))){
__setPropDict[highScores] = currentFrame;
__setProp_highScores_Scene1_highScores_21();
};
}
function frame30(){
if ((((__setPropDict[highScores] == undefined)) || (!((((int(__setPropDict[highScores]) >= 21)) && ((int(__setPropDict[highScores]) <= 30))))))){
__setPropDict[highScores] = currentFrame;
__setProp_highScores_Scene1_highScores_21();
};
}
function frame28(){
if ((((__setPropDict[highScores] == undefined)) || (!((((int(__setPropDict[highScores]) >= 21)) && ((int(__setPropDict[highScores]) <= 30))))))){
__setPropDict[highScores] = currentFrame;
__setProp_highScores_Scene1_highScores_21();
};
}
function frame7(){
if ((((__setPropDict[__id0_] == undefined)) || (!((((int(__setPropDict[__id0_]) >= 1)) && ((int(__setPropDict[__id0_]) <= 10))))))){
__setPropDict[__id0_] = currentFrame;
__setProp___id0__Scene1_preloader_1();
};
}
function frame8(){
if ((((__setPropDict[__id0_] == undefined)) || (!((((int(__setPropDict[__id0_]) >= 1)) && ((int(__setPropDict[__id0_]) <= 10))))))){
__setPropDict[__id0_] = currentFrame;
__setProp___id0__Scene1_preloader_1();
};
}
function frame5(){
if ((((__setPropDict[__id0_] == undefined)) || (!((((int(__setPropDict[__id0_]) >= 1)) && ((int(__setPropDict[__id0_]) <= 10))))))){
__setPropDict[__id0_] = currentFrame;
__setProp___id0__Scene1_preloader_1();
};
}
override protected function getTitle():Title{
return (title);
}
function __setProp___id0__Scene1_preloader_1(){
try {
__id0_["componentInspectorSetting"] = true;
} catch(e:Error) {
};
__id0_.background = "com.novelgames.flashgames.snowball.Logo";
__id0_.barBorderColour = 14748426;
__id0_.barBorderThickness = 2;
__id0_.barColourBottom = 16222733;
__id0_.barColourTop = 16497452;
__id0_.barHeight = 20;
__id0_.barWidth = 100;
__id0_.barX = 250;
__id0_.barY = 320;
__id0_.enabled = true;
__id0_.minShowTime = 8000;
__id0_.playOrStop = "stop";
__id0_.startLabel = "game";
__id0_.visible = true;
try {
__id0_["componentInspectorSetting"] = false;
} catch(e:Error) {
};
}
}
}//package com.novelgames.flashgames.snowball
Section 29
//Message (com.novelgames.flashgames.snowball.Message)
package com.novelgames.flashgames.snowball {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class Message extends MovieClip {
private var messagePlayAgain:MessagePlayAgain;
private var level:Number;
private var messageLevel:MessageLevel;
public function Message(){
stop();
}
public function showGameOver():void{
gotoAndStop("gameOver");
}
public function showPlayAgain():void{
gotoAndStop("hide");
messagePlayAgain = new MessagePlayAgain();
messagePlayAgain.playAgainButton.addEventListener(MouseEvent.CLICK, playAgainButtonClicked);
messagePlayAgain.homeButton.addEventListener(MouseEvent.CLICK, homeButtonClicked);
addChild(messagePlayAgain);
}
private function playAgainButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).gotoGamePage();
}
public function hide():void{
if (messageLevel){
this.removeChild(messageLevel);
messageLevel = null;
};
gotoAndStop("hide");
}
public function showLevel(_arg1:Number):void{
this.level = _arg1;
gotoAndStop("hide");
messageLevel = new MessageLevel();
messageLevel.levelText.text = _arg1.toString();
this.addChild(messageLevel);
}
public function showWin():void{
gotoAndStop("win");
}
private function homeButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).gotoTitlePage();
}
}
}//package com.novelgames.flashgames.snowball
Section 30
//MessageLevel (com.novelgames.flashgames.snowball.MessageLevel)
package com.novelgames.flashgames.snowball {
import flash.display.*;
import flash.text.*;
public dynamic class MessageLevel extends MovieClip {
public var levelText:TextField;
}
}//package com.novelgames.flashgames.snowball
Section 31
//MessagePlayAgain (com.novelgames.flashgames.snowball.MessagePlayAgain)
package com.novelgames.flashgames.snowball {
import flash.display.*;
public dynamic class MessagePlayAgain extends MovieClip {
public var playAgainButton:SimpleButton;
public var homeButton:SimpleButton;
}
}//package com.novelgames.flashgames.snowball
Section 32
//MusicGame (com.novelgames.flashgames.snowball.MusicGame)
package com.novelgames.flashgames.snowball {
import flash.media.*;
public dynamic class MusicGame extends Sound {
}
}//package com.novelgames.flashgames.snowball
Section 33
//Snowball (com.novelgames.flashgames.snowball.Snowball)
package com.novelgames.flashgames.snowball {
import flash.display.*;
public class Snowball extends MovieClip {
public var wind:Number;
public var startSpeedX:Number;
public var startSpeedY:Number;
public var startX:Number;
public var startY:Number;
public var startTime:Number;
public function initialize(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local5:Number;
startX = this.x;
startY = this.y;
_local5 = ((Config.SNOWBALL_MINSPEED * (1 - _arg2)) + (Config.SNOWBALL_MAXSPEED * _arg2));
startSpeedX = (_local5 * Math.cos(((_arg1 * Math.PI) / 180)));
startSpeedY = (_local5 * Math.sin(((_arg1 * Math.PI) / 180)));
this.wind = _arg3;
this.startTime = _arg4;
this.visible = true;
}
public function move(_arg1:Number):void{
var _local2:Number;
_local2 = (_arg1 - startTime);
this.x = (startX + (((startSpeedX + wind) * _local2) / 1000));
this.y = ((startY + ((startSpeedY * _local2) / 1000)) + (((Config.SNOWBALL_ACCELERATION * _local2) * _local2) / 2000000));
}
}
}//package com.novelgames.flashgames.snowball
Section 34
//SoundFire (com.novelgames.flashgames.snowball.SoundFire)
package com.novelgames.flashgames.snowball {
import flash.media.*;
public dynamic class SoundFire extends Sound {
}
}//package com.novelgames.flashgames.snowball
Section 35
//SoundGameOver (com.novelgames.flashgames.snowball.SoundGameOver)
package com.novelgames.flashgames.snowball {
import flash.media.*;
public dynamic class SoundGameOver extends Sound {
}
}//package com.novelgames.flashgames.snowball
Section 36
//SoundHit (com.novelgames.flashgames.snowball.SoundHit)
package com.novelgames.flashgames.snowball {
import flash.media.*;
public dynamic class SoundHit extends Sound {
}
}//package com.novelgames.flashgames.snowball
Section 37
//SoundWin (com.novelgames.flashgames.snowball.SoundWin)
package com.novelgames.flashgames.snowball {
import flash.media.*;
public dynamic class SoundWin extends Sound {
}
}//package com.novelgames.flashgames.snowball
Section 38
//Spark (com.novelgames.flashgames.snowball.Spark)
package com.novelgames.flashgames.snowball {
import flash.display.*;
public class Spark extends MovieClip {
public function Spark(){
stop();
this["cacheAsBitmap"] = true;
}
public function showHit(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
this.visible = true;
gotoAndStop("hit");
}
public function showMiss(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
this.visible = true;
gotoAndStop("miss");
}
}
}//package com.novelgames.flashgames.snowball
Section 39
//Tank (com.novelgames.flashgames.snowball.Tank)
package com.novelgames.flashgames.snowball {
import flash.display.*;
public class Tank extends MovieClip {
public var life:Number;
public var cannon:Cannon;
public function Tank(){
stop();
}
public function showArrow():void{
cannon.showArrow();
}
public function updateCannonAngle(_arg1:Number):void{
cannon.rotation = _arg1;
}
public function setLife(_arg1:Number):void{
this.life = _arg1;
gotoAndStop(("snow" + (Config.LIFE - _arg1)));
}
public function updatePower(_arg1:Number):void{
cannon.updatePower(_arg1);
}
public function hideArrow():void{
cannon.hideArrow();
}
}
}//package com.novelgames.flashgames.snowball
Section 40
//WindMeter (com.novelgames.flashgames.snowball.WindMeter)
package com.novelgames.flashgames.snowball {
import flash.display.*;
import flash.events.*;
import com.novelgames.flashgames.common.*;
import flash.utils.*;
public class WindMeter extends MovieClip {
private var startRotation:Number;
public var cups:MovieClip;
private var startSpeed:Number;
private var startCupsTime:Number;
public var arrow:MovieClip;
private var absSpeed:Number;
private var absStartSpeed:Number;
private var startArrowTime:Number;
private var speed:Number;
private var cupsIntervalID:Timer;
private var arrowIntervalID:Timer;
private function onCupsChangeTime(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number;
var _local4:Boolean;
_local2 = NewTimer.getTimer();
_local3 = (_local2 - startCupsTime);
_local4 = false;
if (absSpeed >= absStartSpeed){
cups.rotation = ((startRotation + ((absStartSpeed * _local3) / 1000)) + (((Config.WINDMETER_SPINACCELERATION * _local3) * _local3) / 2000000));
if ((absStartSpeed + ((Config.WINDMETER_SPINACCELERATION * _local3) / 1000)) >= absSpeed){
_local4 = true;
};
} else {
cups.rotation = ((startRotation + ((absStartSpeed * _local3) / 1000)) - (((Config.WINDMETER_SPINACCELERATION * _local3) * _local3) / 2000000));
if ((absStartSpeed - ((Config.WINDMETER_SPINACCELERATION * _local3) / 1000)) <= absSpeed){
_local4 = true;
};
};
if (_local4){
startRotation = cups.rotation;
startCupsTime = _local2;
cupsIntervalID.stop();
cupsIntervalID = new NewTimer(1, 0);
cupsIntervalID.addEventListener(TimerEvent.TIMER, onCupsTime);
cupsIntervalID.start();
};
_arg1.updateAfterEvent();
}
private function onCupsTime(_arg1:TimerEvent):void{
var _local2:Number;
_local2 = NewTimer.getTimer();
cups.rotation = (startRotation + ((absSpeed * (_local2 - startCupsTime)) / 1000));
_arg1.updateAfterEvent();
}
public function setWind(_arg1:Number):void{
startRotation = cups.rotation;
startSpeed = speed;
absStartSpeed = absSpeed;
startCupsTime = NewTimer.getTimer();
startArrowTime = startCupsTime;
speed = ((Config.WINDMETER_MAXSPINSPEED * _arg1) / Config.WIND_MAX);
absSpeed = Math.abs(speed);
if (cupsIntervalID){
cupsIntervalID.stop();
};
cupsIntervalID = new NewTimer(1, 0);
cupsIntervalID.addEventListener(TimerEvent.TIMER, onCupsChangeTime);
cupsIntervalID.start();
if ((((((startSpeed >= 0)) && ((speed < 0)))) || ((((startSpeed < 0)) && ((speed >= 0)))))){
if (arrowIntervalID){
arrowIntervalID.stop();
};
arrowIntervalID = new NewTimer(1, 0);
arrowIntervalID.addEventListener(TimerEvent.TIMER, onArrowChangeTime);
arrowIntervalID.start();
};
}
public function initialize():void{
speed = 0;
absSpeed = 0;
arrow.scaleX = 1;
}
private function onArrowChangeTime(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number;
_local2 = NewTimer.getTimer();
_local3 = ((_local2 - startArrowTime) / Config.WINDMETER_ARROWTIME);
if (_local3 > 1){
_local3 = 1;
};
if ((((startSpeed >= 0)) && ((speed < 0)))){
arrow.scaleX = (1 - (2 * _local3));
} else {
arrow.scaleX = (-1 + (2 * _local3));
};
if (_local3 == 1){
arrowIntervalID.stop();
};
_arg1.updateAfterEvent();
}
}
}//package com.novelgames.flashgames.snowball
Section 41
//BaseButton (fl.controls.BaseButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.utils.*;
import fl.events.*;
public class BaseButton extends UIComponent {
protected var _selected:Boolean;// = false
private var unlockedMouseState:String;
protected var pressTimer:Timer;
protected var mouseState:String;
protected var background:DisplayObject;
private var _mouseStateLocked:Boolean;// = false
protected var _autoRepeat:Boolean;// = false
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(){
_selected = false;
_autoRepeat = false;
_mouseStateLocked = false;
super();
buttonMode = true;
mouseChildren = false;
useHandCursor = false;
setupMouseEvents();
setMouseState("up");
pressTimer = new Timer(1, 0);
pressTimer.addEventListener(TimerEvent.TIMER, buttonDown, false, 0, true);
}
protected function endPress():void{
pressTimer.reset();
}
public function set mouseStateLocked(_arg1:Boolean):void{
_mouseStateLocked = _arg1;
if (_arg1 == false){
setMouseState(unlockedMouseState);
} else {
unlockedMouseState = mouseState;
};
}
public function get autoRepeat():Boolean{
return (_autoRepeat);
}
public function set autoRepeat(_arg1:Boolean):void{
_autoRepeat = _arg1;
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
mouseEnabled = _arg1;
}
public function get selected():Boolean{
return (_selected);
}
protected function mouseEventHandler(_arg1:MouseEvent):void{
if (_arg1.type == MouseEvent.MOUSE_DOWN){
setMouseState("down");
startPress();
} else {
if ((((_arg1.type == MouseEvent.ROLL_OVER)) || ((_arg1.type == MouseEvent.MOUSE_UP)))){
setMouseState("over");
endPress();
} else {
if (_arg1.type == MouseEvent.ROLL_OUT){
setMouseState("up");
endPress();
};
};
};
}
public function setMouseState(_arg1:String):void{
if (_mouseStateLocked){
unlockedMouseState = _arg1;
return;
};
if (mouseState == _arg1){
return;
};
mouseState = _arg1;
invalidate(InvalidationType.STATE);
}
protected function startPress():void{
if (_autoRepeat){
pressTimer.delay = Number(getStyleValue("repeatDelay"));
pressTimer.start();
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
protected function buttonDown(_arg1:TimerEvent):void{
if (!_autoRepeat){
endPress();
return;
};
if (pressTimer.currentCount == 1){
pressTimer.delay = Number(getStyleValue("repeatInterval"));
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
public function set selected(_arg1:Boolean):void{
if (_selected == _arg1){
return;
};
_selected = _arg1;
invalidate(InvalidationType.STATE);
}
override public function get enabled():Boolean{
return (super.enabled);
}
override protected function draw():void{
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
super.draw();
}
protected function setupMouseEvents():void{
addEventListener(MouseEvent.ROLL_OVER, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_DOWN, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_UP, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.ROLL_OUT, mouseEventHandler, false, 0, true);
}
protected function drawLayout():void{
background.width = width;
background.height = height;
}
protected function drawBackground():void{
var _local1:String;
var _local2:DisplayObject;
_local1 = (enabled) ? mouseState : "disabled";
if (selected){
_local1 = (("selected" + _local1.substr(0, 1).toUpperCase()) + _local1.substr(1));
};
_local1 = (_local1 + "Skin");
_local2 = background;
background = getDisplayObjectInstance(getStyleValue(_local1));
addChildAt(background, 0);
if (((!((_local2 == null))) && (!((_local2 == background))))){
removeChild(_local2);
};
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 42
//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 emphasizedBorder:DisplayObject;
protected var _emphasized:Boolean;// = false
private static var defaultStyles:Object = {emphasizedSkin:"Button_emphasizedSkin", emphasizedPadding:2};
public static var createAccessibilityImplementation:Function;
public function Button(){
_emphasized = false;
super();
}
override public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
var _local3:*;
super.drawFocus(_arg1);
if (_arg1){
_local2 = Number(getStyleValue("emphasizedPadding"));
if ((((_local2 < 0)) || (!(_emphasized)))){
_local2 = 0;
};
_local3 = getStyleValue("focusRectPadding");
_local3 = ((_local3)==null) ? 2 : _local3;
_local3 = (_local3 + _local2);
uiFocusRect.x = -(_local3);
uiFocusRect.y = -(_local3);
uiFocusRect.width = (width + (_local3 * 2));
uiFocusRect.height = (height + (_local3 * 2));
};
}
public function set emphasized(_arg1:Boolean):void{
_emphasized = _arg1;
invalidate(InvalidationType.STYLES);
}
override protected function draw():void{
if (((isInvalid(InvalidationType.STYLES)) || (isInvalid(InvalidationType.SIZE)))){
drawEmphasized();
};
super.draw();
if (emphasizedBorder != null){
setChildIndex(emphasizedBorder, (numChildren - 1));
};
}
public function get emphasized():Boolean{
return (_emphasized);
}
override protected function initializeAccessibility():void{
if (Button.createAccessibilityImplementation != null){
Button.createAccessibilityImplementation(this);
};
}
protected function drawEmphasized():void{
var _local1:Object;
var _local2:Number;
if (emphasizedBorder != null){
removeChild(emphasizedBorder);
};
emphasizedBorder = null;
if (!_emphasized){
return;
};
_local1 = getStyleValue("emphasizedSkin");
if (_local1 != null){
emphasizedBorder = getDisplayObjectInstance(_local1);
};
if (emphasizedBorder != null){
addChildAt(emphasizedBorder, 0);
_local2 = Number(getStyleValue("emphasizedPadding"));
emphasizedBorder.x = (emphasizedBorder.y = -(_local2));
emphasizedBorder.width = (width + (_local2 * 2));
emphasizedBorder.height = (height + (_local2 * 2));
};
}
public static function getStyleDefinition():Object{
return (UIComponent.mergeStyles(LabelButton.getStyleDefinition(), defaultStyles));
}
}
}//package fl.controls
Section 43
//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 44
//LabelButton (fl.controls.LabelButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import fl.managers.*;
import fl.events.*;
import flash.text.*;
import flash.ui.*;
public class LabelButton extends BaseButton implements IFocusManagerComponent {
protected var _labelPlacement:String;// = "right"
protected var _toggle:Boolean;// = false
protected var icon:DisplayObject;
protected var oldMouseState:String;
protected var mode:String;// = "center"
public var textField:TextField;
protected var _label:String;// = "Label"
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;
public function LabelButton(){
_labelPlacement = ButtonLabelPlacement.RIGHT;
_toggle = false;
_label = "Label";
mode = "center";
super();
}
protected function toggleSelected(_arg1:MouseEvent):void{
selected = !(selected);
dispatchEvent(new Event(Event.CHANGE, true));
}
public function get labelPlacement():String{
return (_labelPlacement);
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
if (oldMouseState == null){
oldMouseState = mouseState;
};
setMouseState("down");
startPress();
};
}
protected function setEmbedFont(){
var _local1:Object;
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
}
override protected function keyUpHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
setMouseState(oldMouseState);
oldMouseState = null;
endPress();
dispatchEvent(new MouseEvent(MouseEvent.CLICK));
};
}
override public function get selected():Boolean{
return ((_toggle) ? _selected : false);
}
public function set labelPlacement(_arg1:String):void{
_labelPlacement = _arg1;
invalidate(InvalidationType.SIZE);
}
public function set toggle(_arg1:Boolean):void{
if (((!(_arg1)) && (super.selected))){
selected = false;
};
_toggle = _arg1;
if (_toggle){
addEventListener(MouseEvent.CLICK, toggleSelected, false, 0, true);
} else {
removeEventListener(MouseEvent.CLICK, toggleSelected);
};
invalidate(InvalidationType.STATE);
}
public function get label():String{
return (_label);
}
override public function set selected(_arg1:Boolean):void{
_selected = _arg1;
if (_toggle){
invalidate(InvalidationType.STATE);
};
}
override protected function draw():void{
if (textField.text != _label){
label = _label;
};
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
drawIcon();
drawTextFormat();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
public function get toggle():Boolean{
return (_toggle);
}
override protected function configUI():void{
super.configUI();
textField = new TextField();
textField.type = TextFieldType.DYNAMIC;
textField.selectable = false;
addChild(textField);
}
override protected function drawLayout():void{
var _local1:Number;
var _local2:String;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local1 = Number(getStyleValue("textPadding"));
_local2 = ((((icon == null)) && ((mode == "center")))) ? ButtonLabelPlacement.TOP : _labelPlacement;
textField.height = (textField.textHeight + 4);
_local3 = (textField.textWidth + 4);
_local4 = (textField.textHeight + 4);
_local5 = ((icon)==null) ? 0 : (icon.width + _local1);
_local6 = ((icon)==null) ? 0 : (icon.height + _local1);
textField.visible = (label.length > 0);
if (icon != null){
icon.x = Math.round(((width - icon.width) / 2));
icon.y = Math.round(((height - icon.height) / 2));
};
if (textField.visible == false){
textField.width = 0;
textField.height = 0;
} else {
if ((((_local2 == ButtonLabelPlacement.BOTTOM)) || ((_local2 == ButtonLabelPlacement.TOP)))){
_local7 = Math.max(0, Math.min(_local3, (width - (2 * _local1))));
if ((height - 2) > _local4){
_local8 = _local4;
} else {
_local8 = (height - 2);
};
_local3 = _local7;
textField.width = _local3;
_local4 = _local8;
textField.height = _local4;
textField.x = Math.round(((width - _local3) / 2));
textField.y = Math.round(((((height - textField.height) - _local6) / 2) + ((_local2)==ButtonLabelPlacement.BOTTOM) ? _local6 : 0));
if (icon != null){
icon.y = Math.round(((_local2)==ButtonLabelPlacement.BOTTOM) ? (textField.y - _local6) : ((textField.y + textField.height) + _local1));
};
} else {
_local7 = Math.max(0, Math.min(_local3, ((width - _local5) - (2 * _local1))));
_local3 = _local7;
textField.width = _local3;
textField.x = Math.round(((((width - _local3) - _local5) / 2) + ((_local2)!=ButtonLabelPlacement.LEFT) ? _local5 : 0));
textField.y = Math.round(((height - textField.height) / 2));
if (icon != null){
icon.x = Math.round(((_local2)!=ButtonLabelPlacement.LEFT) ? (textField.x - _local5) : ((textField.x + _local3) + _local1));
};
};
};
super.drawLayout();
}
override protected function initializeAccessibility():void{
if (LabelButton.createAccessibilityImplementation != null){
LabelButton.createAccessibilityImplementation(this);
};
}
protected function drawIcon():void{
var _local1:DisplayObject;
var _local2:String;
var _local3:Object;
_local1 = icon;
_local2 = (enabled) ? mouseState : "disabled";
if (selected){
_local2 = (("selected" + _local2.substr(0, 1).toUpperCase()) + _local2.substr(1));
};
_local2 = (_local2 + "Icon");
_local3 = getStyleValue(_local2);
if (_local3 == null){
_local3 = getStyleValue("icon");
};
if (_local3 != null){
icon = getDisplayObjectInstance(_local3);
};
if (icon != null){
addChildAt(icon, 1);
};
if (((!((_local1 == null))) && (!((_local1 == icon))))){
removeChild(_local1);
};
}
public function set label(_arg1:String):void{
_label = _arg1;
if (textField.text != _label){
textField.text = _label;
dispatchEvent(new ComponentEvent(ComponentEvent.LABEL_CHANGE));
};
invalidate(InvalidationType.SIZE);
invalidate(InvalidationType.STYLES);
}
protected function drawTextFormat():void{
var _local1:Object;
var _local2:TextFormat;
var _local3:TextFormat;
_local1 = UIComponent.getStyleDefinition();
_local2 = (enabled) ? (_local1.defaultTextFormat as TextFormat) : (_local1.defaultDisabledTextFormat as TextFormat);
textField.setTextFormat(_local2);
_local3 = (getStyleValue((enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (_local3 != null){
textField.setTextFormat(_local3);
} else {
_local3 = _local2;
};
textField.defaultTextFormat = _local3;
setEmbedFont();
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, BaseButton.getStyleDefinition()));
}
}
}//package fl.controls
Section 45
//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 46
//UIComponent (fl.core.UIComponent)
package fl.core {
import flash.display.*;
import flash.events.*;
import fl.managers.*;
import flash.utils.*;
import fl.events.*;
import flash.text.*;
import flash.system.*;
public class UIComponent extends Sprite {
protected var _enabled:Boolean;// = true
private var _mouseFocusEnabled:Boolean;// = true
protected var startHeight:Number;
protected var _height:Number;
protected var _oldIMEMode:String;// = null
protected var startWidth:Number;
public var focusTarget:IFocusManagerComponent;
protected var errorCaught:Boolean;// = false
protected var uiFocusRect:DisplayObject;
protected var _width:Number;
public var version:String;// = "3.0.0.15"
protected var isFocused:Boolean;// = false
protected var callLaterMethods:Dictionary;
private var _focusEnabled:Boolean;// = true
private var tempText:TextField;
protected var invalidateFlag:Boolean;// = false
protected var _inspector:Boolean;// = false
protected var sharedStyles:Object;
protected var invalidHash:Object;
protected var isLivePreview:Boolean;// = false
protected var _imeMode:String;// = null
protected var instanceStyles:Object;
protected var _x:Number;
protected var _y:Number;
public 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(){
version = "3.0.0.15";
isLivePreview = false;
invalidateFlag = false;
_enabled = true;
isFocused = false;
_focusEnabled = true;
_mouseFocusEnabled = true;
_imeMode = null;
_oldIMEMode = null;
errorCaught = false;
_inspector = false;
super();
instanceStyles = {};
sharedStyles = {};
invalidHash = {};
callLaterMethods = new Dictionary();
StyleManager.registerInstance(this);
configUI();
invalidate(InvalidationType.ALL);
tabEnabled = (this is IFocusManagerComponent);
focusRect = false;
if (tabEnabled){
addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
};
initializeFocusManager();
addEventListener(Event.ENTER_FRAME, hookAccessibility, false, 0, true);
}
public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
isFocused = _arg1;
if (((!((uiFocusRect == null))) && (contains(uiFocusRect)))){
removeChild(uiFocusRect);
uiFocusRect = null;
};
if (_arg1){
uiFocusRect = (getDisplayObjectInstance(getStyleValue("focusRectSkin")) as Sprite);
if (uiFocusRect == null){
return;
};
_local2 = Number(getStyleValue("focusRectPadding"));
uiFocusRect.x = -(_local2);
uiFocusRect.y = -(_local2);
uiFocusRect.width = (width + (_local2 * 2));
uiFocusRect.height = (height + (_local2 * 2));
addChildAt(uiFocusRect, 0);
};
}
private function callLaterDispatcher(_arg1:Event):void{
var _local2:Dictionary;
var _local3:Object;
if (_arg1.type == Event.ADDED_TO_STAGE){
removeEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher);
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
return;
};
_arg1.target.removeEventListener(Event.RENDER, callLaterDispatcher);
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
return;
};
inCallLaterPhase = true;
_local2 = callLaterMethods;
for (_local3 in _local2) {
_local3();
delete _local2[_local3];
};
inCallLaterPhase = false;
}
private function addedHandler(_arg1:Event):void{
removeEventListener("addedToStage", addedHandler);
initializeFocusManager();
}
protected function getStyleValue(_arg1:String):Object{
return (((instanceStyles[_arg1])==null) ? sharedStyles[_arg1] : instanceStyles[_arg1]);
}
protected function isOurFocus(_arg1:DisplayObject):Boolean{
return ((_arg1 == this));
}
override public function get scaleX():Number{
return ((width / startWidth));
}
override public function get scaleY():Number{
return ((height / startHeight));
}
override public function set height(_arg1:Number):void{
if (_height == _arg1){
return;
};
setSize(width, _arg1);
}
protected function keyDownHandler(_arg1:KeyboardEvent):void{
}
protected function focusInHandler(_arg1:FocusEvent):void{
var _local2:IFocusManager;
if (isOurFocus((_arg1.target as DisplayObject))){
_local2 = focusManager;
if (((_local2) && (_local2.showFocusIndicator))){
drawFocus(true);
isFocused = true;
};
};
}
public function setStyle(_arg1:String, _arg2:Object):void{
if ((((instanceStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
instanceStyles[_arg1] = _arg2;
invalidate(InvalidationType.STYLES);
}
override public function get visible():Boolean{
return (super.visible);
}
public function get componentInspectorSetting():Boolean{
return (_inspector);
}
override public function get x():Number{
return ((isNaN(_x)) ? super.x : _x);
}
override public function get y():Number{
return ((isNaN(_y)) ? super.y : _y);
}
protected function setIMEMode(_arg1:Boolean){
var enabled = _arg1;
if (_imeMode != null){
if (enabled){
IME.enabled = true;
_oldIMEMode = IME.conversionMode;
try {
if (((!(errorCaught)) && (!((IME.conversionMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _imeMode;
};
errorCaught = false;
} catch(e:Error) {
errorCaught = true;
throw (new Error(("IME mode not supported: " + _imeMode)));
};
} else {
if (((!((IME.conversionMode == IMEConversionMode.UNKNOWN))) && (!((_oldIMEMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _oldIMEMode;
};
IME.enabled = false;
};
};
}
public function set enabled(_arg1:Boolean):void{
if (_arg1 == _enabled){
return;
};
_enabled = _arg1;
invalidate(InvalidationType.STATE);
}
public function setSharedStyle(_arg1:String, _arg2:Object):void{
if ((((sharedStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
sharedStyles[_arg1] = _arg2;
if (instanceStyles[_arg1] == null){
invalidate(InvalidationType.STYLES);
};
}
protected function keyUpHandler(_arg1:KeyboardEvent):void{
}
public function set focusEnabled(_arg1:Boolean):void{
_focusEnabled = _arg1;
}
override public function set scaleX(_arg1:Number):void{
setSize((startWidth * _arg1), height);
}
public function get mouseFocusEnabled():Boolean{
return (_mouseFocusEnabled);
}
override public function set scaleY(_arg1:Number):void{
setSize(width, (startHeight * _arg1));
}
protected function getDisplayObjectInstance(_arg1:Object):DisplayObject{
var classDef:Object;
var skin = _arg1;
classDef = null;
if ((skin is Class)){
return ((new (skin) as DisplayObject));
};
if ((skin is DisplayObject)){
(skin as DisplayObject).x = 0;
(skin as DisplayObject).y = 0;
return ((skin as DisplayObject));
};
try {
classDef = getDefinitionByName(skin.toString());
} catch(e:Error) {
try {
classDef = (loaderInfo.applicationDomain.getDefinition(skin.toString()) as Object);
} catch(e:Error) {
};
};
if (classDef == null){
return (null);
};
return ((new (classDef) as DisplayObject));
}
protected function copyStylesToChild(_arg1:UIComponent, _arg2:Object):void{
var _local3:String;
for (_local3 in _arg2) {
_arg1.setStyle(_local3, getStyleValue(_arg2[_local3]));
};
}
protected function beforeComponentParameters():void{
}
protected function callLater(_arg1:Function):void{
if (inCallLaterPhase){
return;
};
callLaterMethods[_arg1] = true;
if (stage != null){
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
} else {
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
};
}
protected function createFocusManager():void{
if (focusManagers[stage] == null){
focusManagers[stage] = new FocusManager(stage);
};
}
override public function set visible(_arg1:Boolean):void{
var _local2:String;
if (super.visible == _arg1){
return;
};
super.visible = _arg1;
_local2 = (_arg1) ? ComponentEvent.SHOW : ComponentEvent.HIDE;
dispatchEvent(new ComponentEvent(_local2, true));
}
protected function hookAccessibility(_arg1:Event):void{
removeEventListener(Event.ENTER_FRAME, hookAccessibility);
initializeAccessibility();
}
public function set componentInspectorSetting(_arg1:Boolean):void{
_inspector = _arg1;
if (_inspector){
beforeComponentParameters();
} else {
afterComponentParameters();
};
}
override public function set x(_arg1:Number):void{
move(_arg1, _y);
}
public function drawNow():void{
draw();
}
override public function set y(_arg1:Number):void{
move(_x, _arg1);
}
protected function checkLivePreview():Boolean{
var className:String;
if (parent == null){
return (false);
};
try {
className = getQualifiedClassName(parent);
} catch(e:Error) {
};
return ((className == "fl.livepreview::LivePreviewParent"));
}
protected function focusOutHandler(_arg1:FocusEvent):void{
if (isOurFocus((_arg1.target as DisplayObject))){
drawFocus(false);
isFocused = false;
};
}
public function set mouseFocusEnabled(_arg1:Boolean):void{
_mouseFocusEnabled = _arg1;
}
public function getFocus():InteractiveObject{
if (stage){
return (stage.focus);
};
return (null);
}
protected function validate():void{
invalidHash = {};
}
override public function get height():Number{
return (_height);
}
public function invalidate(_arg1:String="all", _arg2:Boolean=true):void{
invalidHash[_arg1] = true;
if (_arg2){
this.callLater(draw);
};
}
public function get enabled():Boolean{
return (_enabled);
}
protected function getScaleX():Number{
return (super.scaleX);
}
protected function getScaleY():Number{
return (super.scaleY);
}
public function get focusEnabled():Boolean{
return (_focusEnabled);
}
protected function afterComponentParameters():void{
}
protected function draw():void{
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
protected function configUI():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
isLivePreview = checkLivePreview();
_local1 = rotation;
rotation = 0;
_local2 = super.width;
_local3 = super.height;
var _local4 = 1;
super.scaleY = _local4;
super.scaleX = _local4;
setSize(_local2, _local3);
move(super.x, super.y);
rotation = _local1;
startWidth = _local2;
startHeight = _local3;
if (numChildren > 0){
removeChildAt(0);
};
}
protected function setScaleX(_arg1:Number):void{
super.scaleX = _arg1;
}
protected function setScaleY(_arg1:Number):void{
super.scaleY = _arg1;
}
private function initializeFocusManager():void{
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, addedHandler, false, 0, true);
} else {
createFocusManager();
};
}
public function set focusManager(_arg1:IFocusManager):void{
UIComponent.focusManagers[this] = _arg1;
}
public function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
protected function isInvalid(_arg1:String, ... _args):Boolean{
if (((invalidHash[_arg1]) || (invalidHash[InvalidationType.ALL]))){
return (true);
};
while (_args.length > 0) {
if (invalidHash[_args.pop()]){
return (true);
};
};
return (false);
}
public function setSize(_arg1:Number, _arg2:Number):void{
_width = _arg1;
_height = _arg2;
invalidate(InvalidationType.SIZE);
dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, false));
}
override public function set width(_arg1:Number):void{
if (_width == _arg1){
return;
};
setSize(_arg1, height);
}
public function setFocus():void{
if (stage){
stage.focus = this;
};
}
protected function initializeAccessibility():void{
if (UIComponent.createAccessibilityImplementation != null){
UIComponent.createAccessibilityImplementation(this);
};
}
public function get focusManager():IFocusManager{
var _local1:DisplayObject;
_local1 = this;
while (_local1) {
if (UIComponent.focusManagers[_local1] != null){
return (IFocusManager(UIComponent.focusManagers[_local1]));
};
_local1 = _local1.parent;
};
return (null);
}
override public function get width():Number{
return (_width);
}
public function move(_arg1:Number, _arg2:Number):void{
_x = _arg1;
_y = _arg2;
super.x = Math.round(_arg1);
super.y = Math.round(_arg2);
dispatchEvent(new ComponentEvent(ComponentEvent.MOVE));
}
public function validateNow():void{
invalidate(InvalidationType.ALL, false);
draw();
}
public function getStyle(_arg1:String):Object{
return (instanceStyles[_arg1]);
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
public static function mergeStyles(... _args):Object{
var _local2:Object;
var _local3:uint;
var _local4:uint;
var _local5:Object;
var _local6:String;
_local2 = {};
_local3 = _args.length;
_local4 = 0;
while (_local4 < _local3) {
_local5 = _args[_local4];
for (_local6 in _local5) {
if (_local2[_local6] != null){
} else {
_local2[_local6] = _args[_local4][_local6];
};
};
_local4++;
};
return (_local2);
}
}
}//package fl.core
Section 47
//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 48
//FocusManager (fl.managers.FocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*;
import flash.ui.*;
public class FocusManager implements IFocusManager {
private var focusableObjects:Dictionary;
private var _showFocusIndicator:Boolean;// = true
private var defButton:Button;
private var focusableCandidates:Array;
private var _form:DisplayObjectContainer;
private var _defaultButtonEnabled:Boolean;// = true
private var activated:Boolean;// = false
private var _defaultButton:Button;
private var calculateCandidates:Boolean;// = true
private var lastFocus:InteractiveObject;
private var lastAction:String;
public function FocusManager(_arg1:DisplayObjectContainer){
activated = false;
calculateCandidates = true;
_showFocusIndicator = true;
_defaultButtonEnabled = true;
super();
focusableObjects = new Dictionary(true);
if (_arg1 != null){
_form = _arg1;
addFocusables(DisplayObject(_arg1));
_arg1.addEventListener(Event.ADDED, addedHandler);
_arg1.addEventListener(Event.REMOVED, removedHandler);
activate();
};
}
public function get showFocusIndicator():Boolean{
return (_showFocusIndicator);
}
private function getIndexOfNextObject(_arg1:int, _arg2:Boolean, _arg3:Boolean, _arg4:String):int{
var _local5:int;
var _local6:int;
var _local7:DisplayObject;
var _local8:IFocusManagerGroup;
var _local9:int;
var _local10:DisplayObject;
var _local11:IFocusManagerGroup;
_local5 = focusableCandidates.length;
_local6 = _arg1;
while (true) {
if (_arg2){
_arg1--;
} else {
_arg1++;
};
if (_arg3){
if (((_arg2) && ((_arg1 < 0)))){
break;
};
if (((!(_arg2)) && ((_arg1 == _local5)))){
break;
};
} else {
_arg1 = ((_arg1 + _local5) % _local5);
if (_local6 == _arg1){
break;
};
};
if (isValidFocusCandidate(focusableCandidates[_arg1], _arg4)){
_local7 = DisplayObject(findFocusManagerComponent(focusableCandidates[_arg1]));
if ((_local7 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local7);
_local9 = 0;
while (_local9 < focusableCandidates.length) {
_local10 = focusableCandidates[_local9];
if ((_local10 is IFocusManagerGroup)){
_local11 = IFocusManagerGroup(_local10);
if ((((_local11.groupName == _local8.groupName)) && (_local11.selected))){
_arg1 = _local9;
break;
};
};
_local9++;
};
};
return (_arg1);
};
};
return (_arg1);
}
public function set form(_arg1:DisplayObjectContainer):void{
_form = _arg1;
}
private function addFocusables(_arg1:DisplayObject, _arg2:Boolean=false):void{
var focusable: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));
}
private function mouseFocusChangeHandler(_arg1:FocusEvent):void{
if ((_arg1.relatedObject is TextField)){
return;
};
_arg1.preventDefault();
}
private function focusOutHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
_local2 = (_arg1.target as InteractiveObject);
}
private function isValidFocusCandidate(_arg1:DisplayObject, _arg2:String):Boolean{
var _local3:IFocusManagerGroup;
if (!isEnabledAndVisible(_arg1)){
return (false);
};
if ((_arg1 is IFocusManagerGroup)){
_local3 = IFocusManagerGroup(_arg1);
if (_arg2 == _local3.groupName){
return (false);
};
};
return (true);
}
public function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject{
var _local2:InteractiveObject;
_local2 = _arg1;
while (_arg1) {
if ((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
};
return (_local2);
}
private function sortFocusableObjectsTabIndex():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))){
focusableCandidates.push(_local2);
};
};
focusableCandidates.sort(sortByTabIndex);
}
private function removeFocusables(_arg1:DisplayObject):void{
var _local2:Object;
var _local3:DisplayObject;
if ((_arg1 is DisplayObjectContainer)){
_arg1.removeEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
_arg1.removeEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
for (_local2 in focusableObjects) {
_local3 = DisplayObject(_local2);
if (DisplayObjectContainer(_arg1).contains(_local3)){
if (_local3 == lastFocus){
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local2];
calculateCandidates = true;
};
};
};
}
private function addedHandler(_arg1:Event):void{
var _local2:DisplayObject;
_local2 = DisplayObject(_arg1.target);
if (_local2.stage){
addFocusables(DisplayObject(_arg1.target));
};
}
private function getTopLevelFocusTarget(_arg1:InteractiveObject):InteractiveObject{
while (_arg1 != InteractiveObject(form)) {
if ((((((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))) && (IFocusManagerComponent(_arg1).mouseFocusEnabled))) && (UIComponent(_arg1).enabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
if (_arg1 == null){
break;
};
};
return (null);
}
private function tabChildrenChangeHandler(_arg1:Event):void{
var _local2:DisplayObjectContainer;
if (_arg1.target != _arg1.currentTarget){
return;
};
calculateCandidates = true;
_local2 = DisplayObjectContainer(_arg1.target);
if (_local2.tabChildren){
addFocusables(_local2, true);
} else {
removeFocusables(_local2);
};
}
public function sendDefaultButtonEvent():void{
defButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
public function getFocus():InteractiveObject{
var _local1:InteractiveObject;
_local1 = form.stage.focus;
return (findFocusManagerComponent(_local1));
}
private function isEnabledAndVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
var _local3:TextField;
var _local4:SimpleButton;
_local2 = DisplayObject(form).parent;
while (_arg1 != _local2) {
if ((_arg1 is UIComponent)){
if (!UIComponent(_arg1).enabled){
return (false);
};
} else {
if ((_arg1 is TextField)){
_local3 = TextField(_arg1);
if ((((_local3.type == TextFieldType.DYNAMIC)) || (!(_local3.selectable)))){
return (false);
};
} else {
if ((_arg1 is SimpleButton)){
_local4 = SimpleButton(_arg1);
if (!_local4.enabled){
return (false);
};
};
};
};
if (!_arg1.visible){
return (false);
};
_arg1 = _arg1.parent;
};
return (true);
}
public function set defaultButton(_arg1:Button):void{
var _local2:Button;
_local2 = (_arg1) ? Button(_arg1) : null;
if (_local2 != _defaultButton){
if (_defaultButton){
_defaultButton.emphasized = false;
};
if (defButton){
defButton.emphasized = false;
};
_defaultButton = _local2;
defButton = _local2;
if (_local2){
_local2.emphasized = true;
};
};
}
private function deactivateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
}
public function setFocus(_arg1:InteractiveObject):void{
if ((_arg1 is IFocusManagerComponent)){
IFocusManagerComponent(_arg1).setFocus();
} else {
form.stage.focus = _arg1;
};
}
private function setFocusToNextObject(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
if (!hasFocusableObjects()){
return;
};
_local2 = getNextFocusManagerComponent(_arg1.shiftKey);
if (_local2){
setFocus(_local2);
};
}
private function hasFocusableObjects():Boolean{
var _local1:Object;
for (_local1 in focusableObjects) {
return (true);
};
return (false);
}
private function tabIndexChangeHandler(_arg1:Event):void{
calculateCandidates = true;
}
private function sortFocusableObjects():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))) && ((_local2.tabIndex > 0)))){
sortFocusableObjectsTabIndex();
return;
};
focusableCandidates.push(_local2);
};
focusableCandidates.sort(sortByDepth);
}
private function keyFocusChangeHandler(_arg1:FocusEvent):void{
showFocusIndicator = true;
if ((((((_arg1.keyCode == Keyboard.TAB)) || ((_arg1.keyCode == 0)))) && (!(_arg1.isDefaultPrevented())))){
setFocusToNextObject(_arg1);
_arg1.preventDefault();
};
}
private function getIndexOfFocusedObject(_arg1:DisplayObject):int{
var _local2:int;
var _local3:int;
_local2 = focusableCandidates.length;
_local3 = 0;
_local3 = 0;
while (_local3 < _local2) {
if (focusableCandidates[_local3] == _arg1){
return (_local3);
};
_local3++;
};
return (-1);
}
public function hideFocus():void{
}
private function removedHandler(_arg1:Event):void{
var _local2:int;
var _local3:DisplayObject;
var _local4:InteractiveObject;
_local3 = DisplayObject(_arg1.target);
if ((((_local3 is IFocusManagerComponent)) && ((focusableObjects[_local3] == true)))){
if (_local3 == lastFocus){
IFocusManagerComponent(lastFocus).drawFocus(false);
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local3];
calculateCandidates = true;
} else {
if ((((_local3 is InteractiveObject)) && ((focusableObjects[_local3] == true)))){
_local4 = (_local3 as InteractiveObject);
if (_local4){
if (_local4 == lastFocus){
lastFocus = null;
};
delete focusableObjects[_local4];
calculateCandidates = true;
};
_local3.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
};
};
removeFocusables(_local3);
}
private function sortByDepth(_arg1:InteractiveObject, _arg2:InteractiveObject):Number{
var _local3:String;
var _local4:String;
var _local5:int;
var _local6:String;
var _local7:String;
var _local8:String;
var _local9:DisplayObject;
var _local10:DisplayObject;
_local3 = "";
_local4 = "";
_local8 = "0000";
_local9 = DisplayObject(_arg1);
_local10 = DisplayObject(_arg2);
while (((!((_local9 == DisplayObject(form)))) && (_local9.parent))) {
_local5 = getChildIndex(_local9.parent, _local9);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local3 = (_local7 + _local3);
_local9 = _local9.parent;
};
while (((!((_local10 == DisplayObject(form)))) && (_local10.parent))) {
_local5 = getChildIndex(_local10.parent, _local10);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local4 = (_local7 + _local4);
_local10 = _local10.parent;
};
return (((_local3 > _local4)) ? 1 : ((_local3 < _local4)) ? -1 : 0);
}
public function get defaultButton():Button{
return (_defaultButton);
}
private function activateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
if (lastFocus){
if ((lastFocus is IFocusManagerComponent)){
IFocusManagerComponent(lastFocus).setFocus();
} else {
form.stage.focus = lastFocus;
};
};
lastAction = "ACTIVATE";
}
public function showFocus():void{
}
public function set defaultButtonEnabled(_arg1:Boolean):void{
_defaultButtonEnabled = _arg1;
}
public function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject{
var _local2:DisplayObject;
var _local3:String;
var _local4:int;
var _local5:Boolean;
var _local6:int;
var _local7:int;
var _local8:IFocusManagerGroup;
if (!hasFocusableObjects()){
return (null);
};
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
_local2 = form.stage.focus;
_local2 = DisplayObject(findFocusManagerComponent(InteractiveObject(_local2)));
_local3 = "";
if ((_local2 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local2);
_local3 = _local8.groupName;
};
_local4 = getIndexOfFocusedObject(_local2);
_local5 = false;
_local6 = _local4;
if (_local4 == -1){
if (_arg1){
_local4 = focusableCandidates.length;
};
_local5 = true;
};
_local7 = getIndexOfNextObject(_local4, _arg1, _local5, _local3);
return (findFocusManagerComponent(focusableCandidates[_local7]));
}
private function mouseDownHandler(_arg1:MouseEvent):void{
var _local2:InteractiveObject;
if (_arg1.isDefaultPrevented()){
return;
};
_local2 = getTopLevelFocusTarget(InteractiveObject(_arg1.target));
if (!_local2){
return;
};
showFocusIndicator = false;
if (((((!((_local2 == lastFocus))) || ((lastAction == "ACTIVATE")))) && (!((_local2 is TextField))))){
setFocus(_local2);
};
lastAction = "MOUSEDOWN";
}
private function isTabVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
_local2 = _arg1.parent;
while (((((_local2) && (!((_local2 is Stage))))) && (!(((_local2.parent) && ((_local2.parent is Stage))))))) {
if (!_local2.tabChildren){
return (false);
};
_local2 = _local2.parent;
};
return (true);
}
public function get nextTabIndex():int{
return (0);
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.TAB){
lastAction = "KEY";
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
};
if (((((((defaultButtonEnabled) && ((_arg1.keyCode == Keyboard.ENTER)))) && (defaultButton))) && (defButton.enabled))){
sendDefaultButtonEvent();
};
}
private function focusInHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
var _local3:Button;
_local2 = InteractiveObject(_arg1.target);
if (form.contains(_local2)){
lastFocus = findFocusManagerComponent(InteractiveObject(_local2));
if ((lastFocus is Button)){
_local3 = Button(lastFocus);
if (defButton){
defButton.emphasized = false;
defButton = _local3;
_local3.emphasized = true;
};
} else {
if (((defButton) && (!((defButton == _defaultButton))))){
defButton.emphasized = false;
defButton = _defaultButton;
_defaultButton.emphasized = true;
};
};
};
}
private function tabEnabledChangeHandler(_arg1:Event):void{
var _local2:InteractiveObject;
var _local3:Boolean;
calculateCandidates = true;
_local2 = InteractiveObject(_arg1.target);
_local3 = (focusableObjects[_local2] == true);
if (_local2.tabEnabled){
if (((!(_local3)) && (isTabVisible(_local2)))){
if (!(_local2 is IFocusManagerComponent)){
_local2.focusRect = false;
};
focusableObjects[_local2] = true;
};
} else {
if (_local3){
delete focusableObjects[_local2];
};
};
}
public function set showFocusIndicator(_arg1:Boolean):void{
_showFocusIndicator = _arg1;
}
public function get form():DisplayObjectContainer{
return (_form);
}
private function sortByTabIndex(_arg1:InteractiveObject, _arg2:InteractiveObject):int{
return (((_arg1.tabIndex > _arg2.tabIndex)) ? 1 : ((_arg1.tabIndex < _arg2.tabIndex)) ? -1 : sortByDepth(_arg1, _arg2));
}
public function activate():void{
if (activated){
return;
};
form.stage.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler, false, 0, true);
form.stage.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler, false, 0, true);
form.addEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.addEventListener(Event.ACTIVATE, activateHandler, false, 0, true);
form.stage.addEventListener(Event.DEACTIVATE, deactivateHandler, false, 0, true);
form.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = true;
if (lastFocus){
setFocus(lastFocus);
};
}
public function deactivate():void{
form.stage.removeEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler);
form.stage.removeEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler);
form.removeEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.removeEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.removeEventListener(Event.ACTIVATE, activateHandler);
form.stage.removeEventListener(Event.DEACTIVATE, deactivateHandler);
form.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = false;
}
public function get defaultButtonEnabled():Boolean{
return (_defaultButtonEnabled);
}
}
}//package fl.managers
Section 49
//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 get nextTabIndex():int;
function get defaultButton():Button;
function get showFocusIndicator():Boolean;
function setFocus(_arg1:InteractiveObject):void;
function activate():void;
function showFocus():void;
function set defaultButtonEnabled(_arg1:Boolean):void;
function hideFocus():void;
function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject;
function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject;
}
}//package fl.managers
Section 50
//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 51
//IFocusManagerGroup (fl.managers.IFocusManagerGroup)
package fl.managers {
public interface IFocusManagerGroup {
function set groupName(_arg1:String):void;
function set selected(_arg1:Boolean):void;
function get groupName():String;
function get selected():Boolean;
}
}//package fl.managers
Section 52
//StyleManager (fl.managers.StyleManager)
package fl.managers {
import fl.core.*;
import flash.utils.*;
import flash.text.*;
public class StyleManager {
private var globalStyles:Object;
private var classToDefaultStylesDict:Dictionary;
private var styleToClassesHash:Object;
private var classToStylesDict:Dictionary;
private var classToInstancesDict: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;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
if (((!((_local4 == null))) && (!((_local4[_arg2] == null))))){
delete _local4[_arg2];
invalidateComponentStyle(_local3, _arg2);
};
}
private static function getClassDef(_arg1:Object):Class{
var component = _arg1;
if ((component is Class)){
return ((component as Class));
};
try {
return ((getDefinitionByName(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
if ((component is UIComponent)){
try {
return ((component.loaderInfo.applicationDomain.getDefinition(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
};
};
};
return (null);
}
public static function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
public static function setComponentStyle(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Class;
var _local5:Object;
_local4 = getClassDef(_arg1);
_local5 = getInstance().classToStylesDict[_local4];
if (_local5 == null){
_local5 = (getInstance().classToStylesDict[_local4] = {});
};
if (_local5 == _arg3){
return;
};
_local5[_arg2] = _arg3;
invalidateComponentStyle(_local4, _arg2);
}
private static function setSharedStyles(_arg1:UIComponent):void{
var _local2:StyleManager;
var _local3:Class;
var _local4:Object;
var _local5:String;
_local2 = getInstance();
_local3 = getClassDef(_arg1);
_local4 = _local2.classToDefaultStylesDict[_local3];
for (_local5 in _local4) {
_arg1.setSharedStyle(_local5, getSharedStyle(_arg1, _local5));
};
}
public static function getComponentStyle(_arg1:Object, _arg2:String):Object{
var _local3:Class;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
return (((_local4)==null) ? null : _local4[_arg2]);
}
private static function getInstance(){
if (_instance == null){
_instance = new (StyleManager);
};
return (_instance);
}
private static function invalidateComponentStyle(_arg1:Class, _arg2:String):void{
var _local3:Dictionary;
var _local4:Object;
var _local5:UIComponent;
_local3 = getInstance().classToInstancesDict[_arg1];
if (_local3 == null){
return;
};
for (_local4 in _local3) {
_local5 = (_local4 as UIComponent);
if (_local5 == null){
} else {
_local5.setSharedStyle(_arg2, getSharedStyle(_local5, _arg2));
};
};
}
private static function invalidateStyle(_arg1:String):void{
var _local2:Dictionary;
var _local3:Object;
_local2 = getInstance().styleToClassesHash[_arg1];
if (_local2 == null){
return;
};
for (_local3 in _local2) {
invalidateComponentStyle(Class(_local3), _arg1);
};
}
public static function registerInstance(_arg1:UIComponent):void{
var inst:StyleManager;
var classDef:Class;
var target:Class;
var defaultStyles:Object;
var styleToClasses:Object;
var n:String;
var instance = _arg1;
inst = getInstance();
classDef = getClassDef(instance);
if (classDef == null){
return;
};
if (inst.classToInstancesDict[classDef] == null){
inst.classToInstancesDict[classDef] = new Dictionary(true);
target = classDef;
while (defaultStyles == null) {
if (target["getStyleDefinition"] != null){
defaultStyles = target["getStyleDefinition"]();
break;
};
try {
target = (instance.loaderInfo.applicationDomain.getDefinition(getQualifiedSuperclassName(target)) as Class);
} catch(err:Error) {
try {
target = (getDefinitionByName(getQualifiedSuperclassName(target)) as Class);
} catch(e:Error) {
defaultStyles = UIComponent.getStyleDefinition();
break;
};
};
};
styleToClasses = inst.styleToClassesHash;
for (n in defaultStyles) {
if (styleToClasses[n] == null){
styleToClasses[n] = new Dictionary(true);
};
styleToClasses[n][classDef] = true;
};
inst.classToDefaultStylesDict[classDef] = defaultStyles;
inst.classToStylesDict[classDef] = {};
};
inst.classToInstancesDict[classDef][instance] = true;
setSharedStyles(instance);
}
public static function getStyle(_arg1:String):Object{
return (getInstance().globalStyles[_arg1]);
}
private static function getSharedStyle(_arg1:UIComponent, _arg2:String):Object{
var _local3:Class;
var _local4:StyleManager;
var _local5:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance();
_local5 = _local4.classToStylesDict[_local3][_arg2];
if (_local5 != null){
return (_local5);
};
_local5 = _local4.globalStyles[_arg2];
if (_local5 != null){
return (_local5);
};
return (_local4.classToDefaultStylesDict[_local3][_arg2]);
}
public static function setStyle(_arg1:String, _arg2:Object):void{
var _local3:Object;
_local3 = getInstance().globalStyles;
if ((((_local3[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
_local3[_arg1] = _arg2;
invalidateStyle(_arg1);
}
}
}//package fl.managers
Section 53
//textHolder_19 (HighScores_fla.textHolder_19)
package HighScores_fla {
import flash.display.*;
import com.novelgames.flashgames.highscores.*;
public dynamic class textHolder_19 extends MovieClip {
public var seedText:TextText;
}
}//package HighScores_fla