Section 1
//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 2
//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 3
//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 4
//LabelButton (fl.controls.LabelButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import fl.managers.*;
import flash.text.*;
import fl.events.*;
import flash.ui.*;
public class LabelButton extends BaseButton implements IFocusManagerComponent {
protected var _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 5
//TextInput (fl.controls.TextInput)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import fl.managers.*;
import flash.text.*;
import fl.events.*;
import flash.ui.*;
public class TextInput extends UIComponent implements IFocusManagerComponent {
protected var _html:Boolean;// = false
protected var _savedHTML:String;
protected var background:DisplayObject;
protected var _editable:Boolean;// = true
public var textField:TextField;
private static var defaultStyles:Object = {upSkin:"TextInput_upSkin", disabledSkin:"TextInput_disabledSkin", focusRectSkin:null, focusRectPadding:null, textFormat:null, disabledTextFormat:null, textPadding:0, embedFonts:false};
public static var createAccessibilityImplementation:Function;
public function TextInput(){
_editable = true;
_html = false;
super();
}
override public function drawFocus(_arg1:Boolean):void{
if (focusTarget != null){
focusTarget.drawFocus(_arg1);
return;
};
super.drawFocus(_arg1);
}
public function set imeMode(_arg1:String):void{
_imeMode = _arg1;
}
override protected function isOurFocus(_arg1:DisplayObject):Boolean{
return ((((_arg1 == textField)) || (super.isOurFocus(_arg1))));
}
protected function handleKeyDown(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.ENTER){
dispatchEvent(new ComponentEvent(ComponentEvent.ENTER, true));
};
}
public function set text(_arg1:String):void{
textField.text = _arg1;
_html = false;
invalidate(InvalidationType.DATA);
invalidate(InvalidationType.STYLES);
}
protected function updateTextFieldType():void{
textField.type = (((enabled) && (editable))) ? TextFieldType.INPUT : TextFieldType.DYNAMIC;
textField.selectable = enabled;
}
public function get selectionEndIndex():int{
return (textField.selectionEndIndex);
}
public function get editable():Boolean{
return (_editable);
}
override protected function focusInHandler(_arg1:FocusEvent):void{
var _local2:IFocusManager;
if (_arg1.target == this){
stage.focus = textField;
};
_local2 = focusManager;
if (((editable) && (_local2))){
_local2.showFocusIndicator = true;
if (((textField.selectable) && ((textField.selectionBeginIndex == textField.selectionBeginIndex)))){
setSelection(0, textField.length);
};
};
super.focusInHandler(_arg1);
if (editable){
setIMEMode(true);
};
}
public function get selectionBeginIndex():int{
return (textField.selectionBeginIndex);
}
public function set alwaysShowSelection(_arg1:Boolean):void{
textField.alwaysShowSelection = _arg1;
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
updateTextFieldType();
}
protected function setEmbedFont(){
var _local1:Object;
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
}
public function get horizontalScrollPosition():int{
return (textField.scrollH);
}
public function set condenseWhite(_arg1:Boolean):void{
textField.condenseWhite = _arg1;
}
public function set displayAsPassword(_arg1:Boolean):void{
textField.displayAsPassword = _arg1;
}
public function set horizontalScrollPosition(_arg1:int):void{
textField.scrollH = _arg1;
}
public function get restrict():String{
return (textField.restrict);
}
public function get textWidth():Number{
return (textField.textWidth);
}
public function get textHeight():Number{
return (textField.textHeight);
}
public function set editable(_arg1:Boolean):void{
_editable = _arg1;
updateTextFieldType();
}
public function get maxChars():int{
return (textField.maxChars);
}
public function get length():int{
return (textField.length);
}
public function getLineMetrics(_arg1:int):TextLineMetrics{
return (textField.getLineMetrics(_arg1));
}
public function get imeMode():String{
return (_imeMode);
}
override protected function focusOutHandler(_arg1:FocusEvent):void{
super.focusOutHandler(_arg1);
if (editable){
setIMEMode(false);
};
}
public function set htmlText(_arg1:String):void{
if (_arg1 == ""){
text = "";
return;
};
_html = true;
_savedHTML = _arg1;
textField.htmlText = _arg1;
invalidate(InvalidationType.DATA);
invalidate(InvalidationType.STYLES);
}
public function get text():String{
return (textField.text);
}
override public function get enabled():Boolean{
return (super.enabled);
}
public function get condenseWhite():Boolean{
return (textField.condenseWhite);
}
public function get alwaysShowSelection():Boolean{
return (textField.alwaysShowSelection);
}
override protected function draw():void{
var _local1:Object;
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawTextFormat();
drawBackground();
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
super.draw();
}
protected function handleTextInput(_arg1:TextEvent):void{
_arg1.stopPropagation();
dispatchEvent(new TextEvent(TextEvent.TEXT_INPUT, true, false, _arg1.text));
}
override protected function configUI():void{
super.configUI();
tabChildren = true;
textField = new TextField();
addChild(textField);
updateTextFieldType();
textField.addEventListener(TextEvent.TEXT_INPUT, handleTextInput, false, 0, true);
textField.addEventListener(Event.CHANGE, handleChange, false, 0, true);
textField.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown, false, 0, true);
}
public function setSelection(_arg1:int, _arg2:int):void{
textField.setSelection(_arg1, _arg2);
}
public function get displayAsPassword():Boolean{
return (textField.displayAsPassword);
}
public function appendText(_arg1:String):void{
textField.appendText(_arg1);
}
public function set restrict(_arg1:String):void{
if (((componentInspectorSetting) && ((_arg1 == "")))){
_arg1 = null;
};
textField.restrict = _arg1;
}
public function get htmlText():String{
return (textField.htmlText);
}
protected function drawBackground():void{
var _local1:DisplayObject;
var _local2:String;
_local1 = background;
_local2 = (enabled) ? "upSkin" : "disabledSkin";
background = getDisplayObjectInstance(getStyleValue(_local2));
if (background == null){
return;
};
addChildAt(background, 0);
if (((((!((_local1 == null))) && (!((_local1 == background))))) && (contains(_local1)))){
removeChild(_local1);
};
}
override public function setFocus():void{
stage.focus = textField;
}
protected function drawLayout():void{
var _local1:Number;
_local1 = Number(getStyleValue("textPadding"));
if (background != null){
background.width = width;
background.height = height;
};
textField.width = (width - (2 * _local1));
textField.height = (height - (2 * _local1));
textField.x = (textField.y = _local1);
}
public function set maxChars(_arg1:int):void{
textField.maxChars = _arg1;
}
public function get maxHorizontalScrollPosition():int{
return (textField.maxScrollH);
}
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();
if (_html){
textField.htmlText = _savedHTML;
};
}
protected function handleChange(_arg1:Event):void{
_arg1.stopPropagation();
dispatchEvent(new Event(Event.CHANGE, true));
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 6
//ComponentShim (fl.core.ComponentShim)
package fl.core {
import flash.display.*;
public dynamic class ComponentShim extends MovieClip {
}
}//package fl.core
Section 7
//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 8
//UIComponent (fl.core.UIComponent)
package fl.core {
import flash.display.*;
import flash.events.*;
import fl.managers.*;
import flash.text.*;
import flash.utils.*;
import fl.events.*;
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 9
//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 10
//FocusManager (fl.managers.FocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
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 11
//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 12
//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 13
//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 14
//StyleManager (fl.managers.StyleManager)
package fl.managers {
import fl.core.*;
import flash.text.*;
import flash.utils.*;
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 15
//MochiScores (mochi.MochiScores)
package mochi {
import flash.display.*;
import flash.text.*;
public class MochiScores {
private static var boardID:String;
public static var onErrorHandler:Object;
public static var onCloseHandler:Object;
public static function showLeaderboard(_arg1:Object=null):void{
var options = _arg1;
if (options != null){
if (options.clip != null){
if ((options.clip is Sprite)){
MochiServices.setContainer(options.clip);
};
delete options.clip;
} else {
MochiServices.setContainer();
};
MochiServices.stayOnTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, _arg1, _arg2);
}
public static function requestList(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_requestList", null, _arg1, _arg2);
}
public static function scoresArrayToObjects(_arg1:Object):Object{
var _local2:Object;
var _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
_local2 = {};
for (_local7 in _arg1) {
if (typeof(_arg1[_local7]) == "object"){
if (((!((_arg1[_local7].cols == null))) && (!((_arg1[_local7].rows == null))))){
_local2[_local7] = [];
_local5 = _arg1[_local7];
_local4 = 0;
while (_local4 < _local5.rows.length) {
_local6 = {};
_local3 = 0;
while (_local3 < _local5.cols.length) {
_local6[_local5.cols[_local3]] = _local5.rows[_local4][_local3];
_local3++;
};
_local2[_local7].push(_local6);
_local4++;
};
} else {
_local2[_local7] = {};
for (_local8 in _arg1[_local7]) {
_local2[_local7][_local8] = _arg1[_local7][_local8];
};
};
} else {
_local2[_local7] = _arg1[_local7];
};
};
return (_local2);
}
public static function submit(_arg1:Number, _arg2:String, _arg3:Object=null, _arg4:Object=null):void{
MochiServices.send("scores_submit", {score:_arg1, name:_arg2}, _arg3, _arg4);
}
public static function onClose(_arg1:Object=null):void{
if (_arg1 != null){
if (_arg1.error != null){
if (_arg1.error == true){
if (onErrorHandler != null){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
};
};
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiScores.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
}
}//package mochi
Section 16
//MochiServices (mochi.MochiServices)
package mochi {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
private static var _sendChannel:LocalConnection;
private static var _rcvChannelName:String;
private static var _gatewayURL:String = "http://www.mochiads.com/static/lib/services/services.swf";
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _id:String;
private static var _listenChannel:LocalConnection;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _startTime:Number;
private static var _connecting:Boolean = false;
public static var onError:Object;
private static var _listenChannelName:String = "__mochiservices";
private static var _rcvChannel:LocalConnection;
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_sendChannel.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
onError("NotConnected");
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_clip._queue.push({methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
};
if (_clip != null){
if (((!((_clip._callbacks == null))) && (!((_clip._nextcallbackID == null))))){
_clip._callbacks[_clip._nextcallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_clip._nextcallbackID++;
};
};
}
public static function get connected():Boolean{
return (_connected);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (_clip != null){
if (_clip._queue != null){
while (_clip._queue.length > 0) {
_local2 = _clip._queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _clip._callbacks[_local2.callbackID];
};
delete _clip._callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
public static function get childClip():Object{
return (_clip);
}
public static function get id():String{
return (_id);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function getVersion():String{
return ("1.31");
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
try {
_listenChannel.close();
_rcvChannel.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
Security.allowDomain("*");
Security.allowInsecureDomain("*");
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
return (_local2);
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
if (_clip.parent != null){
Sprite(_clip.parent).removeChild(_clip);
};
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_arg1 != null){
if ((_arg1 is Sprite)){
_container = _arg1;
};
};
if (_arg2){
if ((_container is Sprite)){
Sprite(_container).addChild(_clip);
};
};
}
private static function onStatus(_arg1:StatusEvent):void{
switch (_arg1.level){
case "error":
_connected = false;
_listenChannel.connect(_listenChannelName);
break;
};
}
private static function initComChannels():void{
if (!_connected){
_sendChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"registerGame", id:_id, clip:_container, version:getVersion()});
_rcvChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_clip.onReceive = function (_arg1:Object):void{
var cb:String;
var cblst:Object;
var method:*;
var methodName:String;
var obj:Object;
var pkg = _arg1;
cb = pkg.callbackID;
cblst = this.client._callbacks[cb];
if (!cblst){
return;
};
method = cblst.callbackMethod;
methodName = "";
obj = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete this.client._callbacks[cb];
};
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
_rcvChannel.connect(_rcvChannelName);
trace("connected!");
_connecting = false;
_connected = true;
_listenChannel.close();
while (_clip._queue.length > 0) {
_sendChannel.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function listen():void{
_listenChannel = new LocalConnection();
_listenChannel.client = _clip;
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
_listenChannel.allowDomain("*", "localhost");
_listenChannel.allowInsecureDomain("*", "localhost");
_listenChannel.connect(_listenChannelName);
trace("Waiting for MochiAds services to connect...");
}
private static function handleError(_arg1:Object, _arg2:Object, _arg3:Object):void{
var args = _arg1;
var callbackObject = _arg2;
var callbackMethod = _arg3;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
try {
var _local5 = callbackObject;
_local5[callbackMethod](args);
} catch(error:Error) {
};
} else {
if (callbackMethod != null){
try {
callbackMethod.apply(args);
} catch(error:Error) {
};
};
};
};
}
public static function get clip():Object{
return (_container);
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
_rcvChannelName = _arg1;
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
var clipname:String;
var f:Function;
var req:URLRequest;
var id = _arg1;
var clip = _arg2;
clipname = ("_mochiservices_com_" + id);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
MochiServices.allowDomains(_gatewayURL);
_clip = createEmptyMovieClip(clip, clipname, 10336, false);
_loader = new Loader();
_timer = new Timer(1000, 0);
_startTime = getTimer();
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
f = function (_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
req = new URLRequest(_gatewayURL);
_loader.load(req);
_clip.addChild(_loader);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_rcvChannel = new LocalConnection();
_rcvChannel.allowDomain("*", "localhost");
_rcvChannel.allowInsecureDomain("*", "localhost");
_rcvChannel.client = _clip;
_clip._nextcallbackID = 0;
_clip._callbacks = {};
listen();
return (_clip);
}
public static function bringToTop(_arg1:Event):void{
var e = _arg1;
if (MochiServices.clip != null){
if (MochiServices.childClip != null){
try {
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
} catch(errorObject:Error) {
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
};
};
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
if ((clip is DisplayObject)){
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number, _arg4:Boolean=true):MovieClip{
var mc:MovieClip;
var parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
mc = new MovieClip();
if (doAdd){
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
};
try {
parent[name] = mc;
} catch(e:Error) {
throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
mc["_name"] = name;
return (mc);
}
public static function connectWait(_arg1:TimerEvent):void{
if ((getTimer() - _startTime) > 10000){
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_timer.stop();
};
}
}
}//package mochi
Section 17
//AAFire_73 (mochi_defense1_fla.AAFire_73)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class AAFire_73 extends MovieClip {
public function AAFire_73(){
addFrameScript(0, frame1, 7, frame8);
}
function frame1(){
stop();
}
function frame8(){
gotoAndStop(2);
}
}
}//package mochi_defense1_fla
Section 18
//artilleryFire_102 (mochi_defense1_fla.artilleryFire_102)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class artilleryFire_102 extends MovieClip {
public function artilleryFire_102(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 19
//artilleryTurret_100 (mochi_defense1_fla.artilleryTurret_100)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class artilleryTurret_100 extends MovieClip {
public var fire:MovieClip;
public var cannonNose:MovieClip;
public function artilleryTurret_100(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
public function doRecoil(){
gotoAndPlay(2);
}
}
}//package mochi_defense1_fla
Section 20
//bird1death_6 (mochi_defense1_fla.bird1death_6)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class bird1death_6 extends MovieClip {
public function bird1death_6(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 21
//bird2death_7 (mochi_defense1_fla.bird2death_7)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class bird2death_7 extends MovieClip {
public function bird2death_7(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 22
//bird3death_8 (mochi_defense1_fla.bird3death_8)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class bird3death_8 extends MovieClip {
public function bird3death_8(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 23
//death1noise_9 (mochi_defense1_fla.death1noise_9)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class death1noise_9 extends MovieClip {
public function death1noise_9(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 24
//death2noise_10 (mochi_defense1_fla.death2noise_10)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class death2noise_10 extends MovieClip {
public function death2noise_10(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 25
//death3noise_11 (mochi_defense1_fla.death3noise_11)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class death3noise_11 extends MovieClip {
public function death3noise_11(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 26
//death4noise_12 (mochi_defense1_fla.death4noise_12)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class death4noise_12 extends MovieClip {
public function death4noise_12(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 27
//fastGunTurret_27 (mochi_defense1_fla.fastGunTurret_27)
package mochi_defense1_fla {
import flash.display.*;
public dynamic class fastGunTurret_27 extends MovieClip {
public var fire:MovieClip;
public var cannonNose:MovieClip;
public var cannonNose2:MovieClip;
public var fire2:MovieClip;
}
}//package mochi_defense1_fla
Section 28
//fastTurretFire_28 (mochi_defense1_fla.fastTurretFire_28)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class fastTurretFire_28 extends MovieClip {
public function fastTurretFire_28(){
addFrameScript(4, frame5);
}
function frame5(){
gotoAndStop(1);
}
}
}//package mochi_defense1_fla
Section 29
//fireClip_115 (mochi_defense1_fla.fireClip_115)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class fireClip_115 extends MovieClip {
public function fireClip_115(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 30
//fireTurretTop_114 (mochi_defense1_fla.fireTurretTop_114)
package mochi_defense1_fla {
import flash.display.*;
public dynamic class fireTurretTop_114 extends MovieClip {
public var fire:MovieClip;
public var cannonNose:MovieClip;
}
}//package mochi_defense1_fla
Section 31
//freezeClip_129 (mochi_defense1_fla.freezeClip_129)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class freezeClip_129 extends MovieClip {
public function freezeClip_129(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 32
//MainTimeline (mochi_defense1_fla.MainTimeline)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import mochi.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class MainTimeline extends MovieClip {
public var gridHeight:int;
public var rad;
public var closedList:Array;
public var death1:MovieClip;
public var death2:MovieClip;
public var death3:MovieClip;
public var death4:MovieClip;
public var towerSplashRange;
public var creepReleaseTypes;
public var endGameClip:MovieClip;
public var a;
public var c;
public var mochimode:Number;
public var aBackground:MovieClip;
public var i25;
public var checkFinishTileX:int;
public var markedOnClosed:Array;
public var towerBurn;
public var checkFinishTileY:int;
public var difficultyLevel:Number;
public var creepCount:int;
public var towerPoisonL1;
public var timedOut:Boolean;
public var routeCache1:Array;
public var currentScore:int;
public var towDam;
public var squareHeight:int;
public var frames:int;
public var thisgameid:Number;
public var onTimer:Timer;
public var towerSlow;
public var towerCosts;
public var aStarRan:Boolean;
public var creepLayer:MovieClip;
public var projectileLayer:MovieClip;
public var fps:int;
public var sandboxmode:Number;
public var i5;
public var towerSlowL;
public var myText:TextField;
public var cosine;
public var useRoute;
public var towSplaD1;
public var towRan;
public var player_name:String;
public var selectedTower:int;
public var partialRoute:Boolean;
public var _mochiads_game_id:String;
public var selectedBrush:int;
public var circle1:MovieClip;
public var circle2:MovieClip;
public var circle3:MovieClip;
public var circle4:MovieClip;
public var circle5:MovieClip;
public var tickCount:int;
public var userCash:int;
public var finalRound:Boolean;
public var towerNames;
public var initsandboxmode;
public var lastReleased:int;
public var towSplaD;
public var towerReload;
public var towSplaR;
public var openList:Array;
public var towDam1;
public var targetURL:String;
public var gridWidth:int;
public var gRad;
public var knownOpenArray:Array;
public var birddeath1:MovieClip;
public var birddeath2:MovieClip;
public var birddeath3:MovieClip;
public var rangeimage:RangeImage1;
public var towerQuadFire;
public var ainterfaceLayer:MovieClip;
public var tickerTimer:Timer;
public var towerSplashDamage;
public var route:Array;
public var doingLeftToRight:Boolean;
public var numbers:int;
public var towerReloadL;
public var sine;
public var openAreaSize:int;
public var finishAreaX1:int;
public var finishAreaX2:int;
public var walkable:Array;
public var squareWidth:Number;
public var towSplaR1;
public var finishAreaY1:int;
public var routeCache:Array;
public var maxReleases;
public var thisgametype:Number;
public var towerBurnL;
public var finishAreaY2:int;
public var towerReloadL1;
public var alastFps;
public var towerDualFire;
public var towerPoisonL;
public var totalTimeTaken:int;
public var ticker:int;
public var gridStartX:int;
public var liveProjectiles:Array;
public var gridStartY:int;
public var lastCreepsReleased:int;
public var startAreaX2:int;
public var creepName;
public var startAreaX1:int;
public var startAreaY1:Number;
public var startAreaY2:int;
public var towerList:Array;
public var towerTexts;
public var startScreen:MovieClip;
public var towerPoison;
public var maxTicks:int;
public var towRan1;
public var tiles:Array;
public var towerCount:int;
public var liveCreeps:Array;
public var creepReleaseNumbers;
public var towerSlowL1;
public var towerRecoil;
public var towerCanHitAir;
public var towerSelectedImg1:towerSelectedImg;
public var shotsFired:int;
public var towerRange;
public var gRad2;
public var towerLayer:MovieClip;
public var towerBurnL1;
public var towerDamage;
public var brushSelected:int;
public var userLives:int;
public function MainTimeline(){
addFrameScript(0, frame1, 1, frame2, 2, frame3);
}
public function save_route1(_arg1, _arg2, _arg3, _arg4){
var _local5:*;
var _local6:*;
_local5 = new Array();
_local6 = new Array();
if (routeCache[_arg1][_arg2] == undefined){
return;
};
i = 0;
while (i < _arg4) {
_local5.push(_arg3[i]);
_local6.push(_arg3[i]);
i++;
};
routeCache1[_arg1][_arg2].iRoute = _local5;
routeCache1[_arg1][_arg2].iNeedCheck = false;
routeCache1[_arg1][_arg2].iInit = true;
if (_arg3.length > 1){
if (_local6[0] == undefined){
return;
};
_local6.splice(0, 1);
_arg4--;
save_route1(_local6[0].nodeX, _local6[0].nodeY, _local6, _arg4);
};
}
public function doPostFreeScore(){
var _local1:*;
var _local2:Responder;
var _local3:*;
trace(difficultyLevel);
if (mochimode == 1){
if (difficultyLevel == 2){
MochiScores.showLeaderboard({boardID:"4ee7f738bd1a1937", score:currentScore, name:player_name});
};
if (difficultyLevel == 1){
MochiScores.showLeaderboard({boardID:"b4ae44baeaf1aab0", score:currentScore, name:player_name});
};
if (difficultyLevel == 3){
MochiScores.showLeaderboard({boardID:"1cd1415ace4e4331", score:currentScore, name:player_name});
};
} else {
_local1 = new NetConnection();
_local2 = new Responder(onGetFreeScore, onFault);
_local1.connect("http://www.dukesbox.com/flashservices/gateway.php");
_local3 = 18;
_local1.call("validate.end_free_game", _local2, _local3, player_name, currentScore, difficultyLevel);
};
}
public function sellSelected(){
var _local1:*;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:int;
var _local7:int;
if (selectedTower >= 0){
_local1 = towerList.splice(selectedTower, 1);
_local2 = _local1[0].towerType;
_local3 = _local1[0].upgradeLevel;
userCash = (userCash + calcSellAmount(_local2, _local3));
towerSelectedImg1.visible = true;
towerSelectedImg1.x = -100;
_local4 = Math.round((((_local1[0].x - gridStartX) + 5) / squareWidth));
_local5 = Math.round((((_local1[0].y - gridStartY) + 5) / squareHeight));
walkable[_local4][_local5] = true;
walkable[(_local4 + 1)][_local5] = true;
walkable[_local4][(_local5 + 1)] = true;
walkable[(_local4 + 1)][(_local5 + 1)] = true;
selectedTower = -1;
displayTowerInfo(brushSelected, selectedTower);
_local1[0].towerOnDisplay.visible = false;
delete _local1[0].towerOnDisplay;
delete _local1[0];
doInterfaceUpdate();
_local6 = 0;
while (_local6 < gridWidth) {
_local7 = 0;
while (_local7 < gridHeight) {
routeCache[_local6][_local7].iInit = false;
delete routeCache[_local6][_local7].iRoute;
routeCache[_local6][_local7].iRoute = new Array();
routeCache1[_local6][_local7].iInit = false;
delete routeCache1[_local6][_local7].iRoute;
routeCache1[_local6][_local7].iRoute = new Array();
_local7++;
};
_local6++;
};
};
}
public function checkAllRoutes(){
var _local1:int;
var _local2:*;
var _local3:*;
var _local4:*;
_local1 = liveCreeps.length;
_local2 = 0;
while (_local2 < _local1) {
liveCreeps[_local2].iCheckRoute = true;
_local2++;
};
_local3 = 0;
while (_local3 < gridWidth) {
_local4 = 0;
while (_local4 < gridHeight) {
routeCache[_local3][_local4].iNeedCheck = true;
routeCache1[_local3][_local4].iNeedCheck = true;
_local4++;
};
_local3++;
};
}
public function takeLife(_arg1, _arg2){
var _local3:*;
if (userLives >= 0){
userLives--;
};
_local3 = this.addChild(new takeCash());
_local3.x = _arg1;
_local3.y = _arg2;
_local3.rt = this;
if (userLives == 0){
runEndGame();
return;
};
ainterfaceLayer.livesText.text = userLives;
}
public function removeStartScreen(){
this.removeChild(startScreen);
startScreen = null;
}
public function removeClipProjectileLayer(_arg1:MovieClip){
this.projectileLayer.removeChild(_arg1);
_arg1 = null;
}
public function doEndGame(){
var _local1:*;
var _local2:Responder;
_local1 = new NetConnection();
_local2 = new Responder(onEndGame, onFault);
_local1.connect("http://www.dukesbox.com/flashservices/gateway.php");
_local1.call("validate.end_game", _local2, thisgameid, thisgametype, currentScore);
}
function frame1(){
mochimode = 1;
_mochiads_game_id = "7450431c450a8278";
initsandboxmode = 0;
MochiServices.connect("7450431c450a8278", root);
trace("connecting to mochi");
if (mochimode == 1){
initsandboxmode = 1;
MochiAd.showPreGameAd({clip:root, id:"7450431c450a8278", res:"750x650"});
};
}
function frame3(){
gridStartY = 36;
gridStartX = 0;
squareWidth = 20;
squareHeight = 19;
lastCreepsReleased = 0;
gridWidth = 29;
gridHeight = 25;
openAreaSize = 5;
startAreaX1 = 1;
towerCount = 0;
brushSelected = 1;
startAreaY1 = (Math.ceil((((Math.random() * gridHeight) - 1) - openAreaSize)) + 2);
currentScore = 0;
difficultyLevel = 0;
player_name = this.loaderInfo.parameters.player_name;
thisgameid = this.loaderInfo.parameters.thisgameid;
thisgametype = this.loaderInfo.parameters.thisgametype;
sandboxmode = 1;
if (initsandboxmode == 1){
sandboxmode = 1;
};
stage.removeEventListener(Event.ENTER_FRAME, loading);
walkable = new Array(gridWidth);
routeCache = new Array(gridWidth);
routeCache1 = new Array(gridWidth);
tiles = new Array(gridWidth);
selectedBrush = 0;
creepCount = 0;
shotsFired = 0;
tickCount = 35;
maxTicks = tickCount;
lastReleased = 0;
selectedTower = -1;
userLives = 20;
userCash = 100;
if (startAreaY1 < 2){
startAreaY1 = 2;
};
if (startAreaY1 > ((gridHeight - 3) - openAreaSize)){
startAreaY1 = ((gridHeight - openAreaSize) - 3);
};
startAreaX2 = Math.ceil((((Math.random() * gridWidth) - 2) - openAreaSize));
if (startAreaX2 < 3){
startAreaX2 = 3;
};
if ((startAreaX2 + openAreaSize) > (gridWidth - 2)){
startAreaX2 = ((gridWidth - 2) - openAreaSize);
};
startAreaY2 = 1;
finishAreaX1 = (gridWidth - 2);
finishAreaY1 = ((Math.ceil((((Math.random() * gridHeight) - 1) - openAreaSize)) + openAreaSize) + 1);
if (finishAreaY1 > ((gridHeight - 3) - openAreaSize)){
finishAreaY1 = ((gridHeight - openAreaSize) - 3);
};
finishAreaX2 = Math.ceil((((Math.random() * gridWidth) - 3) - openAreaSize));
if (finishAreaX2 > ((gridWidth - 1) - openAreaSize)){
finishAreaX2 = ((gridWidth - openAreaSize) - 2);
};
if (finishAreaX2 < 2){
finishAreaX2 = 2;
};
if ((finishAreaX2 + openAreaSize) > (gridWidth - 2)){
finishAreaX2 = ((gridWidth - 2) - openAreaSize);
};
finishAreaY2 = (gridHeight - 2);
gRad = (Math.PI / 180);
gRad2 = (180 / Math.PI);
sine = new Array();
cosine = new Array();
rad = (Math.PI / 180);
ticker = 0;
a = 0;
while (a <= 360) {
sine[a] = Math.sin((a * rad));
cosine[a] = (Math.cos((a * rad)) * -1);
a++;
};
timedOut = false;
rangeimage.rt = this;
stop();
fps = 0;
frames = 0;
alastFps = getTimer();
totalTimeTaken = 0;
onTimer = new Timer(25);
onTimer.addEventListener(TimerEvent.TIMER, gameLoop);
tickerTimer = new Timer(1000);
tickerTimer.addEventListener(TimerEvent.TIMER, onTicker);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener);
maxReleases = 36;
creepReleaseTypes = new Array(maxReleases);
creepReleaseNumbers = new Array(maxReleases);
creepName = new Array(35);
creepName[0] = "BARBARIANS";
creepName[1] = "PEASANTS";
creepName[2] = "HUNTERS";
creepName[3] = "WITCHDOCTORS";
creepName[4] = "PIGEONS";
creepName[5] = "BATTERING RAM";
creepName[6] = "LEGIONNAIRE";
creepName[7] = "SERFS";
creepName[8] = "KNIGHTS";
creepName[9] = "PRAETORIAN";
creepName[10] = "HAWK";
creepName[11] = "BATTERING RAM";
creepName[12] = "RED COATS";
creepName[13] = "RIOTERS";
creepName[14] = "CAVALRY";
creepName[15] = "NAPOLEONS GAURD";
creepName[16] = "WRIGHT BROS.";
creepName[17] = "CANNON";
creepName[18] = "INFANTRY";
creepName[19] = "TRENCHMAN";
creepName[20] = "CADILLACS";
creepName[21] = "SNIPERS";
creepName[22] = "RED BARONS";
creepName[23] = "TANK 1";
creepName[24] = "PARATROOPERS";
creepName[25] = "RED ARMY";
creepName[26] = "JEEP";
creepName[27] = "COMMANDOS";
creepName[28] = "SPITFIRE";
creepName[29] = "TANK 2";
creepName[30] = "MARINES";
creepName[31] = "PROTESTORS";
creepName[32] = "HUMVEES";
creepName[33] = "SAS";
creepName[34] = "EUROFIGHTER";
creepName[35] = "TANK 3";
towerCanHitAir = new Array();
towerCanHitAir[1] = 2;
towerCanHitAir[2] = 1;
towerCanHitAir[3] = 0;
towerCanHitAir[4] = 0;
towerCanHitAir[5] = 0;
towerCanHitAir[6] = 0;
towerCanHitAir[7] = 2;
towerCanHitAir[8] = 2;
towerRecoil = new Array();
towerRecoil[1] = false;
towerRecoil[2] = false;
towerRecoil[3] = true;
towerRecoil[4] = true;
towerRecoil[5] = false;
towerRecoil[6] = false;
towerRecoil[7] = false;
towerRecoil[8] = false;
towerDualFire = new Array();
towerDualFire[1] = true;
towerDualFire[2] = true;
towerDualFire[3] = false;
towerDualFire[4] = false;
towerDualFire[5] = false;
towerDualFire[6] = false;
towerDualFire[7] = false;
towerDualFire[8] = false;
towerQuadFire = new Array();
towerDualFire[1] = false;
towerDualFire[2] = false;
towerDualFire[3] = false;
towerDualFire[4] = false;
towerDualFire[5] = false;
towerDualFire[6] = false;
towerDualFire[7] = false;
towerQuadFire[8] = true;
towerReload = new Array(9);
towerReloadL = 0;
while (towerReloadL < towerReload.length) {
towerReload[towerReloadL] = new Array(6);
towerReloadL1 = 0;
while (towerReloadL1 < 6) {
towerReload[towerReloadL][towerReloadL1] = 5;
towerReloadL1++;
};
towerReloadL++;
};
towerReload[1][0] = 9;
towerReload[1][1] = 7;
towerReload[1][2] = 5;
towerReload[1][3] = 3;
towerReload[1][4] = 3;
towerReload[1][5] = 2;
towerReload[2][0] = 6;
towerReload[2][1] = 5;
towerReload[2][2] = 4;
towerReload[2][3] = 3;
towerReload[2][4] = 2;
towerReload[2][5] = 1;
towerReload[3][0] = 30;
towerReload[3][1] = 25;
towerReload[3][2] = 23;
towerReload[3][3] = 21;
towerReload[3][4] = 19;
towerReload[3][5] = 17;
towerReload[4][0] = 35;
towerReload[4][1] = 30;
towerReload[4][2] = 25;
towerReload[4][3] = 19;
towerReload[4][4] = 17;
towerReload[4][5] = 15;
towerReload[5][0] = 35;
towerReload[5][1] = 25;
towerReload[5][2] = 18;
towerReload[5][3] = 16;
towerReload[5][4] = 14;
towerReload[5][5] = 10;
towerReload[6][0] = 30;
towerReload[6][1] = 28;
towerReload[6][2] = 26;
towerReload[6][3] = 20;
towerReload[6][4] = 18;
towerReload[6][5] = 15;
towerReload[7][0] = 36;
towerReload[7][1] = 25;
towerReload[7][2] = 24;
towerReload[7][3] = 23;
towerReload[7][4] = 15;
towerReload[7][5] = 12;
towerReload[8][0] = 11;
towerReload[8][1] = 9;
towerReload[8][2] = 7;
towerReload[8][3] = 6;
towerReload[8][4] = 4;
towerReload[8][5] = 1;
towerBurn = new Array(9);
towerBurnL = 0;
while (towerBurnL < towerBurn.length) {
towerBurn[towerBurnL] = new Array(6);
towerBurnL1 = 0;
while (towerBurnL1 < 6) {
towerBurn[towerBurnL][towerBurnL1] = 0;
towerBurnL1++;
};
towerBurnL++;
};
towerBurn[5][0] = 20;
towerBurn[5][1] = 35;
towerBurn[5][2] = 45;
towerBurn[5][3] = 65;
towerBurn[5][4] = 90;
towerBurn[5][5] = 120;
towerPoison = new Array(9);
towerPoisonL = 0;
while (towerPoisonL < towerPoison.length) {
towerPoison[towerPoisonL] = new Array(6);
towerPoisonL1 = 0;
while (towerPoisonL1 < 6) {
towerPoison[towerPoisonL][towerPoisonL1] = 0;
towerPoisonL1++;
};
towerPoisonL++;
};
towerPoison[7][0] = 10;
towerPoison[7][1] = 20;
towerPoison[7][2] = 25;
towerPoison[7][3] = 30;
towerPoison[7][4] = 35;
towerPoison[7][5] = 50;
towerSlow = new Array(9);
towerSlowL = 0;
while (towerSlowL < towerSlow.length) {
towerSlow[towerSlowL] = new Array(6);
towerSlowL1 = 0;
while (towerSlowL1 < 6) {
towerSlow[towerSlowL][towerSlowL1] = 0;
towerSlowL1++;
};
towerSlowL++;
};
towerSlow[4][0] = 8;
towerSlow[4][1] = 12;
towerSlow[4][2] = 16;
towerSlow[4][3] = 20;
towerSlow[4][4] = 24;
towerSlow[4][5] = 30;
towerSlow[6][0] = 20;
towerSlow[6][1] = 50;
towerSlow[6][2] = 70;
towerSlow[6][3] = 90;
towerSlow[6][4] = 120;
towerSlow[6][5] = 150;
towerRange = new Array(9);
towRan = 0;
while (towRan < towerRange.length) {
towerRange[towRan] = new Array(6);
towRan1 = 0;
while (towRan1 < 6) {
towerRange[towRan][towRan1] = 60;
towRan1++;
};
towRan++;
};
towerRange[1][0] = 80;
towerRange[1][1] = 90;
towerRange[1][2] = 100;
towerRange[1][3] = 110;
towerRange[1][4] = 120;
towerRange[1][5] = 130;
towerRange[2][0] = 150;
towerRange[2][1] = 200;
towerRange[2][2] = 250;
towerRange[2][3] = 300;
towerRange[2][4] = 400;
towerRange[2][5] = 500;
towerRange[3][0] = 160;
towerRange[3][1] = 180;
towerRange[3][2] = 200;
towerRange[3][3] = 220;
towerRange[3][4] = 240;
towerRange[3][5] = 280;
towerRange[7][0] = 150;
towerRange[7][1] = 160;
towerRange[7][2] = 170;
towerRange[7][3] = 180;
towerRange[7][4] = 190;
towerRange[7][5] = 200;
towerRange[8][0] = 120;
towerRange[8][1] = 140;
towerRange[8][2] = 160;
towerRange[8][3] = 180;
towerRange[8][4] = 200;
towerRange[8][5] = 240;
towerSplashRange = new Array(9);
towSplaR = 0;
while (towSplaR < towerSplashRange.length) {
towerSplashRange[towSplaR] = new Array(6);
towSplaR1 = 0;
while (towSplaR1 < 6) {
towerSplashRange[towSplaR][towSplaR1] = 0;
towSplaR1++;
};
towSplaR++;
};
towerSplashRange[3][0] = 50;
towerSplashRange[3][1] = 50;
towerSplashRange[3][2] = 50;
towerSplashRange[3][3] = 50;
towerSplashRange[3][4] = 50;
towerSplashRange[3][5] = 50;
towerSplashRange[4][0] = 25;
towerSplashRange[4][1] = 25;
towerSplashRange[4][2] = 25;
towerSplashRange[4][3] = 35;
towerSplashRange[4][4] = 35;
towerSplashRange[4][5] = 35;
towerSplashRange[5][0] = 25;
towerSplashRange[5][1] = 25;
towerSplashRange[5][2] = 25;
towerSplashRange[5][3] = 30;
towerSplashRange[5][4] = 35;
towerSplashRange[5][5] = 40;
towerSplashRange[6][0] = 75;
towerSplashRange[6][1] = 75;
towerSplashRange[6][2] = 75;
towerSplashRange[6][3] = 80;
towerSplashRange[6][4] = 95;
towerSplashRange[6][5] = 100;
towerSplashDamage = new Array(9);
towSplaD = 0;
while (towSplaD < towerSplashDamage.length) {
towerSplashDamage[towSplaD] = new Array(6);
towSplaD1 = 0;
while (towSplaD1 < 6) {
towerSplashDamage[towSplaD][towSplaD1] = 0;
towSplaD1++;
};
towSplaD++;
};
towerSplashDamage[3][0] = 5;
towerSplashDamage[3][1] = 8;
towerSplashDamage[3][2] = 20;
towerSplashDamage[3][3] = 35;
towerSplashDamage[3][4] = 40;
towerSplashDamage[3][5] = 50;
towerSplashDamage[4][0] = 9;
towerSplashDamage[4][1] = 12;
towerSplashDamage[4][2] = 28;
towerSplashDamage[4][3] = 35;
towerSplashDamage[4][4] = 45;
towerSplashDamage[4][5] = 70;
towerSplashDamage[5][0] = 9;
towerSplashDamage[5][1] = 14;
towerSplashDamage[5][2] = 20;
towerSplashDamage[5][3] = 30;
towerSplashDamage[5][4] = 50;
towerSplashDamage[5][5] = 100;
towerSplashDamage[6][0] = 1;
towerSplashDamage[6][1] = 2;
towerSplashDamage[6][2] = 4;
towerSplashDamage[6][3] = 7;
towerSplashDamage[6][4] = 12;
towerSplashDamage[6][5] = 20;
towerDamage = new Array(9);
towDam = 0;
while (towDam < towerDamage.length) {
towerDamage[towDam] = new Array(6);
towDam1 = 0;
while (towDam1 < 6) {
towerDamage[towDam][towDam1] = 0;
towDam1++;
};
towDam++;
};
towerDamage[1][0] = 4;
towerDamage[1][1] = 5;
towerDamage[1][2] = 6;
towerDamage[1][3] = 7;
towerDamage[1][4] = 8;
towerDamage[1][5] = 9;
towerDamage[2][0] = 30;
towerDamage[2][1] = 40;
towerDamage[2][2] = 50;
towerDamage[2][3] = 60;
towerDamage[2][4] = 70;
towerDamage[2][5] = 80;
towerDamage[7][0] = 0;
towerDamage[7][1] = 5;
towerDamage[7][2] = 10;
towerDamage[7][3] = 15;
towerDamage[7][4] = 20;
towerDamage[7][5] = 25;
towerDamage[8][0] = 90;
towerDamage[8][1] = 100;
towerDamage[8][2] = 110;
towerDamage[8][3] = 120;
towerDamage[8][4] = 130;
towerDamage[8][5] = 140;
towerCosts = new Array(9);
i5 = 0;
while (i5 < towerCosts.length) {
towerCosts[i5] = new Array(6);
i25 = 0;
while (i25 < 6) {
towerCosts[i5][i25] = ((5 * i25) + 10);
i25++;
};
i5++;
};
towerCosts[1][0] = 10;
towerCosts[1][1] = 8;
towerCosts[1][2] = 25;
towerCosts[1][3] = 45;
towerCosts[1][4] = 90;
towerCosts[1][5] = 160;
towerCosts[2][0] = 15;
towerCosts[2][1] = 10;
towerCosts[2][2] = 25;
towerCosts[2][3] = 50;
towerCosts[2][4] = 90;
towerCosts[2][5] = 140;
towerCosts[3][0] = 12;
towerCosts[3][1] = 10;
towerCosts[3][2] = 39;
towerCosts[3][3] = 63;
towerCosts[3][4] = 140;
towerCosts[3][5] = 240;
towerCosts[4][0] = 12;
towerCosts[4][1] = 9;
towerCosts[4][2] = 20;
towerCosts[4][3] = 43;
towerCosts[4][4] = 76;
towerCosts[4][5] = 170;
towerCosts[5][0] = 14;
towerCosts[5][1] = 11;
towerCosts[5][2] = 26;
towerCosts[5][3] = 53;
towerCosts[5][4] = 89;
towerCosts[5][5] = 142;
towerCosts[6][0] = 14;
towerCosts[6][1] = 11;
towerCosts[6][2] = 34;
towerCosts[6][3] = 89;
towerCosts[6][4] = 152;
towerCosts[6][5] = 234;
towerCosts[7][0] = 12;
towerCosts[7][1] = 9;
towerCosts[7][2] = 20;
towerCosts[7][3] = 43;
towerCosts[7][4] = 76;
towerCosts[7][5] = 170;
towerCosts[8][0] = 132;
towerCosts[8][1] = 129;
towerCosts[8][2] = 190;
towerCosts[8][3] = 283;
towerCosts[8][4] = 386;
towerCosts[8][5] = 470;
towerNames = new Array(7);
towerNames[1] = "Fast Tower";
towerNames[2] = "Anti Air Tower";
towerNames[3] = "Artillery Tower";
towerNames[4] = "Smash Tower";
towerNames[5] = "Fire Tower";
towerNames[6] = "Frost Tower";
towerNames[7] = "Poison Tower";
towerNames[8] = "Power Tower";
towerTexts = new Array(7);
towerTexts[1] = "Fast firing but light damage, the fast tower can attack land and air units";
towerTexts[2] = "A powerful AA tower with fast reloads and high damage";
towerTexts[3] = "Excellent range and high splash damage but low accuracy";
towerTexts[4] = "Short range but high damage, good accuracy and high splash";
towerTexts[5] = "Good splash, but short range, can burn creeps";
towerTexts[6] = "Good splash, but short range, can slow creeps";
towerTexts[7] = "Good range and some damage, can poison creeps";
towerTexts[8] = "Expensive but high damage and good range";
markedOnClosed = new Array(gridWidth);
knownOpenArray = new Array(gridWidth);
c = 0;
while (c < gridWidth) {
markedOnClosed[c] = new Array(gridHeight);
knownOpenArray[c] = new Array(gridHeight);
c++;
};
aStarRan = false;
if (sandboxmode == 1){
doInitGame();
} else {
doValidateGame();
};
}
public function onGetFreeScore(_arg1:Object):void{
trace(("onResult: " + _arg1));
}
function frame2(){
stage.addEventListener(Event.ENTER_FRAME, loading);
}
public function reInitGame(){
doInitGame();
startScreen.metalSheet.visible = true;
startScreen.visible = true;
}
public function returnFlyingCreepUID(){
var _local1:*;
var _local2:*;
var _local3:*;
_local1 = Math.round((Math.random() * 5));
_local2 = -1;
_local3 = 0;
while (_local3 < liveCreeps.length) {
if (liveCreeps[_local3].canFly == true){
_local2 = _local3;
if (_local1 > 0){
_local1--;
};
if (_local1 == 0){
return (liveCreeps[_local3].creepUID);
};
};
_local3++;
};
if (_local2 > -1){
return (liveCreeps[_local2].creepUID);
};
return (-1);
}
public function onEndGame(_arg1:Object):void{
trace(_arg1);
targetURL = _arg1;
}
public function getClosestCreep(_arg1, _arg2, _arg3, _arg4){
var _local5:int;
var _local6:int;
var _local7:int;
_local5 = -1;
_local6 = 1000;
_local7 = liveCreeps.length;
if (_arg4 == 2){
i = 0;
while (i < _local7) {
if ((((liveCreeps[i].x > 0)) && ((liveCreeps[i].y > 0)))){
if (distanceToCreep(_arg1, _arg2, i) < _arg3){
_local6 = distanceToCreep(_arg1, _arg2, i);
_local5 = i;
return (i);
};
};
i++;
};
};
if (_arg4 == 1){
i = 0;
while (i < _local7) {
if ((((liveCreeps[i].x > 0)) && ((liveCreeps[i].y > 0)))){
if ((((distanceToCreep(_arg1, _arg2, i) < _arg3)) && ((liveCreeps[i].canFly == true)))){
_local6 = distanceToCreep(_arg1, _arg2, i);
_local5 = i;
return (i);
};
};
i++;
};
};
if (_arg4 == 0){
i = 0;
while (i < _local7) {
if ((((liveCreeps[i].x > 0)) && ((liveCreeps[i].y > 0)))){
if ((((distanceToCreep(_arg1, _arg2, i) < _arg3)) && ((liveCreeps[i].canFly == false)))){
_local6 = distanceToCreep(_arg1, _arg2, i);
_local5 = i;
return (i);
};
};
i++;
};
};
return (-1);
}
public function canBuild():Boolean{
if (userCash >= towerCosts[brushSelected][0]){
return (true);
};
return (false);
}
public function displayTowerInfo(_arg1, _arg2){
var _local3:int;
var _local4:int;
var _local5:*;
var _local6:Number;
if (_arg2 == -1){
ainterfaceLayer.towerName.text = (towerNames[_arg1] + " L1");
ainterfaceLayer.towerCost.text = towerCosts[_arg1][0];
ainterfaceLayer.towerDamage.text = towerDamage[_arg1][0];
if (towerDamage[_arg1][1] != 0){
ainterfaceLayer.towerDamage.text = ("" + towerDamage[_arg1][0]);
} else {
ainterfaceLayer.towerDamage.text = ("" + towerSplashDamage[_arg1][0]);
};
ainterfaceLayer.towerRange.text = towerRange[_arg1][0];
ainterfaceLayer.towerCostUpg.text = towerCosts[_arg1][1];
if (towerDamage[_arg1][1] != 0){
ainterfaceLayer.towerReloadUpg.text = ("+" + (towerDamage[_arg1][1] - towerDamage[_arg1][0]));
} else {
ainterfaceLayer.towerReloadUpg.text = ("+" + (towerSplashDamage[_arg1][1] - towerSplashDamage[_arg1][0]));
};
ainterfaceLayer.upgradeButton.upgradeText.text = "N/A";
ainterfaceLayer.sellButton.sellText.text = "N/A";
ainterfaceLayer.towerInfo.text = towerTexts[_arg1];
ainterfaceLayer.towerRangeUpg.text = ("+" + (towerRange[_arg1][1] - towerRange[_arg1][0]));
} else {
_local3 = towerList[_arg2].towerType;
_local4 = towerList[_arg2].upgradeLevel;
ainterfaceLayer.sellButton.sellText.text = ("SELL " + calcSellAmount(_local3, _local4));
ainterfaceLayer.towerInfo.text = towerTexts[_local3];
showTowerRangeTimeOut(towerList[_arg2].x, towerList[_arg2].y, towerRange[_local3][_local4], true);
towerSelectedImg1.x = towerList[_arg2].x;
towerSelectedImg1.y = towerList[_arg2].y;
if (towerCosts[_local3][(_local4 + 1)] != undefined){
ainterfaceLayer.towerName.text = ((towerNames[_local3] + " L") + (_local4 + 1));
_local5 = _local4;
_local6 = 0;
while (_local5 > -1) {
_local6 = (_local6 + towerCosts[_local3][_local5]);
_local5--;
};
ainterfaceLayer.towerCost.text = _local6;
if (towerDamage[_local3][_local4] != 0){
ainterfaceLayer.towerDamage.text = ("" + towerDamage[_local3][_local4]);
} else {
ainterfaceLayer.towerDamage.text = ("" + towerSplashDamage[_local3][_local4]);
};
ainterfaceLayer.towerRange.text = towerRange[_local3][_local4];
ainterfaceLayer.upgradeButton.upgradeText.text = ("UPGRADE " + towerCosts[_local3][(_local4 + 1)]);
ainterfaceLayer.towerRangeUpg.text = ("+" + (towerRange[_local3][(_local4 + 1)] - towerRange[_local3][_local4]));
ainterfaceLayer.towerCostUpg.text = ("" + towerCosts[_local3][(_local4 + 1)]);
if (towerDamage[_local3][_local4] != 0){
ainterfaceLayer.towerReloadUpg.text = ("+" + (towerDamage[_local3][(_local4 + 1)] - towerDamage[_local3][_local4]));
} else {
ainterfaceLayer.towerReloadUpg.text = ("+" + (towerSplashDamage[_local3][(_local4 + 1)] - towerDamage[_local3][_local4]));
};
} else {
ainterfaceLayer.upgradeButton.upgradeText.text = "N/A";
ainterfaceLayer.towerReloadUpg.text = "N/A";
ainterfaceLayer.towerCostUpg.text = "N/A";
ainterfaceLayer.towerRangeUpg.text = "N/A";
};
};
}
public function upgradeSelected(){
if (selectedTower >= 0){
if (userCash >= towerCosts[towerList[selectedTower].towerType][(towerList[selectedTower].upgradeLevel + 1)]){
userCash = (userCash - towerCosts[towerList[selectedTower].towerType][(towerList[selectedTower].upgradeLevel + 1)]);
ainterfaceLayer.userCashText.text = userCash;
towerList[selectedTower].upgradeTower();
populateTowerInfo(towerList[selectedTower].towerUID);
displayTowerInfo(0, selectedTower);
};
};
}
public function save_route(_arg1, _arg2, _arg3, _arg4){
var _local5:*;
var _local6:*;
_local5 = new Array();
_local6 = new Array();
if (routeCache[_arg1][_arg2] == undefined){
return;
};
i = 0;
while (i < _arg3.length) {
_local5.push(_arg3[i]);
_local6.push(_arg3[i]);
i++;
};
routeCache[_arg1][_arg2].iRoute = _local5;
routeCache[_arg1][_arg2].iNeedCheck = false;
routeCache[_arg1][_arg2].iInit = true;
if (_arg3.length > 1){
if (_local6[0] == undefined){
return;
};
_local6.splice(0, 1);
save_route(_local6[0].nodeX, _local6[0].nodeY, _local6, _arg4);
};
}
public function doRangeImage(_arg1, _arg2, _arg3, _arg4){
if (((_arg4) && (((timedOut) || ((selectedTower == -1)))))){
rangeimage.x = _arg1;
rangeimage.y = _arg2;
rangeimage.width = (_arg3 * 2);
rangeimage.height = (_arg3 * 2);
rangeimage.visible = true;
rangeimage.gotoAndStop(1);
} else {
if (timedOut){
rangeimage.visible = false;
};
};
}
public function doTutorial(){
var _local1:MovieClip;
startScreen.visible = false;
_local1 = (this.addChild(new tutorial()) as MovieClip);
_local1.rt = this;
}
public function doGetPosition(){
var _local1:*;
var _local2:Responder;
var _local3:*;
_local1 = new NetConnection();
_local2 = new Responder(onGetPosition, onFault);
_local1.connect("http://www.dukesbox.com/flashservices/gateway.php");
_local3 = 18;
_local1.call("validate.get_free_position", _local2, _local3, currentScore, difficultyLevel);
}
public function buildTower(_arg1, _arg2){
var _local3:*;
var _local4:*;
var _local5:*;
userCash = (userCash - towerCosts[brushSelected][0]);
ainterfaceLayer.userCashText.text = userCash;
_local3 = this.towerLayer.addChild(new towerBase());
towerCount++;
_local3.x = _arg1;
_local3.y = _arg2;
_local3.towerType = brushSelected;
_local3.rt = this;
_local3.reloadTime = 5;
_local3.dualFire = true;
_local3.towerUID = towerCount;
selectedTower = towerList.length;
towerList.push(_local3);
_local4 = Math.round((((_arg1 - gridStartX) + 5) / squareWidth));
_local5 = Math.round((((_arg2 - gridStartY) + 5) / squareHeight));
walkable[_local4][_local5] = false;
walkable[(_local4 + 1)][_local5] = false;
walkable[_local4][(_local5 + 1)] = false;
walkable[(_local4 + 1)][(_local5 + 1)] = false;
checkAllRoutes();
displayTowerInfo(0, selectedTower);
}
public function loading(_arg1:Event){
var _local2:*;
var _local3:*;
var _local4:*;
_local2 = stage.loaderInfo.bytesTotal;
_local3 = stage.loaderInfo.bytesLoaded;
_local4 = Math.round(((_local3 * 100) / _local2));
myText.text = String(_local4);
if (_local3 >= _local2){
trace("removing event listener");
stage.removeEventListener(Event.ENTER_FRAME, loading);
this.nextScene();
};
}
public function changeBrush(_arg1){
brushSelected = _arg1;
selectedTower = -1;
displayTowerInfo(brushSelected, selectedTower);
}
public function calcXSpeed(_arg1){
while (_arg1 < 0) {
_arg1 = (_arg1 + 360);
};
while (_arg1 > 360) {
_arg1 = (_arg1 - 360);
};
return (sine[Math.round(_arg1)]);
}
public function createCreep(_arg1, _arg2, _arg3){
var _local4:*;
var _local5:*;
creepCount++;
_local4 = this.creepLayer.addChild(new Creep());
_local5 = (liveCreeps.length - 1);
_local4.spriteType = _arg2;
if (_arg1){
_local4.x = -30;
_local4.y = (((startAreaY1 * squareHeight) + Math.round((((Math.random() * openAreaSize) - 1) * squareHeight))) + gridStartY);
_local4.targetX = (gridWidth - 1);
_local4.targetY = (finishAreaY1 + Math.round((Math.random() * openAreaSize)));
} else {
_local4.x = (((startAreaX2 * squareWidth) + Math.round(((Math.random() * openAreaSize) * squareWidth))) + gridStartX);
_local4.y = -30;
_local4.targetX = (finishAreaX2 + Math.round((Math.random() * openAreaSize)));
_local4.targetY = (gridHeight - 1);
};
_local4.rt = this;
_local4.creepUID = creepCount;
_local4.iLeftToRight = _arg1;
setCreepData(_local4);
liveCreeps.push(_local4);
}
public function showTowerRangeTimeOut(_arg1, _arg2, _arg3, _arg4){
if (_arg4){
timedOut = false;
rangeimage.x = (_arg1 + 11);
rangeimage.y = (_arg2 + 9);
rangeimage.width = (_arg3 * 2);
rangeimage.height = (_arg3 * 2);
rangeimage.visible = true;
rangeimage.gotoAndPlay(2);
} else {
rangeimage.visible = false;
};
}
public function doFire(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10, _arg11, _arg12, _arg13, _arg14, _arg15){
var _local16:*;
shotsFired = (shotsFired + 1);
if (_arg15 == liveCreeps[_arg8].creepUID){
_local16 = this.projectileLayer.addChild(new projectileBase());
_local16.x = _arg2;
_local16.y = _arg3;
_local16.projectileDamage = _arg9;
_local16.projectileSplash = _arg10;
_local16.splashRange = _arg11;
_local16.targetX = _arg6;
_local16.targetY = _arg7;
_local16.targetCreep = _arg8;
_local16.targetCreepUID = _arg15;
_local16.visible = true;
_local16.projectileType = _arg1;
_local16.canSlow = _arg12;
_local16.canPoison = _arg13;
_local16.canBurn = _arg14;
_local16.rt = this;
liveProjectiles.push(_local16);
};
}
public function distanceToCreep(_arg1, _arg2, _arg3){
var _local4:int;
var _local5:int;
var _local6:*;
_local4 = (_arg2 - liveCreeps[_arg3].y);
_local5 = (_arg1 - liveCreeps[_arg3].x);
_local4 = (_local4 * _local4);
_local5 = (_local5 * _local5);
_local6 = (_local5 + _local4);
if (_local6 < 0){
_local6 = (_local6 * -1);
};
return (Math.round(Math.sqrt(_local6)));
}
public function populateTowerInfo(_arg1){
var _local2:*;
var _local3:*;
var _local4:*;
_local2 = 0;
while (_local2 < towerList.length) {
if (towerList[_local2].towerUID == _arg1){
break;
};
_local2++;
};
_local3 = towerList[_local2].towerType;
_local4 = towerList[_local2].upgradeLevel;
towerList[_local2].towerRange = towerRange[_local3][_local4];
towerList[_local2].damage = towerDamage[_local3][_local4];
towerList[_local2].splashDamage = towerSplashDamage[_local3][_local4];
towerList[_local2].splashRange = towerSplashRange[_local3][_local4];
towerList[_local2].slowLength = towerSlow[_local3][_local4];
towerList[_local2].poisonLength = towerPoison[_local3][_local4];
towerList[_local2].burnLength = towerBurn[_local3][_local4];
towerList[_local2].reloadTime = towerReload[_local3][_local4];
towerList[_local2].dualFire = towerDualFire[_local3];
towerList[_local2].recoil = towerRecoil[_local3];
towerList[_local2].canHitAir = towerCanHitAir[_local3];
}
public function returnCreepIndex(_arg1){
var _local2:*;
_local2 = 0;
while (_local2 < liveCreeps.length) {
if (liveCreeps[_local2].creepUID == _arg1){
return (_local2);
};
_local2++;
};
return (-1);
}
public function onValidateGame(_arg1:Object):void{
trace(_arg1);
doGetGameInfo();
}
public function start_game(){
var _local1:*;
_local1 = 0;
while (_local1 < maxReleases) {
creepReleaseTypes[_local1] = _local1;
switch (difficultyLevel){
case 1:
numbers = 6;
break;
case 2:
numbers = 8;
break;
case 3:
numbers = 12;
break;
};
creepReleaseNumbers[_local1] = numbers;
_local1++;
};
doInterfaceUpdate();
ainterfaceLayer.nextLevelLabel.text = creepName[creepReleaseTypes[0]];
create_tiles();
ticker = 0;
onTimer.start();
tickerTimer.start();
finalRound = false;
}
public function checkExistsInOpen(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6){
if (knownOpenArray[_arg1][_arg2] != 0){
if (_arg5 < knownOpenArray[_arg1][_arg2].gValue){
knownOpenArray[_arg1][_arg2].ParentX = _arg3;
knownOpenArray[_arg1][_arg2].ParentY = _arg4;
knownOpenArray[_arg1][_arg2].gValue = _arg5;
knownOpenArray[_arg1][_arg2].fValue = _arg6;
};
} else {
return (false);
};
}
public function justShowLeaderboard(){
MochiScores.showLeaderboard({boardID:"1cd1415ace4e4331"});
}
public function gameLoop(_arg1:TimerEvent):void{
var _local2:int;
var _local3:*;
var _local4:Array;
var _local5:Array;
var _local6:int;
var _local7:*;
var _local8:*;
var _local9:int;
var _local10:int;
_local2 = 0;
ticker++;
fps++;
_local3 = liveCreeps.length;
_local6 = 0;
while (_local6 < _local3) {
liveCreeps[_local6].doMovement();
if (liveCreeps[_local6].visible == false){
_local4 = liveCreeps.splice(_local6, 1);
creepLayer.removeChild(_local4[0]);
_local4[0].selfClean();
_local4[0] = null;
_local4 = null;
_local3--;
_local6--;
};
_local6++;
};
if (finalRound){
if (_local3 == 0){
runEndGame();
};
};
_local7 = towerList.length;
if ((ticker % 2) == 0){
_local10 = 0;
while (_local10 < _local7) {
towerList[_local10].doMovement();
_local10++;
};
};
_local8 = liveProjectiles.length;
_local2 = (_local2 + _local8);
_local9 = 0;
while (_local9 < _local8) {
if (liveProjectiles[_local9] != undefined){
liveProjectiles[_local9].doMovement();
if (liveProjectiles[_local9].visible == false){
_local5 = liveProjectiles.splice(_local9, 1);
projectileLayer.removeChild(_local5[0]);
_local5[0].selfClean();
_local5[0] = null;
_local5 = null;
_local8--;
_local9--;
};
};
_local9++;
};
if ((ticker % 2) == 0){
ainterfaceLayer.handleMouse();
doRangeImage((ainterfaceLayer.mouseBut.x + 11), (ainterfaceLayer.mouseBut.y + 9), getSelectedTowerRange(brushSelected, -1), ainterfaceLayer.mouseBut.visible);
};
}
public function onTicker(_arg1:TimerEvent):void{
var _local2:*;
totalTimeTaken = 0;
fps = 0;
frames = 0;
if (tickCount >= 0){
if (!finalRound){
ainterfaceLayer.tickerLabel.text = tickCount;
} else {
ainterfaceLayer.tickerLabel.text = "0";
};
tickCount--;
if ((((tickCount < 25)) && ((tickCount > 0)))){
ainterfaceLayer.spaceToRelase.visible = true;
} else {
ainterfaceLayer.spaceToRelase.visible = false;
};
} else {
if (!finalRound){
tickCount = maxTicks;
_local2 = 0;
while (_local2 < creepReleaseNumbers[lastReleased]) {
createCreep(true, creepReleaseTypes[lastReleased], 0);
createCreep(false, creepReleaseTypes[lastReleased], 0);
_local2++;
};
if (lastReleased < (creepReleaseTypes.length - 1)){
ainterfaceLayer.nextLevelLabel.text = creepName[creepReleaseTypes[(lastReleased + 1)]];
} else {
ainterfaceLayer.nextLevelLabel.text = "FINAL ROUND!";
tickCount = 0;
finalRound = true;
};
lastReleased++;
ainterfaceLayer.currentLevelLabel.text = lastReleased;
};
};
}
public function onGetGameInfo(_arg1:Object){
var _local2:*;
trace(("in onGetGameInfo" + _arg1));
_local2 = 0;
while (_local2 < 8) {
trace(((("index " + _local2) + " is ") + _arg1[_local2]));
_local2++;
};
startAreaX1 = 1;
startAreaY1 = _arg1[0];
startAreaX2 = _arg1[1];
startAreaY2 = 1;
finishAreaX1 = (gridWidth - 2);
finishAreaY1 = _arg1[2];
finishAreaX2 = _arg1[3];
finishAreaY2 = (gridHeight - 2);
doInitGame();
}
public function removeFromOpen(_arg1, _arg2){
var _local3:*;
var _local4:*;
var _local5:*;
_local3 = openList.length;
_local4 = 0;
while (_local4 < _local3) {
_local5 = openList[_local4];
if ((((_local5.nodeX == _arg1)) && ((_local5.nodeY == _arg2)))){
openList.splice(_local4, 1);
return (_local5);
};
_local4++;
};
return (_local5);
}
public function removeClip(_arg1:MovieClip){
this.removeChild(_arg1);
_arg1 = null;
}
public function calcYSpeed(_arg1){
while (_arg1 < 0) {
_arg1 = (_arg1 + 360);
};
while (_arg1 > 360) {
_arg1 = (_arg1 - 360);
};
return (cosine[Math.round(_arg1)]);
}
public function setCreepData(_arg1){
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:Boolean;
var _local6:Boolean;
var _local7:int;
var _local8:*;
var _local9:Boolean;
_local2 = 0;
_local3 = 0;
_local4 = 0;
_local5 = false;
_local6 = false;
_local7 = 0;
_local8 = _arg1.spriteType;
_local9 = false;
switch (_local8){
case 0:
_local2 = 4;
_local3 = 2;
_local4 = 1;
_local7 = 200;
break;
case 1:
_local2 = 3;
_local3 = 2;
_local4 = 1;
_local7 = 20;
break;
case 2:
_local2 = 12;
_local3 = 2.5;
_local4 = 1;
_local7 = 200;
break;
case 3:
_local2 = 35;
_local3 = 1.5;
_local4 = 1;
_local7 = 150;
_local5 = true;
break;
case 4:
_local2 = 6;
_local3 = 3.5;
_local4 = 1;
_local6 = true;
_local7 = 200;
_local9 = true;
break;
case 5:
_local2 = 70;
_local3 = 1.1;
_local4 = 1;
_local7 = 450;
_local5 = true;
break;
case 6:
_local2 = 65;
_local3 = 2;
_local4 = 3;
_local7 = 300;
break;
case 7:
_local2 = 65;
_local3 = 2;
_local4 = 3;
_local7 = 50;
break;
case 8:
_local2 = 70;
_local3 = 3;
_local4 = 3;
_local5 = true;
_local7 = 400;
break;
case 9:
_local2 = 85;
_local3 = 2;
_local4 = 3;
_local7 = 400;
_local5 = true;
break;
case 10:
_local6 = true;
_local2 = 50;
_local3 = 4;
_local4 = 3;
_local7 = 400;
_local9 = true;
break;
case 11:
_local2 = 200;
_local3 = 1.2;
_local4 = 3;
_local7 = 450;
_local5 = true;
break;
case 12:
_local2 = 170;
_local3 = 2;
_local4 = 4;
_local7 = 300;
break;
case 13:
_local2 = 170;
_local3 = 2.2;
_local4 = 4;
_local7 = 50;
break;
case 14:
_local2 = 170;
_local3 = 3;
_local4 = 4;
_local7 = 340;
break;
case 15:
_local2 = 250;
_local3 = 1.5;
_local4 = 4;
_local7 = 200;
_local5 = true;
break;
case 16:
_local2 = 250;
_local3 = 3.5;
_local4 = 4;
_local7 = 350;
_local6 = true;
break;
case 17:
_local2 = 480;
_local3 = 1.3;
_local4 = 4;
_local7 = 200;
_local5 = true;
break;
case 18:
_local2 = 370;
_local3 = 2.4;
_local4 = 4;
_local7 = 250;
break;
case 19:
_local2 = 370;
_local3 = 2.8;
_local4 = 4;
_local7 = 50;
break;
case 20:
_local2 = 430;
_local3 = 3.8;
_local4 = 4;
_local7 = 350;
break;
case 21:
_local2 = 440;
_local3 = 2.6;
_local4 = 4;
_local7 = 350;
_local5 = true;
break;
case 22:
_local2 = 460;
_local3 = 2.4;
_local4 = 4;
_local7 = 250;
_local6 = true;
break;
case 23:
_local2 = 700;
_local3 = 2;
_local4 = 4;
_local7 = 350;
break;
case 24:
_local2 = 650;
_local3 = 2;
_local4 = 5;
_local7 = 250;
break;
case 25:
_local2 = 650;
_local3 = 2.4;
_local4 = 5;
_local7 = 50;
break;
case 26:
_local2 = 550;
_local3 = 4;
_local4 = 5;
_local7 = 450;
break;
case 27:
_local2 = 720;
_local3 = 2;
_local4 = 5;
_local7 = 350;
_local5 = true;
break;
case 28:
_local2 = 690;
_local3 = 4;
_local4 = 5;
_local7 = 350;
_local6 = true;
break;
case 29:
_local2 = 800;
_local3 = 2.4;
_local4 = 5;
_local7 = 325;
_local5 = true;
break;
case 30:
_local2 = 730;
_local3 = 2.4;
_local4 = 6;
_local7 = 300;
break;
case 31:
_local2 = 730;
_local3 = 2.6;
_local4 = 6;
_local7 = 55;
break;
case 32:
_local2 = 780;
_local3 = 3.8;
_local4 = 6;
_local7 = 325;
break;
case 33:
_local2 = 820;
_local3 = 2;
_local4 = 6;
_local7 = 325;
_local5 = true;
break;
case 34:
_local2 = 700;
_local3 = 4.5;
_local4 = 6;
_local7 = 225;
_local6 = true;
break;
case 35:
_local2 = 1200;
_local3 = 2;
_local4 = 6;
_local7 = 325;
_local5 = true;
break;
};
switch (difficultyLevel){
case 1:
_local2 = (_local2 * 0.5);
break;
case 2:
default:
_local2 = (_local2 * 1);
break;
case 3:
_local2 = (_local2 * 1.5);
break;
};
_arg1.immune = _local5;
_arg1.health = _local2;
_arg1.maxHealth = _local2;
_arg1.creepValue = _local4;
_arg1.iSpeed = _local3;
_arg1.canFly = _local6;
_arg1.isBird = _local9;
_arg1.sleepTimer = Math.round((Math.random() * _local7));
}
public function addFunds(_arg1, _arg2, _arg3, _arg4){
var _local5:*;
var _local6:Number;
userCash = (userCash + _arg3);
currentScore = (currentScore + (_arg3 * 2));
doInterfaceUpdate();
ainterfaceLayer.userCashText.text = userCash;
_local5 = this.addChild(new addCash());
_local5.x = _arg1;
_local5.y = _arg2;
_local5.cashVal = _arg3;
_local5.rt = this;
if (!_arg4){
_local6 = Math.round((Math.random() * 4));
switch (_local6){
case 0:
default:
death1.gotoAndPlay(2);
break;
case 1:
death2.gotoAndPlay(2);
break;
case 2:
death3.gotoAndPlay(2);
break;
case 3:
death4.gotoAndPlay(2);
break;
};
} else {
_local6 = Math.round((Math.random() * 3));
switch (_local6){
case 0:
default:
birddeath1.gotoAndPlay(2);
break;
case 1:
birddeath2.gotoAndPlay(2);
break;
case 2:
birddeath3.gotoAndPlay(2);
break;
};
};
}
public function still_valid1(_arg1, _arg2){
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
if (routeCache1[_arg1][_arg2].iInit == false){
return (false);
};
_local3 = routeCache1[_arg1][_arg2].iRoute.length;
_local4 = 0;
while (_local4 < _local3) {
if (walkable[routeCache1[_arg1][_arg2].iRoute[_local4].nodeX][routeCache1[_arg1][_arg2].iRoute[_local4].nodeY] == false){
return (false);
};
_local5 = routeCache1[_arg1][_arg2].iRoute[_local4].nodeX;
_local6 = routeCache1[_arg1][_arg2].iRoute[_local4].nodeY;
if (_local4 < (_local3 - 1)){
_local7 = routeCache1[_arg1][_arg2].iRoute[(_local4 + 1)].nodeX;
_local8 = routeCache1[_arg1][_arg2].iRoute[(_local4 + 1)].nodeY;
if (_local7 != undefined){
if (((!(walkable[_local5][_local8])) && (!(walkable[_local7][_local6])))){
return (false);
};
};
};
_local4++;
};
routeCache1[_arg1][_arg2].iNeedCheck = false;
return (true);
}
public function doAStarQuick(_arg1, _arg2, _arg3, _arg4, _arg5):Boolean{
var _local6:*;
var _local7:int;
var _local8:int;
var _local9:Boolean;
var _local10:int;
var _local11:int;
var _local12:Boolean;
var _local13:*;
var _local14:Boolean;
var _local15:*;
var _local16:int;
var _local17:*;
var _local18:*;
var _local19:*;
var _local20:*;
var _local21:*;
var _local22:*;
var _local23:*;
var _local24:*;
var _local25:*;
_local6 = 0;
while (_local6 < gridWidth) {
_local17 = 0;
while (_local17 < gridHeight) {
markedOnClosed[_local6][_local17] = false;
knownOpenArray[_local6][_local17] = 0;
_local17++;
};
_local6++;
};
partialRoute = false;
checkFinishTileX = _arg3;
checkFinishTileY = _arg4;
doingLeftToRight = _arg5;
openList = new Array();
closedList = new Array();
route = new Array();
aStarRan = true;
_local7 = 0;
_local8 = 0;
_local9 = false;
_local10 = _arg1;
_local11 = _arg2;
_local12 = false;
_local13 = false;
_local14 = false;
_local15 = addToOpen(_local10, _local11, -1, -1, 0, 0);
_local16 = 0;
while (((!(_local14)) && ((_local16 < 600)))) {
_local10 = _local15.nodeX;
_local11 = _local15.nodeY;
_local16++;
_local18 = (_local10 - 1);
while (_local18 <= (_local10 + 1)) {
_local19 = (_local11 - 1);
while (_local19 <= (_local11 + 1)) {
if ((((_local18 > 0)) && ((_local19 > 0)))){
if ((((_local18 < gridWidth)) && ((_local19 < gridHeight)))){
if (((walkable[_local18][_local19]) && (!(markedOnClosed[_local18][_local19])))){
_local20 = 0;
_local21 = (_local18 - _local10);
_local22 = (_local19 - _local11);
if (((((!((_local21 == 0))) || (!((_local22 == 0))))) && ((((_local21 == _local22)) || ((_local21 == (_local22 * -1))))))){
if (((!(walkable[_local10][_local19])) && (!(walkable[_local18][_local11])))){
_local20 = 0;
} else {
_local20 = 13;
};
} else {
_local20 = 10;
};
if (_local20 > 0){
_local23 = (_local18 - checkFinishTileX);
if (_local23 < 0){
_local23 = (_local23 * -1);
};
_local24 = (_local19 - checkFinishTileY);
if (_local24 < 0){
_local24 = (_local24 * -1);
};
_local25 = ((_local15.gValue + _local20) + ((_local23 + _local24) * 10));
addToOpen(_local18, _local19, _local10, _local11, (_local15.gValue + _local20), _local25);
};
};
};
};
_local19++;
};
_local18++;
};
_local15 = removeFromOpen(_local10, _local11);
if (addToClosed(_local15) == true){
_local14 = true;
_local13 = true;
} else {
if (openList.length > 0){
_local15 = openList[0];
} else {
trace("a* exhausted");
_local16 = 1000000;
};
};
};
if (_local13 == true){
route = reverseClosed();
route.splice((route.length - 1), 1);
if (!doingLeftToRight){
save_route1(_arg1, _arg2, route, route.length);
} else {
save_route(_arg1, _arg2, route, route.length);
};
};
openList = null;
closedList = null;
route = null;
return (_local13);
}
public function doValidateGame(){
var _local1:*;
var _local2:Responder;
_local1 = new NetConnection();
_local2 = new Responder(onValidateGame, onFault);
_local1.connect("http://www.dukesbox.com/flashservices/gateway.php");
_local1.call("validate.is_valid", _local2, thisgameid, thisgametype);
}
public function calcAngle2D(_arg1, _arg2, _arg3, _arg4){
return ((Math.atan2((_arg4 - _arg2), (_arg3 - _arg1)) * 57));
}
public function runEndGame(){
onTimer.stop();
tickerTimer.stop();
endGameClip = projectileLayer.addChild(new metalScreenEnd());
endGameClip.finalScore.text = (" Your Final Score was " + currentScore);
endGameClip.score = currentScore;
endGameClip.rt = this;
}
public function calcSellAmount(_arg1, _arg2){
var _local3:int;
_local3 = 0;
while (_arg2 >= 0) {
_local3 = (_local3 + towerCosts[_arg1][_arg2]);
_arg2--;
};
_local3 = (_local3 * 0.75);
return (_local3);
}
public function create_tiles(){
var _local1:*;
var _local2:*;
_local1 = 0;
while (_local1 < gridWidth) {
_local2 = 0;
while (_local2 < gridHeight) {
tiles[_local1][_local2] = this.towerLayer.addChild(new tile());
tiles[_local1][_local2].x = (gridStartX + (_local1 * squareWidth));
tiles[_local1][_local2].y = (gridStartY + (_local2 * squareHeight));
if ((((((((((((((((_local1 == 1)) || ((_local2 == 1)))) || ((_local1 == (gridWidth - 2))))) || ((_local2 == (gridHeight - 2))))) && (!((_local1 == 0))))) && (!((_local2 == 0))))) && (!((_local1 == (gridWidth - 1)))))) && (!((_local2 == (gridHeight - 1)))))){
tiles[_local1][_local2].turnToWall();
walkable[_local1][_local2] = false;
};
if (_local1 == 0){
walkable[_local1][_local2] = false;
};
if ((_local2 == 0)){
walkable[_local1][_local2] = false;
};
if (_local2 == (gridHeight - 1)){
walkable[_local1][_local2] = false;
};
if ((((((((_local1 == 0)) || ((_local2 == 0)))) || ((_local1 == (gridWidth - 1))))) || ((_local2 == (gridHeight - 1))))){
walkable[_local1][_local2] = false;
};
if ((((((((((((_local1 <= startAreaX1)) && ((_local2 >= startAreaY1)))) && ((_local2 <= (startAreaY1 + openAreaSize))))) || ((((((_local2 <= startAreaY2)) && ((_local1 >= startAreaX2)))) && ((_local1 <= (startAreaX2 + openAreaSize))))))) || ((((((_local1 >= finishAreaX1)) && ((_local2 >= finishAreaY1)))) && ((_local2 <= (finishAreaY1 + openAreaSize))))))) || ((((((_local2 >= finishAreaY2)) && ((_local1 >= finishAreaX2)))) && ((_local1 <= (finishAreaX2 + openAreaSize))))))){
tiles[_local1][_local2].visible = false;
walkable[_local1][_local2] = true;
};
_local2++;
};
_local1++;
};
}
public function goToEndGameTarget(){
if (mochimode == 1){
navigateToURL(new URLRequest("#"));
} else {
navigateToURL(new URLRequest(targetURL), "");
};
}
public function getSelectedTowerRange(_arg1, _arg2){
if (_arg2 == -1){
return (towerRange[_arg1][0]);
};
}
public function still_valid(_arg1, _arg2){
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
if (routeCache[_arg1][_arg2].iInit == false){
return (false);
};
_local3 = routeCache[_arg1][_arg2].iRoute.length;
_local4 = 0;
while (_local4 < _local3) {
if (walkable[routeCache[_arg1][_arg2].iRoute[_local4].nodeX][routeCache[_arg1][_arg2].iRoute[_local4].nodeY] == false){
return (false);
};
_local5 = routeCache[_arg1][_arg2].iRoute[_local4].nodeX;
_local6 = routeCache[_arg1][_arg2].iRoute[_local4].nodeY;
if (_local4 < (_local3 - 1)){
_local7 = routeCache[_arg1][_arg2].iRoute[(_local4 + 1)].nodeX;
_local8 = routeCache[_arg1][_arg2].iRoute[(_local4 + 1)].nodeY;
if (((!(walkable[_local5][_local8])) && (!(walkable[_local7][_local6])))){
return (false);
};
};
_local4++;
};
routeCache[_arg1][_arg2].iNeedCheck = false;
return (true);
}
public function wouldBlock(_arg1, _arg2):Boolean{
var _local3:*;
var _local4:*;
var _local5:Boolean;
_local3 = Math.round((((_arg1 - gridStartX) + 5) / squareWidth));
_local4 = Math.round((((_arg2 - gridStartY) + 5) / squareHeight));
if ((((((((walkable[_local3][_local4] == false)) || ((walkable[(_local3 + 1)][_local4] == false)))) || ((walkable[_local3][(_local4 + 1)] == false)))) || ((walkable[(_local3 + 1)][(_local4 + 1)] == false)))){
return (true);
};
_local5 = false;
walkable[_local3][_local4] = false;
walkable[(_local3 + 1)][_local4] = false;
walkable[_local3][(_local4 + 1)] = false;
walkable[(_local3 + 1)][(_local4 + 1)] = false;
if (!doAStarQuick((startAreaX1 - 1), startAreaY1, (finishAreaX1 + 1), finishAreaY1, true)){
_local5 = true;
};
if (!_local5){
if (!doAStarQuick(startAreaX2, (startAreaY2 - 1), finishAreaX2, (finishAreaY2 + 1), false)){
_local5 = true;
};
};
walkable[_local3][_local4] = true;
walkable[(_local3 + 1)][_local4] = true;
walkable[_local3][(_local4 + 1)] = true;
walkable[(_local3 + 1)][(_local4 + 1)] = true;
return (_local5);
}
public function doInitGame(){
var _local1:*;
var _local2:*;
var _local3:Object;
var _local4:Object;
towerLayer = (this.addChild(new layer()) as MovieClip);
creepLayer = (this.addChild(new layer()) as MovieClip);
projectileLayer = (this.addChild(new layer()) as MovieClip);
startScreen = this.addChild(new metalScreen());
startScreen.rt = this;
ainterfaceLayer = (this.addChild(new interfaceLayer()) as MovieClip);
ainterfaceLayer.rt = this;
_local1 = 0;
while (_local1 < gridWidth) {
routeCache[_local1] = new Array(gridHeight);
routeCache1[_local1] = new Array(gridHeight);
walkable[_local1] = new Array(gridHeight);
tiles[_local1] = new Array(gridHeight);
_local2 = 0;
while (_local2 < gridHeight) {
walkable[_local1][_local2] = true;
_local3 = {iInit:false, iNeedCheck:false, iRoute:new Array()};
_local4 = {iInit:false, iNeedCheck:false, iRoute:new Array()};
routeCache[_local1][_local2] = _local3;
routeCache1[_local1][_local2] = _local4;
_local2++;
};
_local1++;
};
liveCreeps = new Array();
towerList = new Array();
liveProjectiles = new Array();
selectedBrush = 0;
creepCount = 0;
tickCount = 35;
maxTicks = tickCount;
lastReleased = 0;
selectedTower = -1;
userLives = 20;
userCash = 100;
displayTowerInfo(1, -1);
}
public function reverseClosed(){
var _local1:*;
var _local2:*;
var _local3:*;
var _local4:*;
_local1 = closedList[(closedList.length - 1)];
closedList.splice((closedList.length - 1), 1);
_local2 = new Array();
_local3 = 0;
_local4 = new Array();
if (partialRoute){
if (!doingLeftToRight){
_local4 = routeCache1[_local1.nodeX][_local1.nodeY].iRoute;
} else {
_local4 = routeCache[_local1.nodeX][_local1.nodeY].iRoute;
};
i5 = _local4.length;
while (i5 >= 0) {
if (_local4[i5] != undefined){
_local2[_local3] = _local4[i5];
};
_local3++;
i5--;
};
};
_local2[_local3] = _local1;
while (_local1.ParentX != -1) {
i = 0;
while (i < closedList.length) {
if ((((closedList[i].nodeX == _local1.ParentX)) && ((closedList[i].nodeY == _local1.ParentY)))){
_local1 = closedList[i];
_local3++;
_local2[_local3] = _local1;
};
i++;
};
};
_local2.reverse();
return (_local2);
}
public function onResult(_arg1:Object):void{
trace(("onResult: " + _arg1));
}
public function onGetPosition(_arg1:Object):void{
endGameClip.leaderboardPosition = parseInt(_arg1);
}
public function doInterfaceUpdate(){
ainterfaceLayer.userCashText.text = userCash;
ainterfaceLayer.livesText.text = userLives;
ainterfaceLayer.scoreText.text = currentScore;
}
public function addToOpen(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6){
var _local7:Object;
if (checkExistsInOpen(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6) == false){
_local7 = {nodeX:_arg1, nodeY:_arg2, ParentX:_arg3, ParentY:_arg4, gValue:_arg5, fValue:_arg6};
knownOpenArray[_arg1][_arg2] = _local7;
openList.push(_local7);
openList.sortOn(["fValue"]);
return (_local7);
};
}
public function keyDownListener(_arg1:KeyboardEvent):void{
var _local2:int;
_local2 = _arg1.keyCode;
switch (_local2){
case 32:
releaseNextCreeps();
break;
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
changeBrush((_local2 - 48));
case 85:
upgradeSelected();
break;
case 83:
sellSelected();
break;
};
}
public function onFault(_arg1:Object):void{
navigateToURL(new URLRequest(((("http://www.dukesbox.com/?" + thisgameid) + ":") + thisgametype)), "");
trace(("a fault " + _arg1));
}
public function addToClosed(_arg1){
var _local2:*;
closedList.push(_arg1);
markedOnClosed[_arg1.nodeX][_arg1.nodeY] = 1;
_local2 = false;
if (doingLeftToRight){
_local2 = (routeCache[_arg1.nodeX][_arg1.nodeY].iRoute.length > 0);
} else {
_local2 = (routeCache1[_arg1.nodeX][_arg1.nodeY].iRoute.length > 0);
};
if (_local2){
if (doingLeftToRight){
_local2 = still_valid(_arg1.nodeX, _arg1.nodeY);
} else {
_local2 = still_valid1(_arg1.nodeX, _arg1.nodeY);
};
};
if ((((((_arg1.nodeX == checkFinishTileX)) && ((_arg1.nodeY == checkFinishTileY)))) || (_local2))){
if (_local2){
partialRoute = true;
};
return (true);
//unresolved jump
};
return (false);
}
public function doGetGameInfo(){
var _local1:*;
var _local2:Responder;
_local1 = new NetConnection();
_local2 = new Responder(onGetGameInfo, onFault);
_local1.connect("http://www.dukesbox.com/flashservices/gateway.php");
_local1.call("towerdefense.get_level", _local2, thisgameid, thisgametype);
}
public function releaseNextCreeps(){
if ((((tickCount < 25)) && ((tickCount > 1)))){
currentScore = (currentScore + (tickCount * 10));
tickCount = 0;
doInterfaceUpdate();
ainterfaceLayer.spaceToRelase.visible = false;
};
}
}
}//package mochi_defense1_fla
Section 33
//missileTurretTop_72 (mochi_defense1_fla.missileTurretTop_72)
package mochi_defense1_fla {
import flash.display.*;
public dynamic class missileTurretTop_72 extends MovieClip {
public var fire:MovieClip;
public var cannonNose:MovieClip;
public var cannonNose2:MovieClip;
public var fire2:MovieClip;
}
}//package mochi_defense1_fla
Section 34
//plainButtonClip_15 (mochi_defense1_fla.plainButtonClip_15)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class plainButtonClip_15 extends MovieClip {
public var texts:TextField;
public function plainButtonClip_15(){
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package mochi_defense1_fla
Section 35
//poisonFire_146 (mochi_defense1_fla.poisonFire_146)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class poisonFire_146 extends MovieClip {
public function poisonFire_146(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 36
//poisonTurret_144 (mochi_defense1_fla.poisonTurret_144)
package mochi_defense1_fla {
import flash.display.*;
public dynamic class poisonTurret_144 extends MovieClip {
public var fire:MovieClip;
public var cannonNose:MovieClip;
}
}//package mochi_defense1_fla
Section 37
//powerFire_198 (mochi_defense1_fla.powerFire_198)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class powerFire_198 extends MovieClip {
public function powerFire_198(){
addFrameScript(0, frame1, 7, frame8);
}
function frame1(){
stop();
}
function frame8(){
gotoAndStop(2);
}
}
}//package mochi_defense1_fla
Section 38
//powerTurret_197 (mochi_defense1_fla.powerTurret_197)
package mochi_defense1_fla {
import flash.display.*;
public dynamic class powerTurret_197 extends MovieClip {
public var fire:MovieClip;
public var cannonNose:MovieClip;
public var fire3:MovieClip;
public var fire4:MovieClip;
public var nose4:MovieClip;
public var cannonNose2:MovieClip;
public var fire2:MovieClip;
public var nose3:MovieClip;
}
}//package mochi_defense1_fla
Section 39
//sellBtn1_55 (mochi_defense1_fla.sellBtn1_55)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class sellBtn1_55 extends MovieClip {
public var sellText:TextField;
public function sellBtn1_55(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 40
//smashFire_87 (mochi_defense1_fla.smashFire_87)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class smashFire_87 extends MovieClip {
public function smashFire_87(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 41
//smashTurret_86 (mochi_defense1_fla.smashTurret_86)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class smashTurret_86 extends MovieClip {
public var fire:MovieClip;
public var cannonNose:MovieClip;
public function smashTurret_86(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
public function doRecoil(){
gotoAndPlay(2);
}
}
}//package mochi_defense1_fla
Section 42
//turret_128 (mochi_defense1_fla.turret_128)
package mochi_defense1_fla {
import flash.display.*;
public dynamic class turret_128 extends MovieClip {
public var fire:MovieClip;
public var cannonNose:MovieClip;
}
}//package mochi_defense1_fla
Section 43
//TutorialBox_14 (mochi_defense1_fla.TutorialBox_14)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class TutorialBox_14 extends MovieClip {
public var stepTitle:TextField;
public var stepText:TextField;
public var nextBtn:MovieClip;
public var Aarrow:MovieClip;
public var Aarrow2:MovieClip;
public var Aarrow3:MovieClip;
public function TutorialBox_14(){
addFrameScript(0, frame1);
}
public function nextBtnOut(_arg1:MouseEvent):void{
nextBtn.gotoAndStop(1);
}
function frame1(){
nextBtn.addEventListener(MouseEvent.MOUSE_OUT, nextBtnOut);
nextBtn.addEventListener(MouseEvent.MOUSE_OVER, nextBtnOver);
nextBtn.addEventListener(MouseEvent.CLICK, nextBtnClick);
}
public function nextBtnClick(_arg1:MouseEvent):void{
parent.nextFrame();
}
public function nextBtnOver(_arg1:MouseEvent):void{
nextBtn.gotoAndStop(2);
}
}
}//package mochi_defense1_fla
Section 44
//tutorialTower_31 (mochi_defense1_fla.tutorialTower_31)
package mochi_defense1_fla {
import flash.display.*;
public dynamic class tutorialTower_31 extends MovieClip {
public var standardTop:MovieClip;
public var turret:MovieClip;
}
}//package mochi_defense1_fla
Section 45
//upgBtn_54 (mochi_defense1_fla.upgBtn_54)
package mochi_defense1_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class upgBtn_54 extends MovieClip {
public var upgradeText:TextField;
public function upgBtn_54(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mochi_defense1_fla
Section 46
//addCash (addCash)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class addCash extends MovieClip {
public var cashAmount:TextField;
public var rt:MovieClip;
public var cashVal:int;
public function addCash(){
addFrameScript(0, frame1, 1, frame2, 8, frame9);
}
function frame1(){
}
function frame2(){
cashAmount.text = ("+" + cashVal);
}
function frame9(){
stop();
rt.removeClip(this);
}
}
}//package
Section 47
//aMissile (aMissile)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class aMissile extends MovieClip {
public function aMissile(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package
Section 48
//artilleryProjectile (artilleryProjectile)
package {
import flash.display.*;
public dynamic class artilleryProjectile extends MovieClip {
}
}//package
Section 49
//artilleryTower (artilleryTower)
package {
import flash.display.*;
public dynamic class artilleryTower extends MovieClip {
public var promotion3:MovieClip;
public var standardTop:MovieClip;
public var goldenTop:MovieClip;
public var promotion:MovieClip;
public var promotion2:MovieClip;
public var promotion4:MovieClip;
public var promotion5:MovieClip;
public var turret:MovieClip;
}
}//package
Section 50
//barbarian (barbarian)
package {
import flash.display.*;
public dynamic class barbarian extends MovieClip {
}
}//package
Section 51
//bullet (bullet)
package {
import flash.display.*;
public dynamic class bullet extends MovieClip {
}
}//package
Section 52
//cadillac (cadillac)
package {
import flash.display.*;
public dynamic class cadillac extends MovieClip {
}
}//package
Section 53
//Cannon (Cannon)
package {
import flash.display.*;
public dynamic class Cannon extends MovieClip {
}
}//package
Section 54
//cavalry (cavalry)
package {
import flash.display.*;
public dynamic class cavalry extends MovieClip {
}
}//package
Section 55
//commandos (commandos)
package {
import flash.display.*;
public dynamic class commandos extends MovieClip {
}
}//package
Section 56
//Creep (Creep)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class Creep extends MovieClip {
public var currentY:Number;
public var healthBar:MovieClip;
public var iLeftToRight:Boolean;
public var rt;
public var isSlowed:Number;
public var health:Number;
public var isBurned:Number;
public var canFly:Boolean;
public var routeInitialised:Boolean;
public var immune:Boolean;
public var sleepTimer:Number;
public var xSpeed:Number;
public var startEndingLife:Boolean;
public var currentCountIn:Number;
public var maxHealth:Number;
public var targetX:Number;
public var targetY:Number;
public var creepValue:Number;
public var isPoisoned:Number;
public var isBird:Boolean;
public var endLifeTimer:Number;
public var FLYCOUNTINTIMER;
public var ySpeed:Number;
public var iCheckRoute:Boolean;
public var activeSprite:MovieClip;
public var iSpeed:Number;
public var iRoute:Array;
public var isCornering:Number;
public var creepUID:Number;
public var spriteType:Number;
public var hasRoute:Boolean;
public var initCreep:Boolean;
public var currentX:Number;
public function Creep(){
addFrameScript(0, frame1);
}
public function causeSlow(_arg1){
if (!immune){
isSlowed = (isSlowed + _arg1);
};
}
public function selfClean(){
sleepTimer = NaN;
iRoute = null;
rt = null;
this.removeChild(activeSprite);
activeSprite = null;
}
public function doMovement(){
if (!initCreep){
doInitCreep();
};
if (canFly == false){
if (sleepTimer == 0){
if (((iCheckRoute) && (!(startEndingLife)))){
hasRoute = routeStillValid();
routeInitialised = hasRoute;
iCheckRoute = false;
};
if (!hasRoute){
setCurrentXY();
if (!routeInitialised){
acquireRoute();
};
} else {
if (activeSprite != null){
followRoute();
};
};
} else {
sleepTimer--;
};
} else {
if (sleepTimer > 0){
sleepTimer--;
} else {
doFlying();
};
};
}
function frame1(){
iRoute = new Array();
routeInitialised = false;
iCheckRoute = false;
endLifeTimer = 20;
startEndingLife = false;
hasRoute = false;
xSpeed = 0;
ySpeed = 0;
FLYCOUNTINTIMER = (Math.random() * 50);
currentCountIn = 0;
isPoisoned = 0;
isBurned = 0;
isSlowed = 0;
isCornering = 0;
initCreep = false;
}
public function routeStillValid():Boolean{
var _local1:*;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
if (iRoute == null){
return (false);
};
_local1 = iRoute.length;
if (_local1 == 0){
return (false);
};
iCheckRoute = false;
_local2 = 0;
while (_local2 < _local1) {
if (!rt.walkable[iRoute[_local2].nodeX][iRoute[_local2].nodeY]){
return (false);
};
if (_local2 < (_local1 - 2)){
_local3 = iRoute[(_local2 + 1)].nodeX;
_local4 = iRoute[(_local2 + 1)].nodeY;
_local5 = iRoute[_local2].nodeX;
_local6 = iRoute[_local2].nodeY;
if (((!(rt.walkable[_local5][_local4])) && (!(rt.walkable[_local3][_local6])))){
return (false);
};
};
_local2++;
};
return (true);
}
public function xPositionIn(_arg1){
return ((this.x + (xSpeed * _arg1)));
}
public function doFlying(){
var _local1:Number;
var _local2:*;
var _local3:*;
var _local4:*;
if (activeSprite == null){
return (false);
};
if (currentCountIn < FLYCOUNTINTIMER){
currentCountIn++;
if (iLeftToRight){
_local1 = 90;
} else {
_local1 = 180;
};
activeSprite.rotation = _local1;
} else {
_local2 = ((targetY * rt.squareHeight) + rt.gridStartY);
_local3 = ((targetX * rt.squareWidth) + rt.gridStartX);
currentX = Math.round(((this.x - rt.gridStartX) / rt.squareWidth));
currentY = Math.round(((this.y - rt.gridStartY) / rt.squareHeight));
_local1 = (rt.calcAngle2D(this.x, this.y, _local3, _local2) + 90);
_local4 = (((_local1 - activeSprite.rotation) + 360) % 360);
if (_local1 < 0){
_local1 = (_local1 + 360);
};
if ((((_local4 > 3)) && ((_local4 < 357)))){
if ((((_local4 < 180)) && ((_local4 > 0)))){
activeSprite.rotation = (activeSprite.rotation + 2);
} else {
activeSprite.rotation = (activeSprite.rotation - 2);
};
} else {
activeSprite.rotation = _local1;
};
if (activeSprite.rotation < 0){
activeSprite.rotation = (activeSprite.rotation + 360);
};
};
xSpeed = (rt.calcXSpeed(activeSprite.rotation) * iSpeed);
ySpeed = (rt.calcYSpeed(activeSprite.rotation) * iSpeed);
this.x = (this.x + xSpeed);
this.y = (this.y + ySpeed);
setCurrentXY();
if ((((currentX == targetX)) && ((currentY == targetY)))){
rt.takeLife(this.x, this.y);
iRoute = null;
this.visible = false;
};
}
public function doBurn(_arg1){
if (!immune){
trace(("im getting burnt " + _arg1));
isBurned = (isBurned + _arg1);
};
}
public function acquireRoute():void{
var _local1:Number;
var _local2:*;
var _local3:Number;
var _local4:*;
if (rt == null){
rt = this.parent;
};
if (iRoute != null){
iRoute.splice(0, iRoute.length);
};
iRoute = null;
iRoute = new Array();
currentX = Math.round(((this.x - rt.gridStartX) / rt.squareWidth));
currentY = Math.round(((this.y - rt.gridStartY) / rt.squareHeight));
if (currentX < 0){
currentX = 0;
};
if (currentY < 0){
currentY = 0;
};
if (iLeftToRight){
if (!rt.routeCache[currentX][currentY].iInit){
if (currentX < 1){
currentX = 0;
};
if (currentY < 1){
currentY = 0;
};
trace("acquiring route because route cache not init");
rt.doAStarQuick(currentX, currentY, targetX, targetY, iLeftToRight);
} else {
if (rt.routeCache[currentX][currentY].iNeedCheck){
if (!rt.still_valid(currentX, currentY)){
trace("route was no longer valid");
if (currentX < 1){
currentX = 0;
};
if (currentY < 1){
currentY = 0;
};
rt.doAStarQuick(currentX, currentY, targetX, targetY, iLeftToRight);
} else {
trace("route here was still valid");
};
};
};
if (rt.routeCache[currentX][currentY].iRoute.length > 0){
_local1 = rt.routeCache[currentX][currentY].iRoute.length;
_local2 = 0;
while (_local2 < _local1) {
iRoute.push(rt.routeCache[currentX][currentY].iRoute[_local2]);
_local2++;
};
hasRoute = true;
};
} else {
if (!rt.routeCache1[currentX][currentY].iInit){
if (currentX < 1){
currentX = 0;
};
if (currentY < 1){
currentY = 0;
};
rt.doAStarQuick(currentX, currentY, targetX, targetY, iLeftToRight);
} else {
if (rt.routeCache1[currentX][currentY].iNeedCheck){
if (!rt.still_valid1(currentX, currentY)){
if (currentX < 1){
currentX = 0;
};
if (currentY < 1){
currentY = 0;
};
rt.doAStarQuick(currentX, currentY, targetX, targetY, iLeftToRight);
};
};
};
if (rt.routeCache1[currentX][currentY].iRoute.length > 0){
_local3 = rt.routeCache1[currentX][currentY].iRoute.length;
_local4 = 0;
while (_local4 < _local3) {
iRoute.push(rt.routeCache1[currentX][currentY].iRoute[_local4]);
_local4++;
};
hasRoute = true;
};
};
}
public function followRoute(){
var _local1:*;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:Number;
var _local6:*;
var _local7:*;
if (startEndingLife){
endLifeTimer--;
this.x = (this.x + xSpeed);
this.y = (this.y + ySpeed);
if (endLifeTimer == 0){
rt.takeLife(this.x, this.y);
iRoute = null;
this.visible = false;
return;
};
return;
};
if (iRoute == null){
return (false);
};
currentX = Math.round(((this.x - rt.gridStartX) / rt.squareWidth));
currentY = Math.round(((this.y - rt.gridStartY) / rt.squareHeight));
if (currentX < 0){
currentX = 0;
};
if (currentY < 0){
currentY = 0;
};
if (!immune){
if (isPoisoned > 0){
isPoisoned--;
takeHealth(1);
if ((((activeSprite == null)) || ((this.visible == false)))){
return;
};
};
};
if (!immune){
if (isBurned > 0){
takeHealth(1);
isBurned--;
if ((((activeSprite == null)) || ((this.visible == false)))){
return;
};
};
};
if (activeSprite == null){
this.visible = false;
return;
};
_local1 = ((iRoute[0].nodeY * rt.squareHeight) + rt.gridStartY);
_local2 = ((iRoute[0].nodeX * rt.squareWidth) + rt.gridStartX);
_local3 = (rt.calcAngle2D(this.x, this.y, _local2, _local1) + 90);
_local4 = (((_local3 - activeSprite.rotation) + 360) % 360);
while (_local3 < 0) {
_local3 = (_local3 + 360);
};
if ((((_local4 > 50)) && ((_local4 < 310)))){
if ((((_local4 < 180)) && ((_local4 > 0)))){
activeSprite.rotation = (activeSprite.rotation + 20);
} else {
activeSprite.rotation = (activeSprite.rotation - 20);
};
isCornering++;
} else {
activeSprite.rotation = _local3;
};
_local5 = Math.round(this.activeSprite.rotation);
while (_local5 < 0) {
_local5 = (_local5 + 360);
};
while (_local5 > 360) {
_local5 = (_local5 - 360);
};
if (isSlowed > 0){
xSpeed = (rt.sine[_local5] * iSpeed);
ySpeed = (rt.cosine[_local5] * iSpeed);
if (isSlowed > 0){
xSpeed = (xSpeed / 2);
ySpeed = (ySpeed / 2);
};
isSlowed--;
} else {
xSpeed = (rt.sine[_local5] * iSpeed);
ySpeed = (rt.cosine[_local5] * iSpeed);
};
if (isCornering > 0){
xSpeed = (xSpeed / 1.5);
ySpeed = (ySpeed / 1.5);
if (isSlowed > 0){
xSpeed = (xSpeed / 2);
ySpeed = (ySpeed / 2);
};
isSlowed--;
isCornering--;
};
this.x = (this.x + xSpeed);
this.y = (this.y + ySpeed);
currentX = Math.round(((this.x - rt.gridStartX) / rt.squareWidth));
currentY = Math.round(((this.y - rt.gridStartY) / rt.squareHeight));
if (currentX < 0){
currentX = 0;
};
if (currentY < 0){
currentY = 0;
};
_local6 = (this.x - _local2);
_local7 = (this.y - _local1);
if (_local6 < 0){
_local6 = (_local6 * -1);
};
if (_local7 < 0){
_local7 = (_local7 * -1);
};
if (iRoute != null){
if (iRoute[0] == undefined){
startEndingLife = true;
};
};
if ((((_local6 < 15)) && ((_local7 < 15)))){
if ((((currentX == iRoute[0].nodeX)) && ((currentY == iRoute[0].nodeY)))){
delete iRoute[0];
iRoute.splice(0, 1);
};
if (iRoute.length == 0){
startEndingLife = true;
};
};
}
public function yPositionIn(_arg1){
return ((this.y + (ySpeed * _arg1)));
}
public function doInitCreep(){
initCreep = true;
switch (spriteType){
case 0:
activeSprite = (this.addChild(new barbarian()) as MovieClip);
break;
case 1:
activeSprite = (this.addChild(new Peasant()) as MovieClip);
break;
case 2:
activeSprite = (this.addChild(new Hunter()) as MovieClip);
break;
case 3:
activeSprite = (this.addChild(new WitchDoctor()) as MovieClip);
break;
case 4:
activeSprite = (this.addChild(new Pigeon()) as MovieClip);
break;
case 5:
activeSprite = (this.addChild(new ram()) as MovieClip);
break;
case 6:
activeSprite = (this.addChild(new Legionnaire()) as MovieClip);
break;
case 7:
activeSprite = (this.addChild(new Serf()) as MovieClip);
break;
case 8:
activeSprite = (this.addChild(new Knights()) as MovieClip);
break;
case 9:
activeSprite = (this.addChild(new Praetorian()) as MovieClip);
break;
case 10:
activeSprite = (this.addChild(new Hawk()) as MovieClip);
break;
case 11:
activeSprite = (this.addChild(new ram()) as MovieClip);
break;
case 12:
activeSprite = (this.addChild(new redCoat()) as MovieClip);
break;
case 13:
activeSprite = (this.addChild(new Rioter()) as MovieClip);
break;
case 14:
activeSprite = (this.addChild(new cavalry()) as MovieClip);
break;
case 15:
activeSprite = (this.addChild(new napoleonsGaurd()) as MovieClip);
break;
case 16:
activeSprite = (this.addChild(new wrightbros()) as MovieClip);
break;
case 17:
activeSprite = (this.addChild(new Cannon()) as MovieClip);
break;
case 18:
activeSprite = (this.addChild(new infantry()) as MovieClip);
break;
case 19:
activeSprite = (this.addChild(new trenchman()) as MovieClip);
break;
case 20:
activeSprite = (this.addChild(new cadillac()) as MovieClip);
break;
case 21:
activeSprite = (this.addChild(new sniper()) as MovieClip);
break;
case 22:
activeSprite = (this.addChild(new redBaron()) as MovieClip);
break;
case 23:
activeSprite = (this.addChild(new tank()) as MovieClip);
break;
case 24:
activeSprite = (this.addChild(new paratrooper()) as MovieClip);
break;
case 25:
activeSprite = (this.addChild(new redArmy()) as MovieClip);
break;
case 26:
activeSprite = (this.addChild(new jeep()) as MovieClip);
break;
case 27:
activeSprite = (this.addChild(new commandos()) as MovieClip);
break;
case 28:
activeSprite = (this.addChild(new spitfire()) as MovieClip);
break;
case 29:
activeSprite = (this.addChild(new tank2()) as MovieClip);
break;
case 30:
activeSprite = (this.addChild(new marine()) as MovieClip);
break;
case 31:
activeSprite = (this.addChild(new protestors()) as MovieClip);
break;
case 32:
activeSprite = (this.addChild(new humvee()) as MovieClip);
break;
case 33:
activeSprite = (this.addChild(new sas()) as MovieClip);
break;
case 34:
activeSprite = (this.addChild(new eurofighter()) as MovieClip);
break;
case 35:
activeSprite = (this.addChild(new tank3()) as MovieClip);
break;
};
}
public function makePoisoned(_arg1){
if (immune == false){
isPoisoned = (isPoisoned + _arg1);
};
}
public function takeHealth(_arg1){
health = (health - _arg1);
healthBar.width = (((health / maxHealth) * 100) / 4);
if (health <= 0){
this.visible = false;
iRoute = null;
rt.addFunds(this.x, this.y, creepValue, isBird);
};
}
public function setCurrentXY():void{
currentX = Math.round(((this.x - rt.gridStartX) / rt.squareWidth));
currentY = Math.round(((this.y - rt.gridStartY) / rt.squareHeight));
if (currentX < 0){
currentX = 0;
};
if (currentY < 0){
currentY = 0;
};
}
}
}//package
Section 57
//eurofighter (eurofighter)
package {
import flash.display.*;
public dynamic class eurofighter extends MovieClip {
}
}//package
Section 58
//fastTower (fastTower)
package {
import flash.display.*;
public dynamic class fastTower extends MovieClip {
public var promotion3:MovieClip;
public var standardTop:MovieClip;
public var goldenTop:MovieClip;
public var promotion:MovieClip;
public var promotion2:MovieClip;
public var promotion4:MovieClip;
public var promotion5:MovieClip;
public var turret:MovieClip;
}
}//package
Section 59
//fireTurret (fireTurret)
package {
import flash.display.*;
public dynamic class fireTurret extends MovieClip {
public var promotion3:MovieClip;
public var standardTop:MovieClip;
public var goldenTop:MovieClip;
public var promotion:MovieClip;
public var promotion2:MovieClip;
public var promotion4:MovieClip;
public var promotion5:MovieClip;
public var turret:MovieClip;
}
}//package
Section 60
//focusRectSkin (focusRectSkin)
package {
import flash.display.*;
public dynamic class focusRectSkin extends MovieClip {
}
}//package
Section 61
//frostTower (frostTower)
package {
import flash.display.*;
public dynamic class frostTower extends MovieClip {
public var promotion3:MovieClip;
public var standardTop:MovieClip;
public var goldenTop:MovieClip;
public var promotion:MovieClip;
public var promotion2:MovieClip;
public var promotion4:MovieClip;
public var promotion5:MovieClip;
public var turret:MovieClip;
}
}//package
Section 62
//Hawk (Hawk)
package {
import flash.display.*;
public dynamic class Hawk extends MovieClip {
}
}//package
Section 63
//humvee (humvee)
package {
import flash.display.*;
public dynamic class humvee extends MovieClip {
}
}//package
Section 64
//Hunter (Hunter)
package {
import flash.display.*;
public dynamic class Hunter extends MovieClip {
}
}//package
Section 65
//infantry (infantry)
package {
import flash.display.*;
public dynamic class infantry extends MovieClip {
}
}//package
Section 66
//interfaceLayer (interfaceLayer)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class interfaceLayer extends MovieClip {
public var tickerLabel:TextField;
public var artilleryButton:SimpleButton;
public var currentLevelLabel:TextField;
public var rt:MovieClip;
public var publisher_link:String;
public var lightningTower:SimpleButton;
public var poisonButton:SimpleButton;
public var upgradeButton:MovieClip;
public var i;
public var towerCost:TextField;
public var antiAir:SimpleButton;
public var powerTowerBtn:SimpleButton;
public var spaceToRelase:MovieClip;
public var livesText:TextField;
public var towerCostUpg:TextField;
public var towerRangeUpg:TextField;
public var scoreText:TextField;
public var fistTower:SimpleButton;
public var fireButton:SimpleButton;
public var nextLevelLabel:TextField;
public var frostButton:SimpleButton;
public var sellButton:MovieClip;
public var towerName:TextField;
public var towerInfo:TextField;
public var publisher_image:String;
public var publisherClip:MovieClip;
public var mouseBut:MovieClip;
public var towerRange:TextField;
public var towerReloadUpg:TextField;
public var towerDamage:TextField;
public var dukelogo:SimpleButton;
public var userCashText:TextField;
public function interfaceLayer(){
addFrameScript(0, frame1);
}
public function upgradeButtonOut(_arg1:MouseEvent):void{
upgradeButton.gotoAndStop(1);
}
public function frostButtonClick(_arg1:MouseEvent):void{
rt.brushSelected = 6;
rt.displayTowerInfo(rt.brushSelected, -1);
}
public function sellButtonOver(_arg1:MouseEvent):void{
sellButton.gotoAndStop(2);
}
public function artilleryButtonClick(_arg1:MouseEvent):void{
rt.brushSelected = 3;
rt.displayTowerInfo(rt.brushSelected, -1);
}
public function upgradeButtonOver(_arg1:MouseEvent):void{
upgradeButton.gotoAndStop(2);
}
public function lightningTowerClick(_arg1:MouseEvent):void{
rt.brushSelected = 1;
rt.displayTowerInfo(rt.brushSelected, -1);
}
function frame1(){
sellButton.addEventListener(MouseEvent.MOUSE_OUT, sellButtonOut);
sellButton.addEventListener(MouseEvent.MOUSE_OVER, sellButtonOver);
sellButton.addEventListener(MouseEvent.CLICK, sellButtonClick);
upgradeButton.addEventListener(MouseEvent.MOUSE_OUT, upgradeButtonOut);
upgradeButton.addEventListener(MouseEvent.MOUSE_OVER, upgradeButtonOver);
upgradeButton.addEventListener(MouseEvent.CLICK, upgradeButtonClick);
dukelogo.addEventListener(MouseEvent.CLICK, dukelogoclick);
lightningTower.addEventListener(MouseEvent.CLICK, lightningTowerClick);
fistTower.addEventListener(MouseEvent.CLICK, fistTowerClick);
antiAir.addEventListener(MouseEvent.CLICK, antiAirClick);
frostButton.addEventListener(MouseEvent.CLICK, frostButtonClick);
fireButton.addEventListener(MouseEvent.CLICK, fireButtonClick);
poisonButton.addEventListener(MouseEvent.CLICK, poisonButtonClick);
artilleryButton.addEventListener(MouseEvent.CLICK, artilleryButtonClick);
powerTowerBtn.addEventListener(MouseEvent.CLICK, powerTowerBtnClick);
mouseBut.addEventListener(MouseEvent.CLICK, mouseButClick);
publisher_image = this.loaderInfo.parameters.publisherimage;
publisher_link = this.loaderInfo.parameters.publisherlink;
if (publisher_image != null){
i = new Loader();
i.load(new URLRequest(publisher_image));
publisherClip.addChild(i);
publisherClip.addEventListener(MouseEvent.CLICK, publisherClipClick);
};
if (rt.mochimode == 1){
dukelogo.visible = true;
} else {
dukelogo.visible = false;
};
}
public function sellButtonClick(_arg1:MouseEvent):void{
if (rt.selectedTower >= 0){
rt.sellSelected();
} else {
trace("no tower selected");
};
}
public function mouseButClick(_arg1:MouseEvent):void{
var _local2:*;
var _local3:*;
if (mouseBut.visible){
_local2 = rt.towerList.length;
_local3 = 0;
while (_local3 < _local2) {
if (mouseBut.hitTestObject(rt.towerList[_local3])){
rt.selectedTower = _local3;
rt.displayTowerInfo(0, _local3);
return;
};
_local3++;
};
if (((rt.canBuild()) && (!(rt.wouldBlock(mouseBut.x, mouseBut.y))))){
rt.buildTower(mouseBut.x, mouseBut.y);
};
};
}
public function poisonButtonClick(_arg1:MouseEvent):void{
rt.brushSelected = 7;
rt.displayTowerInfo(rt.brushSelected, -1);
}
public function handleMouse(){
var _local1:*;
var _local2:*;
_local1 = Math.round((((rt.aBackground.mouseX - rt.gridStartX) - 10) / rt.squareWidth));
_local2 = Math.round((((rt.aBackground.mouseY - rt.gridStartY) - 10) / rt.squareHeight));
if ((((((((_local1 > 1)) && ((_local2 > 1)))) && ((_local1 < (rt.gridWidth - 3))))) && ((_local2 < (rt.gridHeight - 3))))){
mouseBut.x = (rt.gridStartX + (_local1 * rt.squareWidth));
mouseBut.y = (rt.gridStartY + (_local2 * rt.squareHeight));
mouseBut.visible = true;
} else {
mouseBut.visible = false;
};
}
public function dukelogoclick(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.dukesbox.com"), "");
}
public function fireButtonClick(_arg1:MouseEvent):void{
rt.brushSelected = 5;
rt.displayTowerInfo(rt.brushSelected, -1);
}
public function publisherClipClick(_arg1:MouseEvent){
navigateToURL(new URLRequest(publisher_link));
}
public function fistTowerClick(_arg1:MouseEvent):void{
rt.brushSelected = 4;
rt.displayTowerInfo(rt.brushSelected, -1);
}
public function sellButtonOut(_arg1:MouseEvent):void{
sellButton.gotoAndStop(1);
}
public function upgradeButtonClick(_arg1:MouseEvent):void{
if (rt.selectedTower >= 0){
rt.upgradeSelected();
} else {
trace("no tower selected");
};
}
public function powerTowerBtnClick(_arg1:MouseEvent):void{
rt.brushSelected = 8;
rt.displayTowerInfo(rt.brushSelected, -1);
}
public function antiAirClick(_arg1:MouseEvent):void{
rt.brushSelected = 2;
rt.displayTowerInfo(rt.brushSelected, -1);
}
}
}//package
Section 67
//jeep (jeep)
package {
import flash.display.*;
public dynamic class jeep extends MovieClip {
}
}//package
Section 68
//Knights (Knights)
package {
import flash.display.*;
public dynamic class Knights extends MovieClip {
}
}//package
Section 69
//layer (layer)
package {
import flash.display.*;
public dynamic class layer extends MovieClip {
}
}//package
Section 70
//Legionnaire (Legionnaire)
package {
import flash.display.*;
public dynamic class Legionnaire extends MovieClip {
}
}//package
Section 71
//marine (marine)
package {
import flash.display.*;
public dynamic class marine extends MovieClip {
}
}//package
Section 72
//metalScreen (metalScreen)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class metalScreen extends MovieClip {
public var easyBtn:MovieClip;
public var tutorialBtn:MovieClip;
public var hardBtn:MovieClip;
public var rt:MovieClip;
public var metalSheet:MovieClip;
public var mediumBtn:MovieClip;
public function metalScreen(){
addFrameScript(0, frame1, 1, frame2, 52, frame53);
}
public function tutorialBtnOver(_arg1:MouseEvent):void{
tutorialBtn.gotoAndStop(2);
}
public function mediumBtnOver(_arg1:MouseEvent):void{
mediumBtn.gotoAndStop(2);
}
public function tutorialBtnClick(_arg1:MouseEvent):void{
metalSheet.visible = false;
rt.doTutorial();
}
public function hardBtnOut(_arg1:MouseEvent):void{
hardBtn.gotoAndStop(1);
}
public function mediumBtnOut(_arg1:MouseEvent):void{
mediumBtn.gotoAndStop(1);
}
public function mediumBtnClick(_arg1:MouseEvent):void{
rt.difficultyLevel = 2;
gotoAndPlay(2);
}
public function easyBtnOut(_arg1:MouseEvent):void{
easyBtn.gotoAndStop(1);
}
public function tutorialBtnOut(_arg1:MouseEvent):void{
tutorialBtn.gotoAndStop(1);
}
function frame1(){
stop();
tutorialBtn.texts.text = "TUTORIAL";
easyBtn.texts.text = "EASY";
mediumBtn.texts.text = "NORMAL";
hardBtn.texts.text = "HARD";
tutorialBtn.addEventListener(MouseEvent.MOUSE_OUT, tutorialBtnOut);
tutorialBtn.addEventListener(MouseEvent.MOUSE_OVER, tutorialBtnOver);
tutorialBtn.addEventListener(MouseEvent.CLICK, tutorialBtnClick);
easyBtn.addEventListener(MouseEvent.MOUSE_OUT, easyBtnOut);
easyBtn.addEventListener(MouseEvent.MOUSE_OVER, easyBtnOver);
easyBtn.addEventListener(MouseEvent.CLICK, easyBtnClick);
mediumBtn.addEventListener(MouseEvent.MOUSE_OUT, mediumBtnOut);
mediumBtn.addEventListener(MouseEvent.MOUSE_OVER, mediumBtnOver);
mediumBtn.addEventListener(MouseEvent.CLICK, mediumBtnClick);
hardBtn.addEventListener(MouseEvent.MOUSE_OUT, hardBtnOut);
hardBtn.addEventListener(MouseEvent.MOUSE_OVER, hardBtnOver);
hardBtn.addEventListener(MouseEvent.CLICK, hardBtnClick);
if (rt.sandboxmode == 0){
hardBtn.visible = false;
mediumBtn.visible = true;
easyBtn.visible = false;
tutorialBtn.visible = true;
mediumBtn.texts.text = "START";
tutorialBtn.x = 165;
};
}
function frame2(){
rt.start_game();
}
public function hardBtnClick(_arg1:MouseEvent):void{
rt.difficultyLevel = 3;
gotoAndPlay(2);
}
public function easyBtnClick(_arg1:MouseEvent):void{
rt.difficultyLevel = 1;
gotoAndPlay(2);
}
function frame53(){
stop();
rt.removeStartScreen();
}
public function hardBtnOver(_arg1:MouseEvent):void{
hardBtn.gotoAndStop(2);
}
public function easyBtnOver(_arg1:MouseEvent):void{
easyBtn.gotoAndStop(2);
}
}
}//package
Section 73
//metalScreenEnd (metalScreenEnd)
package {
import fl.controls.*;
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class metalScreenEnd extends MovieClip {
public var redirectValue:int;
public var redirectText:TextField;
public var submitBtn:MovieClip;
public var clicked:Boolean;
public var playernameinput:TextInput;
public var rt:MovieClip;
public var score:int;
public var nameSave:TextField;
public var text2:TextField;
public var text1:TextField;
public var restartBtn:MovieClip;
public var finalPosition:TextField;
public var finalScore:TextField;
public var leaderboardPosition:int;
public function metalScreenEnd(){
addFrameScript(0, frame1, 51, frame52, 104, frame105);
}
public function submitBtnOver(_arg1:MouseEvent):void{
submitBtn.gotoAndStop(2);
}
public function restartBtnOver(_arg1:MouseEvent):void{
restartBtn.gotoAndStop(2);
}
function frame105(){
gotoAndStop(52);
}
function frame1(){
this.addEventListener(MouseEvent.CLICK, onMouseClickEvent);
clicked = false;
text1.visible = false;
text2.visible = false;
finalScore.visible = false;
redirectValue = 10;
rt.doGetPosition();
rt.doEndGame();
}
public function restartBtnOut(_arg1:MouseEvent):void{
restartBtn.gotoAndStop(1);
}
public function submitBtnOut(_arg1:MouseEvent):void{
submitBtn.gotoAndStop(1);
}
public function onMouseClickEvent(_arg1:Event):void{
if (!clicked){
clicked = true;
};
}
public function restartBtnClick(_arg1:MouseEvent):void{
if (rt.sandboxmode == 0){
rt.goToEndGameTarget();
} else {
if (rt.mochimode == 0){
navigateToURL(new URLRequest("http://www.dukesbox.com/game.php?id=18&sandboxmode=1"), "");
} else {
rt.justShowLeaderboard();
};
};
}
function frame52(){
finalScore.visible = true;
finalScore.text = ("Your final score was " + score);
finalPosition.text = ("Your final place in the all time leaderboard is position: " + leaderboardPosition);
submitBtn.texts.text = "Submit";
submitBtn.addEventListener(MouseEvent.MOUSE_OUT, submitBtnOut);
submitBtn.addEventListener(MouseEvent.MOUSE_OVER, submitBtnOver);
submitBtn.addEventListener(MouseEvent.CLICK, submitBtnClick);
if (rt.player_name == null){
playernameinput.visible = true;
submitBtn.visible = true;
nameSave.visible = true;
} else {
playernameinput.visible = false;
submitBtn.visible = false;
nameSave.visible = false;
if (redirectValue == 10){
rt.doPostFreeScore();
};
};
restartBtn.texts.text = "END GAME";
restartBtn.addEventListener(MouseEvent.MOUSE_OUT, restartBtnOut);
restartBtn.addEventListener(MouseEvent.MOUSE_OVER, restartBtnOver);
restartBtn.addEventListener(MouseEvent.CLICK, restartBtnClick);
redirectText.visible = false;
if (rt.sandboxmode == 0){
restartBtn.visible = true;
playernameinput.visible = false;
restartBtn.texts.text = "END GAME";
submitBtn.visible = false;
nameSave.visible = false;
redirectText.visible = true;
redirectText.text = ("Your game will redirect in: " + redirectValue);
if (redirectValue > 0){
redirectValue--;
gotoAndPlay(54);
} else {
rt.goToEndGameTarget();
};
};
if (rt.player_name != undefined){
playernameinput.visible = false;
submitBtn.visible = false;
};
stop();
}
public function submitBtnClick(_arg1:MouseEvent):void{
rt.player_name = playernameinput.text;
rt.doPostFreeScore();
playernameinput.visible = false;
submitBtn.visible = false;
nameSave.visible = false;
}
}
}//package
Section 74
//missileTower (missileTower)
package {
import flash.display.*;
public dynamic class missileTower extends MovieClip {
public var promotion3:MovieClip;
public var standardTop:MovieClip;
public var goldenTop:MovieClip;
public var promotion:MovieClip;
public var promotion2:MovieClip;
public var promotion4:MovieClip;
public var promotion5:MovieClip;
public var turret:MovieClip;
}
}//package
Section 75
//MochiAd (MochiAd)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiAd {
public static function getVersion():String{
return ("2.5");
}
public static function showClickAwayAd(_arg1:Object):void{
var DEFAULTS:Object;
var clip:Object;
var ad_timeout:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var sendHostProgress:Boolean;
var options = _arg1;
DEFAULTS = {ad_timeout:2000, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function ():void{
}, ad_finished:function ():void{
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
sendHostProgress = false;
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Number;
var _local3:Boolean;
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
return;
};
_local1 = this.parent._mochiad_ctr;
_local2 = (getTimer() - this.started);
_local3 = false;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
_local3 = true;
chk.started = getTimer();
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (this.root == null){
_local3 = true;
};
if (_local3){
delete this.onEnterFrame;
};
};
doOnEnterFrame(chk);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _allowDomains(_arg1:String):String{
var _local2:String;
_local2 = _arg1.split("/")[2].split(":")[0];
Security.allowDomain("*");
Security.allowDomain(_local2);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(_local2);
return (_local2);
}
public static function unload(_arg1:Object):Boolean{
if (((_arg1.clip) && (_arg1.clip._mochiad))){
_arg1 = _arg1.clip;
};
if (_arg1.origFrameRate != undefined){
_arg1.stage.frameRate = _arg1.origFrameRate;
};
if (!_arg1._mochiad){
return (false);
};
if (_arg1._mochiad._containerLCName != undefined){
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "notify", {id:"unload"});
};
if (_arg1._mochiad.onUnload){
_arg1._mochiad.onUnload();
};
delete _arg1._mochiad_loaded;
delete _arg1._mochiad;
return (true);
}
public static function showInterLevelAd(_arg1:Object):void{
var DEFAULTS:Object;
var clip:Object;
var ad_msec:Number;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var options = _arg1;
DEFAULTS = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
_local1 = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object;
_local2 = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = (_arg1 - 250);
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Number;
var _local3:Boolean;
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
_local1 = this.parent._mochiad_ctr;
_local2 = (getTimer() - this.started);
_local3 = false;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (_local2 > chk.ad_msec){
_local3 = true;
};
if (_local3){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _parseOptions(_arg1:Object, _arg2:Object):Object{
var _local3:Object;
var _local4:String;
var _local5:Array;
var _local6:Number;
var _local7:Array;
_local3 = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
if (_arg1){
for (_local4 in _arg1) {
_local3[_local4] = _arg1[_local4];
};
};
if (_local3.clip == undefined){
throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
};
_arg1 = _local3.clip.loaderInfo.parameters.mochiad_options;
if (_arg1){
_local5 = _arg1.split("&");
_local6 = 0;
while (_local6 < _local5.length) {
_local7 = _local5[_local6].split("=");
_local3[unescape(_local7[0])] = unescape(_local7[1]);
_local6++;
};
};
if (_local3.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (_local3);
}
public static function _cleanup(_arg1:Object):void{
var idx:Number;
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = _arg1;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
try {
lc.client = null;
lc.close();
} catch(e:Error) {
};
};
setTimeout(f, 0);
};
idx = DisplayObjectContainer(mc).numChildren;
while (idx > 0) {
idx = (idx - 1);
DisplayObjectContainer(mc).removeChildAt(idx);
};
for (k in mc) {
delete mc[k];
};
}
public static function load(_arg1:Object):MovieClip{
var DEFAULTS:Object;
var clip:Object;
var depth:Number;
var mc:MovieClip;
var wh:Array;
var lv:URLVariables;
var k:String;
var server:String;
var hostname:String;
var lc:LocalConnection;
var name:String;
var loader:Loader;
var g:Function;
var req:URLRequest;
var v:Object;
var options = _arg1;
DEFAULTS = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!MochiAd._isNetworkAvailable()){
return (null);
};
try {
if (clip._mochiad_loaded){
return (null);
};
} catch(e:Error) {
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
depth = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, "_mochiad", depth);
wh = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
};
lv = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
mc.lcName = name;
lv.lc = name;
lv.st = getTimer();
loader = new Loader();
g = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest((server + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.load(req);
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function runMethod(_arg1:Object, _arg2:String, _arg3:Array):Object{
var _local4:Array;
var _local5:Number;
_local4 = _arg2.split(".");
_local5 = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
if (typeof(_arg1[_local4[_local5]]) == "function"){
return (_arg1[_local4[_local5]].apply(_arg1, _arg3));
};
return (undefined);
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number):MovieClip{
var _local4:MovieClip;
_local4 = new MovieClip();
if (((false) && (_arg3))){
_arg1.addChildAt(_local4, _arg3);
} else {
_arg1.addChild(_local4);
};
_arg1[_arg2] = _local4;
_local4["_name"] = _arg2;
return (_local4);
}
public static function _getRes(_arg1:Object, _arg2:Object):Array{
var _local3:Object;
var _local4:Number;
var _local5:Number;
var _local6:Array;
_local3 = _arg2.getBounds(_arg2.root);
_local4 = 0;
_local5 = 0;
if (typeof(_arg1.res) != "undefined"){
_local6 = _arg1.res.split("x");
_local4 = parseFloat(_local6[0]);
_local5 = parseFloat(_local6[1]);
} else {
_local4 = (_local3.xMax - _local3.xMin);
_local5 = (_local3.yMax - _local3.yMin);
};
if ((((_local4 == 0)) || ((_local5 == 0)))){
_local4 = _arg2.stage.stageWidth;
_local5 = _arg2.stage.stageHeight;
};
return ([_local4, _local5]);
}
public static function adShowing(_arg1:Object):void{
_arg1.origFrameRate = _arg1.stage.frameRate;
_arg1.stage.frameRate = 30;
}
public static function getValue(_arg1:Object, _arg2:String):Object{
var _local3:Array;
var _local4:Number;
_local3 = _arg2.split(".");
_local4 = 0;
while (_local4 < (_local3.length - 1)) {
if ((((_arg1[_local3[_local4]] == undefined)) || ((_arg1[_local3[_local4]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local3[_local4]];
_local4++;
};
return (_arg1[_local3[_local4]]);
}
public static function rpc(_arg1:Object, _arg2:Number, _arg3:Object):void{
var _local4:Object;
var _local5:Object;
switch (_arg3.id){
case "setValue":
MochiAd.setValue(_arg1, _arg3.objectName, _arg3.value);
break;
case "getValue":
_local4 = MochiAd.getValue(_arg1, _arg3.objectName);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local4);
break;
case "runMethod":
_local5 = MochiAd.runMethod(_arg1, _arg3.method, _arg3.args);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local5);
break;
default:
trace(("[mochiads rpc] unknown rpc id: " + _arg3.id));
};
}
public static function setValue(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Array;
var _local5:Number;
_local4 = _arg2.split(".");
_local5 = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return;
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
_arg1[_local4[_local5]] = _arg3;
}
public static function showPreGameAd(_arg1:Object):void{
var DEFAULTS:Object;
var clip:Object;
var ad_msec:Number;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var bar:MovieClip;
var bar_color:Number;
var bar_background:Number;
var bar_outline:Number;
var backing_mc:MovieClip;
var backing:Object;
var inside_mc:MovieClip;
var inside:Object;
var outline_mc:MovieClip;
var outline:Object;
var complete:Boolean;
var unloaded:Boolean;
var f:Function;
var sendHostProgress:Boolean;
var r:MovieClip;
var options = _arg1;
DEFAULTS = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, no_progress_bar:false, ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}, ad_progress:function (_arg1:Number):void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def"){
options.ad_started();
setTimeout(options.ad_finished, 100);
return;
};
clip = options.clip;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
var fn:Function;
MochiAd._cleanup(mc);
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
bar = createEmptyMovieClip(chk, "_mochiad_bar", 4);
if (options.no_progress_bar){
bar.visible = false;
delete options.no_progress_bar;
} else {
bar.x = 10;
bar.y = (h - 20);
};
bar_color = options.color;
delete options.color;
bar_background = options.background;
delete options.background;
bar_outline = options.outline;
delete options.outline;
backing_mc = createEmptyMovieClip(bar, "_outline", 1);
backing = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo((w - 20), 0);
backing.lineTo((w - 20), 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
inside_mc = createEmptyMovieClip(bar, "_inside", 2);
inside = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo((w - 20), 0);
inside.lineTo((w - 20), 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
outline_mc = createEmptyMovieClip(bar, "_outline", 3);
outline = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo((w - 20), 0);
outline.lineTo((w - 20), 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number;
_local1 = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
f = function (_arg1:Event):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
};
};
mc.unloadAd = function ():void{
unloaded = true;
if (complete){
MochiAd.unload(clip);
};
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object;
_local2 = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = _arg1;
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
mc.rpcTestFn = function (_arg1:String):Object{
trace(("[MOCHIAD rpcTestFn] " + _arg1));
return (_arg1);
};
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
sendHostProgress = false;
mc.sendHostLoadProgress = function (_arg1:String):void{
sendHostProgress = true;
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Object;
var _local3:Number;
var _local4:Boolean;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Object;
var _local10:Number;
var _local11:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
_local1 = this.parent.parent.root;
_local2 = this.parent._mochiad_ctr;
_local3 = (getTimer() - this.started);
_local4 = false;
_local5 = _local1.loaderInfo.bytesTotal;
_local6 = _local1.loaderInfo.bytesLoaded;
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
_local7 = ((100 * _local6) / _local5);
_local8 = ((100 * _local3) / chk.ad_msec);
_local9 = this._mochiad_bar._inside;
_local10 = Math.min(100, Math.min(((_local7) || (0)), _local8));
_local10 = Math.max(this.last_pcnt, _local10);
this.last_pcnt = _local10;
_local9.scaleX = (_local10 * 0.01);
options.ad_progress(_local10);
if (sendHostProgress){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:_local7});
if (_local7 == 100){
sendHostProgress = false;
};
};
if (!chk.showing){
_local11 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local11 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if ((((_local3 > chk.ad_timeout)) && ((_local7 == 100)))){
options.ad_failed();
_local4 = true;
};
};
};
if (_local3 > chk.ad_msec){
_local4 = true;
};
if (((complete) && (_local4))){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
MochiAd.showPreGameAd(_arg1);
}
public static function showTimedAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
MochiAd.showInterLevelAd(_arg1);
}
public static function doOnEnterFrame(_arg1:MovieClip):void{
var f:Function;
var mc = _arg1;
f = function (_arg1:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package
Section 76
//napoleonsGaurd (napoleonsGaurd)
package {
import flash.display.*;
public dynamic class napoleonsGaurd extends MovieClip {
}
}//package
Section 77
//paratrooper (paratrooper)
package {
import flash.display.*;
public dynamic class paratrooper extends MovieClip {
}
}//package
Section 78
//Peasant (Peasant)
package {
import flash.display.*;
public dynamic class Peasant extends MovieClip {
}
}//package
Section 79
//Pigeon (Pigeon)
package {
import flash.display.*;
public dynamic class Pigeon extends MovieClip {
}
}//package
Section 80
//poisonProjectile (poisonProjectile)
package {
import flash.display.*;
public dynamic class poisonProjectile extends MovieClip {
}
}//package
Section 81
//poisonTower (poisonTower)
package {
import flash.display.*;
public dynamic class poisonTower extends MovieClip {
public var promotion3:MovieClip;
public var standardTop:MovieClip;
public var goldenTop:MovieClip;
public var promotion:MovieClip;
public var promotion2:MovieClip;
public var promotion4:MovieClip;
public var promotion5:MovieClip;
public var turret:MovieClip;
}
}//package
Section 82
//powerTower (powerTower)
package {
import flash.display.*;
public dynamic class powerTower extends MovieClip {
public var promotion3:MovieClip;
public var standardTop:MovieClip;
public var goldenTop:MovieClip;
public var promotion:MovieClip;
public var promotion2:MovieClip;
public var promotion4:MovieClip;
public var promotion5:MovieClip;
public var turret:MovieClip;
}
}//package
Section 83
//Praetorian (Praetorian)
package {
import flash.display.*;
public dynamic class Praetorian extends MovieClip {
}
}//package
Section 84
//projectileBase (projectileBase)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class projectileBase extends MovieClip {
public var age:Number;
public var canPoison:Number;
public var splashRange:Number;
public var stopRunning:Boolean;
public var landTime:Number;
public var ySpeed;
public var targetCreepUID:Number;
public var rt:MovieClip;
public var dieTime:Number;
public var maxAge:Number;
public var damageDone:Boolean;
public var needsInit:Boolean;
public var activeProjectile:MovieClip;
public var xSpeed;
public var projectileSplash:Number;
public var needsDisplay:Boolean;
public var projectileType:Number;
public var projectileDamage:Number;
public var canBurn:Number;
public var targetY:Number;
public var targetX:Number;
public var canSlow:Number;
public var explode:Boolean;
public var targetCreep:Number;
public function projectileBase(){
addFrameScript(0, frame1, 13, frame14);
}
public function missileMovement(){
var _local1:Number;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
trace("doing missile movement");
if (!stopRunning){
if (activeProjectile == null){
return;
};
age++;
if ((age >= maxAge)){
stopRunning = true;
dieTime = 50;
activeProjectile.visible = false;
gotoAndPlay(2);
return;
};
if (targetCreep < rt.liveCreeps.length){
if ((rt.liveCreeps[targetCreep].creepUID == targetCreepUID)){
this.visible = true;
_local3 = new Point(rt.liveCreeps[targetCreep].x, rt.liveCreeps[targetCreep].y);
_local4 = this.y;
_local5 = this.x;
_local6 = (rt.calcAngle2D(_local5, _local4, _local3.x, _local3.y) + 90);
_local7 = this.rotation;
while (_local7 < 0) {
_local7 = (_local7 + 360);
};
_local8 = (_local6 - _local7);
while (_local8 < 0) {
_local8 = (_local8 + 360);
};
if ((((_local8 > 30)) && ((_local8 < 330)))){
if ((((_local8 < 180)) && ((_local8 > 0)))){
this.rotation = (this.rotation + 15);
} else {
this.rotation = (this.rotation - 15);
};
} else {
this.rotation = _local6;
};
} else {
targetCreep = rt.returnCreepIndex(targetCreepUID);
if (targetCreep == -1){
targetCreepUID = rt.returnFlyingCreepUID();
targetCreep = rt.returnCreepIndex(targetCreepUID);
if (targetCreep == -1){
age = maxAge;
return;
};
};
};
} else {
targetCreep = rt.returnCreepIndex(targetCreepUID);
if (targetCreep == -1){
targetCreepUID = rt.returnFlyingCreepUID();
targetCreep = rt.returnCreepIndex(targetCreepUID);
if (targetCreep == -1){
age = maxAge;
return;
};
};
};
_local1 = Math.round(this.rotation);
while (_local1 < 0) {
_local1 = (_local1 + 360);
};
while (_local1 > 360) {
_local1 = (_local1 - 360);
};
xSpeed = (rt.sine[_local1] * 12);
ySpeed = (rt.cosine[_local1] * 12);
this.x = (this.x + xSpeed);
this.y = (this.y + ySpeed);
_local2 = rt.liveCreeps.length;
if (targetCreep < _local2){
if (activeProjectile.hitTestObject(rt.liveCreeps[targetCreep].activeSprite)){
if (damageDone){
activeProjectile.visible = false;
return;
};
if (canPoison){
rt.liveCreeps[targetCreep].makePoisoned(canPoison);
};
stopRunning = true;
dieTime = 30;
rt.liveCreeps[targetCreep].takeHealth(projectileDamage);
damageDone = true;
activeProjectile.visible = false;
gotoAndPlay(2);
return;
};
};
} else {
if (dieTime > 0){
dieTime--;
xSpeed = (rt.calcXSpeed(this.rotation) * 6);
ySpeed = (rt.calcYSpeed(this.rotation) * 6);
this.x = (this.x + xSpeed);
this.y = (this.y + ySpeed);
} else {
this.visible = false;
};
};
}
public function doSplashDamage(){
var _local1:*;
if (damageDone){
return;
};
damageDone = true;
if (splashRange == 0){
return;
};
_local1 = 0;
while (_local1 < rt.liveCreeps.length) {
if (rt.liveCreeps[_local1].canFly == false){
if (rt.distanceToCreep(targetX, targetY, _local1) < splashRange){
rt.liveCreeps[_local1].takeHealth(projectileSplash);
if (canSlow > 0){
rt.liveCreeps[_local1].causeSlow(canSlow);
};
if (canBurn > 0){
rt.liveCreeps[_local1].doBurn(canBurn);
};
};
};
_local1++;
};
}
public function initProjectile(){
var _local1:*;
var _local2:*;
var _local3:*;
needsInit = false;
xSpeed = 0;
ySpeed = 0;
landTime = 0;
switch (projectileType){
case 0:
activeProjectile = null;
break;
case 1:
default:
activeProjectile = (this.addChild(new bullet()) as MovieClip);
maxAge = 4;
xSpeed = ((targetX - this.x) / maxAge);
ySpeed = ((targetY - this.y) / maxAge);
break;
case 2:
activeProjectile = (this.addChild(new aMissile()) as MovieClip);
maxAge = 50;
dieTime = 50;
if (targetCreep < rt.liveCreeps.length){
_local1 = new Point(rt.liveCreeps[targetCreep].x, rt.liveCreeps[targetCreep].y);
_local3 = this.y;
_local2 = this.x;
this.rotation = (rt.calcAngle2D(_local2, _local3, _local1.x, _local1.y) + 90);
};
break;
case 3:
activeProjectile = (this.addChild(new artilleryProjectile()) as MovieClip);
maxAge = 10;
landTime = 10;
xSpeed = ((targetX - this.x) / maxAge);
ySpeed = ((targetY - this.y) / maxAge);
break;
case 4:
activeProjectile = (this.addChild(new smashprojectile()) as MovieClip);
maxAge = 5;
landTime = 5;
xSpeed = ((targetX - this.x) / maxAge);
ySpeed = ((targetY - this.y) / maxAge);
break;
case 5:
activeProjectile = (this.addChild(new poisonProjectile()) as MovieClip);
maxAge = 50;
dieTime = 50;
if (targetCreep < rt.liveCreeps.length){
_local1 = new Point(rt.liveCreeps[targetCreep].x, rt.liveCreeps[targetCreep].y);
_local3 = this.y;
_local2 = this.x;
this.rotation = (rt.calcAngle2D(_local2, _local3, _local1.x, _local1.y) + 90);
};
break;
};
if (activeProjectile != null){
activeProjectile.visible = true;
activeProjectile.x = 0;
activeProjectile.y = 0;
};
}
public function displayProj(){
activeProjectile.visible = true;
needsDisplay = false;
}
public function doCloudMovement(){
doSplashDamage();
this.visible = false;
}
function frame14(){
this.visible = false;
stop();
}
public function doMovement(){
if (needsInit){
initProjectile();
};
switch (projectileType){
case 0:
doCloudMovement();
break;
case 1:
case 3:
case 4:
default:
bulletMovement();
break;
case 2:
case 5:
missileMovement();
break;
};
}
function frame1(){
needsInit = true;
needsDisplay = false;
stopRunning = false;
age = 0;
dieTime = 0;
explode = false;
landTime = 0;
damageDone = false;
stop();
}
public function selfClean(){
if (activeProjectile != null){
this.removeChild(activeProjectile);
};
activeProjectile = null;
rt = null;
}
public function bulletMovement(){
age++;
if (age > maxAge){
if (!damageDone){
doSplashDamage();
damageDone = true;
if (targetCreep < rt.liveCreeps.length){
if (rt.liveCreeps[targetCreep].creepUID != targetCreepUID){
} else {
rt.liveCreeps[targetCreep].takeHealth(projectileDamage);
};
};
};
if (landTime > 0){
landTime--;
xSpeed = 0;
ySpeed = 0;
} else {
this.visible = false;
};
};
if (age < maxAge){
if (xSpeed != undefined){
this.x = (this.x + xSpeed);
this.y = (this.y + ySpeed);
};
};
}
}
}//package
Section 85
//Protestor (Protestor)
package {
import flash.display.*;
public dynamic class Protestor extends MovieClip {
}
}//package
Section 86
//protestors (protestors)
package {
import flash.display.*;
public dynamic class protestors extends MovieClip {
}
}//package
Section 87
//ram (ram)
package {
import flash.display.*;
public dynamic class ram extends MovieClip {
}
}//package
Section 88
//RangeImage1 (RangeImage1)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class RangeImage1 extends MovieClip {
public var rt:MovieClip;
public function RangeImage1(){
addFrameScript(0, frame1, 93, frame94);
}
function frame94(){
rt.timedOut = true;
stop();
}
function frame1(){
stop();
}
}
}//package
Section 89
//redArmy (redArmy)
package {
import flash.display.*;
public dynamic class redArmy extends MovieClip {
}
}//package
Section 90
//redBaron (redBaron)
package {
import flash.display.*;
public dynamic class redBaron extends MovieClip {
}
}//package
Section 91
//redCoat (redCoat)
package {
import flash.display.*;
public dynamic class redCoat extends MovieClip {
}
}//package
Section 92
//Rioter (Rioter)
package {
import flash.display.*;
public dynamic class Rioter extends MovieClip {
}
}//package
Section 93
//routeClip (routeClip)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class routeClip extends MovieClip {
public var tileName:TextField;
public var routeLength:TextField;
public function routeClip(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package
Section 94
//sas (sas)
package {
import flash.display.*;
public dynamic class sas extends MovieClip {
}
}//package
Section 95
//Serf (Serf)
package {
import flash.display.*;
public dynamic class Serf extends MovieClip {
}
}//package
Section 96
//smashprojectile (smashprojectile)
package {
import flash.display.*;
public dynamic class smashprojectile extends MovieClip {
}
}//package
Section 97
//smashTower (smashTower)
package {
import flash.display.*;
public dynamic class smashTower extends MovieClip {
public var promotion3:MovieClip;
public var standardTop:MovieClip;
public var goldenTop:MovieClip;
public var promotion:MovieClip;
public var promotion2:MovieClip;
public var promotion4:MovieClip;
public var promotion5:MovieClip;
public var turret:MovieClip;
}
}//package
Section 98
//sniper (sniper)
package {
import flash.display.*;
public dynamic class sniper extends MovieClip {
}
}//package
Section 99
//spitfire (spitfire)
package {
import flash.display.*;
public dynamic class spitfire extends MovieClip {
}
}//package
Section 100
//takeCash (takeCash)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class takeCash extends MovieClip {
public var rt:MovieClip;
public function takeCash(){
addFrameScript(0, frame1, 10, frame11);
}
function frame1(){
}
function frame11(){
stop();
rt.removeClip(this);
}
}
}//package
Section 101
//tank (tank)
package {
import flash.display.*;
public dynamic class tank extends MovieClip {
}
}//package
Section 102
//tank2 (tank2)
package {
import flash.display.*;
public dynamic class tank2 extends MovieClip {
}
}//package
Section 103
//tank3 (tank3)
package {
import flash.display.*;
public dynamic class tank3 extends MovieClip {
}
}//package
Section 104
//Test (Test)
package {
import flash.display.*;
public dynamic class Test extends MovieClip {
}
}//package
Section 105
//TextInput_disabledSkin (TextInput_disabledSkin)
package {
import flash.display.*;
public dynamic class TextInput_disabledSkin extends MovieClip {
}
}//package
Section 106
//TextInput_upSkin (TextInput_upSkin)
package {
import flash.display.*;
public dynamic class TextInput_upSkin extends MovieClip {
}
}//package
Section 107
//tile (tile)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class tile extends MovieClip {
public function tile(){
addFrameScript(0, frame1);
}
function frame1(){
}
public function turnToWall(){
var _local1:MovieClip;
_local1 = (this.addChild(new wallClip()) as MovieClip);
_local1.x = 0;
_local1.y = 0;
_local1.visible = true;
}
}
}//package
Section 108
//towerBase (towerBase)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class towerBase extends MovieClip {
public var towerType:Number;
public var reloadTime:Number;
public var poisonLength:Number;
public var splashRange:Number;
public var canFire:Number;
public var quadFire:Boolean;
public var slowLength:Number;
public var targetCreepUID:Number;
public var damage:Number;
public var recoil:Boolean;
public var distanceToCreep:Number;
public var needsDisplayUpdate:Boolean;
public var towerUID:Number;
public var needsInit:Boolean;
public var canHitAir:Number;
public var burnLength:Number;
public var rt:MovieClip;
public var splashDamage:Number;
public var towerRange:Number;
public var projectileType:Number;
public var upgradeLevel:Number;
public var dualFire:Boolean;
public var cannonFire:Number;
public var towerOnDisplay:MovieClip;
public var targetCreep;
public function towerBase(){
addFrameScript(0, frame1);
}
public function setTowerLook(){
towerOnDisplay.visible = true;
needsDisplayUpdate = false;
towerOnDisplay.promotion.visible = false;
towerOnDisplay.promotion2.visible = false;
towerOnDisplay.promotion3.visible = false;
towerOnDisplay.promotion4.visible = false;
towerOnDisplay.promotion5.visible = false;
towerOnDisplay.goldenTop.visible = false;
switch (upgradeLevel){
case 1:
towerOnDisplay.promotion.visible = true;
break;
case 2:
towerOnDisplay.promotion2.visible = true;
break;
case 3:
towerOnDisplay.promotion3.visible = true;
break;
case 4:
towerOnDisplay.promotion4.visible = true;
break;
case 5:
towerOnDisplay.goldenTop.visible = true;
towerOnDisplay.promotion5.visible = true;
break;
};
}
public function doMovement(){
var _local1:Point;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:*;
var _local9:*;
if (needsDisplayUpdate){
setTowerLook();
};
if (needsInit){
initTower();
};
_local1 = new Point(0, 0);
if (targetCreep == -1){
targetCreep = rt.getClosestCreep(this.x, this.y, towerRange, canHitAir);
if (targetCreep > -1){
targetCreepUID = rt.liveCreeps[targetCreep].creepUID;
};
};
if (targetCreep > -1){
if ((((rt.liveCreeps.length < 1)) || ((targetCreep >= rt.liveCreeps.length)))){
targetCreep = -1;
return (false);
};
if (targetCreepUID != rt.liveCreeps[targetCreep].creepUID){
targetCreep = -1;
return (false);
};
distanceToCreep = rt.distanceToCreep(this.x, this.y, targetCreep);
if (distanceToCreep < towerRange){
_local3 = rt.liveCreeps[targetCreep].y;
_local2 = rt.liveCreeps[targetCreep].x;
_local5 = ((Math.atan2((_local3 - this.y), (_local2 - this.x)) * 57) + 90);
_local4 = (_local5 - towerOnDisplay.turret.rotation);
_local6 = _local4;
_local4 = Math.round(((_local4 + 360) % 360));
if ((((_local4 > 50)) && ((_local4 < 280)))){
if ((((_local4 < 180)) && ((_local4 > 0)))){
towerOnDisplay.turret.rotation = (towerOnDisplay.turret.rotation + 50);
} else {
towerOnDisplay.turret.rotation = (towerOnDisplay.turret.rotation - 50);
};
} else {
towerOnDisplay.turret.rotation = _local5;
if (canFire <= 0){
if (dualFire){
if (cannonFire == 0){
towerOnDisplay.turret.fire.gotoAndPlay(2);
cannonFire = 1;
_local1 = towerOnDisplay.turret.cannonNose.localToGlobal(_local1);
} else {
towerOnDisplay.turret.fire2.gotoAndPlay(2);
_local1 = towerOnDisplay.turret.cannonNose2.localToGlobal(_local1);
cannonFire = 0;
};
};
if (quadFire){
if (cannonFire == 0){
towerOnDisplay.turret.fire.gotoAndPlay(2);
cannonFire = 1;
_local1 = towerOnDisplay.turret.cannonNose.localToGlobal(_local1);
} else {
if (cannonFire == 1){
towerOnDisplay.turret.fire2.gotoAndPlay(2);
_local1 = towerOnDisplay.turret.cannonNose2.localToGlobal(_local1);
cannonFire = 2;
} else {
if (cannonFire == 2){
towerOnDisplay.turret.fire3.gotoAndPlay(2);
_local1 = towerOnDisplay.turret.nose3.localToGlobal(_local1);
cannonFire = 3;
} else {
towerOnDisplay.turret.fire4.gotoAndPlay(2);
_local1 = towerOnDisplay.turret.nose4.localToGlobal(_local1);
cannonFire = 0;
};
};
};
};
if (_local1.x == 0){
towerOnDisplay.turret.fire.gotoAndPlay(2);
_local1 = towerOnDisplay.turret.cannonNose.localToGlobal(_local1);
};
if (recoil){
towerOnDisplay.turret.doRecoil();
};
_local8 = rt.liveCreeps[targetCreep].xPositionIn(7);
_local9 = rt.liveCreeps[targetCreep].yPositionIn(7);
if (_local8 > 0){
rt.doFire(projectileType, _local1.x, _local1.y, (_local5 + (_local7 * 5)), distanceToCreep, _local8, _local9, targetCreep, damage, splashDamage, splashRange, slowLength, poisonLength, burnLength, targetCreepUID);
};
canFire = reloadTime;
} else {
canFire--;
};
};
_local7 = _local6;
} else {
targetCreep = -1;
};
};
}
function frame1(){
needsInit = true;
upgradeLevel = 0;
needsDisplayUpdate = false;
targetCreep = -1;
canFire = 0;
reloadTime = 5;
canHitAir = 2;
}
public function upgradeTower(){
if (upgradeLevel < 5){
upgradeLevel++;
setTowerLook();
};
}
public function initTower(){
needsInit = false;
upgradeLevel = 0;
dualFire = false;
quadFire = false;
switch (towerType){
case 1:
towerOnDisplay = (this.addChild(new fastTower()) as MovieClip);
dualFire = true;
projectileType = 1;
break;
case 2:
towerOnDisplay = (this.addChild(new missileTower()) as MovieClip);
dualFire = true;
projectileType = 2;
break;
case 3:
towerOnDisplay = (this.addChild(new artilleryTower()) as MovieClip);
projectileType = 3;
break;
case 4:
towerOnDisplay = (this.addChild(new smashTower()) as MovieClip);
projectileType = 4;
break;
case 5:
towerOnDisplay = (this.addChild(new fireTurret()) as MovieClip);
projectileType = 0;
break;
case 6:
towerOnDisplay = (this.addChild(new frostTower()) as MovieClip);
projectileType = 0;
break;
case 7:
towerOnDisplay = (this.addChild(new poisonTower()) as MovieClip);
projectileType = 5;
break;
case 8:
towerOnDisplay = (this.addChild(new powerTower()) as MovieClip);
projectileType = 1;
quadFire = true;
break;
};
rt.populateTowerInfo(towerUID);
towerOnDisplay.visible = false;
needsDisplayUpdate = true;
}
}
}//package
Section 109
//towerSelectedImg (towerSelectedImg)
package {
import flash.display.*;
public dynamic class towerSelectedImg extends MovieClip {
}
}//package
Section 110
//trenchman (trenchman)
package {
import flash.display.*;
public dynamic class trenchman extends MovieClip {
}
}//package
Section 111
//tutorial (tutorial)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
public dynamic class tutorial extends MovieClip {
public var rt:MovieClip;
public var box:MovieClip;
public var tutorialFast:fastTower;
public function tutorial(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4, 4, frame5, 5, frame6, 6, frame7, 7, frame8, 8, frame9, 9, frame10, 10, frame11, 11, frame12, 12, frame13, 13, frame14, 14, frame15, 15, frame16);
}
function frame10(){
box.stepTitle.text = "Step 7: Your Lives";
box.stepText.text = "Here are your lives. You lose a life each time a creep escapes, when you lose all your lifes, the game is over";
box.x = 80;
box.y = 50;
box.Aarrow3.visible = false;
box.Aarrow2.visible = false;
box.Aarrow.visible = true;
}
function frame14(){
box.stepTitle.text = "Step 11: Tower Range";
box.stepText.text = "Here is the selected towers range, on the right is how much the towers' range will be when its upgraded.";
box.x = 250;
box.y = 345;
box.Aarrow3.visible = false;
box.Aarrow2.visible = false;
box.Aarrow.visible = true;
}
function frame12(){
box.stepTitle.text = "Step 9: Tower Cost";
box.stepText.text = "Here is how much the selected tower costs to build, on the right is how much it costs to upgrade it.";
box.x = 250;
box.y = 250;
box.Aarrow3.visible = false;
box.Aarrow2.visible = false;
box.Aarrow.visible = true;
}
function frame3(){
box.stepTitle.text = "Step 1: Towers";
box.stepText.text = "These buttons are used to select the different tower types. Each tower type has different characteristics.";
box.x = 230;
box.y = 130;
box.Aarrow.visible = true;
}
function frame6(){
box.stepTitle.text = "Step 4: Release Creeps";
box.stepText.text = "Creeps will be released when the countdown gets to 0";
box.x = 240;
box.y = 350;
box.Aarrow.visible = false;
box.Aarrow2.visible = true;
tutorialFast.goldenTop.visible = false;
tutorialFast.promotion5.visible = false;
tutorialFast.promotion4.visible = false;
tutorialFast.promotion3.visible = false;
tutorialFast.promotion2.visible = false;
tutorialFast.promotion.visible = false;
}
function frame7(){
box.stepTitle.text = "Step 5: Early Release";
box.stepText.text = "You can also release creeps by pressing 'space' when the next countdown is less than 25 seconds";
box.x = 240;
box.y = 350;
box.Aarrow.visible = false;
box.Aarrow2.visible = true;
}
function frame1(){
}
function frame13(){
box.stepTitle.text = "Step 10: Tower Damage";
box.stepText.text = "Here is the selected towers damage, on the right is how much its damage will be when its upgraded.";
box.x = 250;
box.y = 285;
box.Aarrow3.visible = false;
box.Aarrow2.visible = false;
box.Aarrow.visible = true;
}
function frame4(){
box.stepTitle.text = "Step 2: Select a Tower";
box.stepText.text = "This tutorial will use the 'fast tower' as it is cheap and good for low level creeps";
box.x = 280;
box.y = 110;
box.Aarrow.visible = true;
}
function frame5(){
box.stepTitle.text = "Step 3: Place a Tower";
box.stepText.text = "Once a tower has been selected, you can place if anywhere on the map by clicking at that location.";
box.x = 5;
box.y = 300;
box.Aarrow.visible = true;
}
function frame16(){
rt.removeClip(this);
rt.reInitGame();
stop();
}
function frame8(){
box.stepTitle.text = "Step 5: Build A Maze";
box.stepText.text = "Hint: Building a maze with towers will cause creeps to escape less quickly as they have to navigate the maze";
box.x = 240;
box.y = 350;
box.Aarrow.visible = false;
box.Aarrow2.visible = true;
}
function frame2(){
stop();
box.stepTitle.text = "Welcome to WWTD";
box.stepText.text = "Welcome to Word War Tower Defence tutorial. This will show you how to play the game. Click next to continue";
box.Aarrow.visible = false;
box.Aarrow2.visible = false;
box.Aarrow3.visible = false;
box.nextBtn.texts.text = "NEXT";
}
function frame15(){
box.stepTitle.text = "Step 12: End Of Tutorial";
box.stepText.text = "You have reached the end of the tutorial. Good Luck!";
box.x = 150;
box.y = 180;
box.Aarrow3.visible = false;
box.Aarrow2.visible = false;
box.Aarrow.visible = false;
}
function frame9(){
box.stepTitle.text = "Step 6: Your Score";
box.stepText.text = "Here is your score. Gain score by killing creeps and releasing creeps early";
box.x = 80;
box.y = 50;
box.Aarrow3.visible = true;
box.Aarrow2.visible = false;
box.Aarrow.visible = false;
}
function frame11(){
box.stepTitle.text = "Step 8: Your Cash";
box.stepText.text = "Here is your cash. Use cash to buy and upgrade towers, you get cash by killing creeps.";
box.x = 250;
box.y = 50;
box.Aarrow3.visible = false;
box.Aarrow2.visible = false;
box.Aarrow.visible = true;
}
}
}//package
Section 112
//wallClip (wallClip)
package {
import flash.display.*;
public dynamic class wallClip extends MovieClip {
}
}//package
Section 113
//WitchDoctor (WitchDoctor)
package {
import flash.display.*;
public dynamic class WitchDoctor extends MovieClip {
}
}//package
Section 114
//wrightbros (wrightbros)
package {
import flash.display.*;
public dynamic class wrightbros extends MovieClip {
}
}//package