Section 1
//body_2 (_panda_fla.body_2)
package _panda_fla {
import flash.display.*;
public dynamic class body_2 extends MovieClip {
public function body_2(){
addFrameScript(15, frame16, 31, frame32, 47, frame48, 63, frame64, 79, frame80);
}
function frame64(){
gotoAndPlay("up");
}
function frame80(){
gotoAndPlay("down_left");
}
function frame16(){
gotoAndPlay("down");
}
function frame48(){
gotoAndPlay("left_up");
}
function frame32(){
gotoAndPlay("left");
}
}
}//package _panda_fla
Section 2
//buildCage_4 (_panda_fla.buildCage_4)
package _panda_fla {
import flash.display.*;
public dynamic class buildCage_4 extends MovieClip {
public function buildCage_4(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package _panda_fla
Section 3
//BrownBear (bears.BrownBear)
package bears {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import com.cheezeworld.math.*;
import flash.utils.*;
import houses.*;
import shop.*;
import game.*;
import pets.*;
import flash.media.*;
import com.melesta.utils.math.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class BrownBear extends BrownBearTemplate implements IBear {
public var inCage:Boolean;// = false
private var _stageInstance:DisplayObjectContainer;
private var timer:Timer;
private var rotationDirect:Number;// = 1
private var _freeTimer:Timer;
private var sound:SoundChannel;
private var _hitTimer:Timer;
private var type:String;
private var pet:MovieClip;
private var clicks:Number;// = 0
private var gameController:GameController;
private var _freeCounter:Number;// = 0
private var _counter:Number;// = 0
public function BrownBear(){
super();
sound = new SoundChannel();
gameController = GameController.instance;
gameController.addEventListener(GameController.PAUSE_GAME, pause, false, 0, true);
gameController.addEventListener(GameController.RESUME_GAME, resume, false, 0, true);
gameController.addEventListener(GameController.LEVEL_COMPLETED, remove, false, 0, true);
addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
this.cacheAsBitmap = true;
_freeTimer = new Timer(1000);
_freeTimer.addEventListener(TimerEvent.TIMER, brokeCage, false, 0, true);
_hitTimer = new Timer(100);
_hitTimer.addEventListener(TimerEvent.TIMER, hitChicken, false, 0, true);
_hitTimer.addEventListener(TimerEvent.TIMER, hitPig, false, 0, true);
}
public function show(posx:Number, posy:Number, delay:Number, stageInstance:DisplayObjectContainer=null):void{
this.x = posx;
this.y = -500;
_stageInstance = stageInstance;
_stageInstance.addChild(this);
this.body.stop();
Tweener.addTween(this, {y:150, time:3, delay:delay, transition:"easeInCirc", onComplete:startAnimation});
timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, move);
sound = SoundManager.play("bear1_brown_scream", 1000);
}
private function remove(event:Event=null):void{
_stageInstance.removeChild(this);
removeEventListener(MouseEvent.CLICK, onClick);
timer.stop();
_hitTimer.stop();
_hitTimer.removeEventListener(TimerEvent.TIMER, hitChicken);
_hitTimer.removeEventListener(TimerEvent.TIMER, hitPig);
timer.removeEventListener(TimerEvent.TIMER, move);
gameController.removeEventListener(GameController.PAUSE_GAME, pause);
gameController.removeEventListener(GameController.RESUME_GAME, resume);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, remove);
_freeTimer.stop();
_freeTimer.removeEventListener(TimerEvent.TIMER, brokeCage);
}
private function hitPig(event:TimerEvent=null):void{
var i:int;
if (event){
event.stopPropagation();
};
if (Pig.pigList){
if (Pig.pigList.length > 0){
i = 0;
while (i < Pig.count) {
if (this.hit.hitTestObject(Pig.pigList[i])){
Pig.pigList[i].kill();
return;
};
i++;
};
};
};
}
private function brokeCage(event:TimerEvent=null):void{
var p1:Point;
var newX:Number;
var newY:Number;
var p2:Point;
var dir:Object;
_freeCounter++;
if ((((_freeCounter > 5)) && ((_freeCounter < 15)))){
SoundManager.play("cage_breaking");
Tweener.addTween(this, {rotation:(10 * rotationDirect), time:1});
if (rotationDirect == -1){
rotationDirect = 1;
} else {
rotationDirect = -1;
};
};
if (_freeCounter == 15){
buildCage.visible = false;
SoundManager.play("cage_broke_bear_flee");
p1 = new Point(this.x, this.y);
newX = 800;
newY = this.y;
p2 = new Point(newX, newY);
dir = Direction.getDirection(p1, p2);
this.body.gotoAndPlay(dir.direction);
if (dir.right){
this.scaleX = -1;
} else {
this.scaleX = 1;
};
Tweener.removeTweens(this);
Tweener.addTween(this, {y:newY, x:newX, time:0.4, transition:"linear", onComplete:remove});
};
}
public function move(event:TimerEvent=null):void{
var p1:Point;
var newX:Number;
var newY:Number;
var p2:Point;
var dir:Object;
if (event){
event.stopPropagation();
};
if (_counter == 0){
_counter = 7;
if (event != null){
event.stopPropagation();
};
p1 = new Point(this.x, this.y);
newX = MathUtils.rand(150, 400);
newY = MathUtils.rand(150, 300);
p2 = new Point(newX, newY);
dir = Direction.getDirection(p1, p2);
this.body.gotoAndPlay(dir.direction);
if (dir.right){
this.scaleX = -1;
} else {
this.scaleX = 1;
};
Tweener.removeTweens(this);
Tweener.addTween(this, {y:newY, x:newX, time:5, transition:"linear"});
};
_counter--;
}
public function startAnimation():void{
SoundManager.play("bear_landing", 1);
timer.start();
_hitTimer.start();
move();
}
private function hitChicken(event:TimerEvent=null):void{
var i:int;
event.stopPropagation();
if (Chicken.chickenList){
if (Chicken.chickenList.length > 0){
i = 0;
while (i < Chicken.count) {
if (this.hit.hitTestObject(Chicken.chickenList[i])){
Chicken.chickenList[i].kill();
return;
};
i++;
};
};
};
}
public function resume(event:Event=null):void{
Tweener.resumeTweens(this);
timer.start();
if (!inCage){
this.body.play();
_hitTimer.start();
sound = SoundManager.play("bear1_brown_scream", 1000);
} else {
_freeTimer.start();
};
}
private function onClick(event:MouseEvent=null):void{
event.stopPropagation();
clicks++;
buildCage.gotoAndStop(clicks);
if (clicks == Number((9 - ShopWindow.availableUpgrades[0]))){
_hitTimer.stop();
buildCage.gotoAndStop(9);
inCage = true;
this.body.stop();
_freeTimer.start();
sound.stop();
Tweener.removeTweens(this, x, y);
timer.stop();
timer.removeEventListener(TimerEvent.TIMER, move, false);
};
if (clicks > Number((9 - ShopWindow.availableUpgrades[0]))){
if (Depot.instance.addProduct("BROWN")){
SoundManager.play("product_take", 1);
this.width = 50;
this.height = 50;
_freeTimer.stop();
Tweener.removeTweens(this);
Tweener.addTween(this, {y:378, time:0.3, onComplete:remove, transition:"easeOutCirc"});
Tweener.addTween(this, {x:265, time:0.3, transition:"easeInOutBack"});
} else {
SoundManager.play("fool_action", 1);
};
} else {
SoundManager.play("cage_click", 1);
};
}
public function pause(event:Event=null):void{
Tweener.pauseTweens(this);
_hitTimer.stop();
_freeTimer.stop();
timer.stop();
this.body.stop();
sound.stop();
}
}
}//package bears
Section 4
//BrownBearTemplate (bears.BrownBearTemplate)
package bears {
import flash.display.*;
public dynamic class BrownBearTemplate extends MovieClip {
public var buildCage:MovieClip;
public var hit:MovieClip;
public var body:MovieClip;
}
}//package bears
Section 5
//IBear (bears.IBear)
package bears {
import flash.events.*;
import flash.display.*;
public interface IBear {
function move(:TimerEvent=null):void;
function startAnimation():void;
function show(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:DisplayObjectContainer=null):void;
function pause(:Event=null):void;
function resume(:Event=null):void;
}
}//package bears
Section 6
//Panda (bears.Panda)
package bears {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import com.cheezeworld.math.*;
import flash.utils.*;
import houses.*;
import shop.*;
import ui.*;
import game.*;
import pets.*;
import utils.*;
import flash.media.*;
import com.melesta.utils.math.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class Panda extends PandaTemplate implements IBear {
public var inCage:Boolean;// = false
private var _stageInstance:DisplayObjectContainer;
private var timer:Timer;
private var rotationDirect:Number;// = 1
private var _freeTimer:Timer;
private var sound:SoundChannel;
private var _hitTimer:Timer;
private var type:String;
private var pet:MovieClip;
private var clicks:Number;// = 0
private var gameController:GameController;
private var _freeCounter:Number;// = 0
private var _counter:Number;// = 0
public static var firstShow:Boolean = true;
public function Panda(){
super();
sound = new SoundChannel();
gameController = GameController.instance;
gameController.addEventListener(GameController.PAUSE_GAME, pause, false, 0, true);
gameController.addEventListener(GameController.RESUME_GAME, resume, false, 0, true);
gameController.addEventListener(GameController.LEVEL_COMPLETED, remove, false, 0, true);
addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
this.cacheAsBitmap = true;
_freeTimer = new Timer(1000);
_freeTimer.addEventListener(TimerEvent.TIMER, brokeCage, false, 0, true);
_hitTimer = new Timer(100);
_hitTimer.addEventListener(TimerEvent.TIMER, hitChicken, false, 0, true);
}
public function show(posx:Number, posy:Number, delay:Number, stageInstance:DisplayObjectContainer=null):void{
this.x = posx;
this.y = -500;
_stageInstance = stageInstance;
_stageInstance.addChild(this);
Tweener.addTween(this, {y:150, time:3, delay:delay, transition:"easeInCirc", onComplete:startAnimation});
timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, move);
sound = SoundManager.play("bear0_panda_scream", 1000);
this.body.stop();
}
private function remove(event:Event=null):void{
_stageInstance.removeChild(this);
removeEventListener(MouseEvent.CLICK, onClick);
timer.stop();
_hitTimer.stop();
_hitTimer.removeEventListener(TimerEvent.TIMER, hitChicken);
_hitTimer.removeEventListener(TimerEvent.TIMER, hitPig);
timer.removeEventListener(TimerEvent.TIMER, move);
gameController.removeEventListener(GameController.PAUSE_GAME, pause);
gameController.removeEventListener(GameController.RESUME_GAME, resume);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, remove);
_freeTimer.stop();
_freeTimer.removeEventListener(TimerEvent.TIMER, brokeCage);
}
private function hitPig(event:TimerEvent=null):void{
var i:int;
if (event){
event.stopPropagation();
};
if (Pig.pigList){
if (Pig.pigList.length > 0){
i = 0;
while (i < Pig.count) {
if (this.hit.hitTestObject(Pig.pigList[i])){
Pig.pigList[i].kill();
return;
};
i++;
};
};
};
}
private function brokeCage(event:TimerEvent=null):void{
var p1:Point;
var newX:Number;
var newY:Number;
var p2:Point;
var dir:Object;
_freeCounter++;
if ((((_freeCounter > 5)) && ((_freeCounter < 15)))){
SoundManager.play("cage_breaking");
Tweener.addTween(this, {rotation:(10 * rotationDirect), time:1});
if (rotationDirect == -1){
rotationDirect = 1;
} else {
rotationDirect = -1;
};
};
if (_freeCounter == 15){
buildCage.visible = false;
SoundManager.play("cage_broke_bear_flee");
p1 = new Point(this.x, this.y);
newX = 800;
newY = this.y;
p2 = new Point(newX, newY);
dir = Direction.getDirection(p1, p2);
this.body.gotoAndPlay(dir.direction);
if (dir.right){
this.scaleX = -1;
} else {
this.scaleX = 1;
};
Tweener.removeTweens(this);
Tweener.addTween(this, {y:newY, x:newX, time:0.4, transition:"linear", onComplete:remove});
};
}
public function move(event:TimerEvent=null):void{
var p1:Point;
var newX:Number;
var newY:Number;
var p2:Point;
var dir:Object;
if (event){
event.stopPropagation();
};
if (_counter == 0){
_counter = 7;
if (event != null){
event.stopPropagation();
};
p1 = new Point(this.x, this.y);
newX = MathUtils.rand(150, 400);
newY = MathUtils.rand(150, 300);
p2 = new Point(newX, newY);
dir = Direction.getDirection(p1, p2);
this.body.gotoAndPlay(dir.direction);
if (dir.right){
this.scaleX = -1;
} else {
this.scaleX = 1;
};
Tweener.removeTweens(this);
Tweener.addTween(this, {y:newY, x:newX, time:5, transition:"linear"});
};
_counter--;
}
public function startAnimation():void{
SoundManager.play("bear_landing", 1);
timer.start();
_hitTimer.start();
move();
if (firstShow){
sound.stop();
firstShow = false;
BlockTooltip.instance.show(this.x, this.y, Config.currentLanguage.tooltips.bear);
};
}
private function hitChicken(event:TimerEvent=null):void{
var i:int;
event.stopPropagation();
if (Chicken.chickenList){
if (Chicken.chickenList.length > 0){
i = 0;
while (i < Chicken.count) {
if (this.hit.hitTestObject(Chicken.chickenList[i])){
Chicken.chickenList[i].kill();
return;
};
i++;
};
};
};
}
public function resume(event:Event=null):void{
sound.stop();
Tweener.resumeTweens(this);
timer.start();
if (!inCage){
this.body.play();
_hitTimer.start();
sound = SoundManager.play("bear0_panda_scream", 1000);
} else {
_freeTimer.start();
};
}
private function onClick(event:MouseEvent=null):void{
event.stopPropagation();
clicks++;
buildCage.gotoAndStop(clicks);
if (clicks == Number((9 - ShopWindow.availableUpgrades[0]))){
_hitTimer.stop();
buildCage.gotoAndStop(9);
inCage = true;
this.body.stop();
_freeTimer.start();
sound.stop();
Tweener.removeTweens(this, x, y);
timer.stop();
timer.removeEventListener(TimerEvent.TIMER, move, false);
};
if (clicks > Number((9 - ShopWindow.availableUpgrades[0]))){
if (Depot.instance.addProduct("PANDA")){
SoundManager.play("product_take", 1);
this.width = 50;
this.height = 50;
_freeTimer.stop();
Tweener.removeTweens(this);
Tweener.addTween(this, {y:378, time:0.3, onComplete:remove, transition:"easeOutCirc"});
Tweener.addTween(this, {x:265, time:0.3, transition:"easeInOutBack"});
} else {
SoundManager.play("fool_action", 1);
};
} else {
SoundManager.play("cage_click", 1);
};
}
public function pause(event:Event=null):void{
Tweener.pauseTweens(this);
_hitTimer.stop();
_freeTimer.stop();
timer.stop();
this.body.stop();
sound.stop();
}
}
}//package bears
Section 7
//PandaTemplate (bears.PandaTemplate)
package bears {
import flash.display.*;
public dynamic class PandaTemplate extends MovieClip {
public var buildCage:MovieClip;
public var hit:MovieClip;
public var body:MovieClip;
public function PandaTemplate(){
addFrameScript(0, frame1);
}
function frame1(){
buildCage.mouseEnabled = false;
buildCage.mouseChildren = false;
}
}
}//package bears
Section 8
//body_2 (brownBear_fla.body_2)
package brownBear_fla {
import flash.display.*;
public dynamic class body_2 extends MovieClip {
public function body_2(){
addFrameScript(15, frame16, 31, frame32, 47, frame48, 63, frame64, 79, frame80);
}
function frame64(){
gotoAndPlay("up");
}
function frame80(){
gotoAndPlay("left_up");
}
function frame16(){
gotoAndPlay("down");
}
function frame48(){
gotoAndPlay("left_down");
}
function frame32(){
gotoAndPlay("left");
}
}
}//package brownBear_fla
Section 9
//buildCage_4 (brownBear_fla.buildCage_4)
package brownBear_fla {
import flash.display.*;
public dynamic class buildCage_4 extends MovieClip {
public function buildCage_4(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package brownBear_fla
Section 10
//AuxFunctions (caurina.transitions.AuxFunctions)
package caurina.transitions {
public class AuxFunctions {
public function AuxFunctions(){
super();
}
public static function getObjectLength(p_object:Object):uint{
var pName:String;
var totalProperties:uint;
for (pName in p_object) {
totalProperties++;
};
return (totalProperties);
}
public static function numberToG(p_num:Number):Number{
return (((p_num & 0xFF00) >> 8));
}
public static function numberToB(p_num:Number):Number{
return ((p_num & 0xFF));
}
public static function numberToR(p_num:Number):Number{
return (((p_num & 0xFF0000) >> 16));
}
public static function concatObjects(... _args):Object{
var currentObject:Object;
var prop:String;
var finalObject:Object = {};
var i:int;
while (i < _args.length) {
currentObject = _args[i];
for (prop in currentObject) {
if (currentObject[prop] == null){
delete finalObject[prop];
} else {
finalObject[prop] = currentObject[prop];
};
};
i++;
};
return (finalObject);
}
}
}//package caurina.transitions
Section 11
//Equations (caurina.transitions.Equations)
package caurina.transitions {
public class Equations {
public function Equations(){
super();
trace("Equations is a static class and should not be instantiated.");
}
public static function easeOutBounce(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
if (t < (1 / 2.75)){
return (((c * ((7.5625 * t) * t)) + b));
};
if (t < (2 / 2.75)){
t = (t - (1.5 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.75)) + b));
};
if (t < (2.5 / 2.75)){
t = (t - (2.25 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.9375)) + b));
};
t = (t - (2.625 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.984375)) + b));
}
public static function easeInOutElastic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number;
if (t == 0){
return (b);
};
t = (t / (d / 2));
if (t == 2){
return ((b + c));
};
var p:Number = (((!(Boolean(p_params))) || (isNaN(p_params.period)))) ? (d * (0.3 * 1.5)) : p_params.period;
var a:Number = (((!(Boolean(p_params))) || (isNaN(p_params.amplitude)))) ? 0 : p_params.amplitude;
if (((!(Boolean(a))) || ((a < Math.abs(c))))){
a = c;
s = (p / 4);
} else {
s = ((p / (2 * Math.PI)) * Math.asin((c / a)));
};
if (t < 1){
--t;
return (((-0.5 * ((a * Math.pow(2, (10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p)))) + b));
};
--t;
return ((((((a * Math.pow(2, (-10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p))) * 0.5) + c) + b));
}
public static function easeInOutQuad(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return (((((c / 2) * t) * t) + b));
};
--t;
return ((((-(c) / 2) * ((t * (t - 2)) - 1)) + b));
}
public static function easeInOutBounce(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (((easeInBounce((t * 2), 0, c, d) * 0.5) + b));
};
return ((((easeOutBounce(((t * 2) - d), 0, c, d) * 0.5) + (c * 0.5)) + b));
}
public static function easeInOutBack(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number = (((!(Boolean(p_params))) || (isNaN(p_params.overshoot)))) ? 1.70158 : p_params.overshoot;
t = (t / (d / 2));
if (t < 1){
s = (s * 1.525);
return ((((c / 2) * ((t * t) * (((s + 1) * t) - s))) + b));
};
t = (t - 2);
s = (s * 1.525);
return ((((c / 2) * (((t * t) * (((s + 1) * t) + s)) + 2)) + b));
}
public static function easeOutInCubic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutCubic((t * 2), b, (c / 2), d, p_params));
};
return (easeInCubic(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeNone(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return ((((c * t) / d) + b));
}
public static function easeOutBack(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number = (((!(Boolean(p_params))) || (isNaN(p_params.overshoot)))) ? 1.70158 : p_params.overshoot;
t = ((t / d) - 1);
return (((c * (((t * t) * (((s + 1) * t) + s)) + 1)) + b));
}
public static function easeInOutSine(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return ((((-(c) / 2) * (Math.cos(((Math.PI * t) / d)) - 1)) + b));
}
public static function easeInBack(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number = (((!(Boolean(p_params))) || (isNaN(p_params.overshoot)))) ? 1.70158 : p_params.overshoot;
t = (t / d);
return (((((c * t) * t) * (((s + 1) * t) - s)) + b));
}
public static function easeInQuart(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return ((((((c * t) * t) * t) * t) + b));
}
public static function easeOutInQuint(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutQuint((t * 2), b, (c / 2), d, p_params));
};
return (easeInQuint(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeOutInBounce(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutBounce((t * 2), b, (c / 2), d, p_params));
};
return (easeInBounce(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function init():void{
Tweener.registerTransition("easenone", easeNone);
Tweener.registerTransition("linear", easeNone);
Tweener.registerTransition("easeinquad", easeInQuad);
Tweener.registerTransition("easeoutquad", easeOutQuad);
Tweener.registerTransition("easeinoutquad", easeInOutQuad);
Tweener.registerTransition("easeoutinquad", easeOutInQuad);
Tweener.registerTransition("easeincubic", easeInCubic);
Tweener.registerTransition("easeoutcubic", easeOutCubic);
Tweener.registerTransition("easeinoutcubic", easeInOutCubic);
Tweener.registerTransition("easeoutincubic", easeOutInCubic);
Tweener.registerTransition("easeinquart", easeInQuart);
Tweener.registerTransition("easeoutquart", easeOutQuart);
Tweener.registerTransition("easeinoutquart", easeInOutQuart);
Tweener.registerTransition("easeoutinquart", easeOutInQuart);
Tweener.registerTransition("easeinquint", easeInQuint);
Tweener.registerTransition("easeoutquint", easeOutQuint);
Tweener.registerTransition("easeinoutquint", easeInOutQuint);
Tweener.registerTransition("easeoutinquint", easeOutInQuint);
Tweener.registerTransition("easeinsine", easeInSine);
Tweener.registerTransition("easeoutsine", easeOutSine);
Tweener.registerTransition("easeinoutsine", easeInOutSine);
Tweener.registerTransition("easeoutinsine", easeOutInSine);
Tweener.registerTransition("easeincirc", easeInCirc);
Tweener.registerTransition("easeoutcirc", easeOutCirc);
Tweener.registerTransition("easeinoutcirc", easeInOutCirc);
Tweener.registerTransition("easeoutincirc", easeOutInCirc);
Tweener.registerTransition("easeinexpo", easeInExpo);
Tweener.registerTransition("easeoutexpo", easeOutExpo);
Tweener.registerTransition("easeinoutexpo", easeInOutExpo);
Tweener.registerTransition("easeoutinexpo", easeOutInExpo);
Tweener.registerTransition("easeinelastic", easeInElastic);
Tweener.registerTransition("easeoutelastic", easeOutElastic);
Tweener.registerTransition("easeinoutelastic", easeInOutElastic);
Tweener.registerTransition("easeoutinelastic", easeOutInElastic);
Tweener.registerTransition("easeinback", easeInBack);
Tweener.registerTransition("easeoutback", easeOutBack);
Tweener.registerTransition("easeinoutback", easeInOutBack);
Tweener.registerTransition("easeoutinback", easeOutInBack);
Tweener.registerTransition("easeinbounce", easeInBounce);
Tweener.registerTransition("easeoutbounce", easeOutBounce);
Tweener.registerTransition("easeinoutbounce", easeInOutBounce);
Tweener.registerTransition("easeoutinbounce", easeOutInBounce);
}
public static function easeOutExpo(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return (((t)==d) ? (b + c) : (((c * 1.001) * (-(Math.pow(2, ((-10 * t) / d))) + 1)) + b));
}
public static function easeOutInBack(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutBack((t * 2), b, (c / 2), d, p_params));
};
return (easeInBack(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeInExpo(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return (((t)==0) ? b : (((c * Math.pow(2, (10 * ((t / d) - 1)))) + b) - (c * 0.001)));
}
public static function easeInCubic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return (((((c * t) * t) * t) + b));
}
public static function easeInQuint(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return (((((((c * t) * t) * t) * t) * t) + b));
}
public static function easeInOutCirc(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return ((((-(c) / 2) * (Math.sqrt((1 - (t * t))) - 1)) + b));
};
t = (t - 2);
return ((((c / 2) * (Math.sqrt((1 - (t * t))) + 1)) + b));
}
public static function easeInQuad(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return ((((c * t) * t) + b));
}
public static function easeInBounce(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return (((c - easeOutBounce((d - t), 0, c, d)) + b));
}
public static function easeOutInExpo(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutExpo((t * 2), b, (c / 2), d, p_params));
};
return (easeInExpo(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeOutQuart(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = ((t / d) - 1);
return (((-(c) * ((((t * t) * t) * t) - 1)) + b));
}
public static function easeInSine(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return ((((-(c) * Math.cos(((t / d) * (Math.PI / 2)))) + c) + b));
}
public static function easeInOutQuart(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return (((((((c / 2) * t) * t) * t) * t) + b));
};
t = (t - 2);
return ((((-(c) / 2) * ((((t * t) * t) * t) - 2)) + b));
}
public static function easeOutQuad(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return ((((-(c) * t) * (t - 2)) + b));
}
public static function easeOutInElastic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutElastic((t * 2), b, (c / 2), d, p_params));
};
return (easeInElastic(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeInElastic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number;
if (t == 0){
return (b);
};
t = (t / d);
if (t == 1){
return ((b + c));
};
var p:Number = (((!(Boolean(p_params))) || (isNaN(p_params.period)))) ? (d * 0.3) : p_params.period;
var a:Number = (((!(Boolean(p_params))) || (isNaN(p_params.amplitude)))) ? 0 : p_params.amplitude;
if (((!(Boolean(a))) || ((a < Math.abs(c))))){
a = c;
s = (p / 4);
} else {
s = ((p / (2 * Math.PI)) * Math.asin((c / a)));
};
--t;
return ((-(((a * Math.pow(2, (10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p)))) + b));
}
public static function easeOutCubic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = ((t / d) - 1);
return (((c * (((t * t) * t) + 1)) + b));
}
public static function easeOutQuint(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = ((t / d) - 1);
return (((c * (((((t * t) * t) * t) * t) + 1)) + b));
}
public static function easeOutInQuad(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutQuad((t * 2), b, (c / 2), d, p_params));
};
return (easeInQuad(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeOutSine(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return (((c * Math.sin(((t / d) * (Math.PI / 2)))) + b));
}
public static function easeInOutCubic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return ((((((c / 2) * t) * t) * t) + b));
};
t = (t - 2);
return ((((c / 2) * (((t * t) * t) + 2)) + b));
}
public static function easeInOutQuint(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return ((((((((c / 2) * t) * t) * t) * t) * t) + b));
};
t = (t - 2);
return ((((c / 2) * (((((t * t) * t) * t) * t) + 2)) + b));
}
public static function easeInCirc(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return (((-(c) * (Math.sqrt((1 - (t * t))) - 1)) + b));
}
public static function easeOutInSine(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutSine((t * 2), b, (c / 2), d, p_params));
};
return (easeInSine(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeInOutExpo(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t == 0){
return (b);
};
if (t == d){
return ((b + c));
};
t = (t / (d / 2));
if (t < 1){
return (((((c / 2) * Math.pow(2, (10 * (t - 1)))) + b) - (c * 0.0005)));
};
--t;
return (((((c / 2) * 1.0005) * (-(Math.pow(2, (-10 * t))) + 2)) + b));
}
public static function easeOutElastic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number;
if (t == 0){
return (b);
};
t = (t / d);
if (t == 1){
return ((b + c));
};
var p:Number = (((!(Boolean(p_params))) || (isNaN(p_params.period)))) ? (d * 0.3) : p_params.period;
var a:Number = (((!(Boolean(p_params))) || (isNaN(p_params.amplitude)))) ? 0 : p_params.amplitude;
if (((!(Boolean(a))) || ((a < Math.abs(c))))){
a = c;
s = (p / 4);
} else {
s = ((p / (2 * Math.PI)) * Math.asin((c / a)));
};
return (((((a * Math.pow(2, (-10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p))) + c) + b));
}
public static function easeOutCirc(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = ((t / d) - 1);
return (((c * Math.sqrt((1 - (t * t)))) + b));
}
public static function easeOutInQuart(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutQuart((t * 2), b, (c / 2), d, p_params));
};
return (easeInQuart(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeOutInCirc(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutCirc((t * 2), b, (c / 2), d, p_params));
};
return (easeInCirc(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
}
}//package caurina.transitions
Section 12
//PropertyInfoObj (caurina.transitions.PropertyInfoObj)
package caurina.transitions {
public class PropertyInfoObj {
public var modifierParameters:Array;
public var isSpecialProperty:Boolean;
public var valueComplete:Number;
public var modifierFunction:Function;
public var extra:Object;
public var valueStart:Number;
public var hasModifier:Boolean;
public var arrayIndex:Number;
public var originalValueComplete:Object;
public function PropertyInfoObj(p_valueStart:Number, p_valueComplete:Number, p_originalValueComplete:Object, p_arrayIndex:Number, p_extra:Object, p_isSpecialProperty:Boolean, p_modifierFunction:Function, p_modifierParameters:Array){
super();
valueStart = p_valueStart;
valueComplete = p_valueComplete;
originalValueComplete = p_originalValueComplete;
arrayIndex = p_arrayIndex;
extra = p_extra;
isSpecialProperty = p_isSpecialProperty;
hasModifier = Boolean(p_modifierFunction);
modifierFunction = p_modifierFunction;
modifierParameters = p_modifierParameters;
}
public function toString():String{
var returnStr:String = "\n[PropertyInfoObj ";
returnStr = (returnStr + ("valueStart:" + String(valueStart)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("valueComplete:" + String(valueComplete)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("originalValueComplete:" + String(originalValueComplete)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("arrayIndex:" + String(arrayIndex)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("extra:" + String(extra)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("isSpecialProperty:" + String(isSpecialProperty)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("hasModifier:" + String(hasModifier)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("modifierFunction:" + String(modifierFunction)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("modifierParameters:" + String(modifierParameters)));
returnStr = (returnStr + "]\n");
return (returnStr);
}
public function clone():PropertyInfoObj{
var nProperty:PropertyInfoObj = new PropertyInfoObj(valueStart, valueComplete, originalValueComplete, arrayIndex, extra, isSpecialProperty, modifierFunction, modifierParameters);
return (nProperty);
}
}
}//package caurina.transitions
Section 13
//SpecialProperty (caurina.transitions.SpecialProperty)
package caurina.transitions {
public class SpecialProperty {
public var parameters:Array;
public var getValue:Function;
public var preProcess:Function;
public var setValue:Function;
public function SpecialProperty(p_getFunction:Function, p_setFunction:Function, p_parameters:Array=null, p_preProcessFunction:Function=null){
super();
getValue = p_getFunction;
setValue = p_setFunction;
parameters = p_parameters;
preProcess = p_preProcessFunction;
}
public function toString():String{
var value:String = "";
value = (value + "[SpecialProperty ");
value = (value + ("getValue:" + String(getValue)));
value = (value + ", ");
value = (value + ("setValue:" + String(setValue)));
value = (value + ", ");
value = (value + ("parameters:" + String(parameters)));
value = (value + ", ");
value = (value + ("preProcess:" + String(preProcess)));
value = (value + "]");
return (value);
}
}
}//package caurina.transitions
Section 14
//SpecialPropertyModifier (caurina.transitions.SpecialPropertyModifier)
package caurina.transitions {
public class SpecialPropertyModifier {
public var getValue:Function;
public var modifyValues:Function;
public function SpecialPropertyModifier(p_modifyFunction:Function, p_getFunction:Function){
super();
modifyValues = p_modifyFunction;
getValue = p_getFunction;
}
public function toString():String{
var value:String = "";
value = (value + "[SpecialPropertyModifier ");
value = (value + ("modifyValues:" + String(modifyValues)));
value = (value + ", ");
value = (value + ("getValue:" + String(getValue)));
value = (value + "]");
return (value);
}
}
}//package caurina.transitions
Section 15
//SpecialPropertySplitter (caurina.transitions.SpecialPropertySplitter)
package caurina.transitions {
public class SpecialPropertySplitter {
public var parameters:Array;
public var splitValues:Function;
public function SpecialPropertySplitter(p_splitFunction:Function, p_parameters:Array){
super();
splitValues = p_splitFunction;
parameters = p_parameters;
}
public function toString():String{
var value:String = "";
value = (value + "[SpecialPropertySplitter ");
value = (value + ("splitValues:" + String(splitValues)));
value = (value + ", ");
value = (value + ("parameters:" + String(parameters)));
value = (value + "]");
return (value);
}
}
}//package caurina.transitions
Section 16
//Tweener (caurina.transitions.Tweener)
package caurina.transitions {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class Tweener {
private static var _timeScale:Number = 1;
private static var _currentTimeFrame:Number;
private static var _specialPropertySplitterList:Object;
private static var _engineExists:Boolean = false;
private static var _specialPropertyModifierList:Object;
private static var _currentTime:Number;
private static var _tweenList:Array;
private static var _specialPropertyList:Object;
private static var _transitionList:Object;
private static var _inited:Boolean = false;
private static var __tweener_controller__:MovieClip;
public function Tweener(){
super();
trace("Tweener is a static class and should not be instantiated.");
}
public static function registerSpecialPropertyModifier(p_name:String, p_modifyFunction:Function, p_getFunction:Function):void{
if (!_inited){
init();
};
var spm:SpecialPropertyModifier = new SpecialPropertyModifier(p_modifyFunction, p_getFunction);
_specialPropertyModifierList[p_name] = spm;
}
public static function registerSpecialProperty(p_name:String, p_getFunction:Function, p_setFunction:Function, p_parameters:Array=null, p_preProcessFunction:Function=null):void{
if (!_inited){
init();
};
var sp:SpecialProperty = new SpecialProperty(p_getFunction, p_setFunction, p_parameters, p_preProcessFunction);
_specialPropertyList[p_name] = sp;
}
public static function init(... _args):void{
_inited = true;
_transitionList = new Object();
Equations.init();
_specialPropertyList = new Object();
_specialPropertyModifierList = new Object();
_specialPropertySplitterList = new Object();
}
private static function updateTweens():Boolean{
var i:int;
if (_tweenList.length == 0){
return (false);
};
i = 0;
while (i < _tweenList.length) {
if ((((_tweenList[i] == undefined)) || (!(_tweenList[i].isPaused)))){
if (!updateTweenByIndex(i)){
removeTweenByIndex(i);
};
if (_tweenList[i] == null){
removeTweenByIndex(i, true);
i--;
};
};
i++;
};
return (true);
}
public static function addCaller(p_scopes:Object=null, p_parameters:Object=null):Boolean{
var i:Number;
var rScopes:Array;
var rTransition:Function;
var nTween:TweenListObj;
var myT:Number;
var trans:String;
if (!Boolean(p_scopes)){
return (false);
};
if ((p_scopes is Array)){
rScopes = p_scopes.concat();
} else {
rScopes = [p_scopes];
};
var p_obj:Object = p_parameters;
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
var rTime:Number = (isNaN(p_obj.time)) ? 0 : p_obj.time;
var rDelay:Number = (isNaN(p_obj.delay)) ? 0 : p_obj.delay;
if (typeof(p_obj.transition) == "string"){
trans = p_obj.transition.toLowerCase();
rTransition = _transitionList[trans];
} else {
rTransition = p_obj.transition;
};
if (!Boolean(rTransition)){
rTransition = _transitionList["easeoutexpo"];
};
i = 0;
while (i < rScopes.length) {
if (p_obj.useFrames == true){
nTween = new TweenListObj(rScopes[i], (_currentTimeFrame + (rDelay / _timeScale)), (_currentTimeFrame + ((rDelay + rTime) / _timeScale)), true, rTransition, p_obj.transitionParams);
} else {
nTween = new TweenListObj(rScopes[i], (_currentTime + ((rDelay * 1000) / _timeScale)), (_currentTime + (((rDelay * 1000) + (rTime * 1000)) / _timeScale)), false, rTransition, p_obj.transitionParams);
};
nTween.properties = null;
nTween.onStart = p_obj.onStart;
nTween.onUpdate = p_obj.onUpdate;
nTween.onComplete = p_obj.onComplete;
nTween.onOverwrite = p_obj.onOverwrite;
nTween.onStartParams = p_obj.onStartParams;
nTween.onUpdateParams = p_obj.onUpdateParams;
nTween.onCompleteParams = p_obj.onCompleteParams;
nTween.onOverwriteParams = p_obj.onOverwriteParams;
nTween.onStartScope = p_obj.onStartScope;
nTween.onUpdateScope = p_obj.onUpdateScope;
nTween.onCompleteScope = p_obj.onCompleteScope;
nTween.onOverwriteScope = p_obj.onOverwriteScope;
nTween.onErrorScope = p_obj.onErrorScope;
nTween.isCaller = true;
nTween.count = p_obj.count;
nTween.waitFrames = p_obj.waitFrames;
_tweenList.push(nTween);
if ((((rTime == 0)) && ((rDelay == 0)))){
myT = (_tweenList.length - 1);
updateTweenByIndex(myT);
removeTweenByIndex(myT);
};
i++;
};
return (true);
}
public static function pauseAllTweens():Boolean{
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
var paused:Boolean;
i = 0;
while (i < _tweenList.length) {
pauseTweenByIndex(i);
paused = true;
i++;
};
return (paused);
}
public static function removeTweens(p_scope:Object, ... _args):Boolean{
var i:uint;
var sps:SpecialPropertySplitter;
var specialProps:Array;
var j:uint;
var properties:Array = new Array();
i = 0;
while (i < _args.length) {
if ((((typeof(_args[i]) == "string")) && ((properties.indexOf(_args[i]) == -1)))){
if (_specialPropertySplitterList[_args[i]]){
sps = _specialPropertySplitterList[_args[i]];
specialProps = sps.splitValues(p_scope, null);
j = 0;
while (j < specialProps.length) {
properties.push(specialProps[j].name);
j++;
};
} else {
properties.push(_args[i]);
};
};
i++;
};
return (affectTweens(removeTweenByIndex, p_scope, properties));
}
public static function splitTweens(p_tween:Number, p_properties:Array):uint{
var i:uint;
var pName:String;
var found:Boolean;
var originalTween:TweenListObj = _tweenList[p_tween];
var newTween:TweenListObj = originalTween.clone(false);
i = 0;
while (i < p_properties.length) {
pName = p_properties[i];
if (Boolean(originalTween.properties[pName])){
originalTween.properties[pName] = undefined;
delete originalTween.properties[pName];
};
i++;
};
for (pName in newTween.properties) {
found = false;
i = 0;
while (i < p_properties.length) {
if (p_properties[i] == pName){
found = true;
break;
};
i++;
};
if (!found){
newTween.properties[pName] = undefined;
delete newTween.properties[pName];
};
};
_tweenList.push(newTween);
return ((_tweenList.length - 1));
}
public static function updateFrame():void{
_currentTimeFrame++;
}
public static function resumeTweenByIndex(p_tween:Number):Boolean{
var tTweening:TweenListObj = _tweenList[p_tween];
if ((((tTweening == null)) || (!(tTweening.isPaused)))){
return (false);
};
var cTime:Number = getCurrentTweeningTime(tTweening);
tTweening.timeStart = (tTweening.timeStart + (cTime - tTweening.timePaused));
tTweening.timeComplete = (tTweening.timeComplete + (cTime - tTweening.timePaused));
tTweening.timePaused = undefined;
tTweening.isPaused = false;
return (true);
}
public static function getVersion():String{
return ("AS3 1.31.74");
}
public static function onEnterFrame(e:Event):void{
updateTime();
updateFrame();
var hasUpdated:Boolean;
hasUpdated = updateTweens();
if (!hasUpdated){
stopEngine();
};
}
public static function updateTime():void{
_currentTime = getTimer();
}
private static function updateTweenByIndex(i:Number):Boolean{
var tTweening:TweenListObj;
var mustUpdate:Boolean;
var nv:Number;
var t:Number;
var b:Number;
var c:Number;
var d:Number;
var pName:String;
var eventScope:Object;
var tScope:Object;
var tProperty:Object;
var pv:Number;
var i = i;
tTweening = _tweenList[i];
if ((((tTweening == null)) || (!(Boolean(tTweening.scope))))){
return (false);
};
var isOver:Boolean;
var cTime:Number = getCurrentTweeningTime(tTweening);
if (cTime >= tTweening.timeStart){
tScope = tTweening.scope;
if (tTweening.isCaller){
do {
t = (((tTweening.timeComplete - tTweening.timeStart) / tTweening.count) * (tTweening.timesCalled + 1));
b = tTweening.timeStart;
c = (tTweening.timeComplete - tTweening.timeStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, b, c, d);
//unresolved if
if (Boolean(tTweening.onUpdate)){
eventScope = (Boolean(tTweening.onUpdateScope)) ? tTweening.onUpdateScope : tScope;
tTweening.onUpdate.apply(eventScope, tTweening.onUpdateParams);
continue;
var _slot1 = e1;
handleError(tTweening, _slot1, "onUpdate");
};
} while (tTweening.timesCalled++, !(tTweening.timesCalled >= tTweening.count));
} else {
mustUpdate = (((((tTweening.skipUpdates < 1)) || (!(tTweening.skipUpdates)))) || ((tTweening.updatesSkipped >= tTweening.skipUpdates)));
if (cTime >= tTweening.timeComplete){
isOver = true;
mustUpdate = true;
};
if (!tTweening.hasStarted){
if (Boolean(tTweening.onStart)){
eventScope = (Boolean(tTweening.onStartScope)) ? tTweening.onStartScope : tScope;
tTweening.onStart.apply(eventScope, tTweening.onStartParams);
//unresolved jump
var _slot1 = e2;
handleError(tTweening, _slot1, "onStart");
};
for (pName in tTweening.properties) {
if (tTweening.properties[pName].isSpecialProperty){
if (Boolean(_specialPropertyList[pName].preProcess)){
tTweening.properties[pName].valueComplete = _specialPropertyList[pName].preProcess(tScope, _specialPropertyList[pName].parameters, tTweening.properties[pName].originalValueComplete, tTweening.properties[pName].extra);
};
pv = _specialPropertyList[pName].getValue(tScope, _specialPropertyList[pName].parameters, tTweening.properties[pName].extra);
} else {
pv = tScope[pName];
};
tTweening.properties[pName].valueStart = (isNaN(pv)) ? tTweening.properties[pName].valueComplete : pv;
};
mustUpdate = true;
tTweening.hasStarted = true;
};
if (mustUpdate){
for (pName in tTweening.properties) {
tProperty = tTweening.properties[pName];
if (isOver){
nv = tProperty.valueComplete;
} else {
if (tProperty.hasModifier){
t = (cTime - tTweening.timeStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, 0, 1, d, tTweening.transitionParams);
nv = tProperty.modifierFunction(tProperty.valueStart, tProperty.valueComplete, nv, tProperty.modifierParameters);
} else {
t = (cTime - tTweening.timeStart);
b = tProperty.valueStart;
c = (tProperty.valueComplete - tProperty.valueStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, b, c, d, tTweening.transitionParams);
};
};
if (tTweening.rounded){
nv = Math.round(nv);
};
if (tProperty.isSpecialProperty){
_specialPropertyList[pName].setValue(tScope, nv, _specialPropertyList[pName].parameters, tTweening.properties[pName].extra);
} else {
tScope[pName] = nv;
};
};
tTweening.updatesSkipped = 0;
if (Boolean(tTweening.onUpdate)){
eventScope = (Boolean(tTweening.onUpdateScope)) ? tTweening.onUpdateScope : tScope;
tTweening.onUpdate.apply(eventScope, tTweening.onUpdateParams);
//unresolved jump
var _slot1 = e3;
handleError(tTweening, _slot1, "onUpdate");
};
} else {
tTweening.updatesSkipped++;
};
};
if (((isOver) && (Boolean(tTweening.onComplete)))){
eventScope = (Boolean(tTweening.onCompleteScope)) ? tTweening.onCompleteScope : tScope;
tTweening.onComplete.apply(eventScope, tTweening.onCompleteParams);
//unresolved jump
var _slot1 = e4;
handleError(tTweening, _slot1, "onComplete");
};
return (!(isOver));
};
return (true);
}
public static function setTimeScale(p_time:Number):void{
var i:Number;
var cTime:Number;
if (isNaN(p_time)){
p_time = 1;
};
if (p_time < 1E-5){
p_time = 1E-5;
};
if (p_time != _timeScale){
if (_tweenList != null){
i = 0;
while (i < _tweenList.length) {
cTime = getCurrentTweeningTime(_tweenList[i]);
_tweenList[i].timeStart = (cTime - (((cTime - _tweenList[i].timeStart) * _timeScale) / p_time));
_tweenList[i].timeComplete = (cTime - (((cTime - _tweenList[i].timeComplete) * _timeScale) / p_time));
if (_tweenList[i].timePaused != undefined){
_tweenList[i].timePaused = (cTime - (((cTime - _tweenList[i].timePaused) * _timeScale) / p_time));
};
i++;
};
};
_timeScale = p_time;
};
}
public static function resumeAllTweens():Boolean{
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
var resumed:Boolean;
i = 0;
while (i < _tweenList.length) {
resumeTweenByIndex(i);
resumed = true;
i++;
};
return (resumed);
}
private static function handleError(pTweening:TweenListObj, pError:Error, pCallBackName:String):void{
var eventScope:Object;
var pTweening = pTweening;
var pError = pError;
var pCallBackName = pCallBackName;
if (((Boolean(pTweening.onError)) && ((pTweening.onError is Function)))){
eventScope = (Boolean(pTweening.onErrorScope)) ? pTweening.onErrorScope : pTweening.scope;
pTweening.onError.apply(eventScope, [pTweening.scope, pError]);
//unresolved jump
var _slot1 = metaError;
printError(((((String(pTweening.scope) + " raised an error while executing the 'onError' handler. Original error:\n ") + pError.getStackTrace()) + "\nonError error: ") + _slot1.getStackTrace()));
} else {
if (!Boolean(pTweening.onError)){
printError(((((String(pTweening.scope) + " raised an error while executing the '") + pCallBackName) + "'handler. \n") + pError.getStackTrace()));
};
};
}
private static function startEngine():void{
_engineExists = true;
_tweenList = new Array();
__tweener_controller__ = new MovieClip();
__tweener_controller__.addEventListener(Event.ENTER_FRAME, Tweener.onEnterFrame);
_currentTimeFrame = 0;
updateTime();
}
public static function removeAllTweens():Boolean{
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
var removed:Boolean;
i = 0;
while (i < _tweenList.length) {
removeTweenByIndex(i);
removed = true;
i++;
};
return (removed);
}
public static function addTween(p_scopes:Object=null, p_parameters:Object=null):Boolean{
var i:Number;
var j:Number;
var istr:String;
var rScopes:Array;
var rTransition:Function;
var nProperties:Object;
var nTween:TweenListObj;
var myT:Number;
var splitProperties:Array;
var splitProperties2:Array;
var tempModifiedProperties:Array;
var trans:String;
if (!Boolean(p_scopes)){
return (false);
};
if ((p_scopes is Array)){
rScopes = p_scopes.concat();
} else {
rScopes = [p_scopes];
};
var p_obj:Object = TweenListObj.makePropertiesChain(p_parameters);
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
var rTime:Number = (isNaN(p_obj.time)) ? 0 : p_obj.time;
var rDelay:Number = (isNaN(p_obj.delay)) ? 0 : p_obj.delay;
var rProperties:Array = new Array();
var restrictedWords:Object = {time:true, delay:true, useFrames:true, skipUpdates:true, transition:true, transitionParams:true, onStart:true, onUpdate:true, onComplete:true, onOverwrite:true, onError:true, rounded:true, onStartParams:true, onUpdateParams:true, onCompleteParams:true, onOverwriteParams:true, onStartScope:true, onUpdateScope:true, onCompleteScope:true, onOverwriteScope:true, onErrorScope:true};
var modifiedProperties:Object = new Object();
for (istr in p_obj) {
if (!restrictedWords[istr]){
if (_specialPropertySplitterList[istr]){
splitProperties = _specialPropertySplitterList[istr].splitValues(p_obj[istr], _specialPropertySplitterList[istr].parameters);
i = 0;
while (i < splitProperties.length) {
if (_specialPropertySplitterList[splitProperties[i].name]){
splitProperties2 = _specialPropertySplitterList[splitProperties[i].name].splitValues(splitProperties[i].value, _specialPropertySplitterList[splitProperties[i].name].parameters);
j = 0;
while (j < splitProperties2.length) {
rProperties[splitProperties2[j].name] = {valueStart:undefined, valueComplete:splitProperties2[j].value, arrayIndex:splitProperties2[j].arrayIndex, isSpecialProperty:false};
j++;
};
} else {
rProperties[splitProperties[i].name] = {valueStart:undefined, valueComplete:splitProperties[i].value, arrayIndex:splitProperties[i].arrayIndex, isSpecialProperty:false};
};
i++;
};
} else {
if (_specialPropertyModifierList[istr] != undefined){
tempModifiedProperties = _specialPropertyModifierList[istr].modifyValues(p_obj[istr]);
i = 0;
while (i < tempModifiedProperties.length) {
modifiedProperties[tempModifiedProperties[i].name] = {modifierParameters:tempModifiedProperties[i].parameters, modifierFunction:_specialPropertyModifierList[istr].getValue};
i++;
};
} else {
rProperties[istr] = {valueStart:undefined, valueComplete:p_obj[istr]};
};
};
};
};
for (istr in rProperties) {
if (_specialPropertyList[istr] != undefined){
rProperties[istr].isSpecialProperty = true;
} else {
if (rScopes[0][istr] == undefined){
printError((((("The property '" + istr) + "' doesn't seem to be a normal object property of ") + String(rScopes[0])) + " or a registered special property."));
};
};
};
for (istr in modifiedProperties) {
if (rProperties[istr] != undefined){
rProperties[istr].modifierParameters = modifiedProperties[istr].modifierParameters;
rProperties[istr].modifierFunction = modifiedProperties[istr].modifierFunction;
};
};
if (typeof(p_obj.transition) == "string"){
trans = p_obj.transition.toLowerCase();
rTransition = _transitionList[trans];
} else {
rTransition = p_obj.transition;
};
if (!Boolean(rTransition)){
rTransition = _transitionList["easeoutexpo"];
};
i = 0;
while (i < rScopes.length) {
nProperties = new Object();
for (istr in rProperties) {
nProperties[istr] = new PropertyInfoObj(rProperties[istr].valueStart, rProperties[istr].valueComplete, rProperties[istr].valueComplete, rProperties[istr].arrayIndex, {}, rProperties[istr].isSpecialProperty, rProperties[istr].modifierFunction, rProperties[istr].modifierParameters);
};
if (p_obj.useFrames == true){
nTween = new TweenListObj(rScopes[i], (_currentTimeFrame + (rDelay / _timeScale)), (_currentTimeFrame + ((rDelay + rTime) / _timeScale)), true, rTransition, p_obj.transitionParams);
} else {
nTween = new TweenListObj(rScopes[i], (_currentTime + ((rDelay * 1000) / _timeScale)), (_currentTime + (((rDelay * 1000) + (rTime * 1000)) / _timeScale)), false, rTransition, p_obj.transitionParams);
};
nTween.properties = nProperties;
nTween.onStart = p_obj.onStart;
nTween.onUpdate = p_obj.onUpdate;
nTween.onComplete = p_obj.onComplete;
nTween.onOverwrite = p_obj.onOverwrite;
nTween.onError = p_obj.onError;
nTween.onStartParams = p_obj.onStartParams;
nTween.onUpdateParams = p_obj.onUpdateParams;
nTween.onCompleteParams = p_obj.onCompleteParams;
nTween.onOverwriteParams = p_obj.onOverwriteParams;
nTween.onStartScope = p_obj.onStartScope;
nTween.onUpdateScope = p_obj.onUpdateScope;
nTween.onCompleteScope = p_obj.onCompleteScope;
nTween.onOverwriteScope = p_obj.onOverwriteScope;
nTween.onErrorScope = p_obj.onErrorScope;
nTween.rounded = p_obj.rounded;
nTween.skipUpdates = p_obj.skipUpdates;
removeTweensByTime(nTween.scope, nTween.properties, nTween.timeStart, nTween.timeComplete);
_tweenList.push(nTween);
if ((((rTime == 0)) && ((rDelay == 0)))){
myT = (_tweenList.length - 1);
updateTweenByIndex(myT);
removeTweenByIndex(myT);
};
i++;
};
return (true);
}
public static function registerTransition(p_name:String, p_function:Function):void{
if (!_inited){
init();
};
_transitionList[p_name] = p_function;
}
public static function printError(p_message:String):void{
trace(("## [Tweener] Error: " + p_message));
}
private static function affectTweens(p_affectFunction:Function, p_scope:Object, p_properties:Array):Boolean{
var i:uint;
var affectedProperties:Array;
var j:uint;
var objectProperties:uint;
var slicedTweenIndex:uint;
var affected:Boolean;
if (!Boolean(_tweenList)){
return (false);
};
i = 0;
while (i < _tweenList.length) {
if (((_tweenList[i]) && ((_tweenList[i].scope == p_scope)))){
if (p_properties.length == 0){
p_affectFunction(i);
affected = true;
} else {
affectedProperties = new Array();
j = 0;
while (j < p_properties.length) {
if (Boolean(_tweenList[i].properties[p_properties[j]])){
affectedProperties.push(p_properties[j]);
};
j++;
};
if (affectedProperties.length > 0){
objectProperties = AuxFunctions.getObjectLength(_tweenList[i].properties);
if (objectProperties == affectedProperties.length){
p_affectFunction(i);
affected = true;
} else {
slicedTweenIndex = splitTweens(i, affectedProperties);
p_affectFunction(slicedTweenIndex);
affected = true;
};
};
};
};
i++;
};
return (affected);
}
public static function getTweens(p_scope:Object):Array{
var i:uint;
var pName:String;
if (!Boolean(_tweenList)){
return ([]);
};
var tList:Array = new Array();
i = 0;
while (i < _tweenList.length) {
if (((Boolean(_tweenList[i])) && ((_tweenList[i].scope == p_scope)))){
for (pName in _tweenList[i].properties) {
tList.push(pName);
};
};
i++;
};
return (tList);
}
public static function isTweening(p_scope:Object):Boolean{
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
i = 0;
while (i < _tweenList.length) {
if (((Boolean(_tweenList[i])) && ((_tweenList[i].scope == p_scope)))){
return (true);
};
i++;
};
return (false);
}
public static function pauseTweenByIndex(p_tween:Number):Boolean{
var tTweening:TweenListObj = _tweenList[p_tween];
if ((((tTweening == null)) || (tTweening.isPaused))){
return (false);
};
tTweening.timePaused = getCurrentTweeningTime(tTweening);
tTweening.isPaused = true;
return (true);
}
public static function getCurrentTweeningTime(p_tweening:Object):Number{
return ((p_tweening.useFrames) ? _currentTimeFrame : _currentTime);
}
public static function getTweenCount(p_scope:Object):Number{
var i:uint;
if (!Boolean(_tweenList)){
return (0);
};
var c:Number = 0;
i = 0;
while (i < _tweenList.length) {
if (((Boolean(_tweenList[i])) && ((_tweenList[i].scope == p_scope)))){
c = (c + AuxFunctions.getObjectLength(_tweenList[i].properties));
};
i++;
};
return (c);
}
private static function stopEngine():void{
_engineExists = false;
_tweenList = null;
_currentTime = 0;
_currentTimeFrame = 0;
__tweener_controller__.removeEventListener(Event.ENTER_FRAME, Tweener.onEnterFrame);
__tweener_controller__ = null;
}
public static function removeTweensByTime(p_scope:Object, p_properties:Object, p_timeStart:Number, p_timeComplete:Number):Boolean{
var removedLocally:Boolean;
var i:uint;
var pName:String;
var eventScope:Object;
var p_scope = p_scope;
var p_properties = p_properties;
var p_timeStart = p_timeStart;
var p_timeComplete = p_timeComplete;
var removed:Boolean;
var tl:uint = _tweenList.length;
i = 0;
while (i < tl) {
if (((Boolean(_tweenList[i])) && ((p_scope == _tweenList[i].scope)))){
if ((((p_timeComplete > _tweenList[i].timeStart)) && ((p_timeStart < _tweenList[i].timeComplete)))){
removedLocally = false;
for (pName in _tweenList[i].properties) {
if (Boolean(p_properties[pName])){
if (Boolean(_tweenList[i].onOverwrite)){
eventScope = (Boolean(_tweenList[i].onOverwriteScope)) ? _tweenList[i].onOverwriteScope : _tweenList[i].scope;
_tweenList[i].onOverwrite.apply(eventScope, _tweenList[i].onOverwriteParams);
//unresolved jump
var _slot1 = e;
handleError(_tweenList[i], _slot1, "onOverwrite");
};
_tweenList[i].properties[pName] = undefined;
delete _tweenList[i].properties[pName];
removedLocally = true;
removed = true;
};
};
if (removedLocally){
if (AuxFunctions.getObjectLength(_tweenList[i].properties) == 0){
removeTweenByIndex(i);
};
};
};
};
i = (i + 1);
};
return (removed);
}
public static function registerSpecialPropertySplitter(p_name:String, p_splitFunction:Function, p_parameters:Array=null):void{
if (!_inited){
init();
};
var sps:SpecialPropertySplitter = new SpecialPropertySplitter(p_splitFunction, p_parameters);
_specialPropertySplitterList[p_name] = sps;
}
public static function removeTweenByIndex(i:Number, p_finalRemoval:Boolean=false):Boolean{
_tweenList[i] = null;
if (p_finalRemoval){
_tweenList.splice(i, 1);
};
return (true);
}
public static function resumeTweens(p_scope:Object, ... _args):Boolean{
var i:uint;
var properties:Array = new Array();
i = 0;
while (i < _args.length) {
if ((((typeof(_args[i]) == "string")) && ((properties.indexOf(_args[i]) == -1)))){
properties.push(_args[i]);
};
i++;
};
return (affectTweens(resumeTweenByIndex, p_scope, properties));
}
public static function pauseTweens(p_scope:Object, ... _args):Boolean{
var i:uint;
var properties:Array = new Array();
i = 0;
while (i < _args.length) {
if ((((typeof(_args[i]) == "string")) && ((properties.indexOf(_args[i]) == -1)))){
properties.push(_args[i]);
};
i++;
};
return (affectTweens(pauseTweenByIndex, p_scope, properties));
}
}
}//package caurina.transitions
Section 17
//TweenListObj (caurina.transitions.TweenListObj)
package caurina.transitions {
public class TweenListObj {
public var hasStarted:Boolean;
public var onUpdate:Function;
public var useFrames:Boolean;
public var count:Number;
public var onOverwriteParams:Array;
public var timeStart:Number;
public var timeComplete:Number;
public var onStartParams:Array;
public var onUpdateScope:Object;
public var rounded:Boolean;
public var onUpdateParams:Array;
public var properties:Object;
public var onComplete:Function;
public var transitionParams:Object;
public var updatesSkipped:Number;
public var onStart:Function;
public var onOverwriteScope:Object;
public var skipUpdates:Number;
public var onStartScope:Object;
public var scope:Object;
public var isCaller:Boolean;
public var timePaused:Number;
public var transition:Function;
public var onCompleteParams:Array;
public var onError:Function;
public var timesCalled:Number;
public var onErrorScope:Object;
public var onOverwrite:Function;
public var isPaused:Boolean;
public var waitFrames:Boolean;
public var onCompleteScope:Object;
public function TweenListObj(p_scope:Object, p_timeStart:Number, p_timeComplete:Number, p_useFrames:Boolean, p_transition:Function, p_transitionParams:Object){
super();
scope = p_scope;
timeStart = p_timeStart;
timeComplete = p_timeComplete;
useFrames = p_useFrames;
transition = p_transition;
transitionParams = p_transitionParams;
properties = new Object();
isPaused = false;
timePaused = undefined;
isCaller = false;
updatesSkipped = 0;
timesCalled = 0;
skipUpdates = 0;
hasStarted = false;
}
public function clone(omitEvents:Boolean):TweenListObj{
var pName:String;
var nTween:TweenListObj = new TweenListObj(scope, timeStart, timeComplete, useFrames, transition, transitionParams);
nTween.properties = new Array();
for (pName in properties) {
nTween.properties[pName] = properties[pName].clone();
};
nTween.skipUpdates = skipUpdates;
nTween.updatesSkipped = updatesSkipped;
if (!omitEvents){
nTween.onStart = onStart;
nTween.onUpdate = onUpdate;
nTween.onComplete = onComplete;
nTween.onOverwrite = onOverwrite;
nTween.onError = onError;
nTween.onStartParams = onStartParams;
nTween.onUpdateParams = onUpdateParams;
nTween.onCompleteParams = onCompleteParams;
nTween.onOverwriteParams = onOverwriteParams;
nTween.onStartScope = onStartScope;
nTween.onUpdateScope = onUpdateScope;
nTween.onCompleteScope = onCompleteScope;
nTween.onOverwriteScope = onOverwriteScope;
nTween.onErrorScope = onErrorScope;
};
nTween.rounded = rounded;
nTween.isPaused = isPaused;
nTween.timePaused = timePaused;
nTween.isCaller = isCaller;
nTween.count = count;
nTween.timesCalled = timesCalled;
nTween.waitFrames = waitFrames;
nTween.hasStarted = hasStarted;
return (nTween);
}
public function toString():String{
var i:String;
var returnStr:String = "\n[TweenListObj ";
returnStr = (returnStr + ("scope:" + String(scope)));
returnStr = (returnStr + ", properties:");
var isFirst:Boolean;
for (i in properties) {
if (!isFirst){
returnStr = (returnStr + ",");
};
returnStr = (returnStr + ("[name:" + properties[i].name));
returnStr = (returnStr + (",valueStart:" + properties[i].valueStart));
returnStr = (returnStr + (",valueComplete:" + properties[i].valueComplete));
returnStr = (returnStr + "]");
isFirst = false;
};
returnStr = (returnStr + (", timeStart:" + String(timeStart)));
returnStr = (returnStr + (", timeComplete:" + String(timeComplete)));
returnStr = (returnStr + (", useFrames:" + String(useFrames)));
returnStr = (returnStr + (", transition:" + String(transition)));
returnStr = (returnStr + (", transitionParams:" + String(transitionParams)));
if (skipUpdates){
returnStr = (returnStr + (", skipUpdates:" + String(skipUpdates)));
};
if (updatesSkipped){
returnStr = (returnStr + (", updatesSkipped:" + String(updatesSkipped)));
};
if (Boolean(onStart)){
returnStr = (returnStr + (", onStart:" + String(onStart)));
};
if (Boolean(onUpdate)){
returnStr = (returnStr + (", onUpdate:" + String(onUpdate)));
};
if (Boolean(onComplete)){
returnStr = (returnStr + (", onComplete:" + String(onComplete)));
};
if (Boolean(onOverwrite)){
returnStr = (returnStr + (", onOverwrite:" + String(onOverwrite)));
};
if (Boolean(onError)){
returnStr = (returnStr + (", onError:" + String(onError)));
};
if (onStartParams){
returnStr = (returnStr + (", onStartParams:" + String(onStartParams)));
};
if (onUpdateParams){
returnStr = (returnStr + (", onUpdateParams:" + String(onUpdateParams)));
};
if (onCompleteParams){
returnStr = (returnStr + (", onCompleteParams:" + String(onCompleteParams)));
};
if (onOverwriteParams){
returnStr = (returnStr + (", onOverwriteParams:" + String(onOverwriteParams)));
};
if (onStartScope){
returnStr = (returnStr + (", onStartScope:" + String(onStartScope)));
};
if (onUpdateScope){
returnStr = (returnStr + (", onUpdateScope:" + String(onUpdateScope)));
};
if (onCompleteScope){
returnStr = (returnStr + (", onCompleteScope:" + String(onCompleteScope)));
};
if (onOverwriteScope){
returnStr = (returnStr + (", onOverwriteScope:" + String(onOverwriteScope)));
};
if (onErrorScope){
returnStr = (returnStr + (", onErrorScope:" + String(onErrorScope)));
};
if (rounded){
returnStr = (returnStr + (", rounded:" + String(rounded)));
};
if (isPaused){
returnStr = (returnStr + (", isPaused:" + String(isPaused)));
};
if (timePaused){
returnStr = (returnStr + (", timePaused:" + String(timePaused)));
};
if (isCaller){
returnStr = (returnStr + (", isCaller:" + String(isCaller)));
};
if (count){
returnStr = (returnStr + (", count:" + String(count)));
};
if (timesCalled){
returnStr = (returnStr + (", timesCalled:" + String(timesCalled)));
};
if (waitFrames){
returnStr = (returnStr + (", waitFrames:" + String(waitFrames)));
};
if (hasStarted){
returnStr = (returnStr + (", hasStarted:" + String(hasStarted)));
};
returnStr = (returnStr + "]\n");
return (returnStr);
}
public static function makePropertiesChain(p_obj:Object):Object{
var chainedObject:Object;
var chain:Object;
var currChainObj:Object;
var len:Number;
var i:Number;
var k:Number;
var baseObject:Object = p_obj.base;
if (baseObject){
chainedObject = {};
if ((baseObject is Array)){
chain = [];
k = 0;
while (k < baseObject.length) {
chain.push(baseObject[k]);
k++;
};
} else {
chain = [baseObject];
};
chain.push(p_obj);
len = chain.length;
i = 0;
while (i < len) {
if (chain[i]["base"]){
currChainObj = AuxFunctions.concatObjects(makePropertiesChain(chain[i]["base"]), chain[i]);
} else {
currChainObj = chain[i];
};
chainedObject = AuxFunctions.concatObjects(chainedObject, currChainObj);
i++;
};
if (chainedObject["base"]){
delete chainedObject["base"];
};
return (chainedObject);
//unresolved jump
};
return (p_obj);
}
}
}//package caurina.transitions
Section 18
//chickenBody_2 (chicken_fla.chickenBody_2)
package chicken_fla {
import flash.display.*;
public dynamic class chickenBody_2 extends MovieClip {
public function chickenBody_2(){
addFrameScript(15, frame16, 49, frame50, 66, frame67, 82, frame83, 98, frame99, 114, frame115, 130, frame131);
}
function frame16(){
gotoAndPlay("down");
}
function frame83(){
gotoAndPlay("left_down");
}
function frame115(){
gotoAndPlay("up");
}
function frame99(){
gotoAndPlay("left_up");
}
function frame131(){
stop();
}
function frame50(){
gotoAndPlay("eat");
}
function frame67(){
gotoAndPlay("left");
}
}
}//package chicken_fla
Section 19
//hungryProgress_3 (chicken_fla.hungryProgress_3)
package chicken_fla {
import flash.display.*;
public dynamic class hungryProgress_3 extends MovieClip {
public var _mask:MovieClip;
}
}//package chicken_fla
Section 20
//MathUtils (com.cheezeworld.math.MathUtils)
package com.cheezeworld.math {
public class MathUtils {
public static const DEG_TO_RAD:Number = (Math.PI / 180);
public static const RAD_TO_DEG:Number = (180 / Math.PI);
public function MathUtils(){
super();
}
public static function simplifyRadian(radian:Number):Number{
var newRadian:Number;
if ((((radian > Math.PI)) || ((radian < -(Math.PI))))){
newRadian = (radian - (int((radian / (Math.PI * 2))) * (Math.PI * 2)));
if (radian > 0){
if (newRadian < Math.PI){
return (newRadian);
};
newRadian = -(((Math.PI * 2) - newRadian));
return (newRadian);
} else {
if (newRadian > -(Math.PI)){
return (newRadian);
};
newRadian = ((Math.PI * 2) + newRadian);
return (newRadian);
};
};
return (radian);
}
public static function getSmallestRotationDirection(objectRotationRadians:Number, radianBetween:Number, errorRadians:Number=0):int{
objectRotationRadians = simplifyRadian(objectRotationRadians);
radianBetween = simplifyRadian(radianBetween);
radianBetween = (radianBetween + -(objectRotationRadians));
radianBetween = simplifyRadian(radianBetween);
objectRotationRadians = 0;
if (radianBetween < -(errorRadians)){
return (-1);
};
if (radianBetween > errorRadians){
return (1);
};
return (0);
}
public static function rand(min:int, max:int):int{
return ((min + Math.floor((Math.random() * ((max - min) + 1)))));
}
public static function calcAngle(p1:Vector2D, p2:Vector2D):Number{
var angle:Number = (Math.atan(((p2.y - p1.y) / (p2.x - p1.x))) * RAD_TO_DEG);
if ((((p2.y < p1.y)) && ((p2.x > p1.x)))){
return (angle);
};
if ((((((p2.y < p1.y)) && ((p2.x < p1.x)))) || ((((p2.y > p1.y)) && ((p2.x < p1.x)))))){
return ((angle + 180));
};
return ((angle + 360));
}
}
}//package com.cheezeworld.math
Section 21
//Vector2D (com.cheezeworld.math.Vector2D)
package com.cheezeworld.math {
import flash.geom.*;
public class Vector2D {
private var v2:Vector2D;
private var _length:Number;
private var _oldX:Number;
private var v1:Vector2D;
private var _oldY:Number;
public var x:Number;
public var y:Number;
private static const DEG_TO_RAD:Number = (Math.PI / 180);
private static const RAD_TO_DEG:Number = (180 / Math.PI);
public function Vector2D(X:Number=0, Y:Number=0){
super();
x = X;
y = Y;
_length = 0;
}
public function divide(scalar:Number):void{
if (scalar == 0){
trace("Vector::dividedBy() - Illegal Divide by Zero!");
} else {
x = (x / scalar);
y = (y / scalar);
};
}
public function isZero():Boolean{
return ((((x == 0)) || ((y == 0))));
}
public function Set(x:Number, y:Number):void{
this.x = x;
this.y = y;
}
public function sign(vector:Vector2D):int{
if ((y * vector.x) > (x * vector.y)){
return (-1);
};
return (1);
}
public function dotOf(vector:Vector2D):Number{
return (((x * vector.x) + (y * vector.y)));
}
public function dividedBy(scalar:Number):Vector2D{
if (scalar == 0){
trace("Vector::dividedBy() - Illegal Divide by Zero!");
return (new Vector2D());
};
return (new Vector2D((x / scalar), (y / scalar)));
}
public function normalize():void{
if (length != 0){
x = (x / _length);
y = (y / _length);
};
}
public function isParallelTo(vector:Vector2D):Boolean{
v1 = copy();
v1.normalize();
v2 = vector.copy();
v2.normalize();
return ((((((v1.x == v2.x)) && ((v1.y == v2.y)))) || ((((v1.x == -(v2.x))) && ((v1.y == -(v2.y)))))));
}
public function distanceTo(vector:Vector2D):Number{
var xSep:Number = (vector.x - x);
var ySep:Number = (vector.y - y);
return (Math.sqrt(((ySep * ySep) + (xSep * xSep))));
}
public function subtract(vector:Vector2D):void{
x = (x - vector.x);
y = (y - vector.y);
}
public function toPoint():Point{
return (new Point(x, y));
}
public function toRotation():Number{
var ang:Number = (Math.atan((y / x)) * RAD_TO_DEG);
if ((((y < 0)) && ((x > 0)))){
return (ang);
};
if ((((((y < 0)) && ((x < 0)))) || ((((y > 0)) && ((x < 0)))))){
return ((ang + 180));
};
return ((ang + 360));
}
public function isInsideRegion(topLeft:Vector2D, botRight:Vector2D):Boolean{
return (!((((((((x < topLeft.x)) || ((x > (topLeft.x + botRight.x))))) || ((y < topLeft.y)))) || ((y > (topLeft.y + botRight.y))))));
}
public function addedTo(vector:Vector2D):Vector2D{
return (new Vector2D((x + vector.x), (y + vector.y)));
}
public function perpDotOf(vector:Vector2D):Number{
return (getPerp().dotOf(vector));
}
public function projectionOn(vector:Vector2D):Vector2D{
v1 = vector.copy();
v1.multiply((this.dotOf(vector) / vector.dotOf(vector)));
return (v1);
}
public function distanceSqTo(vector:Vector2D):Number{
var xSep:Number = (vector.y - y);
var ySep:Number = (vector.x - x);
return (((ySep * ySep) + (xSep * xSep)));
}
public function get lengthSq():Number{
return (((x * x) + (y * y)));
}
public function get length():Number{
if (((!((_oldX == x))) || (!((_oldY == y))))){
_oldX = x;
_oldY = y;
_length = Math.sqrt(((x * x) + (y * y)));
};
return (_length);
}
public function getPerp():Vector2D{
return (new Vector2D(-(y), x));
}
public function subtractedBy(vector:Vector2D):Vector2D{
return (new Vector2D((x - vector.x), (y - vector.y)));
}
public function multiply(scalar:Number):void{
x = (x * scalar);
y = (y * scalar);
}
public function toString():String{
return ((((("(" + x) + ",") + y) + ")"));
}
public function truncate(max:Number):void{
if (lengthSq > (max * max)){
normalize();
multiply(max);
};
}
public function angleTo(vector:Vector2D):Number{
return (Math.acos((dotOf(vector) / (length * vector.length))));
}
public function multipliedBy(scalar:Number):Vector2D{
return (new Vector2D((x * scalar), (y * scalar)));
}
public function getNormalized():Vector2D{
if (length == 0){
return (new Vector2D());
};
return (new Vector2D((x / _length), (y / _length)));
}
public function copy():Vector2D{
var newVector:Vector2D = new Vector2D(x, y);
newVector._length = _length;
newVector._oldX = x;
newVector._oldY = y;
return (newVector);
}
public function wrapAround(topLeft:Vector2D, botRight:Vector2D):void{
if (x > botRight.x){
x = (topLeft.x + (x - botRight.x));
} else {
if (x < topLeft.x){
x = (botRight.x + x);
};
};
if (y < topLeft.y){
y = (botRight.y + y);
} else {
if (y > botRight.y){
y = (topLeft.y + (y - botRight.y));
};
};
}
public function getReverse():Vector2D{
return (new Vector2D(-(x), -(y)));
}
public function addTo(vector:Vector2D):void{
x = (x + vector.x);
y = (y + vector.y);
}
public function reflect(norm:Vector2D):void{
v1 = norm.getReverse();
v1.multiply((2 * dotOf(norm)));
addTo(v1);
}
public function crossOf(vector:Vector2D):Number{
return (((x * vector.y) - (y * vector.x)));
}
public static function rotToHeading(rotInDegrees:Number):Vector2D{
var rotInRad:Number = (rotInDegrees * DEG_TO_RAD);
var xPart:Number = Math.cos(rotInRad);
var yPart:Number = Math.sin(rotInRad);
return (new Vector2D(xPart, yPart));
}
public static function is2ndInFOVof1st(pos1st:Vector2D, facing1st:Vector2D, fov:Number, pos2nd:Vector2D):Boolean{
var toTarget:Vector2D = pos2nd.copy();
toTarget.subtract(pos1st);
toTarget.normalize();
return ((facing1st.dotOf(toTarget) >= Math.cos((fov / 2))));
}
public static function pointToVector(point:Point):Vector2D{
return (new Vector2D(point.x, point.y));
}
}
}//package com.cheezeworld.math
Section 22
//SoundManager (com.melesta.sound.SoundManager)
package com.melesta.sound {
import flash.media.*;
public class SoundManager {
private static var channel:SoundChannel;
public static var _mute:Boolean = false;
private static var map:Object = {};
public function SoundManager(){
super();
throw (new Error(""));
}
public static function play(assetName:String, loops:int=0, transform:SoundTransform=null):SoundChannel{
var cls:Class = (map[assetName] as Class);
var instance:Sound = (new (cls) as Sound);
if (_mute){
transform = new SoundTransform();
transform.volume = 0;
};
return ((instance) ? instance.play(0, loops, transform) : null);
}
public static function resume():void{
_mute = false;
}
public static function mute():void{
_mute = true;
}
public static function registerSoundAsset(assetName:String, cls:Class):void{
if ((((assetName == null)) || ((assetName.split(" ").join("").length == 0)))){
return;
};
if (!map.hasOwnProperty(assetName)){
map[assetName] = cls;
};
}
public static function unregisterSoundAsset(assetName:String):void{
delete map[assetName];
}
}
}//package com.melesta.sound
Section 23
//Direction (com.melesta.utils.math.Direction)
package com.melesta.utils.math {
import flash.geom.*;
public class Direction {
public static const DEG_TO_RAD:Number = (Math.PI / 180);
public static const RAD_TO_DEG:Number = (180 / Math.PI);
private static var directionList:Array = new Array("left", "left_down", "left_up", "up", "right", "right_up", "right_down");
public function Direction(){
super();
}
public static function getDirection(p1:Point, p2:Point):Object{
var object:Object = new Object();
object.direction = "down";
var direction:String = "down";
object.right = false;
var angle:Number = (Math.atan(((p2.y - p1.y) / (p2.x - p1.x))) * RAD_TO_DEG);
if (p2.x > p1.x){
object.right = true;
angle = -(angle);
};
if (angle > -60){
direction = "down_left";
};
if (angle > -30){
direction = "left";
};
if (angle > 30){
direction = "left_up";
};
if (angle > 60){
direction = "up";
};
object.direction = direction;
return (object);
}
}
}//package com.melesta.utils.math
Section 24
//TimeDecoder (com.melesta.utils.time.TimeDecoder)
package com.melesta.utils.time {
public class TimeDecoder {
public function TimeDecoder(){
super();
}
public static function decodeTime(time:Number):String{
var minutes:Number = Math.floor((time / 60));
var seconds:Number = Math.floor((time - (minutes * 60)));
var minutess:String = ((minutes < 10)) ? ("0" + String(minutes)) : String(minutes);
var secondss:String = ((seconds < 10)) ? ("0" + String(seconds)) : String(seconds);
return (((minutess + ":") + secondss));
}
}
}//package com.melesta.utils.time
Section 25
//body_2 (depotProduct_fla.body_2)
package depotProduct_fla {
import flash.display.*;
public dynamic class body_2 extends MovieClip {
public function body_2(){
addFrameScript(0, frame1, 8, frame9);
}
function frame1(){
stop();
}
function frame9(){
stop();
}
}
}//package depotProduct_fla
Section 26
//Field (game.assets.Field)
package game.assets {
public class Field extends FieldTemplate {
public function Field(){
super();
}
}
}//package game.assets
Section 27
//FieldTemplate (game.assets.FieldTemplate)
package game.assets {
import flash.display.*;
public dynamic class FieldTemplate extends MovieClip {
}
}//package game.assets
Section 28
//Grass (game.assets.Grass)
package game.assets {
import flash.events.*;
import flash.display.*;
import flash.filters.*;
import flash.utils.*;
import game.*;
import com.melesta.sound.*;
public class Grass extends GrassTemplate {
private var gameController:GameController;
private var _deathTimer:Timer;
private var _capacity:Number;// = 160
public var index:Number;// = 0
private var _stageInstance:DisplayObjectContainer;
public var distance:Number;// = 0
private var _destroyed:Boolean;// = false
private var _life:Number;// = 16
public static var grassList:Array = new Array();
public static var count:Number = 0;
public function Grass(posx:Number, posy:Number, stageInstance:DisplayObjectContainer=null){
super();
this.mouseChildren = false;
this.mouseEnabled = false;
gameController = GameController.instance;
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
SoundManager.play("action_watering");
_stageInstance = stageInstance;
this.x = posx;
this.y = posy;
this.body.gotoAndPlay(1);
if ((Math.random() * 100) > 40){
body.addEventListener(Event.ENTER_FRAME, grow, false, 0, true);
};
_deathTimer = new Timer(60000, 10);
_stageInstance.addChild(this);
_deathTimer.addEventListener(TimerEvent.TIMER, death, false, 0, true);
_deathTimer.start();
index = Grass.count;
Grass.grassList.push(this);
Grass.count++;
}
public function destroy(event:Event=null):void{
if (!_destroyed){
gameController.removeEventListener(GameController.LEVEL_COMPLETED, remove);
_destroyed = true;
Grass.grassList.splice(index, 1);
Grass.remove();
_deathTimer.stop();
_deathTimer.removeEventListener(TimerEvent.TIMER, death);
_stageInstance.removeChild(this);
};
}
private function grow(event:Event=null):void{
event.stopPropagation();
if (event.target.currentFrame == 15){
body.removeEventListener(Event.ENTER_FRAME, grow, false);
this.body.stop();
};
}
public function getGrass():Number{
if ((_capacity - 10) >= 0){
_capacity = (_capacity - 10);
this.body.gotoAndStop((Math.ceil((_capacity / 10)) + 1));
return (_capacity);
};
return (_capacity);
}
public function hasGrass():Number{
return (_capacity);
}
private function death(event:TimerEvent=null):void{
event.stopPropagation();
_capacity = (_capacity - 10);
if (!_capacity){
destroy();
return;
};
this.body.gotoAndStop(((_capacity / 10) + 1));
}
public static function refreshIndexes():void{
var i:int;
while (i < Grass.grassList.length) {
Grass.grassList[i].index = i;
i++;
};
}
public static function remove():void{
Grass.count--;
Grass.refreshIndexes();
}
public static function getNear(petX:Number, petY:Number):Grass{
var distanceList:Array = new Array();
var i:int;
while (i < Grass.grassList.length) {
distanceList.push(Math.sqrt((((petX - Grass.grassList[i].x) * (petX - Grass.grassList[i].x)) + ((petY - Grass.grassList[i].y) * (petY - Grass.grassList[i].y)))));
Grass.grassList[i].distance = distanceList[i];
i++;
};
Grass.grassList.sortOn("distance", Array.NUMERIC);
Grass.refreshIndexes();
return (Grass.grassList[0]);
}
}
}//package game.assets
Section 29
//GrassTemplate (game.assets.GrassTemplate)
package game.assets {
import flash.display.*;
public dynamic class GrassTemplate extends MovieClip {
public var body:MovieClip;
}
}//package game.assets
Section 30
//PlayGround (game.assets.PlayGround)
package game.assets {
public class PlayGround extends PlayScreenTemplate {
public static var instance:PlayGround;
public function PlayGround(){
super();
instance = this;
}
}
}//package game.assets
Section 31
//PlayScreenTemplate (game.assets.PlayScreenTemplate)
package game.assets {
import flash.display.*;
public dynamic class PlayScreenTemplate extends MovieClip {
}
}//package game.assets
Section 32
//GameController (game.GameController)
package game {
import flash.events.*;
import flash.display.*;
import utils.*;
import com.melesta.sound.*;
public class GameController extends MovieClip {
public static var RESUME_GAME:String = "resume_game";
public static var START_GAME:String = "start_game";
public static var LEVEL_COMPLETED:String = "level_completed";
public static var CHANGE_MONEY:String = "shange_money";
public static var instance:GameController;
public static var DESTROY_GAME:String = "destroy_game";
public static var PAUSE_GAME:String = "pause_game";
public function GameController(){
super();
instance = this;
}
public function changeMoney():void{
dispatchEvent(new Event(GameController.CHANGE_MONEY));
}
public function start():void{
dispatchEvent(new Event(GameController.START_GAME));
}
public function pause():void{
dispatchEvent(new Event(PAUSE_GAME));
}
public function levelCompleted():void{
dispatchEvent(new Event(GameController.LEVEL_COMPLETED));
}
public function destroy():void{
dispatchEvent(new Event(DESTROY_GAME));
if (!SoundsList.muteMusic){
if (SoundsList.gameMusicSound){
SoundsList.gameMusicChannel.stop();
};
if (SoundsList.menuMusicSound){
SoundsList.menuMusicChannel.stop();
};
};
SoundsList.mute = true;
SoundManager.mute();
}
public function resume():void{
dispatchEvent(new Event(RESUME_GAME));
}
}
}//package game
Section 33
//LevelBuilder (game.LevelBuilder)
package game {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import houses.*;
import ui.*;
import market.road.*;
import pets.*;
import utils.*;
import com.melesta.sound.*;
public class LevelBuilder extends MovieClip {
public var houseContainer:HouseContainer;
private var _container:MovieClip;
public var tooltip:Tooltip;
public var goals:GoalsWindow;
private var _gameController:GameController;
private var _bearList:Array;
public var purposes:PurposesWindow;
public var bottomPanel:BottomPanel;
public var road:Road;
private var _bearTime:Number;// = 0
public var petsContainer:PetsContainer;
private var _bearTimer:Timer;
public var waterTooltip:WaterTooltip;
public var petShop:PetShop;
public var results:ResultsWindow;
private var houseTypes:Array;
public static var maxLevel:Number = 1;
public static var instance:LevelBuilder;
public static var currentLevel:Number = 1;
public static var currentLevelXML:XML;
public function LevelBuilder(){
houseTypes = new Array("DRIED_EGGS", "CAKE", "FLOURY_CAKE", "STAKE");
super();
instance = this;
}
public function pause(event:Event=null):void{
_bearTimer.stop();
}
public function get container():MovieClip{
return (_container);
}
private function carCame(event:Event=null):void{
SoundManager.play("car_came");
updateView();
}
public function updateView(event:Event=null):void{
PetShop.instance.update();
BottomPanel.instance.update();
}
public function addBear(event:TimerEvent=null):void{
var currentBear:Array;
_bearTime++;
if (_bearList.length > 0){
currentBear = _bearList[0].split(",");
if (_bearTime >= Number(currentBear[1])){
PetsContainer.instance.addPet(currentBear[0], 0);
_bearList.shift();
};
} else {
_bearTime = 0;
_bearTimer.stop();
};
}
public function addHouses():void{
addPets();
_bearTimer.start();
BottomPanel.instance.startTime();
var housesLength:Number = currentLevelXML.child("Houses").child("h").length();
var houseType:Number = 0;
var houseUpgrade:Number = 0;
var posIndex:Number = 0;
var housesList:Array = new Array();
var i:int;
while (i < housesLength) {
houseType = Number(currentLevelXML.child("Houses").h[i].@Type);
houseUpgrade = Number(currentLevelXML.child("Houses").h[i].@Upgrade);
posIndex = Number(currentLevelXML.child("Houses").h[i].@PosIndex);
HouseContainer.instance.addHouse(houseTypes[houseType], posIndex, houseUpgrade, (i * 0.2));
i++;
};
HouseContainer.instance.addHouse("WELL", 2, 1, (housesLength * 0.2));
if (Config.currentLevel > 3){
HouseContainer.instance.addHouse("PLANE", 2, 1, ((housesLength * 0.2) + 0.2));
};
HouseContainer.instance.addHouse("DEPOT", 2, 1, ((housesLength * 0.2) + 0.8));
if (Config.currentLevel > 1){
HouseContainer.instance.addHouse("CAR", 2, 1, ((housesLength * 0.2) + 0.6));
};
}
public function addMoney(event:MouseEvent=null):void{
Road.instance.addMoney(1000);
}
private function gold(event:MouseEvent=null):void{
ResultsWindow.instance.show();
}
public function createLevel(level:Number=1):void{
var goalType:Number;
var bearType:String;
var bearTime:String;
var purpose:String;
currentLevel = level;
Config.currentLevel = level;
currentLevelXML = Config.getLevel(level);
var goalsLength:Number = currentLevelXML.child("Goals").child("goal").length();
LevelStatistics.goals = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
LevelStatistics.purposes = new Array();
var i:int;
while (i < goalsLength) {
goalType = Number(currentLevelXML.child("Goals").goal[i].@Type);
purpose = ((ProductTypes.numberToType(goalType) + ",") + Number(currentLevelXML.child("Goals").goal[i].@Val));
LevelStatistics.purposes.push(purpose);
i++;
};
_bearTime = 0;
_bearList = new Array();
var bearLength:Number = currentLevelXML.child("BearTimes").child("t").length();
var j:int;
while (j < bearLength) {
bearType = ((currentLevelXML.child("BearTimes").t[j].@Type == "0")) ? "PANDA" : "BROWN";
bearTime = currentLevelXML.child("BearTimes").t[j].@Time;
_bearList.push(((bearType + ",") + bearTime));
j++;
};
goals.show();
LevelStatistics.updateStatistics();
Road.instance.setMoney(Number(currentLevelXML.@StartMoney));
bottomPanel.init();
updateView();
}
public function set container(value:MovieClip):void{
_container = value;
}
public function resume(event:Event=null):void{
_bearTimer.start();
}
public function addPets():void{
Chicken.count = 0;
Chicken.chickenList = new Array();
Pig.count = 0;
Pig.pigList = new Array();
var petsLength:Number = currentLevelXML.child("StartPets").child("Pet").length();
var petType:Number = 0;
var petsList:Array = new Array();
var i:int;
while (i < petsLength) {
petType = Number(currentLevelXML.child("StartPets").Pet[i].@Type);
if (petType){
PetsContainer.instance.addPet("PIG", (0.2 * i));
} else {
PetsContainer.instance.addPet("CHICKEN", (0.2 * i));
};
i++;
};
}
public function prepareAllAssets():void{
_gameController = GameController.instance;
_gameController.addEventListener(GameController.PAUSE_GAME, pause, false, 0, true);
_gameController.addEventListener(GameController.RESUME_GAME, resume, false, 0, true);
petShop = new PetShop();
container.addChild(petShop);
road = new Road();
if (Config.use_cheats){
road.addEventListener(MouseEvent.CLICK, addMoney, false, 0, true);
road.addEventListener(MouseEvent.MOUSE_WHEEL, gold, false, 0, true);
};
container.addChild(road);
road.x = 350;
road.addEventListener(Road.CAR_CAME, carCame, false, 0, true);
road.addEventListener(Road.UPDATE_MONEY, updateView, false, 0, true);
bottomPanel = new BottomPanel();
BottomPanel.effectContainer = container;
bottomPanel.createEffect();
container.addChild(bottomPanel);
houseContainer = new HouseContainer(container);
petsContainer = new PetsContainer(container.parent);
purposes = new PurposesWindow(container.parent);
results = new ResultsWindow(container.parent);
goals = new GoalsWindow(container.parent);
tooltip = new Tooltip();
container.parent.addChild(tooltip);
waterTooltip = new WaterTooltip();
container.parent.addChild(waterTooltip);
_bearTimer = new Timer(1000);
_bearTimer.addEventListener(TimerEvent.TIMER, addBear, false, 0, true);
createLevel(1);
bottomPanel.init();
updateView();
}
}
}//package game
Section 34
//CakeHouse (houses.CakeHouse)
package houses {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
import shop.*;
import ui.*;
import game.*;
import market.road.*;
import pets.*;
import utils.*;
import flash.media.*;
import production.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class CakeHouse extends CakeHouseTemplate {
private var posX:Number;
private var posY:Number;
private var left:Number;// = 1
private var madedProduction:Number;// = 0
private var _progress:WorkLine;
private var _countAnimation:Number;// = 15
private var _upgrade:Number;// = 1
private var gameController:GameController;
private var _upgradeButton:UpgradeButton;
private var _working:Boolean;// = false
private var _stageInstance:DisplayObjectContainer;
public static var output:String = "CAKE";
public static var upgradeCost:Array = new Array(200, 300, 400, 500, 600);
public static var input:Array = new Array("DRIED_EGGS");
public static var firstShow:Boolean = true;
public function CakeHouse(stageInstance:DisplayObjectContainer, upgrd:Number, position:Array, delay:Number=0){
super();
stageInstance.addChild(this);
gameController = GameController.instance;
gameController.addEventListener(GameController.PAUSE_GAME, pause, false, 0, true);
gameController.addEventListener(GameController.RESUME_GAME, resume, false, 0, true);
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
gameController.addEventListener(GameController.CHANGE_MONEY, updateMoney, false, 0, true);
_progress = new WorkLine();
addChild(_progress);
_stageInstance = stageInstance;
var point:Point = new Point(position[0], position[1]);
show(point, delay);
activeArea.addEventListener(MouseEvent.ROLL_OVER, dropShadow, false, 0, true);
activeArea.addEventListener(MouseEvent.ROLL_OUT, removeShadow, false, 0, true);
activeArea.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
_upgrade = upgrd;
_upgradeButton = new UpgradeButton();
_upgradeButton.x = -20;
_upgradeButton.y = -50;
_upgradeButton.target = this;
addChild(_upgradeButton);
upgrade(upgrd);
}
public function destroy(event:Event=null):void{
Tweener.removeTweens(body);
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
gameController.removeEventListener(GameController.PAUSE_GAME, pause);
gameController.removeEventListener(GameController.RESUME_GAME, resume);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
gameController.removeEventListener(GameController.CHANGE_MONEY, updateMoney);
_stageInstance.removeChild(this);
}
private function remove():void{
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
}
public function removeShadow(event:MouseEvent=null):void{
Tooltip.instance.hide();
var mtx:Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
}
private function makeProduction():void{
var ypos:Number;
_working = false;
while (madedProduction > 0) {
ypos = 0;
if (y > 400){
ypos = ((this.y - 40) - (Math.random() * 20));
} else {
ypos = ((this.y - 20) - (Math.random() * 20));
};
PetsContainer.instance.addProduct(output, ((this.x - (left * 80)) - ((left * Math.random()) * 20)), ypos);
madedProduction--;
};
_progress.setProgress(0);
}
private function landing():void{
left = ((this.x)<300) ? -1 : 1;
_progress.x = (-(left) * 50);
_progress.y = -20;
_upgradeButton.x = (left * 40);
_upgradeButton.y = -30;
SoundManager.play("house_landing", 1, new SoundTransform(1, left));
updateMoney();
if (firstShow){
firstShow = false;
BlockTooltip.instance.show(this.x, this.y, Config.currentLanguage.tooltips.bakery);
};
}
public function animate():void{
_countAnimation--;
_progress.setProgress(((37 * (15 - _countAnimation)) / 15));
if (_countAnimation > 0){
Tweener.removeTweens(this.body);
Tweener.addTween(this.body, {scaleX:0.8, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1.1, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleX:1, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleY:0.8, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleX:1.1, time:0.2, delay:0.4, transition:"linear", onComplete:animate});
} else {
Tweener.addTween(this.body, {scaleX:1, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1, time:0.2, delay:0, transition:"linear", onComplete:makeProduction});
};
}
public function upgrade(level:Number):void{
this.body.gotoAndStop(level);
if (_upgrade <= (ShopWindow.availableUpgrades[6] - 1)){
_upgradeButton.caption.text = CakeHouse.upgradeCost[(_upgrade - 1)];
};
if (_upgrade > (ShopWindow.availableUpgrades[6] - 1)){
_upgradeButton.destroy();
};
Road.instance.addMoney(0);
}
public function onClick(event:MouseEvent=null):void{
var i:int;
var movingProduction:MovingProduction;
if (!_working){
_countAnimation = 15;
madedProduction = Depot.instance.getProduction(input, _upgrade);
if (madedProduction > 0){
i = 0;
while (i < madedProduction) {
movingProduction = new MovingProduction("DRIED_EGGS", this.x, (this.y - 20), (i / 7));
i++;
};
_working = true;
animate();
SoundManager.play("house_click", 1);
};
};
}
public function resume(event:Event=null):void{
Tweener.resumeTweens(this);
Tweener.resumeTweens(this.body);
}
public function nextUpgrade():void{
Road.instance.addMoney(-(Number(CakeHouse.upgradeCost[(_upgrade - 1)])));
_upgrade++;
upgrade(_upgrade);
SoundManager.play("action_upgrade", 1);
}
public function dropShadow(event:MouseEvent=null):void{
Tooltip.instance.show(x, y, output, _upgrade, Config.currentLanguage.bakery);
var mtx:Array = [2, 0, 0, 0, -63.5, 0, 2, 0, 0, -63.5, 0, 0, 2, 0, -63.5, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
}
public function pause(event:Event=null):void{
Tweener.pauseTweens(this.body);
Tweener.pauseTweens(this);
}
public function show(position:Point, delay:Number):void{
this.x = position.x;
this.y = 0;
Tweener.addTween(this, {y:position.y, time:0.2, delay:delay, transition:"easeInCirc", onComplete:landing});
}
public function updateMoney(event:Event=null):void{
if (_upgradeButton){
if (CakeHouse.upgradeCost[(_upgrade - 1)] <= Road.currentMoney){
_upgradeButton.disabled(true);
} else {
_upgradeButton.disabled(false);
};
};
}
}
}//package houses
Section 35
//Depot (houses.Depot)
package houses {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
import shop.*;
import ui.*;
import game.*;
import market.road.*;
import utils.*;
import vehicles.*;
import market.*;
import production.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class Depot extends DepotTemplate {
private var _pruductionList:Array;
private var _productionPrice:Array;
private var _capacityList:Array;
private var _importProduction:ImportProduction;
private var _posX:Number;// = 0
private var _posY:Number;// = 0
private var _upgradePosition:Array;
private var _productionDepotSize:Array;
private var _currentItem:Number;// = 0
private var _upgradeButton:UpgradeButton;
private var _stageInstance:DisplayObjectContainer;
private var gameController:GameController;
private var _productionCarSize:Array;
public static var instance:Depot;
public static var upgradeLevel:Number = 1;
public static var upgradeCost:Array = new Array(150, 500, 1000, 12000);
public static var _production:Array = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0);
public function Depot(stageInstance:DisplayObjectContainer, level:Number, delay:Number){
var depotProduct:DepotProduct;
_upgradePosition = new Array(0, -8);
_capacityList = new Array(60, 100, 200, 800);
_productionDepotSize = new Array(1, 2.5, 3.5, 5, 2.5, 8, 10, 25, 35);
_productionPrice = new Array(10, 40, 80, 200, 10, 200, 350, 60, 120, 50, 500);
_productionCarSize = new Array(5, 10, 15, 3, 1, 5, 5, 1, 1, 5, 2);
super();
instance = this;
gameController = GameController.instance;
_stageInstance = stageInstance;
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
gameController.addEventListener(GameController.CHANGE_MONEY, updateMoney, false, 0, true);
stageInstance.addChild(this);
upgradeLevel = level;
SoundManager.registerSoundAsset("house_landing", house_landing);
_pruductionList = new Array();
var point:Point = new Point(277, 430);
show(point, delay);
this.mouseEnabled = false;
activeArea.addEventListener(MouseEvent.MOUSE_OVER, dropShadow, false, 0, true);
activeArea.addEventListener(MouseEvent.MOUSE_OUT, removeShadow, false, 0, true);
activeArea.addEventListener(MouseEvent.CLICK, showMarket, false, 0, true);
var i:int;
var j:int;
var productionContainer:Sprite = new Sprite();
addChild(productionContainer);
i = 0;
while (j <= 7) {
i = 0;
while (i < 5) {
depotProduct = new DepotProduct();
productionContainer.addChild(depotProduct);
depotProduct.y = (-35 - (i * 9.4));
depotProduct.x = (-39 + (j * 9.4));
_pruductionList.push(depotProduct);
i++;
};
j++;
};
productionContainer.mouseEnabled = false;
productionContainer.mouseChildren = false;
this.cacheAsBitmap = true;
_importProduction = new ImportProduction(this, stageInstance);
_upgradeButton = new UpgradeButton();
_upgradeButton.x = _upgradePosition[0];
_upgradeButton.y = _upgradePosition[1];
_upgradeButton.target = this;
addChild(_upgradeButton);
upgrade(upgradeLevel);
}
public function destroy(event:Event=null):void{
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
gameController.removeEventListener(GameController.CHANGE_MONEY, updateMoney);
_production = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0);
_stageInstance.removeChild(this);
}
private function remove():void{
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
}
public function removeShadow(event:MouseEvent=null):void{
var mtx:Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
Tooltip.instance.hide();
}
public function addProduct(type:String):Boolean{
var product:Number = ProductTypes.typeToNumber(type);
if ((((freeSpace() - _productionDepotSize[product]))>=0) ? true : false){
putProduct(product);
return (true);
};
FArrow.instance.show((this.x + 50), (this.y - 100));
return (false);
}
public function updateMoney(event:Event=null):void{
if (_upgradeButton){
if (Depot.upgradeCost[(upgradeLevel - 1)] <= Road.currentMoney){
_upgradeButton.disabled(true);
} else {
_upgradeButton.disabled(false);
};
};
}
private function freeSpace():Number{
var space:Number = 0;
var i:Number = 0;
while (i < _production.length) {
space = (space + (_production[i] * _productionDepotSize[i]));
i++;
};
return ((_capacityList[(upgradeLevel - 1)] - space));
}
public function show(position:Point, delay:Number):void{
this.x = position.x;
this.y = -50;
Tweener.addTween(this, {y:position.y, time:0.4, delay:delay, transition:"easeInQuint", onComplete:landing});
}
public function showMarket(event:MouseEvent=null):void{
if (Car.instance){
if (Car.instance.visible){
SoundManager.play("house_click", 1);
_importProduction.show();
};
};
}
public function animate():void{
}
private function putProduct(type:Number):void{
var _local2 = _production;
var _local3 = type;
var _local4 = (_local2[_local3] + 1);
_local2[_local3] = _local4;
_local2 = LevelStatistics.goals;
_local3 = type;
_local4 = (_local2[_local3] + 1);
_local2[_local3] = _local4;
LevelStatistics.updateStatistics();
updateDepotView();
}
public function onClick(event:MouseEvent=null):void{
}
public function upgrade(level:Number):void{
this.body.gotoAndStop(level);
updateDepotView();
if (upgradeLevel <= (ShopWindow.availableUpgrades[2] - 1)){
_upgradeButton.caption.text = Depot.upgradeCost[(upgradeLevel - 1)];
};
if (upgradeLevel > (ShopWindow.availableUpgrades[2] - 1)){
_upgradeButton.destroy();
};
Road.instance.addMoney(0);
}
public function nextUpgrade():void{
Road.instance.addMoney(-(Number(Depot.upgradeCost[(upgradeLevel - 1)])));
upgradeLevel++;
upgrade(upgradeLevel);
SoundManager.play("action_upgrade", 1);
}
public function productionSize(type:Number):Number{
var capacity:Number = _productionDepotSize[type];
return (((40 / _capacityList[(upgradeLevel - 1)]) * capacity));
}
public function dropShadow(event:MouseEvent=null):void{
var mtx:Array = [2, 0, 0, 0, -63.5, 0, 2, 0, 0, -63.5, 0, 0, 2, 0, -63.5, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
Tooltip.instance.show(x, (y - 50), "DEPOT", upgradeLevel, "Склад");
}
public function updateDepotView():void{
var j:int;
var k:int;
while (k < 40) {
_pruductionList[k].hide();
k++;
};
var item:Number = 0;
var i:int;
while (i < _production.length) {
j = 0;
while (j < Math.ceil((_production[i] * productionSize(i)))) {
_pruductionList[item].show(i);
if (item < 39){
item++;
} else {
break;
};
j++;
};
i++;
};
}
private function landing():void{
SoundManager.play("house_landing", 1);
updateMoney();
}
public function getProduction(type:Array, count:Number):Number{
var product:Number;
var products:Array = new Array();
var i:int;
while (i < type.length) {
product = _production[ProductTypes.typeToNumber(type[i])];
products.push(product);
i++;
};
products.sort(Array.NUMERIC);
var delta:Number = count;
if (count > products[0]){
delta = products[0];
};
var j:int;
while (j < type.length) {
_production[ProductTypes.typeToNumber(type[j])] = (_production[ProductTypes.typeToNumber(type[j])] - delta);
j++;
};
updateDepotView();
return (delta);
}
}
}//package houses
Section 36
//DepotTemplate (houses.DepotTemplate)
package houses {
import flash.display.*;
public dynamic class DepotTemplate extends MovieClip {
public var body:MovieClip;
public var activeArea:MovieClip;
}
}//package houses
Section 37
//DriedEggsHouse (houses.DriedEggsHouse)
package houses {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
import shop.*;
import ui.*;
import game.*;
import market.road.*;
import pets.*;
import utils.*;
import flash.media.*;
import production.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class DriedEggsHouse extends DriedEggsHouseTemplate {
private var posX:Number;
private var posY:Number;
private var left:Number;// = 1
private var madedProduction:Number;// = 0
private var _progress:WorkLine;
private var _countAnimation:Number;// = 15
private var _upgrade:Number;// = 1
private var gameController:GameController;
private var _upgradeButton:UpgradeButton;
private var _working:Boolean;// = false
private var _stageInstance:DisplayObjectContainer;
public static var output:String = "DRIED_EGGS";
public static var upgradeCost:Array = new Array(150, 250, 350, 450, 550);
public static var input:Array = new Array("EGG");
public static var firstShow:Boolean = true;
public function DriedEggsHouse(stageInstance:DisplayObjectContainer, upgrd:Number, position:Array, delay:Number){
super();
gameController = GameController.instance;
gameController.addEventListener(GameController.PAUSE_GAME, pause, false, 0, true);
gameController.addEventListener(GameController.RESUME_GAME, resume, false, 0, true);
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
gameController.addEventListener(GameController.CHANGE_MONEY, updateMoney, false, 0, true);
stageInstance.addChild(this);
_progress = new WorkLine();
addChild(_progress);
_stageInstance = stageInstance;
var point:Point = new Point(position[0], position[1]);
show(point, delay);
activeArea.addEventListener(MouseEvent.ROLL_OVER, dropShadow, false, 0, true);
activeArea.addEventListener(MouseEvent.ROLL_OUT, removeShadow, false, 0, true);
activeArea.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
_upgrade = upgrd;
_upgradeButton = new UpgradeButton();
_upgradeButton.x = -20;
_upgradeButton.y = -50;
_upgradeButton.target = this;
addChild(_upgradeButton);
upgrade(upgrd);
}
public function destroy(event:Event=null):void{
Tweener.removeTweens(body);
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
gameController.removeEventListener(GameController.PAUSE_GAME, pause);
gameController.removeEventListener(GameController.RESUME_GAME, resume);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
gameController.removeEventListener(GameController.CHANGE_MONEY, updateMoney);
_stageInstance.removeChild(this);
}
private function remove():void{
_stageInstance.removeChild(this);
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
}
public function removeShadow(event:MouseEvent=null):void{
Tooltip.instance.hide();
var mtx:Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
}
private function makeProduction():void{
var ypos:Number;
_working = false;
while (madedProduction > 0) {
ypos = 0;
if (y > 400){
ypos = ((this.y - 40) - (Math.random() * 20));
} else {
ypos = ((this.y - 20) - (Math.random() * 20));
};
PetsContainer.instance.addProduct(output, ((this.x - (left * 80)) - ((left * Math.random()) * 20)), ypos);
madedProduction--;
_progress.setProgress(0);
};
}
private function landing():void{
left = ((this.x)<300) ? -1 : 1;
_progress.x = (-(left) * 50);
_progress.y = -20;
_upgradeButton.x = (left * 40);
_upgradeButton.y = -30;
SoundManager.play("house_landing", 1, new SoundTransform(1, left));
updateMoney();
if (firstShow){
firstShow = false;
BlockTooltip.instance.show(this.x, this.y, Config.currentLanguage.tooltips.powdered);
};
}
public function animate():void{
_countAnimation--;
_progress.setProgress(((37 * (15 - _countAnimation)) / 15));
if (_countAnimation > 0){
Tweener.removeTweens(this.body);
Tweener.addTween(this.body, {scaleX:0.8, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1.1, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleX:1, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleY:0.8, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleX:1.1, time:0.2, delay:0.4, transition:"linear", onComplete:animate});
} else {
Tweener.addTween(this.body, {scaleX:1, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1, time:0.2, delay:0, transition:"linear", onComplete:makeProduction});
};
Road.instance.addMoney(0);
}
public function upgrade(level:Number):void{
this.body.gotoAndStop(level);
if (_upgrade <= (ShopWindow.availableUpgrades[5] - 1)){
_upgradeButton.caption.text = DriedEggsHouse.upgradeCost[(_upgrade - 1)];
};
if (_upgrade > (ShopWindow.availableUpgrades[5] - 1)){
_upgradeButton.destroy();
};
}
public function onClick(event:MouseEvent=null):void{
var i:int;
var movingProduction:MovingProduction;
if (!_working){
_countAnimation = 15;
madedProduction = Depot.instance.getProduction(input, _upgrade);
if (madedProduction > 0){
i = 0;
while (i < madedProduction) {
movingProduction = new MovingProduction("EGG", this.x, (this.y - 15), (i / 7));
i++;
};
_working = true;
animate();
SoundManager.play("house_click", 1);
};
};
}
public function resume(event:Event=null):void{
Tweener.resumeTweens(this);
Tweener.resumeTweens(this.body);
}
public function nextUpgrade():void{
Road.instance.addMoney(-(Number(DriedEggsHouse.upgradeCost[(_upgrade - 1)])));
_upgrade++;
upgrade(_upgrade);
SoundManager.play("action_upgrade", 1);
}
public function dropShadow(event:MouseEvent=null):void{
Tooltip.instance.show(x, y, output, _upgrade, Config.currentLanguage.powdered);
var mtx:Array = [2, 0, 0, 0, -63.5, 0, 2, 0, 0, -63.5, 0, 0, 2, 0, -63.5, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
}
public function pause(event:Event=null):void{
Tweener.pauseTweens(this.body);
Tweener.pauseTweens(this);
}
public function show(position:Point, delay:Number):void{
this.x = position.x;
this.y = -50;
Tweener.addTween(this, {y:position.y, time:0.4, delay:delay, transition:"easeInQuint", onComplete:landing});
}
public function updateMoney(event:Event=null):void{
if (_upgradeButton){
if (DriedEggsHouse.upgradeCost[(_upgrade - 1)] <= Road.currentMoney){
_upgradeButton.disabled(true);
} else {
_upgradeButton.disabled(false);
};
};
}
}
}//package houses
Section 38
//FlouryCakeHouse (houses.FlouryCakeHouse)
package houses {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
import shop.*;
import ui.*;
import game.*;
import market.road.*;
import pets.*;
import utils.*;
import flash.media.*;
import production.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class FlouryCakeHouse extends FlouryCakeHouseTemplate {
private var posX:Number;
private var posY:Number;
private var left:Number;// = 1
private var madedProduction:Number;// = 0
private var _progress:WorkLine;
private var _countAnimation:Number;// = 15
private var _upgrade:Number;// = 1
private var gameController:GameController;
private var _upgradeButton:UpgradeButton;
private var _working:Boolean;// = false
private var _stageInstance:DisplayObjectContainer;
public static var output:String = "FLOURY_CAKE";
public static var upgradeCost:Array = new Array(400, 500, 600, 700, 800);
public static var input:Array = new Array("CAKE", "FLOUR");
public static var firstShow:Boolean = true;
public function FlouryCakeHouse(stageInstance:DisplayObjectContainer, upgrd:Number, position:Array, delay:Number){
super();
gameController = GameController.instance;
gameController.addEventListener(GameController.PAUSE_GAME, pause, false, 0, true);
gameController.addEventListener(GameController.RESUME_GAME, resume, false, 0, true);
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
gameController.addEventListener(GameController.CHANGE_MONEY, updateMoney, false, 0, true);
stageInstance.addChild(this);
_progress = new WorkLine();
addChild(_progress);
_stageInstance = stageInstance;
var point:Point = new Point(position[0], position[1]);
show(point, delay);
activeArea.addEventListener(MouseEvent.ROLL_OVER, dropShadow, false, 0, true);
activeArea.addEventListener(MouseEvent.ROLL_OUT, removeShadow, false, 0, true);
activeArea.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
_upgrade = upgrd;
_upgradeButton = new UpgradeButton();
_upgradeButton.x = -20;
_upgradeButton.y = -50;
_upgradeButton.target = this;
addChild(_upgradeButton);
upgrade(upgrd);
}
public function destroy(event:Event=null):void{
Tweener.removeTweens(body);
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
gameController.removeEventListener(GameController.PAUSE_GAME, pause);
gameController.removeEventListener(GameController.RESUME_GAME, resume);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
gameController.removeEventListener(GameController.CHANGE_MONEY, updateMoney);
_stageInstance.removeChild(this);
}
private function remove():void{
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
}
public function removeShadow(event:MouseEvent=null):void{
var mtx:Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
Tooltip.instance.hide();
}
private function makeProduction():void{
var ypos:Number;
_working = false;
_progress.setProgress(0);
while (madedProduction > 0) {
ypos = 0;
if (y > 400){
ypos = ((this.y - 40) - (Math.random() * 20));
} else {
ypos = ((this.y - 20) - (Math.random() * 20));
};
PetsContainer.instance.addProduct(output, ((this.x - (left * 80)) - ((left * Math.random()) * 20)), ypos);
madedProduction--;
};
}
private function landing():void{
left = ((this.x)<300) ? -1 : 1;
_progress.x = (-(left) * 50);
_progress.y = -20;
_upgradeButton.x = (left * 40);
_upgradeButton.y = -30;
SoundManager.play("house_landing", 1, new SoundTransform(1, left));
updateMoney();
if (firstShow){
firstShow = false;
BlockTooltip.instance.show(this.x, this.y, Config.currentLanguage.tooltips.confectionery);
};
}
public function animate():void{
_countAnimation--;
_progress.setProgress(((37 * (15 - _countAnimation)) / 15));
if (_countAnimation > 0){
Tweener.removeTweens(this.body);
Tweener.addTween(this.body, {scaleX:0.8, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1.1, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleX:1, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleY:0.8, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleX:1.1, time:0.2, delay:0.4, transition:"linear", onComplete:animate});
} else {
Tweener.addTween(this.body, {scaleX:1, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1, time:0.2, delay:0, transition:"linear", onComplete:makeProduction});
};
}
public function upgrade(level:Number):void{
this.body.gotoAndStop(level);
if (_upgrade <= (ShopWindow.availableUpgrades[7] - 1)){
_upgradeButton.caption.text = FlouryCakeHouse.upgradeCost[(_upgrade - 1)];
};
if (_upgrade > (ShopWindow.availableUpgrades[7] - 1)){
_upgradeButton.destroy();
};
Road.instance.addMoney(0);
}
public function onClick(event:MouseEvent=null):void{
var i:int;
var movingProduction:MovingProduction;
var movingProduction2:MovingProduction;
if (!_working){
_countAnimation = 15;
madedProduction = Depot.instance.getProduction(input, _upgrade);
if (madedProduction > 0){
i = 0;
while (i < madedProduction) {
movingProduction = new MovingProduction("CAKE", this.x, (this.y - 15), (i / 7));
movingProduction2 = new MovingProduction("FLOUR", this.x, (this.y - 15), (i / 7), true);
i++;
};
_working = true;
animate();
SoundManager.play("house_click", 1);
};
};
}
public function resume(event:Event=null):void{
Tweener.resumeTweens(this);
Tweener.resumeTweens(this.body);
}
public function nextUpgrade():void{
Road.instance.addMoney(-(Number(FlouryCakeHouse.upgradeCost[(_upgrade - 1)])));
_upgrade++;
upgrade(_upgrade);
SoundManager.play("action_upgrade", 1);
}
public function dropShadow(event:MouseEvent=null):void{
Tooltip.instance.show(x, y, output, _upgrade, Config.currentLanguage.confectionery);
var mtx:Array = [2, 0, 0, 0, -63.5, 0, 2, 0, 0, -63.5, 0, 0, 2, 0, -63.5, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
}
public function pause(event:Event=null):void{
Tweener.pauseTweens(this.body);
Tweener.pauseTweens(this);
}
public function show(position:Point, delay:Number):void{
this.x = position.x;
this.y = -50;
Tweener.addTween(this, {y:position.y, time:0.4, delay:delay, transition:"easeInQuint", onComplete:landing});
}
public function updateMoney(event:Event=null):void{
if (_upgradeButton){
if (FlouryCakeHouse.upgradeCost[(_upgrade - 1)] <= Road.currentMoney){
_upgradeButton.disabled(true);
} else {
_upgradeButton.disabled(false);
};
};
}
}
}//package houses
Section 39
//HouseContainer (houses.HouseContainer)
package houses {
import flash.display.*;
import flash.geom.*;
import vehicles.*;
public class HouseContainer {
private var _stageInstance:DisplayObjectContainer;
public static var instance:HouseContainer;
public static var positionList:Array = new Array("118,170", "440,168", "485,258", "78, 260", "485,258", "82,360", "490,360");
public function HouseContainer(stageInstance:DisplayObjectContainer=null):void{
super();
instance = this;
_stageInstance = stageInstance;
}
public function addHouse(type:String, posIndex:Number, upgrade:Number=0, delay:Number=0):void{
var housePlate:HousePlate;
var pos:Array;
var _local7:MeatHouse;
var _local8:FlouryCakeHouse;
var _local9:DriedEggsHouse;
var _local10:CakeHouse;
var _local11:Depot;
var _local12:Well;
var _local13:Car;
var _local14:Plane;
if (((((((((!(upgrade)) && (!((type == "DEPOT"))))) && (!((type == "CAR"))))) && (!((type == "WELL"))))) && (!((type == "PLANE"))))){
housePlate = new HousePlate(_stageInstance, type, posIndex, delay);
} else {
pos = positionList[posIndex].split(",");
switch (type){
case "STAKE":
_local7 = new MeatHouse(_stageInstance, upgrade, pos, delay);
break;
case "FLOURY_CAKE":
_local8 = new FlouryCakeHouse(_stageInstance, upgrade, pos, delay);
break;
case "DRIED_EGGS":
_local9 = new DriedEggsHouse(_stageInstance, upgrade, pos, delay);
break;
case "CAKE":
_local10 = new CakeHouse(_stageInstance, upgrade, pos, delay);
break;
case "DEPOT":
_local11 = new Depot(_stageInstance, upgrade, delay);
break;
case "WELL":
_local12 = new Well(_stageInstance, upgrade, delay);
break;
case "CAR":
_local13 = new Car(_stageInstance, upgrade, delay);
break;
case "PLANE":
_local14 = new Plane(_stageInstance, upgrade, delay);
break;
};
};
}
}
}//package houses
Section 40
//HousePlate (houses.HousePlate)
package houses {
import flash.events.*;
import flash.display.*;
import flash.filters.*;
import ui.*;
import game.*;
import market.road.*;
import utils.*;
import flash.media.*;
import production.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class HousePlate extends HousePlateTemplate {
private var posX:Number;
private var posY:Number;
private var active:Boolean;// = false
private var left:Number;// = 1
private var _icon:ViewProduction;
private var _type:String;
private var _upgrade:Number;// = 0
private var positionIndex:Number;// = 0
private var gameController:GameController;
private var _stageInstance:DisplayObjectContainer;
public static var firstShow:Boolean = true;
public static var types:Array = new Array("DRIED_EGGS", "CAKE", "STAKE", "FLOURY_CAKE");
public static var cost:Array = new Array(150, 200, 1500, 400);
public function HousePlate(stageInstance:DisplayObjectContainer, type:String, posIndex:Number, delay:Number){
super();
stageInstance.addChild(this);
gameController = GameController.instance;
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
gameController.addEventListener(GameController.CHANGE_MONEY, updateMoney, false, 0, true);
_stageInstance = stageInstance;
positionIndex = posIndex;
_icon = new ViewProduction(type);
_type = type;
_icon.y = -45;
addChild(_icon);
_icon.scaleX = (_icon.scaleY = 0.8);
show(delay);
buyButton.price.text = cost[getHouseIndex(_type)];
buyButton.addEventListener(MouseEvent.ROLL_OVER, over, false, 0, true);
buyButton.addEventListener(MouseEvent.ROLL_OUT, out, false, 0, true);
buyButton.addEventListener(MouseEvent.CLICK, click, false, 0, true);
buyButton.addEventListener(MouseEvent.MOUSE_DOWN, press, false, 0, true);
buyButton.gotoAndStop("disable");
}
public function destroy(event:Event=null):void{
buyButton.removeEventListener(MouseEvent.ROLL_OVER, over, false);
buyButton.removeEventListener(MouseEvent.ROLL_OUT, out, false);
buyButton.removeEventListener(MouseEvent.CLICK, click, false);
buyButton.removeEventListener(MouseEvent.MOUSE_DOWN, press);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
gameController.removeEventListener(GameController.CHANGE_MONEY, updateMoney);
_stageInstance.removeChild(this);
}
private function press(event:MouseEvent):void{
if (active){
this.buyButton.gotoAndStop("press");
};
}
private function remove():void{
_stageInstance.removeChild(this);
buyButton.removeEventListener(MouseEvent.ROLL_OVER, over, false);
buyButton.removeEventListener(MouseEvent.ROLL_OUT, out, false);
buyButton.removeEventListener(MouseEvent.CLICK, click, false);
buyButton.removeEventListener(MouseEvent.MOUSE_DOWN, press);
}
private function out(event:MouseEvent):void{
if (active){
this.buyButton.gotoAndStop("active");
};
}
private function click(event:MouseEvent):void{
if (active){
SoundManager.play("action_upgrade", 1);
buyButton.removeEventListener(MouseEvent.CLICK, click, false);
HouseContainer.instance.addHouse(_type, positionIndex, 1, 0);
Road.instance.addMoney(-(Number(cost[getHouseIndex(_type)])));
Tweener.addTween(this, {y:-50, time:0.4, onComplete:destroy, delay:0.2});
};
}
private function over(event:MouseEvent):void{
if (active){
this.buyButton.gotoAndStop("over");
};
}
private function landing():void{
left = ((this.x)<300) ? -1 : 1;
SoundManager.play("house_board_landing", 1, new SoundTransform(1, left));
updateMoney();
if (firstShow){
firstShow = false;
BlockTooltip.instance.show(this.x, this.y, Config.currentLanguage.tooltips.house_plate);
};
}
public function updateMoney(event:Event=null):void{
if (Road.currentMoney >= Number(cost[getHouseIndex(_type)])){
this.active = true;
this.buyButton.gotoAndStop("active");
} else {
buyButton.gotoAndStop("disable");
this.active = false;
};
}
public function show(delay:Number):void{
var position:Array = HouseContainer.positionList[positionIndex].split(",");
this.x = position[0];
this.y = -50;
Tweener.addTween(this, {y:position[1], time:0.4, delay:delay, transition:"easeInQuint", onComplete:landing});
updateMoney();
}
public static function getHouseIndex(house:String):Number{
switch (house){
case "DRIED_EGGS":
return (0);
case "CAKE":
return (1);
case "STAKE":
return (2);
case "FLOURY_CAKE":
return (3);
};
return (0);
}
}
}//package houses
Section 41
//HousePlateTemplate (houses.HousePlateTemplate)
package houses {
import flash.display.*;
public dynamic class HousePlateTemplate extends MovieClip {
public var buyButton:MovieClip;
}
}//package houses
Section 42
//MeatHouse (houses.MeatHouse)
package houses {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
import shop.*;
import ui.*;
import game.*;
import market.road.*;
import pets.*;
import utils.*;
import flash.media.*;
import production.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class MeatHouse extends MeatHouseTemplate {
private var posX:Number;
private var posY:Number;
private var left:Number;// = 1
private var madedProduction:Number;// = 0
private var _progress:WorkLine;
private var _countAnimation:Number;// = 15
private var _upgrade:Number;// = 1
private var gameController:GameController;
private var _upgradeButton:UpgradeButton;
private var _working:Boolean;// = false
private var _stageInstance:DisplayObjectContainer;
public static var output:String = "STAKE";
public static var upgradeCost:Array = new Array(1500, 2500, 3500, 4500, 5500);
public static var input:Array = new Array("MEAT");
public static var firstShow:Boolean = true;
public function MeatHouse(stageInstance:DisplayObjectContainer, upgrd:Number, position:Array, delay:Number){
super();
gameController = GameController.instance;
gameController.addEventListener(GameController.PAUSE_GAME, pause, false, 0, true);
gameController.addEventListener(GameController.RESUME_GAME, resume, false, 0, true);
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
gameController.addEventListener(GameController.CHANGE_MONEY, updateMoney, false, 0, true);
stageInstance.addChild(this);
_progress = new WorkLine();
addChild(_progress);
_stageInstance = stageInstance;
var point:Point = new Point(position[0], position[1]);
show(point, delay);
activeArea.addEventListener(MouseEvent.ROLL_OVER, dropShadow, false, 0, true);
activeArea.addEventListener(MouseEvent.ROLL_OUT, removeShadow, false, 0, true);
activeArea.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
_upgrade = upgrd;
_upgradeButton = new UpgradeButton();
_upgradeButton.x = -20;
_upgradeButton.y = -50;
_upgradeButton.target = this;
addChild(_upgradeButton);
upgrade(upgrd);
}
public function destroy(event:Event=null):void{
Tweener.removeTweens(body);
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
gameController.removeEventListener(GameController.PAUSE_GAME, pause);
gameController.removeEventListener(GameController.RESUME_GAME, resume);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
gameController.removeEventListener(GameController.CHANGE_MONEY, updateMoney);
_stageInstance.removeChild(this);
}
private function remove():void{
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
}
public function removeShadow(event:MouseEvent=null):void{
var mtx:Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
Tooltip.instance.hide();
}
private function makeProduction():void{
var ypos:Number;
_working = false;
while (madedProduction > 0) {
ypos = 0;
if (y > 350){
ypos = ((this.y - 40) - (Math.random() * 20));
} else {
ypos = ((this.y - 20) - (Math.random() * 20));
};
PetsContainer.instance.addProduct(output, ((this.x - (left * 80)) - ((left * Math.random()) * 20)), ypos);
madedProduction--;
};
_progress.setProgress(0);
}
private function landing():void{
left = ((this.x)<300) ? -1 : 1;
_progress.x = (-(left) * 50);
_progress.y = -20;
_upgradeButton.x = (left * 40);
_upgradeButton.y = -30;
SoundManager.play("house_landing", 1, new SoundTransform(1, left));
updateMoney();
if (firstShow){
firstShow = false;
BlockTooltip.instance.show(this.x, this.y, Config.currentLanguage.tooltips.meat_cutter);
};
}
public function animate():void{
_countAnimation--;
if (_countAnimation > 0){
_progress.setProgress(((37 * (15 - _countAnimation)) / 15));
Tweener.removeTweens(this.body);
Tweener.addTween(this.body, {scaleX:0.8, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1.1, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleX:1, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleY:0.8, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleX:1.1, time:0.2, delay:0.4, transition:"linear", onComplete:animate});
} else {
Tweener.addTween(this.body, {scaleX:1, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1, time:0.2, delay:0, transition:"linear", onComplete:makeProduction});
};
}
public function upgrade(level:Number):void{
this.body.gotoAndStop(level);
if (_upgrade <= (ShopWindow.availableUpgrades[8] - 1)){
_upgradeButton.caption.text = MeatHouse.upgradeCost[(_upgrade - 1)];
};
if (_upgrade > (ShopWindow.availableUpgrades[8] - 1)){
_upgradeButton.destroy();
};
Road.instance.addMoney(0);
}
public function onClick(event:MouseEvent=null):void{
var i:int;
var movingProduction:MovingProduction;
if (!_working){
_countAnimation = 15;
madedProduction = Depot.instance.getProduction(input, _upgrade);
if (madedProduction > 0){
i = 0;
while (i < madedProduction) {
movingProduction = new MovingProduction("MEAT", this.x, (this.y - 15), (i / 7));
i++;
};
_working = true;
animate();
SoundManager.play("house_click", 1);
};
};
}
public function resume(event:Event=null):void{
Tweener.resumeTweens(this);
Tweener.resumeTweens(this.body);
}
public function nextUpgrade():void{
Road.instance.addMoney(-(Number(MeatHouse.upgradeCost[(_upgrade - 1)])));
_upgrade++;
upgrade(_upgrade);
SoundManager.play("action_upgrade", 1);
}
public function dropShadow(event:MouseEvent=null):void{
Tooltip.instance.show(x, y, output, _upgrade, Config.currentLanguage.meat_cutter);
var mtx:Array = [2, 0, 0, 0, -63.5, 0, 2, 0, 0, -63.5, 0, 0, 2, 0, -63.5, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
}
public function pause(event:Event=null):void{
Tweener.pauseTweens(this.body);
Tweener.pauseTweens(this);
}
public function show(position:Point, delay:Number):void{
this.x = position.x;
this.y = -50;
Tweener.addTween(this, {y:position.y, time:0.4, delay:delay, transition:"easeInQuint", onComplete:landing});
}
public function updateMoney(event:Event=null):void{
if (_upgradeButton){
if (MeatHouse.upgradeCost[(_upgrade - 1)] <= Road.currentMoney){
_upgradeButton.disabled(true);
} else {
_upgradeButton.disabled(false);
};
};
}
}
}//package houses
Section 43
//UpgradeButton (houses.UpgradeButton)
package houses {
import flash.events.*;
import flash.display.*;
public class UpgradeButton extends UpgradeButtonTemplate {
private var active:Boolean;// = true
private var _target:MovieClip;
public function UpgradeButton(){
super();
addEventListener(MouseEvent.MOUSE_OVER, over, false, 0, true);
addEventListener(MouseEvent.MOUSE_OUT, out, false, 0, true);
addEventListener(MouseEvent.MOUSE_DOWN, click, false, 0, true);
addEventListener(MouseEvent.CLICK, upgrade, false, 0, true);
this.gotoAndStop("active");
}
public function set target(target:MovieClip):void{
_target = target;
}
public function disabled(value:Boolean):void{
if (value){
this.active = true;
this.gotoAndStop("active");
} else {
this.active = false;
this.gotoAndStop("disable");
};
}
public function click(event:MouseEvent):void{
if (active){
this.gotoAndStop("press");
};
}
public function out(event:MouseEvent):void{
if (active){
this.gotoAndStop("active");
};
}
public function get target():MovieClip{
return (_target);
}
public function over(event:MouseEvent):void{
if (active){
this.gotoAndStop("over");
};
}
public function destroy():void{
removeEventListener(MouseEvent.MOUSE_OVER, over, false);
removeEventListener(MouseEvent.MOUSE_OUT, out, false);
removeEventListener(MouseEvent.MOUSE_DOWN, click, false);
removeEventListener(MouseEvent.CLICK, upgrade, false);
_target.removeChild(this);
}
private function upgrade(event:MouseEvent=null):void{
if (this.active){
target.nextUpgrade();
};
}
}
}//package houses
Section 44
//UpgradeButtonTemplate (houses.UpgradeButtonTemplate)
package houses {
import flash.display.*;
import flash.text.*;
public dynamic class UpgradeButtonTemplate extends MovieClip {
public var caption:TextField;
public function UpgradeButtonTemplate(){
addFrameScript(0, frame1, 6, frame7);
}
function frame7(){
stop();
}
function frame1(){
stop();
}
}
}//package houses
Section 45
//Well (houses.Well)
package houses {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
import shop.*;
import ui.*;
import game.*;
import market.road.*;
import utils.*;
import flash.media.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class Well extends WellTemplate {
private var posX:Number;
private var posY:Number;
private var _watering:SoundChannel;
private var _countAnimation:Number;// = 0
private var _size:Number;// = 100
private var _deltaWater:Array;
private var _upgradePosition:Array;
private var _upgradeLevel:Number;// = 1
private var gameController:GameController;
private var _stageInstance:DisplayObjectContainer;
private var _upgradeButton:UpgradeButton;
private var _countSteps:Number;// = 0
public static var waterPrice:Array = new Array(19, 17, 10, 7);
public static var instance:Well;
public static var state:String = "full";
public static var upgradeCost:Array = new Array(300, 600, 1200, 5000);
public static var firstShow:Boolean = true;
public function Well(stageInstance:DisplayObjectContainer, level:Number, delay:Number){
_upgradePosition = new Array(-50, -30);
_deltaWater = new Array(20, 15, 10, 1);
super();
instance = this;
state = "full";
this.body.mouseEnabled = false;
gameController = GameController.instance;
gameController.addEventListener(GameController.PAUSE_GAME, pause, false, 0, true);
gameController.addEventListener(GameController.RESUME_GAME, resume, false, 0, true);
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
gameController.addEventListener(GameController.CHANGE_MONEY, updateMoney, false, 0, true);
_upgradeLevel = level;
_watering = new SoundChannel();
_stageInstance = stageInstance;
stageInstance.addChild(this);
var bitmapData:BitmapData = new BitmapData(100, 100, true, 281857228);
var bitmapArea:Bitmap = new Bitmap(bitmapData);
var activeArea:Sprite = new Sprite();
bitmapArea.x = -50;
bitmapArea.y = -100;
activeArea.addChild(bitmapArea);
addChild(activeArea);
SoundManager.registerSoundAsset("house_landing", house_landing);
var point:Point = new Point(267, 135);
show(point, delay);
activeArea.addEventListener(MouseEvent.MOUSE_OVER, dropShadow, false, 0, true);
activeArea.addEventListener(MouseEvent.MOUSE_OUT, removeShadow, false, 0, true);
activeArea.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
_upgradeButton = new UpgradeButton();
_upgradeButton.x = _upgradePosition[0];
_upgradeButton.y = _upgradePosition[1];
_upgradeButton.target = this;
addChild(_upgradeButton);
upgrade(_upgradeLevel);
}
public function updateMoney(event:Event=null):void{
if (_upgradeButton){
if (Well.upgradeCost[(_upgradeLevel - 1)] <= Road.currentMoney){
_upgradeButton.disabled(true);
} else {
_upgradeButton.disabled(false);
};
};
}
private function remove():void{
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
}
public function removeShadow(event:MouseEvent=null):void{
event.stopPropagation();
var mtx:Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
Tooltip.instance.hide();
}
public function show(position:Point, delay:Number):void{
this.x = position.x;
this.y = -50;
Tweener.addTween(this, {y:position.y, time:0.4, delay:delay, transition:"easeInQuint", onComplete:landing});
}
private function landing():void{
SoundManager.play("house_landing", 1);
updateMoney();
}
public function animate():void{
_countAnimation++;
if (_countAnimation < 10){
setWater();
Tweener.removeTweens(this.body);
Tweener.addTween(this.body, {scaleX:0.8, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1.1, time:0.2, delay:0, transition:"linear"});
Tweener.addTween(this.body, {scaleY:1, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleX:1, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleY:0.8, time:0.2, delay:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleX:1.1, time:0.2, delay:0.2, transition:"linear", onComplete:animate});
} else {
Tweener.addTween(this.body, {scaleY:1, time:0.2, transition:"linear"});
Tweener.addTween(this.body, {scaleX:1, time:0.2, transition:"linear"});
Well.state = "full";
_watering.stop();
};
}
public function upgrade(level:Number):void{
this.body.gotoAndStop(level);
if (_upgradeLevel <= (ShopWindow.availableUpgrades[1] - 1)){
_upgradeButton.caption.text = Well.upgradeCost[(_upgradeLevel - 1)];
};
if (_upgradeLevel > (ShopWindow.availableUpgrades[1] - 1)){
_upgradeButton.destroy();
};
Road.instance.addMoney(0);
}
public function setWater():void{
this.waterline.progressMask.height = (50 - ((45 * (10 - _countAnimation)) / 10));
}
public function onClick(event:MouseEvent=null):void{
if ((((Road.levelMoney > Well.waterPrice[(_upgradeLevel - 1)])) && ((Well.state == "empty")))){
Road.instance.addMoney(-(Well.waterPrice[(_upgradeLevel - 1)]));
Well.state = "working";
_watering = SoundManager.play("action_well", 1);
_countAnimation = 0;
animate();
};
if ((((Road.levelMoney < Well.waterPrice[(_upgradeLevel - 1)])) && ((Well.state == "empty")))){
FArrow.instance.show((this.x + 150), (this.y - 100));
SoundManager.play("fool_action", 1);
};
}
public function resume(event:Event):void{
Tweener.resumeTweens(body);
if (Well.state == "working"){
_watering = SoundManager.play("action_well", 1);
};
}
public function getWater():Boolean{
if (Well.state == "full"){
_countSteps++;
if (Math.ceil((100 / _deltaWater[(_upgradeLevel - 1)])) > _countSteps){
this.waterline.progressMask.height = ((40 * (100 - (_deltaWater[(_upgradeLevel - 1)] * _countSteps))) / 100);
return (true);
};
if (Math.ceil((100 / _deltaWater[(_upgradeLevel - 1)])) == _countSteps){
FArrow.instance.show((this.x + 10), (this.y - 60));
this.waterline.progressMask.height = 0;
Well.state = "empty";
if (firstShow){
firstShow = false;
BlockTooltip.instance.show(this.x, this.y, Config.currentLanguage.tooltips.well_empty, true);
};
_countSteps = 0;
return (true);
};
};
FArrow.instance.show((this.x + 10), (this.y - 60));
SoundManager.play("fool_action", 1);
return (false);
}
public function nextUpgrade():void{
Road.instance.addMoney(-(Number(Well.upgradeCost[(_upgradeLevel - 1)])));
_upgradeLevel++;
upgrade(_upgradeLevel);
SoundManager.play("action_upgrade", 1);
}
public function destroy(event:Event=null):void{
_watering.stop();
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
gameController.removeEventListener(GameController.CHANGE_MONEY, updateMoney);
gameController.removeEventListener(GameController.RESUME_GAME, resume);
gameController.removeEventListener(GameController.PAUSE_GAME, pause);
_stageInstance.removeChild(this);
}
public function pause(event:Event):void{
Tweener.pauseTweens(body);
_watering.stop();
}
public function dropShadow(event:MouseEvent=null):void{
event.stopPropagation();
var mtx:Array = [2, 0, 0, 0, -63.5, 0, 2, 0, 0, -63.5, 0, 0, 2, 0, -63.5, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
Tooltip.instance.show(x, (y - 20), "WELL", 0, "WELL");
}
}
}//package houses
Section 46
//WellTemplate (houses.WellTemplate)
package houses {
import flash.display.*;
public dynamic class WellTemplate extends MovieClip {
public var waterline:MovieClip;
public var body:MovieClip;
public var activeArea:MovieClip;
}
}//package houses
Section 47
//MapNode (map.MapNode)
package map {
import flash.events.*;
import flash.display.*;
import shop.*;
import ui.*;
import utils.*;
import com.melesta.sound.*;
public class MapNode extends MapNodeTemplate {
public var states:Array;
public var _state:String;// = "inaccessible"
public var level:Number;
private var _positions:Array;
private var _currentView:MovieClip;
public static var nodeList:Array = new Array();
public static var inaccessibleShow:Boolean = true;
public static var firstShow:Boolean = true;
public function MapNode(index:Number, stateIndex:Number){
_positions = new Array("220,364", "246, 387", "270, 409", "302,387", "334,367", "366,345", "394,372", "423,397", "452,422", "479,397", "506,373", "534,348", "511,322", "482,297", "454,272");
states = new Array("inaccessible", "none", "novel", "normal", "silver", "gold");
super();
this.x = _positions[index].split(",")[0];
this.y = _positions[index].split(",")[1];
this.level = (index + 1);
this.state = states[stateIndex];
MapNode.nodeList.push(this);
update();
addEventListener(MouseEvent.MOUSE_DOWN, press, false, 0, true);
addEventListener(MouseEvent.MOUSE_OVER, over, false, 0, true);
addEventListener(MouseEvent.MOUSE_OUT, out, false, 0, true);
addEventListener(MouseEvent.CLICK, gotoLevel, false, 0, true);
}
public function gotoLevel(event:MouseEvent=null):void{
if (state != "none"){
MapWindow.instance.hide(level);
} else {
ShopWindow.instance.show();
};
}
public function set state(value:String):void{
_state = value;
}
public function press(event:MouseEvent=null):void{
_currentView.gotoAndStop(3);
MapTooltip.instance.hide();
}
public function out(event:MouseEvent=null):void{
_currentView.gotoAndStop(1);
MapTooltip.instance.hide();
}
public function update():void{
var i:int = this.numChildren;
while (i--) {
this.getChildAt(i).visible = false;
};
if (state != "inaccessible"){
this.getChildByName(state).visible = true;
_currentView = (this.getChildByName(state) as MovieClip);
};
if ((((((state == "novel")) && (firstShow))) && (inaccessibleShow))){
firstShow = false;
MapTooltip.instance.showHelp(this.x, (this.y - 10), Config.currentLanguage.tooltips.level_icon);
} else {
if ((((((state == "none")) && (inaccessibleShow))) && (!(firstShow)))){
inaccessibleShow = false;
MapTooltip.instance.showHelp(this.x, (this.y - 10), Config.currentLanguage.tooltips.level_inaccessible);
};
};
}
public function get state():String{
return (_state);
}
public function over(event:MouseEvent=null):void{
_currentView.gotoAndStop(2);
MapTooltip.instance.show(this.x, (this.y - 15), level);
SoundManager.play("ui_button_hover");
}
public static function updateViews():void{
var i:int;
while (i < MapNode.nodeList.length) {
MapNode.nodeList[i].update();
i++;
};
}
}
}//package map
Section 48
//MapWindow (map.MapWindow)
package map {
import flash.events.*;
import shop.*;
import ui.*;
import flash.net.*;
import game.*;
import utils.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class MapWindow extends MapTemplate {
public static var needIndex:Number = -1;
public static var instance:MapWindow;
public function MapWindow(){
super();
instance = this;
shopBtn.caption.text = Config.currentLanguage.shop;
menuBtn.caption.text = Config.currentLanguage.menu;
shopBtn.addEventListener(MouseEvent.CLICK, showShop, false, 0, true);
menuBtn.addEventListener(MouseEvent.CLICK, showMenu, false, 0, true);
var i:int;
while (i < 15) {
addChild(new MapNode(i, 0));
i++;
};
this.visible = false;
buyBtn.caption.mouseEnabled = false;
buyBtn.stop();
buyBtn.caption.text = Config.currentLanguage.download_full_version;
buyBtn.addEventListener(MouseEvent.MOUSE_OVER, btnOver, false, 0, true);
buyBtn.visible = false;
_shadow.visible = false;
if (Config.downloadable){
_shadow.visible = true;
buyBtn.addEventListener(MouseEvent.CLICK, buy, false, 0, true);
buyBtn.caption.text = Config.currentLanguage.download_full_version;
buyBtn.visible = true;
};
}
private function btnOver(event:MouseEvent=null):void{
event.stopPropagation();
SoundManager.play("ui_button_hover");
}
public function hide(level:Number=1):void{
var level = level;
MapTooltip.instance.hide();
Tweener.addTween(this, {alpha:0, time:0.5, transition:"linear", onComplete:function ():void{
this.visible = false;
LevelBuilder.instance.createLevel(level);
}});
}
private function showShop(event:MouseEvent=null):void{
MapTooltip.instance.hide();
ShopWindow.instance.show();
}
public function updateViews():void{
var xml:XML;
var accessLength:Number;
var accessList:Array;
var accessType:String;
var accessValue:String;
var i:int;
if (LevelBuilder.maxLevel != 16){
MapNode.nodeList[(LevelBuilder.maxLevel - 1)].state = "novel";
xml = Config.getLevel(LevelBuilder.maxLevel);
accessLength = xml.child("Accessibility").child("c").length();
accessList = new Array();
i = 0;
while (i < accessLength) {
accessType = xml.child("Accessibility").c[i].@CritID;
accessValue = xml.child("Accessibility").c[i].@Value;
accessList.push(((accessType + ",") + accessValue));
i++;
};
needIndex = -1;
if (!ShopWindow.isAvailable(accessList)){
MapNode.nodeList[(LevelBuilder.maxLevel - 1)].state = "none";
needIndex = (Number(accessList[0].split(",")[0]) + 5);
};
MapNode.updateViews();
} else {
if (!EndScreen.instance.showed){
EndScreen.instance.show();
};
};
}
private function buy(event:MouseEvent=null):void{
var request:URLRequest = new URLRequest(Config.downloadLink);
navigateToURL(request, "_blank");
}
private function showMenu(event:MouseEvent=null):void{
MapTooltip.instance.hide();
StartScreen.instance.show();
}
public function show():void{
updateViews();
MapNode.updateViews();
this.visible = true;
this.alpha = 1;
}
}
}//package map
Section 49
//Road (market.road.Road)
package market.road {
import flash.events.*;
import game.*;
import pets.*;
import vehicles.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class Road extends RoadTemlate {
private var upgradeForces:Array;
private var _planeUpgrade:Number;// = 0
private var _carUpgrade:Number;// = 0
private var gameController:GameController;
public static var CAR_CAME:String = "car_came";
public static var currentMoney:Number = 0;
public static var UPDATE_MONEY:String = "update_money";
public static var exportProduction:String = "FLOUR";
public static var instance:Road = null;
public static var PLANE_CAME:String = "plane_came";
public static var exportProductCount:Number = 0;
public static var levelMoney:Number = 0;
public function Road(){
upgradeForces = new Array(20, 15, 10, 5);
super();
gameController = GameController.instance;
gameController.addEventListener(GameController.PAUSE_GAME, pause, false, 0, true);
gameController.addEventListener(GameController.RESUME_GAME, resume, false, 0, true);
gameController.addEventListener(GameController.LEVEL_COMPLETED, levelCompleted, false, 0, true);
instance = this;
car.visible = false;
plane.visible = false;
setMoney(0);
if (Farm2.portal == "mail.ru"){
this.coins.gotoAndStop(4);
};
}
public function setMoney(value:Number=0):void{
levelMoney = value;
currentMoney = value;
money.text = String(levelMoney);
dispatchEvent(new Event(Road.UPDATE_MONEY));
GameController.instance.changeMoney();
}
public function levelCompleted(event:Event=null):void{
setMoney(0);
plane.x = 100;
car.visible = (plane.visible = false);
car.x = 100;
Tweener.removeTweens(this.car);
Tweener.removeTweens(this.plane);
}
public function goCar(moneyValue:Number, upgrade:Number):void{
Car.instance.visible = false;
_carUpgrade = upgrade;
car.body.gotoAndStop((upgrade + 1));
car.body.scaleX = -1;
car.money.text = String(moneyValue);
car.visible = true;
car.x = 100;
Tweener.addTween(car, {x:205, time:(upgradeForces[_carUpgrade] / 2), transition:"linear", onComplete:backCar});
}
public function resume(event:Event):void{
Tweener.resumeTweens(plane);
Tweener.resumeTweens(car);
coins.play();
if (Farm2.portal == "mail.ru"){
this.coins.gotoAndStop(4);
};
}
private function backCar():void{
car.body.scaleX = 1;
Tweener.addTween(car, {x:100, time:(upgradeForces[_carUpgrade] / 2), transition:"linear", onComplete:function ():void{
car.visible = false;
dispatchEvent(new Event(Road.CAR_CAME));
addMoney(Number(car.money.text));
Car.instance.visible = true;
}});
}
public function pause(event:Event):void{
Tweener.pauseTweens(plane);
Tweener.pauseTweens(car);
coins.stop();
}
private function backPlane():void{
plane.body.scaleX = 1;
Tweener.addTween(plane, {x:100, time:(upgradeForces[_planeUpgrade] / 2), transition:"linear", onComplete:function ():void{
plane.visible = false;
dispatchEvent(new Event(Road.PLANE_CAME));
Plane.instance.visible = true;
SoundManager.play("airplane_flyin");
PetsContainer.instance.addFlyProduct(exportProduction, exportProductCount);
}});
}
public function goPlane(moneyValue:Number, upgrade:Number):void{
_planeUpgrade = upgrade;
dispatchEvent(new Event(Road.UPDATE_MONEY));
plane.body.gotoAndStop((upgrade + 1));
Plane.instance.visible = false;
plane.body.scaleX = -1;
plane.money.text = String(moneyValue);
plane.visible = true;
plane.x = 100;
addMoney(-(Number(plane.money.text)));
Tweener.addTween(plane, {x:205, time:(upgradeForces[_planeUpgrade] / 2), transition:"linear", onComplete:backPlane});
}
public function addMoney(value:Number=0):void{
levelMoney = (levelMoney + value);
money.text = String(levelMoney);
currentMoney = (currentMoney + value);
dispatchEvent(new Event(Road.UPDATE_MONEY));
GameController.instance.changeMoney();
}
}
}//package market.road
Section 50
//RoadTemlate (market.road.RoadTemlate)
package market.road {
import flash.display.*;
import flash.text.*;
public dynamic class RoadTemlate extends MovieClip {
public var coins:MovieClip;
public var plane:MovieClip;
public var money:TextField;
public var car:MovieClip;
}
}//package market.road
Section 51
//Box (market.Box)
package market {
import utils.*;
public class Box extends BoxTemplate {
public var type:Number;
public var count:Number;// = 0
private static var sizeList:Array = new Array(5, 10, 15, 3, 1, 5, 5, 1, 1, 5, 2);
public function Box(){
super();
body.stop();
this.visible = false;
this.type = -1;
this.count = 0;
}
public function addProduct(typeS:String, countN:Number):Number{
var delta:Number;
if (!count){
this.visible = true;
this.body.gotoAndStop(typeS);
type = ProductTypes.typeToNumber(typeS);
};
if ((((count > 0)) && (!((type == ProductTypes.typeToNumber(typeS)))))){
return (0);
};
if (count == sizeList[type]){
return (-1);
};
if ((countN + count) <= sizeList[type]){
count = (count + countN);
this.progress._mask.width = ((20 * count) / sizeList[type]);
return (countN);
};
if ((countN + count) > sizeList[type]){
delta = (sizeList[type] - count);
count = (count + delta);
this.progress._mask.width = ((20 * count) / sizeList[type]);
return (delta);
};
return (countN);
}
}
}//package market
Section 52
//BoxTemplate (market.BoxTemplate)
package market {
import flash.display.*;
public dynamic class BoxTemplate extends MovieClip {
public var progress:MovieClip;
public var body:MovieClip;
}
}//package market
Section 53
//ExportItem (market.ExportItem)
package market {
import flash.events.*;
import flash.display.*;
import ui.*;
import market.road.*;
import com.melesta.sound.*;
public class ExportItem extends ExportItemTemplate {
public var type:String;
public static var CHOOSE_TEN:String = "choose_ten";
public static var CHOOSE_FIVE:String = "choose_five";
public static var CHOOSE_ONE:String = "choose_one";
public function ExportItem(_type:String, _count:Number, _cost:String){
super();
this.product.gotoAndStop(_type);
this.cost.text = _cost;
type = _type;
one.caption.text = "1";
five.caption.text = "5";
ten.caption.text = "10";
one.gotoAndStop(1);
five.gotoAndStop(1);
ten.gotoAndStop(1);
one.addEventListener(MouseEvent.CLICK, chooseOne, false, 0, true);
five.addEventListener(MouseEvent.CLICK, chooseFive, false, 0, true);
ten.addEventListener(MouseEvent.CLICK, chooseTen, false, 0, true);
ten.addEventListener(MouseEvent.MOUSE_OVER, overT, false, 0, true);
one.addEventListener(MouseEvent.MOUSE_OVER, overO, false, 0, true);
five.addEventListener(MouseEvent.MOUSE_OVER, overF, false, 0, true);
ten.addEventListener(MouseEvent.MOUSE_OUT, outT, false, 0, true);
one.addEventListener(MouseEvent.MOUSE_OUT, outO, false, 0, true);
five.addEventListener(MouseEvent.MOUSE_OUT, outF, false, 0, true);
if (Road.currentMoney < 100){
ten.visible = false;
};
if (Road.currentMoney < 50){
five.visible = false;
};
if (Road.currentMoney < 10){
one.visible = false;
};
}
private function overT(event:MouseEvent=null):void{
event.stopPropagation();
ten.gotoAndStop(2);
}
private function outO(event:MouseEvent=null):void{
one.gotoAndStop(1);
}
private function outT(event:MouseEvent=null):void{
ten.gotoAndStop(1);
}
private function chooseFive(event:MouseEvent=null):void{
event.stopPropagation();
five.gotoAndStop(3);
SoundManager.play("item_add", 1);
dispatchEvent(new Event(ExportItem.CHOOSE_FIVE));
}
private function chooseTen(event:MouseEvent=null):void{
event.stopPropagation();
ten.gotoAndStop(3);
SoundManager.play("item_add", 1);
dispatchEvent(new Event(ExportItem.CHOOSE_TEN));
}
public function updateView(deltaMoney:Number=0):void{
if ((Road.currentMoney - deltaMoney) < 100){
ten.visible = false;
};
if ((Road.currentMoney - deltaMoney) < 50){
five.visible = false;
};
if ((Road.currentMoney - deltaMoney) < 10){
one.visible = false;
};
}
private function chooseOne(event:MouseEvent=null):void{
event.stopPropagation();
one.gotoAndStop(3);
dispatchEvent(new Event(ExportItem.CHOOSE_ONE));
SoundManager.play("item_add", 1);
}
private function overF(event:MouseEvent=null):void{
event.stopPropagation();
five.gotoAndStop(2);
}
private function outF(event:MouseEvent=null):void{
five.gotoAndStop(1);
}
private function overO(event:MouseEvent=null):void{
event.stopPropagation();
one.gotoAndStop(2);
}
}
}//package market
Section 54
//ExportItemTemplate (market.ExportItemTemplate)
package market {
import flash.display.*;
import flash.text.*;
public dynamic class ExportItemTemplate extends MovieClip {
public var ten:MovieClip;
public var one:MovieClip;
public var five:MovieClip;
public var cost:TextField;
public var product:MovieClip;
}
}//package market
Section 55
//ExportProduction (market.ExportProduction)
package market {
import flash.events.*;
import flash.display.*;
import ui.*;
import game.*;
import market.road.*;
import pets.*;
import utils.*;
import vehicles.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class ExportProduction extends ExportProductionTemplate {
private var _money:Number;// = 0
private var _productionPlaneSize:Array;
private var _boxList:Array;
private var _boxContainer:Sprite;
private var _typeList:Array;
private var _productionPrice:Array;
private var productItem:ExportItem;
private var _exportProductionList:Array;
private var _carCapacity:Array;
private var itemContainer:Sprite;
private var _boxPositions:Array;
public static var firstShow:Boolean = true;
public function ExportProduction(stageInstance:DisplayObjectContainer){
_productionPrice = new Array(10, 40, 80, 200, 10, 200, 350, 60, 120, 50, 500);
_typeList = new Array("EGG", "DRIED_EGGS", "CAKE", "FLOURY_CAKE", "FLOUR", "MEAT", "STAKE", "PANDA", "BROWN", "CHICKEN", "PIG");
_boxPositions = new Array("153,296|177,296", "141,296|165,296|189,296", "117,296|141,296|165,296|189,296|213,296", "93,296|117,296|141,296|165,296|189,296|213,296|237,296");
_boxContainer = new Sprite();
_carCapacity = new Array(2, 3, 5, 7);
_productionPlaneSize = new Array(5, 10, 15, 3, 5, 5, 5, 1, 1, 5, 2);
super();
itemContainer = new Sprite();
addChild(itemContainer);
stageInstance.parent.parent.addChild(this);
cancelBtn.caption.text = Config.currentLanguage.cancel;
okBtn.caption.text = Config.currentLanguage.order;
title.text = Config.currentLanguage.order_products;
this.visible = false;
okBtn.addEventListener(MouseEvent.CLICK, hide, false, 0, true);
cancelBtn.addEventListener(MouseEvent.CLICK, cancel, false, 0, true);
addChild(_boxContainer);
}
public function updateItemsView():void{
var item:Number;
var k:Number = 0;
while (itemContainer.numChildren > 0) {
itemContainer.removeChildAt((itemContainer.numChildren - 1));
};
var i:int;
while (i < 9) {
item = _exportProductionList[i];
if (item > 0){
productItem = new ExportItem(_typeList[i], item, _productionPrice[i]);
itemContainer.addChild(productItem);
productItem.y = (126 + (k * 22));
productItem.x = 85;
k++;
productItem.addEventListener(ExportItem.CHOOSE_ONE, chooseOne, false, 0, true);
productItem.addEventListener(ExportItem.CHOOSE_TEN, chooseTen, false, 0, true);
productItem.addEventListener(ExportItem.CHOOSE_FIVE, chooseFive, false, 0, true);
};
i++;
};
}
private function chooseTen(event:Event=null):void{
event.stopPropagation();
var deltaProduction:Number = addProductToPlane(event.target.type, 10);
if (!deltaProduction){
};
addMoney((deltaProduction * Number(event.target.cost.text)));
}
public function hide(event:MouseEvent=null):void{
var event = event;
Tweener.addTween(this, {alpha:0, time:0.3, transition:"linear", onComplete:function ():void{
this.visible = false;
}});
if (_money > 0){
Road.instance.goPlane(_money, (Plane.upgradeLevel - 1));
Road.exportProductCount = (_money / 10);
};
SoundManager.play("action_sell_buy");
GameController.instance.resume();
}
private function addProductToPlane(type:String, count:Number):Number{
var delta:Number = 0;
var tempDelta:Number = 0;
var i:int;
while (i < _boxList.length) {
tempDelta = _boxList[i].addProduct(type, count);
if (tempDelta > 0){
delta = (delta + tempDelta);
count = (count - tempDelta);
if (count <= 0){
return (delta);
};
};
i++;
};
return (delta);
}
private function chooseOne(event:Event=null):void{
event.stopPropagation();
var deltaProduction:Number = addProductToPlane(event.target.type, 1);
if (!deltaProduction){
};
addMoney((deltaProduction * Number(event.target.cost.text)));
}
private function addMoney(cost:Number):void{
_money = (_money + cost);
okBtn.visible = true;
money.text = String(_money);
productItem.updateView(_money);
}
public function upgrade(level:Number=0):void{
plane.gotoAndStop(Plane.upgradeLevel);
boxline.gotoAndStop(Plane.upgradeLevel);
}
private function getBoxPositions():Array{
return (_boxPositions[(Plane.upgradeLevel - 1)].split("|"));
}
private function chooseFive(event:Event=null):void{
event.stopPropagation();
var deltaProduction:Number = addProductToPlane(event.target.type, 5);
if (!deltaProduction){
};
addMoney((deltaProduction * Number(event.target.cost.text)));
}
public function cancel(event:MouseEvent=null):void{
var event = event;
if (_money > 0){
SoundManager.play("item_cancel");
};
SoundManager.play("ui_button_click");
Tweener.addTween(this, {alpha:0, time:0.3, transition:"linear", onComplete:function ():void{
this.visible = false;
}});
GameController.instance.resume();
}
public function show():void{
var box:PlaneBox;
GameController.instance.pause();
okBtn.visible = false;
_money = 0;
money.text = "0";
this.visible = true;
plane.gotoAndStop(Plane.upgradeLevel);
boxline.gotoAndStop(Plane.upgradeLevel);
this.alpha = 0;
_exportProductionList = new Array();
var p:int;
while (p < 9) {
_exportProductionList[p] = 0;
p++;
};
_exportProductionList[4] = 100;
Tweener.addTween(this, {alpha:1, time:0.5});
updateItemsView();
while (_boxContainer.numChildren > 0) {
_boxContainer.removeChildAt((_boxContainer.numChildren - 1));
};
_boxList = new Array();
var boxes:Array = getBoxPositions();
var b:int;
while (b < boxes.length) {
box = new PlaneBox();
box.x = boxes[b].split(",")[0];
box.y = boxes[b].split(",")[1];
_boxContainer.addChild(box);
_boxList.push(box);
b++;
};
if (firstShow){
SimpleTooltip.instance.show(Config.currentLanguage.tooltips.plane);
firstShow = false;
};
}
}
}//package market
Section 56
//ExportProductionTemplate (market.ExportProductionTemplate)
package market {
import flash.display.*;
import flash.text.*;
public dynamic class ExportProductionTemplate extends MovieClip {
public var boxline:MovieClip;
public var title:TextField;
public var plane:MovieClip;
public var cancelBtn:MovieClip;
public var okBtn:MovieClip;
public var money:TextField;
}
}//package market
Section 57
//ImportProduction (market.ImportProduction)
package market {
import flash.events.*;
import flash.display.*;
import houses.*;
import ui.*;
import game.*;
import market.road.*;
import pets.*;
import utils.*;
import vehicles.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class ImportProduction extends ImportProductionTemplate {
private var _money:Number;// = 0
private var _productionCarSize:Array;
private var _boxList:Array;
private var _boxContainer:Sprite;
private var _typeList:Array;
private var _productionPrice:Array;
private var _carCapacity:Array;
private var _marketProductionList:Array;
private var _depot:Depot;
private var itemContainer:Sprite;
private var _boxPositions:Array;
public static var firstShow:Boolean = true;
public function ImportProduction(depot:Depot, stageInstance:DisplayObjectContainer){
_productionPrice = new Array(10, 40, 80, 200, 10, 200, 350, 60, 120, 50, 500);
_typeList = new Array("EGG", "DRIED_EGGS", "CAKE", "FLOURY_CAKE", "FLOUR", "MEAT", "STAKE", "PANDA", "BROWN", "CHICKEN", "PIG");
_boxPositions = new Array("436,248|460,248", "415,248|436,248|460,248", "426,249|449,249|472,249|437,226|460,226", "433,249|456,249|479,249|433,227|456,227|479,227|456,205");
_boxContainer = new Sprite();
_carCapacity = new Array(2, 3, 5, 7);
_productionCarSize = new Array(5, 10, 15, 3, 1, 5, 5, 1, 1, 5, 2);
super();
_depot = depot;
itemContainer = new Sprite();
addChild(itemContainer);
stageInstance.parent.parent.addChild(this);
var simpleTooltip:SimpleTooltip = new SimpleTooltip();
stageInstance.parent.parent.addChild(simpleTooltip);
title.text = Config.currentLanguage.ship_products;
cancelBtn.caption.text = Config.currentLanguage.cancel;
okBtn.caption.text = Config.currentLanguage.ship;
this.visible = false;
okBtn.addEventListener(MouseEvent.CLICK, hide, false, 0, true);
cancelBtn.addEventListener(MouseEvent.CLICK, cancel, false, 0, true);
addChild(_boxContainer);
}
public function updateItemsView():void{
var item:Number;
var productItem:ProductItem;
var chickenItem:ProductItem;
var pigItem:ProductItem;
var k:Number = 0;
while (itemContainer.numChildren > 0) {
itemContainer.removeChildAt((itemContainer.numChildren - 1));
};
var i:int;
while (i < 9) {
item = _marketProductionList[i];
if (item > 0){
productItem = new ProductItem(_typeList[i], item, _productionPrice[i]);
itemContainer.addChild(productItem);
productItem.y = (75 + (k * 22));
productItem.x = 30;
k++;
productItem.addEventListener(ProductItem.CHOOSE_ONE, chooseOne, false, 0, true);
productItem.addEventListener(ProductItem.CHOOSE_ALL, chooseAll, false, 0, true);
};
i++;
};
var pet:Number = 0;
if (_marketProductionList[9] > 0){
chickenItem = new ProductItem(_typeList[9], _marketProductionList[9], _productionPrice[9]);
itemContainer.addChild(chickenItem);
chickenItem.y = (75 + (pet * 22));
chickenItem.x = 400;
pet++;
chickenItem.addEventListener(ProductItem.CHOOSE_ONE, chooseOne, false, 0, true);
chickenItem.addEventListener(ProductItem.CHOOSE_ALL, chooseAll, false, 0, true);
};
if (_marketProductionList[10] > 0){
pigItem = new ProductItem(_typeList[10], _marketProductionList[10], _productionPrice[10]);
itemContainer.addChild(pigItem);
pigItem.y = (75 + (pet * 22));
pigItem.x = 400;
pigItem.addEventListener(ProductItem.CHOOSE_ONE, chooseOne, false, 0, true);
pigItem.addEventListener(ProductItem.CHOOSE_ALL, chooseAll, false, 0, true);
};
}
public function hide(event:MouseEvent=null):void{
var event = event;
var p:int;
while (p < 9) {
Depot._production[p] = _marketProductionList[p];
p = (p + 1);
};
Depot.instance.updateDepotView();
Tweener.addTween(this, {alpha:0, time:0.3, transition:"linear", onComplete:function ():void{
this.visible = false;
}});
if (_money > 0){
Road.instance.goCar(_money, (Car.upgradeLevel - 1));
};
SoundManager.play("action_sell_buy");
Chicken.remove((Chicken.count - _marketProductionList[9]));
Pig.remove((Pig.count - _marketProductionList[10]));
GameController.instance.resume();
}
public function show():void{
var box:Box;
GameController.instance.pause();
okBtn.visible = false;
_money = 0;
money.text = "0";
this.visible = true;
car.gotoAndStop(Car.upgradeLevel);
this.alpha = 0;
_marketProductionList = new Array();
var p:int;
while (p < Depot._production.length) {
_marketProductionList[p] = Depot._production[p];
p++;
};
_marketProductionList[9] = Chicken.count;
_marketProductionList[10] = Pig.count;
Tweener.addTween(this, {alpha:1, time:0.5});
updateItemsView();
while (_boxContainer.numChildren > 0) {
_boxContainer.removeChildAt((_boxContainer.numChildren - 1));
};
_boxList = new Array();
var boxes:Array = getBoxPositions();
var b:int;
while (b < boxes.length) {
box = new Box();
box.x = boxes[b].split(",")[0];
box.y = boxes[b].split(",")[1];
_boxContainer.addChild(box);
_boxList.push(box);
b++;
};
if (firstShow){
SimpleTooltip.instance.show(Config.currentLanguage.tooltips.warehouse);
firstShow = false;
};
}
private function chooseOne(event:Event=null):void{
event.stopPropagation();
var deltaProduction:Number = addProductToCar(event.target.type, 1);
_marketProductionList[ProductTypes.typeToNumber(event.target.type)] = (_marketProductionList[ProductTypes.typeToNumber(event.target.type)] - deltaProduction);
updateItemsView();
addMoney((deltaProduction * Number(event.target.cost.text)));
}
private function chooseAll(event:Event=null):void{
event.stopPropagation();
var deltaProduction:Number = addProductToCar(event.target.type, Number(event.target.count.text));
_marketProductionList[ProductTypes.typeToNumber(event.target.type)] = (_marketProductionList[ProductTypes.typeToNumber(event.target.type)] - deltaProduction);
addMoney((deltaProduction * Number(event.target.cost.text)));
updateItemsView();
}
public function cancel(event:MouseEvent=null):void{
var event = event;
if (_money > 0){
SoundManager.play("item_cancel");
};
SoundManager.play("ui_button_click");
Tweener.addTween(this, {alpha:0, time:0.3, transition:"linear", onComplete:function ():void{
this.visible = false;
}});
GameController.instance.resume();
}
private function addMoney(cost:Number):void{
_money = (_money + cost);
okBtn.visible = true;
money.text = String(_money);
}
public function upgrade(level:Number=0):void{
car.gotoAndStop(Car.upgradeLevel);
}
private function addProductToCar(type:String, count:Number):Number{
var delta:Number = 0;
var tempDelta:Number = 0;
var i:int;
while (i < _boxList.length) {
tempDelta = _boxList[i].addProduct(type, count);
if (tempDelta > 0){
delta = (delta + tempDelta);
count = (count - tempDelta);
if (count <= 0){
return (delta);
};
};
i++;
};
return (delta);
}
private function getBoxPositions():Array{
return (_boxPositions[(Car.upgradeLevel - 1)].split("|"));
}
}
}//package market
Section 58
//ImportProductionTemplate (market.ImportProductionTemplate)
package market {
import flash.display.*;
import flash.text.*;
public dynamic class ImportProductionTemplate extends MovieClip {
public var title:TextField;
public var cancelBtn:MovieClip;
public var car:MovieClip;
public var okBtn:MovieClip;
public var money:TextField;
}
}//package market
Section 59
//PlaneBox (market.PlaneBox)
package market {
import utils.*;
public class PlaneBox extends BoxTemplate {
public var type:Number;
public var count:Number;// = 0
private static var sizeList:Array = new Array(5, 10, 15, 3, 5, 5, 5, 1, 1, 5, 2);
public function PlaneBox(){
super();
body.stop();
this.visible = false;
this.type = -1;
this.count = 0;
}
public function addProduct(typeS:String, countN:Number):Number{
var delta:Number;
if (!count){
this.visible = true;
this.body.gotoAndStop(typeS);
type = ProductTypes.typeToNumber(typeS);
};
if ((((count > 0)) && (!((type == ProductTypes.typeToNumber(typeS)))))){
return (0);
};
if (count == sizeList[type]){
return (-1);
};
if ((countN + count) <= sizeList[type]){
count = (count + countN);
this.progress._mask.width = ((20 * count) / sizeList[type]);
return (countN);
};
if ((countN + count) > sizeList[type]){
delta = (sizeList[type] - count);
count = (count + delta);
this.progress._mask.width = ((20 * count) / sizeList[type]);
return (delta);
};
return (countN);
}
}
}//package market
Section 60
//ProductItem (market.ProductItem)
package market {
import flash.events.*;
import flash.display.*;
import ui.*;
import utils.*;
import com.melesta.sound.*;
public class ProductItem extends ProductItemTemplate {
public var type:String;
public static var CHOOSE_ALL:String = "choose_all";
public static var CHOOSE_ONE:String = "choose_one";
public function ProductItem(_type:String, _count:Number, _cost:String){
super();
this.product.gotoAndStop(_type);
this.count.text = String(_count);
this.cost.text = _cost;
type = _type;
one.caption.text = Config.currentLanguage.one;
all.caption.text = Config.currentLanguage.all;
one.gotoAndStop(1);
all.gotoAndStop(1);
one.addEventListener(MouseEvent.CLICK, chooseOne, false, 0, true);
all.addEventListener(MouseEvent.CLICK, chooseAll, false, 0, true);
all.addEventListener(MouseEvent.MOUSE_OVER, overA, false, 0, true);
one.addEventListener(MouseEvent.MOUSE_OVER, overO, false, 0, true);
all.addEventListener(MouseEvent.MOUSE_OUT, outA, false, 0, true);
one.addEventListener(MouseEvent.MOUSE_OUT, outO, false, 0, true);
}
private function outO(event:MouseEvent=null):void{
one.gotoAndStop(1);
}
private function outA(event:MouseEvent=null):void{
all.gotoAndStop(1);
}
private function chooseAll(event:MouseEvent=null):void{
event.stopPropagation();
all.gotoAndStop(3);
SoundManager.play("item_add", 1);
dispatchEvent(new Event(ProductItem.CHOOSE_ALL));
}
private function overO(event:MouseEvent=null):void{
event.stopPropagation();
one.gotoAndStop(2);
}
private function overA(event:MouseEvent=null):void{
event.stopPropagation();
all.gotoAndStop(2);
}
private function chooseOne(event:MouseEvent=null):void{
event.stopPropagation();
one.gotoAndStop(3);
dispatchEvent(new Event(ProductItem.CHOOSE_ONE));
SoundManager.play("item_add", 1);
}
}
}//package market
Section 61
//ProductItemTemplate (market.ProductItemTemplate)
package market {
import flash.display.*;
import flash.text.*;
public dynamic class ProductItemTemplate extends MovieClip {
public var count:TextField;
public var one:MovieClip;
public var all:MovieClip;
public var cost:TextField;
public var product:MovieClip;
}
}//package market
Section 62
//CAKE_HOUSE_7 (Meat_House_fla.CAKE_HOUSE_7)
package Meat_House_fla {
import flash.display.*;
public dynamic class CAKE_HOUSE_7 extends MovieClip {
public function CAKE_HOUSE_7(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package Meat_House_fla
Section 63
//DRIEDEGGS_HOUSE_9 (Meat_House_fla.DRIEDEGGS_HOUSE_9)
package Meat_House_fla {
import flash.display.*;
public dynamic class DRIEDEGGS_HOUSE_9 extends MovieClip {
public function DRIEDEGGS_HOUSE_9(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package Meat_House_fla
Section 64
//FLOURY_CAKE_HOUSE_5 (Meat_House_fla.FLOURY_CAKE_HOUSE_5)
package Meat_House_fla {
import flash.display.*;
public dynamic class FLOURY_CAKE_HOUSE_5 extends MovieClip {
public function FLOURY_CAKE_HOUSE_5(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package Meat_House_fla
Section 65
//MEAT_HOUSE_2 (Meat_House_fla.MEAT_HOUSE_2)
package Meat_House_fla {
import flash.display.*;
public dynamic class MEAT_HOUSE_2 extends MovieClip {
public function MEAT_HOUSE_2(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package Meat_House_fla
Section 66
//Action (org.flintparticles.common.actions.Action)
package org.flintparticles.common.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
public interface Action {
function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void;
function addedToEmitter(D:\work\Farm2\Flash\melesta_lib\src;org\flintparticles\common\actions;Action.as:Emitter):void;
function removedFromEmitter(D:\work\Farm2\Flash\melesta_lib\src;org\flintparticles\common\actions;Action.as:Emitter):void;
function getDefaultPriority():Number;
}
}//package org.flintparticles.common.actions
Section 67
//ActionBase (org.flintparticles.common.actions.ActionBase)
package org.flintparticles.common.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
public class ActionBase implements Action {
public function ActionBase(){
super();
}
public function addedToEmitter(emitter:Emitter):void{
}
public function removedFromEmitter(emitter:Emitter):void{
}
public function getDefaultPriority():Number{
return (0);
}
public function update(emitter:Emitter, particle:Particle, time:Number):void{
}
}
}//package org.flintparticles.common.actions
Section 68
//Age (org.flintparticles.common.actions.Age)
package org.flintparticles.common.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.energyEasing.*;
public class Age extends ActionBase {
private var _easing:Function;
public function Age(easing:Function=null){
super();
if (easing == null){
_easing = Linear.easeNone;
} else {
_easing = easing;
};
}
public function set easing(value:Function):void{
_easing = value;
}
override public function update(emitter:Emitter, particle:Particle, time:Number):void{
particle.age = (particle.age + time);
if (particle.age >= particle.lifetime){
particle.energy = 0;
particle.isDead = true;
} else {
particle.energy = _easing(particle.age, particle.lifetime);
};
}
public function get easing():Function{
return (_easing);
}
}
}//package org.flintparticles.common.actions
Section 69
//Fade (org.flintparticles.common.actions.Fade)
package org.flintparticles.common.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
public class Fade extends ActionBase {
private var _endAlpha:Number;
private var _diffAlpha:Number;
public function Fade(startAlpha:Number=1, endAlpha:Number=0){
super();
_diffAlpha = (startAlpha - endAlpha);
_endAlpha = endAlpha;
}
public function get endAlpha():Number{
return (_endAlpha);
}
public function set endAlpha(value:Number):void{
_diffAlpha = ((_endAlpha + _diffAlpha) - value);
_endAlpha = value;
}
override public function update(emitter:Emitter, particle:Particle, time:Number):void{
var alpha:Number = (_endAlpha + (_diffAlpha * particle.energy));
particle.color = ((particle.color & 0xFFFFFF) | (Math.round((alpha * 0xFF)) << 24));
}
override public function getDefaultPriority():Number{
return (-5);
}
public function set startAlpha(value:Number):void{
_diffAlpha = (value - _endAlpha);
}
public function get startAlpha():Number{
return ((_endAlpha + _diffAlpha));
}
}
}//package org.flintparticles.common.actions
Section 70
//Activity (org.flintparticles.common.activities.Activity)
package org.flintparticles.common.activities {
import org.flintparticles.common.emitters.*;
public interface Activity {
function initialize(D:\work\Farm2\Flash\melesta_lib\src;org\flintparticles\common\activities;Activity.as:Emitter):void;
function removedFromEmitter(D:\work\Farm2\Flash\melesta_lib\src;org\flintparticles\common\activities;Activity.as:Emitter):void;
function update(_arg1:Emitter, _arg2:Number):void;
function addedToEmitter(D:\work\Farm2\Flash\melesta_lib\src;org\flintparticles\common\activities;Activity.as:Emitter):void;
function getDefaultPriority():Number;
}
}//package org.flintparticles.common.activities
Section 71
//Blast (org.flintparticles.common.counters.Blast)
package org.flintparticles.common.counters {
import org.flintparticles.common.emitters.*;
public class Blast implements Counter {
private var _startCount:uint;
public function Blast(startCount:uint){
super();
_startCount = startCount;
}
public function stop():void{
}
public function updateEmitter(emitter:Emitter, time:Number):uint{
return (0);
}
public function startEmitter(emitter:Emitter):uint{
return (_startCount);
}
public function resume():void{
}
public function set startCount(value:Number):void{
_startCount = value;
}
public function get startCount():Number{
return (_startCount);
}
}
}//package org.flintparticles.common.counters
Section 72
//Counter (org.flintparticles.common.counters.Counter)
package org.flintparticles.common.counters {
import org.flintparticles.common.emitters.*;
public interface Counter {
function stop():void;
function startEmitter(:Emitter):uint;
function updateEmitter(_arg1:Emitter, _arg2:Number):uint;
function resume():void;
}
}//package org.flintparticles.common.counters
Section 73
//ZeroCounter (org.flintparticles.common.counters.ZeroCounter)
package org.flintparticles.common.counters {
import org.flintparticles.common.emitters.*;
public class ZeroCounter implements Counter {
public function ZeroCounter(){
super();
}
public function stop():void{
}
public function updateEmitter(emitter:Emitter, time:Number):uint{
return (0);
}
public function startEmitter(emitter:Emitter):uint{
return (0);
}
public function resume():void{
}
}
}//package org.flintparticles.common.counters
Section 74
//Star (org.flintparticles.common.displayObjects.Star)
package org.flintparticles.common.displayObjects {
import flash.display.*;
import flash.geom.*;
public class Star extends Shape {
public function Star(radius:Number, color:uint=0xFFFFFF, bm:String="normal"){
var point:Point;
super();
var rotStep:Number = (Math.PI / 5);
var innerRadius:Number = (radius * Math.cos((rotStep * 2)));
var halfPi:Number = (Math.PI * 0.5);
graphics.beginFill(color);
graphics.moveTo(0, -(radius));
point = Point.polar(innerRadius, (rotStep - halfPi));
graphics.lineTo(point.x, point.y);
point = Point.polar(radius, ((2 * rotStep) - halfPi));
graphics.lineTo(point.x, point.y);
point = Point.polar(innerRadius, ((3 * rotStep) - halfPi));
graphics.lineTo(point.x, point.y);
point = Point.polar(radius, ((4 * rotStep) - halfPi));
graphics.lineTo(point.x, point.y);
point = Point.polar(innerRadius, ((5 * rotStep) - halfPi));
graphics.lineTo(point.x, point.y);
point = Point.polar(radius, ((6 * rotStep) - halfPi));
graphics.lineTo(point.x, point.y);
point = Point.polar(innerRadius, ((7 * rotStep) - halfPi));
graphics.lineTo(point.x, point.y);
point = Point.polar(radius, ((8 * rotStep) - halfPi));
graphics.lineTo(point.x, point.y);
point = Point.polar(innerRadius, ((9 * rotStep) - halfPi));
graphics.lineTo(point.x, point.y);
graphics.lineTo(0, -(radius));
graphics.endFill();
blendMode = bm;
}
}
}//package org.flintparticles.common.displayObjects
Section 75
//Emitter (org.flintparticles.common.emitters.Emitter)
package org.flintparticles.common.emitters {
import flash.events.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.events.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.common.activities.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.utils.*;
public class Emitter extends EventDispatcher {
protected var _running:Boolean;// = false
protected var _activities:PriorityArray;
protected var _particles:Array;
protected var _initializers:PriorityArray;
protected var _counter:Counter;
protected var _started:Boolean;// = false
protected var _actions:PriorityArray;
protected var _useInternalTick:Boolean;// = true
protected var _particleFactory:ParticleFactory;
protected var _fixedFrameTime:Number;// = 0
protected var _maximumFrameTime:Number;// = 0.1
public function Emitter(){
super();
_particles = new Array();
_actions = new PriorityArray();
_initializers = new PriorityArray();
_activities = new PriorityArray();
_counter = new ZeroCounter();
}
public function addInitializer(initializer:Initializer, priority:Number=NaN):void{
if (isNaN(priority)){
priority = initializer.getDefaultPriority();
};
_initializers.add(initializer, priority);
initializer.addedToEmitter(this);
}
public function stop():void{
if (_useInternalTick){
FrameUpdater.instance.removeEventListener(UpdateEvent.UPDATE, updateEventListener);
};
_started = false;
killAllParticles();
}
public function killAllParticles():void{
var len:int = _particles.length;
var i:int;
while (i < len) {
dispatchEvent(new ParticleEvent(ParticleEvent.PARTICLE_DEAD, _particles[i]));
_particleFactory.disposeParticle(_particles[i]);
i++;
};
_particles.length = 0;
}
public function set fixedFrameTime(value:Number):void{
_fixedFrameTime = value;
}
public function get maximumFrameTime():Number{
return (_maximumFrameTime);
}
public function get useInternalTick():Boolean{
return (_useInternalTick);
}
protected function createParticle():Particle{
var particle:Particle = _particleFactory.createParticle();
var len:int = _initializers.length;
initParticle(particle);
var i:int;
while (i < len) {
_initializers[i].initialize(this, particle);
i++;
};
_particles.push(particle);
dispatchEvent(new ParticleEvent(ParticleEvent.PARTICLE_CREATED, particle));
return (particle);
}
public function get particleFactory():ParticleFactory{
return (_particleFactory);
}
private function updateEventListener(ev:UpdateEvent):void{
if (_fixedFrameTime){
update(_fixedFrameTime);
} else {
update(ev.time);
};
}
public function get particles():Array{
return (_particles);
}
protected function sortParticles():void{
}
public function removeActivity(activity:Activity):void{
if (_activities.remove(activity)){
activity.removedFromEmitter(this);
};
}
public function set maximumFrameTime(value:Number):void{
_maximumFrameTime = value;
}
protected function initParticle(particle:Particle):void{
}
public function addAction(action:Action, priority:Number=NaN):void{
if (isNaN(priority)){
priority = action.getDefaultPriority();
};
_actions.add(action, priority);
action.addedToEmitter(this);
}
public function hasInitializerOfType(initializerClass:Class):Boolean{
var len:uint = _initializers.length;
var i:uint;
while (i < len) {
if ((_initializers[i] is initializerClass)){
return (true);
};
i++;
};
return (false);
}
public function resume():void{
_running = true;
}
public function removeInitializer(initializer:Initializer):void{
if (_initializers.remove(initializer)){
initializer.removedFromEmitter(this);
};
}
public function get running():Boolean{
return (_running);
}
public function hasActionOfType(actionClass:Class):Boolean{
var len:uint = _actions.length;
var i:uint;
while (i < len) {
if ((_actions[i] is actionClass)){
return (true);
};
i++;
};
return (false);
}
public function get fixedFrameTime():Number{
return (_fixedFrameTime);
}
public function set particleFactory(value:ParticleFactory):void{
_particleFactory = value;
}
public function hasActivity(activity:Activity):Boolean{
return (_activities.contains(activity));
}
public function addActivity(activity:Activity, priority:Number=NaN):void{
if (isNaN(priority)){
priority = activity.getDefaultPriority();
};
_activities.add(activity, priority);
activity.addedToEmitter(this);
}
public function update(time:Number):void{
var i:int;
var particle:Particle;
var action:Action;
var len2:int;
var j:int;
if (!_running){
return;
};
if (time > _maximumFrameTime){
time = _maximumFrameTime;
};
var len:int = _counter.updateEmitter(this, time);
i = 0;
while (i < len) {
createParticle();
i++;
};
sortParticles();
len = _activities.length;
i = 0;
while (i < len) {
_activities[i].update(this, time);
i++;
};
if (_particles.length > 0){
len = _actions.length;
len2 = _particles.length;
j = 0;
while (j < len) {
action = _actions[j];
i = 0;
while (i < len2) {
particle = _particles[i];
action.update(this, particle, time);
i++;
};
j++;
};
i = len2;
while (i--) {
particle = _particles[i];
if (particle.isDead){
dispatchEvent(new ParticleEvent(ParticleEvent.PARTICLE_DEAD, particle));
_particleFactory.disposeParticle(particle);
_particles.splice(i, 1);
};
};
} else {
dispatchEvent(new EmitterEvent(EmitterEvent.EMITTER_EMPTY));
};
dispatchEvent(new EmitterEvent(EmitterEvent.EMITTER_UPDATED));
}
public function addExistingParticles(particles:Array, applyInitializers:Boolean=false):void{
var i:int;
var len2:int;
var j:int;
var len:int = particles.length;
if (applyInitializers){
len2 = _initializers.length;
j = 0;
while (j < len2) {
i = 0;
while (i < len) {
_initializers[j].initialize(this, particles[i]);
i++;
};
j++;
};
};
i = 0;
while (i < len) {
_particles.push(particles[i]);
dispatchEvent(new ParticleEvent(ParticleEvent.PARTICLE_ADDED, particles[i]));
i++;
};
}
public function removeAction(action:Action):void{
if (_actions.remove(action)){
action.removedFromEmitter(this);
};
}
public function hasActivityOfType(activityClass:Class):Boolean{
var len:uint = _activities.length;
var i:uint;
while (i < len) {
if ((_activities[i] is activityClass)){
return (true);
};
i++;
};
return (false);
}
public function set useInternalTick(value:Boolean):void{
if (_useInternalTick != value){
_useInternalTick = value;
if (_started){
if (_useInternalTick){
FrameUpdater.instance.addEventListener(UpdateEvent.UPDATE, updateEventListener, false, 0, true);
} else {
FrameUpdater.instance.removeEventListener(UpdateEvent.UPDATE, updateEventListener);
};
};
};
}
public function hasInitializer(initializer:Initializer):Boolean{
return (_initializers.contains(initializer));
}
public function start():void{
if (_useInternalTick){
FrameUpdater.instance.addEventListener(UpdateEvent.UPDATE, updateEventListener, false, 0, true);
};
_started = true;
_running = true;
var len:int = _activities.length;
var i:int;
while (i < len) {
_activities[i].initialize(this);
i++;
};
len = _counter.startEmitter(this);
i = 0;
while (i < len) {
createParticle();
i++;
};
}
public function hasAction(action:Action):Boolean{
return (_actions.contains(action));
}
public function pause():void{
_running = false;
}
public function set counter(value:Counter):void{
_counter = value;
}
public function get counter():Counter{
return (_counter);
}
public function runAhead(time:Number, frameRate:Number=10):void{
var maxTime:Number = _maximumFrameTime;
var step:Number = (1 / frameRate);
_maximumFrameTime = step;
while (time > 0) {
time = (time - step);
update(step);
};
_maximumFrameTime = maxTime;
}
}
}//package org.flintparticles.common.emitters
Section 76
//Linear (org.flintparticles.common.energyEasing.Linear)
package org.flintparticles.common.energyEasing {
public class Linear {
public function Linear(){
super();
}
public static function easeOut(age:Number, lifetime:Number):Number{
return ((1 - (age / lifetime)));
}
public static function easeIn(age:Number, lifetime:Number):Number{
return ((1 - (age / lifetime)));
}
public static function easeInOut(age:Number, lifetime:Number):Number{
return ((1 - (age / lifetime)));
}
public static function easeNone(age:Number, lifetime:Number):Number{
return ((1 - (age / lifetime)));
}
}
}//package org.flintparticles.common.energyEasing
Section 77
//Quadratic (org.flintparticles.common.energyEasing.Quadratic)
package org.flintparticles.common.energyEasing {
public class Quadratic {
public function Quadratic(){
super();
}
public static function easeOut(age:Number, lifetime:Number):Number{
age = (1 - (age / lifetime));
return ((age * age));
}
public static function easeIn(age:Number, lifetime:Number):Number{
age = (age / lifetime);
return ((1 - (age * age)));
}
public static function easeInOut(age:Number, lifetime:Number):Number{
age = (age / (lifetime * 0.5));
if (age < 1){
return ((1 - ((age * age) * 0.5)));
};
age = (age - 2);
return (((age * age) * 0.5));
}
}
}//package org.flintparticles.common.energyEasing
Section 78
//EmitterEvent (org.flintparticles.common.events.EmitterEvent)
package org.flintparticles.common.events {
import flash.events.*;
public class EmitterEvent extends Event {
public static var EMITTER_UPDATED:String = "emitterUpdated";
public static var EMITTER_EMPTY:String = "emitterEmpty";
public function EmitterEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
}
}
}//package org.flintparticles.common.events
Section 79
//ParticleEvent (org.flintparticles.common.events.ParticleEvent)
package org.flintparticles.common.events {
import flash.events.*;
import org.flintparticles.common.particles.*;
public class ParticleEvent extends Event {
public var particle:Particle;
public static var PARTICLE_ADDED:String = "particleAdded";
public static var PARTICLE_DEAD:String = "particleDead";
public static var PARTICLE_CREATED:String = "particleCreated";
public function ParticleEvent(type:String, particle:Particle=null, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
this.particle = particle;
}
}
}//package org.flintparticles.common.events
Section 80
//UpdateEvent (org.flintparticles.common.events.UpdateEvent)
package org.flintparticles.common.events {
import flash.events.*;
public class UpdateEvent extends Event {
public var time:Number;
public static var UPDATE:String = "update";
public function UpdateEvent(type:String, time:Number=NaN, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
this.time = time;
}
}
}//package org.flintparticles.common.events
Section 81
//ColorInit (org.flintparticles.common.initializers.ColorInit)
package org.flintparticles.common.initializers {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.utils.*;
public class ColorInit extends InitializerBase {
private var _max:uint;
private var _min:uint;
public function ColorInit(color1:uint, color2:uint){
super();
_min = color1;
_max = color2;
}
public function set minColor(value:uint):void{
_min = value;
}
public function get color():uint{
return (((_min == _max)) ? _min : interpolateColors(_max, _min, 0.5));
}
public function set color(value:uint):void{
_max = (_min = value);
}
override public function initialize(emitter:Emitter, particle:Particle):void{
if (_max == _min){
particle.color = _min;
} else {
particle.color = interpolateColors(_min, _max, Math.random());
};
}
public function get minColor():uint{
return (_min);
}
public function set maxColor(value:uint):void{
_max = value;
}
public function get maxColor():uint{
return (_max);
}
}
}//package org.flintparticles.common.initializers
Section 82
//Initializer (org.flintparticles.common.initializers.Initializer)
package org.flintparticles.common.initializers {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
public interface Initializer {
function initialize(_arg1:Emitter, _arg2:Particle):void;
function addedToEmitter(D:\work\Farm2\Flash\melesta_lib\src;org\flintparticles\common\initializers;Initializer.as:Emitter):void;
function removedFromEmitter(D:\work\Farm2\Flash\melesta_lib\src;org\flintparticles\common\initializers;Initializer.as:Emitter):void;
function getDefaultPriority():Number;
}
}//package org.flintparticles.common.initializers
Section 83
//InitializerBase (org.flintparticles.common.initializers.InitializerBase)
package org.flintparticles.common.initializers {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
public class InitializerBase implements Initializer {
public function InitializerBase(){
super();
}
public function initialize(emitter:Emitter, particle:Particle):void{
}
public function addedToEmitter(emitter:Emitter):void{
}
public function removedFromEmitter(emitter:Emitter):void{
}
public function getDefaultPriority():Number{
return (0);
}
}
}//package org.flintparticles.common.initializers
Section 84
//Lifetime (org.flintparticles.common.initializers.Lifetime)
package org.flintparticles.common.initializers {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
public class Lifetime extends InitializerBase {
private var _max:Number;
private var _min:Number;
public function Lifetime(minLifetime:Number, maxLifetime:Number=NaN){
super();
_max = maxLifetime;
_min = minLifetime;
}
public function get lifetime():Number{
return (((_min == _max)) ? _min : ((_max + _min) * 0.5));
}
public function get maxLifetime():Number{
return (_max);
}
override public function initialize(emitter:Emitter, particle:Particle):void{
if (isNaN(_max)){
particle.lifetime = _min;
} else {
particle.lifetime = (_min + (Math.random() * (_max - _min)));
};
}
public function set lifetime(value:Number):void{
_max = (_min = value);
}
public function set minLifetime(value:Number):void{
_min = value;
}
public function set maxLifetime(value:Number):void{
_max = value;
}
public function get minLifetime():Number{
return (_min);
}
}
}//package org.flintparticles.common.initializers
Section 85
//SharedImage (org.flintparticles.common.initializers.SharedImage)
package org.flintparticles.common.initializers {
import flash.display.*;
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
public class SharedImage extends InitializerBase {
private var _image:DisplayObject;
public function SharedImage(image:DisplayObject){
super();
_image = image;
}
override public function initialize(emitter:Emitter, particle:Particle):void{
particle.image = _image;
}
public function set image(value:DisplayObject):void{
_image = value;
}
public function get image():DisplayObject{
return (_image);
}
}
}//package org.flintparticles.common.initializers
Section 86
//Particle (org.flintparticles.common.particles.Particle)
package org.flintparticles.common.particles {
import flash.geom.*;
import flash.utils.*;
public class Particle {
public var energy:Number;// = 1
public var lifetime:Number;// = 0
public var scale:Number;// = 1
public var image;// = null
public var color:uint;// = 4294967295
public var collisionRadius:Number;// = 1
private var _colorTransform:ColorTransform;// = null
private var _previousColor:uint;
public var isDead:Boolean;// = false
public var mass:Number;// = 1
private var _dictionary:Dictionary;// = null
public var age:Number;// = 0
public function Particle(){
super();
}
public function get dictionary():Dictionary{
if (_dictionary == null){
_dictionary = new Dictionary();
};
return (_dictionary);
}
public function get colorTransform():ColorTransform{
if (((!(_colorTransform)) || (!((_previousColor == color))))){
_colorTransform = new ColorTransform((((color >>> 16) & 0xFF) / 0xFF), (((color >>> 8) & 0xFF) / 0xFF), ((color & 0xFF) / 0xFF), (((color >>> 24) & 0xFF) / 0xFF), 0, 0, 0, 0);
_previousColor = color;
};
return (_colorTransform);
}
public function get alpha():Number{
return ((((color & 4278190080) >>> 24) / 0xFF));
}
public function initialize():void{
color = 4294967295;
scale = 1;
mass = 1;
collisionRadius = 1;
lifetime = 0;
age = 0;
energy = 1;
isDead = false;
image = null;
_dictionary = null;
_colorTransform = null;
}
}
}//package org.flintparticles.common.particles
Section 87
//ParticleFactory (org.flintparticles.common.particles.ParticleFactory)
package org.flintparticles.common.particles {
public interface ParticleFactory {
function createParticle():Particle;
function disposeParticle(D:\work\Farm2\Flash\melesta_lib\src;org\flintparticles\common\particles;ParticleFactory.as:Particle):void;
}
}//package org.flintparticles.common.particles
Section 88
//Renderer (org.flintparticles.common.renderers.Renderer)
package org.flintparticles.common.renderers {
import org.flintparticles.common.emitters.*;
public interface Renderer {
function removeEmitter(:Emitter):void;
function addEmitter(:Emitter):void;
}
}//package org.flintparticles.common.renderers
Section 89
//SpriteRendererBase (org.flintparticles.common.renderers.SpriteRendererBase)
package org.flintparticles.common.renderers {
import flash.events.*;
import flash.display.*;
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.events.*;
public class SpriteRendererBase extends Sprite implements Renderer {
protected var _emitters:Array;
public function SpriteRendererBase(){
super();
_emitters = new Array();
mouseEnabled = false;
mouseChildren = false;
addEventListener(Event.ADDED_TO_STAGE, addedToStage, false, 0, true);
}
private function particleAdded(ev:ParticleEvent):void{
addParticle(ev.particle);
if (stage){
stage.invalidate();
};
}
private function addedToStage(ev:Event):void{
if (stage){
stage.invalidate();
};
}
public function get emitters():Array{
return (_emitters);
}
protected function addParticle(particle:Particle):void{
}
private function updateParticles(ev:Event):void{
var particles:Array = new Array();
var i:int;
while (i < _emitters.length) {
particles = particles.concat(_emitters[i].particles);
i++;
};
renderParticles(particles);
}
private function emitterUpdated(ev:EmitterEvent):void{
if (stage){
stage.invalidate();
};
}
public function removeEmitter(emitter:Emitter):void{
var p:Particle;
var i:int;
while (i < _emitters.length) {
if (_emitters[i] == emitter){
_emitters.splice(i, 1);
emitter.removeEventListener(EmitterEvent.EMITTER_UPDATED, emitterUpdated);
emitter.removeEventListener(ParticleEvent.PARTICLE_CREATED, particleAdded);
emitter.removeEventListener(ParticleEvent.PARTICLE_ADDED, particleAdded);
emitter.removeEventListener(ParticleEvent.PARTICLE_DEAD, particleRemoved);
for each (p in emitter.particles) {
removeParticle(p);
};
if (_emitters.length == 0){
removeEventListener(Event.RENDER, updateParticles);
renderParticles([]);
} else {
stage.invalidate();
};
return;
};
i++;
};
}
protected function renderParticles(particles:Array):void{
}
protected function removeParticle(particle:Particle):void{
}
private function particleRemoved(ev:ParticleEvent):void{
removeParticle(ev.particle);
if (stage){
stage.invalidate();
};
}
public function addEmitter(emitter:Emitter):void{
var p:Particle;
_emitters.push(emitter);
if (stage){
stage.invalidate();
};
emitter.addEventListener(EmitterEvent.EMITTER_UPDATED, emitterUpdated, false, 0, true);
emitter.addEventListener(ParticleEvent.PARTICLE_CREATED, particleAdded, false, 0, true);
emitter.addEventListener(ParticleEvent.PARTICLE_ADDED, particleAdded, false, 0, true);
emitter.addEventListener(ParticleEvent.PARTICLE_DEAD, particleRemoved, false, 0, true);
for each (p in emitter.particles) {
addParticle(p);
};
if (_emitters.length == 1){
addEventListener(Event.RENDER, updateParticles, false, 0, true);
};
}
}
}//package org.flintparticles.common.renderers
Section 90
//FrameUpdater (org.flintparticles.common.utils.FrameUpdater)
package org.flintparticles.common.utils {
import flash.events.*;
import flash.display.*;
import org.flintparticles.common.events.*;
import flash.utils.*;
public class FrameUpdater extends EventDispatcher {
private var _shape:Shape;
private var _time:Number;
private static var _instance:FrameUpdater;
public function FrameUpdater(){
super();
_shape = new Shape();
_shape.addEventListener(Event.ENTER_FRAME, frameUpdate, false, 0, true);
_time = getTimer();
}
private function frameUpdate(ev:Event):void{
var oldTime:int = _time;
_time = getTimer();
var frameTime:Number = ((_time - oldTime) * 0.001);
dispatchEvent(new UpdateEvent(UpdateEvent.UPDATE, frameTime));
}
public static function get instance():FrameUpdater{
if (_instance == null){
_instance = new (FrameUpdater);
};
return (_instance);
}
}
}//package org.flintparticles.common.utils
Section 91
//interpolateColors (org.flintparticles.common.utils.interpolateColors)
package org.flintparticles.common.utils {
public function interpolateColors(color1:uint, color2:uint, ratio:Number):uint{
var inv:Number = (1 - ratio);
var red:uint = Math.round(((((color1 >>> 16) & 0xFF) * ratio) + (((color2 >>> 16) & 0xFF) * inv)));
var green:uint = Math.round(((((color1 >>> 8) & 0xFF) * ratio) + (((color2 >>> 8) & 0xFF) * inv)));
var blue:uint = Math.round((((color1 & 0xFF) * ratio) + ((color2 & 0xFF) * inv)));
var alpha:uint = Math.round(((((color1 >>> 24) & 0xFF) * ratio) + (((color2 >>> 24) & 0xFF) * inv)));
return (((((alpha << 24) | (red << 16)) | (green << 8)) | blue));
}
}//package org.flintparticles.common.utils
Section 92
//Maths (org.flintparticles.common.utils.Maths)
package org.flintparticles.common.utils {
public class Maths {
private static const DEGTORAD:Number = (Math.PI / 180);
private static const RADTODEG:Number = (180 / Math.PI);
public function Maths(){
super();
}
public static function asRadians(degrees:Number):Number{
return ((degrees * DEGTORAD));
}
public static function asDegrees(radians:Number):Number{
return ((radians * RADTODEG));
}
}
}//package org.flintparticles.common.utils
Section 93
//PriorityArray (org.flintparticles.common.utils.PriorityArray)
package org.flintparticles.common.utils {
import flash.utils.*;
public class PriorityArray extends Proxy {
private var _values:Array;
public function PriorityArray(){
super();
_values = new Array();
}
public function remove(value):Boolean{
var i:uint = _values.length;
while (i--) {
if (_values[i].value == value){
_values.splice(i, 1);
return (true);
};
};
return (false);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(index:int):String{
return ((index - 1).toString());
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(name, value):void{
var index:uint = uint(name);
if ((((index == name)) && ((index < _values.length)))){
_values[index].value = value;
};
}
public function add(value, priority:Number):uint{
var len:uint = _values.length;
var i:uint;
while (i < len) {
if (_values[i].priority < priority){
break;
};
i++;
};
_values.splice(i, 0, new Pair(priority, value));
return (_values.length);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(name){
var index:int = int(name);
if ((((((index == name)) && ((index < _values.length)))) && (_values[index]))){
return (_values[index].value);
};
return (undefined);
}
public function clear():void{
_values.length = 0;
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(index:int):int{
if (index < _values.length){
return ((index + 1));
};
return (0);
}
public function get length():uint{
return (_values.length);
}
public function removeAt(index:uint){
var temp:* = _values[index].value;
_values.splice(index, 1);
return (temp);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextValue(index:int){
return (_values[(index - 1)]);
}
public function contains(value):Boolean{
var i:uint = _values.length;
while (i--) {
if (_values[i].value == value){
return (true);
};
};
return (false);
}
}
}//package org.flintparticles.common.utils
class Pair {
private var value;
private var priority:Number;
private function Pair(priority:Number, value){
super();
this.priority = priority;
this.value = value;
}
}
Section 94
//Accelerate (org.flintparticles.twoD.actions.Accelerate)
package org.flintparticles.twoD.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.twoD.particles.*;
import org.flintparticles.common.actions.*;
public class Accelerate extends ActionBase {
private var _x:Number;
private var _y:Number;
public function Accelerate(accelerationX:Number, accelerationY:Number){
super();
_x = accelerationX;
_y = accelerationY;
}
public function set x(value:Number):void{
_x = value;
}
public function get y():Number{
return (_y);
}
public function get x():Number{
return (_x);
}
override public function update(emitter:Emitter, particle:Particle, time:Number):void{
var p:Particle2D = Particle2D(particle);
p.velX = (p.velX + (_x * time));
p.velY = (p.velY + (_y * time));
}
public function set y(value:Number):void{
_y = value;
}
}
}//package org.flintparticles.twoD.actions
Section 95
//Move (org.flintparticles.twoD.actions.Move)
package org.flintparticles.twoD.actions {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.twoD.particles.*;
import org.flintparticles.common.actions.*;
public class Move extends ActionBase {
private var p:Particle2D;
public function Move(){
super();
}
override public function getDefaultPriority():Number{
return (-10);
}
override public function update(emitter:Emitter, particle:Particle, time:Number):void{
p = Particle2D(particle);
p.x = (p.x + (p.velX * time));
p.y = (p.y + (p.velY * time));
}
}
}//package org.flintparticles.twoD.actions
Section 96
//Emitter2D (org.flintparticles.twoD.emitters.Emitter2D)
package org.flintparticles.twoD.emitters {
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.twoD.particles.*;
import org.flintparticles.common.utils.*;
public class Emitter2D extends Emitter {
protected var _y:Number;// = 0
public var spaceSort:Boolean;// = false
public var spaceSortedX:Array;
protected var _x:Number;// = 0
protected var _rotation:Number;// = 0
protected static var _creator:ParticleCreator2D = new ParticleCreator2D();
public function Emitter2D(){
super();
_particleFactory = _creator;
}
public function get y():Number{
return (_y);
}
override protected function initParticle(particle:Particle):void{
var p:Particle2D;
p = Particle2D(particle);
p.x = _x;
p.y = _y;
p.rotation = _rotation;
}
override protected function sortParticles():void{
var len:int;
var i:int;
if (spaceSort){
spaceSortedX = _particles.sortOn("x", (Array.NUMERIC | Array.RETURNINDEXEDARRAY));
len = _particles.length;
i = 0;
while (i < len) {
_particles[spaceSortedX[i]].sortID = i;
i++;
};
};
}
public function set x(value:Number):void{
_x = value;
}
public function set rotRadians(value:Number):void{
_rotation = value;
}
public function get x():Number{
return (_x);
}
public function get rotRadians():Number{
return (_rotation);
}
public function set rotation(value:Number):void{
_rotation = Maths.asRadians(value);
}
public function get rotation():Number{
return (Maths.asDegrees(_rotation));
}
public function set y(value:Number):void{
_y = value;
}
public static function get defaultParticleFactory():ParticleFactory{
return (_creator);
}
}
}//package org.flintparticles.twoD.emitters
Section 97
//Velocity (org.flintparticles.twoD.initializers.Velocity)
package org.flintparticles.twoD.initializers {
import flash.geom.*;
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.twoD.particles.*;
import org.flintparticles.common.initializers.*;
public class Velocity extends InitializerBase {
private var _zone:Zone2D;
public function Velocity(zone:Zone2D){
super();
_zone = zone;
}
override public function initialize(emitter:Emitter, particle:Particle):void{
var p:Particle2D;
var sin:Number;
var cos:Number;
p = Particle2D(particle);
var loc:Point = _zone.getLocation();
if (p.rotation == 0){
p.velX = loc.x;
p.velY = loc.y;
} else {
sin = Math.sin(p.rotation);
cos = Math.cos(p.rotation);
p.velX = ((cos * loc.x) - (sin * loc.y));
p.velY = ((cos * loc.y) + (sin * loc.x));
};
}
public function set zone(value:Zone2D):void{
_zone = value;
}
public function get zone():Zone2D{
return (_zone);
}
}
}//package org.flintparticles.twoD.initializers
Section 98
//Particle2D (org.flintparticles.twoD.particles.Particle2D)
package org.flintparticles.twoD.particles {
import flash.geom.*;
import org.flintparticles.common.particles.*;
public class Particle2D extends Particle {
public var sortID:uint;// = 0
private var _inertia:Number;
public var velY:Number;// = 0
private var _previousRadius:Number;
private var _previousMass:Number;
public var angVelocity:Number;// = 0
public var x:Number;// = 0
public var y:Number;// = 0
public var velX:Number;// = 0
public var rotation:Number;// = 0
public function Particle2D(){
super();
}
override public function initialize():void{
super.initialize();
x = 0;
y = 0;
velX = 0;
velY = 0;
rotation = 0;
angVelocity = 0;
sortID = 0;
}
public function get matrixTransform():Matrix{
var cos:Number = (scale * Math.cos(rotation));
var sin:Number = (scale * Math.sin(rotation));
return (new Matrix(cos, sin, -(sin), cos, x, y));
}
public function get inertia():Number{
if (((!((mass == _previousMass))) || (!((collisionRadius == _previousRadius))))){
_inertia = (((mass * collisionRadius) * collisionRadius) * 0.5);
_previousMass = mass;
_previousRadius = collisionRadius;
};
return (_inertia);
}
}
}//package org.flintparticles.twoD.particles
Section 99
//ParticleCreator2D (org.flintparticles.twoD.particles.ParticleCreator2D)
package org.flintparticles.twoD.particles {
import org.flintparticles.common.particles.*;
public class ParticleCreator2D implements ParticleFactory {
private var _particles:Array;
public function ParticleCreator2D(){
super();
_particles = new Array();
}
public function clearAllParticles():void{
_particles = new Array();
}
public function disposeParticle(particle:Particle):void{
if ((particle is Particle2D)){
particle.initialize();
_particles.push(particle);
};
}
public function createParticle():Particle{
if (_particles.length){
return (_particles.pop());
};
return (new Particle2D());
}
}
}//package org.flintparticles.twoD.particles
Section 100
//BitmapRenderer (org.flintparticles.twoD.renderers.BitmapRenderer)
package org.flintparticles.twoD.renderers {
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
import org.flintparticles.twoD.particles.*;
import org.flintparticles.common.renderers.*;
public class BitmapRenderer extends SpriteRendererBase {
protected var _canvas:Rectangle;
protected var _bitmap:Bitmap;
protected var _smoothing:Boolean;
protected var _bitmapData:BitmapData;
protected var _postFilters:Array;
protected var _preFilters:Array;
protected var _colorMap:Array;
protected static var ZERO_POINT:Point = new Point(0, 0);
public function BitmapRenderer(canvas:Rectangle, smoothing:Boolean=false){
super();
mouseEnabled = false;
mouseChildren = false;
_smoothing = smoothing;
_preFilters = new Array();
_postFilters = new Array();
_canvas = canvas;
createBitmap();
}
public function get canvas():Rectangle{
return (_canvas);
}
public function set canvas(value:Rectangle):void{
_canvas = value;
createBitmap();
}
public function removeFilter(filter:BitmapFilter):void{
var i:int;
while (i < _preFilters.length) {
if (_preFilters[i] == filter){
_preFilters.splice(i, 1);
return;
};
i++;
};
i = 0;
while (i < _postFilters.length) {
if (_postFilters[i] == filter){
_postFilters.splice(i, 1);
return;
};
i++;
};
}
override protected function renderParticles(particles:Array):void{
var i:int;
var len:int;
if (!_bitmap){
return;
};
_bitmapData.lock();
len = _preFilters.length;
i = 0;
while (i < len) {
_bitmapData.applyFilter(_bitmapData, _bitmapData.rect, BitmapRenderer.ZERO_POINT, _preFilters[i]);
i++;
};
if ((((len == 0)) && ((_postFilters.length == 0)))){
_bitmapData.fillRect(_bitmap.bitmapData.rect, 0);
};
len = particles.length;
if (len){
i = len;
while (i--) {
drawParticle(particles[i]);
};
};
len = _postFilters.length;
i = 0;
while (i < len) {
_bitmapData.applyFilter(_bitmapData, _bitmapData.rect, BitmapRenderer.ZERO_POINT, _postFilters[i]);
i++;
};
if (_colorMap){
_bitmapData.paletteMap(_bitmapData, _bitmapData.rect, ZERO_POINT, _colorMap[1], _colorMap[2], _colorMap[3], _colorMap[0]);
};
_bitmapData.unlock();
}
protected function drawParticle(particle:Particle2D):void{
var matrix:Matrix;
matrix = particle.matrixTransform;
matrix.translate(-(_canvas.x), -(_canvas.y));
_bitmapData.draw(particle.image, matrix, particle.colorTransform, DisplayObject(particle.image).blendMode, null, _smoothing);
}
public function setPaletteMap(red:Array=null, green:Array=null, blue:Array=null, alpha:Array=null):void{
_colorMap = new Array(4);
_colorMap[0] = alpha;
_colorMap[1] = red;
_colorMap[2] = green;
_colorMap[3] = blue;
}
public function clearPaletteMap():void{
_colorMap = null;
}
public function addFilter(filter:BitmapFilter, postRender:Boolean=false):void{
if (postRender){
_postFilters.push(filter);
} else {
_preFilters.push(filter);
};
}
protected function createBitmap():void{
if (!_canvas){
return;
};
if (((_bitmap) && (_bitmapData))){
_bitmapData.dispose();
_bitmapData = null;
};
if (_bitmap){
removeChild(_bitmap);
};
_bitmap = new Bitmap(null, "auto", _smoothing);
_bitmapData = new BitmapData(_canvas.width, _canvas.height, true, 0);
_bitmap.bitmapData = _bitmapData;
addChild(_bitmap);
_bitmap.x = _canvas.x;
_bitmap.y = _canvas.y;
}
}
}//package org.flintparticles.twoD.renderers
Section 101
//DiscSectorZone (org.flintparticles.twoD.zones.DiscSectorZone)
package org.flintparticles.twoD.zones {
import flash.geom.*;
public class DiscSectorZone implements Zone2D {
private var _minAngle:Number;
private var _innerRadius:Number;
private var _minAllowed:Number;
private var _outerRadius:Number;
private var _center:Point;
private var _maxAngle:Number;
private var _innerSq:Number;
private var _outerSq:Number;
private static var TWOPI:Number = 6.28318530717959;
public function DiscSectorZone(center:Point, outerRadius:Number, innerRadius:Number, minAngle:Number, maxAngle:Number){
super();
if (outerRadius < innerRadius){
throw (new Error((((("The outerRadius (" + outerRadius) + ") can't be smaller than the innerRadius (") + innerRadius) + ") in your DiscSectorZone. N.B. the outerRadius is the second argument in the constructor and the innerRadius is the third argument.")));
};
_center = center;
_innerRadius = innerRadius;
_outerRadius = outerRadius;
_innerSq = (_innerRadius * _innerRadius);
_outerSq = (_outerRadius * _outerRadius);
_minAngle = minAngle;
_maxAngle = maxAngle;
while (_maxAngle > TWOPI) {
_maxAngle = (_maxAngle - TWOPI);
};
while (_maxAngle < 0) {
_maxAngle = (_maxAngle + TWOPI);
};
_minAllowed = (_maxAngle - TWOPI);
if (minAngle == maxAngle){
_minAngle = _maxAngle;
} else {
_minAngle = clamp(_minAngle);
};
}
public function set minAngle(value:Number):void{
_minAngle = clamp(value);
}
public function get innerRadius():Number{
return (_innerRadius);
}
public function getArea():Number{
return (((Math.PI * _outerSq) - (Math.PI * _innerSq)));
}
public function get maxAngle():Number{
return (_maxAngle);
}
public function set innerRadius(value:Number):void{
_innerRadius = value;
_innerSq = (_innerRadius * _innerRadius);
}
public function set outerRadius(value:Number):void{
_outerRadius = value;
_outerSq = (_outerRadius * _outerRadius);
}
public function set maxAngle(value:Number):void{
_maxAngle = value;
while (_maxAngle > TWOPI) {
_maxAngle = (_maxAngle - TWOPI);
};
while (_maxAngle < 0) {
_maxAngle = (_maxAngle + TWOPI);
};
_minAllowed = (_maxAngle - TWOPI);
}
public function contains(x:Number, y:Number):Boolean{
x = (x - _center.x);
y = (y - _center.y);
var distSq:Number = ((x * x) + (y * y));
if ((((distSq > _outerSq)) || ((distSq < _innerSq)))){
return (false);
};
var angle:Number = Math.atan2(y, x);
angle = clamp(angle);
return ((angle >= _minAngle));
}
public function get minAngle():Number{
return (_minAngle);
}
public function get center():Point{
return (_center);
}
public function getLocation():Point{
var rand:Number = Math.random();
var point:Point = Point.polar((_innerRadius + ((1 - (rand * rand)) * (_outerRadius - _innerRadius))), (_minAngle + (Math.random() * (_maxAngle - _minAngle))));
point.x = (point.x + _center.x);
point.y = (point.y + _center.y);
return (point);
}
public function get outerRadius():Number{
return (_outerRadius);
}
public function set center(value:Point):void{
_center = value;
}
private function clamp(angle:Number):Number{
while (angle > _maxAngle) {
angle = (angle - TWOPI);
};
while (angle < _minAllowed) {
angle = (angle + TWOPI);
};
return (angle);
}
}
}//package org.flintparticles.twoD.zones
Section 102
//Zone2D (org.flintparticles.twoD.zones.Zone2D)
package org.flintparticles.twoD.zones {
import flash.geom.*;
public interface Zone2D {
function getArea():Number;
function getLocation():Point;
function contains(_arg1:Number, _arg2:Number):Boolean;
}
}//package org.flintparticles.twoD.zones
Section 103
//Chicken (pets.Chicken)
package pets {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import com.cheezeworld.math.*;
import game.assets.*;
import flash.utils.*;
import ui.*;
import game.*;
import utils.*;
import flash.media.*;
import production.*;
import com.melesta.utils.math.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class Chicken extends ChickenTemplate implements IPet {
private var _hungrySound:SoundChannel;
private var _state:String;// = "moving"
private var _produceCounter:Number;// = 0
private var pet:MovieClip;
private var gameController:GameController;
private var _stageInstance:DisplayObjectContainer;
private var _hungryTimer:Timer;
private var type:String;// = "chicken"
private var _produceTimer:Timer;
private var _counter:Number;// = 0
private var timer:Timer;
private var prewRight:Boolean;// = false
public var index:Number;// = 0
private var _stateTimer:Timer;
private var _production:String;// = "EGG"
private var _hungryValue:Number;// = 100
private var _deltaHungry:Number;// = 5
private var nearGrass:Grass;
private var t:Number;// = 0
public static var chickenList:Array = new Array();
public static var firstShow:Boolean = true;
public static var count:Number = 0;
public function Chicken(){
super();
gameController = GameController.instance;
gameController.addEventListener(GameController.PAUSE_GAME, pause, false, 0, true);
gameController.addEventListener(GameController.RESUME_GAME, resume, false, 0, true);
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
this.mouseChildren = false;
this.mouseEnabled = false;
_hungrySound = new SoundChannel();
_produceTimer = new Timer(1000);
_produceTimer.addEventListener(TimerEvent.TIMER, produce, false, 0, true);
_hungryTimer = new Timer(1000);
_hungryTimer.addEventListener(TimerEvent.TIMER, hungry, false, 0, true);
_stateTimer = new Timer(1);
_stateTimer.addEventListener(TimerEvent.TIMER, checkHungry, false, 0, true);
_stateTimer.start();
}
private function getGrass():void{
if (_state == "hungry"){
if (nearGrass != null){
if (!nearGrass.hasGrass()){
Tweener.removeTweens(this);
findGrass();
};
};
};
}
public function destroy(event:Event=null):void{
_stageInstance.removeChild(this);
if (event != null){
Chicken.count--;
};
timer.stop();
timer.removeEventListener(TimerEvent.TIMER, move);
_hungrySound.stop();
Tweener.removeTweens(this);
_hungryTimer.stop();
_produceTimer.stop();
_produceTimer.removeEventListener(TimerEvent.TIMER, produce);
_hungryTimer.removeEventListener(TimerEvent.TIMER, hungry);
_stateTimer.removeEventListener(TimerEvent.TIMER, checkHungry);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
gameController.removeEventListener(GameController.RESUME_GAME, resume);
gameController.removeEventListener(GameController.PAUSE_GAME, pause);
}
public function show(posx:Number, posy:Number, delay:Number, stageInstance:DisplayObjectContainer=null):void{
_counter = 7;
this.x = posx;
this.y = -10;
stageInstance.addChild(this);
_stageInstance = stageInstance;
Tweener.addTween(this, {y:posy, time:0.3, delay:delay, transition:"easeInCirc", onComplete:startAnimation});
timer = new Timer(3000);
timer.addEventListener(TimerEvent.TIMER, move);
index = Chicken.count;
Chicken.chickenList.push(this);
Chicken.count++;
LevelStatistics.goals[9] = Chicken.count;
LevelStatistics.updateStatistics();
_hungryTimer.start();
}
public function resume(event:Event=null):void{
Tweener.resumeTweens(this);
if (((!((this._state == "flyOut"))) && (!((this._state == "death"))))){
switch (_state){
case "hungry":
_stateTimer.start();
_hungryTimer.start();
this.body.play();
if (_hungryValue < 20){
_hungrySound = SoundManager.play("chicken_hungry", 1);
};
break;
case "moving":
_stateTimer.start();
_hungryTimer.start();
timer.start();
this.body.play();
break;
};
_produceTimer.start();
};
}
public function startAnimation():void{
_produceTimer.start();
var left:Number = ((this.x)<300) ? -1 : 1;
SoundManager.play("chicken_voice", 1, new SoundTransform(1, left));
timer.start();
move();
if (firstShow){
firstShow = false;
BlockTooltip.instance.show(this.x, this.y, Config.currentLanguage.tooltips.chicken);
};
}
private function hungry(event:TimerEvent=null):void{
event.stopPropagation();
_hungryValue = (_hungryValue - _deltaHungry);
if (_hungryValue <= 40){
if (_state != "hungry"){
_state = "hungry";
findGrass();
if (_hungryValue == 20){
_hungrySound = SoundManager.play("chicken_hungry", 1);
};
};
} else {
_state = "moving";
};
if (_hungryValue <= 0){
_state = "death";
death();
};
this.hungryProgress._mask.width = ((_hungryValue / 100) * 17);
}
public function move(event:TimerEvent=null):void{
if (event != null){
event.stopPropagation();
};
var p1:Point = new Point(this.x, this.y);
var newX:Number = MathUtils.rand(150, 400);
var newY:Number = MathUtils.rand(150, 300);
var p2:Point = new Point(newX, newY);
var dir:Object = Direction.getDirection(p1, p2);
this.body.gotoAndPlay(dir.direction);
if (dir.right){
this.scaleX = -1;
prewRight = true;
} else {
this.scaleX = 1;
prewRight = false;
};
Tweener.removeTweens(this);
if (_hungryValue <= 30){
t = (Math.sqrt((((x - p2.x) * (x - p2.x)) + ((y - p2.y) * (y - p2.y)))) / 30);
} else {
t = (Math.sqrt((((x - p2.x) * (x - p2.x)) + ((y - p2.y) * (y - p2.y)))) / 10);
};
Tweener.addTween(this, {y:p2.y, x:p2.x, time:t, transition:"linear", onComplete:move});
}
private function nextPoint():Point{
var newX:Number = MathUtils.rand(150, 400);
var newY:Number = MathUtils.rand(150, 300);
var p2:Point = new Point(newX, newY);
while (Math.sqrt((((x - newX) * (x - newX)) + ((y - newY) * (y - newY)))) < 100) {
newX = MathUtils.rand(150, 400);
newY = MathUtils.rand(150, 300);
p2.x = newX;
p2.y = newY;
};
return (p2);
}
public function kill():void{
if (((!((this._state == "flyOut"))) && (!((this._state == "death"))))){
this._state = "flyOut";
Tweener.removeTweens(this);
SoundManager.play("chicken_flyout", 1);
_hungrySound.stop();
Chicken.count--;
this.body.stop();
timer.stop();
_hungryTimer.stop();
_stateTimer.stop();
Chicken.chickenList.splice(index, 1);
Chicken.refreshIndexes();
LevelStatistics.goals[9] = Chicken.count;
LevelStatistics.updateStatistics();
_produceTimer.stop();
Tweener.addTween(this, {y:0, rotation:360, time:3, transition:"easeOutBack", onComplete:destroy});
Tweener.addTween(this, {x:(x + 200), transition:"linear", time:1});
_produceTimer.removeEventListener(TimerEvent.TIMER, produce);
_hungryTimer.removeEventListener(TimerEvent.TIMER, hungry);
_stateTimer.removeEventListener(TimerEvent.TIMER, checkHungry);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
};
}
private function eat():Boolean{
var pay:Number;
_hungryTimer.stop();
if (((!((nearGrass == null))) && ((Grass.grassList.length > 0)))){
pay = nearGrass.getGrass();
if (pay > 0){
this._hungryValue = (this._hungryValue + 10);
this.hungryProgress._mask.width = ((_hungryValue / 100) * 17);
Tweener.removeTweens(this);
Tweener.addTween(this, {alpha:1, delay:0.5, time:0, onUpdate:getGrass, onComplete:eat});
return (true);
};
_hungryTimer.start();
Tweener.removeTweens(this);
if (!pay){
if (nearGrass != null){
nearGrass.destroy();
};
};
findGrass();
return (false);
//unresolved jump
};
_hungryTimer.start();
Tweener.removeTweens(this);
findGrass();
return (false);
}
private function produce(event:TimerEvent=null):void{
event.stopPropagation();
_produceCounter++;
if (_produceCounter == 19){
PetsContainer.instance.addProduct(_production, this.x, this.y);
_produceCounter = 0;
};
}
private function checkHungry(event:TimerEvent=null):void{
if (event){
event.stopPropagation();
};
if (_state == "hungry"){
if (this._hungryValue > 80){
_state = "moving";
Tweener.removeTweens(this);
_hungryTimer.start();
timer.start();
_counter = 7;
move();
};
};
}
public function pause(event:Event=null):void{
Tweener.pauseTweens(this);
_stateTimer.stop();
_hungryTimer.stop();
timer.stop();
this.body.stop();
_produceTimer.stop();
_hungrySound.stop();
}
private function death():void{
Tweener.removeTweens(this);
_hungrySound.stop();
_hungryTimer.stop();
timer.stop();
_produceTimer.stop();
this.body.gotoAndPlay("death");
Tweener.addTween(this, {alpha:0, time:1, delay:0.7, transition:"linear", onComplete:destroy});
SoundManager.play("chicken_die", 1);
Chicken.count--;
Chicken.chickenList.splice(index, 1);
Chicken.refreshIndexes();
LevelStatistics.goals[9] = Chicken.count;
LevelStatistics.updateStatistics();
}
private function findGrass():void{
var nX:Number;
var nY:Number;
var pg:Point;
var dir0:Object;
var pp:Point = new Point(this.x, this.y);
timer.stop();
if (Grass.grassList.length > 0){
nearGrass = Grass.getNear(this.x, this.y);
nX = (Math.ceil(nearGrass.x) + Math.ceil((Math.random() * 10)));
nY = (Math.ceil(nearGrass.y) + Math.ceil((Math.random() * 10)));
pg = new Point(nX, nY);
dir0 = Direction.getDirection(pp, pg);
this.body.gotoAndPlay(dir0.direction);
if (dir0.right){
this.scaleX = -1;
prewRight = true;
} else {
this.scaleX = 1;
prewRight = false;
};
Tweener.removeTweens(this);
t = (Math.sqrt((((x - nX) * (x - nX)) + ((y - nY) * (y - nY)))) / 100);
Tweener.addTween(this, {y:nY, x:nX, time:t, transition:"linear", onUpdate:getGrass, onComplete:function ():void{
if (eat()){
this.body.gotoAndPlay("eat");
};
}});
} else {
_counter = 7;
_state = "moving";
timer.start();
move();
};
}
public static function remove(chickens:Number):void{
while (chickens > 0) {
Chicken.chickenList[(Chicken.count - 1)].destroy();
Chicken.chickenList.pop();
chickens--;
Chicken.count--;
};
Chicken.refreshIndexes();
LevelStatistics.goals[9] = Chicken.count;
LevelStatistics.updateStatistics();
}
public static function refreshIndexes():void{
var i:int;
while (i < Chicken.chickenList.length) {
Chicken.chickenList[i].index = i;
i++;
};
}
}
}//package pets
Section 104
//ChickenTemplate (pets.ChickenTemplate)
package pets {
import flash.display.*;
public dynamic class ChickenTemplate extends MovieClip {
public var hungryProgress:MovieClip;
public var body:MovieClip;
}
}//package pets
Section 105
//IPet (pets.IPet)
package pets {
import flash.events.*;
import flash.display.*;
public interface IPet {
function move(:TimerEvent=null):void;
function startAnimation():void;
function show(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:DisplayObjectContainer=null):void;
}
}//package pets
Section 106
//PetsContainer (pets.PetsContainer)
package pets {
import flash.events.*;
import flash.display.*;
import com.cheezeworld.math.*;
import game.assets.*;
import flash.utils.*;
import houses.*;
import ui.*;
import production.*;
import bears.*;
public class PetsContainer extends MovieClip {
private var container:Sprite;
private var timerSort:Timer;
private var _sortedItems:Array;
private var _stageInstance:DisplayObjectContainer;
private var _field:Field;
public static var instance:PetsContainer;
public function PetsContainer(stageInstance:DisplayObjectContainer):void{
super();
_stageInstance = stageInstance;
container = new Sprite();
_field = new Field();
_field.x = 167;
_field.y = 155;
_field.alpha = 0;
stageInstance.addChild(_field);
stageInstance.addChild(container);
_stageInstance = DisplayObjectContainer(container);
MovingProduction.container = _stageInstance;
PetsContainer.instance = this;
timerSort = new Timer(10);
timerSort.addEventListener(TimerEvent.TIMER, arrange);
timerSort.start();
_field.addEventListener(MouseEvent.CLICK, addGrass, false, 0, true);
container.mouseEnabled = false;
}
private function arrange(event:TimerEvent=null):void{
if (event != null){
event.stopPropagation();
};
_sortedItems = new Array();
var j:int;
while (j < _stageInstance.numChildren) {
_sortedItems[j] = _stageInstance.getChildAt(j);
j++;
};
_sortedItems.sortOn("y", Array.NUMERIC);
var i:int = _stageInstance.numChildren;
while (i--) {
if (_stageInstance.getChildAt(i) != _sortedItems[i]){
_stageInstance.setChildIndex(_sortedItems[i], i);
};
};
}
public function addProduct(production:String, posx:Number, posy:Number):void{
var product:Production = new Production(production, posx, (posy - (Math.random() * 30)), _stageInstance);
}
public function addGrass(event:MouseEvent=null):void{
var grass:Grass;
if (WaterTooltip.firstShow){
WaterTooltip.instance.hide();
};
if (Well.instance.getWater()){
grass = new Grass(Math.ceil(_stageInstance.mouseX), Math.ceil(_stageInstance.mouseY), _stageInstance);
};
}
public function addFlyProduct(production:String, count:Number):void{
var product:Production;
var i:int;
while (i < count) {
product = new Production(production, MathUtils.rand(150, 400), MathUtils.rand(150, 300), _stageInstance, true);
i++;
};
}
public function addPet(type:String, delay:Number=0):void{
var _local5:Panda;
var _local6:BrownBear;
var _local7:Chicken;
var _local8:Pig;
var newX:Number = MathUtils.rand(150, 400);
var newY:Number = MathUtils.rand(150, 300);
switch (type){
case "PANDA":
_local5 = new Panda();
_local5.show(newX, newY, 1, _stageInstance);
break;
case "BROWN":
_local6 = new BrownBear();
_local6.show(newX, newY, 1, _stageInstance);
break;
case "CHICKEN":
_local7 = new Chicken();
_local7.show(newX, newY, delay, _stageInstance);
break;
case "PIG":
_local8 = new Pig();
_local8.show(newX, newY, delay, _stageInstance);
break;
};
}
}
}//package pets
Section 107
//Pig (pets.Pig)
package pets {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import com.cheezeworld.math.*;
import game.assets.*;
import flash.utils.*;
import ui.*;
import game.*;
import utils.*;
import flash.media.*;
import production.*;
import com.melesta.utils.math.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class Pig extends PigTemplate implements IPet {
private var _hungrySound:SoundChannel;
private var _state:String;// = "moving"
private var _produceCounter:Number;// = 0
private var pet:MovieClip;
private var gameController:GameController;
private var _stageInstance:DisplayObjectContainer;
private var _hungryTimer:Timer;
private var type:String;// = "pig"
private var _produceTimer:Timer;
private var _counter:Number;// = 0
private var timer:Timer;
private var prewRight:Boolean;// = false
public var index:Number;// = 0
private var _stateTimer:Timer;
private var _production:String;// = "MEAT"
private var _hungryValue:Number;// = 200
private var _deltaHungry:Number;// = 10
private var nearGrass:Grass;
private var t:Number;// = 0
public static var pigList:Array = new Array();
public static var firstShow:Boolean = true;
public static var count:Number = 0;
public function Pig(){
super();
gameController = GameController.instance;
gameController.addEventListener(GameController.PAUSE_GAME, pause, false, 0, true);
gameController.addEventListener(GameController.RESUME_GAME, resume, false, 0, true);
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
this.mouseChildren = false;
this.mouseEnabled = false;
_hungrySound = new SoundChannel();
_produceTimer = new Timer(1000);
_produceTimer.addEventListener(TimerEvent.TIMER, produce, false, 0, true);
_hungryTimer = new Timer(1000);
_hungryTimer.addEventListener(TimerEvent.TIMER, hungry, false, 0, true);
_stateTimer = new Timer(1);
_stateTimer.addEventListener(TimerEvent.TIMER, checkHungry, false, 0, true);
_stateTimer.start();
}
private function getGrass():void{
if (_state == "hungry"){
if (nearGrass != null){
if (!nearGrass.hasGrass()){
Tweener.removeTweens(this);
findGrass();
};
};
};
}
public function destroy(event:Event=null):void{
_stageInstance.removeChild(this);
timer.stop();
timer.removeEventListener(TimerEvent.TIMER, move);
_hungrySound.stop();
Tweener.removeTweens(this);
if (event != null){
Pig.count--;
};
_hungryTimer.stop();
_produceTimer.stop();
_produceTimer.removeEventListener(TimerEvent.TIMER, produce);
_hungryTimer.removeEventListener(TimerEvent.TIMER, hungry);
_stateTimer.removeEventListener(TimerEvent.TIMER, checkHungry);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
gameController.removeEventListener(GameController.RESUME_GAME, resume);
gameController.removeEventListener(GameController.PAUSE_GAME, pause);
}
public function show(posx:Number, posy:Number, delay:Number, stageInstance:DisplayObjectContainer=null):void{
_counter = 7;
this.x = posx;
this.y = -10;
stageInstance.addChild(this);
_stageInstance = stageInstance;
Tweener.addTween(this, {y:posy, time:0.3, delay:delay, transition:"easeInCirc", onComplete:startAnimation});
timer = new Timer(3000);
timer.addEventListener(TimerEvent.TIMER, move);
index = Pig.count;
Pig.pigList.push(this);
Pig.count++;
LevelStatistics.goals[10] = Pig.count;
LevelStatistics.updateStatistics();
_hungryTimer.start();
}
public function resume(event:Event=null):void{
Tweener.resumeTweens(this);
if (((!((this._state == "flyOut"))) && (!((this._state == "death"))))){
switch (_state){
case "hungry":
_stateTimer.start();
_hungryTimer.start();
this.body.play();
if (_hungryValue < 60){
_hungrySound = SoundManager.play("pig_hungry", 1);
};
break;
case "moving":
_stateTimer.start();
_hungryTimer.start();
timer.start();
this.body.play();
break;
};
_produceTimer.start();
};
}
public function startAnimation():void{
_produceTimer.start();
var left:Number = ((this.x)<300) ? -1 : 1;
SoundManager.play("pig_voice", 1, new SoundTransform(1, left));
timer.start();
move();
if (firstShow){
firstShow = false;
BlockTooltip.instance.show(this.x, this.y, Config.currentLanguage.tooltips.pig);
};
}
private function hungry(event:TimerEvent=null):void{
event.stopPropagation();
_hungryValue = (_hungryValue - _deltaHungry);
if (_hungryValue < 80){
if (_state != "hungry"){
_state = "hungry";
findGrass();
if (_hungryValue == 40){
_hungrySound = SoundManager.play("pig_hungry", 1);
};
};
} else {
_state = "moving";
};
if (_hungryValue <= 0){
_state = "death";
death();
};
this.hungryProgress._mask.width = ((_hungryValue / 200) * 28);
}
public function move(event:TimerEvent=null):void{
if (event != null){
event.stopPropagation();
};
var p1:Point = new Point(this.x, this.y);
var newX:Number = MathUtils.rand(150, 400);
var newY:Number = MathUtils.rand(150, 300);
var p2:Point = new Point(newX, newY);
var dir:Object = Direction.getDirection(p1, p2);
this.body.gotoAndPlay(dir.direction);
if (dir.right){
this.scaleX = -1;
prewRight = true;
} else {
this.scaleX = 1;
prewRight = false;
};
Tweener.removeTweens(this);
if (_hungryValue <= 80){
t = (Math.sqrt((((x - newX) * (x - newX)) + ((y - newY) * (y - newY)))) / 30);
} else {
t = (Math.sqrt((((x - newX) * (x - newX)) + ((y - newY) * (y - newY)))) / 10);
};
Tweener.addTween(this, {y:newY, x:newX, time:t, transition:"linear", onComplete:move});
}
public function kill():void{
if (((!((this._state == "flyOut"))) && (!((this._state == "death"))))){
this._state = "flyOut";
Tweener.removeTweens(this);
SoundManager.play("pig_flyout", 1);
_hungrySound.stop();
Pig.count--;
this.body.stop();
timer.stop();
_hungryTimer.stop();
_stateTimer.stop();
Pig.pigList.splice(index, 1);
Pig.refreshIndexes();
LevelStatistics.goals[10] = Pig.count;
LevelStatistics.updateStatistics();
_produceTimer.stop();
Tweener.addTween(this, {y:0, rotation:360, time:3, transition:"easeOutBack", onComplete:destroy});
Tweener.addTween(this, {x:(x + 200), transition:"linear", time:1});
_produceTimer.removeEventListener(TimerEvent.TIMER, produce);
_hungryTimer.removeEventListener(TimerEvent.TIMER, hungry);
_stateTimer.removeEventListener(TimerEvent.TIMER, checkHungry);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
};
}
private function eat():Boolean{
var pay:Number;
_hungryTimer.stop();
if (((!((nearGrass == null))) && ((Grass.grassList.length > 0)))){
pay = nearGrass.getGrass();
if (pay > 0){
this._hungryValue = (this._hungryValue + 20);
this.hungryProgress._mask.width = ((_hungryValue / 200) * 28);
Tweener.removeTweens(this);
Tweener.addTween(this, {alpha:1, delay:0.3, time:0, onUpdate:getGrass, onComplete:eat});
return (true);
};
_hungryTimer.start();
Tweener.removeTweens(this);
if (!pay){
if (nearGrass != null){
nearGrass.destroy();
};
};
findGrass();
return (false);
//unresolved jump
};
_hungryTimer.start();
Tweener.removeTweens(this);
findGrass();
return (false);
}
private function produce(event:TimerEvent=null):void{
event.stopPropagation();
_produceCounter++;
if (_produceCounter == 19){
PetsContainer.instance.addProduct(_production, this.x, this.y);
_produceCounter = 0;
};
}
private function checkHungry(event:TimerEvent=null):void{
if (event){
event.stopPropagation();
};
if (_state == "hungry"){
if (this._hungryValue >= 180){
_state = "moving";
Tweener.removeTweens(this);
_hungryTimer.start();
timer.start();
_counter = 7;
move();
};
};
}
public function pause(event:Event=null):void{
Tweener.pauseTweens(this);
_stateTimer.stop();
_hungryTimer.stop();
timer.stop();
this.body.stop();
_produceTimer.stop();
_hungrySound.stop();
}
private function death():void{
Tweener.removeTweens(this);
_hungrySound.stop();
_hungryTimer.stop();
timer.stop();
_produceTimer.stop();
this.body.gotoAndPlay("death");
Tweener.addTween(this, {alpha:0, time:1, delay:0.7, transition:"linear", onComplete:destroy});
SoundManager.play("pig_die", 1);
Pig.count--;
Pig.pigList.splice(index, 1);
Pig.refreshIndexes();
LevelStatistics.goals[10] = Pig.count;
LevelStatistics.updateStatistics();
}
private function findGrass():void{
var nX:Number;
var nY:Number;
var pg:Point;
var dir0:Object;
var pp:Point = new Point(this.x, this.y);
timer.stop();
if (Grass.grassList.length > 0){
nearGrass = Grass.getNear(this.x, this.y);
nX = (Math.ceil(nearGrass.x) + Math.ceil((Math.random() * 10)));
nY = (Math.ceil(nearGrass.y) + Math.ceil((Math.random() * 10)));
pg = new Point(nX, nY);
dir0 = Direction.getDirection(pp, pg);
this.body.gotoAndPlay(dir0.direction);
if (dir0.right){
this.scaleX = -1;
prewRight = true;
} else {
this.scaleX = 1;
prewRight = false;
};
Tweener.removeTweens(this);
t = (Math.sqrt((((x - nX) * (x - nX)) + ((y - nY) * (y - nY)))) / 100);
Tweener.addTween(this, {y:nY, x:nX, time:t, transition:"linear", onUpdate:getGrass, onComplete:function ():void{
if (eat()){
this.body.gotoAndPlay("eat");
};
}});
} else {
_counter = 7;
_state = "moving";
timer.start();
move();
};
}
public static function remove(pigs:Number):void{
while (pigs > 0) {
Pig.pigList[(Pig.count - 1)].destroy();
Pig.pigList.pop();
pigs--;
Pig.count--;
};
Pig.refreshIndexes();
LevelStatistics.goals[10] = Pig.count;
LevelStatistics.updateStatistics();
}
public static function refreshIndexes():void{
var i:int;
while (i < Pig.pigList.length) {
Pig.pigList[i].index = i;
i++;
};
}
}
}//package pets
Section 108
//PigTemplate (pets.PigTemplate)
package pets {
import flash.display.*;
public dynamic class PigTemplate extends MovieClip {
public var hungryProgress:MovieClip;
public var body:MovieClip;
}
}//package pets
Section 109
//hungryProgress_3 (pig_fla.hungryProgress_3)
package pig_fla {
import flash.display.*;
public dynamic class hungryProgress_3 extends MovieClip {
public var _mask:MovieClip;
}
}//package pig_fla
Section 110
//pigBody_2 (pig_fla.pigBody_2)
package pig_fla {
import flash.display.*;
public dynamic class pigBody_2 extends MovieClip {
public function pigBody_2(){
addFrameScript(15, frame16, 31, frame32, 47, frame48, 63, frame64, 79, frame80, 95, frame96, 111, frame112);
}
function frame64(){
gotoAndPlay("up");
}
function frame80(){
gotoAndPlay("left_up");
}
function frame16(){
gotoAndPlay("down");
}
function frame96(){
gotoAndPlay("left");
}
function frame112(){
stop();
}
function frame48(){
gotoAndPlay("eat");
}
function frame32(){
gotoAndPlay("down_left");
}
}
}//package pig_fla
Section 111
//DepotProduct (production.DepotProduct)
package production {
public class DepotProduct extends DepotProductTemplate {
private var types:Array;
public function DepotProduct():void{
types = new Array("EGG", "DRIED_EGGS", "CAKE", "FLOURY_CAKE", "FLOUR", "MEAT", "STAKE", "PANDA", "BROWN");
super();
this.visible = false;
}
public function hide():void{
this.visible = false;
}
public function show(productType:String):void{
this.body.gotoAndStop(types[productType]);
this.visible = true;
}
}
}//package production
Section 112
//DepotProductTemplate (production.DepotProductTemplate)
package production {
import flash.display.*;
public dynamic class DepotProductTemplate extends MovieClip {
public var body:MovieClip;
}
}//package production
Section 113
//MovingProduction (production.MovingProduction)
package production {
import flash.events.*;
import flash.display.*;
import game.*;
import caurina.transitions.*;
public class MovingProduction extends PruductionTemplate {
private var gameController:GameController;
public static var container:DisplayObjectContainer;
public function MovingProduction(type:String, posx:Number, posy:Number, delay:Number, second:Boolean=false){
var type = type;
var posx = posx;
var posy = posy;
var delay = delay;
var second = second;
super();
this.body.gotoAndStop(type);
gameController = GameController.instance;
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
container.addChild(this);
this.parashute.visible = false;
this.x = 277;
this.y = 361;
this.alpha = 0;
this.body.scaleX = 1.2;
this.body.scaleY = 1.2;
if (!second){
Tweener.addTween(this, {x:posx, delay:delay, time:0.7, transition:"linear", onStart:function ():void{
this.alpha = 1;
}});
Tweener.addTween(this, {y:posy, delay:delay, time:0.7, transition:"easeInOutBack", onComplete:destroy});
} else {
Tweener.addTween(this, {x:posx, delay:delay, time:0.7, transition:"linear", onStart:function ():void{
this.alpha = 1;
}});
Tweener.addTween(this, {y:posy, delay:delay, time:0.7, transition:"easeOutInBack", onComplete:destroy});
};
}
public function destroy(event:Event=null):void{
Tweener.removeTweens(this);
container.removeChild(this);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
}
}
}//package production
Section 114
//Production (production.Production)
package production {
import flash.events.*;
import flash.display.*;
import flash.filters.*;
import flash.utils.*;
import houses.*;
import ui.*;
import game.*;
import utils.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class Production extends PruductionTemplate {
private var size:uint;// = 80
private var _lifeTime:Number;// = 10
private var offset:uint;// = 50
private var _deathTimer:Timer;
private var _type:String;
private var bgColor:uint;// = 0xFFFFFF
private var gameController:GameController;
private var _stageInstance:DisplayObjectContainer;
public static var firstShow:Boolean = true;
public function Production(type:String, posx:Number, posy:Number, stageInstance:DisplayObjectContainer=null, fly:Boolean=false){
var type = type;
var posx = posx;
var posy = posy;
var stageInstance = stageInstance;
var fly = fly;
super();
gameController = GameController.instance;
gameController.addEventListener(GameController.PAUSE_GAME, pause, false, 0, true);
gameController.addEventListener(GameController.RESUME_GAME, resume, false, 0, true);
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
_type = type;
this.parashute.visible = false;
_stageInstance = stageInstance;
this.body.scaleX = 1.2;
this.body.scaleY = 1.2;
this.x = posx;
if (!fly){
this.y = posy;
} else {
this.y = -50;
this.parashute.visible = true;
Tweener.addTween(this, {y:posy, time:4, delay:(Math.random() * 1), transition:"linear", onComplete:function ():void{
this.parashute.visible = false;
}});
};
this.body.gotoAndStop(type);
addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
_stageInstance.addChild(this);
addEventListener(MouseEvent.ROLL_OVER, dropShadow, false, 0, true);
addEventListener(MouseEvent.ROLL_OUT, removeShadow, false, 0, true);
_lifeTime = (10 * 10);
_deathTimer = new Timer(200);
_deathTimer.addEventListener(TimerEvent.TIMER, live, false, 0, true);
_deathTimer.start();
if (firstShow){
firstShow = false;
BlockTooltip.instance.show(this.x, (this.y - 10), Config.currentLanguage.tooltips.collect);
};
}
private function remove():void{
_stageInstance.removeChild(this);
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
}
private function blinking():void{
Tweener.removeTweens(this, alpha);
var blink:Number = 1;
if (this.alpha < 1){
blink = 1;
} else {
blink = 0.3;
};
Tweener.addTween(this, {alpha:blink, time:0.2});
}
public function removeShadow(event:MouseEvent=null):void{
var filter:BitmapFilter = getBitmapFilter(0);
var myFilters:Array = new Array();
myFilters.push(filter);
filters = myFilters;
}
private function onClick(event:MouseEvent=null):void{
event.stopPropagation();
this.parashute.visible = false;
if (Depot.instance.addProduct(_type)){
this._deathTimer.stop();
_deathTimer.removeEventListener(TimerEvent.TIMER, live, false);
SoundManager.play("product_take", 1);
Tweener.addTween(this, {y:378, time:0.3, onComplete:destroy, transition:"easeOutCirc"});
Tweener.addTween(this, {x:265, time:0.3, transition:"linear"});
} else {
SoundManager.play("fool_action", 1);
};
}
private function live(event:TimerEvent):void{
event.stopPropagation();
_lifeTime--;
if (_lifeTime < 30){
blinking();
};
if (!_lifeTime){
_deathTimer.stop();
Tweener.removeTweens(this, alpha);
_deathTimer.removeEventListener(TimerEvent.TIMER, live, false);
remove();
};
}
public function resume(event:Event=null):void{
_deathTimer.start();
Tweener.resumeTweens(this);
}
public function dropShadow(event:MouseEvent=null):void{
var filter:BitmapFilter = getBitmapFilter(4);
var myFilters:Array = new Array();
myFilters.push(filter);
filters = myFilters;
}
public function pause(event:Event=null):void{
_deathTimer.stop();
Tweener.pauseTweens(this);
}
public function destroy(event:Event=null):void{
_stageInstance.removeChild(this);
Tweener.removeTweens(this);
_deathTimer.stop();
_deathTimer.removeEventListener(TimerEvent.TIMER, live, false);
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
}
private function getBitmapFilter(str:Number):BitmapFilter{
var color:Number = 0xFFFFFF;
var angle:Number = 0;
var alpha:Number = 0.8;
var blurX:Number = 10;
var blurY:Number = 10;
var distance:Number = 0;
var strength:Number = str;
var inner:Boolean;
var knockout:Boolean;
var quality:Number = BitmapFilterQuality.HIGH;
return (new DropShadowFilter(distance, angle, color, alpha, blurX, blurY, strength, quality, inner, knockout));
}
}
}//package production
Section 115
//PruductionTemplate (production.PruductionTemplate)
package production {
import flash.display.*;
public dynamic class PruductionTemplate extends MovieClip {
public var parashute:MovieClip;
public var body:MovieClip;
}
}//package production
Section 116
//ViewProduction (production.ViewProduction)
package production {
public class ViewProduction extends PruductionTemplate {
public function ViewProduction(type:String){
super();
this.parashute.visible = false;
this.body.gotoAndStop(type);
}
}
}//package production
Section 117
//productionbody_2 (production_fla.productionbody_2)
package production_fla {
import flash.display.*;
public dynamic class productionbody_2 extends MovieClip {
public function productionbody_2(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package production_fla
Section 118
//ShopItem (shop.ShopItem)
package shop {
import flash.events.*;
import flash.display.*;
import ui.*;
import map.*;
import com.melesta.sound.*;
public class ShopItem extends MovieClip {
private var _currentUpgrade:Number;// = 0
private var _active:Boolean;// = false
private var _costs:Array;
private var _index:Number;// = 0
public var _icon:MovieClip;
public function ShopItem(icon:MovieClip, costs:String, caption:String, index:Number){
_costs = new Array();
super();
_icon = icon;
_costs = costs.split(",");
_index = index;
_icon.buyBtn.price.text = _costs[_currentUpgrade];
_icon.buyBtn.addEventListener(MouseEvent.CLICK, buyUpgrade, false, 0, true);
_icon.buyBtn.addEventListener(MouseEvent.MOUSE_OVER, btnOver, false, 0, true);
_icon.buyBtn.addEventListener(MouseEvent.MOUSE_OUT, btnOut, false, 0, true);
_icon.buyBtn.addEventListener(MouseEvent.MOUSE_DOWN, btnDown, false, 0, true);
_icon.buyBtn.price.mouseEnabled = false;
_icon.tick.visible = false;
update();
}
public function update():void{
if (_costs[_currentUpgrade] > ShopWindow.instance.stars){
_icon.bg.gotoAndStop(1);
_active = false;
_icon.buyBtn.gotoAndStop("disable");
} else {
_icon.bg.gotoAndStop(2);
_active = true;
_icon.buyBtn.gotoAndStop("active");
};
}
private function btnOut(event:MouseEvent=null):void{
event.stopPropagation();
if (_active){
_icon.buyBtn.gotoAndStop("out");
};
}
private function buyUpgrade(event:MouseEvent=null):void{
event.stopPropagation();
if (this._index == MapWindow.needIndex){
FArrow.instance.hide();
};
if ((((ShopWindow.instance.stars >= _costs[_currentUpgrade])) && ((_currentUpgrade <= (_costs.length - 1))))){
SoundManager.play("action_sell_buy");
ShopWindow.instance.stars = (ShopWindow.instance.stars - _costs[_currentUpgrade]);
_currentUpgrade++;
if (_currentUpgrade < _costs.length){
_icon.buyBtn.price.text = _costs[_currentUpgrade];
_icon.gotoAndStop((_currentUpgrade + 1));
ShopWindow.instance.updateViews();
};
var _local2 = ShopWindow.availableUpgrades;
var _local3 = _index;
var _local4 = (_local2[_local3] + 1);
_local2[_local3] = _local4;
};
if (_currentUpgrade == _costs.length){
SoundManager.play("action_sell_buy");
_icon.tick.visible = true;
_icon.buyBtn.visible = false;
_icon.bg.visible = false;
};
ShopWindow.instance.updateViews();
update();
}
private function btnOver(event:MouseEvent=null):void{
event.stopPropagation();
if (_active){
_icon.buyBtn.gotoAndStop("over");
SoundManager.play("ui_button_hover");
};
}
private function btnDown(event:MouseEvent=null):void{
event.stopPropagation();
if (_active){
_icon.buyBtn.gotoAndStop("press");
};
}
}
}//package shop
Section 119
//ShopWindow (shop.ShopWindow)
package shop {
import flash.events.*;
import flash.display.*;
import ui.*;
import map.*;
import utils.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class ShopWindow extends ShopTemplate {
private var _stars:Number;// = 0
private var _itemCaptions:Array;
private var arrow:FArrow;
public var upgradeCosts:Array;
private var _shopItems:Array;
private var _itemsList:Array;
public static var availableUpgrades:Array = new Array(1, 1, 1, 1, 1, 0, 0, 0, 0);
public static var instance:ShopWindow;
public static var firstShow:Boolean = true;
public function ShopWindow(){
_itemsList = new Array("cage", "well", "depot", "car", "plane", "dried", "cake", "fcake", "stake");
_itemCaptions = new Array("cage", "well", "depot", "car", "plane", "dried", "cake", "fcake", "stake");
_shopItems = new Array();
upgradeCosts = new Array("100,500,5000", "200,400,800", "150,300,2000", "100,500,2000", "100,500,2000", "100,120,130,140,150", "120,130,140,150,160", "120,130,140,150,160", "1000,1200,1300,1400,1500");
super();
this.visible = false;
instance = this;
okBtn.addEventListener(MouseEvent.CLICK, finished, false, 0, true);
stars = 0;
var i:int;
while (i < _itemsList.length) {
_shopItems[i] = new ShopItem((this.getChildByName(_itemsList[i]) as MovieClip), upgradeCosts[i], _itemCaptions[i], i);
i++;
};
if (Config.use_cheats){
stars_txt.addEventListener(MouseEvent.CLICK, addMoney, false, 0, true);
};
title.text = Config.currentLanguage.shop;
okBtn.caption.text = Config.currentLanguage.ok;
}
public function get stars():Number{
return (_stars);
}
public function updateViews():void{
var i:int;
while (i < _shopItems.length) {
_shopItems[i].update();
i++;
};
}
private function addMoney(event:MouseEvent=null):void{
_stars = (_stars + 500);
stars_txt.text = String(_stars);
updateViews();
}
public function set stars(value:Number):void{
_stars = value;
this.stars_txt.text = String(stars);
}
public function finished(event:MouseEvent=null):void{
var event = event;
SoundManager.play("ui_button_click");
Tweener.addTween(this, {alpha:0, time:0.2, transition:"linear", onComplete:function ():void{
this.visible = false;
}});
MapWindow.instance.updateViews();
FArrow.instance.hide();
}
public function show():void{
this.visible = true;
this.alpha = 0;
if (MapWindow.needIndex > 0){
FArrow.instance.show(_shopItems[MapWindow.needIndex]._icon.x, _shopItems[MapWindow.needIndex]._icon.y, true);
};
stars_txt.text = String(stars);
updateViews();
Tweener.addTween(this, {alpha:1, time:0.2, transition:"linear"});
if (firstShow){
firstShow = false;
SimpleTooltip.instance.show(Config.currentLanguage.tooltips.shop);
};
}
public static function isAvailable(upgradeList:Array):Boolean{
var accessCounter:Number = 0;
var item:Array = new Array();
var i:Number = 0;
while (i < upgradeList.length) {
item = upgradeList[i].split(",");
if (Number(item[1]) <= Number(availableUpgrades[(Number(item[0]) + 5)])){
accessCounter++;
};
i++;
};
return (((accessCounter == upgradeList.length)) ? true : false);
}
}
}//package shop
Section 120
//bg_3 (shop_fla.bg_3)
package shop_fla {
import flash.display.*;
public dynamic class bg_3 extends MovieClip {
public function bg_3(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package shop_fla
Section 121
//buyButton_4 (shop_fla.buyButton_4)
package shop_fla {
import flash.display.*;
import flash.text.*;
public dynamic class buyButton_4 extends MovieClip {
public var price:TextField;
public function buyButton_4(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package shop_fla
Section 122
//cage_10 (shop_fla.cage_10)
package shop_fla {
import flash.display.*;
public dynamic class cage_10 extends MovieClip {
public var bg:MovieClip;
public var tick:MovieClip;
public var buyBtn:MovieClip;
public function cage_10(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package shop_fla
Section 123
//cake_8 (shop_fla.cake_8)
package shop_fla {
import flash.display.*;
public dynamic class cake_8 extends MovieClip {
public var bg:MovieClip;
public var tick:MovieClip;
public var buyBtn:MovieClip;
public function cake_8(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package shop_fla
Section 124
//carShop_7 (shop_fla.carShop_7)
package shop_fla {
import flash.display.*;
public dynamic class carShop_7 extends MovieClip {
public var bg:MovieClip;
public var tick:MovieClip;
public var buyBtn:MovieClip;
public function carShop_7(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package shop_fla
Section 125
//depot_6 (shop_fla.depot_6)
package shop_fla {
import flash.display.*;
public dynamic class depot_6 extends MovieClip {
public var bg:MovieClip;
public var tick:MovieClip;
public var buyBtn:MovieClip;
public function depot_6(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package shop_fla
Section 126
//driedEggs_11 (shop_fla.driedEggs_11)
package shop_fla {
import flash.display.*;
public dynamic class driedEggs_11 extends MovieClip {
public var bg:MovieClip;
public var tick:MovieClip;
public var buyBtn:MovieClip;
public function driedEggs_11(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package shop_fla
Section 127
//flouryCake_12 (shop_fla.flouryCake_12)
package shop_fla {
import flash.display.*;
public dynamic class flouryCake_12 extends MovieClip {
public var bg:MovieClip;
public var tick:MovieClip;
public var buyBtn:MovieClip;
public function flouryCake_12(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package shop_fla
Section 128
//meat_13 (shop_fla.meat_13)
package shop_fla {
import flash.display.*;
public dynamic class meat_13 extends MovieClip {
public var bg:MovieClip;
public var tick:MovieClip;
public var buyBtn:MovieClip;
public function meat_13(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package shop_fla
Section 129
//middleButton_14 (shop_fla.middleButton_14)
package shop_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public dynamic class middleButton_14 extends MovieClip {
public var caption:TextField;
public function middleButton_14(){
addFrameScript(0, frame1);
}
public function out(_arg1:MouseEvent){
this.gotoAndStop(1);
}
function frame1(){
addEventListener(MouseEvent.MOUSE_OVER, over);
addEventListener(MouseEvent.MOUSE_OUT, out);
addEventListener(MouseEvent.MOUSE_DOWN, down);
stop();
}
public function down(_arg1:MouseEvent){
this.gotoAndStop(3);
}
public function over(_arg1:MouseEvent){
this.gotoAndStop(2);
}
}
}//package shop_fla
Section 130
//plane_9 (shop_fla.plane_9)
package shop_fla {
import flash.display.*;
public dynamic class plane_9 extends MovieClip {
public var bg:MovieClip;
public var tick:MovieClip;
public var buyBtn:MovieClip;
public function plane_9(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package shop_fla
Section 131
//wellShop_2 (shop_fla.wellShop_2)
package shop_fla {
import flash.display.*;
public dynamic class wellShop_2 extends MovieClip {
public var bg:MovieClip;
public var tick:MovieClip;
public var buyBtn:MovieClip;
public function wellShop_2(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package shop_fla
Section 132
//ArrowTemplate (ui.ArrowTemplate)
package ui {
import flash.display.*;
public dynamic class ArrowTemplate extends MovieClip {
}
}//package ui
Section 133
//BlockTooltip (ui.BlockTooltip)
package ui {
import flash.events.*;
import game.*;
import utils.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class BlockTooltip extends BlockTooltipTemplate {
public static var instance:BlockTooltip;
public function BlockTooltip(){
super();
instance = this;
visible = false;
help.okBtn.caption.text = Config.currentLanguage.ok;
help.okBtn.addEventListener(MouseEvent.CLICK, hide, false, 0, true);
help.okBtn.addEventListener(MouseEvent.MOUSE_DOWN, down, false, 0, true);
}
public function hide(event:MouseEvent=null):void{
if (this.visible){
SoundManager.play("ui_button_click");
Tweener.removeTweens(this);
this.visible = false;
GameController.instance.resume();
if (WaterTooltip.firstShow){
WaterTooltip.instance.show();
};
};
}
public function down(event:MouseEvent=null):void{
help.okBtn.gotoAndStop(3);
}
public function show(posX:Number, posY:Number, caption:String, autoHide:Boolean=false):void{
var posX = posX;
var posY = posY;
var caption = caption;
var autoHide = autoHide;
alpha = 0;
lock.x = -(posX);
lock.y = -(posY);
help.okBtn.visible = true;
this.visible = false;
this.body.scaleX = 1;
this.body.scaleY = 1;
visible = true;
lock.visible = true;
this.help.x = 110;
this.help.y = 77;
if (posX > 300){
this.body.scaleX = -1;
this.help.x = -110;
};
if (posY > 200){
this.help.y = -77;
this.body.scaleY = -1;
};
this.x = posX;
this.y = (posY - 20);
this.help.caption.text = caption;
Tweener.addTween(this, {alpha:1, time:0.5});
if (autoHide){
alpha = 1;
help.okBtn.visible = false;
lock.visible = false;
Tweener.removeTweens(this);
Tweener.addTween(this, {alpha:0, time:1, delay:2, onComplete:function ():void{
this.visible = false;
}});
} else {
GameController.instance.pause();
};
}
}
}//package ui
Section 134
//BottomPanel (ui.BottomPanel)
package ui {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.common.counters.*;
import flash.utils.*;
import game.*;
import market.road.*;
import org.flintparticles.twoD.emitters.*;
import utils.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.common.energyEasing.*;
import org.flintparticles.common.displayObjects.*;
import com.melesta.utils.time.*;
import com.melesta.sound.*;
public class BottomPanel extends BottomPanelTemplate {
public var firstShow:Boolean;// = true
public var assotiationList:Array;
public var state:String;// = "normal"
private var _silverTime:Number;
private var levelTimer:Timer;
private var _goldTime:Number;
private var emitter:Emitter2D;
private var gameController:GameController;
private var _time:Number;// = 0
public static var effectContainer:DisplayObjectContainer;
public static var instance:BottomPanel;
public function BottomPanel(){
assotiationList = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
super();
gameController = GameController.instance;
gameController.addEventListener(GameController.PAUSE_GAME, pause, false, 0, true);
gameController.addEventListener(GameController.RESUME_GAME, resume, false, 0, true);
gameController.addEventListener(GameController.LEVEL_COMPLETED, hideItems, false, 0, true);
this.y = 431;
this.x = 0;
instance = this;
levelTimer = new Timer(1000);
levelTimer.addEventListener(TimerEvent.TIMER, updateTime, false, 0, true);
aim_btn.addEventListener(MouseEvent.CLICK, showPurposes, false, 0, true);
hideItems();
emitter = new Emitter2D();
menuBtn.addEventListener(MouseEvent.CLICK, showMenu, false, 0, true);
menuBtn.caption.text = Config.currentLanguage.menu;
}
public function update():void{
var actual:Number;
var requried:Number;
LevelStatistics.goals[11] = Road.currentMoney;
var i:int;
while (i < assotiationList.length) {
if (assotiationList[i] != 0){
assotiationList[i].actual.text = String(LevelStatistics.goals[i]);
actual = Number(assotiationList[i].actual.text);
requried = Number(assotiationList[i].required.text);
if (actual < requried){
assotiationList[i].required.visible = (assotiationList[i].actual.visible = true);
assotiationList[i].tick.visible = false;
};
if ((((actual > 0)) && ((actual == requried)))){
if (!assotiationList[i].tick.visible){
assotiationList[i].required.visible = (assotiationList[i].actual.visible = false);
assotiationList[i].tick.visible = true;
emitter.start();
SoundManager.play("fanfare_aim", 1);
};
};
};
i++;
};
}
public function startTime():void{
levelTimer.start();
}
public function init():void{
var type:Array;
hideItems();
_time = 0;
updateTime();
lenta.visible = true;
lenta.gotoAndStop(1);
_goldTime = Number(LevelBuilder.currentLevelXML.@GoldTime);
_silverTime = Number(LevelBuilder.currentLevelXML.@SilverTime);
lenta.time_txt.text = TimeDecoder.decodeTime(_goldTime);
var purposes:Array = LevelStatistics.purposes;
var i:int;
while (i < purposes.length) {
type = purposes[i].split(",");
this[("item" + i)].actual.text = "0";
this[("item" + i)].visible = true;
this[("item" + i)]._type = type[0];
assotiationList[ProductTypes.typeToNumber(type[0])] = this[("item" + i)];
this[("item" + i)].required.text = type[1];
this[("item" + i)].body.gotoAndStop(type[0]);
i++;
};
}
public function hideItems(event:Event=null):void{
levelTimer.stop();
_time = 0;
state = "normal";
time_txt.text = TimeDecoder.decodeTime(_time);
assotiationList = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var i:int;
while (i < 4) {
this[("item" + i)].visible = false;
this[("item" + i)].actual.visible = true;
this[("item" + i)].required.visible = true;
this[("item" + i)].actual.text = "0";
this[("item" + i)].required.text = "0";
this[("item" + i)].tick.visible = false;
i++;
};
}
public function resume(event:Event=null):void{
levelTimer.start();
}
private function showPurposes(event:MouseEvent=null):void{
gameController.pause();
PurposesWindow.instance.show();
SoundManager.play("ui_button_click");
Tooltip.instance.hide();
BlockTooltip.instance.hide();
Tooltip.instance.hide();
WaterTooltip.instance.hide();
}
public function createEffect():void{
emitter.counter = new Blast(500);
emitter.addInitializer(new SharedImage(new Star(7)));
emitter.addInitializer(new ColorInit(4294967040, 4294927872));
emitter.addInitializer(new Velocity(new DiscSectorZone(new Point(-100, -200), 500, 0, -90, -91)));
emitter.addInitializer(new Lifetime(1));
emitter.addAction(new Age(Quadratic.easeIn));
emitter.addAction(new Move());
emitter.addAction(new Fade());
emitter.addAction(new Accelerate(-200, 1200));
var renderer:BitmapRenderer = new BitmapRenderer(new Rectangle(0, 0, 570, 430));
renderer.addEmitter(emitter);
effectContainer.addChild(renderer);
emitter.x = 530;
emitter.y = 410;
}
private function updateTime(event:TimerEvent=null):void{
_time++;
if (_time > 40){
if (firstShow){
firstShow = false;
Tooltip.instance.show(510, 400, "GOALS", 1, "GOALS");
};
};
time_txt.text = TimeDecoder.decodeTime(_time);
if (_time > _silverTime){
lenta.visible = false;
state = "normal";
};
if (_time < _silverTime){
lenta.visible = true;
lenta.gotoAndStop(2);
state = "silver";
lenta.time_txt.text = TimeDecoder.decodeTime(_silverTime);
};
if (_time < _goldTime){
lenta.visible = true;
state = "gold";
lenta.gotoAndStop(1);
lenta.time_txt.text = TimeDecoder.decodeTime(_goldTime);
};
}
public function showMenu(event:MouseEvent=null):void{
BlockTooltip.instance.hide();
SimpleTooltip.instance.hide();
WaterTooltip.instance.hide();
GameMenu.instance.show();
SoundManager.play("ui_button_click");
}
public function pause(event:Event=null):void{
levelTimer.stop();
}
}
}//package ui
Section 135
//BottomPanelTemplate (ui.BottomPanelTemplate)
package ui {
import flash.display.*;
import flash.text.*;
public dynamic class BottomPanelTemplate extends MovieClip {
public var time_txt:TextField;
public var aim_btn:MovieClip;
public var lenta:MovieClip;
public var item2:MovieClip;
public var item3:MovieClip;
public var menuBtn:MovieClip;
public var item0:MovieClip;
public var item1:MovieClip;
public function BottomPanelTemplate(){
addFrameScript(0, frame1);
}
function frame1(){
lenta.mouseChildren = false;
lenta.mouseEnabled = false;
}
}
}//package ui
Section 136
//EndScreen (ui.EndScreen)
package ui {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import utils.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class EndScreen extends EndScreenTemplate {
public var showed:Boolean;// = false
public static var instance:EndScreen;
public function EndScreen(stageInstance:DisplayObjectContainer){
super();
instance = this;
stageInstance.addChild(this);
this.visible = false;
exitBtn.caption.text = Config.currentLanguage.main_menu;
caption.text = Config.currentLanguage.game_over;
buyBtn.stop();
exitBtn.addEventListener(MouseEvent.CLICK, exit, false, 0, true);
exitBtn.addEventListener(MouseEvent.MOUSE_OVER, btnOver, false, 0, true);
buyBtn.addEventListener(MouseEvent.MOUSE_OVER, btnOver, false, 0, true);
buyBtn.visible = false;
if (Config.downloadable){
buyBtn.addEventListener(MouseEvent.CLICK, buy, false, 0, true);
buyBtn.caption.text = Config.currentLanguage.download_full_version;
buyBtn.visible = true;
};
}
private function btnOver(event:MouseEvent=null):void{
event.stopPropagation();
SoundManager.play("ui_button_hover");
}
private function buy(event:MouseEvent=null):void{
var request:URLRequest = new URLRequest(Config.downloadLink);
navigateToURL(request, Config.target);
}
public function show():void{
showed = true;
this.alpha = 0;
this.visible = true;
Tweener.addTween(this, {alpha:1, time:0.2, transition:"linear"});
}
private function exit(event:MouseEvent=null):void{
var event = event;
SoundManager.play("ui_button_click");
StartScreen.instance.show();
Tweener.addTween(this, {alpha:0, time:0.1, transition:"linear", onComplete:function ():void{
this.visible = false;
}});
}
}
}//package ui
Section 137
//FarmPreloader (ui.FarmPreloader)
package ui {
import caurina.transitions.*;
import flash.display.*;
public class FarmPreloader extends PreloaderTemplate {
public static var instance:FarmPreloader;
public static var externalLogo:Sprite;
public function FarmPreloader(){
super();
instance = this;
logo.stop();
}
public function hide():void{
Tweener.addTween(this, {alpha:0, time:0.5, onComplete:function ():void{
this.visible = false;
}});
}
}
}//package ui
Section 138
//FArrow (ui.FArrow)
package ui {
import flash.display.*;
import caurina.transitions.*;
public class FArrow extends ArrowTemplate {
public static var container:DisplayObjectContainer;
public static var instance:FArrow;
public function FArrow(cont:DisplayObjectContainer){
container = cont;
super();
instance = this;
container.addChild(this);
this.hide();
this.visible = false;
}
public function hide():void{
this.visible = false;
}
public function show(xpos:Number, ypos:Number, endless:Boolean=false):void{
this.visible = true;
this.alpha = 1;
this.x = xpos;
this.y = ypos;
if (!endless){
Tweener.addTween(this, {alpha:0, delay:1, time:1, transition:"linear", onComplete:hide});
};
}
}
}//package ui
Section 139
//GameMenu (ui.GameMenu)
package ui {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import map.*;
import game.*;
import utils.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class GameMenu extends GameMenuTemplate {
public static var instance:GameMenu;
public function GameMenu(stageInstance:DisplayObjectContainer){
super();
instance = this;
stageInstance.addChild(this);
this.visible = false;
resumeBtn.addEventListener(MouseEvent.CLICK, resumeGame, false, 0, true);
resumeBtn.caption.text = Config.currentLanguage.resume;
mapBtn.addEventListener(MouseEvent.CLICK, showMap, false, 0, true);
mapBtn.caption.text = Config.currentLanguage.map;
restartBtn.addEventListener(MouseEvent.CLICK, restart, false, 0, true);
restartBtn.caption.text = Config.currentLanguage.restart;
buyBtn.visible = false;
if (Config.downloadable){
buyBtn.addEventListener(MouseEvent.CLICK, buy, false, 0, true);
buyBtn.caption.text = Config.currentLanguage.download;
buyBtn.visible = true;
};
exitBtn.caption.text = Config.currentLanguage.exit_to_menu;
exitBtn.addEventListener(MouseEvent.CLICK, exit, false, 0, true);
exitBtn.visible = true;
}
private function buy(event:MouseEvent=null):void{
var request:URLRequest = new URLRequest(Config.downloadLink);
navigateToURL(request, Config.target);
}
private function showMap(event:MouseEvent=null):void{
var event = event;
SoundManager.play("ui_button_click");
Tweener.addTween(this, {alpha:0, time:0.5, transition:"linear", onComplete:function ():void{
this.visible = false;
MapWindow.instance.show();
GameController.instance.levelCompleted();
}});
}
private function resumeGame(event:MouseEvent=null):void{
var event = event;
SoundManager.play("ui_button_click");
Tweener.addTween(this, {alpha:0, time:0.1, transition:"linear", onComplete:function ():void{
this.visible = false;
GameController.instance.resume();
}});
}
public function show():void{
GameController.instance.pause();
this.alpha = 0;
this.visible = true;
Tweener.addTween(this, {alpha:1, time:0.2, transition:"linear"});
}
private function exit(event:MouseEvent=null):void{
var event = event;
SoundManager.play("ui_button_click");
Tweener.addTween(this, {alpha:0, time:0.5, transition:"linear", onComplete:function ():void{
this.visible = false;
QuitDialog.instance.show();
}});
}
private function restart(event:MouseEvent=null):void{
var event = event;
SoundManager.play("ui_button_click");
Tweener.addTween(this, {alpha:0, time:0.1, transition:"linear", onComplete:function ():void{
this.visible = false;
GameController.instance.levelCompleted();
LevelBuilder.instance.createLevel(LevelBuilder.currentLevel);
}});
}
}
}//package ui
Section 140
//GameMenuTemplate (ui.GameMenuTemplate)
package ui {
import flash.display.*;
public dynamic class GameMenuTemplate extends MovieClip {
public var exitBtn:MovieClip;
public var mapBtn:MovieClip;
public var restartBtn:MovieClip;
public var resumeBtn:MovieClip;
public var buyBtn:MovieClip;
}
}//package ui
Section 141
//GoalsTemplate (ui.GoalsTemplate)
package ui {
import flash.display.*;
import flash.text.*;
public dynamic class GoalsTemplate extends MovieClip {
public var for_completing:TextField;
public var silverMoney_txt:TextField;
public var silverTime_txt:TextField;
public var collect:TextField;
public var title:TextField;
public var money_txt:TextField;
public var item2:MovieClip;
public var item0:MovieClip;
public var item3:MovieClip;
public var goldTime_txt:TextField;
public var item1:MovieClip;
public var okBtn:MovieClip;
public var goldMoney_txt:TextField;
}
}//package ui
Section 142
//GoalsWindow (ui.GoalsWindow)
package ui {
import flash.events.*;
import flash.display.*;
import game.*;
import utils.*;
import com.melesta.utils.time.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class GoalsWindow extends GoalsTemplate {
public static var instance:GoalsWindow;
public function GoalsWindow(stageInstance:DisplayObjectContainer){
instance = this;
super();
stageInstance.addChild(this);
this.visible = false;
okBtn.addEventListener(MouseEvent.CLICK, hide, false, 0, true);
title.text = Config.currentLanguage.goals;
collect.text = Config.currentLanguage.collect;
for_completing.text = Config.currentLanguage.for_completing;
hideItems();
}
public function hide(event:MouseEvent=null):void{
var event = event;
okBtn.removeEventListener(MouseEvent.CLICK, hide);
GameController.instance.resume();
SoundManager.play("ui_button_click");
LevelBuilder.instance.addHouses();
Tweener.addTween(this, {alpha:0, time:0.5, onComplete:function ():void{
this.visible = false;
}});
}
public function show():void{
var type:Array;
okBtn.addEventListener(MouseEvent.CLICK, hide, false, 0, true);
this.visible = true;
this.alpha = 0;
Tweener.addTween(this, {alpha:1, time:0.5});
hideItems();
var purposes:Array = LevelStatistics.purposes;
var i:int;
while (i < purposes.length) {
type = purposes[i].split(",");
this[("item" + i)].visible = true;
this[("item" + i)].count.text = type[1];
this[("item" + i)].body.gotoAndStop(type[0]);
i++;
};
GameController.instance.pause();
money_txt.text = LevelBuilder.currentLevelXML.@Prize;
goldMoney_txt.text = ("+" + LevelBuilder.currentLevelXML.@GoldPrize);
silverMoney_txt.text = ("+" + LevelBuilder.currentLevelXML.@SilverPrize);
goldTime_txt.text = TimeDecoder.decodeTime(Number(LevelBuilder.currentLevelXML.@GoldTime));
silverTime_txt.text = TimeDecoder.decodeTime(Number(LevelBuilder.currentLevelXML.@SilverTime));
}
public function hideItems():void{
var i:int;
while (i < 4) {
this[("item" + i)].visible = false;
i++;
};
}
}
}//package ui
Section 143
//MapTooltip (ui.MapTooltip)
package ui {
import utils.*;
import caurina.transitions.*;
public class MapTooltip extends TooltipTemplate {
public static var instance:MapTooltip;
public function MapTooltip(){
super();
instance = this;
visible = false;
alpha = 0;
this.mouseChildren = false;
this.mouseEnabled = false;
this.help.arrow.visible = false;
}
public function hide():void{
Tweener.removeTweens(this);
Tweener.addTween(this, {alpha:0, time:0, onComplete:function ():void{
this.visible = false;
this.body.scaleX = 1;
this.body.scaleY = 1;
}});
}
public function show(posX:Number, posY:Number, level:Number):void{
this.visible = false;
this.body.scaleX = 1;
this.body.scaleY = 1;
visible = true;
this.alpha = 0;
this.x = posX;
this.y = posY;
this.help.x = 100;
this.help.y = 75;
if (posX > 300){
this.body.scaleX = -1;
this.help.x = -120;
};
if (posY > 200){
this.help.y = -50;
this.body.scaleY = -1;
};
this.help.caption.text = Config.currentLanguage.levels.level[(level - 1)];
Tweener.removeTweens(this);
Tweener.addTween(this, {alpha:1, time:0.7, delay:1});
}
public function showHelp(posX:Number, posY:Number, caption:String):void{
this.visible = false;
this.body.scaleX = 1;
this.body.scaleY = 1;
visible = true;
this.alpha = 0;
this.x = posX;
this.y = posY;
this.help.x = 100;
this.help.y = 75;
if (posX > 300){
this.body.scaleX = -1;
this.help.x = -120;
};
if (posY > 200){
this.help.y = -50;
this.body.scaleY = -1;
};
this.help.caption.text = caption;
Tweener.removeTweens(this);
Tweener.addTween(this, {alpha:1, time:0.7});
}
}
}//package ui
Section 144
//PetShop (ui.PetShop)
package ui {
import flash.display.*;
public class PetShop extends PetShopTemplate {
public static var pigButton:ShopButton;
public static var instance:PetShop;
public static var chickenButton:ShopButton;
public static var catButton:ShopButton;
public function PetShop(){
super();
instance = this;
chickenButton = new ShopButton((getChildByName("chicken") as MovieClip), "CHICKEN", 100);
pigButton = new ShopButton((getChildByName("pig") as MovieClip), "PIG", 1000);
}
public function update():void{
chickenButton.updateView();
pigButton.updateView();
}
}
}//package ui
Section 145
//PetShopTemplate (ui.PetShopTemplate)
package ui {
import flash.display.*;
public dynamic class PetShopTemplate extends MovieClip {
public var ostrich:MovieClip;
public var dog:MovieClip;
public var pig:MovieClip;
public var cow:MovieClip;
public var chicken:MovieClip;
public var cat:MovieClip;
}
}//package ui
Section 146
//PurposesWindow (ui.PurposesWindow)
package ui {
import flash.events.*;
import flash.display.*;
import game.*;
import utils.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class PurposesWindow extends PurposesWindowTemplate {
public static var instance:PurposesWindow;
public function PurposesWindow(stageInstance:DisplayObjectContainer){
instance = this;
super();
stageInstance.addChild(this);
this.visible = false;
okBtn.addEventListener(MouseEvent.CLICK, hide, false, 0, true);
}
public function hide(event:MouseEvent=null):void{
var event = event;
SoundManager.play("ui_button_click");
Tweener.addTween(this, {alpha:0, time:0.5, onComplete:function ():void{
this.visible = false;
}});
GameController.instance.resume();
}
public function show():void{
var type:Array;
FArrow.instance.hide();
title.text = Config.currentLanguage.goals;
var j:int;
while (j < 4) {
this[("item" + j)].visible = false;
this[("item" + j)].type_txt.text = "";
this[("item" + j)].count_txt.text = "";
j++;
};
this.visible = true;
this.alpha = 0;
Tweener.addTween(this, {alpha:1, time:0.5});
var purposes:Array = LevelStatistics.purposes;
var i:int;
while (i < purposes.length) {
type = purposes[i].split(",");
this[("item" + i)].visible = true;
this[("item" + i)].type_txt.text = ProductTypes.translate(type[0]);
this[("item" + i)].count_txt.text = ((LevelStatistics.goals[ProductTypes.typeToNumber(type[0])] + "/") + type[1]);
this[("item" + i)].body.gotoAndStop(type[0]);
i++;
};
}
}
}//package ui
Section 147
//PurposesWindowTemplate (ui.PurposesWindowTemplate)
package ui {
import flash.display.*;
import flash.text.*;
public dynamic class PurposesWindowTemplate extends MovieClip {
public var title:TextField;
public var item2:MovieClip;
public var item0:MovieClip;
public var item3:MovieClip;
public var item1:MovieClip;
public var okBtn:MovieClip;
}
}//package ui
Section 148
//QuitDialog (ui.QuitDialog)
package ui {
import flash.events.*;
import game.*;
import utils.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class QuitDialog extends QuitDialogTemplate {
public static var instance:QuitDialog;
public function QuitDialog(){
super();
instance = this;
yesBtn.addEventListener(MouseEvent.CLICK, exit, false, 0, true);
noBtn.addEventListener(MouseEvent.CLICK, hide, false, 0, true);
this.alpha = 0;
this.visible = false;
yesBtn.caption.text = Config.currentLanguage.yes;
noBtn.caption.mouseEnabled = false;
yesBtn.caption.mouseEnabled = false;
noBtn.caption.text = Config.currentLanguage.no;
caption.text = Config.currentLanguage.quit_current_game;
yesBtn.addEventListener(MouseEvent.MOUSE_OVER, yesOver, false, 0, true);
noBtn.addEventListener(MouseEvent.MOUSE_OVER, noOver, false, 0, true);
}
private function yesOver(event:MouseEvent=null):void{
event.stopPropagation();
SoundManager.play("ui_button_hover");
}
public function hide(event:MouseEvent=null):void{
var event = event;
SoundManager.play("ui_button_click");
Tweener.addTween(this, {alpha:0, time:0.2, onComplete:function ():void{
this.visible = false;
GameController.instance.resume();
}});
}
private function noOver(event:MouseEvent=null):void{
event.stopPropagation();
SoundManager.play("ui_button_hover");
}
public function show():void{
this.visible = true;
Tweener.addTween(this, {alpha:1, time:0.2});
}
private function exit(event:MouseEvent=null):void{
var event = event;
SoundManager.play("ui_button_click");
Tweener.addTween(this, {alpha:0, time:0.5, transition:"linear", onComplete:function ():void{
this.visible = false;
StartScreen.instance.show();
GameController.instance.levelCompleted();
}});
}
}
}//package ui
Section 149
//QuitMenu (ui.QuitMenu)
package ui {
import flash.events.*;
import utils.*;
import com.melesta.sound.*;
import caurina.transitions.*;
import flash.external.*;
public class QuitMenu extends QuitMenuTemplate {
public static var instance:QuitMenu;
public function QuitMenu(){
super();
instance = this;
yesBtn.addEventListener(MouseEvent.CLICK, exit, false, 0, true);
noBtn.addEventListener(MouseEvent.CLICK, hide, false, 0, true);
this.alpha = 0;
this.visible = false;
yesBtn.caption.text = Config.currentLanguage.yes;
noBtn.caption.text = Config.currentLanguage.no;
caption.text = Config.currentLanguage.quit;
yesBtn.addEventListener(MouseEvent.MOUSE_OVER, yesOver, false, 0, true);
noBtn.addEventListener(MouseEvent.MOUSE_OVER, noOver, false, 0, true);
yesBtn.addEventListener(MouseEvent.MOUSE_OUT, out, false, 0, true);
noBtn.addEventListener(MouseEvent.MOUSE_OUT, out, false, 0, true);
}
public function hide(event:MouseEvent=null):void{
var event = event;
SoundManager.play("ui_button_click");
Tweener.addTween(this, {alpha:0, time:0.2, onComplete:function ():void{
this.visible = false;
}});
}
private function noOver(event:MouseEvent=null):void{
event.stopPropagation();
ostrich.gotoAndStop(2);
SoundManager.play("ui_button_hover");
}
private function exit(event:MouseEvent=null):void{
ExternalInterface.call(Config.closeFunction, "close");
}
private function yesOver(event:MouseEvent=null):void{
event.stopPropagation();
ostrich.gotoAndStop(3);
SoundManager.play("ui_button_hover");
}
public function show():void{
this.visible = true;
Tweener.addTween(this, {alpha:1, time:0.2});
}
private function out(event:MouseEvent=null):void{
event.stopPropagation();
ostrich.gotoAndStop(1);
}
}
}//package ui
Section 150
//ResultsWindow (ui.ResultsWindow)
package ui {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.common.counters.*;
import flash.utils.*;
import shop.*;
import map.*;
import game.*;
import market.road.*;
import org.flintparticles.twoD.emitters.*;
import utils.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.common.energyEasing.*;
import org.flintparticles.common.displayObjects.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class ResultsWindow extends ResultsWindowTemplate {
private var emitter:Emitter2D;
private var currentScore:Number;// = 0
private var deltaScore:Number;// = 0
private var addScoreTimer:Timer;
private var prewScore:Number;// = 0
public static var effectContainer:DisplayObjectContainer;
public static var bankNum:Number = 0;
public static var instance:ResultsWindow;
public function ResultsWindow(stageInstance:DisplayObjectContainer){
super();
instance = this;
stageInstance.addChild(this);
okBtn.addEventListener(MouseEvent.CLICK, hide, false, 0, true);
this.visible = false;
emitter = new Emitter2D();
effectContainer = stageInstance;
addScoreTimer = new Timer(10);
addScoreTimer.addEventListener(TimerEvent.TIMER, incrementScore, false, 0, true);
coins_txt.text = Config.currentLanguage.coins;
bank_txt.text = Config.currentLanguage.bank;
time_txt.text = Config.currentLanguage.time;
bonus_txt.text = Config.currentLanguage.bonus;
createEffect();
}
public function hide(event:MouseEvent=null):void{
var event = event;
Tweener.addTween(this, {alpha:0, time:0.4, transition:"linear", onComplete:function ():void{
this.visible = false;
}});
GameController.instance.levelCompleted();
MapWindow.instance.show();
bonus.text = String(currentScore);
addScoreTimer.stop();
this.cup.visible = false;
}
private function incrementScore(event:TimerEvent):void{
if (prewScore < currentScore){
prewScore = (prewScore + deltaScore);
bonus.text = String(prewScore);
SoundManager.play("tick_time");
} else {
prewScore = currentScore;
emitter.start();
addScoreTimer.stop();
};
}
public function createEffect():void{
emitter.counter = new Blast(500);
emitter.addInitializer(new SharedImage(new Star(7)));
emitter.addInitializer(new ColorInit(4294967040, 4294927872));
emitter.addInitializer(new Velocity(new DiscSectorZone(new Point(-100, -200), 500, 0, -90, -91)));
emitter.addInitializer(new Lifetime(0.5));
emitter.addAction(new Age(Quadratic.easeIn));
emitter.addAction(new Move());
emitter.addAction(new Fade());
emitter.addAction(new Accelerate(0, 3000));
var renderer:BitmapRenderer = new BitmapRenderer(new Rectangle(0, 0, 570, 430));
renderer.addEmitter(emitter);
effectContainer.addChild(renderer);
emitter.x = 400;
emitter.y = 200;
}
public function addScore(value:Number):void{
prewScore = currentScore;
currentScore = value;
deltaScore = Math.round(((currentScore - prewScore) / 10));
}
public function show():void{
var addBonus:Number;
BlockTooltip.instance.hide();
Tooltip.instance.hide();
WaterTooltip.instance.hide();
prewScore = 0;
currentScore = 0;
deltaScore = 0;
GameController.instance.pause();
FArrow.instance.hide();
if ((((LevelBuilder.currentLevel >= LevelBuilder.maxLevel)) && ((LevelBuilder.currentLevel < 16)))){
LevelBuilder.maxLevel = (LevelBuilder.currentLevel + 1);
};
title.text = Config.currentLanguage.level_results;
bankNum = (bankNum + Road.currentMoney);
MapNode.nodeList[(LevelBuilder.currentLevel - 1)].state = BottomPanel.instance.state;
coins.text = LevelBuilder.currentLevelXML.@Prize;
addBonus = 0;
if (BottomPanel.instance.state == "gold"){
addBonus = Number(LevelBuilder.currentLevelXML.@GoldPrize);
cup.gotoAndStop(1);
cup.visible = true;
addScore(addBonus);
};
if (BottomPanel.instance.state == "silver"){
addBonus = Number(LevelBuilder.currentLevelXML.@SilverPrize);
cup.gotoAndStop(2);
cup.visible = true;
addScore(addBonus);
};
if (BottomPanel.instance.state == "normal"){
bonus.text = "0";
cup.visible = false;
};
ShopWindow.instance.stars = (ShopWindow.instance.stars + (Number(bonus.text) + Number(LevelBuilder.currentLevelXML.@Prize)));
bank.text = String(bankNum);
if (Farm2.mail_ru_connection){
Farm2.mail_ru_connection.send(Farm2.connection_name, "cacheResult", bankNum);
//unresolved jump
var _slot1 = e;
};
time.text = BottomPanel.instance.time_txt.text;
this.visible = true;
this.alpha = 0;
SoundManager.play("fanfare_level_complete", 1);
Tweener.addTween(this, {alpha:1, time:0.5, transition:"linear", delay:0.5, onComplete:function ():void{
if (addBonus > 0){
addScoreTimer.start();
};
}});
}
}
}//package ui
Section 151
//ResultsWindowTemplate (ui.ResultsWindowTemplate)
package ui {
import flash.display.*;
import flash.text.*;
public dynamic class ResultsWindowTemplate extends MovieClip {
public var time_txt:TextField;
public var coins:TextField;
public var bonus:TextField;
public var bank:TextField;
public var cup:MovieClip;
public var bonus_txt:TextField;
public var title:TextField;
public var coins_txt:TextField;
public var time:TextField;
public var okBtn:MovieClip;
public var bank_txt:TextField;
}
}//package ui
Section 152
//ShopButton (ui.ShopButton)
package ui {
import flash.events.*;
import flash.display.*;
import market.road.*;
import pets.*;
public class ShopButton extends MovieClip {
public var active:Boolean;// = false
private var _cost:Number;// = 0
private var _icon:MovieClip;
public var type:String;
public static var ADD_PET:String = "add_pet";
public function ShopButton(icon:MovieClip, t:String, cost:Number){
super();
_cost = cost;
type = t;
_icon = icon;
_icon.activeArea.addEventListener(MouseEvent.MOUSE_OVER, over, false, 0, true);
_icon.activeArea.addEventListener(MouseEvent.MOUSE_OUT, out, false, 0, true);
_icon.activeArea.addEventListener(MouseEvent.MOUSE_DOWN, down, false, 0, true);
_icon.activeArea.addEventListener(MouseEvent.CLICK, addPet, false, 0, true);
}
private function down(event:MouseEvent=null):void{
event.stopPropagation();
if (active){
this._icon.gotoAndStop("press");
};
}
private function out(event:MouseEvent=null):void{
event.stopPropagation();
if (active){
this._icon.gotoAndStop("active");
};
Tooltip.instance.hide();
}
public function updateView(event:Event=null):void{
if (this._cost <= Road.currentMoney){
this._icon.gotoAndStop("active");
this.active = true;
} else {
this.active = false;
this._icon.gotoAndStop("lock");
};
}
private function over(event:MouseEvent=null):void{
event.stopPropagation();
if (active){
this._icon.gotoAndStop("over");
Tooltip.instance.show((this._icon.x - 10), (this.y + 70), type, 0, type);
};
}
private function addPet(event:MouseEvent=null):void{
if (active){
event.stopPropagation();
this._icon.gotoAndStop("active");
PetsContainer.instance.addPet(type);
Road.instance.addMoney(-(_cost));
};
}
}
}//package ui
Section 153
//SimpleTooltip (ui.SimpleTooltip)
package ui {
import flash.events.*;
import utils.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class SimpleTooltip extends SimpleTooltipTemplate {
public static var instance:SimpleTooltip;
public function SimpleTooltip(){
super();
instance = this;
visible = false;
okBtn.caption.text = Config.currentLanguage.ok;
okBtn.addEventListener(MouseEvent.CLICK, hide, false, 0, true);
okBtn.addEventListener(MouseEvent.MOUSE_DOWN, down, false, 0, true);
}
public function hide(event:MouseEvent=null):void{
this.visible = false;
SoundManager.play("ui_button_click");
}
public function down(event:MouseEvent=null):void{
okBtn.gotoAndStop(3);
}
public function show(caption:String):void{
this.caption.text = caption;
this.visible = true;
alpha = 0;
Tweener.addTween(this, {alpha:1, time:0.5});
}
}
}//package ui
Section 154
//StartScreen (ui.StartScreen)
package ui {
import flash.events.*;
import game.assets.*;
import flash.net.*;
import map.*;
import game.*;
import utils.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class StartScreen extends StartScreenTemplate {
private var _firstClick:Boolean;// = false
public static var instance:StartScreen;
public function StartScreen(){
super();
instance = this;
okBtn.addEventListener(MouseEvent.CLICK, hide, false, 0, true);
this.alpha = 0;
okBtn.stop();
okBtn.caption.text = Config.currentLanguage.start;
soundBtn.caption.text = Config.currentLanguage.sounds;
musicBtn.caption.text = Config.currentLanguage.music;
if (Config.language == "ru"){
logo.gotoAndStop("ru");
alawar.gotoAndStop("ru");
} else {
logo.gotoAndStop("en");
alawar.gotoAndStop("en");
};
if (FarmPreloader.externalLogo){
logo.visible = false;
FarmPreloader.externalLogo.x = (FarmPreloader.externalLogo.y = 0);
addChild(FarmPreloader.externalLogo);
};
buyBtn.visible = true;
buyBtn.stop();
buyBtn.caption.text = Config.currentLanguage.download_full_version;
buyBtn.visible = false;
if (Config.downloadable){
buyBtn.addEventListener(MouseEvent.CLICK, buy, false, 0, true);
buyBtn.visible = true;
};
buyBtn.caption.mouseEnabled = false;
okBtn.caption.mouseEnabled = false;
exitBtn.caption.mouseEnabled = false;
okBtn.addEventListener(MouseEvent.MOUSE_OVER, btnOver, false, 0, true);
buyBtn.addEventListener(MouseEvent.MOUSE_OVER, btnOver, false, 0, true);
exitBtn.addEventListener(MouseEvent.MOUSE_OVER, btnOver, false, 0, true);
soundBtn.addEventListener(MouseEvent.CLICK, switchSound, false, 0, true);
musicBtn.addEventListener(MouseEvent.CLICK, switchMusic, false, 0, true);
soundBtn.mouseChildren = false;
soundBtn.buttonMode = true;
musicBtn.buttonMode = true;
musicBtn.mouseChildren = false;
exitBtn.visible = false;
if ((((Config.closeFunction.length > 0)) && (!((Farm2.portal == "mail.ru"))))){
exitBtn.visible = true;
exitBtn.addEventListener(MouseEvent.CLICK, exit, false, 0, true);
};
exitBtn.caption.text = Config.currentLanguage.exit;
if (Farm2.portal == "mail.ru"){
soundBtn.y = 259;
musicBtn.y = 295;
exitBtn.visible = true;
exitBtn.addEventListener(MouseEvent.CLICK, exitMailRu, false, 0, true);
};
}
private function btnOver(event:MouseEvent=null):void{
event.stopPropagation();
SoundManager.play("ui_button_hover");
}
public function switchMusic(event:MouseEvent=null):void{
if (!SoundsList.muteMusic){
musicBtn.gotoAndStop("off");
SoundsList.muteMusic = true;
if (SoundsList.menuMusicChannel){
SoundsList.menuMusicChannel.stop();
};
} else {
musicBtn.gotoAndStop("on");
SoundsList.menuMusicChannel = SoundsList.menuMusicSound.play(1);
SoundsList.muteMusic = false;
};
}
public function hide(event:MouseEvent=null):void{
if (!SoundsList.muteMusic){
if (SoundsList.menuMusicSound){
SoundsList.menuMusicChannel.stop();
};
};
if (!SoundsList.muteMusic){
if (SoundsList.gameMusicSound){
SoundsList.gameMusicChannel = SoundsList.gameMusicSound.play(1000);
};
};
SoundManager.play("ui_button_click");
Tweener.addTween(this, {alpha:0, time:0.2, onComplete:startGame});
PlayGround.instance.alpha = 1;
}
private function startGame(event:MouseEvent=null):void{
this.visible = false;
if (LevelBuilder.currentLevel != 1){
MapWindow.instance.show();
} else {
if (_firstClick){
LevelBuilder.instance.createLevel(1);
};
};
_firstClick = true;
}
private function exit(event:MouseEvent=null):void{
QuitMenu.instance.show();
}
private function buy(event:MouseEvent=null):void{
var request:URLRequest = new URLRequest(Config.downloadLink);
navigateToURL(request, Config.target);
}
private function exitMailRu(event:MouseEvent=null):void{
var event = event;
if (Farm2.mail_ru_connection){
Farm2.mail_ru_connection.send(Farm2.connection_name, "closeGame");
//unresolved jump
var _slot1 = e;
};
}
public function switchSound(event:MouseEvent=null):void{
if (!SoundsList.mute){
soundBtn.gotoAndStop("off");
SoundsList.mute = true;
SoundManager.mute();
} else {
soundBtn.gotoAndStop("on");
SoundsList.mute = false;
SoundManager.resume();
};
}
public function show():void{
if (Farm2.mail_ru_connection){
Farm2.mail_ru_connection.send(Farm2.connection_name, "startGame");
//unresolved jump
var _slot1 = e;
};
this.visible = true;
Tweener.addTween(this, {alpha:1, time:1});
if (!SoundsList.muteMusic){
if (SoundsList.menuMusicSound){
SoundsList.menuMusicChannel = SoundsList.menuMusicSound.play(1);
};
if (SoundsList.gameMusicChannel){
SoundsList.gameMusicChannel.stop();
};
};
}
}
}//package ui
Section 155
//Tooltip (ui.Tooltip)
package ui {
import utils.*;
import caurina.transitions.*;
public class Tooltip extends TooltipTemplate {
public static var instance:Tooltip;
public function Tooltip(){
super();
instance = this;
visible = false;
alpha = 0;
this.mouseChildren = false;
this.mouseEnabled = false;
}
public function hide():void{
Tweener.removeTweens(this);
Tweener.addTween(this, {alpha:0, time:0.2, onComplete:function ():void{
this.visible = false;
this.body.scaleX = 1;
this.body.scaleY = 1;
}});
}
public function show(posX:Number, posY:Number, output:String, upgrade:Number, caption:String=""):void{
this.visible = false;
this.body.scaleX = 1;
this.body.scaleY = 1;
visible = true;
this.alpha = 0;
this.x = (posX + 20);
this.help.x = 100;
this.help.y = 75;
if (posX > 300){
this.body.scaleX = -1;
this.help.x = -120;
this.x = (posX - 20);
};
if (posY > 200){
this.help.y = -50;
this.body.scaleY = -1;
};
this.help.gotoAndStop(output);
this.help.inCount.text = (this.help.outCount.text = ("x" + String(upgrade)));
this.help.arrow.visible = true;
this.help.caption.text = caption;
switch (output){
case "CHICKEN":
this.help.outCount.text = (this.help.inCount.text = "");
this.help.arrow.visible = false;
this.help.caption.text = ProductTypes.translate(caption, true);
break;
case "GOALS":
this.help.outCount.text = (this.help.inCount.text = "");
this.help.arrow.visible = false;
this.help.caption.text = Config.currentLanguage.tooltips.goals;
break;
case "PIG":
this.help.outCount.text = (this.help.inCount.text = "");
this.help.arrow.visible = false;
this.help.caption.text = ProductTypes.translate(caption, true);
break;
case "DEPOT":
this.help.gotoAndStop(1);
this.help.outCount.text = (this.help.inCount.text = "");
this.help.arrow.visible = false;
this.help.caption.text = Config.currentLanguage.warehouse.@tooltip;
break;
case "WELL":
this.help.gotoAndStop(1);
this.help.outCount.text = (this.help.inCount.text = "");
this.help.arrow.visible = false;
this.help.caption.text = Config.currentLanguage.well.@tooltip;
break;
case "CAR":
this.help.outCount.text = (this.help.inCount.text = "");
this.help.arrow.visible = true;
this.help.gotoAndStop("DEPOT");
this.help.caption.text = Config.currentLanguage.car;
break;
case "PLANE":
this.help.outCount.text = (this.help.inCount.text = "");
this.help.caption.text = Config.currentLanguage.plane;
break;
default:
break;
};
Tweener.removeTweens(this);
Tweener.addTween(this, {alpha:1, time:0.7, delay:1});
this.y = (posY - 40);
}
}
}//package ui
Section 156
//WaterTooltip (ui.WaterTooltip)
package ui {
import flash.events.*;
import utils.*;
import caurina.transitions.*;
public class WaterTooltip extends WaterTooltipTemplate {
public static var firstShow:Boolean = true;
public static var instance:WaterTooltip;
public function WaterTooltip(){
super();
instance = this;
visible = false;
this.alpha = 0;
this.mouseEnabled = false;
this.mouseChildren = false;
}
public function hide(event:MouseEvent=null):void{
firstShow = false;
this.visible = false;
}
public function show():void{
if (firstShow){
this.visible = true;
Tweener.addTween(this, {alpha:1, time:1, delay:1});
this.caption.text = Config.currentLanguage.tooltips.click_the_ground;
this.x = 280;
this.y = 200;
visible = true;
};
}
}
}//package ui
Section 157
//WorkLine (ui.WorkLine)
package ui {
public class WorkLine extends WorkLineTemplate {
public function WorkLine(){
super();
this.line.height = 0;
}
public function setProgress(value:Number):void{
this.line.height = value;
}
}
}//package ui
Section 158
//Config (utils.Config)
package utils {
public class Config {
public static var use_cheats:Boolean = false;
public static var closeFunction:String = "";
public static var downloadLink:String = "http://www.alawar.com/download/FarmFrenzy2.exe";
public static var currentLevel:Number = 0;
public static var downloadable:Boolean = true;
public static var currentLanguage:XML;
private static var LevelesRecords:XML = <Records LocalTag="Levels">
<!--StarPets
CHICKEN = 0,
PIG=1,
COW=2,
OSTRICH=3,
DOG=4,
CAT=5,-->
<!--Goals
For FLASH DEMO
0 EGG,
1 DRIED_EGGS,
2 CAKE,
3 FLOURY_CAKE,
4 FLOUR,
5 MEAT,
6 STAKE,
7 PANDA,
8 BROWN,
9 CHICKEN,
10 PIG,
11 MONEY
0 GOAL_MONEY,
1 GOAL_EGG,
2 GOAL_DRIED_EGGS,
3 GOAL_CAKE,
4 GOAL_FLOURY_CAKE,
5 GOAL_MEAT,
6 GOAL_STAKE,
7 GOAL_SPICE_BACON,
8 GOAL_PACKED_MEAT,
9 GOAL_MILK,
10 GOAL_SOUR_CREAM,
11 GOAL_BUTTER,
12 GOAL_CHEESE,
13 GOAL_PLUME,
14 GOAL_PLUME_FAN,
15 GOAL_PLUME_HAT,
16 GOAL_CARNIVAL_DRESS,
17 GOAL_CHICKEN,
18 GOAL_PIG,
19 GOAL_COW,
20 GOAL_OSTRICH,
21 GOAL_CAGED_BEAR1
22 GOAL_CAGED_BEAR2
23 GOAL_CAGED_BEAR3
24 GOAL_CAGED_BEAR4
25 GOAL_FLOUR,
26 GOAL_MEAT_PACK,
27 GOAL_CHEESE_FERMENT,
28 GOAL_HAT,
29 GOAL_TEXTILE,-->
<!--Accessibility codes
0 DRIEDEGGS_HOUSE,
1 CAKE_HOUSE,
2 FLOURY_CAKE_HOUSE,
3 MEAT_HOUSE,
4 MEAT_SPICE_HOUSE,
5 MEAT_PACKET_HOUSE,
6 SOUR_CREAM_HOUSE,
7 BUTTER_HOUSE,
8 CHEESE_HOUSE,
9 FAN_HOUSE,
10 PLUMED_HAT_HOUSE,
11 CARNIVAL_DRESS_HOUSE,-->
<!--AccessProduct codes
16 FLOUR
17 MEAT_PACK
18 CHEESE_FERMENT
19 HAT
20 TEXTILE-->
<!--Accessibility codes
0 DRIEDEGGS_HOUSE,
1 CAKE_HOUSE,
2 FLOURY_CAKE_HOUSE,
3 MEAT_HOUSE,
4 MEAT_SPICE_HOUSE,
5 MEAT_PACKET_HOUSE,
6 SOUR_CREAM_HOUSE,
7 BUTTER_HOUSE,
8 CHEESE_HOUSE,
9 FAN_HOUSE,
10 PLUMED_HAT_HOUSE,
11 CARNIVAL_DRESS_HOUSE,-->
<!--House type codes
0 DRIEDEGGS_HOUSE,
1 CAKE_HOUSE,
2 FLOURY_CAKE_HOUSE,
3 MEAT_HOUSE,
4 MEAT_SPICE_HOUSE,
5 MEAT_PACKET_HOUSE,
6 SOUR_CREAM_HOUSE,
7 BUTTER_HOUSE,
8 CHEESE_HOUSE,
9 FAN_HOUSE,
10 PLUMED_HAT_HOUSE,
11 CARNIVAL_DRESS_HOUSE-->
<!--Медведи
BEAR_PANDA = 0,
BEAR_BROWN = 1,
BEAR_GRIZZLY = 2
BEAR_WHITE = 3,-->
<record StartMoney="100" Name="Куриный пер.1" GoldTime="60" SilverTime="120" Prize="25" SilverPrize="50" GoldPrize="100" BearKillingNum="0">
<StartPets>
<Pet Type="0"/>
<Pet Type="0"/>
</StartPets>
<Goals>
<goal Type="0" Val="4" EndlessStars="4" EndlessLevel="0"/>
</Goals>
<Houses/>
</record>
<record StartMoney="90" Name="Куриный пер.2" GoldTime="90" SilverTime="160" Prize="40" SilverPrize="80" GoldPrize="160" BearKillingNum="0">
<StartPets>
<Pet Type="0"/>
<Pet Type="0"/>
</StartPets>
<Goals>
<goal Type="0" Val="6" EndlessStars="6" EndlessLevel="0"/>
<goal Type="9" Val="3" EndlessStars="15" EndlessLevel="0"/>
</Goals>
<Houses/>
<Accessibility/>
<AccessProduct/>
</record>
<record StartMoney="190" Name="Порошковая 1" GoldTime="120" SilverTime="180" Prize="50" SilverPrize="100" GoldPrize="200" BearKillingNum="0">
<StartPets>
<Pet Type="0"/>
<Pet Type="0"/>
</StartPets>
<Goals>
<goal Type="0" Val="6" EndlessStars="6" EndlessLevel="0"/>
<goal Type="9" Val="3" EndlessStars="15" EndlessLevel="0"/>
<goal Type="1" Val="2" EndlessStars="8" EndlessLevel="0"/>
</Goals>
<BearTimes>
<t Type="0" Time="40"/>
</BearTimes>
<Houses>
<h Type="0" PosIndex="0" Upgrade="0"/>
</Houses>
<Accessibility>
<c CritID="0" Value="1"/>
</Accessibility>
<AccessProduct/>
</record>
<record StartMoney="300" Name="Порошковая 2" GoldTime="150" SilverTime="240" Prize="60" SilverPrize="120" GoldPrize="250" BearKillingNum="1">
<StartPets/>
<Goals>
<goal Type="2" Val="2" EndlessStars="16" EndlessLevel="0"/>
<goal Type="9" Val="2" EndlessStars="10" EndlessLevel="0"/>
</Goals>
<BearTimes>
<t Type="0" Time="15"/>
<t Type="0" Time="30"/>
<t Type="0" Time="60"/>
</BearTimes>
<Houses>
<h Type="0" PosIndex="2" Upgrade="0"/>
<h Type="1" PosIndex="5" Upgrade="0"/>
</Houses>
<Accessibility>
<c CritID="1" Value="1"/>
</Accessibility>
<AccessProduct/>
</record>
<record StartMoney="0" Name="Порошковая 3" GoldTime="170" SilverTime="210" Prize="75" SilverPrize="150" GoldPrize="250" BearKillingNum="1">
<StartPets>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
</StartPets>
<Goals>
<goal Type="1" Val="12" EndlessStars="48" EndlessLevel="0"/>
<goal Type="4" Val="1" EndlessStars="1" EndlessLevel="0"/>
</Goals>
<BearTimes>
<t Type="0" Time="15"/>
<t Type="0" Time="60"/>
<t Type="0" Time="60.1"/>
<t Type="0" Time="90"/>
</BearTimes>
<Houses>
<h Type="0" PosIndex="1" Upgrade="0"/>
<h Type="1" PosIndex="4" Upgrade="1"/>
</Houses>
<Accessibility>
<c CritID="0" Value="2"/>
</Accessibility>
<AccessProduct>
<c Product="4"/>
</AccessProduct>
</record>
<record StartMoney="200" Name="Распутье 1" GoldTime="190" SilverTime="250" Prize="75" SilverPrize="150" GoldPrize="250" BearKillingNum="1">
<StartPets/>
<Goals>
<goal Type="0" Val="20" EndlessStars="20" EndlessLevel="0"/>
<goal Type="1" Val="5" EndlessStars="20" EndlessLevel="0"/>
<goal Type="2" Val="10" EndlessStars="80" EndlessLevel="0"/>
</Goals>
<BearTimes>
<t Type="0" Time="20"/>
<t Type="0" Time="40"/>
<t Type="0" Time="60"/>
<t Type="0" Time="80"/>
</BearTimes>
<Houses>
<h Type="0" PosIndex="0" Upgrade="2"/>
<h Type="1" PosIndex="3" Upgrade="1"/>
</Houses>
<Accessibility>
<c CritID="1" Value="2"/>
</Accessibility>
</record>
<record StartMoney="400" Name="Кексовая 1" GoldTime="180" SilverTime="240" Prize="75" SilverPrize="150" GoldPrize="250" BearKillingNum="1">
<StartPets>
<Pet Type="0"/>
</StartPets>
<Goals>
<goal Type="9" Val="6" EndlessStars="30" EndlessLevel="0"/>
<goal Type="1" Val="16" EndlessStars="64" EndlessLevel="0"/>
<goal Type="2" Val="12" EndlessStars="96" EndlessLevel="0"/>
</Goals>
<BearTimes>
<t Type="0" Time="20"/>
<t Type="0" Time="20.1"/>
<t Type="0" Time="60"/>
<t Type="0" Time="60.1"/>
<t Type="0" Time="120.1"/>
<t Type="0" Time="120.1"/>
</BearTimes>
<Houses>
<h Type="0" PosIndex="2" Upgrade="2"/>
<h Type="1" PosIndex="5" Upgrade="1"/>
</Houses>
<Accessibility>
<c CritID="0" Value="3"/>
</Accessibility>
</record>
<record StartMoney="750" Name="Кексовая 2" GoldTime="190" SilverTime="260" Prize="75" SilverPrize="150" GoldPrize="250" BearKillingNum="1">
<StartPets/>
<Goals>
<goal Type="2" Val="16" EndlessStars="128" EndlessLevel="0"/>
<goal Type="10" Val="1" EndlessStars="80" EndlessLevel="1"/>
</Goals>
<BearTimes>
<t Type="0" Time="20"/>
<t Type="0" Time="20.1"/>
<t Type="0" Time="60"/>
<t Type="0" Time="60.1"/>
<t Type="0" Time="120.1"/>
<t Type="0" Time="120.1"/>
<t Type="0" Time="180.1"/>
<t Type="0" Time="180.1"/>
</BearTimes>
<Houses>
<h Type="0" PosIndex="0" Upgrade="2"/>
<h Type="1" PosIndex="1" Upgrade="2"/>
</Houses>
<Accessibility>
<c CritID="1" Value="3"/>
</Accessibility>
</record>
<record StartMoney="900" Name="Кексовая 3" GoldTime="220" SilverTime="420" Prize="75" SilverPrize="150" GoldPrize="250" BearKillingNum="1">
<StartPets/>
<Goals>
<goal Type="0" Val="30" EndlessStars="30" EndlessLevel="0"/>
<goal Type="2" Val="20" EndlessStars="160" EndlessLevel="0"/>
</Goals>
<BearTimes>
<t Type="0" Time="180"/>
</BearTimes>
<Houses>
<h Type="0" PosIndex="0" Upgrade="0"/>
<h Type="1" PosIndex="1" Upgrade="3"/>
</Houses>
<Accessibility>
<c CritID="0" Value="4"/>
</Accessibility>
</record>
<record StartMoney="550" Name="Кексовый пер. 1" GoldTime="200" SilverTime="240" Prize="100" SilverPrize="200" GoldPrize="300" BearKillingNum="1">
<StartPets>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
</StartPets>
<Goals>
<goal Type="1" Val="30" EndlessStars="120" EndlessLevel="0"/>
<goal Type="2" Val="30" EndlessStars="240" EndlessLevel="0"/>
</Goals>
<BearTimes>
<t Type="0" Time="15"/>
<t Type="0" Time="45"/>
<t Type="0" Time="90"/>
<t Type="0" Time="160"/>
<t Type="0" Time="200"/>
<t Type="0" Time="260"/>
</BearTimes>
<Houses>
<h Type="0" PosIndex="0" Upgrade="4"/>
<h Type="1" PosIndex="5" Upgrade="0"/>
</Houses>
<Accessibility>
<c CritID="1" Value="4"/>
</Accessibility>
</record>
<record StartMoney="190 " Name="Кексовый пер. 2" GoldTime="260" SilverTime="360" Prize="100" SilverPrize="200" GoldPrize="300" BearKillingNum="1">
<StartPets>
<Pet Type="0"/>
</StartPets>
<Goals>
<goal Type="9" Val="5" EndlessStars="25" EndlessLevel="0"/>
<goal Type="2" Val="40" EndlessStars="320" EndlessLevel="0"/>
<goal Type="10" Val="2" EndlessStars="150" EndlessLevel="1"/>
</Goals>
<BearTimes>
<t Type="0" Time="15"/>
<t Type="0" Time="15.1"/>
<t Type="0" Time="90"/>
<t Type="0" Time="90.1"/>
<t Type="0" Time="160"/>
<t Type="0" Time="160.1"/>
<t Type="0" Time="220"/>
<t Type="0" Time="220.1"/>
<t Type="0" Time="280"/>
<t Type="0" Time="280.1"/>
</BearTimes>
<Houses>
<h Type="0" PosIndex="1" Upgrade="4"/>
<h Type="1" PosIndex="4" Upgrade="4"/>
</Houses>
<Accessibility>
<c CritID="0" Value="5"/>
</Accessibility>
</record>
<record StartMoney="2500" Name="Кексовый пер. 3" GoldTime="250" SilverTime="360" Prize="200" SilverPrize="300" GoldPrize="400" BearKillingNum="1">
<StartPets>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
<Pet Type="0"/>
</StartPets>
<Goals>
<goal Type="1" Val="40" EndlessStars="160" EndlessLevel="0"/>
<goal Type="2" Val="40" EndlessStars="320" EndlessLevel="0"/>
<goal Type="4" Val="1" EndlessStars="1" EndlessLevel="0"/>
<goal Type="10" Val="3" EndlessStars="260" EndlessLevel="1"/>
</Goals>
<BearTimes>
<t Type="0" Time="15"/>
<t Type="0" Time="15.1"/>
<t Type="0" Time="30"/>
<t Type="0" Time="30.1"/>
<t Type="0" Time="160"/>
<t Type="0" Time="160.1"/>
<t Type="0" Time="160.2"/>
<t Type="0" Time="240.1"/>
<t Type="0" Time="240.2"/>
<t Type="0" Time="240.3"/>
</BearTimes>
<Houses>
<h Type="0" PosIndex="0" Upgrade="0"/>
<h Type="1" PosIndex="4" Upgrade="0"/>
</Houses>
<Accessibility>
<c CritID="1" Value="5"/>
</Accessibility>
<AccessProduct>
<c Product="4"/>
</AccessProduct>
</record>
<record StartMoney="300" Name="Тортная 1" GoldTime="180" SilverTime="240" Prize="600" SilverPrize="1000" GoldPrize="1200" BearKillingNum="1">
<StartPets>
<Pet Type="0"/>
</StartPets>
<Goals>
<goal Type="9" Val="4" EndlessStars="20" EndlessLevel="0"/>
<goal Type="3" Val="2" EndlessStars="40" EndlessLevel="0"/>
<goal Type="2" Val="20" EndlessStars="160" EndlessLevel="0"/>
</Goals>
<BearTimes>
<t Type="0" Time="30"/>
<t Type="0" Time="30.1"/>
<t Type="0" Time="160"/>
<t Type="0" Time="160.1"/>
<t Type="0" Time="160.2"/>
</BearTimes>
<Houses>
<h Type="2" PosIndex="1" Upgrade="0"/>
<h Type="0" PosIndex="3" Upgrade="5"/>
<h Type="1" PosIndex="4" Upgrade="5"/>
</Houses>
<Accessibility>
<c CritID="2" Value="1"/>
</Accessibility>
<AccessProduct>
<c Product="4"/>
</AccessProduct>
</record>
<record StartMoney="500" Name="Тортная 2" GoldTime="200" SilverTime="300" Prize="100" SilverPrize="200" GoldPrize="300" BearKillingNum="1">
<StartPets>
<Pet Type="1"/>
</StartPets>
<Goals>
<goal Type="2" Val="30" EndlessStars="240" EndlessLevel="0"/>
<goal Type="3" Val="4" EndlessStars="80" EndlessLevel="0"/>
<goal Type="6" Val="2" EndlessStars="50" EndlessLevel="0"/>
</Goals>
<BearTimes>
<t Type="0" Time="30"/>
<t Type="1" Time="30.1"/>
<t Type="0" Time="160"/>
<t Type="0" Time="160.1"/>
<t Type="1" Time="160.2"/>
</BearTimes>
<Houses>
<h Type="0" PosIndex="0" Upgrade="5"/>
<h Type="1" PosIndex="1" Upgrade="5"/>
<h Type="2" PosIndex="3" Upgrade="0"/>
<h Type="3" PosIndex="4" Upgrade="0"/>
</Houses>
<Accessibility>
<c CritID="3" Value="1"/>
</Accessibility>
<AccessProduct>
<c Product="16"/>
</AccessProduct>
</record>
<record StartMoney="450" Name="Распутье 2" GoldTime="190" SilverTime="300" Prize="200" SilverPrize="400" GoldPrize="600" BearKillingNum="1">
<StartPets/>
<Goals>
<goal Type="3" Val="10" EndlessStars="200" EndlessLevel="0"/>
</Goals>
<BearTimes>
<t Type="0" Time="10"/>
<t Type="1" Time="10.1"/>
<t Type="0" Time="20"/>
<t Type="1" Time="20.1"/>
<t Type="1" Time="40.1"/>
<t Type="1" Time="40.2"/>
<t Type="0" Time="90"/>
<t Type="1" Time="90.1"/>
<t Type="1" Time="160.1"/>
<t Type="0" Time="160.2"/>
</BearTimes>
<Houses>
<h Type="0" PosIndex="0" Upgrade="5"/>
<h Type="1" PosIndex="1" Upgrade="5"/>
<h Type="2" PosIndex="2" Upgrade="1"/>
<h Type="3" PosIndex="3" Upgrade="1"/>
</Houses>
<Accessibility>
<c CritID="2" Value="2"/>
</Accessibility>
<AccessProduct>
<c Product="16"/>
</AccessProduct>
</record>
</Records>
;
public static var target:String = "_blank";
public static var language:String = "en";
public function Config(){
super();
}
public static function getLevel(level:Number=1):XML{
return (LevelesRecords.record[(level - 1)]);
}
}
}//package utils
Section 159
//Languages (utils.Languages)
package utils {
public class Languages {
public static var language:XML = <english>
<levels>
<level>Chicken Lane 1</level>
<level>Chicken Lane 2</level>
<level>Powder Street 1</level>
<level>Powder Street 2</level>
<level>Powder Street 3</level>
<level>Crossroads 1</level>
<level>Cake Street 1</level>
<level>Cake Street 2</level>
<level>Cake Street 3</level>
<level>Bun Lane 1</level>
<level>Bun Lane 2</level>
<level>Bun Lane 3</level>
<level>Cake Street 1</level>
<level>Cake Street 2</level>
<level>Crossroads 2</level>
</levels>
<!-- Ui-->
<download>Download</download>
<download_full_version>Download full version</download_full_version>
<ok>Ok</ok>
<yes>Yes</yes>
<resume>Resume</resume>
<map>Map</map>
<restart>Restart</restart>
<no>No</no>
<cancel>Cancel</cancel>
<upgrade_building>Upgrade building</upgrade_building>
<start>Start</start>
<shop>Shop</shop>
<menu>Menu</menu>
<one>1</one>
<all>all</all>
<sounds>Sounds</sounds>
<music>Music</music>
<main_menu>Main menu</main_menu>
<exit_to_menu>Exit to menu</exit_to_menu>
<exit>Exit</exit>
<quit>Are you sure you want to quit?</quit>
<quit_current_game>Quit your current game?</quit_current_game>
<!-- Results -->
<level_results>Level results</level_results>
<coins>Coins:</coins>
<time>Time:</time>
<bonus>Bonus:</bonus>
<bank>Bank:</bank>
<!-- Results window -->
<level_goals>Level goals</level_goals>
<collect>Collect:</collect>
<for_completing>For completing:</for_completing>
<gold>Gold</gold>
<silver>Silver</silver>
<game_over>Congratulations! You have finished online version! Download full version! Five products to buy in the city, Four animals, Four types of bears, 12 buildings with three upgrades apiece, 16 products to produce, 17 secret gags to find and click on, 19 awards to earn, Four additional buildings with three upgrades apiece, Cats and Dogs with three upgrades apiece</game_over>
<!-- Buildings -->
<powdered>Powdered</powdered>
<confectionery>Confectionery</confectionery>
<bakery>Bakery</bakery>
<meat_cutter>Meat Cutter</meat_cutter>
<warehouse tooltip="Warehouse for storing products">Warehouse</warehouse>
<well tooltip="This is a well. It produces water for watering plants.">Well</well>
<!-- market -->
<plane>Plane</plane>
<car>Truck</car>
<order_products>Order products</order_products>
<products>Products</products>
<price>Price</price>
<order>Order</order>
<ship_products>Ship products</ship_products>
<ship>Ship</ship>
<animals>Animals</animals>
<!-- Animals -->
<pig produce="Pig produces">Pig</pig>
<chicken produce="Chicken produces">Chicken</chicken>
<pigs>Pigs</pigs>
<chickens>Chickens</chickens>
<panda>Panda</panda>
<brown_bear>Brown Bear</brown_bear>
<flour>Flour</flour>
<!-- Purposes -->
<goals>Goals</goals>
<money>Money</money>
<egg>Egg</egg>
<eggs>Eggs</eggs>
<powdered_eggs>Powdered eggs</powdered_eggs>
<buns>Buns</buns>
<cakes>Cakes</cakes>
<meat>Meat</meat>
<tenderloin>Tenderloin</tenderloin>
<!-- Tooltips -->
<tooltips>
<chicken>This is a chicken. It eats grass and produces eggs</chicken>
<pig>This is a pig. It eats grass and produces pork</pig>
<bear>This is a bear. It tosses animals around. Catch it and sell it.</bear>
<house_plate>Click here to construct a building.</house_plate>
<click_the_ground>Click the ground to water it and make the grass grow.</click_the_ground>
<well_empty>The well is empty. Click it to buy water.</well_empty>
<collect>Collect products in the warehouse.</collect>
<level_icon>This is the level icon. Click it to start playing.</level_icon>
<level_inaccessible>To access a new level, go to the store and purchase the plans for the stated building.</level_inaccessible>
<powdered>This is a powder factory. Click it to make powder from your eggs.</powdered>
<confectionery>This is a cake factory. It makes cakes from buns.</confectionery>
<bakery>This is a bakery. It produces buns from powder.</bakery>
<meat_cutter>This is a butcher's house. The butcher produces steaks from meat.</meat_cutter>
<warehouse>This is a warehouse. This is where your products are stored. Click it to sell your products.</warehouse>
<plane>This is a plane. Use it to bring in goods from the city.</plane>
<car>This is a truck. It takes products to the city..</car>
<shop>Here, you can upgrade your buildings and more using the stars you collected.</shop>
<goals>This is the goal icon. Click it to see your goals for the level.</goals>
</tooltips>
</english>
;
public function Languages(){
super();
}
}
}//package utils
Section 160
//LevelStatistics (utils.LevelStatistics)
package utils {
import ui.*;
import game.*;
public class LevelStatistics {
public static var goals:Array = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
public static var purposes:Array = new Array();
public function LevelStatistics(){
super();
}
public static function checkCompleted():void{
var purpose:Array;
var completed:Number = 0;
var i:int;
while (i < LevelStatistics.purposes.length) {
purpose = LevelStatistics.purposes[i].split(",");
if (Number(purpose[1]) <= Number(LevelStatistics.goals[ProductTypes.typeToNumber(purpose[0])])){
completed++;
};
i++;
};
if (completed == LevelStatistics.purposes.length){
GameController.instance.pause();
trace("Level has been completed");
ResultsWindow.instance.show();
};
}
public static function updateStatistics():void{
BottomPanel.instance.update();
checkCompleted();
}
}
}//package utils
Section 161
//ProductTypes (utils.ProductTypes)
package utils {
public class ProductTypes {
private static var types:Array = new Array("EGG", "DRIED_EGGS", "CAKE", "FLOURY_CAKE", "FLOUR", "MEAT", "STAKE", "PANDA", "BROWN", "CHICKEN", "PIG", "MONEY");
public function ProductTypes(){
super();
}
public static function numberToType(type:Number):String{
return (types[type]);
}
public static function translate(type:String, help:Boolean=false):String{
switch (type){
case "EGG":
return (Config.currentLanguage.eggs);
case "DRIED_EGGS":
return (Config.currentLanguage.powdered_eggs);
case "CAKE":
return (Config.currentLanguage.buns);
case "FLOURY_CAKE":
return (Config.currentLanguage.cakes);
case "FLOUR":
return (Config.currentLanguage.flour);
case "MEAT":
return (Config.currentLanguage.meat);
case "STAKE":
return (Config.currentLanguage.tenderloin);
case "PANDA":
return (Config.currentLanguage.panda);
case "BROWN":
return (Config.currentLanguage.brown_bear);
case "CHICKEN":
if (help){
return (Config.currentLanguage.chicken.@produce);
};
return (Config.currentLanguage.chickens);
case "PIG":
if (help){
return (Config.currentLanguage.pig.@produce);
};
return (Config.currentLanguage.pigs);
case "MONEY":
return (Config.currentLanguage.money);
default:
return (Config.currentLanguage.eggs);
};
}
public static function typeToNumber(type:String):Number{
switch (type){
case "EGG":
return (0);
case "DRIED_EGGS":
return (1);
case "CAKE":
return (2);
case "FLOURY_CAKE":
return (3);
case "FLOUR":
return (4);
case "MEAT":
return (5);
case "STAKE":
return (6);
case "PANDA":
return (7);
case "BROWN":
return (8);
case "CHICKEN":
return (9);
case "PIG":
return (10);
case "MONEY":
return (11);
default:
return (0);
};
}
}
}//package utils
Section 162
//SoundsList (utils.SoundsList)
package utils {
import flash.media.*;
import com.melesta.sound.*;
public class SoundsList {
public static var menuMusicSound:Sound;
public static var muteMusic:Boolean = false;
public static var gameMusicChannel:SoundChannel;
public static var mute:Boolean = false;
public static var gameMusicSound:Sound;
public static var menuMusicChannel:SoundChannel;
public function SoundsList(){
super();
}
public static function init():void{
SoundManager.registerSoundAsset("action_sell_buy", action_sell_buy);
SoundManager.registerSoundAsset("action_upgrade", action_upgrade);
SoundManager.registerSoundAsset("action_watering", action_watering);
SoundManager.registerSoundAsset("action_well_auto", action_well_auto);
SoundManager.registerSoundAsset("action_well", action_well);
SoundManager.registerSoundAsset("airplane_flyin", airplane_flyin);
SoundManager.registerSoundAsset("bear0_panda_scream", bear0_panda_scream);
SoundManager.registerSoundAsset("bear1_brown_scream", bear1_brown_scream);
SoundManager.registerSoundAsset("bear_landing", bear_landing);
SoundManager.registerSoundAsset("cage_breaking", cage_breaking);
SoundManager.registerSoundAsset("cage_broke_bear_flee", cage_broke_bear_flee);
SoundManager.registerSoundAsset("cage_click", cage_click);
SoundManager.registerSoundAsset("car_came", car_came);
SoundManager.registerSoundAsset("cat_flyout", cat_flyout);
SoundManager.registerSoundAsset("cat_voice", cat_voice);
SoundManager.registerSoundAsset("chicken_die", chicken_die);
SoundManager.registerSoundAsset("chicken_flyout", chicken_flyout);
SoundManager.registerSoundAsset("chicken_hungry", chicken_hungry);
SoundManager.registerSoundAsset("chicken_voice", chicken_voice);
SoundManager.registerSoundAsset("fanfare_aim", fanfare_aim);
SoundManager.registerSoundAsset("fanfare_best_time", fanfare_best_time);
SoundManager.registerSoundAsset("fanfare_level_complete", fanfare_level_complete);
SoundManager.registerSoundAsset("fanfare_medal", fanfare_medal);
SoundManager.registerSoundAsset("fool_action", fool_action);
SoundManager.registerSoundAsset("house_board_landing", house_board_landing);
SoundManager.registerSoundAsset("house_click", house_click);
SoundManager.registerSoundAsset("house_crash", house_crash);
SoundManager.registerSoundAsset("house_downgrade", house_downgrade);
SoundManager.registerSoundAsset("house_landing", house_landing);
SoundManager.registerSoundAsset("item_add", item_add);
SoundManager.registerSoundAsset("item_cancel", item_cancel);
SoundManager.registerSoundAsset("ostrich_voice", ostrich_voice);
SoundManager.registerSoundAsset("pig_die", pig_die);
SoundManager.registerSoundAsset("pig_flyout", pig_flyout);
SoundManager.registerSoundAsset("pig_hungry", pig_hungry);
SoundManager.registerSoundAsset("pig_voice", pig_voice);
SoundManager.registerSoundAsset("product_crack", product_crack);
SoundManager.registerSoundAsset("product_landing", product_landing);
SoundManager.registerSoundAsset("product_take", product_take);
SoundManager.registerSoundAsset("tick_money", tick_money);
SoundManager.registerSoundAsset("tick_time", tick_time);
SoundManager.registerSoundAsset("ui_button_click", ui_button_click);
SoundManager.registerSoundAsset("ui_button_hover", ui_button_hover);
var cls:Class = (music_menu as Class);
menuMusicSound = (new (cls) as Sound);
}
}
}//package utils
Section 163
//Car (vehicles.Car)
package vehicles {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
import houses.*;
import shop.*;
import ui.*;
import game.*;
import market.road.*;
import utils.*;
import flash.media.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class Car extends CarTemplate {
private var _upgradePosition:Array;
private var gameController:GameController;
private var _stageInstance:DisplayObjectContainer;
private var _upgradeButton:UpgradeButton;
public static var instance:Car;
public static var upgradeLevel:Number = 1;
public static var upgradeCost:Array = new Array(300, 800, 1500, 5000);
public static var firstShow:Boolean = true;
public function Car(stageInstance:DisplayObjectContainer, level:Number, delay:Number){
_upgradePosition = new Array(-45, -20);
super();
Car.instance = this;
gameController = GameController.instance;
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
gameController.addEventListener(GameController.CHANGE_MONEY, updateMoney, false, 0, true);
SoundManager.registerSoundAsset("house_landing", house_landing);
upgradeLevel = level;
_stageInstance = stageInstance;
stageInstance.addChild(this);
this.x = 140;
var point:Point = new Point(140, 417);
show(point, delay);
body.addEventListener(MouseEvent.ROLL_OVER, dropShadow, false, 0, true);
body.addEventListener(MouseEvent.ROLL_OUT, removeShadow, false, 0, true);
body.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
_upgradeButton = new UpgradeButton();
_upgradeButton.x = _upgradePosition[0];
_upgradeButton.y = _upgradePosition[1];
_upgradeButton.target = this;
addChild(_upgradeButton);
upgrade(upgradeLevel);
}
public function animate():void{
}
public function upgrade(level:Number):void{
this.body.gotoAndStop(level);
if (upgradeLevel <= (ShopWindow.availableUpgrades[3] - 1)){
_upgradeButton.caption.text = Car.upgradeCost[(upgradeLevel - 1)];
};
if (upgradeLevel > (ShopWindow.availableUpgrades[3] - 1)){
_upgradeButton.destroy();
};
Road.instance.addMoney(0);
}
public function removeShadow(event:MouseEvent=null):void{
var mtx:Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
Tooltip.instance.hide();
}
public function onClick(event:MouseEvent=null):void{
SoundManager.play("house_click", 1);
Depot.instance.showMarket();
}
private function remove():void{
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
}
public function dropShadow(event:MouseEvent=null):void{
var mtx:Array = [2, 0, 0, 0, -63.5, 0, 2, 0, 0, -63.5, 0, 0, 2, 0, -63.5, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
Tooltip.instance.show(x, (y - 20), "CAR", upgradeLevel, "CAR");
}
public function nextUpgrade():void{
Road.instance.addMoney(-(Number(Car.upgradeCost[(upgradeLevel - 1)])));
upgradeLevel++;
upgrade(upgradeLevel);
SoundManager.play("action_upgrade", 1);
}
private function landing():void{
SoundManager.play("house_landing", 1, new SoundTransform(1, -1));
updateMoney();
if (firstShow){
firstShow = false;
BlockTooltip.instance.show(this.x, this.y, Config.currentLanguage.tooltips.car);
};
}
public function updateMoney(event:Event=null):void{
if (_upgradeButton){
if (Car.upgradeCost[(upgradeLevel - 1)] <= Road.currentMoney){
_upgradeButton.disabled(true);
} else {
_upgradeButton.disabled(false);
};
};
}
public function destroy(event:Event=null):void{
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
gameController.removeEventListener(GameController.CHANGE_MONEY, updateMoney);
_stageInstance.removeChild(this);
}
public function show(position:Point, delay:Number):void{
this.x = position.x;
this.y = -50;
Tweener.addTween(this, {y:position.y, time:0.4, delay:delay, transition:"easeInQuint", onComplete:landing});
}
}
}//package vehicles
Section 164
//CarTemplate (vehicles.CarTemplate)
package vehicles {
import flash.display.*;
public dynamic class CarTemplate extends MovieClip {
public var body:MovieClip;
}
}//package vehicles
Section 165
//Plane (vehicles.Plane)
package vehicles {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
import houses.*;
import shop.*;
import ui.*;
import game.*;
import market.road.*;
import utils.*;
import flash.media.*;
import market.*;
import com.melesta.sound.*;
import caurina.transitions.*;
public class Plane extends PlaneTemplate {
private var _upgradePosition:Array;
private var gameController:GameController;
private var _upgradeButton:UpgradeButton;
private var _stageInstance:DisplayObjectContainer;
private var _exportProduction:ExportProduction;
public static var instance:Plane;
public static var upgradeLevel:Number = 1;
public static var upgradeCost:Array = new Array(300, 800, 1500, 5000);
public static var firstShow:Boolean = true;
public function Plane(stageInstance:DisplayObjectContainer, level:Number, delay:Number){
_upgradePosition = new Array(-45, 0);
super();
Plane.instance = this;
SoundManager.registerSoundAsset("house_landing", house_landing);
upgradeLevel = level;
_stageInstance = stageInstance;
gameController = GameController.instance;
gameController.addEventListener(GameController.LEVEL_COMPLETED, destroy, false, 0, true);
gameController.addEventListener(GameController.CHANGE_MONEY, updateMoney, false, 0, true);
stageInstance.addChild(this);
this.x = 403;
var point:Point = new Point(403, 412);
show(point, delay);
body.addEventListener(MouseEvent.ROLL_OVER, dropShadow, false, 0, true);
body.addEventListener(MouseEvent.ROLL_OUT, removeShadow, false, 0, true);
body.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
_upgradeButton = new UpgradeButton();
_upgradeButton.x = _upgradePosition[0];
_upgradeButton.y = _upgradePosition[1];
_upgradeButton.target = this;
addChild(_upgradeButton);
upgrade(upgradeLevel);
_exportProduction = new ExportProduction(stageInstance);
}
public function animate():void{
}
public function upgrade(level:Number):void{
this.body.gotoAndStop(level);
if (upgradeLevel <= (ShopWindow.availableUpgrades[4] - 1)){
_upgradeButton.caption.text = Plane.upgradeCost[(upgradeLevel - 1)];
};
if (upgradeLevel > (ShopWindow.availableUpgrades[4] - 1)){
_upgradeButton.destroy();
};
Road.instance.addMoney(0);
}
private function remove():void{
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
}
public function onClick(event:MouseEvent=null):void{
SoundManager.play("house_click", 1);
_exportProduction.show();
}
public function removeShadow(event:MouseEvent=null):void{
var mtx:Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
Tooltip.instance.hide();
}
public function nextUpgrade():void{
Road.instance.addMoney(-(Number(Plane.upgradeCost[(upgradeLevel - 1)])));
upgradeLevel++;
upgrade(upgradeLevel);
SoundManager.play("action_upgrade", 1);
}
public function dropShadow(event:MouseEvent=null):void{
var mtx:Array = [2, 0, 0, 0, -63.5, 0, 2, 0, 0, -63.5, 0, 0, 2, 0, -63.5, 0, 0, 0, 1, 0];
var mtxFilter:ColorMatrixFilter = new ColorMatrixFilter(mtx);
this.body.filters = [mtxFilter];
Tooltip.instance.show(x, y, "PLANE", upgradeLevel, "PLANE");
}
private function landing():void{
SoundManager.play("house_landing", 1, new SoundTransform(1, 1));
updateMoney();
if (firstShow){
firstShow = false;
BlockTooltip.instance.show(this.x, this.y, Config.currentLanguage.tooltips.plane);
};
}
public function updateMoney(event:Event=null):void{
if (_upgradeButton){
if (Plane.upgradeCost[(upgradeLevel - 1)] <= Road.currentMoney){
_upgradeButton.disabled(true);
} else {
_upgradeButton.disabled(false);
};
};
}
public function destroy(event:Event=null):void{
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(MouseEvent.ROLL_OVER, dropShadow);
removeEventListener(MouseEvent.ROLL_OVER, removeShadow);
gameController.removeEventListener(GameController.LEVEL_COMPLETED, destroy);
gameController.removeEventListener(GameController.CHANGE_MONEY, updateMoney);
_stageInstance.removeChild(this);
}
public function show(position:Point, delay:Number):void{
this.x = position.x;
this.y = -50;
Tweener.addTween(this, {y:position.y, time:0.4, delay:delay, transition:"easeInQuint", onComplete:landing});
}
}
}//package vehicles
Section 166
//PlaneTemplate (vehicles.PlaneTemplate)
package vehicles {
import flash.display.*;
public dynamic class PlaneTemplate extends MovieClip {
public var body:MovieClip;
}
}//package vehicles
Section 167
//_line__103 (wellMain_fla._line__103)
package wellMain_fla {
import flash.display.*;
public dynamic class _line__103 extends MovieClip {
public var _mask:MovieClip;
}
}//package wellMain_fla
Section 168
//_line_9 (wellMain_fla._line_9)
package wellMain_fla {
import flash.display.*;
public dynamic class _line_9 extends MovieClip {
public function _line_9(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 169
//_progress_8 (wellMain_fla._progress_8)
package wellMain_fla {
import flash.display.*;
public dynamic class _progress_8 extends MovieClip {
public var line:MovieClip;
}
}//package wellMain_fla
Section 170
//aim_btn_73 (wellMain_fla.aim_btn_73)
package wellMain_fla {
import flash.events.*;
import flash.display.*;
public dynamic class aim_btn_73 extends MovieClip {
public function aim_btn_73(){
addFrameScript(0, frame1);
}
public function out(_arg1:MouseEvent):void{
this.gotoAndStop(1);
}
function frame1(){
stop();
this.addEventListener(MouseEvent.MOUSE_OVER, over, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_OUT, out, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_DOWN, down, false, 0, true);
}
public function down(_arg1:MouseEvent):void{
this.gotoAndStop(3);
}
public function over(_arg1:MouseEvent):void{
this.gotoAndStop(2);
}
}
}//package wellMain_fla
Section 171
//alawar_10 (wellMain_fla.alawar_10)
package wellMain_fla {
import flash.display.*;
public dynamic class alawar_10 extends MovieClip {
public function alawar_10(){
addFrameScript(0, frame1, 3, frame4);
}
function frame1(){
stop();
}
function frame4(){
stop();
}
}
}//package wellMain_fla
Section 172
//big_btn_24 (wellMain_fla.big_btn_24)
package wellMain_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public dynamic class big_btn_24 extends MovieClip {
public var caption:TextField;
public function big_btn_24(){
addFrameScript(0, frame1);
}
public function out(_arg1:MouseEvent){
this.gotoAndStop(1);
}
function frame1(){
addEventListener(MouseEvent.MOUSE_OVER, over);
addEventListener(MouseEvent.MOUSE_OUT, out);
addEventListener(MouseEvent.MOUSE_DOWN, down);
stop();
}
public function down(_arg1:MouseEvent){
this.gotoAndStop(3);
}
public function over(_arg1:MouseEvent){
this.gotoAndStop(2);
}
}
}//package wellMain_fla
Section 173
//bodyGrass_51 (wellMain_fla.bodyGrass_51)
package wellMain_fla {
import flash.display.*;
public dynamic class bodyGrass_51 extends MovieClip {
public function bodyGrass_51(){
addFrameScript(16, frame17);
}
function frame17(){
stop();
}
}
}//package wellMain_fla
Section 174
//boxlineExpor_99 (wellMain_fla.boxlineExpor_99)
package wellMain_fla {
import flash.display.*;
public dynamic class boxlineExpor_99 extends MovieClip {
public function boxlineExpor_99(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 175
//bueButton_38 (wellMain_fla.bueButton_38)
package wellMain_fla {
import flash.display.*;
import flash.text.*;
public dynamic class bueButton_38 extends MovieClip {
public var price:TextField;
}
}//package wellMain_fla
Section 176
//buyBtn_23 (wellMain_fla.buyBtn_23)
package wellMain_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public dynamic class buyBtn_23 extends MovieClip {
public var caption:TextField;
public function buyBtn_23(){
addFrameScript(0, frame1);
}
public function out(_arg1:MouseEvent){
this.gotoAndStop(1);
}
function frame1(){
addEventListener(MouseEvent.MOUSE_OVER, over);
addEventListener(MouseEvent.MOUSE_OUT, out);
addEventListener(MouseEvent.MOUSE_DOWN, down);
}
public function down(_arg1:MouseEvent){
this.gotoAndStop(3);
}
public function over(_arg1:MouseEvent){
this.gotoAndStop(2);
}
}
}//package wellMain_fla
Section 177
//car0_96 (wellMain_fla.car0_96)
package wellMain_fla {
import flash.display.*;
public dynamic class car0_96 extends MovieClip {
public function car0_96(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 178
//carOnTheRoad_93 (wellMain_fla.carOnTheRoad_93)
package wellMain_fla {
import flash.display.*;
import flash.text.*;
public dynamic class carOnTheRoad_93 extends MovieClip {
public var body:MovieClip;
public var money:TextField;
}
}//package wellMain_fla
Section 179
//cars_55 (wellMain_fla.cars_55)
package wellMain_fla {
import flash.display.*;
public dynamic class cars_55 extends MovieClip {
public function cars_55(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 180
//cars_94 (wellMain_fla.cars_94)
package wellMain_fla {
import flash.display.*;
public dynamic class cars_94 extends MovieClip {
public function cars_94(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 181
//carsItem_102 (wellMain_fla.carsItem_102)
package wellMain_fla {
import flash.display.*;
public dynamic class carsItem_102 extends MovieClip {
public function carsItem_102(){
addFrameScript(1, frame2);
}
function frame2(){
stop();
}
}
}//package wellMain_fla
Section 182
//cat0Icon_mc_85 (wellMain_fla.cat0Icon_mc_85)
package wellMain_fla {
import flash.display.*;
public dynamic class cat0Icon_mc_85 extends MovieClip {
public function cat0Icon_mc_85(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 183
//chickenIcon_mc_79 (wellMain_fla.chickenIcon_mc_79)
package wellMain_fla {
import flash.display.*;
public dynamic class chickenIcon_mc_79 extends MovieClip {
public var activeArea:MovieClip;
public function chickenIcon_mc_79(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 184
//cowIcon_mc_81 (wellMain_fla.cowIcon_mc_81)
package wellMain_fla {
import flash.display.*;
public dynamic class cowIcon_mc_81 extends MovieClip {
public function cowIcon_mc_81(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 185
//dog0Icon_mc_84 (wellMain_fla.dog0Icon_mc_84)
package wellMain_fla {
import flash.display.*;
public dynamic class dog0Icon_mc_84 extends MovieClip {
public function dog0Icon_mc_84(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 186
//dogsIcon_mc_83 (wellMain_fla.dogsIcon_mc_83)
package wellMain_fla {
import flash.display.*;
public dynamic class dogsIcon_mc_83 extends MovieClip {
public var dog0:MovieClip;
}
}//package wellMain_fla
Section 187
//goalItem_43 (wellMain_fla.goalItem_43)
package wellMain_fla {
import flash.display.*;
import flash.text.*;
public dynamic class goalItem_43 extends MovieClip {
public var count:TextField;
public var body:MovieClip;
}
}//package wellMain_fla
Section 188
//gold_32 (wellMain_fla.gold_32)
package wellMain_fla {
import flash.display.*;
public dynamic class gold_32 extends MovieClip {
public function gold_32(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 189
//helpBlockToolTip_21 (wellMain_fla.helpBlockToolTip_21)
package wellMain_fla {
import flash.display.*;
import flash.text.*;
public dynamic class helpBlockToolTip_21 extends MovieClip {
public var okBtn:MovieClip;
public var caption:TextField;
}
}//package wellMain_fla
Section 190
//items_28 (wellMain_fla.items_28)
package wellMain_fla {
import flash.display.*;
import flash.text.*;
public dynamic class items_28 extends MovieClip {
public var arrow:MovieClip;
public var outCount:TextField;
public var caption:TextField;
public var inCount:TextField;
public function items_28(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 191
//kubok_40 (wellMain_fla.kubok_40)
package wellMain_fla {
import flash.display.*;
public dynamic class kubok_40 extends MovieClip {
public function kubok_40(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 192
//middleButton_12 (wellMain_fla.middleButton_12)
package wellMain_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public dynamic class middleButton_12 extends MovieClip {
public var caption:TextField;
public function middleButton_12(){
addFrameScript(0, frame1);
}
public function out(_arg1:MouseEvent){
this.gotoAndStop(1);
}
function frame1(){
addEventListener(MouseEvent.MOUSE_OVER, over);
addEventListener(MouseEvent.MOUSE_OUT, out);
addEventListener(MouseEvent.MOUSE_DOWN, down);
stop();
}
public function down(_arg1:MouseEvent){
this.gotoAndStop(3);
}
public function over(_arg1:MouseEvent){
this.gotoAndStop(2);
}
}
}//package wellMain_fla
Section 193
//new_33 (wellMain_fla.new_33)
package wellMain_fla {
import flash.display.*;
public dynamic class new_33 extends MovieClip {
public function new_33(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 194
//none_34 (wellMain_fla.none_34)
package wellMain_fla {
import flash.display.*;
public dynamic class none_34 extends MovieClip {
public function none_34(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 195
//normal_35 (wellMain_fla.normal_35)
package wellMain_fla {
import flash.display.*;
public dynamic class normal_35 extends MovieClip {
public function normal_35(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 196
//okButton_17 (wellMain_fla.okButton_17)
package wellMain_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public dynamic class okButton_17 extends MovieClip {
public var caption:TextField;
public function okButton_17(){
addFrameScript(0, frame1);
}
public function out(_arg1:MouseEvent){
this.gotoAndStop(1);
}
function frame1(){
addEventListener(MouseEvent.MOUSE_OVER, over);
addEventListener(MouseEvent.MOUSE_OUT, out);
stop();
}
public function over(_arg1:MouseEvent){
this.gotoAndStop(2);
}
}
}//package wellMain_fla
Section 197
//ostrich_14 (wellMain_fla.ostrich_14)
package wellMain_fla {
import flash.display.*;
public dynamic class ostrich_14 extends MovieClip {
public function ostrich_14(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 198
//ostrichIcon_mc_82 (wellMain_fla.ostrichIcon_mc_82)
package wellMain_fla {
import flash.display.*;
public dynamic class ostrichIcon_mc_82 extends MovieClip {
public function ostrichIcon_mc_82(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 199
//pigIcon_mc_80 (wellMain_fla.pigIcon_mc_80)
package wellMain_fla {
import flash.display.*;
public dynamic class pigIcon_mc_80 extends MovieClip {
public var activeArea:MovieClip;
public function pigIcon_mc_80(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 200
//plane_98 (wellMain_fla.plane_98)
package wellMain_fla {
import flash.display.*;
public dynamic class plane_98 extends MovieClip {
public function plane_98(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 201
//planeInTheSky_91 (wellMain_fla.planeInTheSky_91)
package wellMain_fla {
import flash.display.*;
import flash.text.*;
public dynamic class planeInTheSky_91 extends MovieClip {
public var body:MovieClip;
public var money:TextField;
}
}//package wellMain_fla
Section 202
//planes_53 (wellMain_fla.planes_53)
package wellMain_fla {
import flash.display.*;
public dynamic class planes_53 extends MovieClip {
public function planes_53(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 203
//planes_92 (wellMain_fla.planes_92)
package wellMain_fla {
import flash.display.*;
public dynamic class planes_92 extends MovieClip {
public function planes_92(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 204
//productionbody_44 (wellMain_fla.productionbody_44)
package wellMain_fla {
import flash.display.*;
public dynamic class productionbody_44 extends MovieClip {
public function productionbody_44(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 205
//purposes_75 (wellMain_fla.purposes_75)
package wellMain_fla {
import flash.display.*;
import flash.text.*;
public dynamic class purposes_75 extends MovieClip {
public var actual:TextField;
public var tick:MovieClip;
public var required:TextField;
public var body:MovieClip;
public function purposes_75(){
addFrameScript(0, frame1);
}
function frame1(){
this.mouseEnabled = false;
this.mouseChildren = false;
}
}
}//package wellMain_fla
Section 206
//purposesItem_46 (wellMain_fla.purposesItem_46)
package wellMain_fla {
import flash.display.*;
import flash.text.*;
public dynamic class purposesItem_46 extends MovieClip {
public var type_txt:TextField;
public var count_txt:TextField;
public var body:MovieClip;
}
}//package wellMain_fla
Section 207
//purposesRibbon_74 (wellMain_fla.purposesRibbon_74)
package wellMain_fla {
import flash.display.*;
import flash.text.*;
public dynamic class purposesRibbon_74 extends MovieClip {
public var time_txt:TextField;
public function purposesRibbon_74(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 208
//silver_36 (wellMain_fla.silver_36)
package wellMain_fla {
import flash.display.*;
public dynamic class silver_36 extends MovieClip {
public function silver_36(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 209
//sklads_57 (wellMain_fla.sklads_57)
package wellMain_fla {
import flash.display.*;
public dynamic class sklads_57 extends MovieClip {
public function sklads_57(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 210
//smalButton_48 (wellMain_fla.smalButton_48)
package wellMain_fla {
import flash.display.*;
import flash.text.*;
public dynamic class smalButton_48 extends MovieClip {
public var caption:TextField;
public function smalButton_48(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 211
//soundControl_87 (wellMain_fla.soundControl_87)
package wellMain_fla {
import flash.display.*;
import flash.text.*;
public dynamic class soundControl_87 extends MovieClip {
public var caption:TextField;
public function soundControl_87(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 212
//waterline_mc_3 (wellMain_fla.waterline_mc_3)
package wellMain_fla {
import flash.display.*;
public dynamic class waterline_mc_3 extends MovieClip {
public var progressMask:MovieClip;
}
}//package wellMain_fla
Section 213
//well_2 (wellMain_fla.well_2)
package wellMain_fla {
import flash.display.*;
public dynamic class well_2 extends MovieClip {
public function well_2(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package wellMain_fla
Section 214
//action_sell_buy (action_sell_buy)
package {
import flash.media.*;
public dynamic class action_sell_buy extends Sound {
}
}//package
Section 215
//action_upgrade (action_upgrade)
package {
import flash.media.*;
public dynamic class action_upgrade extends Sound {
}
}//package
Section 216
//action_watering (action_watering)
package {
import flash.media.*;
public dynamic class action_watering extends Sound {
}
}//package
Section 217
//action_well (action_well)
package {
import flash.media.*;
public dynamic class action_well extends Sound {
}
}//package
Section 218
//action_well_auto (action_well_auto)
package {
import flash.media.*;
public dynamic class action_well_auto extends Sound {
}
}//package
Section 219
//airplane_flyin (airplane_flyin)
package {
import flash.media.*;
public dynamic class airplane_flyin extends Sound {
}
}//package
Section 220
//bear_landing (bear_landing)
package {
import flash.media.*;
public dynamic class bear_landing extends Sound {
}
}//package
Section 221
//bear0_panda_scream (bear0_panda_scream)
package {
import flash.media.*;
public dynamic class bear0_panda_scream extends Sound {
}
}//package
Section 222
//bear1_brown_scream (bear1_brown_scream)
package {
import flash.media.*;
public dynamic class bear1_brown_scream extends Sound {
}
}//package
Section 223
//BlockTooltipTemplate (BlockTooltipTemplate)
package {
import flash.display.*;
public dynamic class BlockTooltipTemplate extends MovieClip {
public var lock:MovieClip;
public var help:MovieClip;
public var body:MovieClip;
}
}//package
Section 224
//cage_breaking (cage_breaking)
package {
import flash.media.*;
public dynamic class cage_breaking extends Sound {
}
}//package
Section 225
//cage_broke_bear_flee (cage_broke_bear_flee)
package {
import flash.media.*;
public dynamic class cage_broke_bear_flee extends Sound {
}
}//package
Section 226
//cage_click (cage_click)
package {
import flash.media.*;
public dynamic class cage_click extends Sound {
}
}//package
Section 227
//CakeHouseTemplate (CakeHouseTemplate)
package {
import flash.display.*;
public dynamic class CakeHouseTemplate extends MovieClip {
public var body:MovieClip;
public var activeArea:MovieClip;
}
}//package
Section 228
//car_came (car_came)
package {
import flash.media.*;
public dynamic class car_came extends Sound {
}
}//package
Section 229
//cat_flyout (cat_flyout)
package {
import flash.media.*;
public dynamic class cat_flyout extends Sound {
}
}//package
Section 230
//cat_voice (cat_voice)
package {
import flash.media.*;
public dynamic class cat_voice extends Sound {
}
}//package
Section 231
//chicken_die (chicken_die)
package {
import flash.media.*;
public dynamic class chicken_die extends Sound {
}
}//package
Section 232
//chicken_flyout (chicken_flyout)
package {
import flash.media.*;
public dynamic class chicken_flyout extends Sound {
}
}//package
Section 233
//chicken_hungry (chicken_hungry)
package {
import flash.media.*;
public dynamic class chicken_hungry extends Sound {
}
}//package
Section 234
//chicken_voice (chicken_voice)
package {
import flash.media.*;
public dynamic class chicken_voice extends Sound {
}
}//package
Section 235
//DriedEggsHouseTemplate (DriedEggsHouseTemplate)
package {
import flash.display.*;
public dynamic class DriedEggsHouseTemplate extends MovieClip {
public var body:MovieClip;
public var activeArea:MovieClip;
}
}//package
Section 236
//EndScreenTemplate (EndScreenTemplate)
package {
import flash.display.*;
import flash.text.*;
public dynamic class EndScreenTemplate extends MovieClip {
public var exitBtn:MovieClip;
public var caption:TextField;
public var buyBtn:MovieClip;
}
}//package
Section 237
//fanfare_aim (fanfare_aim)
package {
import flash.media.*;
public dynamic class fanfare_aim extends Sound {
}
}//package
Section 238
//fanfare_best_time (fanfare_best_time)
package {
import flash.media.*;
public dynamic class fanfare_best_time extends Sound {
}
}//package
Section 239
//fanfare_level_complete (fanfare_level_complete)
package {
import flash.media.*;
public dynamic class fanfare_level_complete extends Sound {
}
}//package
Section 240
//fanfare_medal (fanfare_medal)
package {
import flash.media.*;
public dynamic class fanfare_medal extends Sound {
}
}//package
Section 241
//Farm2 (Farm2)
package {
import flash.events.*;
import caurina.transitions.*;
import flash.media.*;
import flash.display.*;
import ui.*;
import game.*;
import utils.*;
import flash.net.*;
import flash.text.*;
import flash.utils.*;
public class Farm2 extends MovieClip {
private var musicLoaded:Boolean;// = false
private var musicCurrent:Number;// = 0
private var country:String;// = "US"
private var gameMusicPath:String;// = "music/music_game.mp3"
private var farmLoaded:Boolean;// = false
private var musicTotal:Number;// = 0
private var language:String;// = "en"
private var farmTotal:Number;// = 0
private var preloader:FarmPreloader;
private var xmlLoaded:Boolean;// = true
public static const DOCUMENT_CLASS:String = "FarmFrenzy2";
public static var mail_ru_connection:LocalConnection;
public static var connection_name:String;
public static var portal:String = "not_mail.ru";
public function Farm2(){
super();
stop();
loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loaderInfo.addEventListener(Event.COMPLETE, farmLoadedHandler);
preloader = new FarmPreloader();
addChild(preloader);
Config.currentLanguage = Languages.language;
var gc:GameController = new GameController();
mail_ru_connection = new LocalConnection();
mail_ru_connection.client = this;
connection_name = loaderInfo.parameters.lcom_name;
mail_ru_connection.connect((loaderInfo.parameters.lcom_name + "Back"));
if (loaderInfo.parameters.link != undefined){
Config.downloadLink = loaderInfo.parameters.link;
};
if (loaderInfo.parameters.alawar_f != undefined){
if (loaderInfo.parameters.alawar_f == "true"){
Config.downloadable = false;
};
};
if (loaderInfo.parameters.close_f != undefined){
Config.closeFunction = loaderInfo.parameters.close_f;
};
if (loaderInfo.parameters.target != undefined){
Config.target = loaderInfo.parameters.target;
};
if (loaderInfo.parameters.use_cheats != undefined){
if (loaderInfo.parameters.use_cheats == "true"){
Config.use_cheats = true;
};
};
if (((!((loaderInfo.parameters.language == undefined))) && (!((loaderInfo.parameters.country == undefined))))){
xmlLoaded = false;
language = loaderInfo.parameters.language;
Config.language = language;
country = loaderInfo.parameters.country;
loadLanguage();
};
//unresolved jump
var _slot1 = e;
trace(("Ошибка " + _slot1));
if (language == "ru"){
preloader.logo.gotoAndStop("ru");
preloader.alawar.gotoAndStop("ru");
};
var ldr:Loader = new Loader();
ldr.load(new URLRequest("logos/logo.png"));
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, logoLoaded, false, 0, true);
ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, farmLogoError, false, 0, true);
loadMusic();
}
public function destroy(... _args):void{
mail_ru_connection.close();
GameController.instance.destroy();
}
private function loadSoundError(event:IOErrorEvent=null):void{
musicLoaded = true;
SoundsList.gameMusicSound = null;
initGame();
}
private function farmLogoError(event:IOErrorEvent=null):void{
preloader.logo.visible = true;
}
private function error(event:IOErrorEvent=null):void{
}
private function logoLoaded(event:Event=null):void{
preloader.addChild(event.target.content);
event.target.content.x = 5;
event.target.content.y = (425 - event.target.content.height);
}
private function progressMusic(event:ProgressEvent):void{
musicCurrent = event.bytesLoaded;
musicTotal = event.bytesTotal;
}
private function progressHandler(event:ProgressEvent):void{
var loaded:uint = (event.bytesLoaded + musicCurrent);
var total:uint = (event.bytesTotal + musicTotal);
preloader.progress.line.gotoAndStop(Math.ceil(((loaded / total) * 100)));
}
private function loadLanguage():void{
preloader.logo.visible = false;
var xmlLoader:URLLoader = new URLLoader();
var xmlRequest:URLRequest = new URLRequest((((("localized/" + language) + "-") + country) + "/text/text.xml"));
var logoLoader:Loader = new Loader();
var logoRequest:URLRequest = new URLRequest((((("localized/" + language) + "-") + country) + "/images/logo.png"));
logoLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, farmLogoLoaded, false, 0, true);
logoLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, error, false, 0, true);
xmlLoader.addEventListener(Event.COMPLETE, xmlLoadedHandler);
logoLoader.addEventListener(Event.COMPLETE, farmLogoLoaded);
xmlLoader.load(xmlRequest);
//unresolved jump
var _slot1 = error;
logoLoader.load(logoRequest);
//unresolved jump
var _slot1 = error;
preloader.logo.visible = true;
}
private function loadMusic():void{
var request:URLRequest = new URLRequest(gameMusicPath);
SoundsList.gameMusicSound = new Sound();
SoundsList.gameMusicSound.addEventListener(Event.COMPLETE, gameMusicLoaded, false, 0, true);
SoundsList.gameMusicSound.addEventListener(IOErrorEvent.IO_ERROR, loadSoundError, false, 0, true);
SoundsList.gameMusicSound.addEventListener(ProgressEvent.PROGRESS, progressMusic);
SoundsList.gameMusicSound.load(request);
}
private function initGame(event:Event=null):void{
var event = event;
if (((((xmlLoaded) && (farmLoaded))) && (musicLoaded))){
preloader.progress.line.gotoAndStop(100);
Tweener.addTween(preloader, {alpha:0, time:2, delay:0.5, onComplete:function ():void{
this.visible = false;
}});
main();
};
}
private function farmLogoLoaded(event:Event=null):void{
FarmPreloader.externalLogo = new Sprite();
FarmPreloader.externalLogo.addChild(event.target.content);
FarmPreloader.externalLogo.x = 4;
FarmPreloader.externalLogo.y = 108;
preloader.addChild(FarmPreloader.externalLogo);
}
private function farmLoadedHandler(event:Event=null):void{
farmLoaded = true;
initGame();
}
private function xmlLoadedHandler(event:Event):void{
var loader:URLLoader = URLLoader(event.target);
var languageXML:XML = new XML(loader.data);
languageXML.ignoreWhitespace = true;
Config.currentLanguage = languageXML;
xmlLoaded = true;
initGame();
}
private function main():void{
var app:Object;
nextFrame();
var farmfrenzy2:Class = Class(getDefinitionByName("FarmFrenzy2"));
if (farmfrenzy2){
app = new (farmfrenzy2);
addChildAt((app as DisplayObject), 0);
};
}
private function gameMusicLoaded(event:Event):void{
musicLoaded = true;
initGame();
}
}
}//package
Section 242
//FarmFrenzy2 (FarmFrenzy2)
package {
import flash.events.*;
import flash.display.*;
import game.assets.*;
import shop.*;
import ui.*;
import flash.net.*;
import map.*;
import game.*;
import flash.text.*;
import utils.*;
import com.melesta.sound.*;
import com.melesta.utils.fps.*;
import flash.errors.*;
import caurina.transitions.*;
public class FarmFrenzy2 extends MovieClip {
private var shopWindow:ShopWindow;
private var arrow:FArrow;
private var uiContainer:MovieClip;
private var mail_ru_connection:LocalConnection;
private var map:MapWindow;
private var endScreen:EndScreen;
private var gameController:GameController;
private var gameContainer:MovieClip;
private var gameMenu:GameMenu;
private var startScreen:StartScreen;
private var levelBuilder:LevelBuilder;
private var assetsContainer:MovieClip;
public function FarmFrenzy2(){
super();
var pg:PlayGround = new PlayGround();
addChild(pg);
addEventListener(Event.ADDED_TO_STAGE, gameLoaded, false, 0, true);
stop();
}
private function loaded(event:Event=null):void{
startScreen.addChild(event.target.content);
event.target.content.x = 5;
event.target.content.y = (425 - event.target.content.height);
}
private function prepareFPSMeter():void{
}
private function error(event:IOErrorEvent=null):void{
}
public function gameLoaded(event:Event=null):void{
SoundsList.init();
gameController = new GameController();
gameController.addEventListener(GameController.DESTROY_GAME, destroy, false, 0, true);
gameController.addEventListener(GameController.START_GAME, startGame, false, 0, true);
gameContainer = new MovieClip();
addChild(gameContainer);
assetsContainer = new MovieClip();
gameContainer.addChild(assetsContainer);
uiContainer = new MovieClip();
addChild(uiContainer);
levelBuilder = new LevelBuilder();
levelBuilder.container = assetsContainer;
levelBuilder.prepareAllAssets();
startScreen = new StartScreen();
map = new MapWindow();
uiContainer.addChild(map);
uiContainer.addChild(startScreen);
startScreen.show();
shopWindow = new ShopWindow();
uiContainer.addChild(shopWindow);
var tooltip:Tooltip = new Tooltip();
uiContainer.addChild(tooltip);
var mapTooltip:MapTooltip = new MapTooltip();
uiContainer.addChild(mapTooltip);
var blockTooltip:BlockTooltip = new BlockTooltip();
uiContainer.addChild(blockTooltip);
var quitDialog:QuitDialog = new QuitDialog();
uiContainer.addChild(quitDialog);
gameMenu = new GameMenu(this);
endScreen = new EndScreen(this);
arrow = new FArrow(this);
var ldr:Loader = new Loader();
ldr.load(new URLRequest("logos/logo.png"));
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded, false, 0, true);
ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, error, false, 0, true);
var quitMenu:QuitMenu = new QuitMenu();
uiContainer.addChild(quitMenu);
}
public function startGame(event:Event=null):void{
}
public function destroy(event:Event=null):void{
GameController.instance.levelCompleted();
Tweener.removeAllTweens();
GameController.instance.destroy();
}
}
}//package
Section 243
//FlouryCakeHouseTemplate (FlouryCakeHouseTemplate)
package {
import flash.display.*;
public dynamic class FlouryCakeHouseTemplate extends MovieClip {
public var body:MovieClip;
public var activeArea:MovieClip;
}
}//package
Section 244
//fool_action (fool_action)
package {
import flash.media.*;
public dynamic class fool_action extends Sound {
}
}//package
Section 245
//house_board_landing (house_board_landing)
package {
import flash.media.*;
public dynamic class house_board_landing extends Sound {
}
}//package
Section 246
//house_click (house_click)
package {
import flash.media.*;
public dynamic class house_click extends Sound {
}
}//package
Section 247
//house_crash (house_crash)
package {
import flash.media.*;
public dynamic class house_crash extends Sound {
}
}//package
Section 248
//house_downgrade (house_downgrade)
package {
import flash.media.*;
public dynamic class house_downgrade extends Sound {
}
}//package
Section 249
//house_landing (house_landing)
package {
import flash.media.*;
public dynamic class house_landing extends Sound {
}
}//package
Section 250
//item_add (item_add)
package {
import flash.media.*;
public dynamic class item_add extends Sound {
}
}//package
Section 251
//item_cancel (item_cancel)
package {
import flash.media.*;
public dynamic class item_cancel extends Sound {
}
}//package
Section 252
//MapNodeTemplate (MapNodeTemplate)
package {
import flash.display.*;
public dynamic class MapNodeTemplate extends MovieClip {
public var silver:MovieClip;
public var none:MovieClip;
public var novel:MovieClip;
public var gold:MovieClip;
public var normal:MovieClip;
}
}//package
Section 253
//MapTemplate (MapTemplate)
package {
import flash.display.*;
public dynamic class MapTemplate extends MovieClip {
public var _shadow:MovieClip;
public var menuBtn:MovieClip;
public var shopBtn:MovieClip;
public var buyBtn:MovieClip;
}
}//package
Section 254
//MeatHouseTemplate (MeatHouseTemplate)
package {
import flash.display.*;
public dynamic class MeatHouseTemplate extends MovieClip {
public var body:MovieClip;
public var activeArea:MovieClip;
}
}//package
Section 255
//music_menu (music_menu)
package {
import flash.media.*;
public dynamic class music_menu extends Sound {
}
}//package
Section 256
//ostrich_voice (ostrich_voice)
package {
import flash.media.*;
public dynamic class ostrich_voice extends Sound {
}
}//package
Section 257
//pig_die (pig_die)
package {
import flash.media.*;
public dynamic class pig_die extends Sound {
}
}//package
Section 258
//pig_flyout (pig_flyout)
package {
import flash.media.*;
public dynamic class pig_flyout extends Sound {
}
}//package
Section 259
//pig_hungry (pig_hungry)
package {
import flash.media.*;
public dynamic class pig_hungry extends Sound {
}
}//package
Section 260
//pig_voice (pig_voice)
package {
import flash.media.*;
public dynamic class pig_voice extends Sound {
}
}//package
Section 261
//PreloaderTemplate (PreloaderTemplate)
package {
import flash.display.*;
public dynamic class PreloaderTemplate extends MovieClip {
public var progress:MovieClip;
public var alawar:MovieClip;
public var logo:MovieClip;
}
}//package
Section 262
//product_crack (product_crack)
package {
import flash.media.*;
public dynamic class product_crack extends Sound {
}
}//package
Section 263
//product_landing (product_landing)
package {
import flash.media.*;
public dynamic class product_landing extends Sound {
}
}//package
Section 264
//product_take (product_take)
package {
import flash.media.*;
public dynamic class product_take extends Sound {
}
}//package
Section 265
//QuitDialogTemplate (QuitDialogTemplate)
package {
import flash.display.*;
import flash.text.*;
public dynamic class QuitDialogTemplate extends MovieClip {
public var yesBtn:MovieClip;
public var noBtn:MovieClip;
public var caption:TextField;
}
}//package
Section 266
//QuitMenuTemplate (QuitMenuTemplate)
package {
import flash.display.*;
import flash.text.*;
public dynamic class QuitMenuTemplate extends MovieClip {
public var yesBtn:MovieClip;
public var ostrich:MovieClip;
public var noBtn:MovieClip;
public var caption:TextField;
}
}//package
Section 267
//ShopTemplate (ShopTemplate)
package {
import flash.display.*;
import flash.text.*;
public dynamic class ShopTemplate extends MovieClip {
public var cake:MovieClip;
public var depot:MovieClip;
public var title:TextField;
public var plane:MovieClip;
public var stars_txt:TextField;
public var dried:MovieClip;
public var fcake:MovieClip;
public var stake:MovieClip;
public var cage:MovieClip;
public var well:MovieClip;
public var car:MovieClip;
public var okBtn:MovieClip;
}
}//package
Section 268
//SimpleTooltipTemplate (SimpleTooltipTemplate)
package {
import flash.display.*;
import flash.text.*;
public dynamic class SimpleTooltipTemplate extends MovieClip {
public var okBtn:MovieClip;
public var caption:TextField;
}
}//package
Section 269
//StartScreenTemplate (StartScreenTemplate)
package {
import flash.display.*;
public dynamic class StartScreenTemplate extends MovieClip {
public var musicBtn:MovieClip;
public var exitBtn:MovieClip;
public var alawar:MovieClip;
public var logo:MovieClip;
public var soundBtn:MovieClip;
public var okBtn:MovieClip;
public var buyBtn:MovieClip;
}
}//package
Section 270
//tick_money (tick_money)
package {
import flash.media.*;
public dynamic class tick_money extends Sound {
}
}//package
Section 271
//tick_time (tick_time)
package {
import flash.media.*;
public dynamic class tick_time extends Sound {
}
}//package
Section 272
//TooltipTemplate (TooltipTemplate)
package {
import flash.display.*;
public dynamic class TooltipTemplate extends MovieClip {
public var help:MovieClip;
public var body:MovieClip;
}
}//package
Section 273
//ui_button_click (ui_button_click)
package {
import flash.media.*;
public dynamic class ui_button_click extends Sound {
}
}//package
Section 274
//ui_button_hover (ui_button_hover)
package {
import flash.media.*;
public dynamic class ui_button_hover extends Sound {
}
}//package
Section 275
//WaterTooltipTemplate (WaterTooltipTemplate)
package {
import flash.display.*;
import flash.text.*;
public dynamic class WaterTooltipTemplate extends MovieClip {
public var caption:TextField;
}
}//package
Section 276
//WorkLineTemplate (WorkLineTemplate)
package {
import flash.display.*;
public dynamic class WorkLineTemplate extends MovieClip {
public var line:MovieClip;
public function WorkLineTemplate(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package