[Tools][Expand/Collapse All]Note that automatic extraction of ActionScript 3 is still pretty much unsupported by swfchan. AS1/AS2 works okay most of the time.Section 1 (2.02 KiB) ●
//MainTimeline (Chibi_Latios_fla.MainTimeline)
package Chibi_Latios_fla {
import com.whirled.*;
import flash.events.*;
import flash.display.*;
public dynamic class MainTimeline extends MovieClip {
public var _ctrl:AvatarControl;
public var _body:Body;
public function MainTimeline(){
addFrameScript(0, frame1, 1, frame2, 81, frame82, 86, frame87, 117, frame118, 197, frame198, 202, frame203, 203, frame204, 228, frame229, 243, frame244, 283, frame284, 288, frame289, 308, frame309, 318, frame319, 334, frame335, 335, frame336, 375, frame376, 376, frame377);
}
function frame319(){
_ctrl.setHotSpot(193, 320);
}
function frame204(){
_ctrl.setMoveSpeed(2000);
}
function frame87(){
_ctrl.setMoveSpeed(200);
}
function frame289(){
_ctrl.setHotSpot(193, 320);
_ctrl.setMoveSpeed(200);
}
function frame82(){
_ctrl.setMoveSpeed(200);
}
function frame284(){
_ctrl.setHotSpot(193, 320);
_ctrl.setMoveSpeed(200);
_ctrl.setHotSpot(193, 320);
}
function frame335(){
_ctrl.setHotSpot(193, 320);
}
function frame336(){
_ctrl.setHotSpot(193, 320, 999);
}
public function handleUnload(... _args):void{
_body.shutdown();
}
function frame1(){
if (_ctrl == null){
_ctrl = new AvatarControl(this);
_body = new Body(_ctrl, this, 380);
addEventListener(Event.UNLOAD, handleUnload);
};
}
function frame229(){
_ctrl.setHotSpot(193, 320);
}
function frame203(){
_ctrl.setMoveSpeed(2000);
}
function frame198(){
_ctrl.setMoveSpeed(2000);
}
function frame2(){
_ctrl.setHotSpot(193, 320);
_ctrl.setMoveSpeed(200);
}
function frame118(){
_ctrl.setHotSpot(193, 320);
_ctrl.setMoveSpeed(2000);
}
function frame244(){
_ctrl.setHotSpot(193, 320);
_ctrl.setMoveSpeed(200);
}
function frame376(){
_ctrl.setHotSpot(193, 320, 999);
_ctrl.setMoveSpeed(2000);
}
function frame377(){
_ctrl.setHotSpot(193, 320);
}
function frame309(){
_ctrl.setHotSpot(193, 320);
_ctrl.setMoveSpeed(200);
}
}
}//package Chibi_Latios_fla
Section 2 (1.32 KiB) ●
//Environment (com.threerings.util.env.Environment)
package com.threerings.util.env {
import flash.utils.*;
public class Environment {
private static function getClassByName(_arg1:String):Class{
var cname = _arg1;
try {
return ((getDefinitionByName(cname.replace("::", ".")) as Class));
} catch(error:ReferenceError) {
};
return (null);
}
public static function isAssignableAs(_arg1:Class, _arg2:Class):Boolean{
var _local3:XMLList;
var _local4:XMLList;
var _local5:String;
var _local6:XMLList;
if (_arg1 == _arg2){
return (true);
};
if (_arg2 == Object){
return (false);
};
_local3 = describeType(_arg2).child("factory");
_local4 = _local3.child("extendsClass").attribute("type");
for each (_local5 in _local4) {
if (_arg1 == getClassByName(_local5)){
return (true);
};
};
_local6 = _local3.child("implementsInterface").attribute("type");
for each (_local5 in _local6) {
if (_arg1 == getClassByName(_local5)){
return (true);
};
};
return (false);
}
public static function enumerateFields(_arg1:Object):Array{
var _local2:Array;
var _local3:String;
_local2 = [];
for each (_local3 in describeType(_arg1)..variable.@name) {
_local2.push(_local3);
};
return (_local2);
}
}
}//package com.threerings.util.env
Section 3 (4.94 KiB) ●
//ArrayUtil (com.threerings.util.ArrayUtil)
package com.threerings.util {
public class ArrayUtil {
public static function shuffle(_arg1:Array, _arg2:Random=null):void{
var randFunc:Function;
var ii:int;
var idx:int;
var tmp:Object;
var arr = _arg1;
var rando = _arg2;
randFunc = ((rando)!=null) ? rando.nextInt : function (_arg1:int):int{
return (int((Math.random() * _arg1)));
};
ii = (arr.length - 1);
while (ii > 0) {
idx = randFunc((ii + 1));
tmp = arr[idx];
arr[idx] = arr[ii];
arr[ii] = tmp;
ii = (ii - 1);
};
}
public static function removeAllIf(_arg1:Array, _arg2:Function):Boolean{
return (removeIfImpl(_arg1, _arg2, false));
}
private static function createEqualsPred(_arg1:Object):Function{
var element = _arg1;
return (function (_arg1:Object):Boolean{
return (Util.equals(_arg1, element));
});
}
private static function removeImpl(_arg1:Array, _arg2:Object, _arg3:Boolean):Boolean{
return (removeIfImpl(_arg1, createEqualsPred(_arg2), _arg3));
}
public static function equals(_arg1:Array, _arg2:Array):Boolean{
var _local3:int;
if (_arg1 === _arg2){
return (true);
};
if ((((((_arg1 == null)) || ((_arg2 == null)))) || (!((_arg1.length == _arg2.length))))){
return (false);
};
_local3 = 0;
while (_local3 < _arg1.length) {
if (!Util.equals(_arg1[_local3], _arg2[_local3])){
return (false);
};
_local3++;
};
return (true);
}
private static function removeIfImpl(_arg1:Array, _arg2:Function, _arg3:Boolean):Boolean{
var _local4:Boolean;
var _local5:int;
_local4 = false;
_local5 = 0;
while (_local5 < _arg1.length) {
if (_arg2(_arg1[_local5])){
var _temp1 = _local5;
_local5 = (_local5 - 1);
_arg1.splice(_temp1, 1);
if (_arg3){
return (true);
};
_local4 = true;
};
_local5++;
};
return (_local4);
}
public static function indexOf(_arg1:Array, _arg2:Object):int{
var _local3:int;
if (_arg1 != null){
_local3 = 0;
while (_local3 < _arg1.length) {
if (Util.equals(_arg1[_local3], _arg2)){
return (_local3);
};
_local3++;
};
};
return (-1);
}
public static function removeFirst(_arg1:Array, _arg2:Object):Boolean{
return (removeImpl(_arg1, _arg2, true));
}
public static function indexIf(_arg1:Array, _arg2:Function):int{
var _local3:int;
if (_arg1 != null){
_local3 = 0;
while (_local3 < _arg1.length) {
if (_arg2(_arg1[_local3])){
return (_local3);
};
_local3++;
};
};
return (-1);
}
public static function removeFirstIf(_arg1:Array, _arg2:Function):Boolean{
return (removeIfImpl(_arg1, _arg2, true));
}
public static function copyOf(_arg1:Array):Array{
return (_arg1.slice());
}
public static function copy(_arg1:Array, _arg2:uint, _arg3:Array, _arg4:uint, _arg5:uint):void{
var _local6:uint;
_local6 = 0;
while (_local6 < _arg5) {
var _temp1 = _arg4;
_arg4 = (_arg4 + 1);
var _local7 = _temp1;
var _temp2 = _arg2;
_arg2 = (_arg2 + 1);
_arg3[_local7] = _arg1[_temp2];
_local6++;
};
}
public static function findIf(_arg1:Array, _arg2:Function){
var _local3:int;
_local3 = ((_arg1)!=null) ? indexIf(_arg1, _arg2) : -1;
return (((_local3 >= 0)) ? _arg1[_local3] : undefined);
}
public static function removeLastIf(_arg1:Array, _arg2:Function):Boolean{
var _local3:Boolean;
_arg1.reverse();
_local3 = removeFirstIf(_arg1, _arg2);
_arg1.reverse();
return (_local3);
}
public static function stableSort(_arg1:Array, _arg2:Function=null):void{
var _local3:int;
var _local4:int;
var _local5:*;
var _local6:int;
var _local7:*;
if (_arg2 == null){
_arg2 = Comparators.COMPARABLE;
};
_local3 = _arg1.length;
_local4 = 1;
while (_local4 < _local3) {
_local5 = _arg1[_local4];
_local6 = (_local4 - 1);
while (_local6 >= 0) {
_local7 = _arg1[_local6];
if (_arg2(_local5, _local7) >= 0){
break;
};
_arg1[(_local6 + 1)] = _local7;
_local6--;
};
_arg1[(_local6 + 1)] = _local5;
_local4++;
};
}
public static function removeLast(_arg1:Array, _arg2:Object):Boolean{
var _local3:Boolean;
_arg1.reverse();
_local3 = removeFirst(_arg1, _arg2);
_arg1.reverse();
return (_local3);
}
public static function create(_arg1:uint, _arg2=null):Array{
var _local3:Array;
var _local4:uint;
_local3 = new Array(_arg1);
_local4 = 0;
while (_local4 < _arg1) {
_local3[_local4] = _arg2;
_local4++;
};
return (_local3);
}
public static function removeAll(_arg1:Array, _arg2:Object):Boolean{
return (removeImpl(_arg1, _arg2, false));
}
public static function sort(_arg1:Array):void{
_arg1.sort(Comparators.COMPARABLE);
}
public static function contains(_arg1:Array, _arg2:Object):Boolean{
return (!((indexOf(_arg1, _arg2) == -1)));
}
}
}//package com.threerings.util
Section 4 (156 B)
//Boxed (com.threerings.util.Boxed)
package com.threerings.util {
public interface Boxed {
function unbox():Object;
}
}//package com.threerings.util
Section 5 (1.95 KiB) ●
//ClassUtil (com.threerings.util.ClassUtil)
package com.threerings.util {
import flash.utils.*;
import com.threerings.util.env.*;
public class ClassUtil {
public static function tinyClassName(_arg1:Object):String{
var _local2:String;
var _local3:int;
_local2 = getClassName(_arg1);
_local3 = _local2.lastIndexOf(".");
return (_local2.substring((_local3 + 1)));
}
public static function getClassByName(_arg1:String):Class{
var log:Log;
var cname = _arg1;
try {
return ((getDefinitionByName(cname.replace("::", ".")) as Class));
} catch(error:ReferenceError) {
log = Log.getLog(ClassUtil);
log.warning(("Unknown class: " + cname));
log.logStackTrace(error);
};
return (null);
}
public static function newInstance(_arg1:Object):Object{
var _local2:Class;
_local2 = getClass(_arg1);
return (new (_local2));
}
public static function shortClassName(_arg1:Object):String{
var _local2:String;
var _local3:int;
_local2 = getQualifiedClassName(_arg1);
_local3 = _local2.lastIndexOf(".");
_local2 = _local2.substring((_local3 + 1));
return (_local2.replace("::", "."));
}
public static function isSameClass(_arg1:Object, _arg2:Object):Boolean{
return ((getQualifiedClassName(_arg1) == getQualifiedClassName(_arg2)));
}
public static function getClass(_arg1:Object):Class{
if ((_arg1.constructor is Class)){
return (Class(_arg1.constructor));
};
return (getClassByName(getQualifiedClassName(_arg1)));
}
public static function isFinal(_arg1:Class):Boolean{
if (_arg1 === String){
return (true);
};
if (isAssignableAs(Enum, _arg1)){
return (true);
};
return (false);
}
public static function getClassName(_arg1:Object):String{
return (getQualifiedClassName(_arg1).replace("::", "."));
}
public static function isAssignableAs(_arg1:Class, _arg2:Class):Boolean{
return (Environment.isAssignableAs(_arg1, _arg2));
}
}
}//package com.threerings.util
Section 6 (184 B)
//Comparable (com.threerings.util.Comparable)
package com.threerings.util {
public interface Comparable {
function compareTo(_arg1:Object):int;
}
}//package com.threerings.util
Section 7 (397 B)
//Comparators (com.threerings.util.Comparators)
package com.threerings.util {
public class Comparators {
public static function COMPARABLE(_arg1:Comparable, _arg2:Comparable):int{
if (_arg1 == _arg2){
return (0);
};
if (_arg1 == null){
return (-1);
};
if (_arg2 == null){
return (1);
};
return (_arg1.compareTo(_arg2));
}
}
}//package com.threerings.util
Section 8 (2.22 KiB) ●
//Enum (com.threerings.util.Enum)
package com.threerings.util {
import flash.utils.*;
public class Enum implements Hashable, Comparable {
protected var _name:String;
private static const _enums:Dictionary = new Dictionary(true);
private static const _blocked:Dictionary = new Dictionary(true);
public function Enum(_arg1:String){
var _local2:Class;
var _local3:Array;
var _local4:Enum;
super();
_local2 = ClassUtil.getClass(this);
if (Boolean(_blocked[_local2])){
throw (new Error("You may not just construct an enum!"));
};
if (_arg1 == null){
throw (new ArgumentError("null is invalid."));
};
_local3 = (_enums[_local2] as Array);
if (_local3 == null){
_local3 = [];
_enums[_local2] = _local3;
} else {
for each (_local4 in _local3) {
if (_local4.name() === _arg1){
throw (new ArgumentError(("Duplicate enum: " + _arg1)));
};
};
};
_local3.push(this);
_name = _arg1;
}
public function compareTo(_arg1:Object):int{
if (!ClassUtil.isSameClass(this, _arg1)){
throw (new ArgumentError("Not same class"));
};
return (Integer.compare(this.ordinal(), Enum(_arg1).ordinal()));
}
public function name():String{
return (_name);
}
public function toString():String{
return (_name);
}
public function ordinal():int{
return ((_enums[ClassUtil.getClass(this)] as Array).indexOf(this));
}
public function hashCode():int{
return (ordinal());
}
public function equals(_arg1:Object):Boolean{
return ((_arg1 === this));
}
public static function values(_arg1:Class):Array{
var _local2:Array;
_local2 = (_enums[_arg1] as Array);
if (_local2 == null){
throw (new ArgumentError((("Not an enum [class=" + _arg1) + "].")));
};
return (_local2.concat());
}
public static function valueOf(_arg1:Class, _arg2:String):Enum{
var _local3:Enum;
for each (_local3 in values(_arg1)) {
if (_local3.name() === _arg2){
return (_local3);
};
};
throw (new ArgumentError((((("No such enum [class=" + _arg1) + ", name=") + _arg2) + "].")));
}
protected static function finishedEnumerating(_arg1:Class):void{
_blocked[_arg1] = true;
}
finishedEnumerating(Enum);
}
}//package com.threerings.util
Section 9 (182 B)
//Equalable (com.threerings.util.Equalable)
package com.threerings.util {
public interface Equalable {
function equals(_arg1:Object):Boolean;
}
}//package com.threerings.util
Section 10 (183 B)
//Hashable (com.threerings.util.Hashable)
package com.threerings.util {
public interface Hashable extends Equalable {
function hashCode():int;
}
}//package com.threerings.util
Section 11 (7.04 KiB) ● ●
//HashMap (com.threerings.util.HashMap)
package com.threerings.util {
import flash.utils.*;
import flash.errors.*;
public class HashMap implements Map {
protected var _equalsFn:Function;
protected var _entries:Array;
protected var _hashFn:Function;
protected var _simpleData:Dictionary;
protected var _entriesSize:int;// = 0
protected var _loadFactor:Number;
protected var _simpleSize:int;// = 0
protected static const DEFAULT_BUCKETS:int = 16;
public function HashMap(_arg1:Number=1.75, _arg2:Function=null, _arg3:Function=null){
_simpleSize = 0;
_entriesSize = 0;
super();
if (!((_arg2 == null)) != !((_arg3 == null))){
throw (new ArgumentError(("Both the equals and hash functions " + "must be specified, or neither.")));
};
_loadFactor = _arg1;
_equalsFn = _arg2;
_hashFn = _arg3;
}
public function containsKey(_arg1:Object):Boolean{
return (!((undefined === get(_arg1))));
}
public function remove(_arg1:Object){
var _local2:Hashable;
var _local3:int;
var _local4:int;
var _local5:HashMap_Entry;
var _local6:HashMap_Entry;
var _local7:*;
var _local8:HashMap_Entry;
if (isSimple(_arg1)){
if (_simpleData == null){
return (undefined);
};
_local7 = _simpleData[_arg1];
if (_local7 !== undefined){
_simpleSize--;
};
delete _simpleData[_arg1];
return (_local7);
};
if (_entries == null){
return (undefined);
};
_local2 = keyFor(_arg1);
_local3 = _local2.hashCode();
_local4 = indexFor(_local3);
_local5 = (_entries[_local4] as HashMap_Entry);
_local6 = _local5;
while (_local6 != null) {
_local8 = _local6.next;
if ((((_local6.hash == _local3)) && (_local6.key.equals(_local2)))){
if (_local5 == _local6){
_entries[_local4] = _local8;
} else {
_local5.next = _local8;
};
_entriesSize--;
if ((((_entries.length > DEFAULT_BUCKETS)) && ((_entriesSize < ((_entries.length * _loadFactor) * 0.125))))){
resize(Math.max(DEFAULT_BUCKETS, (_entries.length / 2)));
};
return (_local6.value);
};
_local5 = _local6;
_local6 = _local8;
};
return (undefined);
}
public function size():int{
return ((_simpleSize + _entriesSize));
}
public function isEmpty():Boolean{
return ((size() == 0));
}
protected function resize(_arg1:int):void{
var _local2:Array;
var _local3:int;
var _local4:HashMap_Entry;
var _local5:HashMap_Entry;
var _local6:int;
_local2 = _entries;
_entries = new Array();
_entries.length = _arg1;
_local3 = 0;
while (_local3 < _local2.length) {
_local4 = (_local2[_local3] as HashMap_Entry);
while (_local4 != null) {
_local5 = _local4.next;
_local6 = indexFor(_local4.hash);
_local4.next = (_entries[_local6] as HashMap_Entry);
_entries[_local6] = _local4;
_local4 = _local5;
};
_local3++;
};
}
public function clear():void{
_simpleData = null;
_simpleSize = 0;
_entries = null;
_entriesSize = 0;
}
public function put(_arg1:Object, _arg2:Object){
var _local3:*;
var _local4:Hashable;
var _local5:int;
var _local6:int;
var _local7:HashMap_Entry;
var _local8:HashMap_Entry;
if (isSimple(_arg1)){
if (_simpleData == null){
_simpleData = new Dictionary();
};
_local3 = _simpleData[_arg1];
_simpleData[_arg1] = _arg2;
if (_local3 === undefined){
_simpleSize++;
};
return (_local3);
};
if (_entries == null){
_entries = new Array();
_entries.length = DEFAULT_BUCKETS;
};
_local4 = keyFor(_arg1);
_local5 = _local4.hashCode();
_local6 = indexFor(_local5);
_local7 = (_entries[_local6] as HashMap_Entry);
_local8 = _local7;
while (_local8 != null) {
if ((((_local8.hash == _local5)) && (_local8.key.equals(_local4)))){
_local3 = _local8.value;
_local8.value = _arg2;
return (_local3);
};
_local8 = _local8.next;
};
_entries[_local6] = new HashMap_Entry(_local5, _local4, _arg2, _local7);
_entriesSize++;
if (_entriesSize > (_entries.length * _loadFactor)){
resize((2 * _entries.length));
};
return (undefined);
}
protected function indexFor(_arg1:int):int{
return ((Math.abs(_arg1) % _entries.length));
}
public function values():Array{
var _local1:Array;
var _local2:*;
var _local3:int;
var _local4:HashMap_Entry;
_local1 = new Array();
if (_simpleData != null){
for each (_local2 in _simpleData) {
_local1.push(_local2);
};
};
if (_entries != null){
_local3 = (_entries.length - 1);
while (_local3 >= 0) {
_local4 = (_entries[_local3] as HashMap_Entry);
while (_local4 != null) {
_local1.push(_local4.value);
_local4 = _local4.next;
};
_local3--;
};
};
return (_local1);
}
public function get(_arg1:Object){
var _local2:Hashable;
var _local3:int;
var _local4:int;
var _local5:HashMap_Entry;
if (isSimple(_arg1)){
return (((_simpleData)==null) ? undefined : _simpleData[_arg1]);
};
if (_entries == null){
return (undefined);
};
_local2 = keyFor(_arg1);
_local3 = _local2.hashCode();
_local4 = indexFor(_local3);
_local5 = (_entries[_local4] as HashMap_Entry);
while (_local5 != null) {
if ((((_local5.hash == _local3)) && (_local5.key.equals(_local2)))){
return (_local5.value);
};
_local5 = _local5.next;
};
return (undefined);
}
protected function keyFor(_arg1:Object):Hashable{
if ((_arg1 is Hashable)){
return ((_arg1 as Hashable));
};
if (_hashFn == null){
throw (new IllegalOperationError(("Illegal key specified " + "for HashMap created without hashing functions.")));
};
return (new HashMap_KeyWrapper(_arg1, _equalsFn, _hashFn));
}
public function forEach(_arg1:Function):void{
var _local2:Object;
var _local3:int;
var _local4:HashMap_Entry;
if (_simpleData != null){
for (_local2 in _simpleData) {
_arg1(_local2, _simpleData[_local2]);
};
};
if (_entries != null){
_local3 = (_entries.length - 1);
while (_local3 >= 0) {
_local4 = (_entries[_local3] as HashMap_Entry);
while (_local4 != null) {
_arg1(_local4.getOriginalKey(), _local4.value);
_local4 = _local4.next;
};
_local3--;
};
};
}
public function keys():Array{
var _local1:Array;
var _local2:*;
var _local3:int;
var _local4:HashMap_Entry;
_local1 = new Array();
if (_simpleData != null){
for (_local2 in _simpleData) {
_local1.push(_local2);
};
};
if (_entries != null){
_local3 = (_entries.length - 1);
while (_local3 >= 0) {
_local4 = (_entries[_local3] as HashMap_Entry);
while (_local4 != null) {
_local1.push(_local4.getOriginalKey());
_local4 = _local4.next;
};
_local3--;
};
};
return (_local1);
}
protected function isSimple(_arg1:Object):Boolean{
return ((((((((((_arg1 == null)) || ((_arg1 is String)))) || ((_arg1 is Number)))) || ((_arg1 is Boolean)))) || ((_arg1 is Enum))));
}
}
}//package com.threerings.util
Section 12 (600 B)
//HashMap_Entry (com.threerings.util.HashMap_Entry)
package com.threerings.util {
public class HashMap_Entry {
public var hash:int;
public var value:Object;
public var next:HashMap_Entry;
public var key:Hashable;
public function HashMap_Entry(_arg1:int, _arg2:Hashable, _arg3:Object, _arg4:HashMap_Entry){
this.hash = _arg1;
this.key = _arg2;
this.value = _arg3;
this.next = _arg4;
}
public function getOriginalKey():Object{
if ((key is HashMap_KeyWrapper)){
return ((key as HashMap_KeyWrapper).key);
};
return (key);
}
}
}//package com.threerings.util
Section 13 (1.1 KiB) ●
//HashMap_KeyWrapper (com.threerings.util.HashMap_KeyWrapper)
package com.threerings.util {
public class HashMap_KeyWrapper implements Hashable {
protected var _key:Object;
protected var _hash:int;
public var key:Object;
protected var _equalsFn:Function;
public function HashMap_KeyWrapper(_arg1:Object, _arg2:Function, _arg3:Function){
var _local4:*;
var _local5:String;
var _local6:int;
var _local7:int;
super();
this.key = _arg1;
_equalsFn = _arg2;
_local4 = _arg3(_arg1);
if ((_local4 is String)){
_local5 = (_local4 as String);
_local6 = int(Math.max(1, Math.ceil((_local5.length / 32))));
_local7 = 0;
while (_local7 < _local5.length) {
_hash = ((_hash << 1) ^ int(_local5.charCodeAt(_local7)));
_local7 = (_local7 + _local6);
};
} else {
_hash = int(_local4);
};
}
public function hashCode():int{
return (_hash);
}
public function equals(_arg1:Object):Boolean{
return ((((_arg1 is HashMap_KeyWrapper)) && (Boolean(_equalsFn(key, (_arg1 as HashMap_KeyWrapper).key)))));
}
}
}//package com.threerings.util
Section 14 (735 B)
//Integer (com.threerings.util.Integer)
package com.threerings.util {
public class Integer implements Equalable, Boxed {
public var value:int;
public function Integer(_arg1:int){
this.value = _arg1;
}
public function equals(_arg1:Object):Boolean{
return ((((_arg1 is Integer)) && ((value === (_arg1 as Integer).value))));
}
public function unbox():Object{
return (value);
}
public function toString():String{
return (value.toString());
}
public static function valueOf(_arg1:int):Integer{
return (new Integer(_arg1));
}
public static function compare(_arg1:int, _arg2:int):int{
return (((_arg1)>_arg2) ? 1 : ((_arg1 == _arg2)) ? 0 : -1);
}
}
}//package com.threerings.util
Section 15 (4.69 KiB) ●
//Log (com.threerings.util.Log)
package com.threerings.util {
import flash.utils.*;
public class Log {
protected var _module:String;
protected static const LEVEL_NAMES:Array = ["debug", "INFO", "WARN", "ERROR", false];
public static const OFF:int = 4;
public static const ERROR:int = 3;
public static const INFO:int = 1;
public static const DEBUG:int = 0;
public static const WARNING:int = 2;
protected static var _targets:Array = [];
protected static var _levels:Object = {};
protected static var _setLevels:Object = {:DEBUG};
public function Log(_arg1:String){
if (_arg1 == null){
_arg1 = "";
};
_module = _arg1;
}
protected function getTimeStamp():String{
var _local1:Date;
_local1 = new Date();
return (((((((((((((_local1.fullYear + "-") + StringUtil.prepad(String((_local1.month + 1)), 2, "0")) + "-") + StringUtil.prepad(String(_local1.date), 2, "0")) + " ") + StringUtil.prepad(String(_local1.hours), 2, "0")) + ":") + StringUtil.prepad(String(_local1.minutes), 2, "0")) + ":") + StringUtil.prepad(String(_local1.seconds), 2, "0")) + ",") + StringUtil.prepad(String(_local1.milliseconds), 3, "0")));
}
public function logStackTrace(_arg1:Error):void{
warning(_arg1.getStackTrace());
}
public function info(... _args):void{
doLog(INFO, _args);
}
public function error(... _args):void{
doLog(ERROR, _args);
}
protected function formatMessage(_arg1:int, _arg2:Array):String{
var _local3:String;
var _local4:Error;
var _local5:Object;
var _local6:int;
_local3 = ((((getTimeStamp() + " ") + LEVEL_NAMES[_arg1]) + ": ") + _module);
if (_arg2.length > 0){
_local3 = (_local3 + (" " + String(_arg2[0])));
_local4 = null;
if ((_arg2.length % 2) == 0){
_local5 = _arg2.pop();
if ((_local5 is Error)){
_local4 = (_local5 as Error);
} else {
_arg2.push(_local5, "");
};
};
if (_arg2.length > 1){
_local6 = 1;
while (_local6 < _arg2.length) {
_local3 = (_local3 + ((_local6)==1) ? " [" : ", ");
_local3 = (_local3 + ((String(_arg2[_local6]) + "=") + String(_arg2[(_local6 + 1)])));
_local6 = (_local6 + 2);
};
_local3 = (_local3 + "]");
};
if (_local4 != null){
_local3 = (_local3 + ("\n" + _local4.getStackTrace()));
};
};
return (_local3);
}
public function debug(... _args):void{
doLog(DEBUG, _args);
}
protected function doLog(_arg1:int, _arg2:Array):void{
var _local3:String;
var _local4:LogTarget;
if (_arg1 < getLevel(_module)){
return;
};
_local3 = formatMessage(_arg1, _arg2);
trace(_local3);
for each (_local4 in _targets) {
_local4.log(_local3);
};
}
public function warning(... _args):void{
doLog(WARNING, _args);
}
public static function setLevel(_arg1:String, _arg2:int):void{
_setLevels[_arg1] = _arg2;
_levels = {};
}
public static function getLog(_arg1):Log{
var _local2:String;
_local2 = ((_arg1 is String)) ? String(_arg1) : getQualifiedClassName(_arg1).replace("::", ".");
return (new Log(_local2));
}
public static function addTarget(_arg1:LogTarget):void{
_targets.push(_arg1);
}
public static function testing(... _args):void{
var _local2:Log;
_local2 = new Log("testing");
_local2.debug.apply(_local2, _args);
}
protected static function getLevel(_arg1:String):int{
var _local2:Object;
var _local3:String;
var _local4:int;
_local2 = _levels[_arg1];
if (_local2 == null){
_local3 = _arg1;
while (true) {
_local2 = _setLevels[_local3];
if (((!((_local2 == null))) || ((_local3 == "")))){
_levels[_arg1] = int(_local2);
break;
};
_local4 = _local3.lastIndexOf(".");
_local3 = ((_local4)==-1) ? "" : _local3.substring(0, _local4);
};
};
return (int(_local2));
}
public static function setLevels(_arg1:String):void{
var _local2:String;
var _local3:Array;
for each (_local2 in _arg1.split(";")) {
_local3 = _local2.split(":");
_setLevels[_local3[0]] = stringToLevel(String(_local3[1]));
};
_levels = {};
}
public static function dumpStack(_arg1:String="dumpStack"):void{
testing(new Error(_arg1).getStackTrace());
}
public static function removeTarget(_arg1:LogTarget):void{
var _local2:int;
_local2 = _targets.indexOf(_arg1);
if (_local2 != -1){
_targets.splice(_local2, 1);
};
}
protected static function stringToLevel(_arg1:String):int{
switch (_arg1.toLowerCase()){
case "debug":
default:
return (DEBUG);
case "info":
return (INFO);
case "warning":
case "warn":
return (WARNING);
case "error":
return (ERROR);
case "off":
return (OFF);
};
}
}
}//package com.threerings.util
Section 16 (176 B)
//LogTarget (com.threerings.util.LogTarget)
package com.threerings.util {
public interface LogTarget {
function log(_arg1:String):void;
}
}//package com.threerings.util
Section 17 (447 B)
//Map (com.threerings.util.Map)
package com.threerings.util {
public interface Map {
function containsKey(_arg1:Object):Boolean;
function values():Array;
function isEmpty():Boolean;
function remove(_arg1:Object);
function size():int;
function forEach(_arg1:Function):void;
function clear():void;
function put(_arg1:Object, _arg2:Object);
function keys():Array;
function get(_arg1:Object);
}
}//package com.threerings.util
Section 18 (2.68 KiB) ●
//Random (com.threerings.util.Random)
package com.threerings.util {
public class Random {
protected var q:int;
protected var r:int;
protected var p:int;
protected var x:Array;
protected static const MATRIX_A:uint = 2567483615;
protected static const UPPER_MASK:uint = 2147483648;
protected static const LOWER_MASK:uint = 2147483647;
protected static const M:int = 397;
protected static const N:int = 624;
protected static var seedUniquifier:uint = 2812526361;
public function Random(_arg1:uint=0){
if (_arg1 == 0){
_arg1 = uint((seedUniquifier++ + uint((Math.random() * 4294967295))));
};
x = new Array();
setSeed(_arg1);
}
public function nextInt(_arg1:int=0):int{
var _local2:int;
var _local3:int;
if (_arg1 < 0){
throw (new Error("n must be positive"));
};
if (_arg1 == 0){
return (int(next(32)));
};
do {
_local2 = int(next(31));
_local3 = (_local2 % _arg1);
} while (((_local2 - _local3) + (_arg1 - 1)) < 0);
return (_local3);
}
protected function next(_arg1:int):uint{
var _local2:uint;
_local2 = ((x[p] & UPPER_MASK) | (x[q] & LOWER_MASK));
x[p] = ((x[r] ^ (_local2 >>> 1)) ^ ((_local2 & 1) * MATRIX_A));
_local2 = x[p];
if (++p == N){
p = 0;
};
if (++q == N){
q = 0;
};
if (++r == N){
r = 0;
};
_local2 = (_local2 ^ (_local2 >>> 11));
_local2 = (_local2 ^ ((_local2 << 7) & 2636928640));
_local2 = (_local2 ^ ((_local2 << 15) & 4022730752));
_local2 = (_local2 ^ (_local2 >>> 18));
return ((_local2 >>> (32 - _arg1)));
}
public function nextBoolean():Boolean{
return (!((next(1) == 0)));
}
public function setSeed(_arg1:uint):void{
var _local2:int;
x[0] = _arg1;
_local2 = 1;
while (_local2 < N) {
x[_local2] = (imul(1812433253, (x[(_local2 - 1)] ^ (x[(_local2 - 1)] >>> 30))) + _local2);
x[_local2] = (x[_local2] & 4294967295);
_local2++;
};
p = 0;
q = 1;
r = M;
}
protected function imul(_arg1:Number, _arg2:Number):Number{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local3 = (_arg1 & 0xFFFF);
_local4 = (_arg1 >>> 16);
_local5 = (_arg2 & 0xFFFF);
_local6 = (_arg2 >>> 16);
_local7 = (_local3 * _local5);
_local8 = (((((_local7 >>> 16) + (_local3 * _local6)) & 0xFFFF) + (_local4 * _local5)) & 0xFFFF);
return (((_local8 << 16) | (_local7 & 0xFFFF)));
}
public function nextNumber():Number{
return ((next(32) / 4294967296));
}
}
}//package com.threerings.util
Section 19 (521 B)
//StringBuilder (com.threerings.util.StringBuilder)
package com.threerings.util {
public class StringBuilder {
protected var _buf:String;// = ""
public function StringBuilder(... _args){
_buf = "";
super();
append.apply(this, _args);
}
public function append(... _args):StringBuilder{
var _local2:Object;
for each (_local2 in _args) {
_buf = (_buf + String(_local2));
};
return (this);
}
public function toString():String{
return (_buf);
}
}
}//package com.threerings.util
Section 20 (12.88 KiB) ● ●
//StringUtil (com.threerings.util.StringUtil)
package com.threerings.util {
import flash.utils.*;
import com.threerings.util.env.*;
public class StringUtil {
protected static const DECIMAL:Array = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
protected static const URL_REGEXP:RegExp = new RegExp("(http|https|ftp)://\\S+", "i");
protected static const HEX:Array = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
public static function hexlate(_arg1:ByteArray):String{
var _local2:String;
var _local3:int;
var _local4:int;
_local2 = "";
if (_arg1 != null){
_local3 = 0;
while (_local3 < _arg1.length) {
_local4 = _arg1[_local3];
_local2 = (_local2 + (HEX[(_local4 >> 4)] + HEX[(_local4 & 15)]));
_local3++;
};
};
return (_local2);
}
public static function fieldsToString(_arg1:StringBuilder, _arg2:Object, _arg3:Array=null):void{
var _local4:Boolean;
var _local5:String;
if (_arg3 == null){
_arg3 = Environment.enumerateFields(_arg2);
};
_local4 = false;
for each (_local5 in _arg3) {
if (_local4){
_arg1.append(", ");
};
_arg1.append(_local5, "=", _arg2[_local5]);
_local4 = true;
};
}
public static function startsWith(_arg1:String, _arg2:String):Boolean{
return ((_arg1.lastIndexOf(_arg2, 0) == 0));
}
public static function isLowerCase(_arg1:String):Boolean{
var _local2:String;
_local2 = _arg1.charAt(0);
return (((!((_local2.toUpperCase() == _local2))) && ((_local2.toLowerCase() == _local2))));
}
public static function unhexlate(_arg1:String):ByteArray{
var _local2:ByteArray;
var _local3:int;
var _local4:int;
if ((((_arg1 == null)) || (!(((_arg1.length % 2) == 0))))){
return (null);
};
_arg1 = _arg1.toLowerCase();
_local2 = new ByteArray();
_local3 = 0;
while (_local3 < _arg1.length) {
_local4 = (HEX.indexOf(_arg1.charAt(_local3)) << 4);
_local4 = (_local4 + HEX.indexOf(_arg1.charAt((_local3 + 1))));
_local2[(_local3 / 2)] = _local4;
_local3 = (_local3 + 2);
};
return (_local2);
}
public static function isBlank(_arg1:String):Boolean{
return ((((_arg1 == null)) || ((_arg1.search("\\S") == -1))));
}
public static function parseInteger(_arg1:String, _arg2:uint=0):int{
return (int(parseInt0(_arg1, _arg2, true)));
}
public static function isWhitespace(_arg1:String):Boolean{
switch (_arg1){
case " ":
case "\t":
case "\r":
case "\n":
case "\f":
return (true);
default:
return (false);
};
}
public static function hexdump(_arg1:ByteArray):String{
var _local2:String;
var _local3:int;
var _local4:int;
var _local5:uint;
_local2 = "";
_local3 = 0;
while (_local3 < _arg1.length) {
_local2 = (_local2 + toHex(_local3, 4));
_local4 = 0;
while ((((_local4 < 16)) && (((_local3 + _local4) < _arg1.length)))) {
_local5 = _arg1[(_local3 + _local4)];
_local2 = (_local2 + ((" " + HEX[(_local5 >> 4)]) + HEX[(_local5 & 15)]));
_local4++;
};
_local2 = (_local2 + "\n");
_local3 = (_local3 + 16);
};
return (_local2);
}
public static function prepad(_arg1:String, _arg2:int, _arg3:String=" "):String{
while (_arg1.length < _arg2) {
_arg1 = (_arg3 + _arg1);
};
return (_arg1);
}
public static function pad(_arg1:String, _arg2:int, _arg3:String=" "):String{
while (_arg1.length < _arg2) {
_arg1 = (_arg1 + _arg3);
};
return (_arg1);
}
public static function parseUnsignedInteger(_arg1:String, _arg2:uint=0):uint{
var _local3:Number;
_local3 = parseInt0(_arg1, _arg2, false);
if (_local3 < 0){
throw (new ArgumentError((("parseUnsignedInteger parsed negative value [value=" + _arg1) + "].")));
};
return (uint(_local3));
}
public static function trimEnd(_arg1:String):String{
var _local2:int;
if (_arg1 == null){
return (null);
};
_local2 = _arg1.length;
while (isWhitespace(_arg1.charAt((_local2 - 1)))) {
_local2--;
};
return (((_local2)<_arg1.length) ? _arg1.slice(0, _local2) : _arg1);
}
public static function substitute(_arg1:String, ... _args):String{
var _local3:int;
var _local4:int;
var _local2:Array = Util.unfuckVarargs(_args);
_local3 = _local2.length;
_local4 = 0;
while (_local4 < _local3) {
_arg1 = _arg1.replace(new RegExp((("\\{" + _local4) + "\\}"), "g"), _local2[_local4]);
_local4++;
};
return (_arg1);
}
public static function hashCode(_arg1:String):int{
var _local2:int;
var _local3:int;
var _local4:int;
_local2 = 0;
if (_arg1 != null){
_local3 = Math.min(8, _arg1.length);
_local4 = 0;
while (_local4 < _local3) {
_local2 = ((_local2 * 31) + _arg1.charCodeAt(_local4));
_local4++;
};
};
return (_local2);
}
public static function parseNumber(_arg1:String):Number{
var _local2:String;
var _local3:String;
if (_arg1 == null){
throw (new ArgumentError("Cannot parseNumber(null)"));
};
if (_arg1 == "Infinity"){
return (Infinity);
};
if (_arg1 == "-Infinity"){
return (-(Infinity));
};
if (_arg1 == "NaN"){
return (NaN);
};
_local2 = _arg1;
_arg1 = _arg1.replace(",", "");
_local3 = _arg1;
_arg1 = validateDecimal(_arg1, true, true);
if (((!((null == _arg1))) && ((_arg1.charAt(0) == "e")))){
_arg1 = _arg1.substring(1);
validateDecimal(_arg1, false, false);
};
if (null == _arg1){
throw (new ArgumentError((("Could not convert '" + _local2) + "' to Number")));
};
return (parseFloat(_local3));
}
public static function endsWith(_arg1:String, _arg2:String):Boolean{
var _local3:int;
_local3 = (_arg1.length - _arg2.length);
return ((((_local3 >= 0)) && ((_arg1.indexOf(_arg2, _local3) >= 0))));
}
public static function formatNumber(_arg1:Number):String{
var _local2:String;
var _local3:String;
var _local4:int;
var _local5:int;
_local2 = "";
_local3 = _arg1.toString();
_local4 = _local3.lastIndexOf(".");
if (_local4 != -1){
_local2 = _local3.substring(_local4);
_local3 = _local3.substring(0, _local4);
};
_local5 = ((_arg1)<0) ? 1 : 0;
while ((_local3.length - _local5) > 3) {
_local2 = (("," + _local3.substring((_local3.length - 3))) + _local2);
_local3 = _local3.substring(0, (_local3.length - 3));
};
return ((_local3 + _local2));
}
public static function fromBytes(_arg1:ByteArray):String{
var _local2:String;
var _local3:int;
_local2 = "";
if (_arg1 != null){
_local3 = 0;
while (_local3 < _arg1.length) {
_local2 = (_local2 + String.fromCharCode(_arg1[_local3]));
_local3++;
};
};
return (_local2);
}
public static function truncate(_arg1:String, _arg2:int, _arg3:String=""):String{
if ((((_arg1 == null)) || ((_arg1.length <= _arg2)))){
return (_arg1);
};
return ((_arg1.substring(0, (_arg2 - _arg3.length)) + _arg3));
}
public static function toHex(_arg1:uint, _arg2:uint):String{
return (prepad(_arg1.toString(16), _arg2, "0"));
}
public static function deNull(_arg1:String):String{
return (((_arg1)==null) ? "" : _arg1);
}
public static function trim(_arg1:String):String{
return (trimEnd(trimBeginning(_arg1)));
}
public static function trimBeginning(_arg1:String):String{
var _local2:int;
if (_arg1 == null){
return (null);
};
_local2 = 0;
while (isWhitespace(_arg1.charAt(_local2))) {
_local2++;
};
return (((_local2)>0) ? _arg1.slice(_local2, _arg1.length) : _arg1);
}
public static function toString(_arg1, _arg2:Dictionary=null):String{
var _local3:Boolean;
var _local4:String;
var _local5:Array;
var _local6:int;
var _local7:String;
if (_arg1 == null){
return (String(_arg1));
};
_local3 = (_arg1 is Dictionary);
if ((((((_arg1 is Array)) || (_local3))) || (Util.isPlainObject(_arg1)))){
if (_arg2 == null){
_arg2 = new Dictionary();
} else {
if (_arg2[_arg1] !== undefined){
return ("[cyclic reference]");
};
};
_arg2[_arg1] = true;
if ((_arg1 is Array)){
_local5 = (_arg1 as Array);
_local4 = "";
_local6 = 0;
while (_local6 < _local5.length) {
if (_local6 > 0){
_local4 = (_local4 + ", ");
};
_local4 = (_local4 + ((_local6 + ": ") + toString(_local5[_local6], _arg2)));
_local6++;
};
return ((("Array(" + _local4) + ")"));
} else {
_local4 = "";
for (_local7 in _arg1) {
if (_local4.length > 0){
_local4 = (_local4 + ", ");
};
_local4 = (_local4 + ((_local7 + "=>") + toString(_arg1[_local7], _arg2)));
};
return (((((_local3) ? "Dictionary" : "Object" + "(") + _local4) + ")"));
};
} else {
if ((_arg1 is XML)){
return (Util.XMLtoXMLString((_arg1 as XML)));
};
};
return (String(_arg1));
}
public static function isUpperCase(_arg1:String):Boolean{
var _local2:String;
_local2 = _arg1.charAt(0);
return ((((_local2.toUpperCase() == _local2)) && (!((_local2.toLowerCase() == _local2)))));
}
public static function toBytes(_arg1:String):ByteArray{
var _local2:ByteArray;
var _local3:int;
if (_arg1 == null){
return (null);
};
_local2 = new ByteArray();
_local3 = 0;
while (_local3 < _arg1.length) {
_local2[_local3] = (int(_arg1.charCodeAt(_local3)) & 0xFF);
_local3++;
};
return (_local2);
}
protected static function validateDecimal(_arg1:String, _arg2:Boolean, _arg3:Boolean):String{
var _local4:Boolean;
var _local5:Boolean;
var _local6:String;
if (_arg1.charAt(0) == "-"){
_arg1 = _arg1.substring(1);
};
while (_arg1.length > 0) {
_local6 = _arg1.charAt(0);
if (_local6 == "."){
if (((!(_arg2)) || (_local4))){
return (null);
};
_local4 = true;
} else {
if (_local6 == "e"){
if (!_arg3){
return (null);
};
break;
} else {
if (DECIMAL.indexOf(_local6) >= 0){
_local5 = true;
} else {
return (null);
};
};
};
_arg1 = _arg1.substring(1);
};
if (!_local5){
return (null);
};
return (_arg1);
}
protected static function parseInt0(_arg1:String, _arg2:uint, _arg3:Boolean):Number{
var _local5:Boolean;
var _local6:int;
var _local7:Number;
var _local8:int;
if (_arg1 == null){
throw (new ArgumentError("Cannot parseInt(null)"));
};
_local5 = (_arg1.charAt(0) == "-");
if (_local5){
_arg1 = _arg1.substring(1);
};
if (_arg1 == "0"){
return (0);
};
if (_arg2 == 0){
if (startsWith(_arg1, "0x")){
_arg1 = _arg1.substring(2);
_arg2 = 16;
} else {
if (startsWith(_arg1, "0")){
_arg1 = _arg1.substring(1);
_arg2 = 8;
} else {
_arg2 = 10;
};
};
} else {
if ((((_arg2 == 16)) && (startsWith(_arg1, "0x")))){
_arg1 = _arg1.substring(2);
} else {
if ((((_arg2 < 2)) || ((_arg2 > 16)))){
throw (new ArgumentError(("Radix out of range: " + _arg2)));
};
};
};
_local6 = 0;
while (_local6 < _arg1.length) {
_local8 = HEX.indexOf(_arg1.charAt(_local6).toLowerCase());
if ((((_local8 == -1)) || ((_local8 >= _arg2)))){
throw (new ArgumentError(((("Invalid characters in String parseInt='" + arguments[0]) + "', radix=") + _arg2)));
};
_local6++;
};
_local7 = parseInt(_arg1, _arg2);
if (isNaN(_local7)){
throw (new ArgumentError(("Could not parseInt=" + arguments[0])));
};
if (_local5){
_local7 = (_local7 * -1);
};
return (_local7);
}
public static function parseBoolean(_arg1:String):Boolean{
var _local2:String;
_local2 = _arg1;
if (_arg1 != null){
_arg1 = _arg1.toLowerCase();
if ((((_arg1 == "true")) || ((_arg1 == "1")))){
return (true);
};
if ((((_arg1 == "false")) || ((_arg1 == "0")))){
return (false);
};
};
throw (new ArgumentError((("Could not convert '" + _local2) + "' to Boolean")));
}
public static function parseURLs(_arg1:String):Array{
var _local2:Array;
var _local3:Object;
var _local4:int;
var _local5:String;
_local2 = [];
while (true) {
_local3 = URL_REGEXP.exec(_arg1);
if (_local3 == null){
break;
};
_local4 = int(_local3.index);
_local5 = String(_local3[0]);
_local2.push(_arg1.substring(0, _local4), _local5);
_arg1 = _arg1.substring((_local4 + _local5.length));
};
if (((!((_arg1 == ""))) || ((_local2.length == 0)))){
_local2.push(_arg1);
};
return (_local2);
}
public static function simpleToString(_arg1:Object, _arg2:Array=null):String{
var _local3:StringBuilder;
_local3 = new StringBuilder("[");
_local3.append(ClassUtil.tinyClassName(_arg1));
_local3.append("(");
fieldsToString(_local3, _arg1, _arg2);
return (_local3.append(")]").toString());
}
}
}//package com.threerings.util
Section 21 (2.95 KiB) ●
//Util (com.threerings.util.Util)
package com.threerings.util {
import flash.utils.*;
public class Util {
public static function init(_arg1:Object, _arg2:Object, _arg3:Object=null, _arg4:Object=null):void{
var _local5:String;
for (_local5 in _arg2) {
if ((((_arg4 == null)) || (!((_local5 in _arg4))))){
_arg1[_local5] = _arg2[_local5];
};
};
if (_arg3 != null){
for (_local5 in _arg3) {
if ((((_arg2 == null)) || (!((_local5 in _arg2))))){
_arg1[_local5] = _arg3[_local5];
};
};
};
}
public static function XMLtoString(_arg1:XML, _arg2:Object=null):String{
var xml = _arg1;
var settings = _arg2;
return ((safeXMLOp(function (){
return (xml.toString());
}, settings) as String));
}
public static function unfuckVarargs(_arg1:Array):Array{
return (((((_arg1.length == 1)) && ((_arg1[0] is Array)))) ? (_arg1[0] as Array) : _arg1);
}
public static function XMLtoXMLString(_arg1:XML, _arg2:Object=null):String{
var xml = _arg1;
var settings = _arg2;
return ((safeXMLOp(function (){
return (xml.toXMLString());
}, settings) as String));
}
public static function newXML(_arg1:Object, _arg2:Object=null):XML{
var value = _arg1;
var settings = _arg2;
return ((safeXMLOp(function (){
return (new XML(value));
}, settings) as XML));
}
public static function safeXMLOp(_arg1:Function, _arg2:Object=null){
var oldSettings:Object;
var fn = _arg1;
var settings = _arg2;
oldSettings = XML.settings();
try {
XML.setSettings(settings);
var _local4:* = fn();
//unresolved jump
0;
return (_local4);
} finally {
XML.setSettings(oldSettings);
};
}
public static function isSimple(_arg1:Object):Boolean{
var _local2:String;
_local2 = typeof(_arg1);
switch (_local2){
case "number":
case "string":
case "boolean":
return (true);
case "object":
return ((((_arg1 is Date)) || ((_arg1 is Array))));
default:
return (false);
};
}
public static function equals(_arg1:Object, _arg2:Object):Boolean{
var _local3:ByteArray;
var _local4:ByteArray;
var _local5:int;
if (_arg1 === _arg2){
return (true);
};
if ((_arg1 is Equalable)){
return ((_arg1 as Equalable).equals(_arg2));
};
if ((((_arg1 is Array)) && ((_arg2 is Array)))){
return (ArrayUtil.equals((_arg1 as Array), (_arg2 as Array)));
};
if ((((_arg1 is ByteArray)) && ((_arg2 is ByteArray)))){
_local3 = (_arg1 as ByteArray);
_local4 = (_arg2 as ByteArray);
if (_local3.length != _local4.length){
return (false);
};
_local5 = 0;
while (_local5 < _local3.length) {
if (_local3[_local5] != _local4[_local5]){
return (false);
};
_local5++;
};
return (true);
};
return (false);
}
public static function isPlainObject(_arg1:Object):Boolean{
return ((getQualifiedClassName(_arg1) == "Object"));
}
}
}//package com.threerings.util
Section 22 (3.99 KiB) ●
//AbstractControl (com.whirled.AbstractControl)
package com.whirled {
import flash.events.*;
import flash.display.*;
import flash.errors.*;
public class AbstractControl extends EventDispatcher {
protected var _subControls:Array;
protected var _funcs:Object;
public function AbstractControl(_arg1:DisplayObject, _arg2:Object=null){
var _local3:Object;
var _local4:ConnectEvent;
var _local5:Object;
super();
_subControls = createSubControls();
if ((this is AbstractSubControl)){
return;
};
if (_arg1.root == null){
throw (new Error("Display object used to instantiate a control must be on the stage"));
};
_arg1.root.loaderInfo.addEventListener(Event.UNLOAD, handleUnload, false, 0, true);
_local3 = ((_arg2)!=null) ? _arg2 : new Object();
setUserProps(_local3);
_local4 = new ConnectEvent();
_local4.props.userProps = _local3;
_arg1.root.loaderInfo.sharedEvents.dispatchEvent(_local4);
if (Boolean(_local4.props.alreadyConnected)){
throw (new Error("You've already set up a Control instance. There should only be one."));
};
_local5 = _local4.props.hostProps;
if (_local5 != null){
gotHostProps(_local5);
};
}
override public function dispatchEvent(_arg1:Event):Boolean{
throw (new IllegalOperationError());
}
protected function dispatch(_arg1:Event):void{
var event = _arg1;
try {
super.dispatchEvent(event);
} catch(err:Error) {
trace("Error dispatching event to user code.");
trace(err.getStackTrace());
};
}
protected function handleUnload(_arg1:Event):void{
dispatch(_arg1);
}
override public function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{
super.removeEventListener(_arg1, _arg2, _arg3);
}
override public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
super.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5);
}
protected function checkIsConnected():void{
if (!isConnected()){
throw (new IllegalOperationError(("The control is not connected to the host framework, please check isConnected(). " + "If false, your SWF is being viewed standalone and should adjust.")));
};
}
protected function setUserProps(_arg1:Object):void{
var _local2:AbstractSubControl;
for each (_local2 in _subControls) {
_local2.setUserPropsFriend(_arg1);
};
}
public function doBatch(_arg1:Function, ... _args):void{
var fn = _arg1;
var args = _args;
callHostCode("startTransaction");
try {
fn.apply(null, args);
} finally {
callHostCode("commitTransaction");
};
}
function callHostCodeFriend(_arg1:String, _arg2:Array){
_arg2.unshift(_arg1);
return (callHostCode.apply(this, _arg2));
}
protected function callHostCode(_arg1:String, ... _args){
var func:Function;
var name = _arg1;
var args = _args;
if (_funcs != null){
try {
func = (_funcs[name] as Function);
if (func == null){
trace((("Host code \"" + name) + "\" not found!"));
} else {
return (func.apply(null, args));
};
} catch(err:Error) {
trace(((((("Error! Your code is broken! Unable to call a host method, perhaps " + "you've been shut down? [msg=") + err.message) + ", trace=") + err.getStackTrace()) + "]."));
};
} else {
checkIsConnected();
};
return (undefined);
}
protected function createSubControls():Array{
return (null);
}
protected function gotHostProps(_arg1:Object):void{
var _local2:AbstractSubControl;
_funcs = _arg1;
for each (_local2 in _subControls) {
_local2.gotHostPropsFriend(_arg1);
};
}
public function isConnected():Boolean{
return (!((_funcs == null)));
}
}
}//package com.whirled
import flash.events.*;
class ConnectEvent extends Event {
public var props:Object;
private function ConnectEvent(_arg1:Object=null){
super("controlConnect", true, false);
props = ((_arg1) || ({}));
}
override public function clone():Event{
return (new ConnectEvent(props));
}
}
Section 23 (912 B)
//AbstractSubControl (com.whirled.AbstractSubControl)
package com.whirled {
import flash.events.*;
public class AbstractSubControl extends AbstractControl {
protected var _parent:AbstractControl;
public function AbstractSubControl(_arg1:AbstractControl){
_parent = _arg1;
_parent.addEventListener(Event.UNLOAD, handleUnload, false, 0, true);
super(null);
}
function gotHostPropsFriend(_arg1:Object):void{
gotHostProps(_arg1);
}
function setUserPropsFriend(_arg1:Object):void{
setUserProps(_arg1);
}
override public function doBatch(_arg1:Function, ... _args):void{
_args.unshift(_arg1);
_parent.doBatch.apply(null, _args);
}
override protected function callHostCode(_arg1:String, ... _args){
return (_parent.callHostCodeFriend(_arg1, _args));
}
override public function isConnected():Boolean{
return (_parent.isConnected());
}
}
}//package com.whirled
Section 24 (1.96 KiB) ●
//ActorControl (com.whirled.ActorControl)
package com.whirled {
import flash.display.*;
public class ActorControl extends EntityControl {
protected var _orient:Number;// = 0
protected var _isMoving:Boolean;
public function ActorControl(_arg1:DisplayObject){
_orient = 0;
super(_arg1);
}
override protected function gotInitProps(_arg1:Object):void{
super.gotInitProps(_arg1);
_orient = (_arg1["orient"] as Number);
_isMoving = (_arg1["isMoving"] as Boolean);
}
public function isMoving():Boolean{
return (_isMoving);
}
public function getOrientation():Number{
return (_orient);
}
override protected function setUserProps(_arg1:Object):void{
super.setUserProps(_arg1);
_arg1["appearanceChanged_v2"] = appearanceChanged_v2;
_arg1["stateSet_v1"] = stateSet_v1;
}
public function setLogicalLocation(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
callHostCode("setLocation_v1", _arg1, _arg2, _arg3, _arg4);
}
public function setMoveSpeed(_arg1:Number):void{
callHostCode("setMoveSpeed_v1", _arg1);
}
public function setPixelLocation(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local5:Array;
_local5 = getRoomBounds();
setLogicalLocation((_arg1 / _local5[0]), (_arg2 / _local5[1]), (_arg3 / _local5[2]), _arg4);
}
public function setState(_arg1:String):void{
callHostCode("setState_v1", _arg1);
}
public function getState():String{
return ((isConnected()) ? (callHostCode("getState_v1") as String) : null);
}
public function setOrientation(_arg1:Number):void{
callHostCode("setOrientation_v1", _arg1);
}
protected function stateSet_v1(_arg1:String):void{
dispatchCtrlEvent(ControlEvent.STATE_CHANGED, _arg1);
}
protected function appearanceChanged_v2(_arg1:Array, _arg2:Number, _arg3:Boolean, _arg4:Boolean):void{
_location = _arg1;
_orient = _arg2;
_isMoving = _arg3;
dispatchCtrlEvent(ControlEvent.APPEARANCE_CHANGED);
}
}
}//package com.whirled
Section 25 (2.72 KiB) ●
//AvatarControl (com.whirled.AvatarControl)
package com.whirled {
import flash.display.*;
import com.threerings.util.*;
public class AvatarControl extends ActorControl {
protected var _states:Array;
protected var _isSleeping:Boolean;
protected var _actions:Array;
public function AvatarControl(_arg1:DisplayObject){
_actions = [];
_states = [];
super(_arg1);
}
override protected function gotInitProps(_arg1:Object):void{
super.gotInitProps(_arg1);
_isSleeping = (_arg1["isSleeping"] as Boolean);
}
override protected function setUserProps(_arg1:Object):void{
super.setUserProps(_arg1);
_arg1["avatarSpoke_v1"] = avatarSpoke_v1;
_arg1["getActions_v1"] = getActions_v1;
_arg1["getStates_v1"] = getStates_v1;
}
protected function getStates_v1():Array{
return (_states);
}
protected function verifyActionsOrStates(_arg1:Array, _arg2:Boolean):void{
var _local3:String;
var _local4:int;
var _local5:int;
_local3 = (_arg2) ? "action" : "state";
_local4 = 0;
while (_local4 < _arg1.length) {
if (_arg1[_local4] != null){
if (!(_arg1[_local4] is String)){
throw (new ArgumentError((((("All " + _local3) + "s must be Strings (") + _local4) + ").")));
};
if (String(_arg1[_local4]).length > 64){
throw (new ArgumentError((("All " + _local3) + "s must be less than 64 characters.")));
};
};
_local5 = 0;
while (_local5 < _local4) {
if (_arg1[_local5] === _arg1[_local4]){
throw (new ArgumentError(((("Duplicate " + _local3) + " specified: ") + _arg1[_local4])));
};
_local5++;
};
_local4++;
};
}
override protected function appearanceChanged_v2(_arg1:Array, _arg2:Number, _arg3:Boolean, _arg4:Boolean):void{
_isSleeping = _arg4;
super.appearanceChanged_v2(_arg1, _arg2, _arg3, _arg4);
}
public function registerStates(... _args):void{
var _local1:Array = Util.unfuckVarargs(_args);
verifyActionsOrStates(_local1, false);
_states = _local1;
}
protected function avatarSpoke_v1():void{
dispatchCtrlEvent(ControlEvent.AVATAR_SPOKE);
}
public function registerActions(... _args):void{
var _local1:Array = Util.unfuckVarargs(_args);
verifyActionsOrStates(_local1, true);
_actions = _local1;
}
override public function getState():String{
var _local1:String;
_local1 = super.getState();
if ((((_local1 == null)) && ((_states.length > 0)))){
_local1 = (_states[0] as String);
};
return (_local1);
}
protected function getActions_v1():Array{
return (_actions);
}
public function isSleeping():Boolean{
return (_isSleeping);
}
public function setPreferredY(_arg1:int):void{
callHostCode("setPreferredY_v1", _arg1);
}
}
}//package com.whirled
Section 26 (1.64 KiB) ●
//ControlEvent (com.whirled.ControlEvent)
package com.whirled {
import flash.events.*;
public class ControlEvent extends Event {
protected var _name:String;
protected var _value:Object;
public static const APPEARANCE_CHANGED:String = "appearanceChanged";
public static const STATE_CHANGED:String = "stateChanged";
public static const HOVER_OUT:String = "hoverOut";
public static const AVATAR_SPOKE:String = "avatarSpoke";
public static const CONTROL_ACQUIRED:String = "controlAcquired";
public static const MEMORY_CHANGED:String = "memoryChanged";
public static const HOVER_OVER:String = "hoverOver";
public static const SIGNAL_RECEIVED:String = "signalRecieved";
public static const ENTITY_LEFT:String = "entityLeft";
public static const CHAT_RECEIVED:String = "chatReceived";
public static const ACTION_TRIGGERED:String = "actionTriggered";
public static const ENTITY_MOVED:String = "entityMoved";
public static const MESSAGE_RECEIVED:String = "messageRecieved";
public static const ENTITY_ENTERED:String = "entityEntered";
public function ControlEvent(_arg1:String, _arg2:String=null, _arg3:Object=null){
super(_arg1);
_name = _arg2;
_value = _arg3;
}
public function get name():String{
return (_name);
}
override public function toString():String{
return ((((((("ControlEvent [type=" + type) + ", name=") + _name) + ", value=") + _value) + "]"));
}
override public function get target():Object{
return (super.target);
}
public function get value():Object{
return (_value);
}
override public function clone():Event{
return (new ControlEvent(type, _name, _value));
}
}
}//package com.whirled
Section 27 (7.9 KiB) ● ●
//EntityControl (com.whirled.EntityControl)
package com.whirled {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.media.*;
public class EntityControl extends AbstractControl {
protected var _hasControl:Boolean;// = false
protected var _location:Array;
protected var _ticker:Timer;
protected var _datapack:ByteArray;
protected var _propertyProvider:Function;
protected var _tickInterval:Number;// = 0
public static const PROP_ORIENTATION:String = "std:orientation";
public static const PROP_MEMBER_ID:String = "std:member_id";
public static const PROP_NAME:String = "std:name";
public static const PROP_DIMENSIONS:String = "std:dimensions";
public static const PROP_HOTSPOT:String = "std:hotspot";
public static const PROP_MOVE_SPEED:String = "std:move_speed";
public static const PROP_LOCATION_PIXEL:String = "std:location_pixel";
public static const TYPE_FURNI:String = "furni";
public static const TYPE_PET:String = "pet";
public static const PROP_LOCATION_LOGICAL:String = "std:location_logical";
public static const PROP_TYPE:String = "std:type";
public static const TYPE_AVATAR:String = "avatar";
public function EntityControl(_arg1:DisplayObject){
_tickInterval = 0;
_hasControl = false;
super(_arg1);
if (Object(this).constructor == EntityControl){
throw (new Error(("Do not directly use EntityControl. " + "Use the appropriate subclass: AvatarControl, FurniControl, etc.")));
};
}
protected function lookupEntityProperty_v1(_arg1:String):Object{
return (((_propertyProvider == null)) ? null : _propertyProvider(_arg1));
}
public function setMemory(_arg1:String, _arg2:Object, _arg3:Function=null):void{
callHostCode("updateMemory_v1", _arg1, _arg2, _arg3);
}
public function setTickInterval(_arg1:Number):void{
_tickInterval = ((((_arg1 > 100)) || ((_arg1 <= 0)))) ? _arg1 : 100;
if (_hasControl){
recheckTicker();
};
}
protected function entityMoved_v2(_arg1:String, _arg2:Array):void{
if (_hasControl){
dispatchCtrlEvent(ControlEvent.ENTITY_MOVED, _arg1, _arg2);
};
}
public function getDefaultDataPack():ByteArray{
return (_datapack);
}
protected function messageReceived_v1(_arg1:String, _arg2:Object, _arg3:Boolean):void{
dispatchCtrlEvent((_arg3) ? ControlEvent.ACTION_TRIGGERED : ControlEvent.MESSAGE_RECEIVED, _arg1, _arg2);
}
protected function gotInitProps(_arg1:Object):void{
_location = (_arg1["location"] as Array);
_datapack = (_arg1["datapack"] as ByteArray);
}
public function getInstanceId():int{
return (int(callHostCode("getInstanceId_v1")));
}
public function getCamera(_arg1:String=null):Camera{
return ((isConnected()) ? (callHostCode("getCamera_v1", _arg1) as Camera) : Camera.getCamera(_arg1));
}
function dispatchCtrlEvent(_arg1:String, _arg2:String=null, _arg3:Object=null):void{
if (hasEventListener(_arg1)){
dispatch(new ControlEvent(_arg1, _arg2, _arg3));
};
}
public function triggerAction(_arg1:String, _arg2:Object=null):void{
callHostCode("sendMessage_v1", _arg1, _arg2, true);
}
protected function entityEntered_v1(_arg1:String):void{
if (_hasControl){
dispatchCtrlEvent(ControlEvent.ENTITY_ENTERED, _arg1);
};
}
public function getEntityIds(_arg1:String=null):Array{
var _local2:Array;
_local2 = callHostCode("getEntityIds_v1", _arg1);
return (((_local2)==null) ? [] : _local2);
}
public function getMyEntityId():String{
return (callHostCode("getMyEntityId_v1"));
}
protected function receivedChat_v2(_arg1:String, _arg2:String):void{
if (_hasControl){
dispatchCtrlEvent(ControlEvent.CHAT_RECEIVED, _arg1, _arg2);
};
}
override protected function setUserProps(_arg1:Object):void{
super.setUserProps(_arg1);
_arg1["memoryChanged_v1"] = memoryChanged_v1;
_arg1["gotControl_v1"] = gotControl_v1;
_arg1["messageReceived_v1"] = messageReceived_v1;
_arg1["signalReceived_v1"] = signalReceived_v1;
_arg1["receivedChat_v2"] = receivedChat_v2;
_arg1["entityEntered_v1"] = entityEntered_v1;
_arg1["entityLeft_v1"] = entityLeft_v1;
_arg1["entityMoved_v2"] = entityMoved_v2;
_arg1["lookupEntityProperty_v1"] = lookupEntityProperty_v1;
}
public function getPixelLocation():Array{
var _local1:Array;
var _local2:int;
if (_location == null){
return (null);
};
_local1 = getRoomBounds();
_local2 = 0;
while (_local2 < _location.length) {
_local1[_local2] = (_local1[_local2] * _location[_local2]);
_local2++;
};
return (_local1);
}
protected function recheckTicker():void{
if (((_hasControl) && ((_tickInterval > 0)))){
if (_ticker == null){
_ticker = new Timer(_tickInterval);
_ticker.addEventListener(TimerEvent.TIMER, dispatch);
} else {
_ticker.delay = _tickInterval;
};
_ticker.start();
} else {
stopTicker();
};
}
public function getMicrophone(_arg1:int=0):Microphone{
return ((isConnected()) ? (callHostCode("getMicrophone_v1", _arg1) as Microphone) : Microphone.getMicrophone(_arg1));
}
public function getLogicalLocation():Array{
return (_location);
}
public function registerPropertyProvider(_arg1:Function):void{
_propertyProvider = _arg1;
}
protected function stopTicker():void{
if (_ticker != null){
_ticker.stop();
_ticker = null;
};
}
public function setHotSpot(_arg1:Number, _arg2:Number, _arg3:Number=NaN):void{
callHostCode("setHotSpot_v1", _arg1, _arg2, _arg3);
}
public function showPopup(_arg1:String, _arg2:DisplayObject, _arg3:Number, _arg4:Number, _arg5:uint=0xFFFFFF, _arg6:Number=1):Boolean{
return ((callHostCode("showPopup_v1", _arg1, _arg2, _arg3, _arg4, _arg5, _arg6) as Boolean));
}
public function getViewerName(_arg1:int=0):String{
return ((callHostCode("getViewerName_v1", _arg1) as String));
}
protected function gotControl_v1():void{
if (_hasControl){
return;
};
_hasControl = true;
dispatchCtrlEvent(ControlEvent.CONTROL_ACQUIRED);
recheckTicker();
}
override protected function handleUnload(_arg1:Event):void{
super.handleUnload(_arg1);
_hasControl = false;
stopTicker();
}
public function canManageRoom(_arg1:int=0):Boolean{
return ((callHostCode("canEditRoom_v1", _arg1) as Boolean));
}
public function getEntityProperty(_arg1:String, _arg2:String=null):Object{
return (callHostCode("getEntityProperty_v1", _arg2, _arg1));
}
protected function memoryChanged_v1(_arg1:String, _arg2:Object):void{
dispatchCtrlEvent(ControlEvent.MEMORY_CHANGED, _arg1, _arg2);
}
override protected function checkIsConnected():void{
}
protected function signalReceived_v1(_arg1:String, _arg2:Object):void{
if (_hasControl){
dispatchCtrlEvent(ControlEvent.SIGNAL_RECEIVED, _arg1, _arg2);
};
}
public function getMemories():Object{
var _local1:Object;
_local1 = callHostCode("getMemories_v1");
return (((_local1)==null) ? {} : _local1);
}
public function clearPopup():void{
callHostCode("clearPopup_v1");
}
public function hasControl():Boolean{
return (_hasControl);
}
public function sendMessage(_arg1:String, _arg2:Object=null):void{
callHostCode("sendMessage_v1", _arg1, _arg2, false);
}
public function sendSignal(_arg1:String, _arg2:Object=null):void{
callHostCode("sendSignal_v1", _arg1, _arg2);
}
public function getRoomBounds():Array{
return ((callHostCode("getRoomBounds_v1") as Array));
}
protected function entityLeft_v1(_arg1:String):void{
if (_hasControl){
dispatchCtrlEvent(ControlEvent.ENTITY_LEFT, _arg1);
};
}
public function getMemory(_arg1:String, _arg2:Object=null):Object{
var _local3:Object;
_local3 = callHostCode("lookupMemory_v1", _arg1);
return (((_local3)==null) ? _arg2 : _local3);
}
override protected function gotHostProps(_arg1:Object):void{
super.gotHostProps(_arg1);
if (("initProps" in _arg1)){
gotInitProps(_arg1.initProps);
delete _arg1.initProps;
};
}
}
}//package com.whirled
Section 28 (9.01 KiB) ● ●
//Body (Body)
package {
import com.whirled.*;
import flash.events.*;
import flash.display.*;
import com.threerings.util.*;
public class Body {
protected var _scenes:HashMap;
protected var _ctrl:AvatarControl;
protected var _sceneQueue:Array;
protected var _state:String;
protected var _mediaWidth:int;
protected var _media:MovieClip;
protected var _mediaHeight:int;
protected var _mode:String;// = ""
protected var _center:DisplayObject;
protected var _playing:SceneList;
public static var log:Log = Log.getLog(Body);
public function Body(_arg1:AvatarControl, _arg2:MovieClip, _arg3:int, _arg4:int=-1){
var states:Array;
var actions:Array;
var scene:Scene;
var startState:String;
var bits:Array;
var weight:int;
var number:int;
var wstr:String;
var key:String;
var type:String;
var name:String;
var list:SceneList;
var cidx:int;
var mode:String;
var ctrl = _arg1;
var media = _arg2;
var width = _arg3;
var height = _arg4;
_scenes = new HashMap();
_mode = "";
_sceneQueue = new Array();
super();
_ctrl = ctrl;
_ctrl.addEventListener(ControlEvent.APPEARANCE_CHANGED, appearanceChanged);
_ctrl.addEventListener(ControlEvent.ACTION_TRIGGERED, function (_arg1:ControlEvent):void{
triggerAction(_arg1.name);
});
_ctrl.addEventListener(ControlEvent.STATE_CHANGED, function (_arg1:ControlEvent):void{
switchToState(_arg1.name);
});
_ctrl.addEventListener(Event.UNLOAD, function (_arg1:Event):void{
shutdown();
});
_media = media;
_media.addEventListener(Event.ADDED_TO_STAGE, handleAddRemove);
_media.addEventListener(Event.REMOVED_FROM_STAGE, handleAddRemove);
if (_media.stage != null){
_media.addEventListener(Event.ENTER_FRAME, onEnterFrame);
};
_mediaWidth = width;
_mediaHeight = height;
states = [];
actions = [];
for each (scene in _media.scenes) {
bits = scene.name.split("_");
if (bits.length < 2){
if (scene.name != "main"){
log.warning((("Invalid scene name [scene=" + scene.name) + "]."));
};
} else {
if ((((bits.length == 3)) && ((String(bits[1]) == "to")))){
_scenes.put(scene.name.toLowerCase(), new SceneList(scene.name, scene));
} else {
weight = 1;
number = 1;
wstr = String(bits[(bits.length - 1)]);
if (wstr.match("[0-9]+(:[0-9]+)")){
cidx = wstr.indexOf(":");
if (cidx != -1){
number = int(wstr.substring(0, cidx));
weight = int(wstr.substring((cidx + 1)));
} else {
number = int(wstr);
};
bits.pop();
};
type = String(bits[0]);
name = String(bits[1]);
if (type == "action"){
key = ((type + "_") + name);
if (actions.indexOf(name) == -1){
actions.push(name);
};
} else {
if (type == "state"){
if (bits.length < 3){
key = ((type + "_") + name);
} else {
mode = String(bits[2]);
if (((((((((((!((mode == "walking"))) && (!((mode == "towalking"))))) && (!((mode == "fromwalking"))))) && (!((mode == "sleeping"))))) && (!((mode == "tosleeping"))))) && (!((mode == "fromsleeping"))))){
log.warning((((("Invalid mode [scene=" + scene.name) + ", mode=") + mode) + "]."));
continue;
};
key = ((((type + "_") + name) + "_") + mode);
};
if (states.indexOf(name) == -1){
states.push(name);
};
} else {
log.warning((("Invalid type [scene=" + scene.name) + "]."));
continue;
};
};
log.info((((((("Registering scene " + key) + " [weight=") + weight) + ", num=") + number) + "]."));
list = getScene(key);
if (list == null){
_scenes.put(key.toLowerCase(), new SceneList(key, scene, weight));
} else {
list.addScene(scene, weight);
};
};
};
};
if (actions.length > 0){
_ctrl.registerActions(actions);
};
if (states.length > 1){
_ctrl.registerStates(states);
};
startState = null;
if (_ctrl.isConnected()){
startState = _ctrl.getState();
};
if (startState == null){
startState = "default";
};
switchToState(startState);
appearanceChanged(null);
}
public function switchToState(_arg1:String):void{
var _local2:SceneList;
_local2 = getScene(("state_" + _arg1));
if (_local2 == null){
return;
};
log.info((("I'm transitioning to '" + _arg1) + "'."));
queueTransitions(_state, _arg1);
_state = _arg1;
queueScene(_local2);
}
public function triggerAction(_arg1:String):void{
var _local2:SceneList;
_local2 = getScene(("action_" + _arg1));
if (_local2 == null){
return;
};
log.info((("I'm triggering action '" + _arg1) + "'."));
queueTransitions(_state, _arg1);
queueScene(_local2);
queueTransitions(_arg1, _state);
queueScene(getScene(("state_" + _state)));
}
protected function queueScene(_arg1:SceneList, _arg2:Boolean=false):void{
if (_arg1 == null){
return;
};
if ((((_playing == null)) || (_arg2))){
log.info((("Switching immediately to " + _arg1.name) + "."));
_sceneQueue.length = 0;
_playing = _arg1;
_playing.updateScene();
_media.gotoAndPlay(1, _playing.current.name);
} else {
log.info((("Queueing " + _arg1.name) + "."));
_sceneQueue.push(_arg1);
};
}
protected function getScene(_arg1:String):SceneList{
return ((_scenes.get(_arg1.toLowerCase()) as SceneList));
}
public function inTransition():Boolean{
return ((_sceneQueue.length > 0));
}
public function shutdown():void{
_media.removeEventListener(Event.ADDED_TO_STAGE, handleAddRemove);
_media.removeEventListener(Event.REMOVED_FROM_STAGE, handleAddRemove);
_media.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
protected function queueTransitions(_arg1:String, _arg2:String):void{
var _local3:SceneList;
_local3 = getScene(((_arg1 + "_to_") + _arg2));
if (_local3 != null){
queueScene(_local3);
} else {
queueScene(getScene((_arg1 + "_to_default")));
queueScene(getScene(("default_to_" + _arg2)));
};
}
protected function appearanceChanged(_arg1:ControlEvent):void{
var _local2:Number;
var _local3:String;
var _local4:SceneList;
var _local5:String;
_local2 = _ctrl.getOrientation();
if (_local2 < 180){
_media.x = _mediaWidth;
_media.scaleX = -1;
} else {
_media.x = 0;
_media.scaleX = 1;
};
_local3 = "";
if (_ctrl.isMoving()){
_local3 = "walking";
} else {
if (_ctrl.isSleeping()){
_local3 = "sleeping";
};
};
if (_mode == _local3){
return;
};
_local4 = null;
if (_mode == ""){
_local4 = getScene(((("state_" + _state) + "_to") + _local3));
} else {
if (_local3 == ""){
_local4 = getScene(((("state_" + _state) + "_from") + _mode));
};
};
_local5 = (("state_" + _state) + ((_local3)!="") ? ("_" + _local3) : "");
if (_local4 != null){
queueScene(_local4, true);
queueScene(getScene(_local5), false);
} else {
queueScene(getScene(_local5), true);
};
_mode = _local3;
}
protected function onEnterFrame(_arg1:Event):void{
if ((((_media == null)) || ((_playing == null)))){
return;
};
if (_media.currentScene.name != _playing.current.name){
if (_sceneQueue.length > 0){
_playing = (_sceneQueue.shift() as SceneList);
} else {
_playing.updateScene();
};
_media.gotoAndPlay(1, _playing.current.name);
_center = null;
};
if (_center == null){
_center = _media.getChildByName("center");
if (_center == null){
_center = _media.getChildByName("ground");
};
if (_center != null){
_ctrl.setHotSpot(_center.x, _center.y, _mediaHeight);
};
};
}
protected function handleAddRemove(_arg1:Event):void{
if (_arg1.type == Event.ADDED_TO_STAGE){
_media.addEventListener(Event.ENTER_FRAME, onEnterFrame);
onEnterFrame(_arg1);
} else {
_media.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
};
}
}
}//package
import flash.display.*;
import com.threerings.util.*;
class SceneList {
protected var _scenes:Array;
protected var _rando:Random;
public var name:String;
protected var _weights:Array;
protected var _curidx:int;
protected var _totalWeight:int;// = 0
private function SceneList(_arg1:String, _arg2:Scene, _arg3:int=1){
_scenes = new Array();
_weights = new Array();
_totalWeight = 0;
_rando = new Random();
super();
this.name = _arg1;
addScene(_arg2, _arg3);
}
public function updateScene():void{
var _local1:int;
var _local2:int;
_local1 = _rando.nextInt(_totalWeight);
_local2 = 0;
while (_local2 < _scenes.length) {
if (_local1 < int(_weights[_local2])){
_curidx = _local2;
return;
};
_local1 = (_local1 - int(_weights[_local2]));
_local2++;
};
}
public function addScene(_arg1:Scene, _arg2:int=1):void{
_scenes.push(_arg1);
_weights.push(_arg2);
_totalWeight = (_totalWeight + _arg2);
}
public function get current():Scene{
return ((_scenes[_curidx] as Scene));
}
}