Section 1
//KongregateEvent (com.kongregate.as3.client.events.KongregateEvent)
package com.kongregate.as3.client.events {
import flash.events.*;
public class KongregateEvent extends Event {
public static const COMPLETE:String = "component_api_available";
public function KongregateEvent(_arg1:String){
super(_arg1);
}
}
}//package com.kongregate.as3.client.events
Section 2
//AbstractShadowService (com.kongregate.as3.client.services.AbstractShadowService)
package com.kongregate.as3.client.services {
import flash.events.*;
public class AbstractShadowService extends EventDispatcher {
protected function alert(_arg1:String, _arg2:String, _arg3="", _arg4:String=""):void{
trace(((((((("Kongregate API: " + _arg1) + ".") + _arg2) + "(") + _arg3) + ") ") + _arg4));
}
}
}//package com.kongregate.as3.client.services
Section 3
//HighScoreServiceShadow (com.kongregate.as3.client.services.HighScoreServiceShadow)
package com.kongregate.as3.client.services {
public class HighScoreServiceShadow extends AbstractShadowService implements IHighScoreServices {
private var mode:String;
public function HighScoreServiceShadow(){
mode = "";
}
public function submit(_arg1:Number, _arg2:String=null):void{
alert("IHighScoreServices", "submit", arguments);
}
public function connect():Boolean{
alert("IKongregateServices", "connect");
return (true);
}
public function requestList(_arg1:Function):void{
alert("IHighScoreServices", "requestList", "", (("[Mode: " + mode) + "]"));
_arg1({success:false});
}
public function setMode(_arg1:String):void{
alert("IHighScoreServices", "setMode", arguments);
this.mode = _arg1;
}
}
}//package com.kongregate.as3.client.services
Section 4
//IHighScoreServices (com.kongregate.as3.client.services.IHighScoreServices)
package com.kongregate.as3.client.services {
public interface IHighScoreServices {
function setMode(_arg1:String):void;
function submit(_arg1:Number, _arg2:String=null):void;
function requestList(_arg1:Function):void;
}
}//package com.kongregate.as3.client.services
Section 5
//IKongregateServices (com.kongregate.as3.client.services.IKongregateServices)
package com.kongregate.as3.client.services {
import flash.events.*;
public interface IKongregateServices extends IEventDispatcher {
function getPlayerInfo(_arg1:Function):void;
function connect(_arg1:Number=-1):Boolean;
}
}//package com.kongregate.as3.client.services
Section 6
//IStatServices (com.kongregate.as3.client.services.IStatServices)
package com.kongregate.as3.client.services {
public interface IStatServices {
function submitArray(_arg1:Array):void;
function submit(_arg1:String, _arg2:Number):void;
}
}//package com.kongregate.as3.client.services
Section 7
//IUserServices (com.kongregate.as3.client.services.IUserServices)
package com.kongregate.as3.client.services {
public interface IUserServices {
function getName():String;
function getPlayerInfo(_arg1:Function):void;
}
}//package com.kongregate.as3.client.services
Section 8
//KongregateServiceShadow (com.kongregate.as3.client.services.KongregateServiceShadow)
package com.kongregate.as3.client.services {
public class KongregateServiceShadow extends AbstractShadowService implements IKongregateServices {
public function getName():String{
alert("IKongregateServices", "getName");
return ("Guest");
}
public function connect(_arg1:Number=-1):Boolean{
alert("IKongregateServices", "connect", arguments);
return (true);
}
public function getPlayerInfo(_arg1:Function):void{
alert("IKongregateServices", "getPlayerInfo");
_arg1(new Object());
}
}
}//package com.kongregate.as3.client.services
Section 9
//StatServiceShadow (com.kongregate.as3.client.services.StatServiceShadow)
package com.kongregate.as3.client.services {
public class StatServiceShadow extends AbstractShadowService implements IStatServices {
public function submitArray(_arg1:Array):void{
alert("IStatServices", "submitArray", arguments);
}
public function submit(_arg1:String, _arg2:Number):void{
alert("IStatServices", "submitStat", arguments);
}
}
}//package com.kongregate.as3.client.services
Section 10
//UserServiceShadow (com.kongregate.as3.client.services.UserServiceShadow)
package com.kongregate.as3.client.services {
public class UserServiceShadow extends AbstractShadowService implements IUserServices {
public function getName():String{
alert("UserService", "getName");
return ("Guest");
}
public function getPlayerInfo(_arg1:Function):void{
alert("UserService", "getPlayerInfo");
_arg1({isGuest:true, name:"Guest", points:0, level:0, isMode:false, isAdmin:false, isDeveloper:false, avatarPath:"", chatAvatarPath:""});
}
}
}//package com.kongregate.as3.client.services
Section 11
//IAPIBootstrap (com.kongregate.as3.client.IAPIBootstrap)
package com.kongregate.as3.client {
import flash.events.*;
import flash.display.*;
public interface IAPIBootstrap {
function init(_arg1:Event=null, _arg2:Stage=null):void;
function hideLog():void;
function showLog(_arg1:int=0):void;
}
}//package com.kongregate.as3.client
Section 12
//KongregateAPI (com.kongregate.as3.client.KongregateAPI)
package com.kongregate.as3.client {
import flash.events.*;
import flash.display.*;
import com.kongregate.as3.client.services.*;
import flash.system.*;
import com.kongregate.as3.client.events.*;
import flash.utils.*;
import flash.errors.*;
import flash.net.*;
public class KongregateAPI extends Sprite {
private const VERSION:Number = 1;
private var loader:Loader;
private var loadedDomain:ApplicationDomain;
private static const CLASS_USER:String = "com.kongregate.as3.client.services.UserServices";
private static const CLASS_STATS:String = "com.kongregate.as3.client.services.StatServices";
private static const CLASS_SERVICES:String = "com.kongregate.as3.client.services.KongregateServices";
private static const CLASS_SCORES:String = "com.kongregate.as3.client.services.HighScoreServices";
private static const DEBUG_API_URL:String = "//Linuxpc/kongregate/public/flash/API_AS3.swf";
private static var _connected:Boolean;
private static var kUser:IUserServices;
private static var _loaded:Boolean;
private static var kServices:IKongregateServices;
private static var kScores:IHighScoreServices;
private static var mInstance:KongregateAPI;
private static var kStats:IStatServices;
private static var kAPI:IAPIBootstrap;
public function KongregateAPI(){
if (mInstance != null){
throw (new Error("Warning: KongregateAPI has been added to stage more than once or accessed improperly. Use getInstance() or a stage reference to access."));
};
mInstance = this;
this.addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
}
public function get loaded():Boolean{
return (_loaded);
}
public function get connected():Boolean{
return (_connected);
}
private function alertConnected(_arg1:TimerEvent=null):void{
var _local2:KongregateEvent;
var _local3:Boolean;
_local2 = new KongregateEvent(KongregateEvent.COMPLETE);
_local3 = this.dispatchEvent(_local2);
}
private function init(_arg1:Event):void{
var _local2:Object;
var _local3:String;
var _local4:URLRequest;
var _local5:LoaderContext;
this.removeEventListener(Event.ADDED_TO_STAGE, init);
_loaded = false;
_connected = false;
_local2 = LoaderInfo(root.loaderInfo).parameters;
_local3 = _local2.api_path;
if (_local3 == null){
trace("Alert: Kongregate API could not be loaded, due to local testing. API will load when the game is uploaded.");
createShadowServices();
return;
};
Security.allowDomain("*.kongregate.com");
Security.allowDomain("kongregatetrunk.com");
_local4 = new URLRequest(_local3);
_local5 = new LoaderContext(false);
_local5.applicationDomain = ApplicationDomain.currentDomain;
_local5.securityDomain = SecurityDomain.currentDomain;
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.load(_local4, _local5);
}
public function get api():IAPIBootstrap{
return (kAPI);
}
private function loadComplete(_arg1:Event):void{
getServices();
}
public function get scores():IHighScoreServices{
return (kScores);
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
throw (new IOError(("API file not found. " + _arg1)));
}
public function get services():IKongregateServices{
return (kServices);
}
public function get stats():IStatServices{
return (kStats);
}
private function createShadowServices():void{
var _local1:Timer;
trace(">>> Kongregate Shadow Services instantiated for local development..");
kServices = new KongregateServiceShadow();
kScores = new HighScoreServiceShadow();
kStats = new StatServiceShadow();
kUser = new UserServiceShadow();
_local1 = new Timer(200, 1);
_local1.addEventListener(TimerEvent.TIMER_COMPLETE, alertConnected);
_local1.start();
_connected = true;
}
public function get user():IUserServices{
return (kUser);
}
private function getServices():void{
var _local1:ApplicationDomain;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
_local1 = ApplicationDomain.currentDomain;
kAPI = IAPIBootstrap(loader.getChildAt(0));
this.addChild(loader);
_local2 = _local1.getDefinition(CLASS_SERVICES);
trace(_local2);
kServices = _local2.getInstance();
_local3 = _local1.getDefinition(CLASS_SCORES);
kScores = _local3.getInstance();
_local4 = _local1.getDefinition(CLASS_STATS);
kStats = _local4.getInstance();
_local5 = _local1.getDefinition(CLASS_USER);
kUser = _local5.getInstance();
kServices.connect(VERSION);
_loaded = true;
_connected = true;
alertConnected();
}
public static function getInstance():KongregateAPI{
if (!mInstance){
throw (new IllegalOperationError("You must add the Kongregate API component to the stage before attempting to access it."));
};
return (mInstance);
}
}
}//package com.kongregate.as3.client
Section 13
//BitmapAsset (mx.core.BitmapAsset)
package mx.core {
import flash.display.*;
public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject {
mx_internal static const VERSION:String = "3.2.0.3958";
public function BitmapAsset(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
public function get measuredWidth():Number{
if (bitmapData){
return (bitmapData.width);
};
return (0);
}
public function get measuredHeight():Number{
if (bitmapData){
return (bitmapData.height);
};
return (0);
}
public function setActualSize(_arg1:Number, _arg2:Number):void{
width = _arg1;
height = _arg2;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
}
}//package mx.core
Section 14
//FlexBitmap (mx.core.FlexBitmap)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexBitmap extends Bitmap {
mx_internal static const VERSION:String = "3.2.0.3958";
public function FlexBitmap(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
var bitmapData = _arg1;
var pixelSnapping = _arg2;
var smoothing = _arg3;
super(bitmapData, pixelSnapping, smoothing);
try {
name = NameUtil.createUniqueName(this);
} catch(e:Error) {
};
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 15
//FontAsset (mx.core.FontAsset)
package mx.core {
import flash.text.*;
public class FontAsset extends Font implements IFlexAsset {
mx_internal static const VERSION:String = "3.2.0.3958";
}
}//package mx.core
Section 16
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 17
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.accessibility.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get visible():Boolean;
function get rotation():Number;
function localToGlobal(_arg1:Point):Point;
function get name():String;
function set width(_arg1:Number):void;
function get measuredHeight():Number;
function get blendMode():String;
function get scale9Grid():Rectangle;
function set name(_arg1:String):void;
function set scaleX(_arg1:Number):void;
function set scaleY(_arg1:Number):void;
function get measuredWidth():Number;
function get accessibilityProperties():AccessibilityProperties;
function set scrollRect(_arg1:Rectangle):void;
function get cacheAsBitmap():Boolean;
function globalToLocal(_arg1:Point):Point;
function get height():Number;
function set blendMode(_arg1:String):void;
function get parent():DisplayObjectContainer;
function getBounds(_arg1:DisplayObject):Rectangle;
function get opaqueBackground():Object;
function set scale9Grid(_arg1:Rectangle):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set alpha(_arg1:Number):void;
function set accessibilityProperties(_arg1:AccessibilityProperties):void;
function get width():Number;
function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean;
function set cacheAsBitmap(_arg1:Boolean):void;
function get scaleX():Number;
function get scaleY():Number;
function get scrollRect():Rectangle;
function get mouseX():Number;
function get mouseY():Number;
function set height(_arg1:Number):void;
function set mask(_arg1:DisplayObject):void;
function getRect(_arg1:DisplayObject):Rectangle;
function get alpha():Number;
function set transform(_arg1:Transform):void;
function move(_arg1:Number, _arg2:Number):void;
function get loaderInfo():LoaderInfo;
function get root():DisplayObject;
function hitTestObject(_arg1:DisplayObject):Boolean;
function set opaqueBackground(_arg1:Object):void;
function set visible(_arg1:Boolean):void;
function get mask():DisplayObject;
function set x(_arg1:Number):void;
function set y(_arg1:Number):void;
function get transform():Transform;
function set filters(_arg1:Array):void;
function get x():Number;
function get y():Number;
function get filters():Array;
function set rotation(_arg1:Number):void;
function get stage():Stage;
}
}//package mx.core
Section 18
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(_arg1:Array):void;
function get isDocument():Boolean;
function set repeaters(_arg1:Array):void;
function initializeRepeaterArrays(_arg1:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(_arg1:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 19
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 20
//SoundAsset (mx.core.SoundAsset)
package mx.core {
import flash.media.*;
public class SoundAsset extends Sound implements IFlexAsset {
mx_internal static const VERSION:String = "3.2.0.3958";
}
}//package mx.core
Section 21
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import flash.display.*;
import mx.core.*;
import flash.utils.*;
public class NameUtil {
mx_internal static const VERSION:String = "3.2.0.3958";
private static var counter:int = 0;
public static function displayObjectToString(_arg1:DisplayObject):String{
var result:String;
var o:DisplayObject;
var s:String;
var indices:Array;
var displayObject = _arg1;
try {
o = displayObject;
while (o != null) {
if (((((o.parent) && (o.stage))) && ((o.parent == o.stage)))){
break;
};
s = o.name;
if ((o is IRepeaterClient)){
indices = IRepeaterClient(o).instanceIndices;
if (indices){
s = (s + (("[" + indices.join("][")) + "]"));
};
};
result = ((result == null)) ? s : ((s + ".") + result);
o = o.parent;
};
} catch(e:SecurityError) {
};
return (result);
}
public static function createUniqueName(_arg1:Object):String{
if (!_arg1){
return (null);
};
var _local2:String = getQualifiedClassName(_arg1);
var _local3:int = _local2.indexOf("::");
if (_local3 != -1){
_local2 = _local2.substr((_local3 + 2));
};
var _local4:int = _local2.charCodeAt((_local2.length - 1));
if ((((_local4 >= 48)) && ((_local4 <= 57)))){
_local2 = (_local2 + "_");
};
return ((_local2 + counter++));
}
}
}//package mx.utils
Section 22
//Boat (sitting.Boat)
package sitting {
public class Boat extends Animated {
private static var img:Class = Boat_img;
public function Boat(){
super(new img().bitmapData);
anchor.x = (w / 2);
anchor.y = h;
z = Sitting.Z_BOAT;
floats = true;
}
private function overMe(_arg1:Entity):Boolean{
return ((((_arg1.restingOver == this)) && ((_arg1 is Person))));
}
public function rower():Person{
var _local1:Array = world.filterEntities(overMe);
var _local2:int;
while (_local2 != _local1.length) {
if ((_local1[_local2] as Person).rowingSpeed() > 0){
return (Person(_local1[_local2]));
};
_local2++;
};
return (null);
}
}
}//package sitting
Section 23
//Boat_img (sitting.Boat_img)
package sitting {
import mx.core.*;
public class Boat_img extends BitmapAsset {
}
}//package sitting
Section 24
//Boy (sitting.Boy)
package sitting {
import flash.display.*;
import flash.geom.*;
import utils.*;
public class Boy extends Person {
private var kneeling:BitmapData;
private var moonAnim:Animation;
private var sittingImg:BitmapData;
public var hasMoon:Boolean;// = false
private static var img:Class = Boy_img;
private static var img_rowing:Class = Boy_img_rowing;
private static var img_falling:Class = Boy_img_falling;
private static var img_mooned:Class = Boy_img_mooned;
private static var img_kneeled:Class = Boy_img_kneeled;
public function Boy(){
super(new img().bitmapData, 10, 18);
rowingAnim = new Animation(new img_rowing().bitmapData, 13, 19, 250);
sittingAnim = new Animation(new img().bitmapData, 13, 18, 0);
fallingAnim = new Animation(new img_falling().bitmapData, 13, 18, 200);
moonAnim = new Animation(new img_mooned().bitmapData, 16, 18, 0);
anim = sittingAnim;
anim.play(true);
kneeling = new img_kneeled().bitmapData;
sittingImg = new img().bitmapData;
updates.unshift(doDrown, doFall, doSkywatch, doSitHappily, doRow, doSmallMoon, doWatchGirl, doBeSad, doWatchMoon);
}
override protected function eyes():Point{
var _local1:Point = new Point(6, 5);
if (anim == fallingAnim){
lookingDir = 0;
_local1.x = (_local1.x - 3);
_local1.y = (_local1.y - 3);
} else {
if (anim == rowingAnim){
_local1.x = (_local1.x + 1);
_local1.y = (_local1.y - 4);
} else {
if (anim == moonAnim){
_local1.x = (_local1.x - 3);
} else {
if (anim == sittingAnim){
_local1.x = (_local1.x + 1);
if (lookingDir == 1){
_local1.x = (_local1.x - 3);
};
};
};
};
};
if (lookingDir == 1){
_local1.x = (_local1.x - 3);
};
return (_local1);
}
protected function doWatchMoon():Boolean{
if (!Sitting.moon.isGone()){
anim = sittingAnim;
anim.play(true);
expression.sadLooking(Sitting.moon);
return (true);
};
return (false);
}
protected function doWatchGirl():Boolean{
if (((Sitting.girl.isOnMoon()) && (Sitting.girl.isHarping()))){
anim = sittingAnim;
anim.play(true);
expression.seek(Sitting.girl);
return (true);
};
return (false);
}
protected function doBeSad():Boolean{
if (Sitting.moon.isGone()){
anim = sittingAnim;
anim.play(true);
expression.sad();
return (true);
};
return (false);
}
override public function isGone():Boolean{
return (((super.isGone()) || (Sitting.gull.goneBoy)));
}
protected function doSitHappily():Boolean{
if (isOnMoon()){
lookingDir = 0;
anim = sittingAnim;
anim.play(true);
if (Sitting.moon.isSinking()){
expression.seek(Sitting.moon);
} else {
expression.happy();
};
return (true);
};
return (false);
}
override public function draw(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
if ((((anim == sittingAnim)) && ((((expression.status == Expression.SAD_LOOKING)) || ((expression.status == Expression.SAD_LONELY)))))){
sittingAnim.strip.img = kneeling;
} else {
sittingAnim.strip.img = sittingImg;
};
super.draw(_arg1, _arg2, _arg3);
}
protected function doSmallMoon():Boolean{
if (((!(hasMoon)) && (isTouching(Sitting.smallMoon)))){
hasMoon = true;
Sitting.main.removeEntity(Sitting.smallMoon);
};
if (hasMoon){
anim = moonAnim;
expression.happy();
return (true);
};
return (false);
}
}
}//package sitting
Section 25
//Boy_img (sitting.Boy_img)
package sitting {
import mx.core.*;
public class Boy_img extends BitmapAsset {
}
}//package sitting
Section 26
//Boy_img_falling (sitting.Boy_img_falling)
package sitting {
import mx.core.*;
public class Boy_img_falling extends BitmapAsset {
}
}//package sitting
Section 27
//Boy_img_kneeled (sitting.Boy_img_kneeled)
package sitting {
import mx.core.*;
public class Boy_img_kneeled extends BitmapAsset {
}
}//package sitting
Section 28
//Boy_img_mooned (sitting.Boy_img_mooned)
package sitting {
import mx.core.*;
public class Boy_img_mooned extends BitmapAsset {
}
}//package sitting
Section 29
//Boy_img_rowing (sitting.Boy_img_rowing)
package sitting {
import mx.core.*;
public class Boy_img_rowing extends BitmapAsset {
}
}//package sitting
Section 30
//BoyGull (sitting.BoyGull)
package sitting {
public class BoyGull extends Animated {
private static var img:Class = BoyGull_img;
public function BoyGull(){
super(new img().bitmapData, 7, 3, 350);
anchor.y = (h / 2);
gravity = false;
background = true;
anim.play(true);
z = Sitting.Z_BACK_GULL;
}
override public function update():void{
x = (x - 0.35);
if (x < (-(w) * 3)){
teleport(world.w, 90);
};
super.update();
}
}
}//package sitting
Section 31
//BoyGull_img (sitting.BoyGull_img)
package sitting {
import mx.core.*;
public class BoyGull_img extends BitmapAsset {
}
}//package sitting
Section 32
//Firefly (sitting.Firefly)
package sitting {
import flash.display.*;
import utils.*;
public class Firefly extends Animated {
private var wasVisible:Boolean;// = false
private static var img:Class = Firefly_img;
public function Firefly(){
super(new img().bitmapData, 11, 11, Utils.rand(30, 80));
anim.setBouncingSequence();
anim.play(true);
background = true;
gravity = false;
z = Sitting.Z_FIRE;
}
override public function update():void{
x = (x - 0.7);
y = (y + 0.7);
if (isInside()){
wasVisible = true;
} else {
if (wasVisible){
world.removeEntity(this);
};
};
super.update();
}
override public function onAdded():void{
super.onAdded();
x = Utils.rand(30, (world.w + 60));
y = Utils.rand(0, 20);
}
override public function draw(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
super.draw(_arg1, int(_arg2), int(_arg3));
}
override public function onPlaced(_arg1:Number, _arg2:Number):void{
var _local3:Firefly;
_local3 = new Firefly();
world.addEntityAt(_local3, _arg1, _arg2);
_local3.x = _arg1;
_local3.y = _arg2;
snapped = false;
}
}
}//package sitting
Section 33
//Firefly_img (sitting.Firefly_img)
package sitting {
import mx.core.*;
public class Firefly_img extends BitmapAsset {
}
}//package sitting
Section 34
//Flower (sitting.Flower)
package sitting {
public class Flower extends Animated {
private static var img:Class = Flower_img;
public function Flower(){
super(new img().bitmapData);
z = Sitting.Z_BOAT;
gravity = false;
background = true;
anchor.x = w;
anchor.y = h;
}
}
}//package sitting
Section 35
//Flower_img (sitting.Flower_img)
package sitting {
import mx.core.*;
public class Flower_img extends BitmapAsset {
}
}//package sitting
Section 36
//Girl (sitting.Girl)
package sitting {
import flash.geom.*;
import mx.core.*;
import utils.*;
import flash.media.*;
public class Girl extends Person {
private var music:SoundChannel;
private var isSatisfied:Boolean;// = false
private var hasHarp:Boolean;// = false
private var music_sound:SoundAsset;
private var music_asset:Class;
private var harpingAnim:Animation;
private static const ACTIVITY_HARPING:int = 2;
private static var img_sitting:Class = Girl_img_sitting;
private static var img_harp:Class = Girl_img_harp;
private static var img_fall:Class = Girl_img_fall;
private static var img:Class = Girl_img;
public function Girl(){
music_asset = Girl_music_asset;
super(new img_sitting().bitmapData, 13, 19, 250);
music_sound = (new music_asset() as SoundAsset);
anim.play(true);
rowingAnim = new Animation(new img().bitmapData, 13, 19, 250);
fallingAnim = new Animation(new img_fall().bitmapData, 13, 19, 150);
sittingAnim = new Animation(new img_sitting().bitmapData, 13, 19, 0);
harpingAnim = new Animation(new img_harp().bitmapData, 13, 19, 800);
harpingAnim.play(true);
fallingAnim.play(true);
anim = rowingAnim;
updates.unshift(doDrown, doWantToHarp, doFall, doSkywatch, doRow, doBeAngry, doBeSad, doBeRegretful, doSit);
}
override public function onRemoved():void{
if (music != null){
music.stop();
};
super.onRemoved();
}
public function isHarping():Boolean{
return (hasHarp);
}
protected function doBeRegretful():Boolean{
if (Sitting.boy.expression.status == Expression.SAD_LOOKING){
activity = NONE;
anim = sittingAnim;
anim.stop();
expression.sadLooking(Sitting.boy);
return (true);
};
return (false);
}
override protected function eyes():Point{
var _local1:Point = new Point(7, 6);
if (isFalling){
_local1.y = 5;
} else {
if (anim == rowingAnim){
_local1.y = (_local1.y - 4);
} else {
if (anim == harpingAnim){
_local1.x = (_local1.x - 3);
_local1.y = (_local1.y + 1);
};
};
};
if (lookingDir == 1){
if (anim != harpingAnim){
_local1.x = (_local1.x - 6);
};
};
return (_local1);
}
protected function doSit():Boolean{
activity = NONE;
anim = sittingAnim;
anim.stop();
if (((isOnMoon()) && (Sitting.moon.isSinking()))){
expression.seek(Sitting.moon);
} else {
expression.sadLooking(Sitting.boy);
};
return (false);
}
protected function doWantToHarp():Boolean{
if (((Sitting.boy.isOnBoat()) && (isOnMoon()))){
if (isHarping()){
isSatisfied = true;
activity = ACTIVITY_HARPING;
expression.focused();
anim = harpingAnim;
hasHarp = true;
return (true);
};
lookingDir = ((area().x > Sitting.boy.area().x)) ? 1 : 0;
activity = NONE;
anim = sittingAnim;
anim.stop();
expression.seek(Sitting.boy);
hasHarp = true;
music = music_sound.play(0, 4);
return (true);
} else {
hasHarp = false;
if (music != null){
music.stop();
};
};
return (false);
}
protected function doPlayHarp():Boolean{
if (hasHarp){
isSatisfied = true;
activity = ACTIVITY_HARPING;
expression.happy();
anim = harpingAnim;
return (true);
};
return (false);
}
override public function chaseMoon():Boolean{
return (Sitting.boy.isOnMoon());
}
protected function doBeSad():Boolean{
if (Sitting.boy.isGone()){
if (!isHarping()){
activity = NONE;
anim = sittingAnim;
anim.stop();
expression.sad();
return (true);
};
};
return (false);
}
protected function doBeAngry():Boolean{
if (((Sitting.boy.hasMoon) && (isOnBoat()))){
expression.angry(Sitting.boy);
anim.stop();
anim = sittingAnim;
return (true);
};
return (false);
}
override public function getGravityPull():Number{
return (0.75);
}
override public function update():void{
isSatisfied = false;
activity = NONE;
super.update();
}
}
}//package sitting
Section 37
//Girl_img (sitting.Girl_img)
package sitting {
import mx.core.*;
public class Girl_img extends BitmapAsset {
}
}//package sitting
Section 38
//Girl_img_fall (sitting.Girl_img_fall)
package sitting {
import mx.core.*;
public class Girl_img_fall extends BitmapAsset {
}
}//package sitting
Section 39
//Girl_img_harp (sitting.Girl_img_harp)
package sitting {
import mx.core.*;
public class Girl_img_harp extends BitmapAsset {
}
}//package sitting
Section 40
//Girl_img_sitting (sitting.Girl_img_sitting)
package sitting {
import mx.core.*;
public class Girl_img_sitting extends BitmapAsset {
}
}//package sitting
Section 41
//Girl_music_asset (sitting.Girl_music_asset)
package sitting {
import mx.core.*;
public class Girl_music_asset extends SoundAsset {
}
}//package sitting
Section 42
//GirlGull (sitting.GirlGull)
package sitting {
import utils.*;
public class GirlGull extends Animated {
private var lastTear:Number;// = 0
private static var img:Class = GirlGull_img;
public function GirlGull(){
super(new img().bitmapData, 7, 9, 350);
anchor.y = (h / 2);
gravity = false;
background = true;
if (!Sitting.boy.isGone()){
anim.play(true);
};
z = Sitting.Z_BACK_GULL;
}
override public function update():void{
x = (x - 0.35);
lastTear = (lastTear + Utils.frameTime());
if (lastTear > 1500){
lastTear = 0;
world.addEntityAt(new Tear(), (area().x + 3), (area().y + 2));
};
if (x < (-(w) * 3)){
if (Sitting.main.countFlowers() > 0){
world.removeEntity(this);
} else {
teleport(world.w, 90);
};
};
super.update();
}
}
}//package sitting
Section 43
//GirlGull_img (sitting.GirlGull_img)
package sitting {
import mx.core.*;
public class GirlGull_img extends BitmapAsset {
}
}//package sitting
Section 44
//Gull (sitting.Gull)
package sitting {
import flash.geom.*;
import utils.*;
public class Gull extends Animated {
public var goneGirl:Boolean;// = false
public var goneBoy:Boolean;// = false
private static var img:Class = Gull_img;
public function Gull(){
super(new img().bitmapData, 15, 12, 200);
anim.play(true);
anchor.y = (h / 2);
gravity = false;
z = Sitting.Z_BIRD;
}
override public function update():void{
x = (x - 0.5);
if (x < (-(w) * 3)){
if (((!(Sitting.boy.isOnGull())) && (Sitting.girl.isOnGull()))){
world.removeEntity(this);
world.removeEntity(Sitting.girl);
world.addEntityAt(new GirlGull(), x, y);
goneGirl = true;
};
if (((Sitting.boy.isOnGull()) && (!(Sitting.girl.isOnGull())))){
world.removeEntity(this);
world.removeEntity(Sitting.boy);
world.addEntityAt(new BoyGull(), x, y);
goneBoy = true;
} else {
teleport(world.w, Utils.rand(39, (95 - h)));
};
};
super.update();
}
override public function collisionArea():Rectangle{
var _local1:Rectangle = area();
_local1.y = (_local1.y + 7);
_local1.height = (_local1.height - 7);
return (_local1);
}
}
}//package sitting
Section 45
//Gull_img (sitting.Gull_img)
package sitting {
import mx.core.*;
public class Gull_img extends BitmapAsset {
}
}//package sitting
Section 46
//Horizon (sitting.Horizon)
package sitting {
public class Horizon extends Animated {
private static var img:Class = Horizon_img;
public function Horizon(){
super(new img().bitmapData);
z = Sitting.Z_MOUNTAINS;
gravity = false;
background = true;
}
}
}//package sitting
Section 47
//Horizon_img (sitting.Horizon_img)
package sitting {
import mx.core.*;
public class Horizon_img extends BitmapAsset {
}
}//package sitting
Section 48
//Moon (sitting.Moon)
package sitting {
import flash.geom.*;
public class Moon extends Animated {
private var horizon:Number;
private static var img:Class = Moon_img;
public function Moon(){
super(new img().bitmapData);
anchor.x = (w / 2);
anchor.y = (h / 2);
gravity = false;
floats = false;
z = Sitting.Z_MOON;
}
override public function update():void{
var _local1:Array;
if ((area().top + (area().height / 2)) > Sitting.water.area().top){
y = (y + 0.3);
} else {
_local1 = restingOverMe();
if (_local1.length == 0){
y = (y - 0.3);
} else {
if ((((_local1.length > 1)) || ((distanceToHorizon() > 0.3)))){
y = (y + 0.3);
} else {
if (_local1.length == 1){
y = (y - 0.3);
};
};
};
};
super.update();
}
override public function onAdded():void{
horizon = y;
super.onAdded();
}
public function distanceToHorizon():Number{
return ((horizon - y));
}
override public function canHit(_arg1:Entity):Boolean{
if (_arg1 == Sitting.water){
return (false);
};
return (super.canHit(_arg1));
}
public function isSinking():Boolean{
return ((y > 100));
}
public function isGone():Boolean{
return ((y < 0));
}
private function overMe(_arg1:Entity):Boolean{
return ((((_arg1.restingOver == this)) && ((_arg1 is Person))));
}
private function isFar():Boolean{
return ((x > 75));
}
override public function collisionArea():Rectangle{
var _local1:Rectangle = super.collisionArea();
_local1.y = (_local1.y + 1);
_local1.height = (_local1.height - 1);
return (_local1);
}
}
}//package sitting
Section 49
//Moon_img (sitting.Moon_img)
package sitting {
import mx.core.*;
public class Moon_img extends BitmapAsset {
}
}//package sitting
Section 50
//Person (sitting.Person)
package sitting {
import flash.display.*;
import flash.geom.*;
import utils.*;
public class Person extends Animated {
protected var rowingFast:Boolean;// = false
private var heart:BitmapData;
protected var updates:Array;
protected var activity:int;// = 0
public var expression:Expression;
public var drown:Boolean;// = false
protected var rowingAnim:Animation;
protected var sittingAnim:Animation;
protected var fallingAnim:Animation;
protected static const NONE:int = 0;
protected static const ACTIVITY_ROWING:int = 1;
private static var img_love:Class = Person_img_love;
public function Person(_arg1:BitmapData, _arg2:int, _arg3:int, _arg4:int=-1){
updates = new Array();
super(_arg1, _arg2, _arg3, _arg4);
heart = new img_love().bitmapData;
anchor.y = h;
anchor.x = (w / 2);
expression = new Expression(this);
z = Sitting.Z_GIRL;
}
protected function doSkywatch():Boolean{
var fire:Firefly;
if (((Sitting.main.fireworks) && (!(isFalling)))){
anim.stop();
anim = sittingAnim;
fire = (world.closestThat(this, function (_arg1:Entity):Boolean{
return ((((((((_arg1 is Firefly)) && (_arg1.alive))) && ((_arg1.y < 90)))) && (_arg1.isInside())));
}) as Firefly);
if (fire != null){
expression.seek(fire);
} else {
expression.happy();
};
return (true);
};
return (false);
}
protected function seekOther():void{
lookingDir = ((area().x < myOther.area().x)) ? 0 : 1;
expression.seek(myOther);
}
override public function update():void{
var _local1:int;
while (_local1 != updates.length) {
if (updates[_local1]()){
break;
};
_local1++;
};
super.update();
}
override public function draw(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
super.draw(_arg1, _arg2, _arg3);
expression.draw(_arg1, (int(_arg2) + eyes().x), (int(_arg3) + eyes().y));
if (expression.status == Expression.HAPPY){
if (lookingDir == 0){
Utils.drawImage(_arg1, heart, ((_arg2 + (w / 2)) + 4), (_arg3 - 1));
} else {
Utils.drawImage(_arg1, heart, (((_arg2 + (w / 2)) - heart.width) - 4), (_arg3 - 1));
};
};
}
override public function area():Rectangle{
var _local1:Rectangle = super.area();
if (anim == rowingAnim){
_local1.height = (rowingAnim.strip.frameH - 4);
};
return (_local1);
}
public function isOnBoat():Boolean{
return ((((restingOver == Sitting.boat)) && (!(Sitting.boat.isFalling))));
}
public function isOnMoon():Boolean{
return ((((restingOver == Sitting.moon)) && (!(isFalling))));
}
public function get myOther():Entity{
return (((this == Sitting.boy)) ? Sitting.moon : Sitting.boy);
}
public function chaseMoon():Boolean{
return (true);
}
public function rowingSpeed():Number{
if (activity == ACTIVITY_ROWING){
if (rowingFast){
return ((Sitting.SCENE_SPEED * 2));
};
return (Sitting.SCENE_SPEED);
};
return (0);
}
protected function eyes():Point{
return (new Point());
}
override public function canHit(_arg1:Entity):Boolean{
if ((_arg1 is Person)){
return (false);
};
return (super.canHit(_arg1));
}
protected function doFall():Boolean{
if (isFalling){
anim = fallingAnim;
anim.play(true);
expression.lookDown();
return (true);
};
return (false);
}
protected function doRow():Boolean{
if (((((chaseMoon()) && (!(Sitting.moon.isGone())))) && (isOnBoat()))){
activity = ACTIVITY_ROWING;
anim = rowingAnim;
y = (y + 4);
if (Math.abs((Sitting.moon.x - Sitting.boat.x)) > Sitting.IDEAL_MOON_DISTANCE){
rowingFast = true;
expression.efforting(myOther);
anim.setFrameTime(100);
} else {
rowingFast = false;
expression.sadLooking(myOther);
if (Sitting.girl.isHarping()){
expression.seek(Sitting.moon);
};
anim.setFrameTime(300);
};
anim.play(true);
lookingDir = ((myOther.area().x > area().x)) ? 0 : 1;
return (true);
};
return (false);
}
public function isGone():Boolean{
return (drown);
}
protected function doDrown():Boolean{
if (Sitting.water.isSubmerged(this)){
drown = true;
world.removeEntity(this);
return (true);
};
return (false);
}
public function isOnGull():Boolean{
return ((((restingOver == Sitting.gull)) && (!(isFalling))));
}
}
}//package sitting
Section 51
//Person_img_love (sitting.Person_img_love)
package sitting {
import mx.core.*;
public class Person_img_love extends BitmapAsset {
}
}//package sitting
Section 52
//Sitting (sitting.Sitting)
package sitting {
import flash.display.*;
import flash.geom.*;
import utils.*;
public class Sitting extends World {
public var fireworks:Boolean;// = false
public static const Z_BOAT:int = 6;
public static const Z_MOON:int = 5;
public static const Z_MOUNTAINS:int = 2;
public static const Z_WATER:int = 8;
public static const SCENE_SPEED:Number = 0.25;
public static const ENDINGS:int = 8;
public static const Z_BACK_GULL:int = 3;
public static const Z_BACK:int = 0;
public static const Z_GIRL:int = 7;
public static const Z_FIRE:int = 1;
public static const Z_BIRD:int = 9;
public static const Z_TEAR:int = 4;
public static var moon:Moon;
public static var boat:Boat;
public static var boy:Boy;
private static var backgroundImage:BitmapData;
public static var water:Water;
public static var main:Sitting;
public static var posStarSpinCenter:Point;
public static var girl:Girl;
private static var back_asset:Class = Sitting_back_asset;
public static var smallMoon:SmallMoon;
public static var IDEAL_MOON_DISTANCE:Number = 58;
public static var gull:Gull;
public static var starsBand:Point = new Point();
public function Sitting(){
super(0, 0, 91, 120);
main = this;
backgroundImage = new back_asset().bitmapData;
addEntityAt((water = new Water()));
addEntityAt((boat = new Boat()), 24, water.y);
addEntityAt((girl = new Girl()), (boat.x - 10), boat.top());
addEntityAt((moon = new Moon()), 62, 62);
IDEAL_MOON_DISTANCE = Math.abs((moon.x - boat.x));
addEntityAt((smallMoon = new SmallMoon()), 65, 62);
addEntityAt((boy = new Boy()), (moon.x - 2), moon.top());
posStarSpinCenter = new Point((w / 2), (h - water.area().height));
starsBand.x = 3;
starsBand.y = (water.area().y - 20);
addEntityAt(new Star(), 41, 5);
addEntityAt(new Star(), 13, 19);
addEntityAt(new Star(), 71, 20);
addEntityAt(new Star(), 25, 47);
addEntityAt(new Star(), 79, 49);
addEntityAt(new Star(), 36, 87);
addEntityAt(new Star(), 69, 86);
addEntityAt(new Horizon(), 0, 100);
addEntityAt((gull = new Gull()), (w + 20), 50);
}
public function countFlowers():int{
return (filterEntities(function (_arg1:Entity):Boolean{
return ((((_arg1 is Flower)) && (_arg1.alive)));
}).length);
}
override public function isDone():Boolean{
return (!((ending() == null)));
}
override public function draw(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
cache.copyPixels(backgroundImage, new Rectangle(0, 0, backgroundImage.width, backgroundImage.height), new Point(0, 0));
super.draw(_arg1, _arg2, _arg3);
}
public function ending():String{
if (boat.y > water.y){
return ("Sunk boat Secret Ending");
};
if (fireworks){
return ("Such a pretty sky");
};
if (countFlowers() > 0){
return ("Do not forget me");
};
if (((((boy.isGone()) && (girl.isGone()))) && (water.isSubmerged(moon)))){
return ("If I can't have you...");
};
if (((((boy.drown) || (girl.drown))) && (!(water.isSubmerged(moon))))){
return ("Tragedy");
};
if (((boy.hasMoon) && (!(girl.drown)))){
return ("Bring me the Moon");
};
if (gull.goneBoy){
return ("No reason to live");
};
if (((((!(boy.isFalling)) && (girl.isOnBoat()))) && (moon.isGone()))){
return ("Lost Love");
};
if (((((boy.isOnBoat()) && (girl.isOnMoon()))) && (girl.isHarping()))){
return ("I am your Moon");
};
if (((!(boy.isGone())) && (gull.goneGirl))){
return ("Be Free");
};
return (null);
}
override public function update():void{
super.update();
var _local1:int = countFireflies();
if (fireworks){
if (_local1 < 5){
addEntityAt(new Firefly(), 0, 0);
};
} else {
if (((((!(isDone())) && ((Utils.rand(0, 90) == 5)))) && ((_local1 == 0)))){
addEntityAt(new Firefly(), 0, 0);
};
if (_local1 > 3){
fireworks = true;
};
};
}
private function countFireflies():int{
return (filterEntities(function (_arg1:Entity):Boolean{
return ((((_arg1 is Firefly)) && (_arg1.alive)));
}).length);
}
}
}//package sitting
Section 53
//Sitting_back_asset (sitting.Sitting_back_asset)
package sitting {
import mx.core.*;
public class Sitting_back_asset extends BitmapAsset {
}
}//package sitting
Section 54
//SmallMoon (sitting.SmallMoon)
package sitting {
import flash.display.*;
import utils.*;
public class SmallMoon extends Animated {
private var girlImage:BitmapData;
private static var img_girl:Class = SmallMoon_img_girl;
private static var img:Class = SmallMoon_img;
public function SmallMoon(){
super(new img().bitmapData);
anchor.x = (w / 2);
anchor.y = (h / 2);
gravity = false;
background = true;
z = Sitting.Z_MOUNTAINS;
visible = true;
girlImage = new img_girl().bitmapData;
}
override public function update():void{
if (Sitting.moon.isGone()){
visible = true;
if (y < 40){
y = (y + 0.2);
};
};
super.update();
}
override public function onAdded():void{
y = -(h);
super.onAdded();
}
override public function draw(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
if (((Sitting.girl.isHarping()) && (Sitting.girl.isOnMoon()))){
Utils.drawImage(_arg1, girlImage, _arg2, _arg3);
} else {
super.draw(_arg1, _arg2, _arg3);
};
}
}
}//package sitting
Section 55
//SmallMoon_img (sitting.SmallMoon_img)
package sitting {
import mx.core.*;
public class SmallMoon_img extends BitmapAsset {
}
}//package sitting
Section 56
//SmallMoon_img_girl (sitting.SmallMoon_img_girl)
package sitting {
import mx.core.*;
public class SmallMoon_img_girl extends BitmapAsset {
}
}//package sitting
Section 57
//Star (sitting.Star)
package sitting {
import flash.geom.*;
import utils.*;
public class Star extends Animated {
private static var img_star2:Class = Star_img_star2;
public function Star(){
super(new img_star2().bitmapData, 10, 10, Utils.rand(300, 450));
anim.setBouncingSequence();
background = true;
gravity = false;
z = Sitting.Z_BACK;
}
override public function update():void{
if (Sitting.boat.rower() != null){
if (!isInside()){
x = world.w;
};
x = (x - 0.4);
} else {
anim.play(true);
};
super.update();
}
override public function onAdded():void{
}
public function distToCenter():Number{
return (new Point((x - Sitting.posStarSpinCenter.x), (y - Sitting.posStarSpinCenter.y)).length);
}
}
}//package sitting
Section 58
//Star_img_star2 (sitting.Star_img_star2)
package sitting {
import mx.core.*;
public class Star_img_star2 extends BitmapAsset {
}
}//package sitting
Section 59
//Tear (sitting.Tear)
package sitting {
import flash.display.*;
import flash.geom.*;
public class Tear extends Entity {
public var activated:Boolean;// = false
public function Tear(){
z = Sitting.Z_TEAR;
gravity = true;
background = true;
}
override public function draw(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
_arg1.fillRect(new Rectangle(_arg2, _arg3, 1, 1), 4280294385);
}
override public function onPictured():void{
activated = true;
z = (Sitting.Z_MOON + 1);
}
override public function update():void{
super.update();
}
override public function area():Rectangle{
return (new Rectangle(x, y, 1, 1));
}
}
}//package sitting
Section 60
//Water (sitting.Water)
package sitting {
import flash.display.*;
import utils.*;
public class Water extends Entity {
private var offset:Number;// = 0
private var curve:Sprite;
private var strip:Strip;
private var waveStrip:Strip;
private static var img:Class = Water_img;
public function Water(){
w = MoonWish2.WIDTH;
h = 4;
y = (MoonWish2.HEIGHT - h);
z = Sitting.Z_WATER;
gravity = false;
liquid = true;
pixelPerfectCollision = false;
strip = new Strip(new img().bitmapData, 34, 14);
}
public function isSubmerged(_arg1:Entity):Boolean{
return ((_arg1.collisionArea().top > area().top));
}
override public function draw(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
var _local4:Number = (y + (Sitting.moon.distanceToHorizon() / 3));
var _local5:Number = ((world.w / strip.frameW) + 3);
var _local6:Number = (int(offset) - strip.frameW);
var _local7:int;
while (_local7 != int(_local5)) {
strip.draw(_arg1, _local6, y, 0);
_local6 = (_local6 + strip.frameW);
_local7++;
};
}
override public function update():void{
var _local1:Person = Sitting.boat.rower();
if (_local1 != null){
offset = (offset - _local1.rowingSpeed());
offset = (offset % strip.frameW);
};
super.update();
}
}
}//package sitting
Section 61
//Water_img (sitting.Water_img)
package sitting {
import mx.core.*;
public class Water_img extends BitmapAsset {
}
}//package sitting
Section 62
//Animation (utils.Animation)
package utils {
import flash.display.*;
public class Animation {
public var sequence:Array;
private var currentTime:int;// = 0
public var strip:Strip;
private var frameTime:int;
public var currentFrame:int;// = 0
private var looping:Boolean;// = false
private var running:Boolean;// = false
public function Animation(_arg1:BitmapData, _arg2:int, _arg3:int, _arg4:int){
strip = new Strip(_arg1, _arg2, _arg3);
this.frameTime = _arg4;
sequence = new Array(strip.frameCount);
var _local5:int;
while (_local5 != sequence.length) {
sequence[_local5] = _local5;
_local5++;
};
}
public function play(_arg1:Boolean=false):void{
running = true;
looping = _arg1;
}
public function draw(_arg1:BitmapData, _arg2:int, _arg3:int, _arg4:int=0, _arg5:int=0, _arg6:Number=1):void{
strip.draw(_arg1, _arg2, _arg3, sequence[currentFrame], _arg4, _arg5, _arg6);
}
public function setFrameTime(_arg1:int):void{
frameTime = _arg1;
}
public function stop():void{
running = false;
}
public function setFrame(_arg1:int):void{
currentFrame = _arg1;
}
public function setBouncingSequence():void{
var _local1:Array = new Array((strip.frameCount * 2));
var _local2:int;
var _local3:int;
_local3 = 0;
while (_local3 != strip.frameCount) {
var _temp1 = _local2;
_local2 = (_local2 + 1);
var _local4 = _temp1;
_local1[_local4] = _local3;
_local3++;
};
_local3 = 0;
while (_local3 != strip.frameCount) {
var _temp2 = _local2;
_local2 = (_local2 + 1);
_local4 = _temp2;
_local1[_local4] = ((strip.frameCount - _local3) - 1);
_local3++;
};
sequence = _local1;
}
public function isRunning():Boolean{
return (running);
}
public function update():void{
if (frameTime <= 0){
stop();
return;
};
if (running){
currentTime = (currentTime + Utils.frameTime());
if (currentTime >= frameTime){
currentTime = (currentTime - frameTime);
if (currentFrame < (sequence.length - 1)){
currentFrame++;
} else {
if (looping){
currentFrame = 0;
} else {
stop();
};
};
};
};
}
}
}//package utils
Section 63
//Game (utils.Game)
package utils {
import flash.events.*;
import flash.display.*;
public class Game extends Sprite {
public var backbuffer:BitmapData;
public static var game:Game;
public function Game(){
game = this;
this.height = stage.stageHeight;
this.width = stage.stageWidth;
backbuffer = new BitmapData(stage.stageWidth, stage.stageHeight, false);
stage.addChild(new Bitmap(backbuffer));
stage.addEventListener(Event.ENTER_FRAME, updateFrame);
}
protected function update(_arg1:BitmapData):void{
}
private function updateFrame(_arg1:Event):void{
backbuffer.lock();
update(backbuffer);
backbuffer.unlock();
}
}
}//package utils
Section 64
//Strip (utils.Strip)
package utils {
import flash.display.*;
import flash.geom.*;
public class Strip {
private var rowSize:int;
public var img:BitmapData;
public var frameCount:int;
public var frameW:int;
public var frameH:int;
public function Strip(_arg1:BitmapData, _arg2:int, _arg3:int){
this.img = _arg1;
this.frameW = _arg2;
this.frameH = _arg3;
rowSize = (_arg1.width / _arg2);
frameCount = (rowSize * (_arg1.height / _arg3));
}
public function draw(_arg1:BitmapData, _arg2:int, _arg3:int, _arg4:int, _arg5:int=0, _arg6:int=0, _arg7:Number=1):void{
var _local10:Matrix;
var _local8:int = (Math.floor((_arg4 / rowSize)) * frameH);
var _local9:int = ((_arg4 % rowSize) * frameW);
if ((_arg6 & Utils.ANCHOR_HCENTER) != 0){
_arg2 = (_arg2 - (frameW / 2));
};
if (_arg5 == 0){
if (_arg7 == 1){
_arg1.copyPixels(img, new Rectangle(_local9, _local8, frameW, frameH), new Point(_arg2, _arg3), null, null, true);
} else {
_local10 = new Matrix();
_local10.translate((_local9 + _arg2), (_local9 + _arg3));
_arg1.draw(img, _local10, new ColorTransform(1, 1, 1, _arg7), null, new Rectangle((_local9 + _arg2), (_local8 + _arg3), frameW, frameH));
};
} else {
Utils.drawFlipH(_arg1, img, new Rectangle(_local9, _local8, frameW, frameH), new Point(_arg2, _arg3), _arg7);
};
}
}
}//package utils
Section 65
//Utils (utils.Utils)
package utils {
import flash.display.*;
import flash.geom.*;
import flash.text.*;
import flash.utils.*;
public class Utils {
public static const ANCHOR_HCENTER:int = 4;
public static const ANCHOR_RIGHT:int = 1;
public static const ANCHOR_BOTTOM:int = 2;
private static var textField:TextField;
private static var overrideFrameTime:Number = -1;
private static var textWrap:MovieClip;
public static function newMatrix(_arg1:int, _arg2:int, _arg3:Function=null):Array{
var _local6:int;
var _local4:Array = new Array(_arg1);
var _local5:int;
while (_local5 != _arg1) {
_local4[_local5] = new Array(_arg2);
if (_arg3 != null){
_local6 = 0;
while (_local6 != _arg2) {
_local4[_local5][_local6] = _arg3(_local5, _local6);
_local6++;
};
};
_local5++;
};
return (_local4);
}
public static function getClass(_arg1:Object):Class{
return (Class(getDefinitionByName(getQualifiedClassName(_arg1))));
}
public static function remove(_arg1:Array, _arg2:Object):void{
var _local3:int;
if (_arg2 != null){
_local3 = _arg1.indexOf(_arg2);
if (_local3 != -1){
_arg1.splice(_local3, 1);
};
};
}
public static function fillRect(_arg1:BitmapData, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:uint, _arg7:Number=1):void{
var _local8:Sprite = new Sprite();
_local8.graphics.beginFill(_arg6);
_local8.graphics.drawRect(0, 0, _arg4, _arg5);
_local8.graphics.endFill();
var _local9:Matrix = new Matrix();
_local9.translate(_arg2, _arg3);
_arg1.draw(_local8, _local9, new ColorTransform(1, 1, 1, _arg7));
}
public static function drawTargetOutline(_arg1:Graphics, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):void{
_arg1.lineStyle(1, 4294967295);
drawLine(_arg1, _arg2, _arg3, (_arg2 + _arg6), _arg3);
drawLine(_arg1, _arg2, _arg3, _arg2, (_arg3 + _arg6));
drawLine(_arg1, (_arg2 + _arg4), _arg3, ((_arg2 + _arg4) - _arg6), _arg3);
drawLine(_arg1, (_arg2 + _arg4), _arg3, (_arg2 + _arg4), (_arg3 + _arg6));
drawLine(_arg1, (_arg2 + _arg4), (_arg3 + _arg5), ((_arg2 + _arg4) - _arg6), (_arg3 + _arg5));
drawLine(_arg1, (_arg2 + _arg4), (_arg3 + _arg5), (_arg2 + _arg4), ((_arg3 + _arg5) - _arg6));
drawLine(_arg1, _arg2, (_arg3 + _arg5), (_arg2 + _arg6), (_arg3 + _arg5));
drawLine(_arg1, _arg2, (_arg3 + _arg5), _arg2, ((_arg3 + _arg5) - _arg6));
}
public static function textSize(_arg1:String, _arg2:TextFormat, _arg3:int):Rectangle{
return (drawText(null, _arg1, _arg2, _arg3, 0, 0));
}
public static function fillRoundRect(_arg1:BitmapData, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:uint, _arg8:Number=1):void{
var _local9:Sprite = new Sprite();
_local9.graphics.beginFill(_arg7);
_local9.graphics.drawRoundRect(0, 0, _arg4, _arg5, _arg6);
_local9.graphics.endFill();
var _local10:Matrix = new Matrix();
_local10.translate(_arg2, _arg3);
_arg1.draw(_local9, _local10, new ColorTransform(1, 1, 1, _arg8));
}
public static function drawText(_arg1:BitmapData, _arg2:String, _arg3:TextFormat, _arg4:int, _arg5:int, _arg6:int, _arg7:Number=1, _arg8:int=0):Rectangle{
var _local9:Matrix;
if (textField == null){
textField = new TextField();
textWrap = new MovieClip();
textWrap.addChild(textField);
textField.selectable = false;
textField.antiAliasType = AntiAliasType.ADVANCED;
textField.type = TextFieldType.DYNAMIC;
textField.autoSize = TextFieldAutoSize.LEFT;
textField.multiline = true;
textField.wordWrap = true;
textField.sharpness = 400;
textField.gridFitType = "pixel";
textField.embedFonts = true;
};
textField.width = _arg4;
textField.text = _arg2;
textField.setTextFormat(_arg3);
if (_arg1 != null){
_local9 = new Matrix();
if ((_arg8 & ANCHOR_RIGHT) != 0){
_local9.translate((_arg5 - textField.textWidth), _arg6);
} else {
if ((_arg8 & ANCHOR_BOTTOM) != 0){
_local9.translate(_arg5, (_arg6 - textField.textHeight));
} else {
if ((_arg8 & ANCHOR_HCENTER) != 0){
_local9.translate((_arg5 - (textField.textWidth / 2)), _arg6);
} else {
_local9.translate(_arg5, _arg6);
};
};
};
_arg1.draw(textWrap, _local9, new ColorTransform(1, 1, 1, _arg7));
};
return (new Rectangle(0, 0, Math.min(_arg4, textField.textWidth), (textField.textHeight + 3)));
}
public static function drawFlipH(_arg1:BitmapData, _arg2:BitmapData, _arg3:Rectangle, _arg4:Point, _arg5:Number=1):void{
var _local6:Matrix = new Matrix();
_local6.scale(-1, 1);
_local6.translate((_arg4.x + _arg3.width), _arg4.y);
var _local7:BitmapData = new BitmapData(_arg3.width, _arg3.height, true, 0);
_local7.copyPixels(_arg2, _arg3, new Point());
_arg1.draw(_local7, _local6, ((_arg5 == 1)) ? null : new ColorTransform(1, 1, 1, _arg5));
}
public static function drawLine(_arg1:Graphics, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{
_arg1.moveTo(_arg2, _arg3);
_arg1.lineTo(_arg4, _arg5);
}
public static function frameTime():Number{
if (overrideFrameTime == -1){
return ((1000 / Game.game.stage.frameRate));
};
return (overrideFrameTime);
}
public static function iterateMatrix(_arg1:Array, _arg2:Function):void{
var _local4:int;
var _local3:int;
while (_local3 != _arg1.length) {
_local4 = 0;
while (_local4 != _arg1[0].length) {
_arg1[_local3][_local4] = _arg2(_local3, _local4);
_local4++;
};
_local3++;
};
}
public static function fitRectangle(_arg1:Rectangle, _arg2:Rectangle):Rectangle{
var _local3:Rectangle = new Rectangle();
_local3.x = ((_arg1.x < _arg2.x)) ? _arg2.x : (((_arg1.x + _arg1.width) > (_arg2.x + _arg2.width))) ? ((_arg2.x + _arg2.width) - _arg1.width) : _arg1.x;
_local3.y = ((_arg1.y < _arg2.y)) ? _arg2.y : (((_arg1.y + _arg1.height) > (_arg2.y + _arg2.height))) ? ((_arg2.y + _arg2.height) - _arg1.height) : _arg1.y;
_local3.width = _arg1.width;
_local3.height = _arg1.height;
return (_local3);
}
public static function pick(_arg1:Array){
return (_arg1[rand(0, (_arg1.length - 1))]);
}
public static function rand(_arg1:int, _arg2:int):int{
if (_arg1 >= _arg2){
return (int(_arg2));
};
_arg2 = (_arg2 + 1);
var _local3:int = (_arg2 - _arg1);
var _local4:Number = ((Math.random() * _local3) + _arg1);
return (_local4);
}
public static function drawTextCentered(_arg1:BitmapData, _arg2:String, _arg3:TextFormat, _arg4:int, _arg5:int, _arg6:int):Rectangle{
var _local7:Rectangle = textSize(_arg2, _arg3, _arg4);
drawText(_arg1, _arg2, _arg3, _arg4, (_arg5 - (_local7.width / 2)), (_arg6 - _local7.height));
return (_local7);
}
public static function beginFrameOverride(_arg1:Number):void{
overrideFrameTime = _arg1;
}
public static function drawImage(_arg1:BitmapData, _arg2:BitmapData, _arg3:Number, _arg4:Number):void{
_arg1.copyPixels(_arg2, new Rectangle(0, 0, _arg2.width, _arg2.height), new Point(_arg3, _arg4), null, null, true);
}
public static function shuffle(_arg1:Array):Array{
var _local4:uint;
var _local2:Array = new Array();
var _local3:Array = _arg1.slice();
while (_local3.length > 0) {
_local4 = Math.floor((Math.random() * _local3.length));
_local2.push(_local3.splice(_local4, 1));
};
return (_local2);
}
public static function drawAlpha(_arg1:BitmapData, _arg2:BitmapData, _arg3:Rectangle, _arg4:Point, _arg5:Number=1):void{
var _local6:Matrix = new Matrix();
_local6.translate(_arg4.x, _arg4.y);
_arg1.draw(_arg2, _local6, ((_arg5 == 1)) ? null : new ColorTransform(1, 1, 1, _arg5));
}
public static function cloneArray(_arg1:Array):Array{
var _local2:Array = new Array(_arg1.length);
var _local3:int;
while (_local3 < _arg1.length) {
_local2[_local3] = _arg1[_local3];
_local3++;
};
return (_local2);
}
public static function endFrameOverride():void{
overrideFrameTime = -1;
}
}
}//package utils
Section 66
//Animated (Animated)
package {
import flash.display.*;
import utils.*;
public class Animated extends Entity {
protected var anim:Animation;
public var lookingDir:int;// = 0
public var alpha:Number;// = 1
public function Animated(_arg1:BitmapData, _arg2:int=-1, _arg3:int=-1, _arg4:int=-1){
if ((((_arg2 == -1)) || ((_arg3 == -1)))){
_arg2 = _arg1.width;
_arg3 = _arg1.height;
};
if (_arg4 == -1){
_arg4 = 0;
};
anim = new Animation(_arg1, _arg2, _arg3, _arg4);
w = _arg2;
h = _arg3;
}
override public function update():void{
anim.update();
super.update();
}
override public function draw(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
anim.draw(_arg1, _arg2, _arg3, ((lookingDir == 0)) ? 0 : 1, alpha);
}
}
}//package
Section 67
//Entity (Entity)
package {
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
public class Entity {
public var restingOver:Entity;// = null
public var snapped:Boolean;// = false
public var duplicateOnPhoto:Boolean;// = false
public var world:World;// = null
public var visible:Boolean;// = true
public var floats:Boolean;// = false
private var _y:Number;// = 0
public var overAnchor:Point;
public var background:Boolean;// = false
public var anchor:Point;
protected var gravityPull:Number;// = -1
public var liquid:Boolean;// = false
public var pixelPerfectCollision:Boolean;// = true
public var alive:Boolean;// = true
public var canBePhotographed:Boolean;// = true
public var gravity:Boolean;// = true
public var h:Number;// = 0
public var w:Number;// = 0
private var _x:Number;// = 0
public var z:Number;// = 0
public var isFalling:Boolean;// = false
public function Entity(){
anchor = new Point(0, 0);
overAnchor = new Point(0, 0);
super();
}
public function get y():Number{
return (_y);
}
public function onRemoved():void{
}
private function overMe(_arg1:Entity):Boolean{
return ((_arg1.restingOver == this));
}
public function area():Rectangle{
return (new Rectangle((x - anchor.x), (y - anchor.y), w, h));
}
private function fallingOver(_arg1:Entity):Boolean{
var _local2:Rectangle = collisionArea();
_local2.height = (_local2.height + getGravityPull());
return (world.collides(this, _arg1, false, _local2));
}
public function getGravityPull():Number{
if (gravityPull == -1){
return (world.defaultGravityPull);
};
return (gravityPull);
}
private function fall():void{
var _local1:Number;
var _local2:Rectangle;
var _local3:Array;
var _local4:int;
var _local5:Entity;
var _local6:Number;
if (restingOver != null){
if (fallingOver(restingOver)){
_local1 = (restingOver.collisionArea().top - collisionArea().bottom);
y = (y + _local1);
} else {
restingOver = null;
};
};
if (restingOver == null){
_local2 = collisionArea();
_local2.height = (_local2.height + getGravityPull());
_local3 = world.collisions(this, false, _local2);
isFalling = true;
_local4 = 0;
while (_local4 < _local3.length) {
_local5 = _local3[_local4];
if (((((collisionArea().bottom + gravity) >= _local5.collisionArea().top)) && ((collisionArea().top < _local5.collisionArea().top)))){
isFalling = false;
_local6 = (_local5.collisionArea().top - collisionArea().bottom);
_y = (_y + _local6);
if (restingOver != _local5){
onHit(_local5);
restingOver = _local5;
overAnchor.x = (_x - restingOver._x);
};
};
_local4++;
};
if (isFalling){
restingOver = null;
_y = (_y + gravity);
};
};
}
public function isTouching(_arg1:Entity):Boolean{
var _local4:Entity;
var _local2:Array = world.collisions(this, true);
var _local3:int;
while (_local3 < _local2.length) {
_local4 = _local2[_local3];
if ((((_local4 == _arg1)) && (collisionArea().intersects(_arg1.collisionArea())))){
return (perfectHit(_local4));
};
_local3++;
};
return (false);
}
public function canHit(_arg1:Entity):Boolean{
if (((_arg1.background) || (background))){
return (false);
};
if (((((_arg1.liquid) && (!(floats)))) || (((liquid) && (!(_arg1.floats)))))){
return (false);
};
return (true);
}
public function teleport(_arg1:Number, _arg2:Number):void{
var _local5:Number;
var _local6:Number;
var _local3:Array = world.filterEntities(overMe);
var _local4:int;
while (_local4 != _local3.length) {
_local5 = (x - _local3[_local4].x);
_local6 = (y - _local3[_local4].y);
_local3[_local4]._x = (_arg1 + _local5);
_local3[_local4]._y = (_arg2 + _local6);
_local4++;
};
x = _arg1;
y = _arg2;
}
public function onPictured():void{
}
public function bottom():Number{
return (area().bottom);
}
protected function onHit(_arg1:Entity):void{
}
public function restingOverMe():Array{
return (world.filterEntities(restingOverMeFilter));
}
public function draw(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
}
protected function perfectHit(_arg1:Entity):Boolean{
var _local2:BitmapData;
var _local3:BitmapData;
if (((pixelPerfectCollision) && (_arg1.pixelPerfectCollision))){
_local2 = new BitmapData(area().width, area().height, true, 0);
draw(_local2, 0, 0);
_local3 = new BitmapData(_arg1.area().width, _arg1.area().height, true, 0);
_arg1.draw(_local3, 0, 0);
return (_local2.hitTest(new Point(area().x, area().y), 0xFF, _local3, new Point(_arg1.area().x, _arg1.area().y), 0xFF));
};
return (true);
}
public function update():void{
if (((((gravity) && ((top() < world.area().height)))) && (canFall()))){
fall();
};
var _local1:Array = restingOverMe();
var _local2:int;
while (_local2 != _local1.length) {
_local1[_local2]._x = (_x + _local1[_local2].overAnchor.x);
_local2++;
};
}
private function restingOverMeFilter(_arg1:Entity):Boolean{
return ((_arg1.restingOver == this));
}
final public function clone():Object{
var _local1:Class = Class(getDefinitionByName(getQualifiedClassName(this)));
var _local2:Object = new (_local1);
copy(_local2);
return (_local2);
}
public function isInside():Boolean{
return (new Rectangle(0, 0, world.area().width, world.area().height).intersects(area()));
}
public function collisionArea():Rectangle{
return (area());
}
public function onAdded():void{
}
public function paint(_arg1:BitmapData):void{
draw(_arg1, Math.floor(area().x), Math.floor(area().y));
}
public function isContained(_arg1:Entity):Boolean{
return (_arg1.area().containsRect(area()));
}
protected function canFall():Boolean{
return (true);
}
public function top():Number{
return (area().y);
}
public function set x(_arg1:Number):void{
if (restingOver != null){
overAnchor.x = (overAnchor.x - (_x - _arg1));
};
_x = _arg1;
}
public function set y(_arg1:Number):void{
_y = _arg1;
}
protected function copy(_arg1:Object):void{
var _local2:Entity = Entity(_arg1);
_local2._x = _x;
_local2._y = _y;
_local2.w = w;
_local2.h = h;
_local2.z = z;
_local2.visible = visible;
_local2.anchor = anchor.clone();
_local2.world = world;
_local2.gravity = gravity;
_local2.liquid = liquid;
_local2.floats = floats;
_local2.background = background;
_local2.pixelPerfectCollision = pixelPerfectCollision;
_local2.gravityPull = gravityPull;
_local2.canBePhotographed = canBePhotographed;
_local2.isFalling = isFalling;
_local2.restingOver = restingOver;
_local2.overAnchor = overAnchor.clone();
_local2.snapped = false;
_local2.alive = false;
}
public function onPlaced(_arg1:Number, _arg2:Number):void{
_x = _arg1;
_y = _arg2;
restingOver = null;
snapped = false;
}
public function get x():Number{
return (_x);
}
}
}//package
Section 68
//Expression (Expression)
package {
import flash.display.*;
import sitting.*;
import utils.*;
public class Expression {
public var seekTarget:Entity;
private var from:Person;
public var status:int;// = 1
private var strip:Strip;
public static const ANGRY:int = 7;
public static const HAPPY:int = 1;
public static const SAD_LONELY:int = 2;
public static const DOWN:int = 8;
public static const EFFORTING:int = 5;
public static const NONE:int = 0;
public static const SAD_LOOKING:int = 4;
public static const FOCUSED:int = 6;
public static const SEEK:int = 3;
private static var img:Class = Expression_img;
private static var SEPARATION:int = 3;
public function Expression(_arg1:Person, _arg2:Number=2, _arg3:Number=4, _arg4:Number=3){
strip = new Strip(new img().bitmapData, _arg2, _arg3);
SEPARATION = _arg4;
this.from = _arg1;
}
public function happy():void{
status = HAPPY;
}
public function lookDown():void{
status = DOWN;
}
public function sad():void{
status = SAD_LONELY;
}
public function none():void{
status = NONE;
}
public function angry(_arg1:Entity):void{
status = ANGRY;
seekTarget = _arg1;
}
public function dead():void{
status = HAPPY;
}
public function sadLooking(_arg1:Entity):void{
status = SAD_LOOKING;
seekTarget = _arg1;
}
private function drawSeekerEye(_arg1:BitmapData, _arg2:int, _arg3:int, _arg4:Boolean):void{
var _local5:int;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:int;
if (seekTarget != null){
from.lookingDir = ((seekTarget.x < from.x)) ? 1 : 0;
_local5 = 0;
if (seekTarget.x > from.x){
_local5 = 1;
};
_local6 = (from.y - seekTarget.y);
_local7 = (from.x - seekTarget.x);
_local8 = -(Math.atan((_local6 / _local7)));
if (_local8 < (-(Math.PI) / 8)){
_local9 = 2;
} else {
if (_local8 > (Math.PI / 8)){
_local9 = 0;
} else {
_local9 = 1;
};
};
if (_local5 == 1){
strip.draw(_arg1, _arg2, _arg3, _local9);
} else {
strip.draw(_arg1, _arg2, _arg3, (_local9 + 3));
};
};
}
public function efforting(_arg1:Entity):void{
status = EFFORTING;
seekTarget = _arg1;
}
public function focused():void{
status = FOCUSED;
}
private function drawEye(_arg1:BitmapData, _arg2:int, _arg3:int, _arg4:Boolean):void{
switch (status){
case NONE:
break;
case FOCUSED:
strip.draw(_arg1, _arg2, _arg3, 13);
break;
case HAPPY:
strip.draw(_arg1, _arg2, (_arg3 - 1), 6);
break;
case EFFORTING:
strip.draw(_arg1, _arg2, _arg3, (_arg4) ? 11 : 12);
drawSeekerEye(_arg1, _arg2, _arg3, _arg4);
break;
case SAD_LONELY:
strip.draw(_arg1, _arg2, _arg3, (_arg4) ? 8 : 9);
strip.draw(_arg1, _arg2, _arg3, (_arg4) ? 2 : 3);
break;
case SAD_LOOKING:
strip.draw(_arg1, _arg2, _arg3, (_arg4) ? 8 : 9);
drawSeekerEye(_arg1, _arg2, _arg3, _arg4);
break;
case SEEK:
strip.draw(_arg1, _arg2, _arg3, 7);
drawSeekerEye(_arg1, _arg2, _arg3, _arg4);
break;
case ANGRY:
strip.draw(_arg1, _arg2, _arg3, (_arg4) ? 15 : 14);
drawSeekerEye(_arg1, _arg2, _arg3, _arg4);
break;
case DOWN:
strip.draw(_arg1, _arg2, _arg3, 7);
strip.draw(_arg1, _arg2, _arg3, (_arg4) ? 2 : 3);
break;
};
}
public function draw(_arg1:BitmapData, _arg2:int, _arg3:int):void{
drawEye(_arg1, _arg2, _arg3, true);
drawEye(_arg1, (_arg2 + SEPARATION), _arg3, false);
}
public function clone():Expression{
var _local1:Expression = new Expression(this.from);
_local1.seekTarget = seekTarget;
_local1.status = status;
return (_local1);
}
public function seek(_arg1:Entity):void{
status = SEEK;
seekTarget = _arg1;
}
}
}//package
Section 69
//Expression_img (Expression_img)
package {
import mx.core.*;
public class Expression_img extends BitmapAsset {
}
}//package
Section 70
//Kongregate (Kongregate)
package {
import flash.display.*;
import com.kongregate.as3.client.*;
public class Kongregate {
private var isGameFinished:Boolean;// = false
public function Kongregate(_arg1:Stage){
var _local2:KongregateAPI = new KongregateAPI();
_arg1.addChild(_local2);
}
public function gameFinished():void{
var _local1:KongregateAPI;
if (((KongregateAPI.getInstance().connected) && (!(isGameFinished)))){
_local1 = KongregateAPI.getInstance();
_local1.stats.submit("GameComplete", 1);
isGameFinished = true;
};
}
}
}//package
Section 71
//MoonWish2 (MoonWish2)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.text.*;
import sitting.*;
import mx.core.*;
import utils.*;
import flash.media.*;
import flash.ui.*;
public class MoonWish2 extends Game {
private var curWorldIndex:int;// = 0
public var field:BitmapData;
private var mouseClicked:Boolean;// = false
private var cameraH:Number;// = 20
private var snapped:Array;
private var playNext:Boolean;// = false
private var snapshot:BitmapData;
private var cameraW:Number;// = 24
private var cameraX:Number;// = 0
private var cameraY:Number;// = 0
private var music_asset:Class;
private var photoSnd:Class;
private var currentWorld:World;
private var cameraOutline:Shape;
private var worlds:Array;
public var endings:Array;
private var hasPhoto:Boolean;// = false
private var anchorPoints:Array;
public static const WIDTH:int = 91;
public static const HEIGHT:int = 111;
public static const SCALE:int = 5;
private static const POLAROID_BORDER:int = 3;
private static var font_asset:Class = MoonWish2_font_asset;
private static var defaultFont:TextFormat;
public static var main:MoonWish2;
private static var kong:Kongregate = null;
public function MoonWish2(){
endings = new Array();
photoSnd = MoonWish2_photoSnd;
music_asset = MoonWish2_music_asset;
cameraOutline = new Shape();
snapped = new Array();
anchorPoints = new Array();
super();
main = this;
Mouse.hide();
scaleX = 1;
scaleY = 1;
try {
kong = new Kongregate(stage);
} catch(err:Object) {
};
defaultFont = new TextFormat();
defaultFont.size = 25;
defaultFont.font = new font_asset().fontName;
defaultFont.color = "0xffffff";
defaultFont.bold = false;
field = new BitmapData(WIDTH, HEIGHT, false, 4278190080);
stage.addEventListener(MouseEvent.CLICK, onMouseClick);
stage.addEventListener(KeyboardEvent.KEY_UP, onKey);
Utils.drawTargetOutline(cameraOutline.graphics, 0, 0, (cameraW * SCALE), (cameraH * SCALE), 10);
stage.addChild(cameraOutline);
snapshot = new BitmapData((cameraW * SCALE), (cameraH * SCALE), true, 0);
resetWorlds();
resetWorld();
var mySound:SoundAsset = (new music_asset() as SoundAsset);
var sndChannel:SoundChannel = mySound.play(0, 99);
stage.addEventListener(Event.ACTIVATE, mouseEnter);
}
private function resetWorlds():void{
worlds = new Array(Sitting);
}
public function playNextWorld():void{
playNext = true;
}
private function resetWorld():void{
var _local1:Array;
var _local2:int;
if (currentWorld != null){
_local1 = Utils.cloneArray(currentWorld.entities);
_local2 = 0;
while (_local2 != _local1.length) {
currentWorld.removeEntity(_local1[_local2]);
_local2++;
};
};
currentWorld = new (worlds[curWorldIndex]);
hasPhoto = false;
}
private function mouseEnter(_arg1:Event):void{
Mouse.hide();
}
public function onKey(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == 82){
playNextWorld();
};
if (_arg1.keyCode == 51){
currentWorld.addEntityAt(new Firefly(), 0, 0);
};
}
private function captureEntities():void{
var _local5:Entity;
var _local6:Rectangle;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:int;
var _local1:SoundAsset = (new photoSnd() as SoundAsset);
var _local2:SoundChannel = _local1.play();
snapped.length = 0;
anchorPoints.length = 0;
var _local3:Rectangle = new Rectangle(cameraX, (cameraY + 9), cameraW, cameraH);
var _local4:int;
while (_local4 < currentWorld.entities.length) {
_local5 = currentWorld.entities[_local4];
if (_local5.collisionArea().intersects(_local3)){
_local6 = _local5.collisionArea().intersection(_local3);
_local7 = (_local6.width * _local6.height);
_local8 = (_local5.collisionArea().width * _local5.collisionArea().height);
_local9 = (_local7 / _local8);
if (_local9 > 0.75){
anchorPoints.push(new Point((_local5.x - _local3.x), (_local5.y - _local3.y)));
snapped.push(_local5);
_local5.onPictured();
_local5.snapped = true;
};
};
_local4++;
};
snapped.sortOn("z", Array.DESCENDING);
if (snapped.length == 0){
_local10 = 18;
while (_local10 >= 1) {
grabPicture(_local10, _local10, true);
_local10 = (_local10 - 2);
};
};
}
public function onMouseClick(_arg1:MouseEvent):void{
mouseClicked = true;
}
private function grabPicture(_arg1:Number, _arg2:Number, _arg3:Boolean=false):void{
var _local4:BitmapData;
if (_arg3){
_local4 = new BitmapData(snapshot.width, snapshot.height, true, 2130706432);
snapshot.copyPixels(backbuffer, new Rectangle((cameraOutline.x + _arg1), (cameraOutline.y + _arg2), (cameraW * SCALE), (cameraH * SCALE)), new Point(0, 0), _local4, new Point(0, 0), true);
} else {
snapshot.copyPixels(backbuffer, new Rectangle((cameraOutline.x + _arg1), (cameraOutline.y + _arg2), (cameraW * SCALE), (cameraH * SCALE)), new Point(0, 0));
};
}
override protected function update(_arg1:BitmapData):void{
var _local4:Number;
var _local5:Number;
var _local6:String;
if (playNext){
playNext = false;
curWorldIndex++;
if (curWorldIndex == worlds.length){
resetWorlds();
curWorldIndex = 0;
};
resetWorld();
};
cameraX = ((stage.mouseX / SCALE) - (cameraW / 2));
cameraY = ((stage.mouseY / SCALE) - (cameraH / 2));
var _local2:Rectangle = new Rectangle(cameraX, cameraY, cameraW, cameraH);
_local2 = Utils.fitRectangle(_local2, new Rectangle(0, 0, WIDTH, (HEIGHT - 9)));
cameraX = _local2.x;
cameraY = _local2.y;
cameraOutline.x = (cameraX * SCALE);
cameraOutline.y = (cameraY * SCALE);
currentWorld.update();
currentWorld.draw(field, 0, 0);
var _local3:Matrix = new Matrix();
_local3.scale(SCALE, SCALE);
_local3.translate(0, -45);
backbuffer.draw(field, _local3);
if (mouseClicked){
mouseClicked = false;
if (hasPhoto){
hasPhoto = false;
placeEntities();
} else {
grabPicture(0, 0);
hasPhoto = true;
captureEntities();
};
};
if (hasPhoto){
_local4 = cameraOutline.x;
_local5 = cameraOutline.y;
Utils.drawAlpha(backbuffer, snapshot, new Rectangle(0, 0, snapshot.width, snapshot.height), new Point((cameraOutline.x / scaleX), (cameraOutline.y / scaleY)), 0.7);
backbuffer.fillRect(new Rectangle((_local4 - POLAROID_BORDER), (_local5 - POLAROID_BORDER), (snapshot.width + (POLAROID_BORDER * 2)), POLAROID_BORDER), 4294901502);
backbuffer.fillRect(new Rectangle((_local4 - POLAROID_BORDER), _local5, POLAROID_BORDER, snapshot.height), 4294901502);
backbuffer.fillRect(new Rectangle((_local4 + snapshot.width), _local5, POLAROID_BORDER, snapshot.height), 4294901502);
backbuffer.fillRect(new Rectangle((_local4 - POLAROID_BORDER), (_local5 + snapshot.height), (snapshot.width + (POLAROID_BORDER * 2)), 13), 4294901502);
cameraOutline.visible = false;
} else {
cameraOutline.visible = true;
};
if (Sitting.main.isDone()){
_local6 = Sitting.main.ending();
if (endings.indexOf(_local6) == -1){
endings.push(_local6);
};
_local6 = (_local6 + "\n");
if (endings.length < Sitting.ENDINGS){
_local6 = (_local6 + ((Sitting.ENDINGS - endings.length) + " missing endings"));
_local6 = (_local6 + "\nPress [R] to rewind");
} else {
if (kong != null){
kong.gameFinished();
};
_local6 = (_local6 + "You discovered all endings!");
};
Utils.drawText(backbuffer, _local6, defaultFont, stage.stageWidth, 3, 3, 1);
};
}
private function placeEntities():void{
var _local2:Entity;
var _local3:Point;
var _local1:int;
while (_local1 != snapped.length) {
_local2 = snapped[_local1];
_local3 = anchorPoints[_local1];
_local2.onPlaced((cameraX + _local3.x), ((cameraY + _local3.y) + 9));
_local1++;
};
}
}
}//package
Section 72
//MoonWish2_font_asset (MoonWish2_font_asset)
package {
import mx.core.*;
public class MoonWish2_font_asset extends FontAsset {
}
}//package
Section 73
//MoonWish2_music_asset (MoonWish2_music_asset)
package {
import mx.core.*;
public class MoonWish2_music_asset extends SoundAsset {
}
}//package
Section 74
//MoonWish2_photoSnd (MoonWish2_photoSnd)
package {
import mx.core.*;
public class MoonWish2_photoSnd extends SoundAsset {
}
}//package
Section 75
//World (World)
package {
import flash.display.*;
import flash.geom.*;
import utils.*;
public class World extends Entity {
public var entities:Array;
public var cache:BitmapData;
public var defaultGravityPull:Number;// = 1
public function World(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number){
entities = new Array();
super();
cache = new BitmapData(_arg3, _arg4, true, 4278190080);
this.x = _arg1;
this.y = _arg2;
this.w = _arg3;
this.h = _arg4;
}
public function closestThat(_arg1:Entity, _arg2:Function):Entity{
var dist:Number;
var from = _arg1;
var filter = _arg2;
var ret:Entity;
dist = 100000;
entities.forEach(function (_arg1, _arg2:Number, _arg3:Array):void{
var _local4:Number;
if (((_arg1.visible) && (filter(_arg1)))){
_local4 = new Point((_arg1.x - from.x), (_arg1.y - from.y)).length;
if (_local4 < dist){
ret = _arg1;
dist = _local4;
};
};
});
return (ret);
}
override public function draw(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
var _local7:Entity;
super.draw(cache, _arg2, _arg3);
var _local4:Array = Utils.cloneArray(entities);
_local4.sortOn("z");
var _local5:int;
while (_local5 < _local4.length) {
_local7 = _local4[_local5];
if (_local7.visible){
_local7.paint(cache);
};
_local5++;
};
var _local6:Matrix = new Matrix();
_local6.translate(x, y);
_arg1.copyPixels(cache, new Rectangle(0, 0, cache.width, cache.height), new Point(x, y), null, null, true);
}
public function removeEntity(_arg1:Entity):void{
if (_arg1 != null){
Utils.remove(entities, _arg1);
_arg1.onRemoved();
};
}
public function collisions(_arg1:Entity, _arg2:Boolean, _arg3:Rectangle=null):Array{
var _local6:Entity;
var _local4:Array = new Array();
var _local5:int;
while (_local5 < entities.length) {
_local6 = entities[_local5];
if (collides(_arg1, _local6, _arg2, _arg3)){
_local4.push(_local6);
};
_local5++;
};
return (_local4);
}
override public function update():void{
var _local3:Entity;
var _local1:Array = Utils.cloneArray(entities);
_local1.sortOn("y", Array.DESCENDING);
var _local2:int;
while (_local2 < _local1.length) {
_local3 = _local1[_local2];
_local3.update();
_local2++;
};
}
public function isDone():Boolean{
return (false);
}
public function collides(_arg1:Entity, _arg2:Entity, _arg3:Boolean, _arg4:Rectangle=null):Boolean{
var _local5:Rectangle = ((_arg4 == null)) ? _arg1.collisionArea() : _arg4;
return (((((!((_arg2 == _arg1))) && (((_arg3) || (((_arg1.canHit(_arg2)) && (_arg2.canHit(_arg1)))))))) && (_local5.intersects(_arg2.collisionArea()))));
}
public function addEntityAt(_arg1:Entity, _arg2:int=-1, _arg3:int=-1):Entity{
if (_arg2 != -1){
_arg1.x = _arg2;
};
if (_arg3 != -1){
_arg1.y = _arg3;
};
_arg1.world = this;
entities.push(_arg1);
_arg1.onAdded();
return (_arg1);
}
public function filterEntities(_arg1:Function):Array{
var _local4:Entity;
var _local2:Array = new Array();
var _local3:int;
while (_local3 < entities.length) {
_local4 = entities[_local3];
if (_arg1(_local4)){
_local2.push(_local4);
};
_local3++;
};
return (_local2);
}
public function getEntitiesIn(_arg1:Rectangle, _arg2:Entity=null):Array{
var _local5:Entity;
var _local6:Rectangle;
var _local3:Array = new Array();
var _local4:int;
while (_local4 < entities.length) {
_local5 = entities[_local4];
_local6 = _arg1;
_local6.inflate(1, 1);
if (((!((_local5 == _arg2))) && (_arg1.containsRect(_local5.collisionArea())))){
_local3.push(_local5);
};
_local4++;
};
return (_local3);
}
}
}//package