Section 1
//GTween (com.gskinner.motion.GTween)
package com.gskinner.motion {
import flash.events.*;
import flash.utils.*;
public class GTween extends EventDispatcher {
protected var ticker:ITicker;
protected var children:Dictionary;
protected var positionOffset:Number;// = NAN
public var useSmartRotation:Boolean;// = true
protected var lastProgressPosition:Number;// = 0
public var autoReverse:Boolean;// = false
public var nextTween:GTween;
protected var _paused:Boolean;// = true
protected var clearProperties:Boolean;// = true
protected var initProperties:Object;
protected var _proxy:TargetProxy;
protected var destProperties:Object;
protected var progressPoints:Array;
public var autoPlay:Boolean;// = true
protected var _position:Number;// = 0
protected var hasSetSize:Boolean;// = false
protected var _delay:Number;// = 0
protected var _state:String;// = "beginning"
protected var hasAlphaAndVisible:Boolean;// = true
public var data;
protected var _target:Object;
public var assignmentTarget:Object;
public var assignmentProperty:String;
public var useSnapping:Boolean;// = false
protected var _lastProgressPoint:ProgressPoint;
protected var _autoHide:Boolean;// = true
protected var invalid:Boolean;// = false
protected var _duration:Number;// = 10
public var useSetSize:Boolean;// = true
public var ease:Function;
public static const TIME:String = "time";
public static const FRAME:String = "frame";
public static const TWEEN_PHASE:String = "tweenPhase";
public static const PROGRESS:String = "progress";
public static const END:String = "end";
public static const HYBRID:String = "hybrid";
public static const BEGINNING:String = "beginning";
public static const DELAY_PHASE:String = "delayPhase";
protected static var ticker:ITicker;
public static var pauseAll:Boolean = false;
public static var defaultEase:Function = linearEase;
public static var rotationProperties:Object = {_rotation:true, rotation:true, rotationX:true, rotationY:true, rotationZ:true};
protected static var activeTweens:Dictionary = new Dictionary(false);
protected static var _timeInterval:uint = 40;
protected static var _timingMode:String;
public static var snappingProperties:Object = {x:true, y:true};
public function GTween(_arg1:Object=null, _arg2:Number=10, _arg3:Object=null, _arg4:Object=null){
ease = ((defaultEase) || (linearEase));
if (isNaN(_arg2)){
_arg2 = 10;
};
if (_timingMode == null){
timingMode = HYBRID;
};
ticker = GTween.ticker;
progressPoints = [];
children = new Dictionary(true);
this.target = _arg1;
_duration = _arg2;
setTweenProperties(_arg4);
setProperties(_arg3);
}
public function set delay(_arg1:Number):void{
if (isNaN(_arg1)){
return;
};
if ((((_state == BEGINNING)) || ((_position == -(_delay))))){
positionOffset = (ticker.position - (_position = -(_arg1)));
lastProgressPosition = -(_delay);
};
_delay = _arg1;
}
protected function init():void{
lastProgressPosition = -(_delay);
_state = TWEEN_PHASE;
copyInitProperties();
dispatchEvent(new Event(Event.INIT));
}
public function set target(_arg1:Object):void{
_target = ((_arg1)===null) ? {} : _arg1;
hasSetSize = ("setSize" in _target);
hasAlphaAndVisible = ((("alpha" in _target)) && (("visible" in _target)));
reset();
}
public function set duration(_arg1:Number):void{
var _local2:Object;
if (isNaN(_arg1)){
return;
};
_duration = _arg1;
for (_local2 in children) {
if (children[_local2]){
(_local2 as GTween).duration = _duration;
};
};
}
public function get position():Number{
return (_position);
}
public function get paused():Boolean{
return (_paused);
}
public function set autoHide(_arg1:Boolean):void{
_autoHide = _arg1;
}
public function play():void{
paused = false;
}
public function setProperties(_arg1:Object):void{
var _local2:String;
if (!_arg1){
return;
};
for (_local2 in _arg1) {
setProperty(_local2, _arg1[_local2]);
};
}
public function invalidate():void{
invalid = true;
if (_position > 0){
positionOffset = (ticker.position - (_position = 0));
};
if (autoPlay){
paused = false;
} else {
if (_state == END){
_state = BEGINNING;
};
};
}
public function setTweenProperties(_arg1:Object):void{
var _local2:String;
if (!_arg1){
return;
};
if (("duration" in _arg1)){
duration = _arg1.duration;
delete _arg1.duration;
};
if (("activateListener" in _arg1)){
addEventListener(Event.ACTIVATE, _arg1.activateListener, false, 0, true);
delete _arg1.activateListener;
};
if (("initListener" in _arg1)){
addEventListener(Event.INIT, _arg1.initListener, false, 0, true);
delete _arg1.initListener;
};
if (("completeListener" in _arg1)){
addEventListener(Event.COMPLETE, _arg1.completeListener, false, 0, true);
delete _arg1.completeListener;
};
if (("progressListener" in _arg1)){
addEventListener(PROGRESS, _arg1.progressListener, false, 0, true);
delete _arg1.progressListener;
};
if (("changeListener" in _arg1)){
addEventListener(Event.CHANGE, _arg1.changeListener, false, 0, true);
delete _arg1.changeListener;
};
for (_local2 in _arg1) {
this[_local2] = _arg1[_local2];
};
}
public function addProgressPoint(_arg1:Number, _arg2=null):void{
progressPoints.push(new ProgressPoint(_arg1, _arg2));
progressPoints.sortOn("position", Array.NUMERIC);
}
public function removeProgressPoint(_arg1:Number, _arg2=null):void{
var _local3:int = (progressPoints.length - 1);
while (_local3 >= 0) {
if ((((progressPoints[_local3].position == _arg1)) && ((progressPoints[_local3].data == _arg2)))){
progressPoints.splice(_local3, 1);
};
_local3--;
};
}
public function getProperty(_arg1:String):Number{
return (destProperties[_arg1]);
}
public function reset():void{
_position = -(_delay);
_state = BEGINNING;
paused = true;
initProperties = (_lastProgressPoint = null);
destProperties = {};
}
protected function copyInitProperties():void{
var _local1:String;
var _local2:Number;
var _local3:Number;
if (!invalid){
return;
};
if (((assignmentTarget) && (assignmentProperty))){
_target = assignmentTarget[assignmentProperty];
};
initProperties = {};
for (_local1 in destProperties) {
if (((useSmartRotation) && (rotationProperties[_local1]))){
_local2 = (destProperties[_local1] % 360);
_local3 = (_target[_local1] % 360);
initProperties[_local1] = (_local3 + ((Math.abs((_local3 - _local2)))<180) ? 0 : ((_local3)>_local2) ? -360 : 360);
} else {
initProperties[_local1] = _target[_local1];
};
};
invalid = false;
}
public function set position(_arg1:Number):void{
if (isNaN(_arg1)){
return;
};
_arg1 = ((_arg1)>_duration) ? _duration : ((_arg1)<-(_delay)) ? -(_delay) : _arg1;
if (_position == _arg1){
return;
};
lastProgressPosition = _arg1;
setPosition(_arg1);
}
public function setProperty(_arg1:String, _arg2:Number):void{
if (isNaN(_arg2)){
return;
};
if (_state == END){
reset();
};
destProperties[_arg1] = _arg2;
invalidate();
}
protected function nullListener(_arg1:Event):void{
}
public function set paused(_arg1:Boolean):void{
if (_paused == _arg1){
return;
};
_paused = _arg1;
if (_arg1){
ticker.removeEventListener("tick", handleTick);
if ((_target is IEventDispatcher)){
_target.removeEventListener("GDS__NONEXISTENT_EVENT", nullListener);
};
delete activeTweens[this];
} else {
if ((((_state == BEGINNING)) || ((_state == END)))){
_position = -(_delay);
activate();
};
positionOffset = (ticker.position - _position);
ticker.addEventListener("tick", handleTick);
if ((_target is IEventDispatcher)){
_target.addEventListener("GDS__NONEXISTENT_EVENT", nullListener, false, 0, false);
} else {
activeTweens[this] = true;
};
};
}
public function clone(_arg1:Object=null, _arg2:Boolean=false, _arg3:Boolean=false):GTween{
var _local5:Object;
if (_arg1 == null){
_arg1 = this.target;
};
var _local4:GTween = new GTween(_arg1, duration, destProperties, {assignmentProperty:assignmentProperty, assignmentTarget:assignmentTarget, autoHide:autoHide, autoPlay:autoPlay, autoReverse:autoReverse, delay:delay, nextTween:nextTween, ease:ease, useSmartRotation:useSmartRotation});
for (_local5 in progressPoints) {
_local4.addProgressPoint(_local5.position, _local5.data);
};
if (_arg2){
for (_local5 in children) {
_local4.addChild((_local5 as GTween), children[_local5]);
};
};
if (_arg3){
_local4.position = position;
_local4.paused = paused;
};
return (_local4);
}
override public function dispatchEvent(_arg1:Event):Boolean{
if (hasEventListener(_arg1.type)){
return (super.dispatchEvent(_arg1));
};
return (true);
}
public function removeAllProgressPoints():void{
progressPoints = [];
}
public function get lastProgressPoint(){
return ((_lastProgressPoint) ? _lastProgressPoint.data : null);
}
public function get proxy():Object{
if (_proxy == null){
_proxy = new TargetProxy(this);
};
return (_proxy);
}
public function get delay():Number{
return (_delay);
}
protected function endTransition():void{
_state = END;
paused = true;
dispatchEvent(new Event(Event.COMPLETE));
if (autoReverse){
reverse();
};
if (nextTween){
nextTween.play();
};
}
public function get target():Object{
return (_target);
}
public function get duration():Number{
return (_duration);
}
public function get autoHide():Boolean{
return (_autoHide);
}
public function deleteProperty(_arg1:String):Boolean{
return (delete destProperties[_arg1]);
}
protected function checkProgressPoints():void{
var _local2:ProgressPoint;
if (progressPoints.length < 1){
return;
};
if (lastProgressPosition > position){
trace("A PROGRESS POINT PROBLEM OCCURRED, PLEASE REPORT THIS BACK TO GSKINNER.COM");
lastProgressPosition = position;
return;
};
var _local1:uint;
while (_local1 < progressPoints.length) {
_local2 = (progressPoints[_local1] as ProgressPoint);
if (_local2.position <= lastProgressPosition){
} else {
if (_local2.position > position){
break;
};
_lastProgressPoint = _local2;
dispatchEvent(new Event(PROGRESS));
};
_local1++;
};
lastProgressPosition = position;
}
public function get state():String{
return (_state);
}
protected function setPosition(_arg1:Number):void{
if (_arg1 > _duration){
_arg1 = _duration;
};
positionOffset = (ticker.position - (_position = _arg1));
update();
}
protected function update():void{
var _local2:Object;
if ((((_state == BEGINNING)) || ((_state == END)))){
activate();
};
if (_position < 0){
return;
};
if (_state == DELAY_PHASE){
init();
} else {
if ((((_state == TWEEN_PHASE)) && (invalid))){
copyInitProperties();
};
};
var _local1:Number = ((_position >= _duration)) ? 1 : ease((_position / _duration), 0, 1, 1);
updateProperties(_local1);
if (((((hasAlphaAndVisible) && (_autoHide))) && (!((destProperties["visible"] == null))))){
_target.visible = (_target.alpha > 0);
};
for (_local2 in children) {
(_local2 as GTween).position = _position;
};
dispatchEvent(new Event(Event.CHANGE));
checkProgressPoints();
if (_position >= _duration){
endTransition();
};
}
public function setAssignment(_arg1:Object=null, _arg2:String=null):void{
this.assignmentTarget = _arg1;
this.assignmentProperty = _arg2;
}
public function end(_arg1:Boolean=true):void{
position = _duration;
if (((_arg1) && (nextTween))){
nextTween.end();
};
}
public function beginning():void{
var _local1:Object;
updateProperties(0);
positionOffset = (ticker.position - (_position = -(_delay)));
lastProgressPosition = -(_delay);
for (_local1 in children) {
(_local1 as GTween).beginning();
};
_state = BEGINNING;
paused = true;
}
public function reverse(_arg1:Boolean=true):void{
var _local3:Object;
var _local2:Object = destProperties;
destProperties = initProperties;
initProperties = _local2;
invalid = false;
if (_state == TWEEN_PHASE){
positionOffset = (ticker.position - (_position = (_duration - _position)));
};
if (_arg1){
for (_local3 in children) {
(_local3 as GTween).reverse();
};
};
if (autoPlay){
play();
};
}
protected function handleTick(_arg1:Event):void{
if (GTween.pauseAll){
positionOffset = (ticker.position - _position);
return;
};
var _local2:Number = (ticker.position - positionOffset);
setPosition(((_local2 < _duration)) ? _local2 : _duration);
}
protected function activate():void{
_state = ((_position)<0) ? DELAY_PHASE : TWEEN_PHASE;
dispatchEvent(new Event(Event.ACTIVATE));
if (_position >= 0){
init();
};
}
protected function updateProperties(_arg1:Number):void{
var _local3:String;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local2:Boolean;
for (_local3 in destProperties) {
if (((((useSetSize) && (hasSetSize))) && ((((_local3 == "width")) || ((_local3 == "height")))))){
if (_local2){
continue;
};
_local2 = true;
_local4 = ((destProperties["width"])==null) ? _target.width : (initProperties["width"] + ((destProperties["width"] - initProperties["width"]) * _arg1));
_local5 = ((destProperties["height"])==null) ? _target.height : (initProperties["height"] + ((destProperties["height"] - initProperties["height"]) * _arg1));
if (((useSnapping) && (snappingProperties["width"]))){
_local4 = Math.round(_local4);
};
if (((useSnapping) && (snappingProperties["height"]))){
_local5 = Math.round(_local5);
};
var _local9 = _target;
_local9["setSize"](_local4, _local5);
} else {
_local6 = (initProperties[_local3] + ((destProperties[_local3] - initProperties[_local3]) * _arg1));
_target[_local3] = (((useSnapping) && (snappingProperties[_local3]))) ? Math.round(_local6) : _local6;
};
};
if (((assignmentTarget) && (assignmentProperty))){
assignmentTarget[assignmentProperty] = _target;
};
}
public function pause():void{
paused = true;
}
public function removeChild(_arg1:GTween):void{
delete children[_arg1];
}
public function addChild(_arg1:GTween, _arg2:Boolean=true):void{
if (!_arg1){
return;
};
children[_arg1] = _arg2;
_arg1.paused = true;
if (_arg2){
_arg1.duration = _duration;
};
}
public static function set timingMode(_arg1:String):void{
_arg1 = ((((_arg1 == FRAME)) || ((_arg1 == TIME)))) ? _arg1 : HYBRID;
if (_arg1 == _timingMode){
return;
};
_timingMode = _arg1;
if (_timingMode == TIME){
ticker = new TimeTicker();
(ticker as TimeTicker).interval = (_timeInterval / 1000);
} else {
if (_timingMode == FRAME){
ticker = new FrameTicker();
} else {
ticker = new HybridTicker();
};
};
}
public static function get timingMode():String{
return (_timingMode);
}
public static function set timeInterval(_arg1:uint):void{
_timeInterval = _arg1;
if ((ticker is TimeTicker)){
(ticker as TimeTicker).interval = (_timeInterval / 1000);
};
}
public static function linearEase(_arg1:Number, ... _args):Number{
return (_arg1);
}
public static function get timeInterval():uint{
return (_timeInterval);
}
}
}//package com.gskinner.motion
import flash.display.*;
import flash.events.*;
import flash.utils.*;
class HybridTicker extends EventDispatcher implements ITicker {
protected var shape:Shape;
private function HybridTicker():void{
shape = new Shape();
shape.addEventListener(Event.ENTER_FRAME, tick);
}
public function get interval():Number{
return (1);
}
public function get position():Number{
return ((getTimer() / 1000));
}
protected function tick(_arg1:Event):void{
dispatchEvent(new Event("tick"));
}
}
class TimeTicker extends EventDispatcher implements ITicker {
protected var timer:Timer;
private function TimeTicker():void{
timer = new Timer(20);
timer.start();
timer.addEventListener(TimerEvent.TIMER, tick);
}
public function get position():Number{
return ((getTimer() / 1000));
}
public function set interval(_arg1:Number):void{
timer.delay = (_arg1 * 1000);
}
public function get interval():Number{
return ((timer.delay / 1000));
}
protected function tick(_arg1:TimerEvent):void{
dispatchEvent(new Event("tick"));
_arg1.updateAfterEvent();
}
}
interface ITicker extends IEventDispatcher {
"GTween.as$129:ITicker"?? function get position():Number;
"GTween.as$129:ITicker"?? function get interval():Number;
}
class FrameTicker extends EventDispatcher implements ITicker {
protected var shape:Shape;
protected var _position:Number;// = 0
private function FrameTicker():void{
shape = new Shape();
shape.addEventListener(Event.ENTER_FRAME, tick);
}
public function get interval():Number{
return (1);
}
public function get position():Number{
return (_position);
}
protected function tick(_arg1:Event):void{
_position++;
dispatchEvent(new Event("tick"));
}
}
dynamic class TargetProxy extends Proxy {
private var gTween:GTween;
private function TargetProxy(_arg1:GTween):void{
this.gTween = _arg1;
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function deleteProperty(_arg1):Boolean{
return (gTween.deleteProperty(_arg1));
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function callProperty(_arg1, ... _args){
return (gTween.target[_arg1].apply(null, _args));
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
if (isNaN(_arg2)){
gTween.target[_arg1] = _arg2;
} else {
gTween.setProperty(String(_arg1), Number(_arg2));
};
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
var _local2:Number = gTween.getProperty(_arg1);
return ((isNaN(_local2)) ? gTween.target[_arg1] : _local2);
}
}
class ProgressPoint {
public var position:Number;
public var data;
private function ProgressPoint(_arg1:Number, _arg2):void{
this.position = _arg1;
this.data = _arg2;
}
}
Section 2
//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 3
//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 4
//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 5
//LabelButton (fl.controls.LabelButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import fl.managers.*;
import fl.events.*;
import flash.text.*;
import flash.ui.*;
public class LabelButton extends BaseButton implements IFocusManagerComponent {
protected var _labelPlacement:String;// = "right"
protected var _toggle:Boolean;// = false
protected var icon:DisplayObject;
protected var oldMouseState:String;
protected var mode:String;// = "center"
public var textField:TextField;
protected var _label:String;// = "Label"
private static var defaultStyles:Object = {icon:null, upIcon:null, downIcon:null, overIcon:null, disabledIcon:null, selectedDisabledIcon:null, selectedUpIcon:null, selectedDownIcon:null, selectedOverIcon:null, textFormat:null, disabledTextFormat:null, textPadding:5, embedFonts:false};
public static var createAccessibilityImplementation:Function;
public function LabelButton(){
_labelPlacement = ButtonLabelPlacement.RIGHT;
_toggle = false;
_label = "Label";
mode = "center";
super();
}
protected function toggleSelected(_arg1:MouseEvent):void{
selected = !(selected);
dispatchEvent(new Event(Event.CHANGE, true));
}
public function get labelPlacement():String{
return (_labelPlacement);
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
if (oldMouseState == null){
oldMouseState = mouseState;
};
setMouseState("down");
startPress();
};
}
protected function setEmbedFont(){
var _local1:Object;
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
}
override protected function keyUpHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
setMouseState(oldMouseState);
oldMouseState = null;
endPress();
dispatchEvent(new MouseEvent(MouseEvent.CLICK));
};
}
override public function get selected():Boolean{
return ((_toggle) ? _selected : false);
}
public function set labelPlacement(_arg1:String):void{
_labelPlacement = _arg1;
invalidate(InvalidationType.SIZE);
}
public function set toggle(_arg1:Boolean):void{
if (((!(_arg1)) && (super.selected))){
selected = false;
};
_toggle = _arg1;
if (_toggle){
addEventListener(MouseEvent.CLICK, toggleSelected, false, 0, true);
} else {
removeEventListener(MouseEvent.CLICK, toggleSelected);
};
invalidate(InvalidationType.STATE);
}
public function get label():String{
return (_label);
}
override public function set selected(_arg1:Boolean):void{
_selected = _arg1;
if (_toggle){
invalidate(InvalidationType.STATE);
};
}
override protected function draw():void{
if (textField.text != _label){
label = _label;
};
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
drawIcon();
drawTextFormat();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
public function get toggle():Boolean{
return (_toggle);
}
override protected function configUI():void{
super.configUI();
textField = new TextField();
textField.type = TextFieldType.DYNAMIC;
textField.selectable = false;
addChild(textField);
}
override protected function drawLayout():void{
var _local1:Number;
var _local2:String;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local1 = Number(getStyleValue("textPadding"));
_local2 = ((((icon == null)) && ((mode == "center")))) ? ButtonLabelPlacement.TOP : _labelPlacement;
textField.height = (textField.textHeight + 4);
_local3 = (textField.textWidth + 4);
_local4 = (textField.textHeight + 4);
_local5 = ((icon)==null) ? 0 : (icon.width + _local1);
_local6 = ((icon)==null) ? 0 : (icon.height + _local1);
textField.visible = (label.length > 0);
if (icon != null){
icon.x = Math.round(((width - icon.width) / 2));
icon.y = Math.round(((height - icon.height) / 2));
};
if (textField.visible == false){
textField.width = 0;
textField.height = 0;
} else {
if ((((_local2 == ButtonLabelPlacement.BOTTOM)) || ((_local2 == ButtonLabelPlacement.TOP)))){
_local7 = Math.max(0, Math.min(_local3, (width - (2 * _local1))));
if ((height - 2) > _local4){
_local8 = _local4;
} else {
_local8 = (height - 2);
};
_local3 = _local7;
textField.width = _local3;
_local4 = _local8;
textField.height = _local4;
textField.x = Math.round(((width - _local3) / 2));
textField.y = Math.round(((((height - textField.height) - _local6) / 2) + ((_local2)==ButtonLabelPlacement.BOTTOM) ? _local6 : 0));
if (icon != null){
icon.y = Math.round(((_local2)==ButtonLabelPlacement.BOTTOM) ? (textField.y - _local6) : ((textField.y + textField.height) + _local1));
};
} else {
_local7 = Math.max(0, Math.min(_local3, ((width - _local5) - (2 * _local1))));
_local3 = _local7;
textField.width = _local3;
textField.x = Math.round(((((width - _local3) - _local5) / 2) + ((_local2)!=ButtonLabelPlacement.LEFT) ? _local5 : 0));
textField.y = Math.round(((height - textField.height) / 2));
if (icon != null){
icon.x = Math.round(((_local2)!=ButtonLabelPlacement.LEFT) ? (textField.x - _local5) : ((textField.x + _local3) + _local1));
};
};
};
super.drawLayout();
}
override protected function initializeAccessibility():void{
if (LabelButton.createAccessibilityImplementation != null){
LabelButton.createAccessibilityImplementation(this);
};
}
protected function drawIcon():void{
var _local1:DisplayObject;
var _local2:String;
var _local3:Object;
_local1 = icon;
_local2 = (enabled) ? mouseState : "disabled";
if (selected){
_local2 = (("selected" + _local2.substr(0, 1).toUpperCase()) + _local2.substr(1));
};
_local2 = (_local2 + "Icon");
_local3 = getStyleValue(_local2);
if (_local3 == null){
_local3 = getStyleValue("icon");
};
if (_local3 != null){
icon = getDisplayObjectInstance(_local3);
};
if (icon != null){
addChildAt(icon, 1);
};
if (((!((_local1 == null))) && (!((_local1 == icon))))){
removeChild(_local1);
};
}
public function set label(_arg1:String):void{
_label = _arg1;
if (textField.text != _label){
textField.text = _label;
dispatchEvent(new ComponentEvent(ComponentEvent.LABEL_CHANGE));
};
invalidate(InvalidationType.SIZE);
invalidate(InvalidationType.STYLES);
}
protected function drawTextFormat():void{
var _local1:Object;
var _local2:TextFormat;
var _local3:TextFormat;
_local1 = UIComponent.getStyleDefinition();
_local2 = (enabled) ? (_local1.defaultTextFormat as TextFormat) : (_local1.defaultDisabledTextFormat as TextFormat);
textField.setTextFormat(_local2);
_local3 = (getStyleValue((enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (_local3 != null){
textField.setTextFormat(_local3);
} else {
_local3 = _local2;
};
textField.defaultTextFormat = _local3;
setEmbedFont();
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, BaseButton.getStyleDefinition()));
}
}
}//package fl.controls
Section 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.utils.*;
import fl.events.*;
import flash.text.*;
import flash.system.*;
public class UIComponent extends Sprite {
protected var _enabled:Boolean;// = true
private var _mouseFocusEnabled:Boolean;// = true
protected var startHeight:Number;
protected var _height:Number;
protected var _oldIMEMode:String;// = null
protected var startWidth:Number;
public var focusTarget:IFocusManagerComponent;
protected var errorCaught:Boolean;// = false
protected var uiFocusRect:DisplayObject;
protected var _width:Number;
public var version:String;// = "3.0.0.15"
protected var isFocused:Boolean;// = false
protected var callLaterMethods:Dictionary;
private var _focusEnabled:Boolean;// = true
private var tempText:TextField;
protected var invalidateFlag:Boolean;// = false
protected var _inspector:Boolean;// = false
protected var sharedStyles:Object;
protected var invalidHash:Object;
protected var isLivePreview:Boolean;// = false
protected var _imeMode:String;// = null
protected var instanceStyles:Object;
protected var _x:Number;
protected var _y:Number;
public static var inCallLaterPhase:Boolean = false;
private static var defaultStyles:Object = {focusRectSkin:"focusRectSkin", focusRectPadding:2, textFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), disabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultTextFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultDisabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0)};
public static var createAccessibilityImplementation:Function;
private static var focusManagers:Dictionary = new Dictionary(false);
public function UIComponent(){
version = "3.0.0.15";
isLivePreview = false;
invalidateFlag = false;
_enabled = true;
isFocused = false;
_focusEnabled = true;
_mouseFocusEnabled = true;
_imeMode = null;
_oldIMEMode = null;
errorCaught = false;
_inspector = false;
super();
instanceStyles = {};
sharedStyles = {};
invalidHash = {};
callLaterMethods = new Dictionary();
StyleManager.registerInstance(this);
configUI();
invalidate(InvalidationType.ALL);
tabEnabled = (this is IFocusManagerComponent);
focusRect = false;
if (tabEnabled){
addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
};
initializeFocusManager();
addEventListener(Event.ENTER_FRAME, hookAccessibility, false, 0, true);
}
public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
isFocused = _arg1;
if (((!((uiFocusRect == null))) && (contains(uiFocusRect)))){
removeChild(uiFocusRect);
uiFocusRect = null;
};
if (_arg1){
uiFocusRect = (getDisplayObjectInstance(getStyleValue("focusRectSkin")) as Sprite);
if (uiFocusRect == null){
return;
};
_local2 = Number(getStyleValue("focusRectPadding"));
uiFocusRect.x = -(_local2);
uiFocusRect.y = -(_local2);
uiFocusRect.width = (width + (_local2 * 2));
uiFocusRect.height = (height + (_local2 * 2));
addChildAt(uiFocusRect, 0);
};
}
private function callLaterDispatcher(_arg1:Event):void{
var _local2:Dictionary;
var _local3:Object;
if (_arg1.type == Event.ADDED_TO_STAGE){
removeEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher);
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
return;
};
_arg1.target.removeEventListener(Event.RENDER, callLaterDispatcher);
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
return;
};
inCallLaterPhase = true;
_local2 = callLaterMethods;
for (_local3 in _local2) {
_local3();
delete _local2[_local3];
};
inCallLaterPhase = false;
}
private function addedHandler(_arg1:Event):void{
removeEventListener("addedToStage", addedHandler);
initializeFocusManager();
}
protected function getStyleValue(_arg1:String):Object{
return (((instanceStyles[_arg1])==null) ? sharedStyles[_arg1] : instanceStyles[_arg1]);
}
protected function isOurFocus(_arg1:DisplayObject):Boolean{
return ((_arg1 == this));
}
override public function get scaleX():Number{
return ((width / startWidth));
}
override public function get scaleY():Number{
return ((height / startHeight));
}
override public function set height(_arg1:Number):void{
if (_height == _arg1){
return;
};
setSize(width, _arg1);
}
protected function keyDownHandler(_arg1:KeyboardEvent):void{
}
protected function focusInHandler(_arg1:FocusEvent):void{
var _local2:IFocusManager;
if (isOurFocus((_arg1.target as DisplayObject))){
_local2 = focusManager;
if (((_local2) && (_local2.showFocusIndicator))){
drawFocus(true);
isFocused = true;
};
};
}
public function setStyle(_arg1:String, _arg2:Object):void{
if ((((instanceStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
instanceStyles[_arg1] = _arg2;
invalidate(InvalidationType.STYLES);
}
override public function get visible():Boolean{
return (super.visible);
}
public function get componentInspectorSetting():Boolean{
return (_inspector);
}
override public function get x():Number{
return ((isNaN(_x)) ? super.x : _x);
}
override public function get y():Number{
return ((isNaN(_y)) ? super.y : _y);
}
protected function setIMEMode(_arg1:Boolean){
var enabled = _arg1;
if (_imeMode != null){
if (enabled){
IME.enabled = true;
_oldIMEMode = IME.conversionMode;
try {
if (((!(errorCaught)) && (!((IME.conversionMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _imeMode;
};
errorCaught = false;
} catch(e:Error) {
errorCaught = true;
throw (new Error(("IME mode not supported: " + _imeMode)));
};
} else {
if (((!((IME.conversionMode == IMEConversionMode.UNKNOWN))) && (!((_oldIMEMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _oldIMEMode;
};
IME.enabled = false;
};
};
}
public function set enabled(_arg1:Boolean):void{
if (_arg1 == _enabled){
return;
};
_enabled = _arg1;
invalidate(InvalidationType.STATE);
}
public function setSharedStyle(_arg1:String, _arg2:Object):void{
if ((((sharedStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
sharedStyles[_arg1] = _arg2;
if (instanceStyles[_arg1] == null){
invalidate(InvalidationType.STYLES);
};
}
protected function keyUpHandler(_arg1:KeyboardEvent):void{
}
public function set focusEnabled(_arg1:Boolean):void{
_focusEnabled = _arg1;
}
override public function set scaleX(_arg1:Number):void{
setSize((startWidth * _arg1), height);
}
public function get mouseFocusEnabled():Boolean{
return (_mouseFocusEnabled);
}
override public function set scaleY(_arg1:Number):void{
setSize(width, (startHeight * _arg1));
}
protected function getDisplayObjectInstance(_arg1:Object):DisplayObject{
var classDef:Object;
var skin = _arg1;
classDef = null;
if ((skin is Class)){
return ((new (skin) as DisplayObject));
};
if ((skin is DisplayObject)){
(skin as DisplayObject).x = 0;
(skin as DisplayObject).y = 0;
return ((skin as DisplayObject));
};
try {
classDef = getDefinitionByName(skin.toString());
} catch(e:Error) {
try {
classDef = (loaderInfo.applicationDomain.getDefinition(skin.toString()) as Object);
} catch(e:Error) {
};
};
if (classDef == null){
return (null);
};
return ((new (classDef) as DisplayObject));
}
protected function copyStylesToChild(_arg1:UIComponent, _arg2:Object):void{
var _local3:String;
for (_local3 in _arg2) {
_arg1.setStyle(_local3, getStyleValue(_arg2[_local3]));
};
}
protected function beforeComponentParameters():void{
}
protected function callLater(_arg1:Function):void{
if (inCallLaterPhase){
return;
};
callLaterMethods[_arg1] = true;
if (stage != null){
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
} else {
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
};
}
protected function createFocusManager():void{
if (focusManagers[stage] == null){
focusManagers[stage] = new FocusManager(stage);
};
}
override public function set visible(_arg1:Boolean):void{
var _local2:String;
if (super.visible == _arg1){
return;
};
super.visible = _arg1;
_local2 = (_arg1) ? ComponentEvent.SHOW : ComponentEvent.HIDE;
dispatchEvent(new ComponentEvent(_local2, true));
}
protected function hookAccessibility(_arg1:Event):void{
removeEventListener(Event.ENTER_FRAME, hookAccessibility);
initializeAccessibility();
}
public function set componentInspectorSetting(_arg1:Boolean):void{
_inspector = _arg1;
if (_inspector){
beforeComponentParameters();
} else {
afterComponentParameters();
};
}
override public function set x(_arg1:Number):void{
move(_arg1, _y);
}
public function drawNow():void{
draw();
}
override public function set y(_arg1:Number):void{
move(_x, _arg1);
}
protected function checkLivePreview():Boolean{
var className:String;
if (parent == null){
return (false);
};
try {
className = getQualifiedClassName(parent);
} catch(e:Error) {
};
return ((className == "fl.livepreview::LivePreviewParent"));
}
protected function focusOutHandler(_arg1:FocusEvent):void{
if (isOurFocus((_arg1.target as DisplayObject))){
drawFocus(false);
isFocused = false;
};
}
public function set mouseFocusEnabled(_arg1:Boolean):void{
_mouseFocusEnabled = _arg1;
}
public function getFocus():InteractiveObject{
if (stage){
return (stage.focus);
};
return (null);
}
protected function validate():void{
invalidHash = {};
}
override public function get height():Number{
return (_height);
}
public function invalidate(_arg1:String="all", _arg2:Boolean=true):void{
invalidHash[_arg1] = true;
if (_arg2){
this.callLater(draw);
};
}
public function get enabled():Boolean{
return (_enabled);
}
protected function getScaleX():Number{
return (super.scaleX);
}
protected function getScaleY():Number{
return (super.scaleY);
}
public function get focusEnabled():Boolean{
return (_focusEnabled);
}
protected function afterComponentParameters():void{
}
protected function draw():void{
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
protected function configUI():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
isLivePreview = checkLivePreview();
_local1 = rotation;
rotation = 0;
_local2 = super.width;
_local3 = super.height;
var _local4 = 1;
super.scaleY = _local4;
super.scaleX = _local4;
setSize(_local2, _local3);
move(super.x, super.y);
rotation = _local1;
startWidth = _local2;
startHeight = _local3;
if (numChildren > 0){
removeChildAt(0);
};
}
protected function setScaleX(_arg1:Number):void{
super.scaleX = _arg1;
}
protected function setScaleY(_arg1:Number):void{
super.scaleY = _arg1;
}
private function initializeFocusManager():void{
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, addedHandler, false, 0, true);
} else {
createFocusManager();
};
}
public function set focusManager(_arg1:IFocusManager):void{
UIComponent.focusManagers[this] = _arg1;
}
public function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
protected function isInvalid(_arg1:String, ... _args):Boolean{
if (((invalidHash[_arg1]) || (invalidHash[InvalidationType.ALL]))){
return (true);
};
while (_args.length > 0) {
if (invalidHash[_args.pop()]){
return (true);
};
};
return (false);
}
public function setSize(_arg1:Number, _arg2:Number):void{
_width = _arg1;
_height = _arg2;
invalidate(InvalidationType.SIZE);
dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, false));
}
override public function set width(_arg1:Number):void{
if (_width == _arg1){
return;
};
setSize(_arg1, height);
}
public function setFocus():void{
if (stage){
stage.focus = this;
};
}
protected function initializeAccessibility():void{
if (UIComponent.createAccessibilityImplementation != null){
UIComponent.createAccessibilityImplementation(this);
};
}
public function get focusManager():IFocusManager{
var _local1:DisplayObject;
_local1 = this;
while (_local1) {
if (UIComponent.focusManagers[_local1] != null){
return (IFocusManager(UIComponent.focusManagers[_local1]));
};
_local1 = _local1.parent;
};
return (null);
}
override public function get width():Number{
return (_width);
}
public function move(_arg1:Number, _arg2:Number):void{
_x = _arg1;
_y = _arg2;
super.x = Math.round(_arg1);
super.y = Math.round(_arg2);
dispatchEvent(new ComponentEvent(ComponentEvent.MOVE));
}
public function validateNow():void{
invalidate(InvalidationType.ALL, false);
draw();
}
public function getStyle(_arg1:String):Object{
return (instanceStyles[_arg1]);
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
public static function mergeStyles(... _args):Object{
var _local2:Object;
var _local3:uint;
var _local4:uint;
var _local5:Object;
var _local6:String;
_local2 = {};
_local3 = _args.length;
_local4 = 0;
while (_local4 < _local3) {
_local5 = _args[_local4];
for (_local6 in _local5) {
if (_local2[_local6] != null){
} else {
_local2[_local6] = _args[_local4][_local6];
};
};
_local4++;
};
return (_local2);
}
}
}//package fl.core
Section 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.utils.*;
import flash.text.*;
import flash.ui.*;
public class FocusManager implements IFocusManager {
private var focusableObjects:Dictionary;
private var _showFocusIndicator:Boolean;// = true
private var defButton:Button;
private var focusableCandidates:Array;
private var _form:DisplayObjectContainer;
private var _defaultButtonEnabled:Boolean;// = true
private var activated:Boolean;// = false
private var _defaultButton:Button;
private var calculateCandidates:Boolean;// = true
private var lastFocus:InteractiveObject;
private var lastAction:String;
public function FocusManager(_arg1:DisplayObjectContainer){
activated = false;
calculateCandidates = true;
_showFocusIndicator = true;
_defaultButtonEnabled = true;
super();
focusableObjects = new Dictionary(true);
if (_arg1 != null){
_form = _arg1;
addFocusables(DisplayObject(_arg1));
_arg1.addEventListener(Event.ADDED, addedHandler);
_arg1.addEventListener(Event.REMOVED, removedHandler);
activate();
};
}
public function get showFocusIndicator():Boolean{
return (_showFocusIndicator);
}
private function getIndexOfNextObject(_arg1:int, _arg2:Boolean, _arg3:Boolean, _arg4:String):int{
var _local5:int;
var _local6:int;
var _local7:DisplayObject;
var _local8:IFocusManagerGroup;
var _local9:int;
var _local10:DisplayObject;
var _local11:IFocusManagerGroup;
_local5 = focusableCandidates.length;
_local6 = _arg1;
while (true) {
if (_arg2){
_arg1--;
} else {
_arg1++;
};
if (_arg3){
if (((_arg2) && ((_arg1 < 0)))){
break;
};
if (((!(_arg2)) && ((_arg1 == _local5)))){
break;
};
} else {
_arg1 = ((_arg1 + _local5) % _local5);
if (_local6 == _arg1){
break;
};
};
if (isValidFocusCandidate(focusableCandidates[_arg1], _arg4)){
_local7 = DisplayObject(findFocusManagerComponent(focusableCandidates[_arg1]));
if ((_local7 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local7);
_local9 = 0;
while (_local9 < focusableCandidates.length) {
_local10 = focusableCandidates[_local9];
if ((_local10 is IFocusManagerGroup)){
_local11 = IFocusManagerGroup(_local10);
if ((((_local11.groupName == _local8.groupName)) && (_local11.selected))){
_arg1 = _local9;
break;
};
};
_local9++;
};
};
return (_arg1);
};
};
return (_arg1);
}
public function set form(_arg1:DisplayObjectContainer):void{
_form = _arg1;
}
private function addFocusables(_arg1:DisplayObject, _arg2:Boolean=false):void{
var focusable:IFocusManagerComponent;
var io:InteractiveObject;
var doc:DisplayObjectContainer;
var i:int;
var child:DisplayObject;
var o = _arg1;
var skipTopLevel = _arg2;
if (!skipTopLevel){
if ((o is IFocusManagerComponent)){
focusable = IFocusManagerComponent(o);
if (focusable.focusEnabled){
if (((focusable.tabEnabled) && (isTabVisible(o)))){
focusableObjects[o] = true;
calculateCandidates = true;
};
o.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
o.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
};
} else {
if ((o is InteractiveObject)){
io = (o as InteractiveObject);
if (((((io) && (io.tabEnabled))) && ((findFocusManagerComponent(io) == io)))){
focusableObjects[io] = true;
calculateCandidates = true;
};
io.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
io.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
};
};
};
if ((o is DisplayObjectContainer)){
doc = DisplayObjectContainer(o);
o.addEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
if ((((((doc is Stage)) || ((doc.parent is Stage)))) || (doc.tabChildren))){
i = 0;
while (i < doc.numChildren) {
try {
child = doc.getChildAt(i);
if (child != null){
addFocusables(doc.getChildAt(i));
};
} catch(error:SecurityError) {
};
i = (i + 1);
};
};
};
}
private function getChildIndex(_arg1:DisplayObjectContainer, _arg2:DisplayObject):int{
return (_arg1.getChildIndex(_arg2));
}
private function mouseFocusChangeHandler(_arg1:FocusEvent):void{
if ((_arg1.relatedObject is TextField)){
return;
};
_arg1.preventDefault();
}
private function focusOutHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
_local2 = (_arg1.target as InteractiveObject);
}
private function isValidFocusCandidate(_arg1:DisplayObject, _arg2:String):Boolean{
var _local3:IFocusManagerGroup;
if (!isEnabledAndVisible(_arg1)){
return (false);
};
if ((_arg1 is IFocusManagerGroup)){
_local3 = IFocusManagerGroup(_arg1);
if (_arg2 == _local3.groupName){
return (false);
};
};
return (true);
}
public function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject{
var _local2:InteractiveObject;
_local2 = _arg1;
while (_arg1) {
if ((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
};
return (_local2);
}
private function sortFocusableObjectsTabIndex():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))){
focusableCandidates.push(_local2);
};
};
focusableCandidates.sort(sortByTabIndex);
}
private function removeFocusables(_arg1:DisplayObject):void{
var _local2:Object;
var _local3:DisplayObject;
if ((_arg1 is DisplayObjectContainer)){
_arg1.removeEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
_arg1.removeEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
for (_local2 in focusableObjects) {
_local3 = DisplayObject(_local2);
if (DisplayObjectContainer(_arg1).contains(_local3)){
if (_local3 == lastFocus){
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local2];
calculateCandidates = true;
};
};
};
}
private function addedHandler(_arg1:Event):void{
var _local2:DisplayObject;
_local2 = DisplayObject(_arg1.target);
if (_local2.stage){
addFocusables(DisplayObject(_arg1.target));
};
}
private function getTopLevelFocusTarget(_arg1:InteractiveObject):InteractiveObject{
while (_arg1 != InteractiveObject(form)) {
if ((((((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))) && (IFocusManagerComponent(_arg1).mouseFocusEnabled))) && (UIComponent(_arg1).enabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
if (_arg1 == null){
break;
};
};
return (null);
}
private function tabChildrenChangeHandler(_arg1:Event):void{
var _local2:DisplayObjectContainer;
if (_arg1.target != _arg1.currentTarget){
return;
};
calculateCandidates = true;
_local2 = DisplayObjectContainer(_arg1.target);
if (_local2.tabChildren){
addFocusables(_local2, true);
} else {
removeFocusables(_local2);
};
}
public function sendDefaultButtonEvent():void{
defButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
public function getFocus():InteractiveObject{
var _local1:InteractiveObject;
_local1 = form.stage.focus;
return (findFocusManagerComponent(_local1));
}
private function isEnabledAndVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
var _local3:TextField;
var _local4:SimpleButton;
_local2 = DisplayObject(form).parent;
while (_arg1 != _local2) {
if ((_arg1 is UIComponent)){
if (!UIComponent(_arg1).enabled){
return (false);
};
} else {
if ((_arg1 is TextField)){
_local3 = TextField(_arg1);
if ((((_local3.type == TextFieldType.DYNAMIC)) || (!(_local3.selectable)))){
return (false);
};
} else {
if ((_arg1 is SimpleButton)){
_local4 = SimpleButton(_arg1);
if (!_local4.enabled){
return (false);
};
};
};
};
if (!_arg1.visible){
return (false);
};
_arg1 = _arg1.parent;
};
return (true);
}
public function set defaultButton(_arg1:Button):void{
var _local2:Button;
_local2 = (_arg1) ? Button(_arg1) : null;
if (_local2 != _defaultButton){
if (_defaultButton){
_defaultButton.emphasized = false;
};
if (defButton){
defButton.emphasized = false;
};
_defaultButton = _local2;
defButton = _local2;
if (_local2){
_local2.emphasized = true;
};
};
}
private function deactivateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
}
public function setFocus(_arg1:InteractiveObject):void{
if ((_arg1 is IFocusManagerComponent)){
IFocusManagerComponent(_arg1).setFocus();
} else {
form.stage.focus = _arg1;
};
}
private function setFocusToNextObject(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
if (!hasFocusableObjects()){
return;
};
_local2 = getNextFocusManagerComponent(_arg1.shiftKey);
if (_local2){
setFocus(_local2);
};
}
private function hasFocusableObjects():Boolean{
var _local1:Object;
for (_local1 in focusableObjects) {
return (true);
};
return (false);
}
private function tabIndexChangeHandler(_arg1:Event):void{
calculateCandidates = true;
}
private function sortFocusableObjects():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))) && ((_local2.tabIndex > 0)))){
sortFocusableObjectsTabIndex();
return;
};
focusableCandidates.push(_local2);
};
focusableCandidates.sort(sortByDepth);
}
private function keyFocusChangeHandler(_arg1:FocusEvent):void{
showFocusIndicator = true;
if ((((((_arg1.keyCode == Keyboard.TAB)) || ((_arg1.keyCode == 0)))) && (!(_arg1.isDefaultPrevented())))){
setFocusToNextObject(_arg1);
_arg1.preventDefault();
};
}
private function getIndexOfFocusedObject(_arg1:DisplayObject):int{
var _local2:int;
var _local3:int;
_local2 = focusableCandidates.length;
_local3 = 0;
_local3 = 0;
while (_local3 < _local2) {
if (focusableCandidates[_local3] == _arg1){
return (_local3);
};
_local3++;
};
return (-1);
}
public function hideFocus():void{
}
private function removedHandler(_arg1:Event):void{
var _local2:int;
var _local3:DisplayObject;
var _local4:InteractiveObject;
_local3 = DisplayObject(_arg1.target);
if ((((_local3 is IFocusManagerComponent)) && ((focusableObjects[_local3] == true)))){
if (_local3 == lastFocus){
IFocusManagerComponent(lastFocus).drawFocus(false);
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local3];
calculateCandidates = true;
} else {
if ((((_local3 is InteractiveObject)) && ((focusableObjects[_local3] == true)))){
_local4 = (_local3 as InteractiveObject);
if (_local4){
if (_local4 == lastFocus){
lastFocus = null;
};
delete focusableObjects[_local4];
calculateCandidates = true;
};
_local3.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
};
};
removeFocusables(_local3);
}
private function sortByDepth(_arg1:InteractiveObject, _arg2:InteractiveObject):Number{
var _local3:String;
var _local4:String;
var _local5:int;
var _local6:String;
var _local7:String;
var _local8:String;
var _local9:DisplayObject;
var _local10:DisplayObject;
_local3 = "";
_local4 = "";
_local8 = "0000";
_local9 = DisplayObject(_arg1);
_local10 = DisplayObject(_arg2);
while (((!((_local9 == DisplayObject(form)))) && (_local9.parent))) {
_local5 = getChildIndex(_local9.parent, _local9);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local3 = (_local7 + _local3);
_local9 = _local9.parent;
};
while (((!((_local10 == DisplayObject(form)))) && (_local10.parent))) {
_local5 = getChildIndex(_local10.parent, _local10);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local4 = (_local7 + _local4);
_local10 = _local10.parent;
};
return (((_local3 > _local4)) ? 1 : ((_local3 < _local4)) ? -1 : 0);
}
public function get defaultButton():Button{
return (_defaultButton);
}
private function activateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
if (lastFocus){
if ((lastFocus is IFocusManagerComponent)){
IFocusManagerComponent(lastFocus).setFocus();
} else {
form.stage.focus = lastFocus;
};
};
lastAction = "ACTIVATE";
}
public function showFocus():void{
}
public function set defaultButtonEnabled(_arg1:Boolean):void{
_defaultButtonEnabled = _arg1;
}
public function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject{
var _local2:DisplayObject;
var _local3:String;
var _local4:int;
var _local5:Boolean;
var _local6:int;
var _local7:int;
var _local8:IFocusManagerGroup;
if (!hasFocusableObjects()){
return (null);
};
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
_local2 = form.stage.focus;
_local2 = DisplayObject(findFocusManagerComponent(InteractiveObject(_local2)));
_local3 = "";
if ((_local2 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local2);
_local3 = _local8.groupName;
};
_local4 = getIndexOfFocusedObject(_local2);
_local5 = false;
_local6 = _local4;
if (_local4 == -1){
if (_arg1){
_local4 = focusableCandidates.length;
};
_local5 = true;
};
_local7 = getIndexOfNextObject(_local4, _arg1, _local5, _local3);
return (findFocusManagerComponent(focusableCandidates[_local7]));
}
private function mouseDownHandler(_arg1:MouseEvent):void{
var _local2:InteractiveObject;
if (_arg1.isDefaultPrevented()){
return;
};
_local2 = getTopLevelFocusTarget(InteractiveObject(_arg1.target));
if (!_local2){
return;
};
showFocusIndicator = false;
if (((((!((_local2 == lastFocus))) || ((lastAction == "ACTIVATE")))) && (!((_local2 is TextField))))){
setFocus(_local2);
};
lastAction = "MOUSEDOWN";
}
private function isTabVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
_local2 = _arg1.parent;
while (((((_local2) && (!((_local2 is Stage))))) && (!(((_local2.parent) && ((_local2.parent is Stage))))))) {
if (!_local2.tabChildren){
return (false);
};
_local2 = _local2.parent;
};
return (true);
}
public function get nextTabIndex():int{
return (0);
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.TAB){
lastAction = "KEY";
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
};
if (((((((defaultButtonEnabled) && ((_arg1.keyCode == Keyboard.ENTER)))) && (defaultButton))) && (defButton.enabled))){
sendDefaultButtonEvent();
};
}
private function focusInHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
var _local3:Button;
_local2 = InteractiveObject(_arg1.target);
if (form.contains(_local2)){
lastFocus = findFocusManagerComponent(InteractiveObject(_local2));
if ((lastFocus is Button)){
_local3 = Button(lastFocus);
if (defButton){
defButton.emphasized = false;
defButton = _local3;
_local3.emphasized = true;
};
} else {
if (((defButton) && (!((defButton == _defaultButton))))){
defButton.emphasized = false;
defButton = _defaultButton;
_defaultButton.emphasized = true;
};
};
};
}
private function tabEnabledChangeHandler(_arg1:Event):void{
var _local2:InteractiveObject;
var _local3:Boolean;
calculateCandidates = true;
_local2 = InteractiveObject(_arg1.target);
_local3 = (focusableObjects[_local2] == true);
if (_local2.tabEnabled){
if (((!(_local3)) && (isTabVisible(_local2)))){
if (!(_local2 is IFocusManagerComponent)){
_local2.focusRect = false;
};
focusableObjects[_local2] = true;
};
} else {
if (_local3){
delete focusableObjects[_local2];
};
};
}
public function set showFocusIndicator(_arg1:Boolean):void{
_showFocusIndicator = _arg1;
}
public function get form():DisplayObjectContainer{
return (_form);
}
private function sortByTabIndex(_arg1:InteractiveObject, _arg2:InteractiveObject):int{
return (((_arg1.tabIndex > _arg2.tabIndex)) ? 1 : ((_arg1.tabIndex < _arg2.tabIndex)) ? -1 : sortByDepth(_arg1, _arg2));
}
public function activate():void{
if (activated){
return;
};
form.stage.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler, false, 0, true);
form.stage.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler, false, 0, true);
form.addEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.addEventListener(Event.ACTIVATE, activateHandler, false, 0, true);
form.stage.addEventListener(Event.DEACTIVATE, deactivateHandler, false, 0, true);
form.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = true;
if (lastFocus){
setFocus(lastFocus);
};
}
public function deactivate():void{
form.stage.removeEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler);
form.stage.removeEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler);
form.removeEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.removeEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.removeEventListener(Event.ACTIVATE, activateHandler);
form.stage.removeEventListener(Event.DEACTIVATE, deactivateHandler);
form.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = false;
}
public function get defaultButtonEnabled():Boolean{
return (_defaultButtonEnabled);
}
}
}//package fl.managers
Section 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.utils.*;
import flash.text.*;
public class StyleManager {
private var globalStyles:Object;
private var classToDefaultStylesDict:Dictionary;
private var styleToClassesHash:Object;
private var classToStylesDict:Dictionary;
private var classToInstancesDict:Dictionary;
private static var _instance:StyleManager;
public function StyleManager(){
styleToClassesHash = {};
classToInstancesDict = new Dictionary(true);
classToStylesDict = new Dictionary(true);
classToDefaultStylesDict = new Dictionary(true);
globalStyles = UIComponent.getStyleDefinition();
}
public static function clearComponentStyle(_arg1:Object, _arg2:String):void{
var _local3:Class;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
if (((!((_local4 == null))) && (!((_local4[_arg2] == null))))){
delete _local4[_arg2];
invalidateComponentStyle(_local3, _arg2);
};
}
private static function getClassDef(_arg1:Object):Class{
var component = _arg1;
if ((component is Class)){
return ((component as Class));
};
try {
return ((getDefinitionByName(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
if ((component is UIComponent)){
try {
return ((component.loaderInfo.applicationDomain.getDefinition(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
};
};
};
return (null);
}
public static function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
public static function setComponentStyle(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Class;
var _local5:Object;
_local4 = getClassDef(_arg1);
_local5 = getInstance().classToStylesDict[_local4];
if (_local5 == null){
_local5 = (getInstance().classToStylesDict[_local4] = {});
};
if (_local5 == _arg3){
return;
};
_local5[_arg2] = _arg3;
invalidateComponentStyle(_local4, _arg2);
}
private static function setSharedStyles(_arg1:UIComponent):void{
var _local2:StyleManager;
var _local3:Class;
var _local4:Object;
var _local5:String;
_local2 = getInstance();
_local3 = getClassDef(_arg1);
_local4 = _local2.classToDefaultStylesDict[_local3];
for (_local5 in _local4) {
_arg1.setSharedStyle(_local5, getSharedStyle(_arg1, _local5));
};
}
public static function getComponentStyle(_arg1:Object, _arg2:String):Object{
var _local3:Class;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
return (((_local4)==null) ? null : _local4[_arg2]);
}
private static function getInstance(){
if (_instance == null){
_instance = new (StyleManager);
};
return (_instance);
}
private static function invalidateComponentStyle(_arg1:Class, _arg2:String):void{
var _local3:Dictionary;
var _local4:Object;
var _local5:UIComponent;
_local3 = getInstance().classToInstancesDict[_arg1];
if (_local3 == null){
return;
};
for (_local4 in _local3) {
_local5 = (_local4 as UIComponent);
if (_local5 == null){
} else {
_local5.setSharedStyle(_arg2, getSharedStyle(_local5, _arg2));
};
};
}
private static function invalidateStyle(_arg1:String):void{
var _local2:Dictionary;
var _local3:Object;
_local2 = getInstance().styleToClassesHash[_arg1];
if (_local2 == null){
return;
};
for (_local3 in _local2) {
invalidateComponentStyle(Class(_local3), _arg1);
};
}
public static function registerInstance(_arg1:UIComponent):void{
var inst:StyleManager;
var classDef:Class;
var target:Class;
var defaultStyles:Object;
var styleToClasses:Object;
var n:String;
var instance = _arg1;
inst = getInstance();
classDef = getClassDef(instance);
if (classDef == null){
return;
};
if (inst.classToInstancesDict[classDef] == null){
inst.classToInstancesDict[classDef] = new Dictionary(true);
target = classDef;
while (defaultStyles == null) {
if (target["getStyleDefinition"] != null){
defaultStyles = target["getStyleDefinition"]();
break;
};
try {
target = (instance.loaderInfo.applicationDomain.getDefinition(getQualifiedSuperclassName(target)) as Class);
} catch(err:Error) {
try {
target = (getDefinitionByName(getQualifiedSuperclassName(target)) as Class);
} catch(e:Error) {
defaultStyles = UIComponent.getStyleDefinition();
break;
};
};
};
styleToClasses = inst.styleToClassesHash;
for (n in defaultStyles) {
if (styleToClasses[n] == null){
styleToClasses[n] = new Dictionary(true);
};
styleToClasses[n][classDef] = true;
};
inst.classToDefaultStylesDict[classDef] = defaultStyles;
inst.classToStylesDict[classDef] = {};
};
inst.classToInstancesDict[classDef][instance] = true;
setSharedStyles(instance);
}
public static function getStyle(_arg1:String):Object{
return (getInstance().globalStyles[_arg1]);
}
private static function getSharedStyle(_arg1:UIComponent, _arg2:String):Object{
var _local3:Class;
var _local4:StyleManager;
var _local5:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance();
_local5 = _local4.classToStylesDict[_local3][_arg2];
if (_local5 != null){
return (_local5);
};
_local5 = _local4.globalStyles[_arg2];
if (_local5 != null){
return (_local5);
};
return (_local4.classToDefaultStylesDict[_local3][_arg2]);
}
public static function setStyle(_arg1:String, _arg2:Object):void{
var _local3:Object;
_local3 = getInstance().globalStyles;
if ((((_local3[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
_local3[_arg1] = _arg2;
invalidateStyle(_arg1);
}
}
}//package fl.managers
Section 15
//Regular (fl.transitions.easing.Regular)
package fl.transitions.easing {
public class Regular {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((((-(_arg3) * _arg1) * (_arg1 - 2)) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((((_arg3 * _arg1) * _arg1) + _arg2));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return (((((_arg3 / 2) * _arg1) * _arg1) + _arg2));
};
--_arg1;
return ((((-(_arg3) / 2) * ((_arg1 * (_arg1 - 2)) - 1)) + _arg2));
}
}
}//package fl.transitions.easing
Section 16
//AbsorbWaterMinerals (AbsorbWaterMinerals)
package {
public dynamic class AbsorbWaterMinerals extends GreyButton {
}
}//package
Section 17
//AddDialog (AddDialog)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class AddDialog extends MovieClip {
public var chosenElement:Number;
public var cancelButton:CancelButton;
public var theController:Controller;
private var dotLength:Number;// = 95
private var tabWidth:Number;// = 300
private var beingShown:Boolean;
private var tabList:Array;
public var dottedLine:MovieClip;
private var meristemHeight:Number;// = 16
public static var CANCELCLICKED = "CANCELCLICKED";
public static var ADDCLICKED = "ADDCLICKED";
public function AddDialog(_arg1:Controller){
tabList = new Array();
visible = false;
beingShown = false;
theController = _arg1;
addEventListener(AddDialog.ADDCLICKED, theController.doGrow);
addEventListener(AddDialog.CANCELCLICKED, theController.removeDialog);
cancelButton.addEventListener(MouseEvent.CLICK, cancelClicked);
}
public function cancelClicked(_arg1:Event){
hide();
dispatchEvent(new Event(AddDialog.CANCELCLICKED));
}
public function hide(){
beingShown = false;
removeTabs();
visible = false;
}
public function addClicked(_arg1:Event){
chosenElement = removeTabs();
visible = false;
dispatchEvent(new Event(AddDialog.ADDCLICKED));
}
public function removeTabs():Number{
var _local2:int;
var _local1:Number = -1;
while (tabList.length > 0) {
_local2 = (tabList.length - 1);
if (tabList[_local2].selected){
_local1 = _local2;
};
removeChild(tabList[_local2]);
tabList.pop();
};
return (_local1);
}
public function show(_arg1:Number, _arg2:Number, _arg3:Array, _arg4:Number, _arg5:Number){
var _local7:Number;
var _local9:AddTab;
if (beingShown){
hide();
};
beingShown = true;
var _local6:Number = 0;
visible = true;
_arg2 = (_arg2 - (meristemHeight / 2));
x = _arg1;
y = _arg2;
if (((_arg1 + dotLength) + tabWidth) > 1000){
x = (_arg1 - (dotLength + tabWidth));
cancelButton.x = 0;
dottedLine.x = tabWidth;
_local7 = 0;
} else {
_local7 = dotLength;
dottedLine.x = 0;
x = _arg1;
cancelButton.x = (dotLength + tabWidth);
};
var _local8:* = 0;
while (_local8 < _arg3.length) {
_local9 = new AddTab(this);
_local9.show(_local7, _local6, _arg3[_local8].elementType, _arg3[_local8].costSugar, _arg3[_local8].costMinerals, _arg4, _arg5);
tabList.push(_local9);
addChild(_local9);
_local6 = (_local6 + _local9.tabHeight);
_local8++;
};
if (getChildIndex(cancelButton) < getChildIndex(tabList[0])){
swapChildren(cancelButton, tabList[0]);
};
}
}
}//package
Section 18
//AddTab (AddTab)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class AddTab extends MovieClip {
public var needSugar:TextField;
public var addButton:GrowButton;
public var mineralBar:TabDisplay;
private var tabList:Array;
public var theDialog:AddDialog;
public var newItem:TextField;
public var selected:Boolean;// = false
public var tabHeight:Number;// = 36
private var buttonLabel:Object;
private var newLabel:Object;
public var sugarBar:TabDisplay;
public var needMinerals:TextField;
public function AddTab(_arg1:AddDialog){
newLabel = {Root:"NEW ROOT", Leaf:"NEW LEAF", Stem:"GROW STEM", Flower:"NEW FLOWER", BigSeed:"GROW LARGER", FallOff:"EJECT SEED"};
buttonLabel = {Root:"Grow", Leaf:"Grow", Stem:"Grow", Flower:"Grow", BigSeed:"Grow", FallOff:"Fall"};
super();
theDialog = _arg1;
addEventListener(AddDialog.ADDCLICKED, _arg1.addClicked);
selected = false;
}
private function addClicked(_arg1:Event){
selected = true;
dispatchEvent(new Event(AddDialog.ADDCLICKED));
}
public function show(_arg1:Number, _arg2:Number, _arg3:String, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number){
x = _arg1;
y = _arg2;
newItem.text = newLabel[_arg3];
addButton.label.text = buttonLabel[_arg3];
sugarBar.set(_arg4, "Sugar", false, false, false);
mineralBar.set(_arg5, "Minerals", false, false, false);
needSugar.visible = false;
needMinerals.visible = false;
if ((((_arg4 > _arg6)) || ((_arg5 > _arg7)))){
addButton.visible = false;
addButton.removeEventListener(MouseEvent.CLICK, addClicked);
if (_arg4 > _arg6){
needSugar.visible = true;
} else {
needMinerals.visible = true;
};
} else {
addButton.visible = true;
addButton.setEnabled(true);
addButton.addEventListener(MouseEvent.CLICK, addClicked);
};
}
private function cancelClicked(_arg1:Event){
dispatchEvent(new Event(AddDialog.CANCELCLICKED));
}
}
}//package
Section 19
//BarDisplay (BarDisplay)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.utils.*;
import flash.text.*;
public class BarDisplay extends MovieClip {
private var valueChange:Number;
private var maxWidth;// = 204
private var lightHighlight:Number;// = 0xD6D6D6
private var marks:Array;
private var colourScheme:Object;
private var colour:Number;
private var icons:Object;
private var barValue:Number;
private var highlightColour:Number;
private var animateTimer:Timer;
private var darkHighlight:Number;// = 13089
private var newValue:Number;
private var lastValue:Number;
public var valueText:TextField;
public function BarDisplay(){
colourScheme = {Sugar:16082193, Minerals:4217696, DarkMinerals:5404538, Carbon:5151046, Sunlight:15643663, Water:4427941};
icons = {Sugar:"sugarIcon", Minerals:"mineralIcon", Carbon:"carbonIcon", Sunlight:"sunlightIcon", Water:"waterIcon"};
super();
marks = new Array();
animateTimer = new Timer(40, 0);
animateTimer.addEventListener(TimerEvent.TIMER, animateText);
lastValue = 0;
}
public function removeMarks(){
graphics.clear();
while (marks.length > 0) {
removeChild(marks.pop());
};
}
public function animateText(_arg1:TimerEvent){
lastValue = (lastValue + valueChange);
if (Math.abs((lastValue - newValue)) <= 1){
lastValue = newValue;
animateTimer.stop();
};
setValue(lastValue);
}
private function setValue(_arg1:Number){
_arg1 = Math.round(_arg1);
valueText.text = String(_arg1);
}
public function set(_arg1:Number, _arg2:String, _arg3:Boolean, _arg4:Boolean, _arg5:Boolean=true){
var _local6:*;
var _local7:ColorTransform;
var _local8:MovieClip;
colour = colourScheme[_arg2];
newValue = _arg1;
highlightColour = 0xFFFFFF;
valueText.textColor = colour;
if (((!((lastValue == newValue))) && (_arg4))){
valueChange = ((newValue - lastValue) / 25);
if ((((valueChange < 0)) && ((valueChange > -1)))){
valueChange = -1;
};
if ((((valueChange > 0)) && ((valueChange < 1)))){
valueChange = 1;
};
animateTimer.start();
} else {
lastValue = newValue;
setValue(newValue);
};
}
}
}//package
Section 20
//BarDisplayMark (BarDisplayMark)
package {
import flash.display.*;
public dynamic class BarDisplayMark extends MovieClip {
}
}//package
Section 21
//Bee (Bee)
package {
public dynamic class Bee extends Insect {
}
}//package
Section 22
//BeeSound (BeeSound)
package {
import flash.media.*;
public dynamic class BeeSound extends Sound {
}
}//package
Section 23
//Beetle (Beetle)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.utils.*;
public class Beetle extends MovieClip {
public var eaten:MovieClip;
public var dead:MovieClip;
public var speed:Number;// = 6
public var animateTimer:Timer;
public var alive:MovieClip;
public var targetPoint:Point;
public static var FOUNDTARGET:String = "found target";
public function Beetle(_arg1:Boolean){
y = (130 + (Math.random() * 50));
if (_arg1){
x = -500;
speed = 8;
targetPoint = new Point((Math.random() * 30), y);
} else {
x = (0x0400 - 500);
speed = -8;
scaleX = -1;
targetPoint = new Point((50 + (Math.random() * 30)), y);
};
animateTimer = new Timer(40, 0);
animateTimer.addEventListener(TimerEvent.TIMER, animate);
}
public function start(_arg1:Function){
alive.visible = true;
dead.visible = false;
eaten.visible = false;
addEventListener(FOUNDTARGET, _arg1);
animateTimer.start();
}
public function animate(_arg1:Event){
x = (x + speed);
if (Point.distance(targetPoint, new Point(x, y)) < Math.abs((speed * 6))){
foundTarget();
};
}
public function foundTarget(){
x = targetPoint.x;
y = targetPoint.y;
alive.visible = false;
dead.visible = true;
animateTimer.stop();
dispatchEvent(new Event(FOUNDTARGET));
}
public function foundByRoot(){
eaten.visible = true;
dead.visible = true;
}
}
}//package
Section 24
//BigSeed (BigSeed)
package {
import flash.display.*;
import flash.geom.*;
public class BigSeed extends PlantElement {
public var arrow1:MovieClip;
public var node1:Meristem;
public function BigSeed(_arg1:Sprite, _arg2:Controller, _arg3:Point){
super(_arg1, _arg2, _arg3);
nodeCount = 1;
elementType = "BigSeed";
initNodes([["FallOff"]], 0);
}
override public function setRotation(_arg1:Number){
rotation = 0;
if (parentElement.rotation < 0){
scaleX = 1;
} else {
scaleX = -1;
};
}
override public function checkNode(_arg1){
return (true);
}
}
}//package
Section 25
//Button_disabledSkin (Button_disabledSkin)
package {
import flash.display.*;
public dynamic class Button_disabledSkin extends MovieClip {
}
}//package
Section 26
//Button_downSkin (Button_downSkin)
package {
import flash.display.*;
public dynamic class Button_downSkin extends MovieClip {
}
}//package
Section 27
//Button_emphasizedSkin (Button_emphasizedSkin)
package {
import flash.display.*;
public dynamic class Button_emphasizedSkin extends MovieClip {
}
}//package
Section 28
//Button_overSkin (Button_overSkin)
package {
import flash.display.*;
public dynamic class Button_overSkin extends MovieClip {
}
}//package
Section 29
//Button_selectedDisabledSkin (Button_selectedDisabledSkin)
package {
import flash.display.*;
public dynamic class Button_selectedDisabledSkin extends MovieClip {
}
}//package
Section 30
//Button_selectedDownSkin (Button_selectedDownSkin)
package {
import flash.display.*;
public dynamic class Button_selectedDownSkin extends MovieClip {
}
}//package
Section 31
//Button_selectedOverSkin (Button_selectedOverSkin)
package {
import flash.display.*;
public dynamic class Button_selectedOverSkin extends MovieClip {
}
}//package
Section 32
//Button_selectedUpSkin (Button_selectedUpSkin)
package {
import flash.display.*;
public dynamic class Button_selectedUpSkin extends MovieClip {
}
}//package
Section 33
//Button_upSkin (Button_upSkin)
package {
import flash.display.*;
public dynamic class Button_upSkin extends MovieClip {
}
}//package
Section 34
//ButtonClick (ButtonClick)
package {
import flash.media.*;
public dynamic class ButtonClick extends Sound {
}
}//package
Section 35
//CancelButton (CancelButton)
package {
public dynamic class CancelButton extends GreyButton {
}
}//package
Section 36
//carbonIcon (carbonIcon)
package {
import flash.display.*;
public dynamic class carbonIcon extends MovieClip {
}
}//package
Section 37
//ChompSound (ChompSound)
package {
import flash.media.*;
public dynamic class ChompSound extends Sound {
}
}//package
Section 38
//Container (Container)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.utils.*;
public class Container extends Sprite {
private var topScroll;
private var scrollTop:Boolean;
private var boxPos;// = 300
private var plantSprite:Sprite;
private var scrollBack:Boolean;
private var bottomScroll:Sprite;
private var overBottom:Boolean;
private var overTop:Boolean;
private var offsetY:Number;
public var scrollSprite:Sprite;
private var scrollEnabled:Boolean;// = false
private var scrollTimer:Timer;
public static var SCROLL_RESET:String = "scroll reset";
public function Container(){
scrollSprite = new Sprite();
scrollTimer = new Timer(40, 0);
scrollTimer.addEventListener(TimerEvent.TIMER, onScroll);
scrollTimer.start();
makeScrollAreas();
}
public function getScrollAreas():Sprite{
return (scrollSprite);
}
public function setScrollAreas(_arg1:Sprite, _arg2:Number){
plantSprite = _arg1;
offsetY = _arg2;
overTop = false;
overBottom = false;
scrollBack = false;
}
public function scrollToTop(){
scrollTop = true;
}
public function onScroll(_arg1:Event){
var _local2:Rectangle;
if (scrollBack){
if (y > 0){
y = (y - 10);
scrollSprite.y = -(y);
} else {
scrollBack = false;
dispatchEvent(new Event(SCROLL_RESET));
};
};
if (scrollTop){
_local2 = plantSprite.getBounds(this);
if ((y + _local2.top) < offsetY){
y = (y + 10);
scrollSprite.y = -(y);
} else {
scrollTop = false;
};
};
if (scrollEnabled){
if (overTop){
_local2 = plantSprite.getBounds(this);
if ((y + _local2.top) < offsetY){
y = (y + 10);
scrollSprite.y = -(y);
};
};
if (overBottom){
if (y > 0){
y = (y - 10);
scrollSprite.y = -(y);
};
};
};
}
public function removeScrollAreas(){
if (contains(scrollSprite)){
removeChild(scrollSprite);
};
}
public function onOverTop(_arg1:MouseEvent){
overTop = true;
}
private function makeScrollBox(_arg1:Function, _arg2:Function):Sprite{
var _local3:* = new Sprite();
_local3.graphics.beginFill(0xFF0000, 0);
_local3.graphics.drawRect(0, 0, 0x0400, 100);
_local3.graphics.endFill();
_local3.addEventListener(MouseEvent.MOUSE_OVER, _arg1);
_local3.addEventListener(MouseEvent.MOUSE_OUT, _arg2);
return (_local3);
}
public function onOverBottom(_arg1:MouseEvent){
overBottom = true;
}
public function makeScrollAreas(){
topScroll = makeScrollBox(onOverTop, onOutTop);
scrollSprite.addChild(topScroll);
bottomScroll = makeScrollBox(onOverBottom, onOutBottom);
topScroll.height = 200;
bottomScroll.y = 678;
scrollSprite.addChild(bottomScroll);
}
public function onOutTop(_arg1:MouseEvent){
overTop = false;
}
public function onOutBottom(_arg1:MouseEvent){
overBottom = false;
}
public function resetScroll(){
scrollBack = true;
}
public function initScroll(){
y = 0;
scrollSprite.y = 0;
}
public function enableScroll(_arg1:Boolean){
scrollEnabled = _arg1;
}
}
}//package
Section 39
//Controller (Controller)
package {
import fl.controls.*;
import flash.events.*;
import flash.geom.*;
import flash.media.*;
public class Controller extends EventDispatcher {
private var removeList:Array;
public var newGrowth:Object;
private var addDialog:AddDialog;
private var eventList:Array;
private var events:Object;
private var currentEvent:Number;
private var toBeRemoved:Number;
public var resetButton:Button;
private var theView:View;
private var theModel:Model;
public var elementList:Array;
private var ejectSound:Sound;
public static var REMOVE_ELEMENT:String = "remove element";
public static var DONEGROW:String = "doneGrow";
public static var CANCELGROW:String = "cancelGrow";
public function Controller(){
eventList = ["Pollinate", "Bugs", "Irrigation", "Insecticide", "ResetScroll", "Beetles", "Weeding", "Weather", "Nutrients"];
super();
ejectSound = new EjectSeedSound();
}
public function elementGrowFinished(_arg1:Event){
trace("controller knows element has done animating");
theView.plantChanged();
}
public function growAllSeeds(_arg1:Array){
var _local2:Number = 0;
var _local3:* = 0;
while (_local3 < _arg1.length) {
if (_arg1[_local3].elementType == "Seed"){
growSeed(_arg1[_local3]);
_local2++;
};
_local3++;
};
theModel.useResource((_local2 * 10), (_local2 * 10));
theView.plantChanged();
}
public function stemOk(_arg1:PlantElement, _arg2:Point):Boolean{
return (theView.testStem(_arg1, _arg2));
}
public function stopEvents(){
currentEvent = (eventList.length + 1);
}
public function growNew(_arg1:Point, _arg2:Number, _arg3:Array, _arg4:PlantElement, _arg5:Meristem){
dispatchEvent(new Event(View.RESETTIMEOUT));
theView.hideInfo();
newGrowth.rotation = _arg2;
newGrowth.newPos = _arg1;
newGrowth.growElement = _arg4;
newGrowth.growNode = _arg5;
elementList = _arg3;
var _local6:Point = theView.plantSprite.localToGlobal(_arg1);
addDialog.show(_local6.x, _local6.y, elementList, theModel.sugar, theModel.minerals);
}
public function removeSeed(_arg1:Event){
var _local2:*;
toBeRemoved--;
if (toBeRemoved <= 0){
theModel.useResource((removeList.length * 2), (removeList.length * 2));
_local2 = 0;
while (_local2 < removeList.length) {
removeList[_local2].removeEventListener(Controller.REMOVE_ELEMENT, removeElement);
theView.removeElement(removeList[_local2]);
_local2++;
};
removeList = [];
dispatchEvent(new Event(Controller.DONEGROW));
theView.plantChanged();
};
}
public function doGrow(_arg1:Event){
var _local2:Number;
dispatchEvent(new Event(View.RESETTIMEOUT));
var _local3:Object = elementList[addDialog.chosenElement];
newGrowth.elementType = _local3.elementType;
if (_local3.elementType != "FallOff"){
dispatchEvent(new Event(Controller.DONEGROW));
theModel.useResource(_local3.costSugar, _local3.costMinerals);
};
switch (_local3.elementType){
case "BigSeed":
if ((((((((theModel.growThisMonth == 2)) && ((theModel.growth.seeds > 1)))) && (((theModel.minerals / 10) > theModel.growth.seeds)))) && (((theModel.sugar / 10) > theModel.growth.seeds)))){
theView.askAllSeeds(false);
} else {
growSeed(newGrowth.growElement);
if (!theModel.growMessage){
theView.theContainer.resetScroll();
if (theModel.plantType == "Wild"){
theView.showInfo("Bad move", "As a wild plant you don't need to make big seeds, small ones will do.");
} else {
theView.showInfo("Great!", "The farmer prefers big seeds, so make as many as you can");
};
theModel.growMessage = true;
};
theView.plantChanged();
};
break;
case "FallOff":
theView.displayAllNodes(false);
_local2 = (theModel.growth.seeds + theModel.growth.bigSeeds);
if ((((((((theModel.ejectThisMonth == 2)) && ((_local2 > 1)))) && (((theModel.minerals / 2) > _local2)))) && (((theModel.sugar / 2) > _local2)))){
theView.askAllSeeds(true);
} else {
ejectSeed(newGrowth.growElement);
if (!theModel.ejectMessage){
theView.theContainer.resetScroll();
if (theModel.plantType == "Wild"){
theView.showInfo("Great!", "As a wild plant you need to eject as many seeds as possible.");
} else {
theView.showInfo("Bad move", "As a farm plant you need to keep your seeds so they can be harvested.");
};
theModel.ejectMessage = true;
};
theView.plantChanged();
};
break;
case "Flower":
newGrowth.newPos = newGrowth.growElement.getFlowerPos(newGrowth.growNode);
default:
theView.growElement(_local3.elementType, newGrowth);
};
}
public function init(_arg1:View, _arg2:Model){
theModel = _arg2;
theView = _arg1;
newGrowth = new Object();
addDialog = new AddDialog(this);
theView.addChild(addDialog);
theView.addEventListener(View.DONEEVENT, doneEvent);
addEventListener(View.RESETTIMEOUT, theView.resetTimeOut);
theView.introScreen();
removeList = [];
toBeRemoved = 0;
}
public function growLastSeed(){
growSeed(newGrowth.growElement);
theView.plantChanged();
}
public function startEvents(){
currentEvent = -1;
doneEvent();
}
public function ejectLastSeed(){
ejectSeed(newGrowth.growElement);
}
public function growSeed(_arg1:PlantElement){
var _local2:Object = new Object();
_local2.growElement = _arg1;
theModel.growThisMonth++;
theView.growReplacementElement("BigSeed", _local2);
}
public function doneEvent(_arg1:Event=null){
currentEvent++;
if (currentEvent < eventList.length){
dispatchEvent(new Event(View.RESETTIMEOUT));
switch (eventList[currentEvent]){
case "Pollinate":
theView.pollinateFlowers();
break;
case "Bugs":
if (((theModel.pollinationMonth()) && ((theModel.plantType == "Wild")))){
theView.doPests();
} else {
doneEvent();
};
break;
case "Irrigation":
if (theModel.plantType == "Farm"){
theView.doIrrigation();
} else {
doneEvent();
};
break;
case "Beetles":
if (theModel.beetles < 2){
theView.doBeetles();
} else {
doneEvent();
};
break;
case "Insecticide":
if (theModel.plantType == "Farm"){
theView.doInsecticide();
} else {
doneEvent();
};
break;
case "ResetScroll":
theView.doResetScroll();
break;
case "Weeding":
if ((((((theModel.plantType == "Farm")) && (((theModel.currentMonth % 2) == 0)))) && ((theView.theNeighbours.growth > 0)))){
theView.doWeeding();
} else {
doneEvent();
};
break;
case "Weather":
theView.doWeather();
break;
case "Nutrients":
theView.showContinue();
break;
};
};
}
public function removeElement(_arg1:Event){
newGrowth.growElement.removeEventListener(Controller.REMOVE_ELEMENT, removeElement);
theView.removeElement(newGrowth.growElement);
theView.plantChanged();
}
private function ejectSeed(_arg1:PlantElement){
ejectSound.play();
_arg1.addEventListener(Controller.REMOVE_ELEMENT, removeSeed);
_arg1.fall();
theModel.seedCount++;
theModel.ejectThisMonth++;
removeList.push(_arg1);
toBeRemoved++;
}
public function endGame():Boolean{
return ((((theModel.currentMonth >= 9)) || (((theModel.noSugar()) || (theModel.noMinerals())))));
}
public function doneGrowth(_arg1:Event){
addDialog.hide();
trace("done growth");
if (endGame()){
theView.countGrowth();
theView.theEndGame.show(theModel);
} else {
startEvents();
};
}
public function ejectAllSeeds(_arg1:Array){
var _local2:* = 0;
while (_local2 < _arg1.length) {
if ((((_arg1[_local2].elementType == "Seed")) || ((_arg1[_local2].elementType == "BigSeed")))){
ejectSeed(_arg1[_local2]);
};
_local2++;
};
}
public function removeDialog(_arg1:Event){
}
public function newElementOk(_arg1:String, _arg2:Point, _arg3:Number, _arg4:Number):Boolean{
return (!(theView.testElement(_arg1, _arg2, _arg3, _arg4)));
}
}
}//package
Section 40
//CreateSugar (CreateSugar)
package {
public dynamic class CreateSugar extends GreyButton {
}
}//package
Section 41
//Credits (Credits)
package {
public dynamic class Credits extends GreyButton {
}
}//package
Section 42
//DoAllSeeds (DoAllSeeds)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class DoAllSeeds extends MovieClip {
public var eject:Boolean;
public var doAll:PlayAsWildPlant;
public var advice:TextField;
public var cancel:PlayAsWildPlant;
public var title:TextField;
public function DoAllSeeds(){
x = 0;
y = 200;
visible = false;
cancel.addEventListener(MouseEvent.CLICK, onDoOne);
doAll.addEventListener(MouseEvent.CLICK, onDoAll);
}
public function hide(){
visible = false;
}
public function onDoOne(_arg1:MouseEvent){
visible = false;
dispatchEvent(new Event(View.DOONESEED));
}
public function show(_arg1:Boolean){
eject = _arg1;
if (_arg1){
cancel.label.text = "Eject one seed";
doAll.label.text = "Eject all seeds";
title.text = "DO YOU WANT TO EJECT ALL YOUR SEEDS?";
advice.text = "This is a good idea for wild plants but NOT a good idea for farm plants.";
} else {
cancel.label.text = "Grow one seed";
doAll.label.text = "Grow all seeds";
title.text = "DO YOU WANT TO GROW ALL YOUR SEEDS?";
advice.text = "This is a good idea for farm plants but NOT a good idea for wild plants.";
};
visible = true;
}
public function onDoAll(_arg1:MouseEvent){
visible = false;
dispatchEvent(new Event(View.DOALLSEEDS));
}
}
}//package
Section 43
//EjectSeedSound (EjectSeedSound)
package {
import flash.media.*;
public dynamic class EjectSeedSound extends Sound {
}
}//package
Section 44
//EndGame (EndGame)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class EndGame extends MovieClip {
private var farmRatings:Array;
public var endText:MovieClip;
public var creditDisplay:MovieClip;
var monthData:Object;
public var creditButton:Credits;
private var wildRatings:Array;
var growthData:Object;
public var backButton:GoBack;
public function EndGame(_arg1:Number, _arg2:Number){
farmRatings = ["You'll have to make it in the wild or go extinct", "A few useful traits might keep you in the breeding programme, but only as a pollen donor", "Expensive delicacy - difficult to grow and not popular", "Secondary crop - just about worth the farmer's while", " Staple food - grown everywhere and eaten by millions"];
wildRatings = ["Extinct!", "Endangered species - you may not survive long", " Conservation dependent - you'll only survive in protected areas", "Just about viable - you can make it on your own", "Highly successful plant - found all over the place"];
super();
x = 0;
y = 200;
visible = false;
endText.nextButton.addEventListener(MouseEvent.CLICK, playAgain);
creditButton.addEventListener(MouseEvent.CLICK, showCredits);
backButton.addEventListener(MouseEvent.CLICK, hideCredits);
}
public function showCredits(_arg1:Event){
dispatchEvent(new Event(View.RESETTIMEOUT));
creditDisplay.visible = true;
creditButton.visible = false;
backButton.visible = true;
endText.visible = false;
}
public function hide(){
visible = false;
}
public function playAgain(_arg1:Event){
visible = false;
dispatchEvent(new Event(View.PLAYAGAIN));
}
public function show(_arg1:Model){
var _local3:Number;
var _local2:* = _arg1.growth;
creditDisplay.visible = false;
creditButton.visible = true;
backButton.visible = false;
visible = true;
endText.visible = true;
if (_arg1.noMinerals()){
endText.endReason.text = "YOUR PLANT IS DEAD";
endText.report.text = "You have run out of minerals and have no roots to get some more\nHave another go and grow some roots this time.";
endText.score.text = "Have another go and grow some roots this time.";
} else {
if (_arg1.noSugar()){
endText.endReason.text = "YOUR PLANT IS DEAD";
endText.report.text = "You have run out of sugar and need roots and leaves to make some more";
endText.score.text = "Have another go and grow roots and leaves this time.";
} else {
endText.endReason.text = "IT'S SEPTEMBER AND YOUR TIME IS UP";
if (_arg1.plantType == "Wild"){
if (_arg1.seedCount == 1){
endText.report.text = "You have created 1 seed this year";
} else {
endText.report.text = (("You have created " + _arg1.seedCount) + " seeds this year");
};
endText.score.text = (("This gives you a " + Math.min((_arg1.seedCount * 4), 100)) + "% chance of passing your genes on to the next generation");
} else {
if (_local2.bigSeeds == 1){
endText.report.text = "You have 1 big seed on your plant at the moment";
} else {
endText.report.text = (("You have " + _local2.bigSeeds) + " big seeds on your plant at the moment");
};
endText.score.text = (("This gives you a " + Math.min(100, (_local2.bigSeeds * 4))) + "% chance of passing your genes on to the next generation");
};
};
};
if (_arg1.plantType == "Wild"){
_local3 = Math.min((wildRatings.length - 1), Math.floor(((_arg1.seedCount * 4) / 20)));
endText.rating.text = wildRatings[_local3];
} else {
_local3 = Math.min((farmRatings.length - 1), Math.floor(((_local2.bigSeeds * 4) / 20)));
endText.rating.text = farmRatings[_local3];
};
}
public function hideCredits(_arg1:Event){
dispatchEvent(new Event(View.RESETTIMEOUT));
creditDisplay.visible = false;
creditButton.visible = true;
backButton.visible = false;
endText.visible = true;
}
}
}//package
Section 45
//FarmBackground (FarmBackground)
package {
import flash.display.*;
public dynamic class FarmBackground extends MovieClip {
}
}//package
Section 46
//FinishGrowingButton (FinishGrowingButton)
package {
public dynamic class FinishGrowingButton extends GreyButton {
}
}//package
Section 47
//FirstSeed (FirstSeed)
package {
import flash.display.*;
import flash.geom.*;
public class FirstSeed extends PlantElement {
public var node2:Meristem;
public var arrow1:MovieClip;
public var arrow2:MovieClip;
public var node1:Meristem;
public function FirstSeed(_arg1:Sprite, _arg2:Controller, _arg3:Point){
super(_arg1, _arg2, _arg3);
nodeCount = 2;
elementType = "FirstSeed";
initNodes([["Leaf"], ["Root"]], 0);
}
}
}//package
Section 48
//Flower (Flower)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class Flower extends PlantElement {
public static var outlinePoints = [new Point(20.9, -62), new Point(0.5, -29.1)];
public function Flower(_arg1:Sprite, _arg2:Controller, _arg3:Point){
super(_arg1, _arg2, _arg3);
nodeCount = 0;
pushUp = false;
elementType = "Flower";
initNodes([], 0);
}
override public function setRotation(_arg1:Number){
rotation = _arg1;
startGrow();
}
override public function rightDirection(_arg1:Number):Boolean{
if (_arg1 < 0){
_arg1 = (_arg1 + 360);
};
if (_arg1 > 359){
_arg1 = (_arg1 - 360);
};
return ((((_arg1 < 90)) || ((_arg1 > 270))));
}
override public function getEndPoint():Point{
var _local1:* = {x:0, y:-41.7};
var _local2:* = _local1.x;
var _local3:* = _local1.y;
var _local4:* = new Point();
var _local5:* = ((rotation * Math.PI) / 180);
_local4.x = ((_local2 * Math.cos(_local5)) - (_local3 * Math.sin(_local5)));
_local4.y = ((_local2 * Math.sin(_local5)) + (_local3 * Math.cos(_local5)));
return (_local4);
}
}
}//package
Section 49
//FlowerStem (FlowerStem)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class FlowerStem extends PlantElement {
public var arrow1:MovieClip;
public var node1:Meristem;
public static var outlinePoints = [new Point(20.9, -62), new Point(0.5, -29.1)];
public function FlowerStem(_arg1:Sprite, _arg2:Controller, _arg3:Point){
super(_arg1, _arg2, _arg3);
pushUp = true;
nodeCount = 1;
setUpNodes();
}
override public function setRotation(_arg1:Number){
rotation = _arg1;
startGrow();
}
override public function setUpNodes(){
nodeCount = 1;
elementType = "FlowerStem";
initNodes([["Flower"]], 1);
this["node1"].enabled = false;
}
override public function growProgress(_arg1:Event){
var _local2:Number = (scaleX - lastScale);
lastScale = scaleX;
var _local3:Point = new Point((pushAmount.x * _local2), (pushAmount.y * _local2));
pushElement.moveUp(_local3);
}
override public function rightDirection(_arg1:Number):Boolean{
if (_arg1 < 0){
_arg1 = (_arg1 + 360);
};
if (_arg1 > 359){
_arg1 = (_arg1 - 360);
};
return ((((_arg1 < 90)) || ((_arg1 > 270))));
}
public function getGrowPos():Point{
return (toContainer(node1.growPos));
}
override public function getEndPoint():Point{
var _local1:* = {x:0, y:-41.7};
var _local2:* = _local1.x;
var _local3:* = _local1.y;
var _local4:* = new Point();
var _local5:* = ((rotation * Math.PI) / 180);
_local4.x = ((_local2 * Math.cos(_local5)) - (_local3 * Math.sin(_local5)));
_local4.y = ((_local2 * Math.sin(_local5)) + (_local3 * Math.cos(_local5)));
return (_local4);
}
}
}//package
Section 50
//focusRectSkin (focusRectSkin)
package {
import flash.display.*;
public dynamic class focusRectSkin extends MovieClip {
}
}//package
Section 51
//GoBack (GoBack)
package {
public dynamic class GoBack extends GreyButton {
}
}//package
Section 52
//GreyButton (GreyButton)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.text.*;
public class GreyButton extends MovieClip {
public var enable:Boolean;// = true
public var enabledGraphic:MovieClip;
public var label:TextField;
public var disabledGraphic:MovieClip;
public var over:Boolean;
public var buttonClick:Sound;
public var overGraphic:MovieClip;
public function GreyButton(){
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
addEventListener(MouseEvent.CLICK, onMouseClick);
buttonClick = new ButtonClick();
}
public function onMouseOut(_arg1:MouseEvent){
over = false;
reDraw();
}
public function onMouseOver(_arg1:MouseEvent){
if (enable){
over = true;
reDraw();
};
}
public function onMouseClick(_arg1:MouseEvent){
buttonClick.play();
}
public function reDraw(){
enabledGraphic.visible = ((enable) && (!(over)));
disabledGraphic.visible = !(enable);
overGraphic.visible = ((over) && (enable));
if (enable){
label.textColor = 0xFFFFFF;
} else {
label.textColor = 8362384;
};
}
public function setEnabled(_arg1:Boolean){
enable = _arg1;
reDraw();
}
}
}//package
Section 53
//GreyFrame (GreyFrame)
package {
import flash.display.*;
public dynamic class GreyFrame extends MovieClip {
}
}//package
Section 54
//Grid (Grid)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class Grid extends Sprite {
private var traceBmp:BitmapData;
public var traceOn:Boolean;// = false
private var cells:Array;
private var widthPixels;
private var checkBmp:BitmapData;
private var gridSize:Number;
private var heightCells:Number;
private var widthCells;
private var numberOfCells:Number;
private var heightPixels:Number;
public function Grid(_arg1:Number, _arg2:Number, _arg3:Number){
widthPixels = _arg1;
heightPixels = _arg2;
gridSize = _arg3;
widthCells = Math.ceil((widthPixels / gridSize));
heightCells = Math.ceil((heightPixels / gridSize));
numberOfCells = (widthCells * heightCells);
createCells();
traceBmp = new BitmapData(widthPixels, heightPixels, true, 0);
checkBmp = new BitmapData(widthPixels, heightPixels, true, 0);
var _local4:Bitmap = new Bitmap(traceBmp);
var _local5:Bitmap = new Bitmap(checkBmp);
if (traceOn){
addChild(_local4);
addChild(_local5);
};
}
public function setGridPoints(_arg1:Array, _arg2:Boolean){
var _local3:* = 0;
while (_local3 < _arg1.length) {
setGrid(_arg1[_local3].x, _arg1[_local3].y, _arg2);
_local3++;
};
}
public function setGrid(_arg1:Number, _arg2:Number, _arg3:Boolean){
var _local4:int = Math.round((_arg1 / gridSize));
var _local5:int = Math.round((_arg2 / gridSize));
setCell(_local4, _local5, _arg3);
}
private function setCell(_arg1:int, _arg2:int, _arg3:Boolean){
var _local4:int = (_arg1 + (_arg2 * widthCells));
cells[_local4] = _arg3;
var _local5:* = new Rectangle(((_arg1 - 0.5) * gridSize), ((_arg2 - 0.5) * gridSize), gridSize, gridSize);
traceBmp.fillRect(_local5, 1727987712);
}
public function fillGrid(_arg1:DisplayObject){
var _local3:*;
var _local2:* = _arg1.x;
while (_local2 < (_arg1.x + _arg1.width)) {
_local3 = _arg1.y;
while (_local3 < (_arg1.y + _arg1.height)) {
setGrid(_local2, _local3, true);
_local3 = (_local3 + gridSize);
};
_local2 = (_local2 + gridSize);
};
}
public function clearGrid(){
var _local1:* = 0;
while (_local1 < (numberOfCells - 1)) {
cells[_local1] = false;
_local1++;
};
var _local2:* = 0;
while (_local2 < widthCells) {
setGrid(_local2, 0, true);
setGrid(_local2, 1, true);
setGrid(_local2, (heightCells - 2), true);
setGrid(_local2, (heightCells - 1), true);
_local2++;
};
var _local3:* = 0;
while (_local3 < heightCells) {
setGrid(0, _local3, true);
setGrid(1, _local3, true);
setGrid((widthCells - 1), _local3, true);
setGrid((widthCells - 2), _local3, true);
_local3++;
};
}
private function createCells(){
cells = new Array(numberOfCells);
}
public function resetCheck(){
trace("reset check bmp");
var _local1:* = new Rectangle(0, 0, widthPixels, heightPixels);
checkBmp.fillRect(_local1, 0);
}
public function getGrid(_arg1:Number, _arg2:Number):Boolean{
var _local3:int = Math.round((_arg1 / gridSize));
var _local4:int = Math.round((_arg2 / gridSize));
var _local5:* = new Rectangle(((_local3 - 0.25) * gridSize), ((_local4 - 0.25) * gridSize), (gridSize * 0.5), (gridSize * 0.5));
checkBmp.fillRect(_local5, 1711341312);
var _local6:int = (_local3 + (_local4 * widthCells));
return (cells[_local6]);
}
}
}//package
Section 55
//GrowButton (GrowButton)
package {
public dynamic class GrowButton extends GreyButton {
}
}//package
Section 56
//InfoBox (InfoBox)
package {
import flash.display.*;
import com.gskinner.motion.*;
import fl.transitions.easing.*;
import flash.text.*;
public class InfoBox extends MovieClip {
public var displayMessage:TextField;
public var theController:Controller;
public var chosenElement:Number;
private var tabList:Array;
public var displayTitle:TextField;
private var growTween:GTween;
public static var CANCELCLICKED = "CANCELCLICKED";
public static var ADDCLICKED = "ADDCLICKED";
public function InfoBox(){
visible = false;
x = 30;
y = 530;
}
public function hide(){
visible = false;
}
public function show(_arg1:String, _arg2:String, _arg3:Boolean=false){
if (_arg1 != ""){
visible = true;
displayTitle.autoSize = TextFieldAutoSize.LEFT;
displayMessage.autoSize = TextFieldAutoSize.LEFT;
displayTitle.text = _arg1.toUpperCase();
displayMessage.y = ((displayTitle.y + displayTitle.textHeight) + 16);
displayMessage.text = _arg2;
if (_arg3){
GTween.defaultEase = Regular.easeOut;
alpha = 0;
growTween = new GTween(this, 0.5, {alpha:1});
};
};
}
}
}//package
Section 57
//Insect (Insect)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.utils.*;
public class Insect extends MovieClip {
public var animateTimer:Timer;
public var speed:Number;// = 8
public var targetFlower:PlantElement;
public var directionCount:Number;// = 0
public var landed:Boolean;// = false
public var hasFlower:Boolean;// = false
public var targetPoint:Point;
public static var DONE:String = "done";
public static var FOUNDTARGET:String = "found target";
public function Insect(){
x = (100 + (Math.random() * 50));
y = (100 + (Math.random() * 50));
rotation = (45 + (Math.random() * 90));
animateTimer = new Timer(40, 0);
animateTimer.addEventListener(TimerEvent.TIMER, animate);
animateTimer.start();
directionCount = 0;
}
public function animate(_arg1:Event){
var _local2:*;
var _local3:Number;
_local2 = ((rotation * Math.PI) / 180);
x = (x + (Math.cos(_local2) * speed));
y = (y + (Math.sin(_local2) * speed));
directionCount++;
if (directionCount > 10){
directionCount = 0;
if (hasFlower){
if (Point.distance(targetPoint, new Point(x, y)) < (speed * 6)){
foundTarget();
};
_local3 = Math.atan2((targetPoint.y - y), (targetPoint.x - x));
rotation = ((_local3 * 180) / Math.PI);
rotation = (rotation + ((Math.random() * 20) - 10));
} else {
rotation = ((Math.random() * 30) - 15);
if (x >= 0x0400){
trace("bee off screen");
dispatchEvent(new Event(DONE));
};
};
};
}
public function setDone(_arg1:Function, _arg2:Number){
speed = _arg2;
addEventListener(Insect.DONE, _arg1);
}
public function init(_arg1:PlantElement, _arg2:Function){
addEventListener(Insect.FOUNDTARGET, _arg2);
hasFlower = true;
targetFlower = _arg1;
var _local3:Rectangle = _arg1.getBounds(parent);
targetPoint = new Point(((_local3.left + _local3.right) / 2), ((_local3.top + _local3.bottom) / 2));
trace(("insect target =" + targetPoint));
}
public function foundTarget(){
x = targetPoint.x;
y = targetPoint.y;
hasFlower = false;
rotation = (45 + (Math.random() * 90));
dispatchEvent(new Event(FOUNDTARGET));
dispatchEvent(new Event(DONE));
}
public function end(){
animateTimer.stop();
}
}
}//package
Section 58
//Insecticide (Insecticide)
package {
import flash.events.*;
import flash.utils.*;
public class Insecticide extends TimedEvent {
public var animateTimer:Timer;
public function Insecticide(_arg1:Function){
super(_arg1);
}
public function animate(_arg1:Event){
x = (x - 15);
if (x < 0){
animateTimer.stop();
visible = false;
dispatchEvent(new Event(DONE));
};
}
override public function show(_arg1:Number){
visible = true;
x = 0x0400;
animateTimer = new Timer(40, 0);
animateTimer.addEventListener(TimerEvent.TIMER, animate);
animateTimer.start();
}
}
}//package
Section 59
//IntroScreen (IntroScreen)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class IntroScreen extends MovieClip {
public var backToMenu:PlayAsWildPlant;
public var nextButton:StartButton;
public var farmButton:PlayAsFarmPlant;
public var tenMinutes:TextField;
public var plantType:String;
public var wildInstructions:MovieClip;
public var trackball:TextField;
public var farmInstructions:MovieClip;
private var theTimeOut:TimeOut;
public var wildButton:PlayAsWildPlant;
public var screenSizeChosen:Boolean;// = true
public var farmEnabled:Boolean;
public var window:PlayAsWildPlant;
public var fullscreen:PlayAsFarmPlant;
private var theModel:Model;
public function IntroScreen(_arg1:Number, _arg2:Number, _arg3:Model, _arg4:TimeOut){
x = 0;
((_arg1 - width) / 2);
y = 0;
((_arg2 - height) / 2);
fullscreen.label.text = "Fill the whole screen";
window.label.text = "Stay this size";
fullscreen.addEventListener(MouseEvent.CLICK, choosefullscreen);
window.addEventListener(MouseEvent.CLICK, chooseWindow);
wildButton.addEventListener(MouseEvent.CLICK, chooseWild);
theModel = _arg3;
theTimeOut = _arg4;
nextButton.addEventListener(MouseEvent.CLICK, startGame);
backToMenu.label.text = "Back To Menu";
backToMenu.addEventListener(MouseEvent.CLICK, quitGame);
visible = false;
farmEnabled = false;
}
public function startGame(_arg1:Event){
visible = false;
farmEnabled = true;
dispatchEvent(new Event(View.STARTGAME));
}
public function disableFarm(){
farmButton.visible = false;
farmButton.removeEventListener(MouseEvent.CLICK, chooseFarm);
}
public function choosefullscreen(_arg1:Event){
var e = _arg1;
if (stage.displayState == StageDisplayState.NORMAL){
try {
theModel.webFullScreen = true;
stage.displayState = StageDisplayState.FULL_SCREEN;
} catch(e:SecurityError) {
theModel.webFullScreen = false;
trace("an error has occured. please modify the html file to allow fullscreen mode");
};
};
screenSizeChosen = true;
choosePlantType();
}
public function show(_arg1:Boolean){
if (!screenSizeChosen){
if (!theModel.webVersion){
screenSizeChosen = true;
if (!theModel.studio108Version){
stage.displayState = StageDisplayState.FULL_SCREEN;
};
};
};
stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
farmInstructions.visible = false;
wildInstructions.visible = false;
if (((theModel.webVersion) || (theModel.desktop))){
tenMinutes.visible = true;
trackball.visible = false;
} else {
tenMinutes.visible = false;
trackball.visible = true;
};
backToMenu.visible = false;
if (_arg1){
farmEnabled = false;
};
visible = true;
if (screenSizeChosen){
choosePlantType();
} else {
fullscreen.visible = true;
window.visible = true;
farmButton.visible = false;
wildButton.visible = false;
nextButton.label.text = "Start";
nextButton.visible = false;
};
}
public function quitGame(_arg1:Event){
theTimeOut.dispatchEvent(new Event(TimeOut.TIMEOUT));
}
public function chooseWild(_arg1:Event){
backToMenu.visible = false;
tenMinutes.visible = false;
trackball.visible = false;
stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
if (((!(theModel.webVersion)) && (!(theModel.desktop)))){
theTimeOut.switchOn();
};
farmButton.visible = false;
wildButton.visible = false;
nextButton.visible = true;
wildInstructions.visible = true;
plantType = "Wild";
}
public function enableFarm(){
farmButton.visible = true;
farmButton.addEventListener(MouseEvent.CLICK, chooseFarm);
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
trace("key down");
}
public function chooseWindow(_arg1:Event){
screenSizeChosen = true;
choosePlantType();
}
private function choosePlantType(){
fullscreen.visible = false;
window.visible = false;
farmButton.visible = true;
wildButton.visible = true;
nextButton.label.text = "Start";
nextButton.visible = false;
if (farmEnabled){
enableFarm();
} else {
disableFarm();
};
}
public function getPlantType():String{
return (plantType);
}
public function chooseFarm(_arg1:Event){
backToMenu.visible = false;
tenMinutes.visible = false;
trackball.visible = false;
stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
if (((!(theModel.webVersion)) && (!(theModel.desktop)))){
theTimeOut.switchOn();
};
farmButton.visible = false;
wildButton.visible = false;
nextButton.visible = true;
farmInstructions.visible = true;
plantType = "Farm";
}
}
}//package
Section 60
//Irrigation (Irrigation)
package {
public class Irrigation extends TimedEvent {
public function Irrigation(_arg1:Function){
addFrameScript(4, frame5);
super(_arg1);
}
function frame5(){
gotoAndPlay(0);
}
}
}//package
Section 61
//LargeButton (LargeButton)
package {
import flash.display.*;
import flash.text.*;
public dynamic class LargeButton extends MovieClip {
public var label:TextField;
}
}//package
Section 62
//Leaf (Leaf)
package {
import flash.display.*;
import flash.geom.*;
public class Leaf extends PlantElement {
public var graphicFrame:Number;
public var arrow1:MovieClip;
public var arrow2:MovieClip;
public var node1:Meristem;
public var flowerPos:MovieClip;
public var rotationFrame:Number;
public var node2:Meristem;
public static var outlinePoints = [new Point(20.9, -62), new Point(0.5, -29.1)];
public function Leaf(_arg1:Sprite, _arg2:Controller, _arg3:Point){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4);
super(_arg1, _arg2, _arg3);
graphicFrame = 1;
rotationFrame = 0;
elementType = "Leaf";
gotoAndStop((graphicFrame + rotationFrame));
nodeCount = 2;
setUpNodes();
}
override public function rightDirection(_arg1:Number):Boolean{
if (_arg1 < 0){
_arg1 = (_arg1 + 360);
};
if (_arg1 > 359){
_arg1 = (_arg1 - 360);
};
return ((((_arg1 > 270)) || ((_arg1 < 90))));
}
function frame1(){
}
function frame3(){
}
override public function setRotation(_arg1:Number){
if (_arg1 < 0){
_arg1 = (_arg1 + 360);
};
if (_arg1 > 359){
_arg1 = (_arg1 - 360);
};
rotation = _arg1;
if ((((rotation >= 0)) && ((rotation < 180)))){
rotationFrame = 0;
} else {
rotationFrame = 2;
};
changeGraphic();
startGrow();
}
function frame2(){
}
function frame4(){
}
override public function setUpNodes(){
flowerPos.visible = false;
initNodes([["Leaf", "Stem"], ["Flower"]], 6);
}
private function changeGraphic(){
gotoAndStop((graphicFrame + rotationFrame));
refreshNodes();
}
override public function elementHasGrown(){
trace(("leaf has grown " + name));
graphicFrame = 2;
changeGraphic();
}
}
}//package
Section 63
//LeafReport (LeafReport)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class LeafReport extends MovieClip {
public var leavesOpen:Number;
public var growth:TextField;
private var monthData:Object;
public var nextMonth:CreateSugar;
public var leafIndicator:MovieClip;
public var leavesCount:TextField;
private var availableWater:Number;
private var growthData:Object;
public var sugarCreated:Number;
public var slider:Slider;
public var sunlightBar:ReportDisplay;
public var co2Bar:ReportDisplay;
public var noOfLeaves:TextField;
public var waterBar:ReportDisplay;
public var sugarBar:ReportDisplay;
public function LeafReport(){
slider.addEventListener(Slider.THUMB_DRAG, sliderChange);
slider.addEventListener(Slider.THUMB_RELEASE, sliderUpdate);
nextMonth.addEventListener(MouseEvent.CLICK, doneLeaf);
nextMonth.label.text = "Make sugar";
}
function sliderChange(_arg1:Event):void{
leavesOpen = slider.getValue();
updateValues();
}
public function show(_arg1:Number, _arg2:Object, _arg3:Object){
visible = true;
dispatchEvent(new Event(View.RESETTIMEOUT));
monthData = _arg2;
availableWater = _arg1;
growthData = _arg3;
noOfLeaves.text = growthData.leaves;
leavesOpen = 0;
var _local4:* = new Array();
var _local5:* = 0;
while (_local5 <= growthData.leaves) {
_local4.push([((_local5 / growthData.leaves) * 100), _local5]);
_local5++;
};
slider.show();
slider.initSlider(false, _local4);
slider.setValue(leavesOpen);
checkValues(false);
updateValues();
nextMonth.visible = (((leavesOpen == growthData.leaves)) || ((availableWater == 0)));
}
public function hide(){
slider.hide();
visible = false;
}
private function updateValues(){
var _local1:Number;
leafIndicator.leavesOpenDisplay.text = (leafCount(leavesOpen) + " open");
leafIndicator.leavesNumber.text = leavesOpen;
leafIndicator.disallowed.visible = false;
_local1 = (availableWater - ((leavesOpen * monthData.sunshine) / 4));
var _local2:Number = (leavesOpen * 20);
var _local3:Number = ((monthData.sunshine * (growthData.leaves - (growthData.shadedLeaves * 0.5))) / 5);
waterBar.set((_local1 / 5), "Water", false, false);
if (_local1 < 0){
leafIndicator.disallowed.visible = true;
leafIndicator.leavesOpenDisplay.text = (("You don't have enough water to open " + leafCount(leavesOpen)) + ". Try again.");
};
co2Bar.set(((leavesOpen * 20) / 2), "Carbon", false, false);
sunlightBar.set(_local3, "Sunlight", false, false);
sugarCreated = Math.min(_local2, _local3);
sugarBar.set(sugarCreated, "Sugar", false, false);
}
function doneLeaf(_arg1:Event){
trace("done leaf");
leavesOpen = 0;
dispatchEvent(new Event(View.RESETTIMEOUT));
dispatchEvent(new Event(Nutrients.SHOWLEAVESOPEN));
dispatchEvent(new Event(Nutrients.DONELEAF));
}
private function leafCount(_arg1:Number):String{
if (_arg1 == 1){
return ("1 leaf");
};
return ((_arg1 + " leaves"));
}
function checkValues(_arg1:Boolean){
var _local3:Number;
var _local2:Number = leavesOpen;
var _local4:Boolean;
do {
_local3 = ((availableWater - ((leavesOpen * monthData.sunshine) / 4)) * 5);
if ((((_local3 < 0)) && ((leavesOpen > 0)))){
leavesOpen = (leavesOpen - 1);
} else {
_local4 = true;
};
} while (!(_local4));
if (slider.getValue() != leavesOpen){
slider.setValue(leavesOpen);
};
}
public function showNumber(_arg1:Number):String{
if (_arg1 < 0){
return ("!");
};
return (String(_arg1));
}
function sliderUpdate(_arg1:Event):void{
leavesOpen = slider.getValue();
nextMonth.visible = true;
checkValues(true);
updateValues();
dispatchEvent(new Event(View.RESETTIMEOUT));
}
}
}//package
Section 64
//Meristem (Meristem)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class Meristem extends MovieClip {
public var growPos:Point;
public var border1:MovieClip;
public var border2:MovieClip;
public var border3:MovieClip;
public var border4:MovieClip;
public var allowedAngles:Array;
public var possibleAngles:Array;
public var isStem:Boolean;
public var highlightGraphic:MovieClip;
private var mineralCost;
private var sugarCost;
public var isFlower:Boolean;
public var growType:String;
public var allowedTypes:Array;
public var flowerEnabled:Boolean;
public var typeList:Array;
public var upAngleIndex:Number;
public var stemEnabled:Boolean;
public function Meristem(){
mineralCost = {Root:5, Stem:5, Leaf:5, BigSeed:15, FallOff:2, Flower:10};
sugarCost = {Root:5, Stem:5, Leaf:5, BigSeed:15, FallOff:2, Flower:10};
super();
addEventListener(MouseEvent.MOUSE_OVER, highlightOn);
addEventListener(MouseEvent.MOUSE_OUT, highlightOff);
highlightOff();
growType = "";
isStem = false;
isFlower = false;
stemEnabled = true;
flowerEnabled = true;
}
public function getTypes():Array{
var _local1:Array = new Array();
var _local2:* = 0;
while (_local2 < typeList.length) {
switch (typeList[_local2].elementType){
case "Root":
case "Leaf":
if (allowedAngles.length > 0){
_local1.push(typeList[_local2]);
};
break;
case "Stem":
if (stemEnabled){
_local1.push(typeList[_local2]);
};
break;
case "Flower":
if (flowerEnabled){
_local1.push(typeList[_local2]);
};
break;
default:
_local1.push(typeList[_local2]);
break;
};
_local2++;
};
return (_local1);
}
public function draw(){
var _local1:Number;
rotation = -(parent.rotation);
var _local2:Array = getTypes();
_local1 = 1;
while (_local1 <= 4) {
setColour(this[("border" + _local1)], 0xFFFFFF);
_local1++;
};
setColour(highlightGraphic, 16082193);
_local1 = 0;
while (_local1 < _local2.length) {
switch (_local2[_local1].elementType){
case "Leaf":
setColour(this["border1"], 0x456100);
setColour(this["border4"], 0x456100);
setColour(this["border2"], 0x456100);
setColour(this["border3"], 0x456100);
setColour(highlightGraphic, 0x456100);
break;
case "Flower":
setColour(this["border1"], 15643663);
setColour(this["border2"], 15643663);
setColour(this["border3"], 15643663);
setColour(this["border4"], 15643663);
setColour(highlightGraphic, 15643663);
break;
case "BigSeed":
case "FallOff":
setColour(this["border3"], 0xFF4C00);
setColour(this["border2"], 0xFF4C00);
setColour(this["border1"], 0xFF4C00);
setColour(this["border4"], 0xFF4C00);
setColour(highlightGraphic, 0xFF4C00);
break;
};
_local1++;
};
}
public function setTypeList(_arg1:Array, _arg2:Number){
var _local4:String;
typeList = new Array();
var _local3:* = 0;
while (_local3 < _arg1.length) {
_local4 = _arg1[_local3];
if (_local4 == "Root"){
growType = "Root";
};
if (_local4 == "Leaf"){
growType = "Leaf";
};
if (_local4 == "Stem"){
isStem = true;
};
if (_local4 == "Flower"){
isFlower = true;
};
typeList.push({elementType:_local4, costSugar:sugarCost[_local4], costMinerals:mineralCost[_local4]});
_local3++;
};
}
public function highlightOn(_arg1:Event){
highlightGraphic.visible = true;
}
public function setNodeHeight(_arg1:Number){
var _local2:Number;
var _local3:String;
_local2 = 0;
while (_local2 < typeList.length) {
_local3 = typeList[_local2].elementType;
if ((((_local3 == "Leaf")) || ((_local3 == "Stem")))){
typeList[_local2].costSugar = (sugarCost[_local3] + Math.floor((_arg1 / 2)));
typeList[_local2].costMinerals = (mineralCost[_local3] + Math.floor((_arg1 / 2)));
};
_local2++;
};
}
function setColour(_arg1:MovieClip, _arg2:Number){
var _local3:ColorTransform = _arg1.transform.colorTransform;
_local3.color = _arg2;
_arg1.transform.colorTransform = _local3;
}
public function generateAngles(_arg1:Number, _arg2:Number){
var _local4:*;
trace(("generate angles " + _arg1));
possibleAngles = new Array();
allowedAngles = new Array();
var _local3:* = 1;
while (_local3 <= 13) {
_local4 = false;
if (Math.abs((_local3 - 7)) <= _arg2){
_local4 = true;
};
possibleAngles.push({angle:(_arg1 + ((_local3 - 7) * 20)), enable:_local4});
_local3++;
};
}
public function highlightOff(_arg1:Event=null){
highlightGraphic.visible = false;
}
public function getTypeName(_arg1:int){
return (typeList[_arg1].elementType);
}
}
}//package
Section 65
//mineralIcon (mineralIcon)
package {
import flash.display.*;
public dynamic class mineralIcon extends MovieClip {
}
}//package
Section 66
//Model (Model)
package {
import flash.display.*;
import flash.events.*;
public class Model extends Sprite {
public var shortMonthNames:Array;
public var plantType:String;
public var growth:Object;
public var minerals:Number;
public var growThisMonth:Number;
public var currentMonth:Number;
public var rainfallText:Array;
public var sunshine:Array;
public var ejectMessage:Boolean;
public var webVersion:Boolean;// = true
public var seedCount:Number;
public var webFullScreen:Boolean;// = false
public var beetles:Number;
public var desktop:Boolean;// = false
public var monthNames:Array;
public var ejectThisMonth:Number;
public var sunshineText:Array;
public var growMessage:Boolean;
public var studio108Version:Boolean;// = false
public var rainFall:Array;
public var sugar:Number;
public function Model(){
monthNames = new Array("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
shortMonthNames = new Array("", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEPT", "OCT", "NOV", "DEC");
rainFall = new Array(0, 68.7, 48.1, 59.2, 54.8, 52.8, 62.1, 53.4, 56.9, 61.4, 68.2, 68, 75.8);
sunshine = new Array(0, 48.4, 66.1, 99.8, 134.4, 186.9, 173.1, 179.5, 173.9, 130.8, 100.8, 62.7, 41.5);
rainfallText = ["Dry", "Showers", "Heavy rain"];
sunshineText = ["Clouds", "Some sun", "Sunshine"];
super();
reset();
}
public function pollinationMonth():Boolean{
return (true);
}
public function getCurrentMonth():Object{
var _local1:* = new Object();
_local1.name = monthNames[currentMonth];
_local1.shortName = shortMonthNames[currentMonth];
_local1.rain = rainFall[currentMonth];
_local1.sunshine = sunshine[currentMonth];
_local1.rainfallIndex = Math.floor(((_local1.rain - 50) / 5));
_local1.rainfallText = rainfallText[_local1.rainfallIndex];
_local1.sunshineIndex = Math.floor(((_local1.sunshine - 99) / 30));
_local1.sunshineText = sunshineText[_local1.sunshineIndex];
_local1.monthNumber = currentMonth;
return (_local1);
}
public function useResource(_arg1:Number, _arg2:Number){
minerals = (minerals - _arg2);
sugar = (sugar - _arg1);
dispatchEvent(new Event(View.UPDATE_RESOURCES));
}
public function nextMonth(){
currentMonth++;
}
public function cancelButtonState():Boolean{
return (((!(webVersion)) || (((webVersion) && (webFullScreen)))));
}
public function noSugar():Boolean{
return ((((((growth.leaves <= 0)) || ((growth.roots <= 0)))) && ((sugar <= 0))));
}
public function reset(){
minerals = 10;
sugar = 10;
currentMonth = 3;
seedCount = 0;
beetles = 0;
ejectMessage = false;
growMessage = false;
ejectThisMonth = 0;
growThisMonth = 0;
}
public function noMinerals():Boolean{
return ((((growth.roots <= 0)) && ((minerals <= 0))));
}
}
}//package
Section 67
//Neighbour (Neighbour)
package {
import flash.display.*;
import flash.events.*;
import com.gskinner.motion.*;
import flash.geom.*;
import flash.utils.*;
import fl.transitions.easing.*;
public class Neighbour extends MovieClip {
public var growth:Number;
public var waitTimer:Timer;
public var wildCanopy:MovieClip;
public var shadeheight:Number;
private var growTween:GTween;
public var canopyMask:MovieClip;
private var targetPoint:Point;
public static var DONE:String = "done";
public function Neighbour(_arg1:Function){
addEventListener(DONE, _arg1);
x = 0;
y = 504;
shadeheight = y;
growth = 0;
wildCanopy.y = 0;
}
public function timesUp(_arg1:TimerEvent){
waitTimer.stop();
dispatchEvent(new Event(DONE));
}
public function weed(_arg1:Number){
growth = 0;
updateGrowth();
waitTimer = new Timer(_arg1, 1);
waitTimer.addEventListener(TimerEvent.TIMER, timesUp);
waitTimer.start();
}
public function grow(){
if (growth < 4){
trace(("neighbours grow " + growth));
growth++;
updateGrowth();
};
}
private function updateGrowth(){
var _local1:Number = (-((wildCanopy.height / 4)) * growth);
GTween.defaultEase = Regular.easeOut;
growTween = new GTween(wildCanopy, 0.5, {y:_local1});
shadeheight = (y + _local1);
}
}
}//package
Section 68
//Nutrients (Nutrients)
package {
import flash.display.*;
import flash.events.*;
public class Nutrients extends MovieClip {
var leavesOpen:Number;
var monthData:Object;
var availableWater:Number;
var growthData:Object;
public var sugarCreated:Number;
public var mineralsCreated:Number;
public var rootBackground:MovieClip;
public var leafReport:LeafReport;
public var rootReport:RootReport;
private var theModel:Model;
public static var DONELEAF = "done roots";
public static var DONE = "Nutrients done";
public static var SHOWLEAVESOPEN = "show leaves open";
public static var SHOWROOTWATER = "show root water";
public static var DONEROOTS = "done roots";
public function Nutrients(_arg1:Number, _arg2:Number, _arg3:View){
x = ((_arg1 - width) / 2);
y = 200;
theModel = _arg3.theModel;
rootReport.addEventListener(Nutrients.DONEROOTS, doneRoots);
rootReport.addEventListener(View.RESETTIMEOUT, _arg3.resetTimeOut);
leafReport.addEventListener(Nutrients.DONELEAF, doneLeaf);
leafReport.addEventListener(View.RESETTIMEOUT, _arg3.resetTimeOut);
hide();
}
function doneLeaf(_arg1:Event){
sugarCreated = leafReport.sugarCreated;
trace("done Nutrients");
dispatchEvent(new Event(Nutrients.DONE));
}
public function hide(){
visible = false;
}
public function doneRoots(_arg1:Event){
rootBackground.visible = false;
rootReport.hide();
availableWater = rootReport.availableWater;
mineralsCreated = rootReport.mineralsCreated;
leafReport.show(availableWater, monthData, growthData);
}
public function getOpenLeaves():Number{
return (leafReport.leavesOpen);
}
public function show(_arg1:Object, _arg2:Object, _arg3:String){
visible = true;
leafReport.hide();
monthData = _arg1;
growthData = _arg2;
rootReport.show(monthData, growthData, _arg3, theModel);
rootBackground.visible = true;
}
}
}//package
Section 69
//Pest (Pest)
package {
import flash.events.*;
import flash.utils.*;
import flash.media.*;
public class Pest extends Insect {
var chompSound:Sound;
var pauseTimer:Timer;
public function Pest(){
speed = 10;
chompSound = new ChompSound();
}
public function pauseDone(_arg1:Event){
rotation = (45 + (Math.random() * 90));
dispatchEvent(new Event(FOUNDTARGET));
animateTimer.start();
}
override public function foundTarget(){
x = targetPoint.x;
y = targetPoint.y;
trace(((("pest x=" + x) + " ") + y));
hasFlower = false;
animateTimer.stop();
chompSound.play();
pauseTimer = new Timer(1000, 1);
pauseTimer.addEventListener(TimerEvent.TIMER, pauseDone);
pauseTimer.start();
}
}
}//package
Section 70
//PlantElement (PlantElement)
package {
import flash.display.*;
import flash.events.*;
import com.gskinner.motion.*;
import flash.geom.*;
import flash.utils.*;
import fl.transitions.easing.*;
import fl.motion.easing.*;
import fl.transitions.*;
public class PlantElement extends MovieClip {
private var angles:Number;
public var container:Sprite;
public var animateTimer:Timer;
public var pushElement:PlantElement;
public var fallSpeed:Point;
public var pushAmount:Point;
private var growTween:GTween;
public var nodeCount:int;
public var growAngleIndex:Number;
private var shadowFilter:Array;
public var growNode:Meristem;
public var heightOfElement:Number;// = 0
public var lastScale:Number;
public var pushUp:Boolean;// = false
public var elementType:String;
public var clickedMeristem:Meristem;
public var theController:Controller;
public var parentElement:PlantElement;
public var nodeIndex:Number;
public var children:Array;
public static var ANIMATEDONE:String = "animate done";
public function PlantElement(_arg1:Sprite, _arg2:Controller, _arg3:Point){
container = _arg1;
theController = _arg2;
children = new Array();
x = _arg3.x;
y = _arg3.y;
addEventListener(PlantElement.ANIMATEDONE, theController.elementGrowFinished);
addEventListener(MouseEvent.CLICK, doNewCheck);
}
public function animateFall(_arg1:Event){
x = (x + fallSpeed.x);
y = (y + fallSpeed.y);
fallSpeed.y = (fallSpeed.y + 1);
if (y > 0){
animateTimer.stop();
animateTimer = new Timer(1000, 0);
animateTimer.addEventListener(TimerEvent.TIMER, removeNode);
animateTimer.start();
};
}
private function setNodeHeights(){
var _local1:* = 1;
while (_local1 <= nodeCount) {
this[("node" + _local1)].setNodeHeight(heightOfElement);
_local1++;
};
}
public function setRotation(_arg1:Number){
rotation = _arg1;
}
public function addChildElement(_arg1:PlantElement){
children.push(_arg1);
_arg1.setParent(this);
}
public function setUpNodes(){
}
public function startGrow(){
GTween.defaultEase = Regular.easeOut;
scaleX = 0;
scaleY = 0;
growTween = new GTween(this, 0.5, {scaleX:1, scaleY:1});
growTween.addEventListener(Event.COMPLETE, doneGrow);
growTween.addEventListener(Event.CHANGE, growProgress);
}
public function refreshNodes(){
var _local2:*;
var _local1:* = 1;
while (_local1 <= nodeCount) {
_local2 = this[("arrow" + _local1)].rotation;
this[("node" + _local1)].generateAngles(_local2, angles);
this[("node" + _local1)].x = this[("arrow" + _local1)].x;
this[("node" + _local1)].y = this[("arrow" + _local1)].y;
this[("node" + _local1)].growPos = new Point(this[("arrow" + _local1)].x, this[("arrow" + _local1)].y);
_local1++;
};
}
public function initNodes(_arg1:Array, _arg2:Number){
angles = _arg2;
var _local3:* = 1;
while (_local3 <= nodeCount) {
this[("node" + _local3)].addEventListener(MouseEvent.MOUSE_DOWN, nodeClick);
this[("arrow" + _local3)].visible = false;
this[("node" + _local3)].visible = false;
this[("node" + _local3)].enabled = true;
this[("node" + _local3)].setTypeList(_arg1[(_local3 - 1)], heightOfElement);
_local3++;
};
refreshNodes();
}
public function checkNodes(){
var _local1:Boolean;
var _local2:Number = 1;
while (_local2 <= nodeCount) {
checkNode(this[("node" + _local2)]);
_local1 = (this[("node" + _local2)].getTypes().length > 0);
this[("node" + _local2)].visible = ((_local1) && (this[("node" + _local2)].enabled));
this[("node" + _local2)].draw();
_local2++;
};
}
public function nodeClick(_arg1:MouseEvent){
var _local2:Number;
clickedMeristem = (_arg1.currentTarget as Meristem);
var _local3:Point = toContainer(clickedMeristem.growPos);
if (clickedMeristem.allowedAngles.length > 0){
growAngleIndex = clickedMeristem.allowedAngles[clickedMeristem.upAngleIndex];
_local2 = clickedMeristem.possibleAngles[growAngleIndex].angle;
} else {
_local2 = 0;
growAngleIndex = 0;
};
theController.addEventListener(Controller.DONEGROW, nodeHasGrown);
theController.addEventListener(Controller.CANCELGROW, nodeNotGrown);
theController.growNew(_local3, _local2, clickedMeristem.getTypes(), this, clickedMeristem);
}
public function checkNode(_arg1){
var _local2:Array;
var _local3:PlantElement;
var _local4:Boolean;
var _local5:Number;
var _local7:*;
var _local8:*;
if (_arg1.growType == "Root"){
_local5 = 180;
} else {
_local5 = 0;
};
var _local6:Point = toContainer(_arg1.growPos);
if (_arg1.isStem){
_arg1.stemEnabled = theController.stemOk(this, _local6);
};
if (_arg1.isFlower){
_arg1.flowerEnabled = theController.newElementOk("Flower", _local6, 0, nodeIndex);
} else {
_arg1.allowedAngles = new Array();
_arg1.upAngleIndex = 0;
_local7 = 0;
while (_local7 < _arg1.possibleAngles.length) {
if (_arg1.possibleAngles[_local7].enable){
_local8 = (_arg1.possibleAngles[_local7].angle + this.rotation);
if (rightDirection(_local8)){
if ((((_arg1.growType == "Leaf")) || ((_arg1.growType == "Root")))){
if (theController.newElementOk(_arg1.growType, _local6, _local8, -1)){
_arg1.allowedAngles.push(_local7);
if (Math.abs((_local8 - _local5)) < Math.abs((_arg1.possibleAngles[_arg1.allowedAngles[_arg1.upAngleIndex]].angle + this.rotation))){
_arg1.upAngleIndex = (_arg1.allowedAngles.length - 1);
};
};
} else {
_arg1.allowedAngles.push(_local7);
if (Math.abs(_local8) < Math.abs((_arg1.possibleAngles[_arg1.allowedAngles[_arg1.upAngleIndex]].angle + this.rotation))){
_arg1.upAngleIndex = (_arg1.allowedAngles.length - 1);
};
};
};
};
_local7++;
};
};
}
public function doneGrow(_arg1:Event){
refreshNodes();
dispatchEvent(new Event(PlantElement.ANIMATEDONE));
}
public function setParent(_arg1:PlantElement){
parentElement = _arg1;
heightOfElement = (_arg1.heightOfElement + 1);
setNodeHeights();
}
public function getFlowerPos(_arg1:Meristem):Point{
return (toContainer(new Point(_arg1.x, _arg1.y)));
}
public function toContainer(_arg1:Point):Point{
var _local2:Point = this.localToGlobal(_arg1);
_local2 = container.globalToLocal(_local2);
return (_local2);
}
public function initPush(_arg1:PlantElement){
pushAmount = getEndPoint();
pushElement = _arg1;
lastScale = 0;
}
public function moveUp(_arg1:Point){
x = (x + _arg1.x);
y = (y + _arg1.y);
var _local2:* = 0;
while (_local2 < children.length) {
children[_local2].moveUp(_arg1);
_local2++;
};
}
public function nodeNotGrown(_arg1:Event){
theController.removeEventListener(Controller.DONEGROW, nodeHasGrown);
theController.removeEventListener(Controller.CANCELGROW, nodeNotGrown);
}
public function rightDirection(_arg1:Number):Boolean{
return (true);
}
public function removeNode(_arg1:Event){
animateTimer.stop();
dispatchEvent(new Event(Controller.REMOVE_ELEMENT));
}
public function getPoints():Array{
var _local1:* = new Array();
var _local2:* = 1;
while (_local2 <= nodeCount) {
_local1.push(toContainer(new Point(this[("node" + _local2)].x, this[("node" + _local2)].y)));
_local2++;
};
return (_local1);
}
public function elementHasGrown(){
}
public function nodeHasGrown(_arg1:Event){
theController.removeEventListener(Controller.DONEGROW, nodeHasGrown);
theController.removeEventListener(Controller.CANCELGROW, nodeNotGrown);
if (theController.newGrowth.elementType == "Flower"){
clickedMeristem.enabled = false;
};
elementHasGrown();
}
public function removeChildElement(_arg1:PlantElement){
var _local2:* = children.indexOf(_arg1);
if (_local2 != -1){
children.splice(_local2, 1);
};
}
public function growProgress(_arg1:Event){
}
public function doNewCheck(_arg1:MouseEvent){
trace(((("This nodes is " + name) + " index=") + nodeIndex));
}
public function getLocalPoints(_arg1:Number, _arg2:String):Array{
var _local3:Matrix = new Matrix();
_local3.rotate(((Math.PI / 180) * _arg1));
var _local4:* = new Array();
var _local5:Class = (getDefinitionByName(_arg2) as Class);
var _local6:* = _local5["outlinePoints"];
var _local7:* = 0;
while (_local7 < _local6.length) {
_local4.push(_local3.transformPoint(_local6[_local7]));
_local7++;
};
return (_local4);
}
public function displayAllNodes(_arg1:Boolean){
var _local2:* = 1;
while (_local2 <= nodeCount) {
this[("node" + _local2)].visible = _arg1;
if (_arg1){
this[("node" + _local2)].draw();
};
_local2++;
};
}
public function getEndPoint():Point{
return (new Point(0, 0));
}
public function fall(){
animateTimer = new Timer(40, 0);
animateTimer.addEventListener(TimerEvent.TIMER, animateFall);
animateTimer.start();
fallSpeed = new Point(12, -5);
if (x < 450){
fallSpeed = new Point(-12, -5);
};
}
}
}//package
Section 71
//PlantLimit (PlantLimit)
package {
import flash.display.*;
public dynamic class PlantLimit extends MovieClip {
}
}//package
Section 72
//PlayAgain (PlayAgain)
package {
public dynamic class PlayAgain extends GreyButton {
}
}//package
Section 73
//PlayAsFarmPlant (PlayAsFarmPlant)
package {
public dynamic class PlayAsFarmPlant extends GreyButton {
}
}//package
Section 74
//PlayAsWildPlant (PlayAsWildPlant)
package {
public dynamic class PlayAsWildPlant extends GreyButton {
}
}//package
Section 75
//QuitDialog (QuitDialog)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class QuitDialog extends MovieClip {
public var eject:Boolean;
public var doAll:PlayAsWildPlant;
public var advice:TextField;
public var cancel:PlayAsWildPlant;
public var title:TextField;
public function QuitDialog(){
visible = false;
cancel.addEventListener(MouseEvent.CLICK, onContinue);
doAll.addEventListener(MouseEvent.CLICK, onQuit);
doAll.label.text = "End the game";
cancel.label.text = "Continue the game";
}
public function onContinue(_arg1:MouseEvent){
visible = false;
}
public function hide(){
visible = false;
}
public function onQuit(_arg1:MouseEvent){
visible = false;
dispatchEvent(new Event(TimeOut.TIMEOUT));
}
public function show(){
visible = true;
}
}
}//package
Section 76
//RainSound (RainSound)
package {
import flash.media.*;
public dynamic class RainSound extends Sound {
}
}//package
Section 77
//ReportDisplay (ReportDisplay)
package {
public dynamic class ReportDisplay extends BarDisplay {
}
}//package
Section 78
//Root (Root)
package {
import flash.display.*;
import flash.geom.*;
public class Root extends PlantElement {
public var graphicFrame:Number;
public var arrow1:MovieClip;
public var arrow2:MovieClip;
public var node1:Meristem;
public var node2:Meristem;
public static var outlinePoints = [new Point(-13.8, -47.5), new Point(0.7, -23.1)];
public function Root(_arg1:Sprite, _arg2:Controller, _arg3:Point){
super(_arg1, _arg2, _arg3);
graphicFrame = 1;
elementType = "Root";
changeGraphic();
setUpNodes();
}
override public function rightDirection(_arg1:Number):Boolean{
if (_arg1 < 0){
_arg1 = (_arg1 + 360);
};
if (_arg1 > 359){
_arg1 = (_arg1 - 360);
};
return ((((_arg1 > 90)) && ((_arg1 < 270))));
}
override public function setRotation(_arg1:Number){
rotation = _arg1;
if ((Math.floor(rotation) % 2) == 0){
graphicFrame = 1;
} else {
graphicFrame = 2;
};
changeGraphic();
startGrow();
}
override public function setUpNodes(){
nodeCount = 2;
initNodes([["Root"], ["Root"]], 1);
}
private function changeGraphic(){
gotoAndStop(graphicFrame);
}
}
}//package
Section 79
//RootReport (RootReport)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class RootReport extends MovieClip {
public var month:TextField;
public var nextButton:AbsorbWaterMinerals;
public var mineralReport:TextField;
public var availableWater:Number;
private var monthData:Object;
private var growthData:Object;
private var plantType:String;
public var mineralsCreated:Number;
public var rootGraphic:MovieClip;
public var leafButton:CreateSugar;
public var leafReport:TextField;
public var report:TextField;
public var rootReport:TextField;
private var theModel:Model;
public function RootReport(){
leafButton.addEventListener(MouseEvent.CLICK, doneRoots);
leafButton.label.text = "Create sugar";
nextButton.label.text = "Absorb minerals and water";
nextButton.addEventListener(MouseEvent.CLICK, doRoots);
}
public function hide(){
visible = false;
}
public function doRoots(_arg1:Event){
dispatchEvent(new Event(View.RESETTIMEOUT));
leafButton.visible = true;
nextButton.visible = false;
rootGraphic.visible = true;
rootReport.visible = true;
rootReport.visible = true;
availableWater = (monthData.rain * growthData.roots);
mineralReport.visible = true;
if (plantType == "Farm"){
mineralsCreated = (growthData.roots * 20);
} else {
mineralsCreated = (growthData.roots * 15);
};
if (growthData.beetlesFound > 0){
mineralsCreated = (mineralsCreated + (growthData.beetlesFound * 20));
};
rootGraphic.waterBar.set((availableWater / 5), "Water", false, false);
rootGraphic.mineralBar.set(mineralsCreated, "DarkMinerals", false, false);
theModel.useResource(0, Math.round(-(mineralsCreated)));
}
function doneRoots(_arg1:Event){
trace("done roots");
dispatchEvent(new Event(Nutrients.DONEROOTS));
}
public function show(_arg1:Object, _arg2:Object, _arg3:String, _arg4:Model){
var _local5:String;
var _local6:String;
visible = true;
theModel = _arg4;
monthData = _arg1;
growthData = _arg2;
plantType = _arg3;
mineralReport.text = "";
month.text = ("IN " + monthData.name.toUpperCase());
rootGraphic.y = 205;
mineralReport.autoSize = TextFieldAutoSize.LEFT;
mineralReport.text = "";
report.htmlText = (((("The weather was mainly <font face='DINOT-Bold'>" + monthData.rainfallText.toLowerCase()) + "</font> with <font face='DINOT-Bold'>") + monthData.sunshineText.toLowerCase()) + "</font>");
if (_arg3 == "Farm"){
mineralReport.appendText("The farmer watered you which lets you absorb more water\n");
monthData.rain = (monthData.rain + 20);
};
if (growthData.beetlesFound > 0){
mineralReport.appendText("Your roots have found some dead beetles which gives you extra minerals\n");
};
rootGraphic.y = ((mineralReport.y + mineralReport.textHeight) + 20);
if (growthData.roots == 1){
_local5 = "You have <font face='DINOT-Bold'>1</font> root which can absorb water and minerals";
} else {
_local5 = (("You have <font face='DINOT-Bold'>" + growthData.roots) + "</font> roots which can absorb water and minerals");
};
rootReport.htmlText = _local5;
if (growthData.leaves == 1){
_local6 = "You have <font face='DINOT-Bold'>1</font> leaf which can absorb sunlight and Carbon Dioxide";
if (growthData.shadedLeaves == 1){
_local6 = (_local6 + "\nbut it is shaded by other plants and doesn't get much sun");
};
} else {
_local6 = (("You have <font face='DINOT-Bold'>" + growthData.leaves) + "</font> leaves which can absorb sunlight and Carbon Dioxide");
if (growthData.shadedLeaves == 1){
_local6 = (_local6 + ((",\nbut <font face='DINOT-Bold'>" + growthData.shadedLeaves) + "</font> is shaded by other plants and doesn't get much sun"));
};
if (growthData.shadedLeaves > 1){
_local6 = (_local6 + ((",\nbut <font face='DINOT-Bold'>" + growthData.shadedLeaves) + "</font> are shaded by other plants and don't get much sun"));
};
};
leafReport.htmlText = _local6;
leafButton.visible = false;
nextButton.visible = true;
rootGraphic.visible = false;
rootReport.visible = true;
leafReport.visible = true;
mineralReport.visible = false;
}
}
}//package
Section 80
//Seed (Seed)
package {
import flash.display.*;
import flash.geom.*;
public class Seed extends PlantElement {
public var arrow1:MovieClip;
public var node1:Meristem;
public function Seed(_arg1:Sprite, _arg2:Controller, _arg3:Point){
super(_arg1, _arg2, _arg3);
nodeCount = 1;
elementType = "Seed";
initNodes([["BigSeed", "FallOff"]], 0);
node1.visible = false;
}
override public function setRotation(_arg1:Number){
rotation = 0;
if (parentElement.rotation < 0){
scaleX = 1;
} else {
scaleX = -1;
};
}
override public function checkNode(_arg1){
}
}
}//package
Section 81
//SimPlant (SimPlant)
package {
import fl.controls.*;
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class SimPlant extends Sprite {
public var resetButton:Button;
public var rootNode:PlantElement;
private var theController:Controller;
private var nodes:Array;
private var theView:View;
private var theGrid:Grid;
private var theModel:Model;
public function SimPlant(){
theController = new Controller();
addEventListener(Event.ADDED_TO_STAGE, init);
}
public function quitGame(_arg1:Event){
trace("Game quitting");
var _local2:LocalConnection = new LocalConnection();
_local2.send("AVM2toAVM1", "finishGame");
}
private function init(_arg1:Event){
trace("added to stage");
theModel = new Model();
theView = new View(theModel);
theView.setController(theController);
addChild(theView);
theView.addEventListener(View.QUITGAME, quitGame);
theController.init(theView, theModel);
}
}
}//package
Section 82
//Slider (Slider)
package {
import flash.display.*;
import flash.events.*;
public class Slider extends MovieClip {
public var analogue:Boolean;
public var arrow:MovieClip;
public var valueRange:Number;
public var pointList:Object;
protected var moving:Boolean;
protected var speed:Number;// = 0
public var measure:MovieClip;
protected var targetValue:Number;
public var quarter:MovieClip;
public var maxValue:Number;
public var threeQuarter:MovieClip;
public var leftX:Number;
public var half:MovieClip;
public var buttonDown:Boolean;
protected var lastValue:Number;
public var rightX:Number;
public var minValue:Number;
public static var THUMB_DRAG = "Thumb drag";
public static var THUMB_RELEASE = "Thumb release";
public function Slider(){
mouseChildren = false;
leftX = (this.measure.x + (this.arrow.width / 2));
rightX = ((this.measure.x + this.measure.width) - (this.arrow.width / 2));
setArrow(this.arrow.x);
buttonDown = false;
addEventListener(MouseEvent.MOUSE_DOWN, onPress);
addEventListener(MouseEvent.MOUSE_UP, chooseValue);
addEventListener(MouseEvent.MOUSE_OUT, chooseValue);
}
public function hide(){
visible = false;
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function getValue(){
var _local1:Array;
if (analogue == false){
_local1 = findSlot();
return (_local1[1]);
};
return (getValue());
}
public function setArrow(_arg1){
this.arrow.x = _arg1;
}
public function initSlider(_arg1, _arg2){
analogue = _arg1;
if (analogue){
maxValue = _arg2["max"];
minValue = _arg2["min"];
valueRange = (maxValue - minValue);
} else {
pointList = _arg2;
minValue = pointList[0][1];
maxValue = pointList[(pointList.length - 1)][1];
valueRange = (maxValue - minValue);
};
half.visible = false;
quarter.visible = false;
threeQuarter.visible = false;
}
public function getArrow(){
return ((this.arrow.x + (this.arrow.width / 2)));
}
public function findSlot():Array{
var _local1:*;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
_local1 = (((getArrow() - leftX) / (rightX - leftX)) * 100);
_local4 = 100;
_local5 = 0;
while (_local5 < pointList.length) {
if (Math.abs((pointList[_local5][0] - _local1)) < _local4){
_local4 = Math.abs((pointList[_local5][0] - _local1));
_local2 = pointList[_local5];
};
_local5++;
};
return (_local2);
}
public function onEnterFrame(_arg1:Event){
if (buttonDown){
trace(((((("mouseX=" + this.mouseX) + " left=") + leftX) + " rightX=") + rightX));
setArrow(this.mouseX);
dispatchEvent(new Event(THUMB_DRAG));
};
}
public function onPress(_arg1:MouseEvent){
trace(("mouse event " + _arg1.type));
lastValue = getArrow();
buttonDown = true;
}
private function moveToCorrectPosition(){
var _local1:Array;
targetValue = this.arrow.x;
buttonDown = false;
if (analogue == false){
_local1 = findSlot();
targetValue = (leftX + ((rightX - leftX) * (_local1[0] / 100)));
};
setArrow(targetValue);
}
public function chooseValue(_arg1:MouseEvent=null){
trace(("mouse event " + _arg1.type));
if (buttonDown){
moveToCorrectPosition();
dispatchEvent(new Event(THUMB_RELEASE));
};
}
public function setValue(_arg1:Number){
var _local3:Number;
var _local2:Number = 9999;
var _local4:* = 0;
while (_local4 < pointList.length) {
if (Math.abs((pointList[_local4][1] - _arg1)) < _local2){
_local2 = Math.abs((pointList[_local4][1] - _arg1));
_local3 = pointList[_local4][0];
};
_local4++;
};
setArrow((leftX + ((_local3 / 100) * (rightX - leftX))));
moveToCorrectPosition();
}
public function show(){
visible = true;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
}//package
Section 83
//SmallButton (SmallButton)
package {
import flash.display.*;
import flash.text.*;
public dynamic class SmallButton extends MovieClip {
public var label:TextField;
}
}//package
Section 84
//SmallDisplayMark (SmallDisplayMark)
package {
import flash.display.*;
public dynamic class SmallDisplayMark extends MovieClip {
}
}//package
Section 85
//StartButton (StartButton)
package {
public dynamic class StartButton extends GreyButton {
}
}//package
Section 86
//StatusBarDisplay (StatusBarDisplay)
package {
public dynamic class StatusBarDisplay extends BarDisplay {
}
}//package
Section 87
//StatusDisplay (StatusDisplay)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class StatusDisplay extends MovieClip {
public var rainLabel:TextField;
public var runningScore1:TextField;
public var wildLabel:MovieClip;
public var sunshineLabel:TextField;
public var monthsLeft1:TextField;
public var monthsLeft2:TextField;
public var farmLabel:MovieClip;
public var mineralAmount:StatusBarDisplay;
public var sunIcon:MovieClip;
public var monthName1:TextField;
public var monthName2:TextField;
public var rainIcon:MovieClip;
public var rainLabel2:TextField;
public var sugarAmount:StatusBarDisplay;
public var sunshineLabel2:TextField;
public var runningScore2:TextField;
public function StatusDisplay(_arg1:Number){
updateResources(10, 10);
}
public function hide(){
visible = false;
}
public function updateMonth(_arg1:Model){
var _local2:String;
var _local3:* = _arg1.getCurrentMonth();
var _local4:* = (9 - _local3.monthNumber);
if (_local4 == 1){
_local2 = "1 month left";
} else {
_local2 = (_local4 + " months left");
};
monthsLeft1.text = _local2;
monthsLeft2.text = _local2;
monthName1.text = _local3.shortName;
monthName2.text = _local3.shortName;
rainLabel.text = _local3.rainfallText;
sunshineLabel.text = _local3.sunshineText;
rainLabel2.text = _local3.rainfallText;
sunshineLabel2.text = _local3.sunshineText;
rainIcon.gotoAndStop((_local3.rainfallIndex + 1));
sunIcon.gotoAndStop((_local3.sunshineIndex + 1));
}
public function update(_arg1:Model){
updateResources(_arg1.sugar, _arg1.minerals);
updateMonth(_arg1);
updateType(_arg1.plantType);
updateRunningScore(_arg1);
}
public function updateRunningScore(_arg1:Model){
if (_arg1.plantType == "Farm"){
runningScore1.text = (_arg1.growth.bigSeeds + " large seeds on the plant");
} else {
runningScore1.text = (_arg1.seedCount + " seeds ejected");
};
runningScore2.text = runningScore1.text;
}
public function show(){
visible = true;
}
public function updateResources(_arg1:Number, _arg2:Number){
sugarAmount.set(_arg1, "Sugar", true, true, false);
mineralAmount.set(_arg2, "Minerals", true, true, false);
}
public function hilightResources(){
}
public function updateType(_arg1:String){
if (_arg1 == "Farm"){
wildLabel.visible = false;
farmLabel.visible = true;
} else {
wildLabel.visible = true;
farmLabel.visible = false;
};
}
}
}//package
Section 88
//Stem (Stem)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class Stem extends PlantElement {
public var graphicFrame:Number;
public var arrow1:MovieClip;
public var node1:Meristem;
public static var outlinePoints = [new Point(20.9, -62), new Point(0.5, -29.1)];
public function Stem(_arg1:Sprite, _arg2:Controller, _arg3){
super(_arg1, _arg2, _arg3);
pushUp = true;
elementType = "Stem";
setUpNodes();
}
override public function setRotation(_arg1:Number){
rotation = _arg1;
if ((Math.floor(rotation) % 2) == 0){
graphicFrame = 1;
} else {
graphicFrame = 2;
};
changeGraphic();
startGrow();
}
override public function rightDirection(_arg1:Number):Boolean{
if (_arg1 < 0){
_arg1 = (_arg1 + 360);
};
if (_arg1 > 359){
_arg1 = (_arg1 - 360);
};
return ((((_arg1 < 90)) || ((_arg1 > 270))));
}
override public function growProgress(_arg1:Event){
var _local2:Number = (scaleX - lastScale);
lastScale = scaleX;
var _local3:Point = new Point((pushAmount.x * _local2), (pushAmount.y * _local2));
pushElement.moveUp(_local3);
}
override public function getEndPoint():Point{
var _local1:* = [{x:0, y:-45.2}, {x:4.5, y:-68.3}];
var _local2:* = _local1[(graphicFrame - 1)].x;
var _local3:* = _local1[(graphicFrame - 1)].y;
var _local4:* = new Point();
var _local5:* = ((rotation * Math.PI) / 180);
_local4.x = ((_local2 * Math.cos(_local5)) - (_local3 * Math.sin(_local5)));
_local4.y = ((_local2 * Math.sin(_local5)) + (_local3 * Math.cos(_local5)));
return (_local4);
}
public function enableNode(){
this["node1"].enabled = true;
}
override public function setUpNodes(){
nodeCount = 1;
initNodes([["Leaf"]], 6);
this["node1"].enabled = false;
}
private function changeGraphic(){
gotoAndStop(graphicFrame);
}
}
}//package
Section 89
//sugarIcon (sugarIcon)
package {
import flash.display.*;
public dynamic class sugarIcon extends MovieClip {
}
}//package
Section 90
//sunlightIcon (sunlightIcon)
package {
import flash.display.*;
public dynamic class sunlightIcon extends MovieClip {
}
}//package
Section 91
//TabDisplay (TabDisplay)
package {
public dynamic class TabDisplay extends BarDisplay {
}
}//package
Section 92
//TestElements (TestElements)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.utils.*;
public class TestElements extends Sprite {
private var testElements:Object;
private var elementList:Array;
public function TestElements(_arg1){
var _local3:Class;
var _local4:*;
elementList = ["Leaf", "Root", "Stem", "Flower"];
super();
testElements = new Object();
var _local2:* = 0;
while (_local2 < elementList.length) {
_local3 = (getDefinitionByName(("Test" + elementList[_local2])) as Class);
_local4 = (new _local3(this, _arg1, new Point(0, 0)) as PlantElement);
addChild(_local4);
_local4.visible = false;
testElements[elementList[_local2]] = _local4;
_local4.gotoAndStop(0);
_local2++;
};
}
public function getTest(_arg1, _arg2, _arg3, _arg4):PlantElement{
var _local5:PlantElement;
_local5 = testElements[_arg1];
_local5.x = _arg2;
_local5.y = _arg3;
_local5.setRotation(_arg4);
return (_local5);
}
}
}//package
Section 93
//TestFlower (TestFlower)
package {
import flash.display.*;
import flash.geom.*;
public class TestFlower extends Flower {
public function TestFlower(_arg1:Sprite, _arg2:Controller, _arg3:Point){
super(_arg1, _arg2, _arg3);
}
override public function setUpNodes(){
nodeCount = 0;
}
override public function startGrow(){
}
}
}//package
Section 94
//TestLeaf (TestLeaf)
package {
import flash.display.*;
import flash.geom.*;
public class TestLeaf extends Leaf {
public var testnode1:Meristem;
public function TestLeaf(_arg1:Sprite, _arg2:Controller, _arg3:Point){
super(_arg1, _arg2, _arg3);
}
override public function setUpNodes(){
nodeCount = 0;
}
override public function startGrow(){
}
}
}//package
Section 95
//TestRoot (TestRoot)
package {
import flash.display.*;
import flash.geom.*;
public class TestRoot extends Root {
public static var outlinePoints = [new Point(-13.8, -47.5), new Point(0.7, -23.1)];
public function TestRoot(_arg1:Sprite, _arg2:Controller, _arg3:Point){
super(_arg1, _arg2, _arg3);
}
override public function setUpNodes(){
nodeCount = 0;
}
override public function startGrow(){
}
}
}//package
Section 96
//TestStem (TestStem)
package {
import flash.display.*;
public class TestStem extends Stem {
public function TestStem(_arg1:Sprite, _arg2:Controller, _arg3){
super(_arg1, _arg2, _arg3);
}
override public function setUpNodes(){
nodeCount = 0;
}
override public function startGrow(){
}
}
}//package
Section 97
//TimedEvent (TimedEvent)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.media.*;
public class TimedEvent extends MovieClip {
public var waitTimer:Timer;
public var soundChannel:SoundChannel;// = null
public static var DONE:String = "done";
public function TimedEvent(_arg1:Function){
x = ((0x0400 - width) / 2);
y = (((0x0300 - height) / 2) - 80);
visible = false;
addEventListener(DONE, _arg1);
}
public function timesUp(_arg1:TimerEvent){
if (soundChannel != null){
soundChannel.stop();
};
visible = false;
dispatchEvent(new Event(DONE));
}
public function show(_arg1:Number){
visible = true;
waitTimer = new Timer(_arg1, 1);
waitTimer.addEventListener(TimerEvent.TIMER, timesUp);
waitTimer.start();
}
}
}//package
Section 98
//TimeOut (TimeOut)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*;
public class TimeOut extends MovieClip {
private var startTime:Number;
private var countDown:Number;
public var displayText:TextField;
private var state:String;
private var checkTimer:Timer;
public var title:TextField;
private var text1:String;
private var text2:String;
private var visibleTime:Number;
private var timeLimit:Number;
private var countDownText:String;
public static const RESET_TIMEOUT:String = "resetTimeOut";
public static const TIMEOUT:String = "timeOut";
public function TimeOut(){
checkTimer = new Timer(100, 0);
checkTimer.addEventListener("timer", doCheck);
addEventListener(MouseEvent.MOUSE_DOWN, reset);
trace("starting timeout");
off();
}
public function switchOn(){
checkTimer.start();
state = "counting";
reset();
}
public function doCheck(_arg1:Object){
if (state == "counting"){
if ((getTimer() - startTime) > (timeLimit * 1000)){
doTimeOut();
visibleTime = getTimer();
};
};
if (state == "visible"){
countDown = (10 - Math.floor(((getTimer() - this.visibleTime) / 1000)));
this["displayText"].text = ((((text1 + " ") + countDown) + " ") + text2);
if (countDown < 1){
trace("send timeout message");
off();
dispatchEvent(new Event(TimeOut.TIMEOUT));
};
};
}
public function doTimeOut(){
visible = true;
state = "visible";
}
public function reset(_arg1:Object=undefined){
startTime = getTimer();
if (state == "visible"){
state = "counting";
};
visible = false;
}
public function off(){
checkTimer.stop();
state = "off";
visible = false;
}
public function setup(_arg1){
countDownText = "";
timeLimit = _arg1;
text1 = "Click on the screen or I'll reset in";
text2 = "seconds";
}
}
}//package
Section 99
//TopTips (TopTips)
package {
public class TopTips {
private var farmTipList:Array;
private var plantType:String;
private var theTipList:Array;
private var wildTipList:Array;
public function TopTips(){
wildTipList = [{title:"Click on the crosses to grow your plant", text:"Try and get the right balance of roots and leaves. Roots collect water and minerals. Leaves collect light and carbon dioxide."}, {title:"Growing the plant uses sugar and minerals", text:"The top right of the screen shows you how much you've got left."}, {title:"Smart plant tip", text:"Grow a mixture of\nroots and leaves."}, {title:"Smart plant tip", text:"Don't grow flowers until the last few months, save your energy for roots and leaves."}, {title:"Smart plant tip", text:"Grow your leaves higher than your neighbours so they're not shaded."}, {title:"Smart plant tip", text:"Grow your roots to the dead beetles to get extra minerals."}, {title:"Smart plant tip", text:"Don't grow too many stems\nsave your resouces for\nroots and leaves."}, {title:"Smart plant tip", text:"Don't grow big seeds - save your resources for roots and leaves."}, {title:"Smart plant tip", text:"Remember to eject all your seeds so they can grow new plants."}];
farmTipList = [{title:"Click on the crosses to grow your plant", text:"Try and get the right balance of roots and leaves. Roots collect water and minerals. Leaves collect light and carbon dioxide."}, {title:"Growing the plant uses sugar and minerals", text:"The top right of the screen shows you how much you've got left."}, {title:"Smart plant tip", text:"Grow a mixture of\nroots and leaves."}, {title:"Smart plant tip", text:"Don't grow flowers until the last few months, save your energy for roots and leaves."}, {title:"Smart plant tip", text:"Don't worry about growing high, your neighbours will be removed by the farmer."}, {title:"Smart plant tip", text:"Don't worry about getting minerals from dead beetles, the farmer has fertilised you."}, {title:"Smart plant tip", text:"Don't eject your seeds, the farmer wants them on the plant."}, {title:"Smart plant tip", text:"Make sure you grow all your seeds."}];
super();
}
public function reset(_arg1:String){
plantType = _arg1;
resetTips(wildTipList);
resetTips(farmTipList);
if (plantType == "Wild"){
theTipList = wildTipList;
} else {
theTipList = farmTipList;
};
}
public function getTip(_arg1:Model):Object{
var _local4:Object;
var _local2:Number = 0;
var _local3:Boolean;
while ((((_local2 < theTipList.length)) && (!(_local3)))) {
if (!theTipList[_local2].done){
if (plantType == "Wild"){
_local3 = getWildTip(_local2, _arg1);
} else {
_local3 = getFarmTip(_local2, _arg1);
};
};
_local2++;
};
_local2--;
if (_local3){
theTipList[_local2].done = true;
return (theTipList[_local2]);
};
return ({title:"", text:""});
}
public function resetTips(_arg1:Array){
var _local2:Number = 0;
while (_local2 < _arg1.length) {
_arg1[_local2].done = false;
_local2++;
};
}
private function getFarmTip(_arg1:Number, _arg2:Model):Boolean{
var _local3:Object;
var _local4:Number;
var _local5:Number;
_local3 = _arg2.growth;
switch (_arg1){
case 0:
return (true);
case 1:
return (true);
case 2:
_local4 = (_local3.leaves / (_local3.roots + 0.0001));
if ((((_local4 > 3)) || ((_local4 < 0.3)))){
return (true);
};
break;
case 3:
_local5 = (_local3.seeds + _local3.bigSeeds);
if ((((_local5 > 0)) && ((_arg2.currentMonth <= 6)))){
return (true);
};
break;
case 4:
_local4 = (_local3.leaves / (_local3.stem + 0.0001));
if (_local4 < 2){
return (true);
};
break;
case 5:
if (_local3.beetlesFound > 1){
return (true);
};
break;
case 6:
if (_arg2.seedCount > 0){
return (true);
};
break;
case 7:
if (_local3.seeds > 0){
return (true);
};
break;
};
return (false);
}
public function getParticularTip(_arg1:Number, _arg2){
if (!theTipList[_arg1].done){
theTipList[_arg1].done = true;
return (theTipList[_arg1]);
};
return ({title:"", text:""});
}
private function getWildTip(_arg1:Number, _arg2:Model):Boolean{
var _local3:Object;
var _local4:Number;
var _local5:Number;
_local3 = _arg2.growth;
switch (_arg1){
case 0:
return (true);
case 1:
return (true);
case 2:
_local4 = (_local3.leaves / (_local3.roots + 0.0001));
if ((((_local4 > 3)) || ((_local4 < 0.3)))){
return (true);
};
break;
case 3:
_local5 = (_local3.seeds + _local3.bigSeeds);
if ((((_local5 > 0)) && ((_arg2.currentMonth <= 6)))){
return (true);
};
break;
case 4:
if (_local3.shadedLeaves > 1){
return (true);
};
break;
case 5:
if (_local3.beetlesFound == 0){
return (true);
};
break;
case 6:
_local4 = (_local3.leaves / (_local3.stem + 0.0001));
if (_local4 < 2){
return (true);
};
break;
case 7:
if (_local3.bigSeeds > 1){
return (true);
};
break;
case 8:
if ((((_local3.seeds > 2)) && ((_arg2.seedCount == 0)))){
return (true);
};
break;
};
return (false);
}
}
}//package
Section 100
//waterIcon (waterIcon)
package {
import flash.display.*;
public dynamic class waterIcon extends MovieClip {
}
}//package
Section 101
//Weather (Weather)
package {
import flash.display.*;
import flash.media.*;
public class Weather extends TimedEvent {
private var rainSound:Sound;
public var lightRain:MovieClip;
public var heavyRain:MovieClip;
public function Weather(_arg1:Function){
super(_arg1);
x = 0;
y = 135;
rainSound = new RainSound();
}
public function showWeather(_arg1:Number, _arg2:Number){
trace(("weather rainfall =" + _arg2));
switch (_arg2){
case 1:
heavyRain.visible = false;
lightRain.visible = true;
soundChannel = rainSound.play(0, 10);
break;
case 2:
heavyRain.visible = true;
lightRain.visible = false;
soundChannel = rainSound.play(0, 10);
break;
default:
_arg1 = 0;
break;
};
super.show(_arg1);
}
}
}//package
Section 102
//View (View)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.utils.*;
import flash.media.*;
import flash.filters.*;
public class View extends Sprite {
private var theNutrients:Nutrients;
private var nextButton:GreyButton;
private var theDoAllSeeds:DoAllSeeds;
public var plantSprite:Sprite;
private var flowerNodes:Array;
public var theContainer:Container;
private var plantLimit:PlantLimit;
private var addFlowerFrom:FlowerStem;
private var groundSprite:Sprite;
public var insectsSprite:Sprite;
public var theInsecticide:Insecticide;
public var theModel:Model;
public var infoBox:InfoBox;
public var theWeather:Weather;
public var theNeighbours:Neighbour;
private var theTips:TopTips;
private var cancelButton:MovieClip;
private var theGrid:Grid;
public var theIrrigation:Irrigation;
public var thePlant:PlantElement;
private var delayTimer:Timer;
private var noOfPests:Number;
public var theTimeOut:TimeOut;
public var testElements:TestElements;
private var beeSound:Sound;
private var nodes:Array;
private var shadowFilter:Array;
private var continueButton:GreyButton;
public var theEndGame:EndGame;
private var theStatus:StatusDisplay;
private var leavesEaten:Number;
private var theIntroScreen:IntroScreen;
public var theQuitDialog:QuitDialog;
private var noOfBees:Number;
public var beetleSprite:Sprite;
private var theController:Controller;
private var soundChannel:SoundChannel;
public var eventSprite:Sprite;
public static var QUITGAME = "quit game";
public static var DOONESEED = "do one seed";
public static var UPDATE_RESOURCES = "Update resources";
public static var RESETTIMEOUT = "reset timeout";
public static var DOALLSEEDS = "do all seeds";
public static var STARTGAME = "start game";
public static var PLAYAGAIN = "play again";
public static var DONEEVENT = "Done event";
public function View(_arg1:Model){
theModel = _arg1;
nodes = new Array();
theModel.addEventListener(View.UPDATE_RESOURCES, this.updateResources);
theContainer = new Container();
addChild(theContainer);
theContainer.addEventListener(Container.SCROLL_RESET, doneScrollEvent);
theStatus = new StatusDisplay(0x0400);
nextButton = new FinishGrowingButton();
nextButton.x = 670;
nextButton.y = 700;
addChild(nextButton);
continueButton = new PlayAsWildPlant();
continueButton.label.text = "Absorb nutrients";
continueButton.x = 756;
continueButton.y = 700;
addChild(continueButton);
infoBox = new InfoBox();
eventSprite = new Sprite();
theIrrigation = new Irrigation(doneEvent);
eventSprite.addChild(theIrrigation);
theInsecticide = new Insecticide(doneEvent);
eventSprite.addChild(theInsecticide);
theWeather = new Weather(doneEvent);
eventSprite.addChild(theWeather);
insectsSprite = new Sprite();
eventSprite.addChild(insectsSprite);
addChild(eventSprite);
theNutrients = new Nutrients(0x0400, 0x0300, this);
theNutrients.addEventListener(Nutrients.DONE, this.NutrientsDone);
addChild(theNutrients);
theEndGame = new EndGame(0x0400, 0x0300);
theEndGame.addEventListener(View.PLAYAGAIN, introScreen);
theEndGame.addEventListener(View.RESETTIMEOUT, resetTimeOut);
theDoAllSeeds = new DoAllSeeds();
theDoAllSeeds.addEventListener(View.DOONESEED, doOneSeed);
theDoAllSeeds.addEventListener(View.DOALLSEEDS, doAllSeeds);
addChild(theEndGame);
addChild(theDoAllSeeds);
addChild(theStatus);
theTimeOut = new TimeOut();
theIntroScreen = new IntroScreen(0x0400, 0x0300, theModel, theTimeOut);
theIntroScreen.addEventListener(View.STARTGAME, start);
addChild(theIntroScreen);
theTips = new TopTips();
var _local2:* = new GreyFrame();
_local2.x = -456;
_local2.y = -452.1;
addChild(_local2);
cancelButton = new CancelButton();
addChild(cancelButton);
theQuitDialog = new QuitDialog();
theQuitDialog.addEventListener(TimeOut.TIMEOUT, introScreen);
addChild(theQuitDialog);
theTimeOut.addEventListener(TimeOut.TIMEOUT, introScreen);
addChild(theTimeOut);
theTimeOut.setup(60);
cancelButton.x = 1013;
cancelButton.y = 10;
cancelButton.visible = theModel.cancelButtonState();
cancelButton.addEventListener(MouseEvent.CLICK, cancelClicked);
beeSound = new BeeSound();
}
public function testElement(_arg1:String, _arg2:Point, _arg3:Number, _arg4:Number):Boolean{
var _local5:PlantElement = testElements.getTest(_arg1, _arg2.x, _arg2.y, _arg3);
var _local6:Boolean;
var _local7:Number = 1;
var _local8:* = plantLimit.getBounds(plantSprite);
var _local9:* = _local5.getBounds(plantSprite);
if (withinLimit(_local8, _local9)){
while ((((_local7 < nodes.length)) && ((_local6 == false)))) {
if (_arg4 != _local7){
if (hitTest(nodes[_local7], _local5, plantSprite, plantSprite) != null){
_local6 = true;
} else {
_local7++;
};
} else {
_local7++;
};
};
} else {
_local6 = true;
};
return (_local6);
}
private function childOutOfBounds(_arg1:PlantElement, _arg2:Rectangle, _arg3:Point):Boolean{
var _local4:Boolean;
var _local5:Rectangle = _arg1.getBounds(plantSprite);
_local5.offsetPoint(_arg3);
if (!withinLimit(_arg2, _local5)){
return (true);
};
var _local6:* = 0;
while (_local6 < _arg1.children.length) {
if (childOutOfBounds(_arg1.children[_local6], _arg2, _arg3)){
return (true);
};
_local6++;
};
return (false);
}
public function beeDone(_arg1:Event){
trace("bee done");
noOfBees--;
if (noOfBees <= 0){
donePollinate();
};
}
public function hideInfo(){
infoBox.hide();
}
private function withinLimit(_arg1:Rectangle, _arg2:Rectangle):Boolean{
if ((((((_arg2.left > _arg1.left)) && ((_arg2.right < _arg1.right)))) && ((_arg2.bottom < _arg1.bottom)))){
return (true);
};
return (false);
}
public function containsObject(_arg1:DisplayObject, _arg2:DisplayObject):Boolean{
var _local3:Rectangle = _arg1.getBounds(plantSprite);
var _local4:Rectangle = _arg2.getBounds(plantSprite);
return (_local3.containsRect(_local4));
}
public function doneEvent(_arg1:Event){
hideInfo();
dispatchEvent(new Event(View.DONEEVENT));
}
public function showInfo(_arg1:String, _arg2:String, _arg3:Boolean=false){
infoBox.show(_arg1, _arg2, _arg3);
}
public function cancelClicked(_arg1:Event){
if (theModel.webVersion){
if (theModel.webFullScreen){
stage.displayState = StageDisplayState.NORMAL;
theModel.webFullScreen = false;
cancelButton.visible = theModel.cancelButtonState();
};
} else {
theQuitDialog.show();
};
}
public function removePlant(){
var _local1:PlantElement;
while (nodes.length > 0) {
_local1 = nodes.pop();
if (plantSprite.contains(_local1)){
plantSprite.removeChild(_local1);
};
};
if (plantSprite != null){
while (plantSprite.numChildren > 0) {
plantSprite.removeChildAt(0);
};
};
if (groundSprite != null){
groundSprite.visible = false;
countGrowth();
};
}
public function nextMonth(){
theModel.nextMonth();
theStatus.updateMonth(theModel);
}
public function hideNext(_arg1:Event){
theContainer.scrollToTop();
theContainer.enableScroll(false);
nextButton.visible = false;
displayAllNodes(false);
}
public function doPests(){
var _local3:*;
var _local4:*;
leavesEaten = 0;
countGrowth();
noOfPests = Math.floor((theModel.growth.leaves / 4));
var _local1:Array = new Array();
var _local2:Number = (nodes.length - 1);
while ((((_local1.length < noOfPests)) && ((_local2 > 0)))) {
if ((((nodes[_local2].elementType == "Leaf")) && ((nodes[_local2].children.length == 0)))){
if (Math.random() > 0.2){
_local1.push(_local2);
};
};
_local2--;
};
if (_local1.length > 0){
showInfo("You're attacked by insects", "");
_local3 = 0;
while (_local3 < noOfPests) {
_local4 = new Pest();
insectsSprite.addChild(_local4);
_local4.setDone(pestDone, 10);
if (_local3 < _local1.length){
_local4.init(nodes[_local1[_local3]], this.eatLeaf);
};
_local3++;
};
} else {
dispatchEvent(new Event(View.DONEEVENT));
};
}
public function updateResources(_arg1:Event){
theStatus.updateResources(theModel.sugar, theModel.minerals);
theStatus.hilightResources();
}
public function showTip(){
var _local1:Object = theTips.getTip(theModel);
showInfo(_local1.title, _local1.text, true);
}
public function addFlower(_arg1:PlantElement, _arg2:Sprite, _arg3:Controller, _arg4:Point){
var _local5:* = new Flower(_arg2, _arg3, _arg4);
_local5.growNode = _arg1["node1"];
_arg1["node1"].enabled = false;
_local5.setRotation(0);
_arg2.addChild(_local5);
_arg1.addChildElement(_local5);
nodes.push(_local5);
}
public function growElement(_arg1:String, _arg2:Object){
var _local3:PlantElement;
var _local5:String;
displayAllNodes(false);
nextButton.visible = false;
var _local4:Class = (getDefinitionByName(_arg1) as Class);
_arg2.newElement = (new _local4(plantSprite, theController, _arg2.newPos) as PlantElement);
_arg2.newElement.growNode = _arg2.growNode;
if (_arg2.newElement.elementType != "Flower"){
plantSprite.addChildAt(_arg2.newElement, 0);
} else {
plantSprite.addChild(_arg2.newElement);
};
if (_arg2.newElement.pushUp){
_local3 = _arg2.growElement;
if (_arg2.growElement.children.length > 0){
trace("push with children");
_local5 = _arg2.growElement.children[0].elementType;
if ((((_local5 == "Leaf")) || ((_local5 == "Stem")))){
_local3 = _arg2.growElement.children[0];
};
};
_arg2.newElement.x = _local3.x;
_arg2.newElement.y = _local3.y;
_arg2.newElement.setRotation(_local3.rotation);
_local3.parentElement.removeChildElement(_local3);
_local3.parentElement.addChildElement(_arg2.newElement);
_arg2.newElement.addChildElement(_local3);
_arg2.newElement.initPush(_local3);
} else {
_arg2.newElement.setRotation((_arg2.rotation + _arg2.growElement.rotation));
_arg2.growElement.addChildElement(_arg2.newElement);
};
if (_arg2.newElement.elementType == "FlowerStem"){
addFlowerFrom = _arg2.newElement;
};
nodes.push(_arg2.newElement);
}
public function start(_arg1:Event){
theStatus.show();
theModel.plantType = theIntroScreen.getPlantType();
cancelButton.visible = theModel.cancelButtonState();
plantLimit = new PlantLimit();
plantLimit.visible = false;
plantLimit.x = 116;
plantLimit.y = 85;
theContainer.addChild(plantLimit);
if (groundSprite != null){
theContainer.removeChild(groundSprite);
};
if (theContainer.contains(infoBox)){
theContainer.removeChild(infoBox);
};
theContainer.removeScrollAreas();
if (theModel.plantType == "Wild"){
groundSprite = new WildBackground();
} else {
groundSprite = new FarmBackground();
};
groundSprite.cacheAsBitmap = true;
theNeighbours = new Neighbour(doneEvent);
groundSprite.addChild(theNeighbours);
beetleSprite = new Sprite();
groundSprite.addChild(beetleSprite);
beetleSprite.x = 500;
beetleSprite.y = 520;
theContainer.addChild(groundSprite);
theContainer.addChild(theContainer.getScrollAreas());
groundSprite.visible = true;
plantSprite = new Sprite();
var _local2:* = new Sprite();
_local2.addChild(plantSprite);
shadowFilter = new Array();
shadowFilter = [new DropShadowFilter(5, 45, 1, 5, 5)];
_local2.filters = shadowFilter;
theGrid = new Grid(0x0400, 0x0300, 25);
theContainer.addChild(theGrid);
thePlant = new FirstSeed(plantSprite, theController, new Point(0, 0));
theContainer.addChild(_local2);
theContainer.addChild(infoBox);
theContainer.setScrollAreas(plantSprite, 150);
plantSprite.addChild(testElements);
plantSprite.addChild(thePlant);
plantSprite.x = 500;
plantSprite.y = 520;
continueButton.visible = false;
theGrid.setGridPoints(thePlant.getPoints(), true);
nodes.push(thePlant);
checkNodes();
countGrowth();
theNutrients.hide();
theModel.reset();
theStatus.update(theModel);
theContainer.enableScroll(true);
theContainer.initScroll();
theTips.reset(theModel.plantType);
showTip();
theTimeOut.reset();
}
public function displayAllNodes(_arg1:Boolean){
var _local2:* = 0;
while (_local2 < nodes.length) {
nodes[_local2].displayAllNodes(_arg1);
_local2++;
};
}
public function testStem(_arg1, _arg2){
var _local3:PlantElement = testElements.getTest("Stem", _arg2.x, _arg2.y, _arg1.rotation);
var _local4:Point = _local3.getEndPoint();
var _local5:* = plantLimit.getBounds(plantSprite);
return (!(childOutOfBounds(_arg1, _local5, _local4)));
}
public function doResetScroll(){
theContainer.resetScroll();
}
public function checkNodes(){
displayAllNodes(true);
var _local1:* = 0;
while (_local1 < nodes.length) {
nodes[_local1].checkNodes();
nodes[_local1].nodeIndex = _local1;
_local1++;
};
}
public function donePollinate(){
var _local1:*;
var _local2:PlantElement;
var _local3:Bee;
soundChannel.stop();
trace("done pollinate");
countGrowth();
if (flowerNodes.length > 0){
_local1 = 0;
while (_local1 < flowerNodes.length) {
_local2 = new Seed(plantSprite, theController, new Point(flowerNodes[_local1].x, flowerNodes[_local1].y));
replaceElement(_local2, flowerNodes[_local1]);
_local1++;
};
countGrowth();
};
while (insectsSprite.numChildren > 0) {
_local3 = (insectsSprite.getChildAt(0) as Bee);
_local3.end();
insectsSprite.removeChildAt(0);
};
hideInfo();
dispatchEvent(new Event(View.DONEEVENT));
}
public function askAllSeeds(_arg1:Boolean){
theTimeOut.reset();
nextButton.visible = false;
displayAllNodes(false);
theDoAllSeeds.show(_arg1);
}
public function doBeetles(){
showInfo("A beetle dies in the ground", "Grow your roots to it to extract more minerals.");
var _local1:Beetle = new Beetle((theModel.beetles == 0));
beetleSprite.addChild(_local1);
theModel.beetles++;
_local1.start(doneEvent);
}
public function setController(_arg1:Controller){
theController = _arg1;
testElements = new TestElements(theController);
nextButton.addEventListener(MouseEvent.CLICK, theController.doneGrowth);
nextButton.addEventListener(MouseEvent.CLICK, hideNext);
continueButton.addEventListener(MouseEvent.CLICK, showNutrients);
}
public function replaceElement(_arg1:PlantElement, _arg2:PlantElement){
_arg1.x = _arg2.x;
_arg1.y = _arg2.y;
_arg1.growNode = _arg2.growNode;
_arg2.parentElement.addChildElement(_arg1);
_arg2.parentElement.removeChildElement(_arg2);
_arg1.setRotation(_arg2.rotation);
plantSprite.addChild(_arg1);
plantSprite.swapChildren(_arg1, _arg2);
plantSprite.removeChild(_arg2);
nodes[_arg2.nodeIndex] = _arg1;
_arg1.nodeIndex = _arg2.nodeIndex;
}
public function pollinateFlowers(){
var _local1:Number;
var _local3:*;
countGrowth();
noOfBees = (theModel.growth.flowers + 3);
if (theModel.growth.flowers > 0){
showInfo("Bees visit your plant", "They pollinate your flowers so they can become seeds.");
} else {
showInfo("Bees visit your plant", "But there are no flowers for them to pollinate.");
};
if (theModel.currentMonth == 3){
_local1 = 8;
} else {
_local1 = 12;
};
soundChannel = beeSound.play(0, 10);
var _local2:* = 0;
while (_local2 < noOfBees) {
_local3 = new Bee();
insectsSprite.addChild(_local3);
_local3.setDone(beeDone, _local1);
if (_local2 < flowerNodes.length){
_local3.init(flowerNodes[_local2], this.flowerPollinate);
};
_local2++;
};
}
public function doAllSeeds(_arg1:Event){
theDoAllSeeds.hide();
if (theDoAllSeeds.eject){
theController.ejectAllSeeds(nodes);
} else {
theController.growAllSeeds(nodes);
};
}
public function countGrowth(){
var _local3:*;
var _local4:Beetle;
var _local1:Object = {leaves:0, shadedLeaves:0, stem:0, roots:0, beetlesFound:0, flowers:0, seeds:0, bigSeeds:0};
flowerNodes = new Array();
var _local2:* = 0;
while (_local2 < nodes.length) {
nodes[_local2].nodeIndex = _local2;
switch (nodes[_local2].elementType){
case "Leaf":
_local1.leaves++;
if (((nodes[_local2].y + plantSprite.y) - 35) > theNeighbours.shadeheight){
_local1.shadedLeaves++;
};
break;
case "Stem":
_local1.stem++;
break;
case "Seed":
_local1.seeds++;
break;
case "Root":
_local1.roots++;
_local3 = 0;
while (_local3 < beetleSprite.numChildren) {
_local4 = (beetleSprite.getChildAt(_local3) as Beetle);
if (hitTest(_local4, nodes[_local2], beetleSprite, plantSprite)){
_local1.beetlesFound++;
_local4.foundByRoot();
trace("Found a beetle");
};
_local3++;
};
break;
case "Flower":
_local1.flowers++;
flowerNodes.push(nodes[_local2]);
break;
case "BigSeed":
_local1.bigSeeds++;
break;
};
_local2++;
};
trace(((((("Number of Flowers =" + _local1.flowers) + " leaves ") + _local1.leaves) + " roots ") + _local1.roots));
theModel.growth = _local1;
theStatus.update(theModel);
}
public function donePests(){
var _local1:Pest;
countGrowth();
while (insectsSprite.numChildren > 0) {
_local1 = (insectsSprite.getChildAt(0) as Pest);
_local1.end();
insectsSprite.removeChildAt(0);
};
hideInfo();
dispatchEvent(new Event(View.DONEEVENT));
}
public function pestDone(_arg1:Event){
trace("pest done");
noOfPests--;
if (noOfPests <= 0){
donePests();
};
}
public function showContinue(){
continueButton.visible = true;
countGrowth();
}
public function doWeeding(){
showInfo("The farmer removes the surrounding weeds", "");
theNeighbours.weed(3000);
countGrowth();
}
public function hitTest(_arg1:DisplayObject, _arg2:DisplayObject, _arg3:DisplayObject, _arg4:DisplayObject, _arg5:Boolean=true, _arg6:int=0xFF):Rectangle{
var _local7:Rectangle;
var _local8:Rectangle;
var _local9:Rectangle;
var _local10:BitmapData;
var _local11:Matrix;
var _local12:Matrix;
var _local13:Rectangle;
if (_arg1.hitTestObject(_arg2)){
_local7 = _arg1.getBounds(_arg3);
_local8 = _arg2.getBounds(_arg4);
_local9 = _local7.intersection(_local8);
_local9.x = Math.floor(_local9.x);
_local9.y = Math.floor(_local9.y);
_local9.width = Math.ceil(_local9.width);
_local9.height = Math.ceil(_local9.height);
if ((((_local9.width < 1)) || ((_local9.height < 1)))){
return (null);
};
if (!_arg5){
return (_local9);
};
_local10 = new BitmapData(_local9.width, _local9.height, false);
_local11 = _arg3.transform.concatenatedMatrix;
_local11.invert();
_local12 = _arg1.transform.concatenatedMatrix;
_local12.concat(_local11);
_local12.translate(-(_local9.left), -(_local9.top));
_local10.draw(_arg1, _local12, new ColorTransform(1, 1, 1, 1, 0xFF, -255, -255, _arg6));
_local11 = _arg4.transform.concatenatedMatrix;
_local11.invert();
_local12 = _arg2.transform.concatenatedMatrix;
_local12.concat(_local11);
_local12.translate(-(_local9.left), -(_local9.top));
_local10.draw(_arg2, _local12, new ColorTransform(1, 1, 1, 1, 0xFF, 0xFF, 0xFF, _arg6), "difference");
_local13 = _local10.getColorBoundsRect(4294967295, 4278255615);
if (_local13.width == 0){
return (null);
};
_local13.offset(_local9.left, _local9.top);
_local10.dispose();
return (_local13);
//unresolved jump
};
return (null);
}
public function flowerPollinate(_arg1:Event){
var _local2:* = (_arg1.target.targetFlower as PlantElement);
var _local3:PlantElement = new Seed(plantSprite, theController, new Point(_local2.x, _local2.y));
replaceElement(_local3, _local2);
}
public function eatLeaf(_arg1:Event){
trace("eat leaf");
var _local2:* = (_arg1.target.targetFlower as PlantElement);
removeElement(_local2);
leavesEaten++;
showInfo("You're attacked by insects", (("They've eaten " + leavesEaten) + " of your leaves."));
}
public function removeElement(_arg1:PlantElement){
var _local2:PlantElement = _arg1.parentElement;
_local2.removeChildElement(_arg1);
nodes.splice(_arg1.nodeIndex, 1);
if (plantSprite.contains(_arg1)){
plantSprite.removeChild(_arg1);
} else {
trace((("removal element " + _arg1) + " not in plant sprite"));
};
if ((((_local2.children.length == 0)) && ((_local2.elementType == "Stem")))){
(_local2 as Stem).enableNode();
};
}
public function doInsecticide(){
showInfo("The farmer sprays you against pests", "");
theInsecticide.show(3000);
}
public function plantChanged(){
var _local1:Object;
trace("plant changed");
if (addFlowerFrom != null){
addFlower(addFlowerFrom, plantSprite, theController, addFlowerFrom.getGrowPos());
addFlowerFrom = null;
} else {
_local1 = theTips.getParticularTip(1, theModel);
showInfo(_local1.title, _local1.text, true);
countGrowth();
checkNodes();
};
if (theModel.currentMonth > 3){
nextButton.visible = true;
} else {
if (theModel.sugar == 0){
showInfo("You've used all your sugar", "Click on ‘Finish growing for this month?’ to move on.", true);
nextButton.visible = true;
} else {
if (theModel.minerals == 0){
showInfo("You've used all your minerals", "Click on ‘Finish growing for this month?’ to move on.", true);
nextButton.visible = true;
};
};
};
}
public function doWeather(){
theWeather.showWeather(3000, theModel.getCurrentMonth().rainfallIndex);
}
public function doneScrollEvent(_arg1:Event){
dispatchEvent(new Event(View.DONEEVENT));
}
public function doOneSeed(_arg1:Event){
theTimeOut.reset();
theDoAllSeeds.hide();
if (theDoAllSeeds.eject){
theController.ejectLastSeed();
} else {
theController.growLastSeed();
};
}
public function NutrientsDone(_arg1:Event){
theNutrients.hide();
nextMonth();
theModel.useResource(Math.round(-(theNutrients.sugarCreated)), 0);
checkNodes();
theNeighbours.grow();
theContainer.enableScroll(true);
theContainer.resetScroll();
theModel.ejectThisMonth = 0;
theModel.growThisMonth = 0;
if (theModel.currentMonth > 3){
nextButton.visible = true;
} else {
nextButton.visible = false;
};
showTip();
}
public function showNutrients(_arg1:Event){
theTimeOut.reset();
continueButton.visible = false;
theNutrients.show(theModel.getCurrentMonth(), theModel.growth, theModel.plantType);
}
public function resetTimeOut(_arg1:Event){
theTimeOut.reset();
}
public function introScreen(_arg1:Event=null){
var _local2:Boolean;
if (_arg1 == null){
_arg1 = new Event("no event");
};
if (!theModel.webVersion){
theTimeOut.off();
};
if (!_local2){
nextButton.visible = false;
theStatus.hide();
theQuitDialog.hide();
theNutrients.hide();
theDoAllSeeds.hide();
theEndGame.hide();
theController.stopEvents();
theIntroScreen.show((_arg1.type == TimeOut.TIMEOUT));
theModel.reset();
removePlant();
};
}
public function doIrrigation(){
showInfo("The farmer waters and fertilises you", "");
theIrrigation.show(3000);
}
public function growReplacementElement(_arg1:String, _arg2:Object){
var _local3:Class = (getDefinitionByName(_arg1) as Class);
_arg2.newElement = (new _local3(plantSprite, theController, new Point(0, 0)) as PlantElement);
replaceElement(_arg2.newElement, _arg2.growElement);
}
}
}//package
Section 103
//WildBackground (WildBackground)
package {
import flash.display.*;
public dynamic class WildBackground extends MovieClip {
}
}//package