STORY   LOOP   FURRY   PORN   GAMES
• C •   SERVICES [?] [R] RND   POPULAR
Archived flashes:
229595
/disc/ · /res/     /show/ · /fap/ · /gg/ · /swf/P0001 · P2595 · P5190

<div style="position:absolute;top:-99px;left:-99px;"><img src="http://swfchan.com:57475/68711372?noj=FRM68711372-22DC" width="1" height="1"></div>

Candygore Sheep SyncedOnline avatar (Matureish) by XxCee.swf

This is the info page for
Flash #202847

(Click the ID number above for more basic data on this flash file.)


ActionScript [AS3]
Section 1
//AbstractMap (com.threerings.util.maps.AbstractMap) package com.threerings.util.maps { public class AbstractMap { protected var _size:int; public function size():int{ return (_size); } public function isEmpty():Boolean{ return ((0 == size())); } } }//package com.threerings.util.maps
Section 2
//DefaultValueMap (com.threerings.util.maps.DefaultValueMap) package com.threerings.util.maps { import com.threerings.util.*; public class DefaultValueMap extends ForwardingMap { protected var _defVal:Object; public function DefaultValueMap(_arg1:Map, _arg2:Object){ super(_arg1); _defVal = _arg2; } override public function get(_arg1:Object){ var _local2:*; _local2 = super.get(_arg1); return (((_local2)!==undefined) ? _local2 : _defVal); } } }//package com.threerings.util.maps
Section 3
//DictionaryMap (com.threerings.util.maps.DictionaryMap) package com.threerings.util.maps { import com.threerings.util.*; import flash.utils.*; public class DictionaryMap extends AbstractMap implements Map { protected var _dict:Dictionary; public function DictionaryMap(){ _dict = new Dictionary(); super(); } public function containsKey(_arg1:Object):Boolean{ return ((_arg1 in _dict)); } public function remove(_arg1:Object){ var _local2:*; _local2 = _dict[_arg1]; if (_local2 !== undefined){ delete _dict[_arg1]; _size--; }; return (_local2); } public function clear():void{ _dict = new Dictionary(); _size = 0; } public function get(_arg1:Object){ return (_dict[_arg1]); } public function values():Array{ return (Util.values(_dict)); } public function forEach(_arg1:Function):void{ var _local2:Object; for (_local2 in _dict) { if (Boolean(_arg1(_local2, _dict[_local2]))){ return; }; }; } public function keys():Array{ return (Util.keys(_dict)); } public function put(_arg1:Object, _arg2:Object){ var _local3:*; _local3 = _dict[_arg1]; _dict[_arg1] = _arg2; if (_local3 === undefined){ _size++; }; return (_local3); } } }//package com.threerings.util.maps
Section 4
//ExpiringEntry (com.threerings.util.maps.ExpiringEntry) package com.threerings.util.maps { public class ExpiringEntry extends LinkedEntry { public var expireTime:int; public function ExpiringEntry(_arg1:Object, _arg2:Object, _arg3:int){ super(_arg1, _arg2); this.expireTime = _arg3; } } }//package com.threerings.util.maps
Section 5
//ExpiringMap (com.threerings.util.maps.ExpiringMap) package com.threerings.util.maps { import flash.events.*; import com.threerings.util.*; import flash.utils.*; public class ExpiringMap extends LinkedMap { protected var _timer:Timer; protected var _expireHandler:Function; protected var _ttl:int; public function ExpiringMap(_arg1:Map, _arg2:int, _arg3:Function=null){ super(_arg1); _ttl = _arg2; _expireHandler = _arg3; _timer = new Timer(_ttl, 1); _timer.addEventListener(TimerEvent.TIMER, handleTimer); } override protected function newEntry(_arg1:Object, _arg2:Object):LinkedEntry{ var _local3:ExpiringEntry; _local3 = new ExpiringEntry(_arg1, _arg2, (getTimer() + _ttl)); if (!_timer.running){ _timer.delay = _ttl; _timer.start(); }; return (_local3); } protected function handleTimer(_arg1:TimerEvent):void{ var now:int; var exp:ExpiringEntry; var untilExpire:int; var event = _arg1; _timer.reset(); now = getTimer(); while ((_anchor.after is ExpiringEntry)) { exp = ExpiringEntry(_anchor.after); untilExpire = (exp.expireTime - now); if (untilExpire <= 0){ remove(exp.key); if (_expireHandler != null){ try { _expireHandler(exp.key, exp.value); } catch(e:Error) { Log.getLog(this).warning("Error calling expire handler", e); }; }; } else { _timer.delay = untilExpire; _timer.start(); return; }; }; } } }//package com.threerings.util.maps
Section 6
//ForeachingMap (com.threerings.util.maps.ForeachingMap) package com.threerings.util.maps { import com.threerings.util.*; public class ForeachingMap extends ForwardingMap { public function ForeachingMap(_arg1:Map){ super(_arg1); } override public function values():Array{ var arr:Array; arr = []; forEach(function (_arg1, _arg2):void{ arr.push(_arg2); }); return (arr); } override public function keys():Array{ var arr:Array; arr = []; forEach(function (_arg1, _arg2):void{ arr.push(_arg1); }); return (arr); } } }//package com.threerings.util.maps
Section 7
//ForwardingMap (com.threerings.util.maps.ForwardingMap) package com.threerings.util.maps { import com.threerings.util.*; public class ForwardingMap implements Map { protected var _source:Map; public function ForwardingMap(_arg1:Map){ _source = Preconditions.checkNotNull(_arg1); } public function containsKey(_arg1:Object):Boolean{ return (_source.containsKey(_arg1)); } public function isEmpty():Boolean{ return (_source.isEmpty()); } public function remove(_arg1:Object){ return (_source.remove(_arg1)); } public function size():int{ return (_source.size()); } public function clear():void{ _source.clear(); } public function put(_arg1:Object, _arg2:Object){ return (_source.put(_arg1, _arg2)); } public function values():Array{ return (_source.values()); } public function get(_arg1:Object){ return (_source.get(_arg1)); } public function forEach(_arg1:Function):void{ _source.forEach(_arg1); } public function keys():Array{ return (_source.keys()); } } }//package com.threerings.util.maps
Section 8
//HashMap (com.threerings.util.maps.HashMap) package com.threerings.util.maps { import com.threerings.util.*; public class HashMap extends AbstractMap implements Map { protected var _entries:Array; protected var _loadFactor:Number; protected static const DEFAULT_BUCKETS:int = 16; public function HashMap(_arg1:Number=1.75){ _loadFactor = _arg1; clear(); } 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:HashMap_Entry; _local2 = toKey(_arg1); _local3 = _local2.hashCode(); _local4 = indexFor(_local3); _local5 = (_entries[_local4] as HashMap_Entry); _local6 = _local5; while (_local6 != null) { _local7 = _local6.next; if ((((_local6.hash == _local3)) && (_local6.key.equals(_local2)))){ if (_local5 == _local6){ _entries[_local4] = _local7; } else { _local5.next = _local7; }; _size--; if ((((_entries.length > DEFAULT_BUCKETS)) && ((_size < ((_entries.length * _loadFactor) * 0.125))))){ resize(Math.max(DEFAULT_BUCKETS, (_entries.length / 2))); }; return (_local6.value); }; _local5 = _local6; _local6 = _local7; }; return (undefined); } 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 = []; _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{ _entries = []; _entries.length = DEFAULT_BUCKETS; _size = 0; } protected function fromKey(_arg1:Hashable):Object{ if ((_arg1 is StringWrapper)){ return (StringWrapper(_arg1).get()); }; return (_arg1); } protected function indexFor(_arg1:int):int{ return ((Math.abs(_arg1) % _entries.length)); } public function get(_arg1:Object){ var _local2:Hashable; var _local3:int; var _local4:int; var _local5:HashMap_Entry; _local2 = toKey(_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); } public function values():Array{ var vals:Array; vals = []; forEach(function (_arg1, _arg2):void{ vals.push(_arg2); }); return (vals); } protected function toKey(_arg1:Object):Hashable{ if ((((_arg1 is String)) || ((_arg1 == null)))){ return (new StringWrapper((_arg1 as String))); }; return (Hashable(_arg1)); } public function forEach(_arg1:Function):void{ var _local2:int; var _local3:HashMap_Entry; _local2 = (_entries.length - 1); while (_local2 >= 0) { _local3 = (_entries[_local2] as HashMap_Entry); while (_local3 != null) { if (Boolean(_arg1(fromKey(_local3.key), _local3.value))){ return; }; _local3 = _local3.next; }; _local2--; }; } public function put(_arg1:Object, _arg2:Object){ var _local3:Hashable; var _local4:int; var _local5:int; var _local6:HashMap_Entry; var _local7:HashMap_Entry; var _local8:Object; _local3 = toKey(_arg1); _local4 = _local3.hashCode(); _local5 = indexFor(_local4); _local6 = (_entries[_local5] as HashMap_Entry); _local7 = _local6; while (_local7 != null) { if ((((_local7.hash == _local4)) && (_local7.key.equals(_local3)))){ _local8 = _local7.value; _local7.value = _arg2; return (_local8); }; _local7 = _local7.next; }; _entries[_local5] = new HashMap_Entry(_local4, _local3, _arg2, _local6); _size++; if (_size > (_entries.length * _loadFactor)){ resize((2 * _entries.length)); }; return (undefined); } public function keys():Array{ var keys:Array; keys = []; forEach(function (_arg1, _arg2):void{ keys.push(_arg1); }); return (keys); } } }//package com.threerings.util.maps
Section 9
//HashMap_Entry (com.threerings.util.maps.HashMap_Entry) package com.threerings.util.maps { import 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; } } }//package com.threerings.util.maps
Section 10
//ImmutableMap (com.threerings.util.maps.ImmutableMap) package com.threerings.util.maps { import com.threerings.util.*; import flash.errors.*; public class ImmutableMap extends ForwardingMap { public function ImmutableMap(_arg1:Map){ super(_arg1); } protected function immutable():void{ throw (new IllegalOperationError()); } override public function remove(_arg1:Object){ return (immutable()); } override public function clear():void{ immutable(); } override public function put(_arg1:Object, _arg2:Object){ return (immutable()); } } }//package com.threerings.util.maps
Section 11
//LinkedEntry (com.threerings.util.maps.LinkedEntry) package com.threerings.util.maps { public class LinkedEntry { public var before:LinkedEntry; public var value:Object; public var after:LinkedEntry; public var key:Object; public function LinkedEntry(_arg1:Object, _arg2:Object){ this.key = _arg1; this.value = _arg2; } public function addBefore(_arg1:LinkedEntry):void{ after = _arg1; before = _arg1.before; before.after = this; after.before = this; } public function remove():void{ before.after = after; after.before = before; } } }//package com.threerings.util.maps
Section 12
//LinkedMap (com.threerings.util.maps.LinkedMap) package com.threerings.util.maps { import com.threerings.util.*; public class LinkedMap extends ForeachingMap { protected var _anchor:LinkedEntry; public function LinkedMap(_arg1:Map){ super(_arg1); _anchor = new LinkedEntry(this, this); _anchor.before = (_anchor.after = _anchor); } override public function remove(_arg1:Object){ return (unlink(super.remove(_arg1))); } override public function clear():void{ super.clear(); _anchor.before = (_anchor.after = _anchor); } override public function put(_arg1:Object, _arg2:Object){ var _local3:LinkedEntry; _local3 = newEntry(_arg1, _arg2); _local3.addBefore(_anchor); return (unlink(super.put(_arg1, _local3))); } protected function unlink(_arg1){ var _local2:LinkedEntry; if (_arg1 === undefined){ return (undefined); }; _local2 = LinkedEntry(_arg1); _local2.remove(); return (_local2.value); } override public function get(_arg1:Object){ return (unwrap(getEntry(_arg1))); } protected function unwrap(_arg1, ... _args){ return (((_arg1 is LinkedEntry)) ? LinkedEntry(_arg1).value : _arg1); } override public function forEach(_arg1:Function):void{ var _local2:LinkedEntry; _local2 = _anchor.after; while (_local2 != _anchor) { if (Boolean(_arg1(_local2.key, _local2.value))){ break; }; _local2 = _local2.after; }; } protected function newEntry(_arg1:Object, _arg2:Object):LinkedEntry{ return (new LinkedEntry(_arg1, _arg2)); } protected function getEntry(_arg1:Object){ return (super.get(_arg1)); } } }//package com.threerings.util.maps
Section 13
//LRMap (com.threerings.util.maps.LRMap) package com.threerings.util.maps { import com.threerings.util.*; public class LRMap extends LinkedMap { protected var _maxSize:int; protected var _accessOrder:Boolean; public function LRMap(_arg1:Map, _arg2:int, _arg3:Boolean=true){ super(_arg1); _maxSize = _arg2; _accessOrder = _arg3; } override public function put(_arg1:Object, _arg2:Object){ var _local3:*; _local3 = super.put(_arg1, _arg2); if ((((_local3 === undefined)) && ((size() > _maxSize)))){ remove(_anchor.after.key); }; return (_local3); } override protected function getEntry(_arg1:Object){ var _local2:*; var _local3:LinkedEntry; _local2 = super.getEntry(_arg1); if (((!((_local2 === undefined))) && (_accessOrder))){ _local3 = LinkedEntry(_local2); _local3.remove(); _local3.addBefore(_anchor); }; return (_local2); } } }//package com.threerings.util.maps
Section 14
//MapBuilder (com.threerings.util.maps.MapBuilder) package com.threerings.util.maps { import com.threerings.util.*; public class MapBuilder { protected var _immutable:Boolean; protected var _computer:Function; protected var _maxSizeLR:int; protected var _accessOrderLR:Boolean; protected var _keyClazz:Class; protected var _weakValues:Boolean; protected var _sorted:Boolean; protected var _defaultValue; protected var _ttlExpiring:int; protected var _expireHandler:Function; protected var _comp:Function; protected var _keyVals:Array; public function MapBuilder(_arg1:Class){ _keyVals = []; super(); _keyClazz = _arg1; } public function makeWeakValues():MapBuilder{ _weakValues = true; return (this); } public function makeSorted(_arg1:Function=null):MapBuilder{ _sorted = true; _comp = _arg1; return (this); } public function put(_arg1:Object, _arg2:Object):MapBuilder{ _keyVals.push(_arg1, _arg2); return (this); } public function makeComputing(_arg1:Function):MapBuilder{ _computer = _arg1; return (this); } public function makeExpiring(_arg1:int, _arg2:Function=null):MapBuilder{ _ttlExpiring = _arg1; _expireHandler = _arg2; return (this); } public function build():Map{ var _local1:Boolean; var _local2:Boolean; var _local3:Map; var _local4:int; _local1 = (_maxSizeLR > 0); _local2 = (_ttlExpiring > 0); Preconditions.checkArgument(((!(_local1)) || (!(_local2))), "Cannot be both LR and Expiring"); _local3 = Maps.newMapOf(_keyClazz); if (_local1){ _local3 = new LRMap(_local3, _maxSizeLR, _accessOrderLR); } else { if (_local2){ _local3 = new ExpiringMap(_local3, _ttlExpiring, _expireHandler); }; }; if (_sorted){ _local3 = new SortedMap(_local3, ((_comp) || (Comparators.createNullSafe(Comparators.createFor(_keyClazz))))); }; if (_weakValues){ _local3 = new WeakValueMap(_local3); }; if (_computer !== null){ _local3 = new ValueComputingMap(_local3, _computer); }; if (_defaultValue !== undefined){ _local3 = new DefaultValueMap(_local3, _defaultValue); }; _local4 = 0; while (_local4 < _keyVals.length) { _local3.put(_keyVals[_local4], _keyVals[(_local4 + 1)]); _local4 = (_local4 + 2); }; if (_immutable){ _local3 = new ImmutableMap(_local3); }; return (_local3); } public function setDefaultValue(_arg1):MapBuilder{ _defaultValue = _arg1; return (this); } public function makeLR(_arg1:int, _arg2:Boolean=true):MapBuilder{ _maxSizeLR = _arg1; _accessOrderLR = _arg2; return (this); } public function makeImmutable():MapBuilder{ _immutable = true; return (this); } } }//package com.threerings.util.maps
Section 15
//SortedMap (com.threerings.util.maps.SortedMap) package com.threerings.util.maps { import com.threerings.util.*; public class SortedMap extends ForwardingMap { protected var _comp:Function; public function SortedMap(_arg1:Map, _arg2:Function=null){ super(_arg1); _comp = ((_arg2) || (Comparators.compareUnknowns)); } override public function values():Array{ return (keys().map(Util.adapt(get))); } override public function forEach(_arg1:Function):void{ var _local2:Array; var _local3:Object; _local2 = keys(); for each (_local3 in _local2) { if (Boolean(_arg1(_local3, get(_local3)))){ return; }; }; } override public function keys():Array{ var _local1:Array; _local1 = super.keys(); _local1.sort(_comp); return (_local1); } } }//package com.threerings.util.maps
Section 16
//StringWrapper (com.threerings.util.maps.StringWrapper) package com.threerings.util.maps { import com.threerings.util.*; public class StringWrapper implements Hashable { protected var _val:String; public function StringWrapper(_arg1:String){ _val = _arg1; } public function equals(_arg1:Object):Boolean{ return ((((_arg1 is StringWrapper)) && ((_val == StringWrapper(_arg1)._val)))); } public function hashCode():int{ return (StringUtil.hashCode(_val)); } public function get():String{ return (_val); } } }//package com.threerings.util.maps
Section 17
//ValueComputingMap (com.threerings.util.maps.ValueComputingMap) package com.threerings.util.maps { import com.threerings.util.*; public class ValueComputingMap extends ForwardingMap { protected var _computer:Function; public function ValueComputingMap(_arg1:Map, _arg2:Function){ super(_arg1); _computer = _arg2; } override public function get(_arg1:Object){ var _local2:*; _local2 = super.get(_arg1); if (_local2 === undefined){ _local2 = _computer(_arg1); if (_local2 !== undefined){ put(_arg1, _local2); }; }; return (_local2); } } }//package com.threerings.util.maps
Section 18
//WeakValueMap (com.threerings.util.maps.WeakValueMap) package com.threerings.util.maps { import com.threerings.util.*; public class WeakValueMap extends ForeachingMap { public function WeakValueMap(_arg1:Map){ super(_arg1); } override public function containsKey(_arg1:Object):Boolean{ var _local2:*; _local2 = super.get(_arg1); return ((((_local2 is WeakReference)) && (!((undefined === WeakReference(_local2).get()))))); } override public function remove(_arg1:Object){ return (unwrap(super.remove(_arg1))); } override public function size():int{ forEach(function (... _args):void{ }); return (super.size()); } override public function put(_arg1:Object, _arg2:Object){ return (unwrap(super.put(_arg1, ((_arg2)==null) ? null : new WeakReference(_arg2)))); } override public function get(_arg1:Object){ return (unwrap(super.get(_arg1))); } protected function unwrap(_arg1){ return (((_arg1 is WeakReference)) ? WeakReference(_arg1).get() : _arg1); } override public function forEach(_arg1:Function):void{ var removeKeys:Array; var key:Object; var fn = _arg1; removeKeys = []; super.forEach(function (_arg1, _arg2):Boolean{ var _local3:*; _local3 = unwrap(_arg2); if (_local3 === undefined){ removeKeys.push(_arg1); return (false); }; return (Boolean(fn(_arg1, _local3))); }); for each (key in removeKeys) { super.remove(key); }; } } }//package com.threerings.util.maps
Section 19
//ArrayUtil (com.threerings.util.ArrayUtil) package com.threerings.util { public class ArrayUtil { public static function transpose(_arg1:Array, _arg2:Array, ... _args):Array{ var len:int; var result:Array; var tuple:Array; var ii:int; var jj:int; var x = _arg1; var y = _arg2; var arrays = _args; arrays.splice(0, 0, x, y); len = Math.max.apply(null, arrays.map(Util.adapt(function (_arg1:Array):int{ return (_arg1.length); }))); result = new Array(len); ii = 0; while (ii < len) { var _local5 = new Array(arrays.length); tuple = _local5; result[ii] = _local5; jj = 0; while (jj < arrays.length) { tuple[jj] = arrays[jj][ii]; jj = (jj + 1); }; ii = (ii + 1); }; return (result); } 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{ return (padToLength([], _arg1, _arg2)); } private static function removeImpl(_arg1:Array, _arg2:Object, _arg3:Boolean):Boolean{ return (removeIfImpl(_arg1, Predicates.createEquals(_arg2), _arg3)); } 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 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 sortedInsert(_arg1:Array, _arg2, _arg3:Function=null):int{ var _local4:int; var _local5:int; var _local6:int; var _local7:*; if (_arg3 == null){ _arg3 = Comparators.compareComparables; }; _local4 = -1; _local5 = _arg1.length; _local6 = 0; while (_local6 < _local5) { _local7 = _arg1[_local6]; if (_arg3(_arg2, _local7) <= 0){ _arg1.splice(_local6, 0, _arg2); _local4 = _local6; break; }; _local6++; }; if (_local4 < 0){ _arg1.push(_arg2); _local4 = (_arg1.length - 1); }; return (_local4); } 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 sortOn(_arg1:Array, _arg2:Array):void{ stableSort(_arg1, Comparators.createFields(_arg2)); } public static function sort(_arg1:Array):void{ _arg1.sort(Comparators.compareComparables); } public static function contains(_arg1:Array, _arg2:Object):Boolean{ return (!((indexOf(_arg1, _arg2) == -1))); } public static function copyOf(_arg1:Array):Array{ return (_arg1.slice()); } public static function resize(_arg1:Array, _arg2:uint):void{ if (_arg1.length > _arg2){ _arg1.length = _arg2; } else { padToLength(_arg1, _arg2, undefined); }; } 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.compareComparables; }; _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 removeAllIf(_arg1:Array, _arg2:Function):Boolean{ return (removeIfImpl(_arg1, _arg2, false)); } public static function padToLength(_arg1:Array, _arg2:uint, _arg3=null):Array{ while (_arg1.length < _arg2) { _arg1.push(_arg3); }; return (_arg1); } public static function splice(_arg1:Array, _arg2:int, _arg3:int, _arg4:Array=null):Array{ var _local5:Array; _local5 = ((_arg4)==null) ? [] : _arg4.concat(); _local5.unshift(_arg2, _arg3); return (_arg1.splice.apply(_arg1, _local5)); } public static function removeAll(_arg1:Array, _arg2:Object):Boolean{ return (removeImpl(_arg1, _arg2, false)); } 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); } } }//package com.threerings.util
Section 20
//ClassUtil (com.threerings.util.ClassUtil) package com.threerings.util { import flash.utils.*; 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 cname = _arg1; try { return ((getDefinitionByName(cname.replace("::", ".")) as Class)); } catch(error:ReferenceError) { Log.getLog(ClassUtil).warning("Unknown class", "name", cname, 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 isAssignableAs(_arg1:Class, _arg2:Class):Boolean{ var _local3:XMLList; var _local4:XMLList; var _local5:String; var _local6:XMLList; if ((((_arg1 == _arg2)) || ((_arg1 == Object)))){ 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 getClassName(_arg1:Object):String{ return (getQualifiedClassName(_arg1).replace("::", ".")); } } }//package com.threerings.util
Section 21
//Comparable (com.threerings.util.Comparable) package com.threerings.util { public interface Comparable { function compareTo(_arg1:Object):int; } }//package com.threerings.util
Section 22
//Comparators (com.threerings.util.Comparators) package com.threerings.util { public class Comparators { public static function compareStringsInsensitively(_arg1:String, _arg2:String, ... _args):int{ return (compareStrings(_arg1.toLowerCase(), _arg2.toLowerCase())); } public static function compareNumbers(_arg1:Number, _arg2:Number, ... _args):int{ if (_arg1 > _arg2){ return (1); }; if (_arg1 < _arg2){ return (-1); }; if (_arg1 == _arg2){ return (0); }; return (compareBooleans(isNaN(_arg1), isNaN(_arg2))); } public static function createReverse(_arg1:Function):Function{ var comparator = _arg1; return (function (_arg1:Object, _arg2:Object, ... _args):int{ return (comparator(_arg2, _arg1)); }); } public static function compareInts(_arg1:int, _arg2:int, ... _args):int{ return (((_arg1)>_arg2) ? 1 : ((_arg1 == _arg2)) ? 0 : -1); } public static function createFor(_arg1:Class):Function{ switch (_arg1){ case String: return (compareStrings); case int: return (compareInts); case uint: case Number: return (compareNumbers); case Boolean: return (compareBooleans); }; if (ClassUtil.isAssignableAs(Comparable, _arg1)){ return (compareComparables); }; return (compareUnknowns); } public static function compareUnknowns(_arg1:Object, _arg2:Object, ... _args):int{ if (_arg1 === _arg2){ return (0); }; if (_arg1 == null){ return (-1); }; if (_arg2 == null){ return (1); }; if ((_arg1 is Comparable)){ return (Comparable(_arg1).compareTo(_arg2)); }; if ((((_arg1 is Number)) && ((_arg2 is Number)))){ return (compareNumbers(Number(_arg1), Number(_arg2))); }; if ((((_arg1 is Boolean)) && ((_arg2 is Boolean)))){ return (compareBooleans(Boolean(_arg1), Boolean(_arg2))); }; return (compareStrings(String(_arg1), String(_arg2))); } public static function compareEnumsByName(_arg1:Enum, _arg2:Enum, ... _args):int{ return (compareStrings(_arg1.name(), _arg2.name())); } public static function createNullSafe(_arg1:Function):Function{ var comparator = _arg1; return (function (_arg1:Object, _arg2:Object, ... _args):int{ if (_arg1 === _arg2){ return (0); }; if (_arg1 == null){ return (-1); }; if (_arg2 == null){ return (1); }; return (comparator(_arg1, _arg2)); }); } public static function compareComparables(_arg1:Comparable, _arg2:Comparable, ... _args):int{ return (_arg1.compareTo(_arg2)); } public static function createFields(_arg1:Array, _arg2:Array=null):Function{ var sortFields = _arg1; var defaults = _arg2; if (defaults == null){ defaults = []; }; return (function (_arg1:Object, _arg2:Object, ... _args):int{ var _local4:*; var _local5:*; var _local6:*; var _local7:*; var _local8:*; var _local9:*; _local4 = 0; while (_local4 < sortFields.length) { _local5 = sortFields[_local4]; _local6 = defaults[_local4]; _local7 = (((!((_arg1 == null))) && (_arg1.hasOwnProperty(_local5)))) ? _arg1[_local5] : _local6; _local8 = (((!((_arg2 == null))) && (_arg2.hasOwnProperty(_local5)))) ? _arg2[_local5] : _local6; _local9 = compareUnknowns(_local7, _local8); if (_local9 != 0){ return (_local9); }; _local4++; }; return (0); }); } public static function compareBooleans(_arg1:Boolean, _arg2:Boolean, ... _args):int{ return (((_arg1)==_arg2) ? 0 : (_arg1) ? 1 : -1); } public static function compareStrings(_arg1:String, _arg2:String, ... _args):int{ return (((_arg1)==_arg2) ? 0 : ((_arg1)>_arg2) ? 1 : -1); } } }//package com.threerings.util
Section 23
//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(Joiner.args("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 (Comparators.compareInts(this.ordinal(), Enum(_arg1).ordinal())); } public function valueOf():Object{ return (ordinal()); } final public function name():String{ return (_name); } public function toString():String{ return (_name); } final public function ordinal():int{ return ((_enums[ClassUtil.getClass(this)] as Array).indexOf(this)); } final public function hashCode():int{ return (ordinal()); } final 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(Joiner.pairs("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(Joiner.pairs("No such enum", "class", _arg1, "name", _arg2))); } protected static function finishedEnumerating(_arg1:Class):void{ _blocked[_arg1] = true; } finishedEnumerating(Enum); } }//package com.threerings.util
Section 24
//Equalable (com.threerings.util.Equalable) package com.threerings.util { public interface Equalable { function equals(_arg1:Object):Boolean; } }//package com.threerings.util
Section 25
//Hashable (com.threerings.util.Hashable) package com.threerings.util { public interface Hashable extends Equalable { function hashCode():int; } }//package com.threerings.util
Section 26
//Joiner (com.threerings.util.Joiner) package com.threerings.util { import flash.utils.*; public class Joiner { protected var _msg:String; protected var _details:String; public function Joiner(_arg1:String=""){ _msg = _arg1; _details = ""; } public function add(... _args):Joiner{ _details = format(true, _details, _args); return (this); } public function toString():String{ return (output(_msg, _details)); } public function addFields(_arg1:Object, _arg2:Array=null):Joiner{ var args:Array; var field:String; var bit:String; var dynamicFieldName:String; var obj = _arg1; var fieldNames = _arg2; if (fieldNames == null){ fieldNames = []; for each (bit in describeType(obj)..variable.@name) { fieldNames.push(bit); }; for (dynamicFieldName in obj) { fieldNames.push(dynamicFieldName); }; }; args = []; for each (field in fieldNames) { args.push(field); try { args.push(obj[field]); } catch(re:ReferenceError) { args.push("<ReferenceError>"); }; }; return (add.apply(null, args)); } public function addArgsArray(_arg1:Array):Joiner{ return (addArgs.apply(null, _arg1)); } public function addArgs(... _args):Joiner{ _details = format(false, _details, _args); return (this); } public static function pairsArray(_arg1:String, _arg2:Array):String{ return (output(_arg1, format(true, "", _arg2))); } protected static function output(_arg1:String, _arg2:String):String{ return (((_arg2)=="") ? _arg1 : (((_arg1 + " [") + _arg2) + "]")); } public static function createFor(_arg1:Object):Joiner{ return (new Joiner(ClassUtil.tinyClassName(_arg1))); } protected static function format(_arg1:Boolean, _arg2:String, _arg3:Array):String{ var _local4:int; _local4 = 0; while (_local4 < _arg3.length) { if (_arg2 != ""){ _arg2 = (_arg2 + ", "); }; _arg2 = (_arg2 + argToString(_arg3[_local4])); if (((_arg1) && ((_temp1 < _arg3.length)))){ _arg2 = (_arg2 + ("=" + argToString(_arg3[_local4]))); }; _local4++; }; return (_arg2); } public static function pairs(_arg1:String, ... _args):String{ return (pairsArray(_arg1, _args)); } protected static function argToString(_arg1):String{ return (String(_arg1)); } public static function argsArray(_arg1:String, _arg2:Array):String{ return (output(_arg1, format(false, "", _arg2))); } public static function args(_arg1:String, ... _args):String{ return (argsArray(_arg1, _args)); } public static function simpleToString(_arg1:Object, _arg2:Array=null):String{ return (createFor(_arg1).addFields(_arg1, _arg2).toString()); } } }//package com.threerings.util
Section 27
//Log (com.threerings.util.Log) package com.threerings.util { import flash.utils.*; import flash.system.*; 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 = {:(Capabilities.isDebugger) ? DEBUG : OFF}; 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()); } protected function argToString(_arg1):String{ var arg = _arg1; try { if ((arg is Function)){ return (String(arg())); } else { return (String(arg)); }; } catch(e:Error) { try { return ((("<" + e) + ">")); } catch(e2:Error) { }; }; return ("<Error>"); } 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 { if (_local5 == null){ _arg2.push("error", _local5); } else { _arg2.push(_local5, ""); }; }; }; if (_arg2.length > 1){ _local6 = 1; while (_local6 < _arg2.length) { _local3 = (_local3 + ((_local6)==1) ? " [" : ", "); _local3 = (_local3 + ((argToString(_arg2[_local6]) + "=") + argToString(_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 28
//LogTarget (com.threerings.util.LogTarget) package com.threerings.util { public interface LogTarget { function log(_arg1:String):void; } }//package com.threerings.util
Section 29
//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 keys():Array; function get(_arg1:Object); function put(_arg1:Object, _arg2:Object); } }//package com.threerings.util
Section 30
//Maps (com.threerings.util.Maps) package com.threerings.util { import com.threerings.util.maps.*; public class Maps { public static function newMapOf(_arg1:Class):Map{ if ((((_arg1 === String)) || (((ClassUtil.isAssignableAs(Hashable, _arg1)) && (!(ClassUtil.isAssignableAs(Enum, _arg1))))))){ return (new HashMap()); }; return (new DictionaryMap()); } public static function some(_arg1:Map, _arg2:Function):Boolean{ var found:Boolean; var map = _arg1; var condition = _arg2; found = false; map.forEach(function (_arg1:Object, _arg2:Object):Boolean{ if (condition(_arg1, _arg2)){ found = true; return (true); }; return (false); }); return (found); } public static function selectValue(_arg1:Object, _arg2:Object):Object{ return (_arg2); } public static function findKey(_arg1:Map, _arg2:Object){ var key:*; var map = _arg1; var value = _arg2; key = undefined; map.forEach(function (_arg1:Object, _arg2:Object):Boolean{ if (Util.equals(value, _arg2)){ key = _arg1; return (true); }; return (false); }); return (key); } public static function filter(_arg1:Map, _arg2:Function, _arg3:Function=null):Array{ var matches:Array; var map = _arg1; var condition = _arg2; var transform = _arg3; if (transform == null){ transform = selectValue; }; matches = []; map.forEach(function (_arg1:Object, _arg2:Object):void{ if (condition(_arg1, _arg2)){ matches.push(transform(_arg1, _arg2)); }; }); return (matches); } public static function selectKey(_arg1:Object, _arg2:Object):Object{ return (_arg1); } public static function newBuilder(_arg1:Class):MapBuilder{ return (new MapBuilder(_arg1)); } public static function newSortedMapOf(_arg1:Class, _arg2:Function=null):Map{ return (newBuilder(_arg1).makeSorted(_arg2).build()); } public static function equals(_arg1:Map, _arg2:Map):Boolean{ var allEquals:Boolean; var map1 = _arg1; var map2 = _arg2; if (map1 === map2){ return (true); }; if ((((((map1 == null)) || ((map2 == null)))) || (!((map1.size() == map2.size()))))){ return (false); }; allEquals = true; map1.forEach(function (_arg1:Object, _arg2:Object):Boolean{ var _local3:*; _local3 = map2.get(_arg1); if ((((_local3 === undefined)) || (!(Util.equals(_arg2, _local3))))){ allEquals = false; }; return (!(allEquals)); }); return (allEquals); } } }//package com.threerings.util
Section 31
//Preconditions (com.threerings.util.Preconditions) package com.threerings.util { public class Preconditions { public static function checkNotNull(_arg1, _arg2:String=null){ if (_arg1 == null){ throw (new TypeError(((_arg2) || ("")))); }; return (_arg1); } public static function checkIndex(_arg1:int, _arg2:int, _arg3:String=null):int{ if ((((_arg1 < 0)) || ((_arg1 >= _arg2)))){ throw (new RangeError(((_arg3) || (Joiner.pairs("Index out of bounds", "index", _arg1, "size", _arg2))))); }; return (_arg1); } public static function checkArgument(_arg1:Boolean, _arg2:String=null):void{ if (!_arg1){ throw (new ArgumentError(((_arg2) || ("")))); }; } public static function checkRange(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:String=null):Number{ if (((((isNaN(_arg1)) || ((_arg1 < _arg2)))) || ((_arg1 > _arg3)))){ throw (new RangeError(((_arg4) || (Joiner.pairs("Value out of range", "value", _arg1, "low", _arg2, "high", _arg3))))); }; return (_arg1); } } }//package com.threerings.util
Section 32
//Predicates (com.threerings.util.Predicates) package com.threerings.util { public class Predicates { public static function createPropertyEquals(_arg1:String, _arg2:Object):Function{ var propName = _arg1; var value = _arg2; return (function (_arg1, ... _args):Boolean{ return (((((!((_arg1 == null))) && (_arg1.hasOwnProperty(propName)))) && (Util.equals(_arg1[propName], value)))); }); } public static function isNull(_arg1, ... _args):Boolean{ return ((_arg1 == null)); } public static function createHasProperty(_arg1:String):Function{ var propName = _arg1; return (function (_arg1, ... _args):Boolean{ return (((!((_arg1 == null))) && (_arg1.hasOwnProperty(propName)))); }); } public static function createIs(_arg1:Class):Function{ var clazz = _arg1; return (function (_arg1, ... _args):Boolean{ return ((_arg1 is clazz)); }); } public static function createNot(_arg1:Function):Function{ var pred = _arg1; return (function (... _args):Boolean{ return (!(pred.apply(null, _args))); }); } public static function createIn(_arg1:Array):Function{ var array = _arg1; return (function (_arg1, ... _args):Boolean{ return (ArrayUtil.contains(array, _arg1)); }); } public static function notNull(_arg1, ... _args):Boolean{ return (!((_arg1 == null))); } public static function createEquals(_arg1:Object):Function{ var value = _arg1; return (function (_arg1, ... _args):Boolean{ return (Util.equals(_arg1, value)); }); } public static function createAnd(... _args):Function{ var predicates = _args; return (function (... _args):Boolean{ var _local2:*; for each (_local2 in predicates) { if (!_local2.apply(null, _args)){ return (false); }; }; return (true); }); } public static function createOr(... _args):Function{ var predicates = _args; return (function (... _args):Boolean{ var _local2:*; for each (_local2 in predicates) { if (_local2.apply(null, _args)){ return (true); }; }; return (false); }); } } }//package com.threerings.util
Section 33
//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 34
//StringUtil (com.threerings.util.StringUtil) package com.threerings.util { import flash.utils.*; public class StringUtil { protected static const DECIMAL:Array = HEX.slice(0, 10); protected static const URL_REGEXP:RegExp = new RegExp("\\b(([\\w-]+://?|www[.])[^\\s()<>]+(?:\\([\\w\\d]+\\)|([^!\\\"#$%&'()*+,\\-./:;<=>?@\\[\\\\\\]\\^_`{|}~\\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 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)); _arg1 = _arg1.substring((_local4 + _local5.length)); if (startsWith(_local5.toLowerCase(), "www.")){ _local5 = ("http://" + _local5); }; _local2.push(_local5); }; if (((!((_arg1 == ""))) || ((_local2.length == 0)))){ _local2.push(_arg1); }; return (_local2); } 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(Joiner.pairs("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; _local2 = 0; if (_arg1 != null){ _local3 = 0; while (_local3 < _arg1.length) { _local2 = ((31 * _local2) + _arg1.charCodeAt(_local3)); _local3++; }; }; 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(Joiner.args("Could not convert to Number", _local2))); }; 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 compare(_arg1:String, _arg2:String):int{ return (Comparators.compareStrings(_arg1, _arg2)); } 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 compareIgnoreCase(_arg1:String, _arg2:String):int{ return (Comparators.compareStringsInsensitively(_arg1, _arg2)); } public static function isUpperCase(_arg1:String):Boolean{ var _local2:String; _local2 = _arg1.charAt(0); return ((((_local2.toUpperCase() == _local2)) && (!((_local2.toLowerCase() == _local2))))); } 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 (XmlUtil.toXMLString((_arg1 as XML))); }; }; return (String(_arg1)); } public static function deNull(_arg1:String):String{ return (((_arg1)==null) ? "" : _arg1); } 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); } public static function toColorString(_arg1:uint, _arg2:String="0x"):String{ return ((_arg2 + prepad(_arg1.toString(16), 6, "0"))); } public static function capitalize(_arg1:String):String{ if (isBlank(_arg1)){ return (_arg1); }; return ((_arg1.substr(0, 1).toUpperCase() + _arg1.substr(1))); } 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(Joiner.args("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(Joiner.pairs("Invalid characters in String", "string", arguments[0], "radix", _arg2))); }; _local6++; }; _local7 = parseInt(_arg1, _arg2); if (isNaN(_local7)){ throw (new ArgumentError(Joiner.args("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(Joiner.args("Could not convert to Boolean", _local2))); } public static function startsWith(_arg1:String, _arg2:String):Boolean{ return ((_arg1.lastIndexOf(_arg2, 0) == 0)); } public static function toHex(_arg1:uint, _arg2:uint):String{ return (prepad(_arg1.toString(16), _arg2, "0")); } 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); } public static function simpleToString(_arg1:Object, _arg2:Array=null):String{ return (Joiner.simpleToString(_arg1, _arg2)); } } }//package com.threerings.util
Section 35
//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 sequence(... _args):Function{ var functions = _args; return (function (... _args):void{ var _local2:*; for each (_local2 in functions) { _local2.apply(null, _args); }; }); } public static function adapt(_arg1:Function, ... _args):Function{ var fn = _arg1; var prepend = _args; return (function (... _args){ if (prepend.length > 0){ _args.unshift.apply(null, prepend); }; ArrayUtil.resize(_args, fn.length); return (fn.apply(null, _args)); }); } public static function keys(_arg1:Object):Array{ var _local2:Array; var _local3:*; _local2 = []; for (_local3 in _arg1) { _local2.push(_local3); }; return (_local2); } public static function unit(_arg1:int):Function{ var n = _arg1; return (function (... _args){ return (_args[n]); }); } 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 values(_arg1:Object):Array{ var _local2:Array; var _local3:*; _local2 = []; for each (_local3 in _arg1) { _local2.push(_local3); }; return (_local2); } public static function getDefault(_arg1:Object, _arg2:String, _arg3:Object):Object{ return (((_arg2 in _arg1)) ? _arg1[_arg2] : _arg3); } 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 unfuckVarargs(_arg1:Array):Array{ return (((((_arg1.length == 1)) && ((_arg1[0] is Array)))) ? (_arg1[0] as Array) : _arg1); } public static function isPlainObject(_arg1:Object):Boolean{ return ((getQualifiedClassName(_arg1) == "Object")); } } }//package com.threerings.util
Section 36
//WeakReference (com.threerings.util.WeakReference) package com.threerings.util { import flash.utils.*; public class WeakReference { protected var _ref:Dictionary; public function WeakReference(_arg1:Object){ _ref = new Dictionary(true); super(); _ref[_arg1] = true; } public function get(){ var _local1:*; for (_local1 in _ref) { return (_local1); }; return (undefined); } } }//package com.threerings.util
Section 37
//XmlReadError (com.threerings.util.XmlReadError) package com.threerings.util { public class XmlReadError extends Error { public function XmlReadError(_arg1:String="", _arg2:XML=null){ super(getErrString(_arg1, _arg2), 0); } protected static function getErrString(_arg1:String, _arg2:XML=null):String{ var _local3:String; _local3 = _arg1; if (_arg2 != null){ _local3 = (_local3 + ("\n" + XmlUtil.toXMLString(_arg2))); }; return (_local3); } } }//package com.threerings.util
Section 38
//XmlUtil (com.threerings.util.XmlUtil) package com.threerings.util { public class XmlUtil { public static function getUintAttr(_arg1:XML, _arg2:String, _arg3=undefined):uint{ return (getAttr(_arg1, _arg2, _arg3, StringUtil.parseUnsignedInteger)); } public static function hasAttribute(_arg1:XML, _arg2:String):Boolean{ return (!((null == _arg1.attribute(_arg2)[0]))); } public static function getStringArrayAttr(_arg1:XML, _arg2:String, _arg3:Array, _arg4=undefined):int{ var xml = _arg1; var name = _arg2; var stringMapping = _arg3; var defaultValue = _arg4; return (getAttr(xml, name, defaultValue, function (_arg1:String):int{ return (parseStringMember(_arg1, stringMapping)); })); } protected static function parseStringMember(_arg1:String, _arg2:Array):int{ var _local3:int; var _local4:Boolean; var _local5:int; var _local6:String; _local5 = 0; while (_local5 < _arg2.length) { if (String(_arg2[_local5]) == _arg1){ _local3 = _local5; _local4 = true; break; }; _local5++; }; if (!_local4){ _local6 = (("could not convert '" + _arg1) + "' to the correct value (must be one of: "); _local5 = 0; while (_local5 < _arg2.length) { _local6 = (_local6 + String(_arg2[_local5])); if (_local5 < (_arg2.length - 1)){ _local6 = (_local6 + ", "); }; _local5++; }; _local6 = (_local6 + ")"); throw (new ArgumentError(_local6)); }; return (_local3); } public static function getAttr(_arg1:XML, _arg2:String, _arg3, _arg4:Function=null){ var value:*; var attr:XML; var xml = _arg1; var name = _arg2; var defaultValue = _arg3; var parseFunction = _arg4; attr = xml.attribute(name)[0]; if (null == attr){ if (undefined !== defaultValue){ return (defaultValue); }; throw (new XmlReadError((("error reading attribute '" + name) + "': attribute does not exist"), xml)); }; try { value = ((null)!=parseFunction) ? parseFunction(attr) : attr; } catch(e:ArgumentError) { throw (new XmlReadError(((("error reading attribute '" + name) + "': ") + e.message), xml)); }; return (value); } public static function getEnumAttr(_arg1:XML, _arg2:String, _arg3:Class, _arg4=undefined){ var xml = _arg1; var name = _arg2; var enumClazz = _arg3; var defaultValue = _arg4; return (getAttr(xml, name, defaultValue, function (_arg1:String):Enum{ return (Enum.valueOf(enumClazz, _arg1)); })); } public static function hasChild(_arg1:XML, _arg2:String):Boolean{ return ((_arg1.child(_arg2).length() > 0)); } public static function getIntAttr(_arg1:XML, _arg2:String, _arg3=undefined):int{ return (getAttr(_arg1, _arg2, _arg3, StringUtil.parseInteger)); } public static function toString(_arg1:XML, _arg2:Object=null):String{ var xml = _arg1; var settings = _arg2; return ((safeOp(function (){ return (xml.toString()); }, settings) as String)); } public static function toXMLString(_arg1:XML, _arg2:Object=null):String{ var xml = _arg1; var settings = _arg2; return ((safeOp(function (){ return (xml.toXMLString()); }, settings) as String)); } public static function safeOp(_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 getNumberAttr(_arg1:XML, _arg2:String, _arg3=undefined):Number{ return (getAttr(_arg1, _arg2, _arg3, StringUtil.parseNumber)); } public static function getBooleanAttr(_arg1:XML, _arg2:String, _arg3=undefined):Boolean{ return (getAttr(_arg1, _arg2, _arg3, StringUtil.parseBoolean)); } public static function newXML(_arg1:Object, _arg2:Object=null):XML{ var value = _arg1; var settings = _arg2; return ((safeOp(function (){ return (new XML(value)); }, settings) as XML)); } public static function getStringAttr(_arg1:XML, _arg2:String, _arg3=undefined):String{ return (getAttr(_arg1, _arg2, _arg3)); } public static function getSingleChild(_arg1:XML, _arg2:String, _arg3=undefined):XML{ var _local4:XML; _local4 = _arg1.child(_arg2)[0]; if (null == _local4){ if (undefined !== _arg3){ return (_arg3); }; throw (new XmlReadError((("error accessing child '" + _arg2) + "': child does not exist"), _arg1)); }; return (_local4); } } }//package com.threerings.util
Section 39
//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); }; } public 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 handleUnload(_arg1:Event):void{ dispatchEvent(_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."))); }; } public function setUserProps(_arg1:Object):void{ var _local2:AbstractSubControl; for each (_local2 in _subControls) { _local2.setUserProps(_arg1); }; } public function doBatch(_arg1:Function, ... _args):void{ var fn = _arg1; var args = _args; callHostCode("startTransaction"); try { fn.apply(null, args); } finally { callHostCode("commitTransaction"); }; } protected function createSubControls():Array{ return (null); } public function gotHostProps(_arg1:Object):void{ var _local2:AbstractSubControl; _funcs = _arg1; for each (_local2 in _subControls) { _local2.gotHostProps(_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 40
//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); } override public function doBatch(_arg1:Function, ... _args):void{ _args.unshift(_arg1); _parent.doBatch.apply(null, _args); } override public function callHostCode(_arg1:String, ... _args){ _args.unshift(_arg1); return (_parent.callHostCode.apply(null, _args)); } override public function isConnected():Boolean{ return (_parent.isConnected()); } } }//package com.whirled
Section 41
//ActorControl (com.whirled.ActorControl) package com.whirled { import flash.display.*; public class ActorControl extends EntityControl { protected var _orient:Number;// = 0 protected var _isMoving:Boolean; protected var _avatarMovie:DisplayObject; public function ActorControl(_arg1:DisplayObject){ _orient = 0; _avatarMovie = _arg1; 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 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 setLogicalLocation(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{ callHostCode("setLocation_v1", _arg1, _arg2, _arg3, _arg4); } public function setOrientation(_arg1:Number):void{ callHostCode("setOrientation_v1", _arg1); } override public function setUserProps(_arg1:Object):void{ super.setUserProps(_arg1); _arg1["appearanceChanged_v2"] = appearanceChanged_v2; _arg1["stateSet_v1"] = stateSet_v1; } public function setState(_arg1:String):void{ callHostCode("setState_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); } public function getOrientation():Number{ return (_orient); } public function setMoveSpeed(_arg1:Number):void{ callHostCode("setMoveSpeed_v1", _arg1); } public function noFlip(_arg1:DisplayObject){ if (getOrientation() < 180){ if (_arg1 == _avatarMovie){ _arg1.x = 0; }; _arg1.scaleX = 1; }; } public function getState():String{ return ((isConnected()) ? (callHostCode("getState_v1") as String) : null); } } }//package com.whirled
Section 42
//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); } public function isSleeping():Boolean{ return (_isSleeping); } override protected function gotInitProps(_arg1:Object):void{ super.gotInitProps(_arg1); _isSleeping = (_arg1["isSleeping"] as Boolean); } override public 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++; }; } public function unfly(){ setPreferredY(0); } 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 fly(_arg1:Number=0.2){ var _local2:Array; _local2 = new Array(3); _local2 = getRoomBounds(); setPreferredY((_local2[1] * _arg1)); } 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 setPreferredY(_arg1:int):void{ callHostCode("setPreferredY_v1", _arg1); } } }//package com.whirled
Section 43
//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 MUSIC_STARTED:String = "musicStarted"; public static const CHAT_RECEIVED:String = "chatReceived"; public static const ACTION_TRIGGERED:String = "actionTriggered"; public static const MUSIC_STOPPED:String = "musicStopped"; public static const ENTITY_MOVED:String = "entityMoved"; public static const MESSAGE_RECEIVED:String = "messageRecieved"; public static const ENTITY_ENTERED:String = "entityEntered"; public static const MUSIC_ID3:String = "musicId3"; 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 44
//EntityControl (com.whirled.EntityControl) package com.whirled { import flash.events.*; import flash.display.*; import flash.utils.*; import flash.media.*; import flash.text.*; import flash.filters.*; public class EntityControl extends AbstractControl { protected var _hasControl:Boolean;// = false protected var _customConfig:Function; protected var _datapack:ByteArray; protected var _env:String; protected var _ticker:Timer; protected var _location:Array; protected var _propertyProvider:Function; protected var _tickInterval:Number;// = 0 public static const ENV_VIEWER:String = "viewer"; public static const PROP_MEMBER_ID:String = "std:member_id"; public static const ENV_ROOM:String = "room"; public static const PROP_HOTSPOT:String = "std:hotspot"; public static const PROP_ORIENTATION:String = "std:orientation"; public static const PROP_MOVE_SPEED:String = "std:move_speed"; public static const PROP_TYPE:String = "std:type"; public static const TYPE_FURNI:String = "furni"; public static const PROP_NAME:String = "std:name"; public static const PROP_DIMENSIONS:String = "std:dimensions"; public static const ENV_SHOP:String = "shop"; public static const PROP_LOCATION_PIXEL:String = "std:location_pixel"; public static const TYPE_PET:String = "pet"; public static const PROP_LOCATION_LOGICAL:String = "std:location_logical"; 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(); }; } public function getMusicId3():Object{ return (callHostCode("getMusicId3_v1")); } public function showAboutPopup(_arg1:String, _arg2:uint=0, _arg3:uint=0xFFFFFF, _arg4:Number=300, _arg5:Number=300, _arg6:Number=1, _arg7:int=12):void{ var _local8:MovieClip; var _local9:DisplayObject; var _local10:TextField; var _local11:TextFormat; var _local12:Shape; _local8 = new MovieClip(); _local10 = new TextField(); _local11 = new TextFormat(); _local12 = new Shape(); _local8.addChild(_local12); _local12.width = _arg4; _local12.height = _arg5; _local12.graphics.beginFill(_arg2, _arg6); _local12.graphics.drawRect(0, 0, _arg4, _arg5); _local12.graphics.endFill(); _local8.addChild(_local10); _local10.text = _arg1; _local10.width = (_arg4 - 10); _local10.height = (_arg5 - 10); _local10.x = 5; _local10.y = 5; _local10.selectable = true; _local10.wordWrap = true; _local11.size = _arg7; _local11.color = _arg3; _local10.setTextFormat(_local11); _local9 = _local8; showPopup("About", _local9, _arg4, _arg5, _arg2, _arg6); } 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); _env = (_arg1["env"] as String); } public function getInstanceId():int{ return (int(callHostCode("getInstanceId_v1"))); } protected function entityMoved_v2(_arg1:String, _arg2:Array):void{ if (_hasControl){ dispatchCtrlEvent(ControlEvent.ENTITY_MOVED, _arg1, _arg2); }; } public function getCamera(_arg1:String=null):Camera{ return ((isConnected()) ? (callHostCode("getCamera_v1", _arg1) as Camera) : Camera.getCamera(_arg1)); } public function dispatchCtrlEvent(_arg1:String, _arg2:String=null, _arg3:Object=null):void{ if (hasEventListener(_arg1)){ dispatchEvent(new ControlEvent(_arg1, _arg2, _arg3)); }; } public function triggerAction(_arg1:String, _arg2:Object=null):void{ callHostCode("sendMessage_v1", _arg1, _arg2, true); } public function removeOutline(_arg1:DisplayObject){ _arg1.filters = []; } 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 public 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["hasConfigPanel_v1"] = hasConfigPanel_v1; _arg1["getConfigPanel_v1"] = getConfigPanel_v1; _arg1["musicStartStop_v1"] = musicStartStop_v1; _arg1["musicId3_v1"] = musicId3_v1; _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, dispatchEvent); } else { _ticker.delay = _tickInterval; }; _ticker.start(); } else { stopTicker(); }; } public function getMicrophone(_arg1:int=-1):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)); } protected function hasConfigPanel_v1():Boolean{ return (!((_customConfig == null))); } protected function musicId3_v1(_arg1:Object):void{ dispatchCtrlEvent(ControlEvent.MUSIC_ID3, null, _arg1); } public function getViewerName(_arg1:int=0):String{ return ((callHostCode("getViewerName_v1", _arg1) as String)); } public function getMusicOwnerId():int{ return (callHostCode("getMusicOwner_v1")); } protected function gotControl_v1():void{ if (_hasControl){ return; }; _hasControl = true; dispatchCtrlEvent(ControlEvent.CONTROL_ACQUIRED); recheckTicker(); } protected function entityEntered_v1(_arg1:String):void{ if (_hasControl){ dispatchCtrlEvent(ControlEvent.ENTITY_ENTERED, _arg1); }; } 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 getMemories():Object{ var _local1:Object; _local1 = callHostCode("getMemories_v1"); return (((_local1)==null) ? {} : _local1); } public function registerCustomConfig(_arg1:Function):void{ _customConfig = _arg1; } override protected function checkIsConnected():void{ } protected function signalReceived_v1(_arg1:String, _arg2:Object):void{ if (_hasControl){ dispatchCtrlEvent(ControlEvent.SIGNAL_RECEIVED, _arg1, _arg2); }; } protected function musicStartStop_v1(_arg1:Boolean, ... _args):void{ dispatchCtrlEvent((_arg1) ? ControlEvent.MUSIC_STARTED : ControlEvent.MUSIC_STOPPED); } public function getEnvironment():String{ return (_env); } public function sendMessage(_arg1:String, _arg2:Object=null):void{ callHostCode("sendMessage_v1", _arg1, _arg2, false); } public function addOutline(_arg1:DisplayObject, _arg2:uint=0, _arg3:Number=1, _arg4:Number=5, _arg5:Number=2, _arg6:int=1){ if (_arg3 > 1){ _arg3 = 1; } else { if (_arg3 < 0){ _arg3 = 0; }; }; if (_arg4 > 0xFF){ _arg4 = 0xFF; } else { if (_arg4 < 0){ _arg4 = 0; }; }; if (_arg5 > 0xFF){ _arg5 = 0xFF; } else { if (_arg5 < 0){ _arg5 = 0; }; }; if (_arg6 > 15){ _arg6 = 15; } else { if (_arg6 < 0){ _arg6 = 0; }; }; _arg1.filters = [new GlowFilter(_arg2, _arg3, _arg4, _arg4, _arg5, _arg6)]; } public function hasControl():Boolean{ return (_hasControl); } public function getRoomBounds():Array{ return ((callHostCode("getRoomBounds_v1") as Array)); } public function sendSignal(_arg1:String, _arg2:Object=null):void{ callHostCode("sendSignal_v1", _arg1, _arg2); } protected function memoryChanged_v1(_arg1:String, _arg2:Object):void{ dispatchCtrlEvent(ControlEvent.MEMORY_CHANGED, _arg1, _arg2); } public function clearPopup():void{ callHostCode("clearPopup_v1"); } public function getEntityProperty(_arg1:String, _arg2:String=null):Object{ return (callHostCode("getEntityProperty_v1", _arg2, _arg1)); } protected function entityLeft_v1(_arg1:String):void{ if (_hasControl){ dispatchCtrlEvent(ControlEvent.ENTITY_LEFT, _arg1); }; } protected function getConfigPanel_v1():DisplayObject{ return (((_customConfig)!=null) ? (_customConfig() as DisplayObject) : null); } public function getMemory(_arg1:String, _arg2:Object=null):Object{ var _local3:Object; _local3 = callHostCode("lookupMemory_v1", _arg1); return (((_local3)==null) ? _arg2 : _local3); } override public function gotHostProps(_arg1:Object):void{ super.gotHostProps(_arg1); if (("initProps" in _arg1)){ gotInitProps(_arg1.initProps); delete _arg1.initProps; }; } } }//package com.whirled
Section 45
//MainTimeline (Gorey_fla.MainTimeline) package Gorey_fla { import com.whirled.*; import flash.events.*; import flash.display.*; public dynamic class MainTimeline extends MovieClip { public var _ctrl:AvatarControl; public var Face:MovieClip; public var _body:Body; public function MainTimeline(){ addFrameScript(0, frame1); } public function startTalking(_arg1:ControlEvent):void{ Face.gotoAndPlay("Talk"); } public function handleUnload(... _args):void{ _body.shutdown(); } function frame1(){ if (_ctrl == null){ _ctrl = new AvatarControl(this); _body = new Body(_ctrl, this, 550); _ctrl.setHotSpot(275, 380, 390); _ctrl.setMoveSpeed(330); _ctrl.addEventListener(ControlEvent.AVATAR_SPOKE, startTalking); _ctrl.addEventListener(Event.UNLOAD, handleUnload); }; } } }//package Gorey_fla
Section 46
//Body (Body) package { import com.whirled.*; import flash.events.*; import flash.display.*; import com.threerings.util.*; public class Body { protected var _scenes:Map; 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 var _avatarScenes; 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 = Maps.newMapOf(String); _mode = ""; _sceneQueue = []; 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 = []; _avatarScenes = _media.scenes; 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(); _sceneQueue.push(_arg1); } 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 = []; _weights = []; _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)); } }

Library Items

Symbol 1 GraphicUsed by:4
Symbol 2 GraphicUsed by:3
Symbol 3 MovieClipUses:2Used by:4 39
Symbol 4 MovieClipUses:1 3Used by:Timeline
Symbol 5 GraphicUsed by:6
Symbol 6 MovieClipUses:5Used by:Timeline
Symbol 7 GraphicUsed by:8
Symbol 8 MovieClipUses:7Used by:Timeline
Symbol 9 GraphicUsed by:10
Symbol 10 MovieClipUses:9Used by:Timeline
Symbol 11 GraphicUsed by:12
Symbol 12 MovieClipUses:11Used by:Timeline
Symbol 13 GraphicUsed by:14
Symbol 14 MovieClipUses:13Used by:Timeline
Symbol 15 GraphicUsed by:16
Symbol 16 MovieClipUses:15Used by:Timeline
Symbol 17 GraphicUsed by:20
Symbol 18 GraphicUsed by:19
Symbol 19 MovieClipUses:18Used by:20 39
Symbol 20 MovieClipUses:17 19Used by:Timeline
Symbol 21 GraphicUsed by:22
Symbol 22 MovieClipUses:21Used by:Timeline
Symbol 23 GraphicUsed by:24
Symbol 24 MovieClipUses:23Used by:Timeline
Symbol 25 GraphicUsed by:29
Symbol 26 GraphicUsed by:27
Symbol 27 MovieClipUses:26Used by:29
Symbol 28 GraphicUsed by:29
Symbol 29 MovieClipUses:25 27 28Used by:Timeline
Symbol 30 GraphicUsed by:31
Symbol 31 MovieClipUses:30Used by:Timeline
Symbol 32 GraphicUsed by:35
Symbol 33 GraphicUsed by:34
Symbol 34 MovieClipUses:33Used by:35
Symbol 35 MovieClipUses:32 34Used by:Timeline
Symbol 36 GraphicUsed by:37
Symbol 37 MovieClipUses:36Used by:Timeline
Symbol 38 GraphicUsed by:39
Symbol 39 MovieClipUses:38 19 3Used by:Timeline
Symbol 40 GraphicUsed by:41
Symbol 41 MovieClipUses:40Used by:Timeline

Instance Names

"Face"Frame 2Symbol 35 MovieClip
"Face"Frame 62Symbol 35 MovieClip
"Face"Frame 77Symbol 35 MovieClip
"Face"Frame 107Symbol 35 MovieClip
"Face"Frame 132Symbol 35 MovieClip
"Face"Frame 147Symbol 35 MovieClip
"Face"Frame 177Symbol 35 MovieClip
"Face"Frame 203Symbol 35 MovieClip
"Face"Frame 248Symbol 35 MovieClip
"Face"Frame 256Symbol 39 MovieClip
"Face"Frame 266Symbol 39 MovieClip
"Face"Frame 273Symbol 35 MovieClip
"Face"Frame 281Symbol 35 MovieClip
"Face"Frame 311Symbol 35 MovieClip
"Face"Frame 319Symbol 39 MovieClip

Special Tags

FileAttributes (69)Timeline Frame 1Access local files only, Metadata not present, AS3.




http://swfchan.com/41/202847/info.shtml
Created: 27/7 -2019 10:53:29 Last modified: 27/7 -2019 10:53:29 Server time: 22/12 -2024 10:22:41