Section 1
//AuxFunctions (caurina.transitions.AuxFunctions)
package caurina.transitions {
public class AuxFunctions {
public function AuxFunctions(){
super();
}
public static function concatObjects(... _args):Object{
var finalObject:Object;
var currentObject:Object;
var i:int;
var prop:String;
finalObject = {};
i = 0;
while (i < _args.length) {
currentObject = _args[i];
for (prop in currentObject) {
if (currentObject[prop] == null){
delete finalObject[prop];
} else {
finalObject[prop] = currentObject[prop];
};
};
i++;
};
return (finalObject);
}
public static function numberToG(p_num:Number):Number{
return (((p_num & 0xFF00) >> 8));
}
public static function numberToR(p_num:Number):Number{
return (((p_num & 0xFF0000) >> 16));
}
public static function isInArray(p_string:String, p_array:Array):Boolean{
var l:uint;
var i:uint;
l = p_array.length;
i = 0;
while (i < l) {
if (p_array[i] == p_string){
return (true);
};
i++;
};
return (false);
}
public static function getObjectLength(p_object:Object):uint{
var totalProperties:uint;
var pName:String;
totalProperties = 0;
for (pName in p_object) {
totalProperties++;
};
return (totalProperties);
}
public static function numberToB(p_num:Number):Number{
return ((p_num & 0xFF));
}
}
}//package caurina.transitions
Section 2
//Equations (caurina.transitions.Equations)
package caurina.transitions {
public class Equations {
public function Equations(){
super();
trace("Equations is a static class and should not be instantiated.");
}
public static function easeOutBounce(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
if (t < (1 / 2.75)){
return (((c * ((7.5625 * t) * t)) + b));
};
if (t < (2 / 2.75)){
t = (t - (1.5 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.75)) + b));
};
if (t < (2.5 / 2.75)){
t = (t - (2.25 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.9375)) + b));
};
t = (t - (2.625 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.984375)) + b));
}
public static function easeInOutElastic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var p:Number;
var s:Number;
var a:Number;
if (t == 0){
return (b);
};
t = (t / (d / 2));
if (t == 2){
return ((b + c));
};
p = (((!(Boolean(p_params))) || (isNaN(p_params.period)))) ? (d * (0.3 * 1.5)) : p_params.period;
a = (((!(Boolean(p_params))) || (isNaN(p_params.amplitude)))) ? 0 : p_params.amplitude;
if (((!(Boolean(a))) || ((a < Math.abs(c))))){
a = c;
s = (p / 4);
} else {
s = ((p / (2 * Math.PI)) * Math.asin((c / a)));
};
if (t < 1){
--t;
return (((-0.5 * ((a * Math.pow(2, (10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p)))) + b));
};
--t;
return ((((((a * Math.pow(2, (-10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p))) * 0.5) + c) + b));
}
public static function easeInOutQuad(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return (((((c / 2) * t) * t) + b));
};
--t;
return ((((-(c) / 2) * ((t * (t - 2)) - 1)) + b));
}
public static function easeInOutBounce(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (((easeInBounce((t * 2), 0, c, d) * 0.5) + b));
};
return ((((easeOutBounce(((t * 2) - d), 0, c, d) * 0.5) + (c * 0.5)) + b));
}
public static function easeInOutBack(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number;
s = (((!(Boolean(p_params))) || (isNaN(p_params.overshoot)))) ? 1.70158 : p_params.overshoot;
t = (t / (d / 2));
if (t < 1){
s = (s * 1.525);
return ((((c / 2) * ((t * t) * (((s + 1) * t) - s))) + b));
};
t = (t - 2);
s = (s * 1.525);
return ((((c / 2) * (((t * t) * (((s + 1) * t) + s)) + 2)) + b));
}
public static function easeOutInCubic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutCubic((t * 2), b, (c / 2), d, p_params));
};
return (easeInCubic(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeNone(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return ((((c * t) / d) + b));
}
public static function easeOutBack(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number;
s = (((!(Boolean(p_params))) || (isNaN(p_params.overshoot)))) ? 1.70158 : p_params.overshoot;
t = ((t / d) - 1);
return (((c * (((t * t) * (((s + 1) * t) + s)) + 1)) + b));
}
public static function easeInOutSine(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return ((((-(c) / 2) * (Math.cos(((Math.PI * t) / d)) - 1)) + b));
}
public static function easeInBack(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var s:Number;
s = (((!(Boolean(p_params))) || (isNaN(p_params.overshoot)))) ? 1.70158 : p_params.overshoot;
t = (t / d);
return (((((c * t) * t) * (((s + 1) * t) - s)) + b));
}
public static function easeInQuart(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return ((((((c * t) * t) * t) * t) + b));
}
public static function easeOutInQuint(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutQuint((t * 2), b, (c / 2), d, p_params));
};
return (easeInQuint(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeOutInBounce(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutBounce((t * 2), b, (c / 2), d, p_params));
};
return (easeInBounce(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function init():void{
Tweener.registerTransition("easenone", easeNone);
Tweener.registerTransition("linear", easeNone);
Tweener.registerTransition("easeinquad", easeInQuad);
Tweener.registerTransition("easeoutquad", easeOutQuad);
Tweener.registerTransition("easeinoutquad", easeInOutQuad);
Tweener.registerTransition("easeoutinquad", easeOutInQuad);
Tweener.registerTransition("easeincubic", easeInCubic);
Tweener.registerTransition("easeoutcubic", easeOutCubic);
Tweener.registerTransition("easeinoutcubic", easeInOutCubic);
Tweener.registerTransition("easeoutincubic", easeOutInCubic);
Tweener.registerTransition("easeinquart", easeInQuart);
Tweener.registerTransition("easeoutquart", easeOutQuart);
Tweener.registerTransition("easeinoutquart", easeInOutQuart);
Tweener.registerTransition("easeoutinquart", easeOutInQuart);
Tweener.registerTransition("easeinquint", easeInQuint);
Tweener.registerTransition("easeoutquint", easeOutQuint);
Tweener.registerTransition("easeinoutquint", easeInOutQuint);
Tweener.registerTransition("easeoutinquint", easeOutInQuint);
Tweener.registerTransition("easeinsine", easeInSine);
Tweener.registerTransition("easeoutsine", easeOutSine);
Tweener.registerTransition("easeinoutsine", easeInOutSine);
Tweener.registerTransition("easeoutinsine", easeOutInSine);
Tweener.registerTransition("easeincirc", easeInCirc);
Tweener.registerTransition("easeoutcirc", easeOutCirc);
Tweener.registerTransition("easeinoutcirc", easeInOutCirc);
Tweener.registerTransition("easeoutincirc", easeOutInCirc);
Tweener.registerTransition("easeinexpo", easeInExpo);
Tweener.registerTransition("easeoutexpo", easeOutExpo);
Tweener.registerTransition("easeinoutexpo", easeInOutExpo);
Tweener.registerTransition("easeoutinexpo", easeOutInExpo);
Tweener.registerTransition("easeinelastic", easeInElastic);
Tweener.registerTransition("easeoutelastic", easeOutElastic);
Tweener.registerTransition("easeinoutelastic", easeInOutElastic);
Tweener.registerTransition("easeoutinelastic", easeOutInElastic);
Tweener.registerTransition("easeinback", easeInBack);
Tweener.registerTransition("easeoutback", easeOutBack);
Tweener.registerTransition("easeinoutback", easeInOutBack);
Tweener.registerTransition("easeoutinback", easeOutInBack);
Tweener.registerTransition("easeinbounce", easeInBounce);
Tweener.registerTransition("easeoutbounce", easeOutBounce);
Tweener.registerTransition("easeinoutbounce", easeInOutBounce);
Tweener.registerTransition("easeoutinbounce", easeOutInBounce);
}
public static function easeOutExpo(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return (((t)==d) ? (b + c) : (((c * 1.001) * (-(Math.pow(2, ((-10 * t) / d))) + 1)) + b));
}
public static function easeOutInBack(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutBack((t * 2), b, (c / 2), d, p_params));
};
return (easeInBack(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeInExpo(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return (((t)==0) ? b : (((c * Math.pow(2, (10 * ((t / d) - 1)))) + b) - (c * 0.001)));
}
public static function easeInCubic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return (((((c * t) * t) * t) + b));
}
public static function easeInQuint(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return (((((((c * t) * t) * t) * t) * t) + b));
}
public static function easeInOutCirc(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return ((((-(c) / 2) * (Math.sqrt((1 - (t * t))) - 1)) + b));
};
t = (t - 2);
return ((((c / 2) * (Math.sqrt((1 - (t * t))) + 1)) + b));
}
public static function easeInQuad(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return ((((c * t) * t) + b));
}
public static function easeInBounce(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return (((c - easeOutBounce((d - t), 0, c, d)) + b));
}
public static function easeOutInExpo(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutExpo((t * 2), b, (c / 2), d, p_params));
};
return (easeInExpo(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeOutQuart(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = ((t / d) - 1);
return (((-(c) * ((((t * t) * t) * t) - 1)) + b));
}
public static function easeInSine(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return ((((-(c) * Math.cos(((t / d) * (Math.PI / 2)))) + c) + b));
}
public static function easeInOutQuart(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return (((((((c / 2) * t) * t) * t) * t) + b));
};
t = (t - 2);
return ((((-(c) / 2) * ((((t * t) * t) * t) - 2)) + b));
}
public static function easeOutQuad(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return ((((-(c) * t) * (t - 2)) + b));
}
public static function easeOutInElastic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutElastic((t * 2), b, (c / 2), d, p_params));
};
return (easeInElastic(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeInElastic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var p:Number;
var s:Number;
var a:Number;
if (t == 0){
return (b);
};
t = (t / d);
if (t == 1){
return ((b + c));
};
p = (((!(Boolean(p_params))) || (isNaN(p_params.period)))) ? (d * 0.3) : p_params.period;
a = (((!(Boolean(p_params))) || (isNaN(p_params.amplitude)))) ? 0 : p_params.amplitude;
if (((!(Boolean(a))) || ((a < Math.abs(c))))){
a = c;
s = (p / 4);
} else {
s = ((p / (2 * Math.PI)) * Math.asin((c / a)));
};
--t;
return ((-(((a * Math.pow(2, (10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p)))) + b));
}
public static function easeOutCubic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = ((t / d) - 1);
return (((c * (((t * t) * t) + 1)) + b));
}
public static function easeOutQuint(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = ((t / d) - 1);
return (((c * (((((t * t) * t) * t) * t) + 1)) + b));
}
public static function easeOutInQuad(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutQuad((t * 2), b, (c / 2), d, p_params));
};
return (easeInQuad(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeOutSine(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
return (((c * Math.sin(((t / d) * (Math.PI / 2)))) + b));
}
public static function easeInOutCubic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return ((((((c / 2) * t) * t) * t) + b));
};
t = (t - 2);
return ((((c / 2) * (((t * t) * t) + 2)) + b));
}
public static function easeInOutQuint(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / (d / 2));
if (t < 1){
return ((((((((c / 2) * t) * t) * t) * t) * t) + b));
};
t = (t - 2);
return ((((c / 2) * (((((t * t) * t) * t) * t) + 2)) + b));
}
public static function easeInCirc(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = (t / d);
return (((-(c) * (Math.sqrt((1 - (t * t))) - 1)) + b));
}
public static function easeOutInSine(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutSine((t * 2), b, (c / 2), d, p_params));
};
return (easeInSine(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeInOutExpo(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t == 0){
return (b);
};
if (t == d){
return ((b + c));
};
t = (t / (d / 2));
if (t < 1){
return (((((c / 2) * Math.pow(2, (10 * (t - 1)))) + b) - (c * 0.0005)));
};
--t;
return (((((c / 2) * 1.0005) * (-(Math.pow(2, (-10 * t))) + 2)) + b));
}
public static function easeOutElastic(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
var p:Number;
var s:Number;
var a:Number;
if (t == 0){
return (b);
};
t = (t / d);
if (t == 1){
return ((b + c));
};
p = (((!(Boolean(p_params))) || (isNaN(p_params.period)))) ? (d * 0.3) : p_params.period;
a = (((!(Boolean(p_params))) || (isNaN(p_params.amplitude)))) ? 0 : p_params.amplitude;
if (((!(Boolean(a))) || ((a < Math.abs(c))))){
a = c;
s = (p / 4);
} else {
s = ((p / (2 * Math.PI)) * Math.asin((c / a)));
};
return (((((a * Math.pow(2, (-10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p))) + c) + b));
}
public static function easeOutCirc(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
t = ((t / d) - 1);
return (((c * Math.sqrt((1 - (t * t)))) + b));
}
public static function easeOutInQuart(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutQuart((t * 2), b, (c / 2), d, p_params));
};
return (easeInQuart(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
public static function easeOutInCirc(t:Number, b:Number, c:Number, d:Number, p_params:Object=null):Number{
if (t < (d / 2)){
return (easeOutCirc((t * 2), b, (c / 2), d, p_params));
};
return (easeInCirc(((t * 2) - d), (b + (c / 2)), (c / 2), d, p_params));
}
}
}//package caurina.transitions
Section 3
//PropertyInfoObj (caurina.transitions.PropertyInfoObj)
package caurina.transitions {
public class PropertyInfoObj {
public var originalValueComplete:Object;
public var modifierParameters:Array;
public var isSpecialProperty:Boolean;
public var hasModifier:Boolean;
public var valueComplete:Number;
public var extra:Object;
public var valueStart:Number;
public var modifierFunction:Function;
public var arrayIndex:Number;
public function PropertyInfoObj(p_valueStart:Number, p_valueComplete:Number, p_originalValueComplete:Object, p_arrayIndex:Number, p_extra:Object, p_isSpecialProperty:Boolean, p_modifierFunction:Function, p_modifierParameters:Array){
super();
valueStart = p_valueStart;
valueComplete = p_valueComplete;
originalValueComplete = p_originalValueComplete;
arrayIndex = p_arrayIndex;
extra = p_extra;
isSpecialProperty = p_isSpecialProperty;
hasModifier = Boolean(p_modifierFunction);
modifierFunction = p_modifierFunction;
modifierParameters = p_modifierParameters;
}
public function toString():String{
var returnStr:String;
returnStr = "\n[PropertyInfoObj ";
returnStr = (returnStr + ("valueStart:" + String(valueStart)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("valueComplete:" + String(valueComplete)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("originalValueComplete:" + String(originalValueComplete)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("arrayIndex:" + String(arrayIndex)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("extra:" + String(extra)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("isSpecialProperty:" + String(isSpecialProperty)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("hasModifier:" + String(hasModifier)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("modifierFunction:" + String(modifierFunction)));
returnStr = (returnStr + ", ");
returnStr = (returnStr + ("modifierParameters:" + String(modifierParameters)));
returnStr = (returnStr + "]\n");
return (returnStr);
}
public function clone():PropertyInfoObj{
var nProperty:PropertyInfoObj;
nProperty = new PropertyInfoObj(valueStart, valueComplete, originalValueComplete, arrayIndex, extra, isSpecialProperty, modifierFunction, modifierParameters);
return (nProperty);
}
}
}//package caurina.transitions
Section 4
//SpecialProperty (caurina.transitions.SpecialProperty)
package caurina.transitions {
public class SpecialProperty {
public var parameters:Array;
public var preProcess:Function;
public var setValue:Function;
public var getValue:Function;
public function SpecialProperty(p_getFunction:Function, p_setFunction:Function, p_parameters:Array=null, p_preProcessFunction:Function=null){
super();
getValue = p_getFunction;
setValue = p_setFunction;
parameters = p_parameters;
preProcess = p_preProcessFunction;
}
public function toString():String{
var value:String;
value = "";
value = (value + "[SpecialProperty ");
value = (value + ("getValue:" + String(getValue)));
value = (value + ", ");
value = (value + ("setValue:" + String(setValue)));
value = (value + ", ");
value = (value + ("parameters:" + String(parameters)));
value = (value + ", ");
value = (value + ("preProcess:" + String(preProcess)));
value = (value + "]");
return (value);
}
}
}//package caurina.transitions
Section 5
//SpecialPropertyModifier (caurina.transitions.SpecialPropertyModifier)
package caurina.transitions {
public class SpecialPropertyModifier {
public var getValue:Function;
public var modifyValues:Function;
public function SpecialPropertyModifier(p_modifyFunction:Function, p_getFunction:Function){
super();
modifyValues = p_modifyFunction;
getValue = p_getFunction;
}
public function toString():String{
var value:String;
value = "";
value = (value + "[SpecialPropertyModifier ");
value = (value + ("modifyValues:" + String(modifyValues)));
value = (value + ", ");
value = (value + ("getValue:" + String(getValue)));
value = (value + "]");
return (value);
}
}
}//package caurina.transitions
Section 6
//SpecialPropertySplitter (caurina.transitions.SpecialPropertySplitter)
package caurina.transitions {
public class SpecialPropertySplitter {
public var parameters:Array;
public var splitValues:Function;
public function SpecialPropertySplitter(p_splitFunction:Function, p_parameters:Array){
super();
splitValues = p_splitFunction;
parameters = p_parameters;
}
public function toString():String{
var value:String;
value = "";
value = (value + "[SpecialPropertySplitter ");
value = (value + ("splitValues:" + String(splitValues)));
value = (value + ", ");
value = (value + ("parameters:" + String(parameters)));
value = (value + "]");
return (value);
}
}
}//package caurina.transitions
Section 7
//Tweener (caurina.transitions.Tweener)
package caurina.transitions {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
public class Tweener {
private static var _timeScale:Number = 1;
private static var _currentTimeFrame:Number;
private static var _specialPropertySplitterList:Object;
private static var _engineExists:Boolean = false;
private static var _specialPropertyModifierList:Object;
private static var _currentTime:Number;
private static var _tweenList:Array;
private static var _specialPropertyList:Object;
private static var _transitionList:Object;
private static var _inited:Boolean = false;
private static var __tweener_controller__:MovieClip;
public function Tweener(){
super();
trace("Tweener is a static class and should not be instantiated.");
}
public static function registerSpecialPropertyModifier(p_name:String, p_modifyFunction:Function, p_getFunction:Function):void{
var spm:SpecialPropertyModifier;
if (!_inited){
init();
};
spm = new SpecialPropertyModifier(p_modifyFunction, p_getFunction);
_specialPropertyModifierList[p_name] = spm;
}
public static function registerSpecialProperty(p_name:String, p_getFunction:Function, p_setFunction:Function, p_parameters:Array=null, p_preProcessFunction:Function=null):void{
var sp:SpecialProperty;
if (!_inited){
init();
};
sp = new SpecialProperty(p_getFunction, p_setFunction, p_parameters, p_preProcessFunction);
_specialPropertyList[p_name] = sp;
}
public static function init(... _args):void{
_inited = true;
_transitionList = new Object();
Equations.init();
_specialPropertyList = new Object();
_specialPropertyModifierList = new Object();
_specialPropertySplitterList = new Object();
}
private static function updateTweens():Boolean{
var i:int;
if (_tweenList.length == 0){
return (false);
};
i = 0;
while (i < _tweenList.length) {
if ((((_tweenList[i] == undefined)) || (!(_tweenList[i].isPaused)))){
if (!updateTweenByIndex(i)){
removeTweenByIndex(i);
};
if (_tweenList[i] == null){
removeTweenByIndex(i, true);
i--;
};
};
i++;
};
return (true);
}
public static function addCaller(p_scopes:Object=null, p_parameters:Object=null):Boolean{
var i:Number;
var rScopes:Array;
var p_obj:Object;
var rTime:Number;
var rDelay:Number;
var rTransition:Function;
var nTween:TweenListObj;
var myT:Number;
var trans:String;
if (!Boolean(p_scopes)){
return (false);
};
if ((p_scopes is Array)){
rScopes = p_scopes.concat();
} else {
rScopes = [p_scopes];
};
p_obj = p_parameters;
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
rTime = (isNaN(p_obj.time)) ? 0 : p_obj.time;
rDelay = (isNaN(p_obj.delay)) ? 0 : p_obj.delay;
if (typeof(p_obj.transition) == "string"){
trans = p_obj.transition.toLowerCase();
rTransition = _transitionList[trans];
} else {
rTransition = p_obj.transition;
};
if (!Boolean(rTransition)){
rTransition = _transitionList["easeoutexpo"];
};
i = 0;
while (i < rScopes.length) {
if (p_obj.useFrames == true){
nTween = new TweenListObj(rScopes[i], (_currentTimeFrame + (rDelay / _timeScale)), (_currentTimeFrame + ((rDelay + rTime) / _timeScale)), true, rTransition, p_obj.transitionParams);
} else {
nTween = new TweenListObj(rScopes[i], (_currentTime + ((rDelay * 1000) / _timeScale)), (_currentTime + (((rDelay * 1000) + (rTime * 1000)) / _timeScale)), false, rTransition, p_obj.transitionParams);
};
nTween.properties = null;
nTween.onStart = p_obj.onStart;
nTween.onUpdate = p_obj.onUpdate;
nTween.onComplete = p_obj.onComplete;
nTween.onOverwrite = p_obj.onOverwrite;
nTween.onStartParams = p_obj.onStartParams;
nTween.onUpdateParams = p_obj.onUpdateParams;
nTween.onCompleteParams = p_obj.onCompleteParams;
nTween.onOverwriteParams = p_obj.onOverwriteParams;
nTween.onStartScope = p_obj.onStartScope;
nTween.onUpdateScope = p_obj.onUpdateScope;
nTween.onCompleteScope = p_obj.onCompleteScope;
nTween.onOverwriteScope = p_obj.onOverwriteScope;
nTween.onErrorScope = p_obj.onErrorScope;
nTween.isCaller = true;
nTween.count = p_obj.count;
nTween.waitFrames = p_obj.waitFrames;
_tweenList.push(nTween);
if ((((rTime == 0)) && ((rDelay == 0)))){
myT = (_tweenList.length - 1);
updateTweenByIndex(myT);
removeTweenByIndex(myT);
};
i++;
};
return (true);
}
public static function pauseAllTweens():Boolean{
var paused:Boolean;
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
paused = false;
i = 0;
while (i < _tweenList.length) {
pauseTweenByIndex(i);
paused = true;
i++;
};
return (paused);
}
public static function removeTweens(p_scope:Object, ... _args):Boolean{
var properties:Array;
var i:uint;
properties = new Array();
i = 0;
while (i < _args.length) {
if ((((typeof(_args[i]) == "string")) && (!(AuxFunctions.isInArray(_args[i], properties))))){
properties.push(_args[i]);
};
i++;
};
return (affectTweens(removeTweenByIndex, p_scope, properties));
}
public static function splitTweens(p_tween:Number, p_properties:Array):uint{
var originalTween:TweenListObj;
var newTween:TweenListObj;
var i:uint;
var pName:String;
var found:Boolean;
originalTween = _tweenList[p_tween];
newTween = originalTween.clone(false);
i = 0;
while (i < p_properties.length) {
pName = p_properties[i];
if (Boolean(originalTween.properties[pName])){
originalTween.properties[pName] = undefined;
delete originalTween.properties[pName];
};
i++;
};
for (pName in newTween.properties) {
found = false;
i = 0;
while (i < p_properties.length) {
if (p_properties[i] == pName){
found = true;
break;
};
i++;
};
if (!found){
newTween.properties[pName] = undefined;
delete newTween.properties[pName];
};
};
_tweenList.push(newTween);
return ((_tweenList.length - 1));
}
public static function updateFrame():void{
_currentTimeFrame++;
}
public static function resumeTweenByIndex(p_tween:Number):Boolean{
var tTweening:TweenListObj;
var cTime:Number;
tTweening = _tweenList[p_tween];
if ((((tTweening == null)) || (!(tTweening.isPaused)))){
return (false);
};
cTime = getCurrentTweeningTime(tTweening);
tTweening.timeStart = (tTweening.timeStart + (cTime - tTweening.timePaused));
tTweening.timeComplete = (tTweening.timeComplete + (cTime - tTweening.timePaused));
tTweening.timePaused = undefined;
tTweening.isPaused = false;
return (true);
}
public static function getVersion():String{
return ("AS3 1.31.71");
}
public static function onEnterFrame(e:Event):void{
var hasUpdated:Boolean;
updateTime();
updateFrame();
hasUpdated = false;
hasUpdated = updateTweens();
if (!hasUpdated){
stopEngine();
};
}
public static function updateTime():void{
_currentTime = getTimer();
}
private static function updateTweenByIndex(i:Number):Boolean{
var tTweening:TweenListObj;
var isOver:Boolean;
var mustUpdate:Boolean;
var nv:Number;
var t:Number;
var b:Number;
var c:Number;
var d:Number;
var pName:String;
var eventScope:Object;
var tScope:Object;
var cTime:Number;
var tProperty:Object;
var pv:Number;
var i = i;
tTweening = _tweenList[i];
if ((((tTweening == null)) || (!(Boolean(tTweening.scope))))){
return (false);
};
isOver = false;
cTime = getCurrentTweeningTime(tTweening);
if (cTime >= tTweening.timeStart){
tScope = tTweening.scope;
if (tTweening.isCaller){
do {
t = (((tTweening.timeComplete - tTweening.timeStart) / tTweening.count) * (tTweening.timesCalled + 1));
b = tTweening.timeStart;
c = (tTweening.timeComplete - tTweening.timeStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, b, c, d);
//unresolved if
if (Boolean(tTweening.onUpdate)){
eventScope = (Boolean(tTweening.onUpdateScope)) ? tTweening.onUpdateScope : tScope;
tTweening.onUpdate.apply(eventScope, tTweening.onUpdateParams);
continue;
var _slot1 = e;
handleError(tTweening, _slot1, "onUpdate");
};
} while (tTweening.timesCalled++, !(tTweening.timesCalled >= tTweening.count));
} else {
mustUpdate = (((((tTweening.skipUpdates < 1)) || (!(tTweening.skipUpdates)))) || ((tTweening.updatesSkipped >= tTweening.skipUpdates)));
if (cTime >= tTweening.timeComplete){
isOver = true;
mustUpdate = true;
};
if (!tTweening.hasStarted){
if (Boolean(tTweening.onStart)){
eventScope = (Boolean(tTweening.onStartScope)) ? tTweening.onStartScope : tScope;
tTweening.onStart.apply(eventScope, tTweening.onStartParams);
//unresolved jump
var _slot1 = e;
handleError(tTweening, _slot1, "onStart");
};
for (pName in tTweening.properties) {
if (tTweening.properties[pName].isSpecialProperty){
if (Boolean(_specialPropertyList[pName].preProcess)){
tTweening.properties[pName].valueComplete = _specialPropertyList[pName].preProcess(tScope, _specialPropertyList[pName].parameters, tTweening.properties[pName].originalValueComplete, tTweening.properties[pName].extra);
};
pv = _specialPropertyList[pName].getValue(tScope, _specialPropertyList[pName].parameters, tTweening.properties[pName].extra);
} else {
pv = tScope[pName];
};
tTweening.properties[pName].valueStart = (isNaN(pv)) ? tTweening.properties[pName].valueComplete : pv;
};
mustUpdate = true;
tTweening.hasStarted = true;
};
if (mustUpdate){
for (pName in tTweening.properties) {
tProperty = tTweening.properties[pName];
if (isOver){
nv = tProperty.valueComplete;
} else {
if (tProperty.hasModifier){
t = (cTime - tTweening.timeStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, 0, 1, d, tTweening.transitionParams);
nv = tProperty.modifierFunction(tProperty.valueStart, tProperty.valueComplete, nv, tProperty.modifierParameters);
} else {
t = (cTime - tTweening.timeStart);
b = tProperty.valueStart;
c = (tProperty.valueComplete - tProperty.valueStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, b, c, d, tTweening.transitionParams);
};
};
if (tTweening.rounded){
nv = Math.round(nv);
};
if (tProperty.isSpecialProperty){
_specialPropertyList[pName].setValue(tScope, nv, _specialPropertyList[pName].parameters, tTweening.properties[pName].extra);
} else {
tScope[pName] = nv;
};
};
tTweening.updatesSkipped = 0;
if (Boolean(tTweening.onUpdate)){
eventScope = (Boolean(tTweening.onUpdateScope)) ? tTweening.onUpdateScope : tScope;
tTweening.onUpdate.apply(eventScope, tTweening.onUpdateParams);
//unresolved jump
var _slot1 = e;
handleError(tTweening, _slot1, "onUpdate");
};
} else {
tTweening.updatesSkipped++;
};
};
if (((isOver) && (Boolean(tTweening.onComplete)))){
eventScope = (Boolean(tTweening.onCompleteScope)) ? tTweening.onCompleteScope : tScope;
tTweening.onComplete.apply(eventScope, tTweening.onCompleteParams);
//unresolved jump
var _slot1 = e;
handleError(tTweening, _slot1, "onComplete");
};
return (!(isOver));
};
return (true);
}
public static function setTimeScale(p_time:Number):void{
var i:Number;
var cTime:Number;
if (isNaN(p_time)){
p_time = 1;
};
if (p_time < 1E-5){
p_time = 1E-5;
};
if (p_time != _timeScale){
if (_tweenList != null){
i = 0;
while (i < _tweenList.length) {
cTime = getCurrentTweeningTime(_tweenList[i]);
_tweenList[i].timeStart = (cTime - (((cTime - _tweenList[i].timeStart) * _timeScale) / p_time));
_tweenList[i].timeComplete = (cTime - (((cTime - _tweenList[i].timeComplete) * _timeScale) / p_time));
if (_tweenList[i].timePaused != undefined){
_tweenList[i].timePaused = (cTime - (((cTime - _tweenList[i].timePaused) * _timeScale) / p_time));
};
i++;
};
};
_timeScale = p_time;
};
}
public static function resumeAllTweens():Boolean{
var resumed:Boolean;
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
resumed = false;
i = 0;
while (i < _tweenList.length) {
resumeTweenByIndex(i);
resumed = true;
i++;
};
return (resumed);
}
private static function handleError(pTweening:TweenListObj, pError:Error, pCallBackName:String):void{
var eventScope:Object;
var pTweening = pTweening;
var pError = pError;
var pCallBackName = pCallBackName;
if (((Boolean(pTweening.onError)) && ((pTweening.onError is Function)))){
eventScope = (Boolean(pTweening.onErrorScope)) ? pTweening.onErrorScope : pTweening.scope;
pTweening.onError.apply(eventScope, [pTweening.scope, pError]);
//unresolved jump
var _slot1 = metaError;
printError(((((String(pTweening.scope) + " raised an error while executing the 'onError' handler. Original error:\n ") + pError.getStackTrace()) + "\nonError error: ") + _slot1.getStackTrace()));
} else {
if (!Boolean(pTweening.onError)){
printError(((((String(pTweening.scope) + " raised an error while executing the '") + pCallBackName) + "'handler. \n") + pError.getStackTrace()));
};
};
}
private static function startEngine():void{
_engineExists = true;
_tweenList = new Array();
__tweener_controller__ = new MovieClip();
__tweener_controller__.addEventListener(Event.ENTER_FRAME, Tweener.onEnterFrame);
_currentTimeFrame = 0;
updateTime();
}
public static function removeAllTweens():Boolean{
var removed:Boolean;
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
removed = false;
i = 0;
while (i < _tweenList.length) {
removeTweenByIndex(i);
removed = true;
i++;
};
return (removed);
}
public static function addTween(p_scopes:Object=null, p_parameters:Object=null):Boolean{
var i:Number;
var j:Number;
var istr:String;
var rScopes:Array;
var p_obj:Object;
var rTime:Number;
var rDelay:Number;
var rProperties:Array;
var restrictedWords:Object;
var modifiedProperties:Object;
var rTransition:Function;
var nProperties:Object;
var nTween:TweenListObj;
var myT:Number;
var splitProperties:Array;
var splitProperties2:Array;
var tempModifiedProperties:Array;
var trans:String;
if (!Boolean(p_scopes)){
return (false);
};
if ((p_scopes is Array)){
rScopes = p_scopes.concat();
} else {
rScopes = [p_scopes];
};
p_obj = TweenListObj.makePropertiesChain(p_parameters);
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
rTime = (isNaN(p_obj.time)) ? 0 : p_obj.time;
rDelay = (isNaN(p_obj.delay)) ? 0 : p_obj.delay;
rProperties = new Array();
restrictedWords = {time:true, delay:true, useFrames:true, skipUpdates:true, transition:true, transitionParams:true, onStart:true, onUpdate:true, onComplete:true, onOverwrite:true, onError:true, rounded:true, onStartParams:true, onUpdateParams:true, onCompleteParams:true, onOverwriteParams:true, onStartScope:true, onUpdateScope:true, onCompleteScope:true, onOverwriteScope:true, onErrorScope:true};
modifiedProperties = new Object();
for (istr in p_obj) {
if (!restrictedWords[istr]){
if (_specialPropertySplitterList[istr]){
splitProperties = _specialPropertySplitterList[istr].splitValues(p_obj[istr], _specialPropertySplitterList[istr].parameters);
i = 0;
while (i < splitProperties.length) {
if (_specialPropertySplitterList[splitProperties[i].name]){
splitProperties2 = _specialPropertySplitterList[splitProperties[i].name].splitValues(splitProperties[i].value, _specialPropertySplitterList[splitProperties[i].name].parameters);
j = 0;
while (j < splitProperties2.length) {
rProperties[splitProperties2[j].name] = {valueStart:undefined, valueComplete:splitProperties2[j].value, arrayIndex:splitProperties2[j].arrayIndex, isSpecialProperty:false};
j++;
};
} else {
rProperties[splitProperties[i].name] = {valueStart:undefined, valueComplete:splitProperties[i].value, arrayIndex:splitProperties[i].arrayIndex, isSpecialProperty:false};
};
i++;
};
} else {
if (_specialPropertyModifierList[istr] != undefined){
tempModifiedProperties = _specialPropertyModifierList[istr].modifyValues(p_obj[istr]);
i = 0;
while (i < tempModifiedProperties.length) {
modifiedProperties[tempModifiedProperties[i].name] = {modifierParameters:tempModifiedProperties[i].parameters, modifierFunction:_specialPropertyModifierList[istr].getValue};
i++;
};
} else {
rProperties[istr] = {valueStart:undefined, valueComplete:p_obj[istr]};
};
};
};
};
for (istr in rProperties) {
if (_specialPropertyList[istr] != undefined){
rProperties[istr].isSpecialProperty = true;
} else {
if (rScopes[0][istr] == undefined){
printError((((("The property '" + istr) + "' doesn't seem to be a normal object property of ") + String(rScopes[0])) + " or a registered special property."));
};
};
};
for (istr in modifiedProperties) {
if (rProperties[istr] != undefined){
rProperties[istr].modifierParameters = modifiedProperties[istr].modifierParameters;
rProperties[istr].modifierFunction = modifiedProperties[istr].modifierFunction;
};
};
if (typeof(p_obj.transition) == "string"){
trans = p_obj.transition.toLowerCase();
rTransition = _transitionList[trans];
} else {
rTransition = p_obj.transition;
};
if (!Boolean(rTransition)){
rTransition = _transitionList["easeoutexpo"];
};
i = 0;
while (i < rScopes.length) {
nProperties = new Object();
for (istr in rProperties) {
nProperties[istr] = new PropertyInfoObj(rProperties[istr].valueStart, rProperties[istr].valueComplete, rProperties[istr].valueComplete, rProperties[istr].arrayIndex, {}, rProperties[istr].isSpecialProperty, rProperties[istr].modifierFunction, rProperties[istr].modifierParameters);
};
if (p_obj.useFrames == true){
nTween = new TweenListObj(rScopes[i], (_currentTimeFrame + (rDelay / _timeScale)), (_currentTimeFrame + ((rDelay + rTime) / _timeScale)), true, rTransition, p_obj.transitionParams);
} else {
nTween = new TweenListObj(rScopes[i], (_currentTime + ((rDelay * 1000) / _timeScale)), (_currentTime + (((rDelay * 1000) + (rTime * 1000)) / _timeScale)), false, rTransition, p_obj.transitionParams);
};
nTween.properties = nProperties;
nTween.onStart = p_obj.onStart;
nTween.onUpdate = p_obj.onUpdate;
nTween.onComplete = p_obj.onComplete;
nTween.onOverwrite = p_obj.onOverwrite;
nTween.onError = p_obj.onError;
nTween.onStartParams = p_obj.onStartParams;
nTween.onUpdateParams = p_obj.onUpdateParams;
nTween.onCompleteParams = p_obj.onCompleteParams;
nTween.onOverwriteParams = p_obj.onOverwriteParams;
nTween.onStartScope = p_obj.onStartScope;
nTween.onUpdateScope = p_obj.onUpdateScope;
nTween.onCompleteScope = p_obj.onCompleteScope;
nTween.onOverwriteScope = p_obj.onOverwriteScope;
nTween.onErrorScope = p_obj.onErrorScope;
nTween.rounded = p_obj.rounded;
nTween.skipUpdates = p_obj.skipUpdates;
removeTweensByTime(nTween.scope, nTween.properties, nTween.timeStart, nTween.timeComplete);
_tweenList.push(nTween);
if ((((rTime == 0)) && ((rDelay == 0)))){
myT = (_tweenList.length - 1);
updateTweenByIndex(myT);
removeTweenByIndex(myT);
};
i++;
};
return (true);
}
public static function registerTransition(p_name:String, p_function:Function):void{
if (!_inited){
init();
};
_transitionList[p_name] = p_function;
}
public static function printError(p_message:String):void{
trace(("## [Tweener] Error: " + p_message));
}
private static function affectTweens(p_affectFunction:Function, p_scope:Object, p_properties:Array):Boolean{
var affected:Boolean;
var i:uint;
var affectedProperties:Array;
var j:uint;
var objectProperties:uint;
var slicedTweenIndex:uint;
affected = false;
if (!Boolean(_tweenList)){
return (false);
};
i = 0;
while (i < _tweenList.length) {
if (((_tweenList[i]) && ((_tweenList[i].scope == p_scope)))){
if (p_properties.length == 0){
p_affectFunction(i);
affected = true;
} else {
affectedProperties = new Array();
j = 0;
while (j < p_properties.length) {
if (Boolean(_tweenList[i].properties[p_properties[j]])){
affectedProperties.push(p_properties[j]);
};
j++;
};
if (affectedProperties.length > 0){
objectProperties = AuxFunctions.getObjectLength(_tweenList[i].properties);
if (objectProperties == affectedProperties.length){
p_affectFunction(i);
affected = true;
} else {
slicedTweenIndex = splitTweens(i, affectedProperties);
p_affectFunction(slicedTweenIndex);
affected = true;
};
};
};
};
i++;
};
return (affected);
}
public static function getTweens(p_scope:Object):Array{
var i:uint;
var pName:String;
var tList:Array;
if (!Boolean(_tweenList)){
return ([]);
};
tList = new Array();
i = 0;
while (i < _tweenList.length) {
if (((Boolean(_tweenList[i])) && ((_tweenList[i].scope == p_scope)))){
for (pName in _tweenList[i].properties) {
tList.push(pName);
};
};
i++;
};
return (tList);
}
public static function isTweening(p_scope:Object):Boolean{
var i:uint;
if (!Boolean(_tweenList)){
return (false);
};
i = 0;
while (i < _tweenList.length) {
if (((Boolean(_tweenList[i])) && ((_tweenList[i].scope == p_scope)))){
return (true);
};
i++;
};
return (false);
}
public static function pauseTweenByIndex(p_tween:Number):Boolean{
var tTweening:TweenListObj;
tTweening = _tweenList[p_tween];
if ((((tTweening == null)) || (tTweening.isPaused))){
return (false);
};
tTweening.timePaused = getCurrentTweeningTime(tTweening);
tTweening.isPaused = true;
return (true);
}
public static function getCurrentTweeningTime(p_tweening:Object):Number{
return ((p_tweening.useFrames) ? _currentTimeFrame : _currentTime);
}
public static function getTweenCount(p_scope:Object):Number{
var i:uint;
var c:Number;
if (!Boolean(_tweenList)){
return (0);
};
c = 0;
i = 0;
while (i < _tweenList.length) {
if (((Boolean(_tweenList[i])) && ((_tweenList[i].scope == p_scope)))){
c = (c + AuxFunctions.getObjectLength(_tweenList[i].properties));
};
i++;
};
return (c);
}
private static function stopEngine():void{
_engineExists = false;
_tweenList = null;
_currentTime = 0;
_currentTimeFrame = 0;
__tweener_controller__.removeEventListener(Event.ENTER_FRAME, Tweener.onEnterFrame);
__tweener_controller__ = null;
}
public static function removeTweensByTime(p_scope:Object, p_properties:Object, p_timeStart:Number, p_timeComplete:Number):Boolean{
var removed:Boolean;
var removedLocally:Boolean;
var i:uint;
var tl:uint;
var pName:String;
var eventScope:Object;
var p_scope = p_scope;
var p_properties = p_properties;
var p_timeStart = p_timeStart;
var p_timeComplete = p_timeComplete;
removed = false;
tl = _tweenList.length;
i = 0;
while (i < tl) {
if (((Boolean(_tweenList[i])) && ((p_scope == _tweenList[i].scope)))){
if ((((p_timeComplete > _tweenList[i].timeStart)) && ((p_timeStart < _tweenList[i].timeComplete)))){
removedLocally = false;
for (pName in _tweenList[i].properties) {
if (Boolean(p_properties[pName])){
if (Boolean(_tweenList[i].onOverwrite)){
eventScope = (Boolean(_tweenList[i].onOverwriteScope)) ? _tweenList[i].onOverwriteScope : _tweenList[i].scope;
_tweenList[i].onOverwrite.apply(eventScope, _tweenList[i].onOverwriteParams);
//unresolved jump
var _slot1 = e;
handleError(_tweenList[i], _slot1, "onOverwrite");
};
_tweenList[i].properties[pName] = undefined;
delete _tweenList[i].properties[pName];
removedLocally = true;
removed = true;
};
};
if (removedLocally){
if (AuxFunctions.getObjectLength(_tweenList[i].properties) == 0){
removeTweenByIndex(i);
};
};
};
};
i = (i + 1);
};
return (removed);
}
public static function registerSpecialPropertySplitter(p_name:String, p_splitFunction:Function, p_parameters:Array=null):void{
var sps:SpecialPropertySplitter;
if (!_inited){
init();
};
sps = new SpecialPropertySplitter(p_splitFunction, p_parameters);
_specialPropertySplitterList[p_name] = sps;
}
public static function removeTweenByIndex(i:Number, p_finalRemoval:Boolean=false):Boolean{
_tweenList[i] = null;
if (p_finalRemoval){
_tweenList.splice(i, 1);
};
return (true);
}
public static function resumeTweens(p_scope:Object, ... _args):Boolean{
var properties:Array;
var i:uint;
properties = new Array();
i = 0;
while (i < _args.length) {
if ((((typeof(_args[i]) == "string")) && (!(AuxFunctions.isInArray(_args[i], properties))))){
properties.push(_args[i]);
};
i++;
};
return (affectTweens(resumeTweenByIndex, p_scope, properties));
}
public static function pauseTweens(p_scope:Object, ... _args):Boolean{
var properties:Array;
var i:uint;
properties = new Array();
i = 0;
while (i < _args.length) {
if ((((typeof(_args[i]) == "string")) && (!(AuxFunctions.isInArray(_args[i], properties))))){
properties.push(_args[i]);
};
i++;
};
return (affectTweens(pauseTweenByIndex, p_scope, properties));
}
}
}//package caurina.transitions
Section 8
//TweenListObj (caurina.transitions.TweenListObj)
package caurina.transitions {
public class TweenListObj {
public var onUpdate:Function;
public var useFrames:Boolean;
public var hasStarted:Boolean;
public var onOverwriteParams:Array;
public var timeStart:Number;
public var count:Number;
public var timeComplete:Number;
public var onStartParams:Array;
public var onUpdateScope:Object;
public var rounded:Boolean;
public var onUpdateParams:Array;
public var properties:Object;
public var onComplete:Function;
public var transitionParams:Object;
public var updatesSkipped:Number;
public var onStart:Function;
public var onOverwriteScope:Object;
public var skipUpdates:Number;
public var onStartScope:Object;
public var scope:Object;
public var transition:Function;
public var timePaused:Number;
public var onCompleteParams:Array;
public var timesCalled:Number;
public var isCaller:Boolean;
public var onError:Function;
public var onErrorScope:Object;
public var onOverwrite:Function;
public var isPaused:Boolean;
public var waitFrames:Boolean;
public var onCompleteScope:Object;
public function TweenListObj(p_scope:Object, p_timeStart:Number, p_timeComplete:Number, p_useFrames:Boolean, p_transition:Function, p_transitionParams:Object){
super();
scope = p_scope;
timeStart = p_timeStart;
timeComplete = p_timeComplete;
useFrames = p_useFrames;
transition = p_transition;
transitionParams = p_transitionParams;
properties = new Object();
isPaused = false;
timePaused = undefined;
isCaller = false;
updatesSkipped = 0;
timesCalled = 0;
skipUpdates = 0;
hasStarted = false;
}
public function clone(omitEvents:Boolean):TweenListObj{
var nTween:TweenListObj;
var pName:String;
nTween = new TweenListObj(scope, timeStart, timeComplete, useFrames, transition, transitionParams);
nTween.properties = new Array();
for (pName in properties) {
nTween.properties[pName] = properties[pName].clone();
};
nTween.skipUpdates = skipUpdates;
nTween.updatesSkipped = updatesSkipped;
if (!omitEvents){
nTween.onStart = onStart;
nTween.onUpdate = onUpdate;
nTween.onComplete = onComplete;
nTween.onOverwrite = onOverwrite;
nTween.onError = onError;
nTween.onStartParams = onStartParams;
nTween.onUpdateParams = onUpdateParams;
nTween.onCompleteParams = onCompleteParams;
nTween.onOverwriteParams = onOverwriteParams;
nTween.onStartScope = onStartScope;
nTween.onUpdateScope = onUpdateScope;
nTween.onCompleteScope = onCompleteScope;
nTween.onOverwriteScope = onOverwriteScope;
nTween.onErrorScope = onErrorScope;
};
nTween.rounded = rounded;
nTween.isPaused = isPaused;
nTween.timePaused = timePaused;
nTween.isCaller = isCaller;
nTween.count = count;
nTween.timesCalled = timesCalled;
nTween.waitFrames = waitFrames;
nTween.hasStarted = hasStarted;
return (nTween);
}
public function toString():String{
var returnStr:String;
var isFirst:Boolean;
var i:String;
returnStr = "\n[TweenListObj ";
returnStr = (returnStr + ("scope:" + String(scope)));
returnStr = (returnStr + ", properties:");
isFirst = true;
for (i in properties) {
if (!isFirst){
returnStr = (returnStr + ",");
};
returnStr = (returnStr + ("[name:" + properties[i].name));
returnStr = (returnStr + (",valueStart:" + properties[i].valueStart));
returnStr = (returnStr + (",valueComplete:" + properties[i].valueComplete));
returnStr = (returnStr + "]");
isFirst = false;
};
returnStr = (returnStr + (", timeStart:" + String(timeStart)));
returnStr = (returnStr + (", timeComplete:" + String(timeComplete)));
returnStr = (returnStr + (", useFrames:" + String(useFrames)));
returnStr = (returnStr + (", transition:" + String(transition)));
returnStr = (returnStr + (", transitionParams:" + String(transitionParams)));
if (skipUpdates){
returnStr = (returnStr + (", skipUpdates:" + String(skipUpdates)));
};
if (updatesSkipped){
returnStr = (returnStr + (", updatesSkipped:" + String(updatesSkipped)));
};
if (Boolean(onStart)){
returnStr = (returnStr + (", onStart:" + String(onStart)));
};
if (Boolean(onUpdate)){
returnStr = (returnStr + (", onUpdate:" + String(onUpdate)));
};
if (Boolean(onComplete)){
returnStr = (returnStr + (", onComplete:" + String(onComplete)));
};
if (Boolean(onOverwrite)){
returnStr = (returnStr + (", onOverwrite:" + String(onOverwrite)));
};
if (Boolean(onError)){
returnStr = (returnStr + (", onError:" + String(onError)));
};
if (onStartParams){
returnStr = (returnStr + (", onStartParams:" + String(onStartParams)));
};
if (onUpdateParams){
returnStr = (returnStr + (", onUpdateParams:" + String(onUpdateParams)));
};
if (onCompleteParams){
returnStr = (returnStr + (", onCompleteParams:" + String(onCompleteParams)));
};
if (onOverwriteParams){
returnStr = (returnStr + (", onOverwriteParams:" + String(onOverwriteParams)));
};
if (onStartScope){
returnStr = (returnStr + (", onStartScope:" + String(onStartScope)));
};
if (onUpdateScope){
returnStr = (returnStr + (", onUpdateScope:" + String(onUpdateScope)));
};
if (onCompleteScope){
returnStr = (returnStr + (", onCompleteScope:" + String(onCompleteScope)));
};
if (onOverwriteScope){
returnStr = (returnStr + (", onOverwriteScope:" + String(onOverwriteScope)));
};
if (onErrorScope){
returnStr = (returnStr + (", onErrorScope:" + String(onErrorScope)));
};
if (rounded){
returnStr = (returnStr + (", rounded:" + String(rounded)));
};
if (isPaused){
returnStr = (returnStr + (", isPaused:" + String(isPaused)));
};
if (timePaused){
returnStr = (returnStr + (", timePaused:" + String(timePaused)));
};
if (isCaller){
returnStr = (returnStr + (", isCaller:" + String(isCaller)));
};
if (count){
returnStr = (returnStr + (", count:" + String(count)));
};
if (timesCalled){
returnStr = (returnStr + (", timesCalled:" + String(timesCalled)));
};
if (waitFrames){
returnStr = (returnStr + (", waitFrames:" + String(waitFrames)));
};
if (hasStarted){
returnStr = (returnStr + (", hasStarted:" + String(hasStarted)));
};
returnStr = (returnStr + "]\n");
return (returnStr);
}
public static function makePropertiesChain(p_obj:Object):Object{
var baseObject:Object;
var chainedObject:Object;
var chain:Object;
var currChainObj:Object;
var len:Number;
var i:Number;
var k:Number;
baseObject = p_obj.base;
if (baseObject){
chainedObject = {};
if ((baseObject is Array)){
chain = [];
k = 0;
while (k < baseObject.length) {
chain.push(baseObject[k]);
k++;
};
} else {
chain = [baseObject];
};
chain.push(p_obj);
len = chain.length;
i = 0;
while (i < len) {
if (chain[i]["base"]){
currChainObj = AuxFunctions.concatObjects(makePropertiesChain(chain[i]["base"]), chain[i]);
} else {
currChainObj = chain[i];
};
chainedObject = AuxFunctions.concatObjects(chainedObject, currChainObj);
i++;
};
if (chainedObject["base"]){
delete chainedObject["base"];
};
return (chainedObject);
//unresolved jump
};
return (p_obj);
}
}
}//package caurina.transitions
Section 9
//BaseButton (fl.controls.BaseButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.utils.*;
import fl.events.*;
public class BaseButton extends UIComponent {
protected var _selected:Boolean;// = false
private var unlockedMouseState:String;
protected var pressTimer:Timer;
protected var mouseState:String;
protected var background:DisplayObject;
private var _mouseStateLocked:Boolean;// = false
protected var _autoRepeat:Boolean;// = false
private static var defaultStyles:Object = {upSkin:"Button_upSkin", downSkin:"Button_downSkin", overSkin:"Button_overSkin", disabledSkin:"Button_disabledSkin", selectedDisabledSkin:"Button_selectedDisabledSkin", selectedUpSkin:"Button_selectedUpSkin", selectedDownSkin:"Button_selectedDownSkin", selectedOverSkin:"Button_selectedOverSkin", focusRectSkin:null, focusRectPadding:null, repeatDelay:500, repeatInterval:35};
public function BaseButton(){
_selected = false;
_autoRepeat = false;
_mouseStateLocked = false;
super();
buttonMode = true;
mouseChildren = false;
useHandCursor = false;
setupMouseEvents();
setMouseState("up");
pressTimer = new Timer(1, 0);
pressTimer.addEventListener(TimerEvent.TIMER, buttonDown, false, 0, true);
}
protected function endPress():void{
pressTimer.reset();
}
public function set mouseStateLocked(_arg1:Boolean):void{
_mouseStateLocked = _arg1;
if (_arg1 == false){
setMouseState(unlockedMouseState);
} else {
unlockedMouseState = mouseState;
};
}
public function get autoRepeat():Boolean{
return (_autoRepeat);
}
public function set autoRepeat(_arg1:Boolean):void{
_autoRepeat = _arg1;
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
mouseEnabled = _arg1;
}
public function get selected():Boolean{
return (_selected);
}
protected function mouseEventHandler(_arg1:MouseEvent):void{
if (_arg1.type == MouseEvent.MOUSE_DOWN){
setMouseState("down");
startPress();
} else {
if ((((_arg1.type == MouseEvent.ROLL_OVER)) || ((_arg1.type == MouseEvent.MOUSE_UP)))){
setMouseState("over");
endPress();
} else {
if (_arg1.type == MouseEvent.ROLL_OUT){
setMouseState("up");
endPress();
};
};
};
}
public function setMouseState(_arg1:String):void{
if (_mouseStateLocked){
unlockedMouseState = _arg1;
return;
};
if (mouseState == _arg1){
return;
};
mouseState = _arg1;
invalidate(InvalidationType.STATE);
}
protected function startPress():void{
if (_autoRepeat){
pressTimer.delay = Number(getStyleValue("repeatDelay"));
pressTimer.start();
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
protected function buttonDown(_arg1:TimerEvent):void{
if (!_autoRepeat){
endPress();
return;
};
if (pressTimer.currentCount == 1){
pressTimer.delay = Number(getStyleValue("repeatInterval"));
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
public function set selected(_arg1:Boolean):void{
if (_selected == _arg1){
return;
};
_selected = _arg1;
invalidate(InvalidationType.STATE);
}
override public function get enabled():Boolean{
return (super.enabled);
}
override protected function draw():void{
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
super.draw();
}
protected function setupMouseEvents():void{
addEventListener(MouseEvent.ROLL_OVER, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_DOWN, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_UP, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.ROLL_OUT, mouseEventHandler, false, 0, true);
}
protected function drawLayout():void{
background.width = width;
background.height = height;
}
protected function drawBackground():void{
var _local1:String;
var _local2:DisplayObject;
_local1 = (enabled) ? mouseState : "disabled";
if (selected){
_local1 = (("selected" + _local1.substr(0, 1).toUpperCase()) + _local1.substr(1));
};
_local1 = (_local1 + "Skin");
_local2 = background;
background = getDisplayObjectInstance(getStyleValue(_local1));
addChildAt(background, 0);
if (((!((_local2 == null))) && (!((_local2 == background))))){
removeChild(_local2);
};
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 10
//Button (fl.controls.Button)
package fl.controls {
import flash.display.*;
import fl.core.*;
import fl.managers.*;
public class Button extends LabelButton implements IFocusManagerComponent {
protected var emphasizedBorder:DisplayObject;
protected var _emphasized:Boolean;// = false
private static var defaultStyles:Object = {emphasizedSkin:"Button_emphasizedSkin", emphasizedPadding:2};
public static var createAccessibilityImplementation:Function;
public function Button(){
_emphasized = false;
super();
}
override public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
var _local3:*;
super.drawFocus(_arg1);
if (_arg1){
_local2 = Number(getStyleValue("emphasizedPadding"));
if ((((_local2 < 0)) || (!(_emphasized)))){
_local2 = 0;
};
_local3 = getStyleValue("focusRectPadding");
_local3 = ((_local3)==null) ? 2 : _local3;
_local3 = (_local3 + _local2);
uiFocusRect.x = -(_local3);
uiFocusRect.y = -(_local3);
uiFocusRect.width = (width + (_local3 * 2));
uiFocusRect.height = (height + (_local3 * 2));
};
}
public function set emphasized(_arg1:Boolean):void{
_emphasized = _arg1;
invalidate(InvalidationType.STYLES);
}
override protected function draw():void{
if (((isInvalid(InvalidationType.STYLES)) || (isInvalid(InvalidationType.SIZE)))){
drawEmphasized();
};
super.draw();
if (emphasizedBorder != null){
setChildIndex(emphasizedBorder, (numChildren - 1));
};
}
public function get emphasized():Boolean{
return (_emphasized);
}
override protected function initializeAccessibility():void{
if (Button.createAccessibilityImplementation != null){
Button.createAccessibilityImplementation(this);
};
}
protected function drawEmphasized():void{
var _local1:Object;
var _local2:Number;
if (emphasizedBorder != null){
removeChild(emphasizedBorder);
};
emphasizedBorder = null;
if (!_emphasized){
return;
};
_local1 = getStyleValue("emphasizedSkin");
if (_local1 != null){
emphasizedBorder = getDisplayObjectInstance(_local1);
};
if (emphasizedBorder != null){
addChildAt(emphasizedBorder, 0);
_local2 = Number(getStyleValue("emphasizedPadding"));
emphasizedBorder.x = (emphasizedBorder.y = -(_local2));
emphasizedBorder.width = (width + (_local2 * 2));
emphasizedBorder.height = (height + (_local2 * 2));
};
}
public static function getStyleDefinition():Object{
return (UIComponent.mergeStyles(LabelButton.getStyleDefinition(), defaultStyles));
}
}
}//package fl.controls
Section 11
//ButtonLabelPlacement (fl.controls.ButtonLabelPlacement)
package fl.controls {
public class ButtonLabelPlacement {
public static const TOP:String = "top";
public static const LEFT:String = "left";
public static const BOTTOM:String = "bottom";
public static const RIGHT:String = "right";
}
}//package fl.controls
Section 12
//LabelButton (fl.controls.LabelButton)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import fl.managers.*;
import flash.text.*;
import fl.events.*;
import flash.ui.*;
public class LabelButton extends BaseButton implements IFocusManagerComponent {
protected var _labelPlacement:String;// = "right"
protected var _toggle:Boolean;// = false
protected var icon:DisplayObject;
protected var oldMouseState:String;
protected var mode:String;// = "center"
public var textField:TextField;
protected var _label:String;// = "Label"
private static var defaultStyles:Object = {icon:null, upIcon:null, downIcon:null, overIcon:null, disabledIcon:null, selectedDisabledIcon:null, selectedUpIcon:null, selectedDownIcon:null, selectedOverIcon:null, textFormat:null, disabledTextFormat:null, textPadding:5, embedFonts:false};
public static var createAccessibilityImplementation:Function;
public function LabelButton(){
_labelPlacement = ButtonLabelPlacement.RIGHT;
_toggle = false;
_label = "Label";
mode = "center";
super();
}
protected function toggleSelected(_arg1:MouseEvent):void{
selected = !(selected);
dispatchEvent(new Event(Event.CHANGE, true));
}
public function get labelPlacement():String{
return (_labelPlacement);
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
if (oldMouseState == null){
oldMouseState = mouseState;
};
setMouseState("down");
startPress();
};
}
protected function setEmbedFont(){
var _local1:Object;
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
}
override protected function keyUpHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
setMouseState(oldMouseState);
oldMouseState = null;
endPress();
dispatchEvent(new MouseEvent(MouseEvent.CLICK));
};
}
override public function get selected():Boolean{
return ((_toggle) ? _selected : false);
}
public function set labelPlacement(_arg1:String):void{
_labelPlacement = _arg1;
invalidate(InvalidationType.SIZE);
}
public function set toggle(_arg1:Boolean):void{
if (((!(_arg1)) && (super.selected))){
selected = false;
};
_toggle = _arg1;
if (_toggle){
addEventListener(MouseEvent.CLICK, toggleSelected, false, 0, true);
} else {
removeEventListener(MouseEvent.CLICK, toggleSelected);
};
invalidate(InvalidationType.STATE);
}
public function get label():String{
return (_label);
}
override public function set selected(_arg1:Boolean):void{
_selected = _arg1;
if (_toggle){
invalidate(InvalidationType.STATE);
};
}
override protected function draw():void{
if (textField.text != _label){
label = _label;
};
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
drawIcon();
drawTextFormat();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
public function get toggle():Boolean{
return (_toggle);
}
override protected function configUI():void{
super.configUI();
textField = new TextField();
textField.type = TextFieldType.DYNAMIC;
textField.selectable = false;
addChild(textField);
}
override protected function drawLayout():void{
var _local1:Number;
var _local2:String;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local1 = Number(getStyleValue("textPadding"));
_local2 = ((((icon == null)) && ((mode == "center")))) ? ButtonLabelPlacement.TOP : _labelPlacement;
textField.height = (textField.textHeight + 4);
_local3 = (textField.textWidth + 4);
_local4 = (textField.textHeight + 4);
_local5 = ((icon)==null) ? 0 : (icon.width + _local1);
_local6 = ((icon)==null) ? 0 : (icon.height + _local1);
textField.visible = (label.length > 0);
if (icon != null){
icon.x = Math.round(((width - icon.width) / 2));
icon.y = Math.round(((height - icon.height) / 2));
};
if (textField.visible == false){
textField.width = 0;
textField.height = 0;
} else {
if ((((_local2 == ButtonLabelPlacement.BOTTOM)) || ((_local2 == ButtonLabelPlacement.TOP)))){
_local7 = Math.max(0, Math.min(_local3, (width - (2 * _local1))));
if ((height - 2) > _local4){
_local8 = _local4;
} else {
_local8 = (height - 2);
};
_local3 = _local7;
textField.width = _local3;
_local4 = _local8;
textField.height = _local4;
textField.x = Math.round(((width - _local3) / 2));
textField.y = Math.round(((((height - textField.height) - _local6) / 2) + ((_local2)==ButtonLabelPlacement.BOTTOM) ? _local6 : 0));
if (icon != null){
icon.y = Math.round(((_local2)==ButtonLabelPlacement.BOTTOM) ? (textField.y - _local6) : ((textField.y + textField.height) + _local1));
};
} else {
_local7 = Math.max(0, Math.min(_local3, ((width - _local5) - (2 * _local1))));
_local3 = _local7;
textField.width = _local3;
textField.x = Math.round(((((width - _local3) - _local5) / 2) + ((_local2)!=ButtonLabelPlacement.LEFT) ? _local5 : 0));
textField.y = Math.round(((height - textField.height) / 2));
if (icon != null){
icon.x = Math.round(((_local2)!=ButtonLabelPlacement.LEFT) ? (textField.x - _local5) : ((textField.x + _local3) + _local1));
};
};
};
super.drawLayout();
}
override protected function initializeAccessibility():void{
if (LabelButton.createAccessibilityImplementation != null){
LabelButton.createAccessibilityImplementation(this);
};
}
protected function drawIcon():void{
var _local1:DisplayObject;
var _local2:String;
var _local3:Object;
_local1 = icon;
_local2 = (enabled) ? mouseState : "disabled";
if (selected){
_local2 = (("selected" + _local2.substr(0, 1).toUpperCase()) + _local2.substr(1));
};
_local2 = (_local2 + "Icon");
_local3 = getStyleValue(_local2);
if (_local3 == null){
_local3 = getStyleValue("icon");
};
if (_local3 != null){
icon = getDisplayObjectInstance(_local3);
};
if (icon != null){
addChildAt(icon, 1);
};
if (((!((_local1 == null))) && (!((_local1 == icon))))){
removeChild(_local1);
};
}
public function set label(_arg1:String):void{
_label = _arg1;
if (textField.text != _label){
textField.text = _label;
dispatchEvent(new ComponentEvent(ComponentEvent.LABEL_CHANGE));
};
invalidate(InvalidationType.SIZE);
invalidate(InvalidationType.STYLES);
}
protected function drawTextFormat():void{
var _local1:Object;
var _local2:TextFormat;
var _local3:TextFormat;
_local1 = UIComponent.getStyleDefinition();
_local2 = (enabled) ? (_local1.defaultTextFormat as TextFormat) : (_local1.defaultDisabledTextFormat as TextFormat);
textField.setTextFormat(_local2);
_local3 = (getStyleValue((enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (_local3 != null){
textField.setTextFormat(_local3);
} else {
_local3 = _local2;
};
textField.defaultTextFormat = _local3;
setEmbedFont();
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, BaseButton.getStyleDefinition()));
}
}
}//package fl.controls
Section 13
//TextInput (fl.controls.TextInput)
package fl.controls {
import flash.display.*;
import fl.core.*;
import flash.events.*;
import fl.managers.*;
import flash.text.*;
import fl.events.*;
import flash.ui.*;
public class TextInput extends UIComponent implements IFocusManagerComponent {
protected var _html:Boolean;// = false
protected var _savedHTML:String;
protected var background:DisplayObject;
protected var _editable:Boolean;// = true
public var textField:TextField;
private static var defaultStyles:Object = {upSkin:"TextInput_upSkin", disabledSkin:"TextInput_disabledSkin", focusRectSkin:null, focusRectPadding:null, textFormat:null, disabledTextFormat:null, textPadding:0, embedFonts:false};
public static var createAccessibilityImplementation:Function;
public function TextInput(){
_editable = true;
_html = false;
super();
}
override public function drawFocus(_arg1:Boolean):void{
if (focusTarget != null){
focusTarget.drawFocus(_arg1);
return;
};
super.drawFocus(_arg1);
}
public function set imeMode(_arg1:String):void{
_imeMode = _arg1;
}
override protected function isOurFocus(_arg1:DisplayObject):Boolean{
return ((((_arg1 == textField)) || (super.isOurFocus(_arg1))));
}
protected function handleKeyDown(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.ENTER){
dispatchEvent(new ComponentEvent(ComponentEvent.ENTER, true));
};
}
public function set text(_arg1:String):void{
textField.text = _arg1;
_html = false;
invalidate(InvalidationType.DATA);
invalidate(InvalidationType.STYLES);
}
protected function updateTextFieldType():void{
textField.type = (((enabled) && (editable))) ? TextFieldType.INPUT : TextFieldType.DYNAMIC;
textField.selectable = enabled;
}
public function get selectionEndIndex():int{
return (textField.selectionEndIndex);
}
public function get editable():Boolean{
return (_editable);
}
override protected function focusInHandler(_arg1:FocusEvent):void{
var _local2:IFocusManager;
if (_arg1.target == this){
stage.focus = textField;
};
_local2 = focusManager;
if (((editable) && (_local2))){
_local2.showFocusIndicator = true;
if (((textField.selectable) && ((textField.selectionBeginIndex == textField.selectionBeginIndex)))){
setSelection(0, textField.length);
};
};
super.focusInHandler(_arg1);
if (editable){
setIMEMode(true);
};
}
public function get selectionBeginIndex():int{
return (textField.selectionBeginIndex);
}
public function set alwaysShowSelection(_arg1:Boolean):void{
textField.alwaysShowSelection = _arg1;
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
updateTextFieldType();
}
protected function setEmbedFont(){
var _local1:Object;
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
}
public function get horizontalScrollPosition():int{
return (textField.scrollH);
}
public function set condenseWhite(_arg1:Boolean):void{
textField.condenseWhite = _arg1;
}
public function set displayAsPassword(_arg1:Boolean):void{
textField.displayAsPassword = _arg1;
}
public function set horizontalScrollPosition(_arg1:int):void{
textField.scrollH = _arg1;
}
public function get restrict():String{
return (textField.restrict);
}
public function get textWidth():Number{
return (textField.textWidth);
}
public function get textHeight():Number{
return (textField.textHeight);
}
public function set editable(_arg1:Boolean):void{
_editable = _arg1;
updateTextFieldType();
}
public function get maxChars():int{
return (textField.maxChars);
}
public function get length():int{
return (textField.length);
}
public function getLineMetrics(_arg1:int):TextLineMetrics{
return (textField.getLineMetrics(_arg1));
}
public function get imeMode():String{
return (_imeMode);
}
override protected function focusOutHandler(_arg1:FocusEvent):void{
super.focusOutHandler(_arg1);
if (editable){
setIMEMode(false);
};
}
public function set htmlText(_arg1:String):void{
if (_arg1 == ""){
text = "";
return;
};
_html = true;
_savedHTML = _arg1;
textField.htmlText = _arg1;
invalidate(InvalidationType.DATA);
invalidate(InvalidationType.STYLES);
}
public function get text():String{
return (textField.text);
}
override public function get enabled():Boolean{
return (super.enabled);
}
public function get condenseWhite():Boolean{
return (textField.condenseWhite);
}
public function get alwaysShowSelection():Boolean{
return (textField.alwaysShowSelection);
}
override protected function draw():void{
var _local1:Object;
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawTextFormat();
drawBackground();
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
super.draw();
}
protected function handleTextInput(_arg1:TextEvent):void{
_arg1.stopPropagation();
dispatchEvent(new TextEvent(TextEvent.TEXT_INPUT, true, false, _arg1.text));
}
override protected function configUI():void{
super.configUI();
tabChildren = true;
textField = new TextField();
addChild(textField);
updateTextFieldType();
textField.addEventListener(TextEvent.TEXT_INPUT, handleTextInput, false, 0, true);
textField.addEventListener(Event.CHANGE, handleChange, false, 0, true);
textField.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown, false, 0, true);
}
public function setSelection(_arg1:int, _arg2:int):void{
textField.setSelection(_arg1, _arg2);
}
public function get displayAsPassword():Boolean{
return (textField.displayAsPassword);
}
public function appendText(_arg1:String):void{
textField.appendText(_arg1);
}
public function set restrict(_arg1:String):void{
if (((componentInspectorSetting) && ((_arg1 == "")))){
_arg1 = null;
};
textField.restrict = _arg1;
}
public function get htmlText():String{
return (textField.htmlText);
}
protected function drawBackground():void{
var _local1:DisplayObject;
var _local2:String;
_local1 = background;
_local2 = (enabled) ? "upSkin" : "disabledSkin";
background = getDisplayObjectInstance(getStyleValue(_local2));
if (background == null){
return;
};
addChildAt(background, 0);
if (((((!((_local1 == null))) && (!((_local1 == background))))) && (contains(_local1)))){
removeChild(_local1);
};
}
override public function setFocus():void{
stage.focus = textField;
}
protected function drawLayout():void{
var _local1:Number;
_local1 = Number(getStyleValue("textPadding"));
if (background != null){
background.width = width;
background.height = height;
};
textField.width = (width - (2 * _local1));
textField.height = (height - (2 * _local1));
textField.x = (textField.y = _local1);
}
public function set maxChars(_arg1:int):void{
textField.maxChars = _arg1;
}
public function get maxHorizontalScrollPosition():int{
return (textField.maxScrollH);
}
protected function drawTextFormat():void{
var _local1:Object;
var _local2:TextFormat;
var _local3:TextFormat;
_local1 = UIComponent.getStyleDefinition();
_local2 = (enabled) ? (_local1.defaultTextFormat as TextFormat) : (_local1.defaultDisabledTextFormat as TextFormat);
textField.setTextFormat(_local2);
_local3 = (getStyleValue((enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (_local3 != null){
textField.setTextFormat(_local3);
} else {
_local3 = _local2;
};
textField.defaultTextFormat = _local3;
setEmbedFont();
if (_html){
textField.htmlText = _savedHTML;
};
}
protected function handleChange(_arg1:Event):void{
_arg1.stopPropagation();
dispatchEvent(new Event(Event.CHANGE, true));
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 14
//ComponentShim (fl.core.ComponentShim)
package fl.core {
import flash.display.*;
public dynamic class ComponentShim extends MovieClip {
}
}//package fl.core
Section 15
//InvalidationType (fl.core.InvalidationType)
package fl.core {
public class InvalidationType {
public static const SIZE:String = "size";
public static const ALL:String = "all";
public static const DATA:String = "data";
public static const SCROLL:String = "scroll";
public static const STATE:String = "state";
public static const STYLES:String = "styles";
public static const SELECTED:String = "selected";
public static const RENDERER_STYLES:String = "rendererStyles";
}
}//package fl.core
Section 16
//UIComponent (fl.core.UIComponent)
package fl.core {
import flash.display.*;
import flash.events.*;
import fl.managers.*;
import flash.text.*;
import flash.utils.*;
import fl.events.*;
import flash.system.*;
public class UIComponent extends Sprite {
protected var _enabled:Boolean;// = true
private var _mouseFocusEnabled:Boolean;// = true
protected var startHeight:Number;
protected var _height:Number;
protected var _oldIMEMode:String;// = null
protected var startWidth:Number;
public var focusTarget:IFocusManagerComponent;
protected var errorCaught:Boolean;// = false
protected var uiFocusRect:DisplayObject;
protected var _width:Number;
public var version:String;// = "3.0.0.15"
protected var isFocused:Boolean;// = false
protected var callLaterMethods:Dictionary;
private var _focusEnabled:Boolean;// = true
private var tempText:TextField;
protected var invalidateFlag:Boolean;// = false
protected var _inspector:Boolean;// = false
protected var sharedStyles:Object;
protected var invalidHash:Object;
protected var isLivePreview:Boolean;// = false
protected var _imeMode:String;// = null
protected var instanceStyles:Object;
protected var _x:Number;
protected var _y:Number;
public static var inCallLaterPhase:Boolean = false;
private static var defaultStyles:Object = {focusRectSkin:"focusRectSkin", focusRectPadding:2, textFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), disabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultTextFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultDisabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0)};
public static var createAccessibilityImplementation:Function;
private static var focusManagers:Dictionary = new Dictionary(false);
public function UIComponent(){
version = "3.0.0.15";
isLivePreview = false;
invalidateFlag = false;
_enabled = true;
isFocused = false;
_focusEnabled = true;
_mouseFocusEnabled = true;
_imeMode = null;
_oldIMEMode = null;
errorCaught = false;
_inspector = false;
super();
instanceStyles = {};
sharedStyles = {};
invalidHash = {};
callLaterMethods = new Dictionary();
StyleManager.registerInstance(this);
configUI();
invalidate(InvalidationType.ALL);
tabEnabled = (this is IFocusManagerComponent);
focusRect = false;
if (tabEnabled){
addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
};
initializeFocusManager();
addEventListener(Event.ENTER_FRAME, hookAccessibility, false, 0, true);
}
public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
isFocused = _arg1;
if (((!((uiFocusRect == null))) && (contains(uiFocusRect)))){
removeChild(uiFocusRect);
uiFocusRect = null;
};
if (_arg1){
uiFocusRect = (getDisplayObjectInstance(getStyleValue("focusRectSkin")) as Sprite);
if (uiFocusRect == null){
return;
};
_local2 = Number(getStyleValue("focusRectPadding"));
uiFocusRect.x = -(_local2);
uiFocusRect.y = -(_local2);
uiFocusRect.width = (width + (_local2 * 2));
uiFocusRect.height = (height + (_local2 * 2));
addChildAt(uiFocusRect, 0);
};
}
private function callLaterDispatcher(_arg1:Event):void{
var _local2:Dictionary;
var _local3:Object;
if (_arg1.type == Event.ADDED_TO_STAGE){
removeEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher);
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
return;
};
_arg1.target.removeEventListener(Event.RENDER, callLaterDispatcher);
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
return;
};
inCallLaterPhase = true;
_local2 = callLaterMethods;
for (_local3 in _local2) {
_local3();
delete _local2[_local3];
};
inCallLaterPhase = false;
}
private function addedHandler(_arg1:Event):void{
removeEventListener("addedToStage", addedHandler);
initializeFocusManager();
}
protected function getStyleValue(_arg1:String):Object{
return (((instanceStyles[_arg1])==null) ? sharedStyles[_arg1] : instanceStyles[_arg1]);
}
protected function isOurFocus(_arg1:DisplayObject):Boolean{
return ((_arg1 == this));
}
override public function get scaleX():Number{
return ((width / startWidth));
}
override public function get scaleY():Number{
return ((height / startHeight));
}
override public function set height(_arg1:Number):void{
if (_height == _arg1){
return;
};
setSize(width, _arg1);
}
protected function keyDownHandler(_arg1:KeyboardEvent):void{
}
protected function focusInHandler(_arg1:FocusEvent):void{
var _local2:IFocusManager;
if (isOurFocus((_arg1.target as DisplayObject))){
_local2 = focusManager;
if (((_local2) && (_local2.showFocusIndicator))){
drawFocus(true);
isFocused = true;
};
};
}
public function setStyle(_arg1:String, _arg2:Object):void{
if ((((instanceStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
instanceStyles[_arg1] = _arg2;
invalidate(InvalidationType.STYLES);
}
override public function get visible():Boolean{
return (super.visible);
}
public function get componentInspectorSetting():Boolean{
return (_inspector);
}
override public function get x():Number{
return ((isNaN(_x)) ? super.x : _x);
}
override public function get y():Number{
return ((isNaN(_y)) ? super.y : _y);
}
protected function setIMEMode(_arg1:Boolean){
var enabled = _arg1;
if (_imeMode != null){
if (enabled){
IME.enabled = true;
_oldIMEMode = IME.conversionMode;
try {
if (((!(errorCaught)) && (!((IME.conversionMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _imeMode;
};
errorCaught = false;
} catch(e:Error) {
errorCaught = true;
throw (new Error(("IME mode not supported: " + _imeMode)));
};
} else {
if (((!((IME.conversionMode == IMEConversionMode.UNKNOWN))) && (!((_oldIMEMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _oldIMEMode;
};
IME.enabled = false;
};
};
}
public function set enabled(_arg1:Boolean):void{
if (_arg1 == _enabled){
return;
};
_enabled = _arg1;
invalidate(InvalidationType.STATE);
}
public function setSharedStyle(_arg1:String, _arg2:Object):void{
if ((((sharedStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
sharedStyles[_arg1] = _arg2;
if (instanceStyles[_arg1] == null){
invalidate(InvalidationType.STYLES);
};
}
protected function keyUpHandler(_arg1:KeyboardEvent):void{
}
public function set focusEnabled(_arg1:Boolean):void{
_focusEnabled = _arg1;
}
override public function set scaleX(_arg1:Number):void{
setSize((startWidth * _arg1), height);
}
public function get mouseFocusEnabled():Boolean{
return (_mouseFocusEnabled);
}
override public function set scaleY(_arg1:Number):void{
setSize(width, (startHeight * _arg1));
}
protected function getDisplayObjectInstance(_arg1:Object):DisplayObject{
var classDef:Object;
var skin = _arg1;
classDef = null;
if ((skin is Class)){
return ((new (skin) as DisplayObject));
};
if ((skin is DisplayObject)){
(skin as DisplayObject).x = 0;
(skin as DisplayObject).y = 0;
return ((skin as DisplayObject));
};
try {
classDef = getDefinitionByName(skin.toString());
} catch(e:Error) {
try {
classDef = (loaderInfo.applicationDomain.getDefinition(skin.toString()) as Object);
} catch(e:Error) {
};
};
if (classDef == null){
return (null);
};
return ((new (classDef) as DisplayObject));
}
protected function copyStylesToChild(_arg1:UIComponent, _arg2:Object):void{
var _local3:String;
for (_local3 in _arg2) {
_arg1.setStyle(_local3, getStyleValue(_arg2[_local3]));
};
}
protected function beforeComponentParameters():void{
}
protected function callLater(_arg1:Function):void{
if (inCallLaterPhase){
return;
};
callLaterMethods[_arg1] = true;
if (stage != null){
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
} else {
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
};
}
protected function createFocusManager():void{
if (focusManagers[stage] == null){
focusManagers[stage] = new FocusManager(stage);
};
}
override public function set visible(_arg1:Boolean):void{
var _local2:String;
if (super.visible == _arg1){
return;
};
super.visible = _arg1;
_local2 = (_arg1) ? ComponentEvent.SHOW : ComponentEvent.HIDE;
dispatchEvent(new ComponentEvent(_local2, true));
}
protected function hookAccessibility(_arg1:Event):void{
removeEventListener(Event.ENTER_FRAME, hookAccessibility);
initializeAccessibility();
}
public function set componentInspectorSetting(_arg1:Boolean):void{
_inspector = _arg1;
if (_inspector){
beforeComponentParameters();
} else {
afterComponentParameters();
};
}
override public function set x(_arg1:Number):void{
move(_arg1, _y);
}
public function drawNow():void{
draw();
}
override public function set y(_arg1:Number):void{
move(_x, _arg1);
}
protected function checkLivePreview():Boolean{
var className:String;
if (parent == null){
return (false);
};
try {
className = getQualifiedClassName(parent);
} catch(e:Error) {
};
return ((className == "fl.livepreview::LivePreviewParent"));
}
protected function focusOutHandler(_arg1:FocusEvent):void{
if (isOurFocus((_arg1.target as DisplayObject))){
drawFocus(false);
isFocused = false;
};
}
public function set mouseFocusEnabled(_arg1:Boolean):void{
_mouseFocusEnabled = _arg1;
}
public function getFocus():InteractiveObject{
if (stage){
return (stage.focus);
};
return (null);
}
protected function validate():void{
invalidHash = {};
}
override public function get height():Number{
return (_height);
}
public function invalidate(_arg1:String="all", _arg2:Boolean=true):void{
invalidHash[_arg1] = true;
if (_arg2){
this.callLater(draw);
};
}
public function get enabled():Boolean{
return (_enabled);
}
protected function getScaleX():Number{
return (super.scaleX);
}
protected function getScaleY():Number{
return (super.scaleY);
}
public function get focusEnabled():Boolean{
return (_focusEnabled);
}
protected function afterComponentParameters():void{
}
protected function draw():void{
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
protected function configUI():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
isLivePreview = checkLivePreview();
_local1 = rotation;
rotation = 0;
_local2 = super.width;
_local3 = super.height;
var _local4 = 1;
super.scaleY = _local4;
super.scaleX = _local4;
setSize(_local2, _local3);
move(super.x, super.y);
rotation = _local1;
startWidth = _local2;
startHeight = _local3;
if (numChildren > 0){
removeChildAt(0);
};
}
protected function setScaleX(_arg1:Number):void{
super.scaleX = _arg1;
}
protected function setScaleY(_arg1:Number):void{
super.scaleY = _arg1;
}
private function initializeFocusManager():void{
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, addedHandler, false, 0, true);
} else {
createFocusManager();
};
}
public function set focusManager(_arg1:IFocusManager):void{
UIComponent.focusManagers[this] = _arg1;
}
public function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
protected function isInvalid(_arg1:String, ... _args):Boolean{
if (((invalidHash[_arg1]) || (invalidHash[InvalidationType.ALL]))){
return (true);
};
while (_args.length > 0) {
if (invalidHash[_args.pop()]){
return (true);
};
};
return (false);
}
public function setSize(_arg1:Number, _arg2:Number):void{
_width = _arg1;
_height = _arg2;
invalidate(InvalidationType.SIZE);
dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, false));
}
override public function set width(_arg1:Number):void{
if (_width == _arg1){
return;
};
setSize(_arg1, height);
}
public function setFocus():void{
if (stage){
stage.focus = this;
};
}
protected function initializeAccessibility():void{
if (UIComponent.createAccessibilityImplementation != null){
UIComponent.createAccessibilityImplementation(this);
};
}
public function get focusManager():IFocusManager{
var _local1:DisplayObject;
_local1 = this;
while (_local1) {
if (UIComponent.focusManagers[_local1] != null){
return (IFocusManager(UIComponent.focusManagers[_local1]));
};
_local1 = _local1.parent;
};
return (null);
}
override public function get width():Number{
return (_width);
}
public function move(_arg1:Number, _arg2:Number):void{
_x = _arg1;
_y = _arg2;
super.x = Math.round(_arg1);
super.y = Math.round(_arg2);
dispatchEvent(new ComponentEvent(ComponentEvent.MOVE));
}
public function validateNow():void{
invalidate(InvalidationType.ALL, false);
draw();
}
public function getStyle(_arg1:String):Object{
return (instanceStyles[_arg1]);
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
public static function mergeStyles(... _args):Object{
var _local2:Object;
var _local3:uint;
var _local4:uint;
var _local5:Object;
var _local6:String;
_local2 = {};
_local3 = _args.length;
_local4 = 0;
while (_local4 < _local3) {
_local5 = _args[_local4];
for (_local6 in _local5) {
if (_local2[_local6] != null){
} else {
_local2[_local6] = _args[_local4][_local6];
};
};
_local4++;
};
return (_local2);
}
}
}//package fl.core
Section 17
//ComponentEvent (fl.events.ComponentEvent)
package fl.events {
import flash.events.*;
public class ComponentEvent extends Event {
public static const HIDE:String = "hide";
public static const BUTTON_DOWN:String = "buttonDown";
public static const MOVE:String = "move";
public static const RESIZE:String = "resize";
public static const ENTER:String = "enter";
public static const LABEL_CHANGE:String = "labelChange";
public static const SHOW:String = "show";
public function ComponentEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
override public function toString():String{
return (formatToString("ComponentEvent", "type", "bubbles", "cancelable"));
}
override public function clone():Event{
return (new ComponentEvent(type, bubbles, cancelable));
}
}
}//package fl.events
Section 18
//FocusManager (fl.managers.FocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
import fl.core.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.ui.*;
public class FocusManager implements IFocusManager {
private var focusableObjects:Dictionary;
private var _showFocusIndicator:Boolean;// = true
private var defButton:Button;
private var focusableCandidates:Array;
private var _form:DisplayObjectContainer;
private var _defaultButtonEnabled:Boolean;// = true
private var activated:Boolean;// = false
private var _defaultButton:Button;
private var calculateCandidates:Boolean;// = true
private var lastFocus:InteractiveObject;
private var lastAction:String;
public function FocusManager(_arg1:DisplayObjectContainer){
activated = false;
calculateCandidates = true;
_showFocusIndicator = true;
_defaultButtonEnabled = true;
super();
focusableObjects = new Dictionary(true);
if (_arg1 != null){
_form = _arg1;
addFocusables(DisplayObject(_arg1));
_arg1.addEventListener(Event.ADDED, addedHandler);
_arg1.addEventListener(Event.REMOVED, removedHandler);
activate();
};
}
public function get showFocusIndicator():Boolean{
return (_showFocusIndicator);
}
private function getIndexOfNextObject(_arg1:int, _arg2:Boolean, _arg3:Boolean, _arg4:String):int{
var _local5:int;
var _local6:int;
var _local7:DisplayObject;
var _local8:IFocusManagerGroup;
var _local9:int;
var _local10:DisplayObject;
var _local11:IFocusManagerGroup;
_local5 = focusableCandidates.length;
_local6 = _arg1;
while (true) {
if (_arg2){
_arg1--;
} else {
_arg1++;
};
if (_arg3){
if (((_arg2) && ((_arg1 < 0)))){
break;
};
if (((!(_arg2)) && ((_arg1 == _local5)))){
break;
};
} else {
_arg1 = ((_arg1 + _local5) % _local5);
if (_local6 == _arg1){
break;
};
};
if (isValidFocusCandidate(focusableCandidates[_arg1], _arg4)){
_local7 = DisplayObject(findFocusManagerComponent(focusableCandidates[_arg1]));
if ((_local7 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local7);
_local9 = 0;
while (_local9 < focusableCandidates.length) {
_local10 = focusableCandidates[_local9];
if ((_local10 is IFocusManagerGroup)){
_local11 = IFocusManagerGroup(_local10);
if ((((_local11.groupName == _local8.groupName)) && (_local11.selected))){
_arg1 = _local9;
break;
};
};
_local9++;
};
};
return (_arg1);
};
};
return (_arg1);
}
public function set form(_arg1:DisplayObjectContainer):void{
_form = _arg1;
}
private function addFocusables(_arg1:DisplayObject, _arg2:Boolean=false):void{
var focusable:IFocusManagerComponent;
var io:InteractiveObject;
var doc:DisplayObjectContainer;
var i:int;
var child:DisplayObject;
var o = _arg1;
var skipTopLevel = _arg2;
if (!skipTopLevel){
if ((o is IFocusManagerComponent)){
focusable = IFocusManagerComponent(o);
if (focusable.focusEnabled){
if (((focusable.tabEnabled) && (isTabVisible(o)))){
focusableObjects[o] = true;
calculateCandidates = true;
};
o.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
o.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
};
} else {
if ((o is InteractiveObject)){
io = (o as InteractiveObject);
if (((((io) && (io.tabEnabled))) && ((findFocusManagerComponent(io) == io)))){
focusableObjects[io] = true;
calculateCandidates = true;
};
io.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
io.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
};
};
};
if ((o is DisplayObjectContainer)){
doc = DisplayObjectContainer(o);
o.addEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
if ((((((doc is Stage)) || ((doc.parent is Stage)))) || (doc.tabChildren))){
i = 0;
while (i < doc.numChildren) {
try {
child = doc.getChildAt(i);
if (child != null){
addFocusables(doc.getChildAt(i));
};
} catch(error:SecurityError) {
};
i = (i + 1);
};
};
};
}
private function getChildIndex(_arg1:DisplayObjectContainer, _arg2:DisplayObject):int{
return (_arg1.getChildIndex(_arg2));
}
private function mouseFocusChangeHandler(_arg1:FocusEvent):void{
if ((_arg1.relatedObject is TextField)){
return;
};
_arg1.preventDefault();
}
private function focusOutHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
_local2 = (_arg1.target as InteractiveObject);
}
private function isValidFocusCandidate(_arg1:DisplayObject, _arg2:String):Boolean{
var _local3:IFocusManagerGroup;
if (!isEnabledAndVisible(_arg1)){
return (false);
};
if ((_arg1 is IFocusManagerGroup)){
_local3 = IFocusManagerGroup(_arg1);
if (_arg2 == _local3.groupName){
return (false);
};
};
return (true);
}
public function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject{
var _local2:InteractiveObject;
_local2 = _arg1;
while (_arg1) {
if ((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
};
return (_local2);
}
private function sortFocusableObjectsTabIndex():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))){
focusableCandidates.push(_local2);
};
};
focusableCandidates.sort(sortByTabIndex);
}
private function removeFocusables(_arg1:DisplayObject):void{
var _local2:Object;
var _local3:DisplayObject;
if ((_arg1 is DisplayObjectContainer)){
_arg1.removeEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
_arg1.removeEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
for (_local2 in focusableObjects) {
_local3 = DisplayObject(_local2);
if (DisplayObjectContainer(_arg1).contains(_local3)){
if (_local3 == lastFocus){
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local2];
calculateCandidates = true;
};
};
};
}
private function addedHandler(_arg1:Event):void{
var _local2:DisplayObject;
_local2 = DisplayObject(_arg1.target);
if (_local2.stage){
addFocusables(DisplayObject(_arg1.target));
};
}
private function getTopLevelFocusTarget(_arg1:InteractiveObject):InteractiveObject{
while (_arg1 != InteractiveObject(form)) {
if ((((((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))) && (IFocusManagerComponent(_arg1).mouseFocusEnabled))) && (UIComponent(_arg1).enabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
if (_arg1 == null){
break;
};
};
return (null);
}
private function tabChildrenChangeHandler(_arg1:Event):void{
var _local2:DisplayObjectContainer;
if (_arg1.target != _arg1.currentTarget){
return;
};
calculateCandidates = true;
_local2 = DisplayObjectContainer(_arg1.target);
if (_local2.tabChildren){
addFocusables(_local2, true);
} else {
removeFocusables(_local2);
};
}
public function sendDefaultButtonEvent():void{
defButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
public function getFocus():InteractiveObject{
var _local1:InteractiveObject;
_local1 = form.stage.focus;
return (findFocusManagerComponent(_local1));
}
private function isEnabledAndVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
var _local3:TextField;
var _local4:SimpleButton;
_local2 = DisplayObject(form).parent;
while (_arg1 != _local2) {
if ((_arg1 is UIComponent)){
if (!UIComponent(_arg1).enabled){
return (false);
};
} else {
if ((_arg1 is TextField)){
_local3 = TextField(_arg1);
if ((((_local3.type == TextFieldType.DYNAMIC)) || (!(_local3.selectable)))){
return (false);
};
} else {
if ((_arg1 is SimpleButton)){
_local4 = SimpleButton(_arg1);
if (!_local4.enabled){
return (false);
};
};
};
};
if (!_arg1.visible){
return (false);
};
_arg1 = _arg1.parent;
};
return (true);
}
public function set defaultButton(_arg1:Button):void{
var _local2:Button;
_local2 = (_arg1) ? Button(_arg1) : null;
if (_local2 != _defaultButton){
if (_defaultButton){
_defaultButton.emphasized = false;
};
if (defButton){
defButton.emphasized = false;
};
_defaultButton = _local2;
defButton = _local2;
if (_local2){
_local2.emphasized = true;
};
};
}
private function deactivateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
}
public function setFocus(_arg1:InteractiveObject):void{
if ((_arg1 is IFocusManagerComponent)){
IFocusManagerComponent(_arg1).setFocus();
} else {
form.stage.focus = _arg1;
};
}
private function setFocusToNextObject(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
if (!hasFocusableObjects()){
return;
};
_local2 = getNextFocusManagerComponent(_arg1.shiftKey);
if (_local2){
setFocus(_local2);
};
}
private function hasFocusableObjects():Boolean{
var _local1:Object;
for (_local1 in focusableObjects) {
return (true);
};
return (false);
}
private function tabIndexChangeHandler(_arg1:Event):void{
calculateCandidates = true;
}
private function sortFocusableObjects():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))) && ((_local2.tabIndex > 0)))){
sortFocusableObjectsTabIndex();
return;
};
focusableCandidates.push(_local2);
};
focusableCandidates.sort(sortByDepth);
}
private function keyFocusChangeHandler(_arg1:FocusEvent):void{
showFocusIndicator = true;
if ((((((_arg1.keyCode == Keyboard.TAB)) || ((_arg1.keyCode == 0)))) && (!(_arg1.isDefaultPrevented())))){
setFocusToNextObject(_arg1);
_arg1.preventDefault();
};
}
private function getIndexOfFocusedObject(_arg1:DisplayObject):int{
var _local2:int;
var _local3:int;
_local2 = focusableCandidates.length;
_local3 = 0;
_local3 = 0;
while (_local3 < _local2) {
if (focusableCandidates[_local3] == _arg1){
return (_local3);
};
_local3++;
};
return (-1);
}
public function hideFocus():void{
}
private function removedHandler(_arg1:Event):void{
var _local2:int;
var _local3:DisplayObject;
var _local4:InteractiveObject;
_local3 = DisplayObject(_arg1.target);
if ((((_local3 is IFocusManagerComponent)) && ((focusableObjects[_local3] == true)))){
if (_local3 == lastFocus){
IFocusManagerComponent(lastFocus).drawFocus(false);
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local3];
calculateCandidates = true;
} else {
if ((((_local3 is InteractiveObject)) && ((focusableObjects[_local3] == true)))){
_local4 = (_local3 as InteractiveObject);
if (_local4){
if (_local4 == lastFocus){
lastFocus = null;
};
delete focusableObjects[_local4];
calculateCandidates = true;
};
_local3.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
};
};
removeFocusables(_local3);
}
private function sortByDepth(_arg1:InteractiveObject, _arg2:InteractiveObject):Number{
var _local3:String;
var _local4:String;
var _local5:int;
var _local6:String;
var _local7:String;
var _local8:String;
var _local9:DisplayObject;
var _local10:DisplayObject;
_local3 = "";
_local4 = "";
_local8 = "0000";
_local9 = DisplayObject(_arg1);
_local10 = DisplayObject(_arg2);
while (((!((_local9 == DisplayObject(form)))) && (_local9.parent))) {
_local5 = getChildIndex(_local9.parent, _local9);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local3 = (_local7 + _local3);
_local9 = _local9.parent;
};
while (((!((_local10 == DisplayObject(form)))) && (_local10.parent))) {
_local5 = getChildIndex(_local10.parent, _local10);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local4 = (_local7 + _local4);
_local10 = _local10.parent;
};
return (((_local3 > _local4)) ? 1 : ((_local3 < _local4)) ? -1 : 0);
}
public function get defaultButton():Button{
return (_defaultButton);
}
private function activateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
if (lastFocus){
if ((lastFocus is IFocusManagerComponent)){
IFocusManagerComponent(lastFocus).setFocus();
} else {
form.stage.focus = lastFocus;
};
};
lastAction = "ACTIVATE";
}
public function showFocus():void{
}
public function set defaultButtonEnabled(_arg1:Boolean):void{
_defaultButtonEnabled = _arg1;
}
public function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject{
var _local2:DisplayObject;
var _local3:String;
var _local4:int;
var _local5:Boolean;
var _local6:int;
var _local7:int;
var _local8:IFocusManagerGroup;
if (!hasFocusableObjects()){
return (null);
};
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
_local2 = form.stage.focus;
_local2 = DisplayObject(findFocusManagerComponent(InteractiveObject(_local2)));
_local3 = "";
if ((_local2 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local2);
_local3 = _local8.groupName;
};
_local4 = getIndexOfFocusedObject(_local2);
_local5 = false;
_local6 = _local4;
if (_local4 == -1){
if (_arg1){
_local4 = focusableCandidates.length;
};
_local5 = true;
};
_local7 = getIndexOfNextObject(_local4, _arg1, _local5, _local3);
return (findFocusManagerComponent(focusableCandidates[_local7]));
}
private function mouseDownHandler(_arg1:MouseEvent):void{
var _local2:InteractiveObject;
if (_arg1.isDefaultPrevented()){
return;
};
_local2 = getTopLevelFocusTarget(InteractiveObject(_arg1.target));
if (!_local2){
return;
};
showFocusIndicator = false;
if (((((!((_local2 == lastFocus))) || ((lastAction == "ACTIVATE")))) && (!((_local2 is TextField))))){
setFocus(_local2);
};
lastAction = "MOUSEDOWN";
}
private function isTabVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
_local2 = _arg1.parent;
while (((((_local2) && (!((_local2 is Stage))))) && (!(((_local2.parent) && ((_local2.parent is Stage))))))) {
if (!_local2.tabChildren){
return (false);
};
_local2 = _local2.parent;
};
return (true);
}
public function get nextTabIndex():int{
return (0);
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.TAB){
lastAction = "KEY";
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
};
if (((((((defaultButtonEnabled) && ((_arg1.keyCode == Keyboard.ENTER)))) && (defaultButton))) && (defButton.enabled))){
sendDefaultButtonEvent();
};
}
private function focusInHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
var _local3:Button;
_local2 = InteractiveObject(_arg1.target);
if (form.contains(_local2)){
lastFocus = findFocusManagerComponent(InteractiveObject(_local2));
if ((lastFocus is Button)){
_local3 = Button(lastFocus);
if (defButton){
defButton.emphasized = false;
defButton = _local3;
_local3.emphasized = true;
};
} else {
if (((defButton) && (!((defButton == _defaultButton))))){
defButton.emphasized = false;
defButton = _defaultButton;
_defaultButton.emphasized = true;
};
};
};
}
private function tabEnabledChangeHandler(_arg1:Event):void{
var _local2:InteractiveObject;
var _local3:Boolean;
calculateCandidates = true;
_local2 = InteractiveObject(_arg1.target);
_local3 = (focusableObjects[_local2] == true);
if (_local2.tabEnabled){
if (((!(_local3)) && (isTabVisible(_local2)))){
if (!(_local2 is IFocusManagerComponent)){
_local2.focusRect = false;
};
focusableObjects[_local2] = true;
};
} else {
if (_local3){
delete focusableObjects[_local2];
};
};
}
public function set showFocusIndicator(_arg1:Boolean):void{
_showFocusIndicator = _arg1;
}
public function get form():DisplayObjectContainer{
return (_form);
}
private function sortByTabIndex(_arg1:InteractiveObject, _arg2:InteractiveObject):int{
return (((_arg1.tabIndex > _arg2.tabIndex)) ? 1 : ((_arg1.tabIndex < _arg2.tabIndex)) ? -1 : sortByDepth(_arg1, _arg2));
}
public function activate():void{
if (activated){
return;
};
form.stage.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler, false, 0, true);
form.stage.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler, false, 0, true);
form.addEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.addEventListener(Event.ACTIVATE, activateHandler, false, 0, true);
form.stage.addEventListener(Event.DEACTIVATE, deactivateHandler, false, 0, true);
form.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = true;
if (lastFocus){
setFocus(lastFocus);
};
}
public function deactivate():void{
form.stage.removeEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler);
form.stage.removeEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler);
form.removeEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.removeEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.removeEventListener(Event.ACTIVATE, activateHandler);
form.stage.removeEventListener(Event.DEACTIVATE, deactivateHandler);
form.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = false;
}
public function get defaultButtonEnabled():Boolean{
return (_defaultButtonEnabled);
}
}
}//package fl.managers
Section 19
//IFocusManager (fl.managers.IFocusManager)
package fl.managers {
import fl.controls.*;
import flash.display.*;
public interface IFocusManager {
function getFocus():InteractiveObject;
function deactivate():void;
function set defaultButton(_arg1:Button):void;
function set showFocusIndicator(_arg1:Boolean):void;
function get defaultButtonEnabled():Boolean;
function get nextTabIndex():int;
function get defaultButton():Button;
function get showFocusIndicator():Boolean;
function setFocus(_arg1:InteractiveObject):void;
function activate():void;
function showFocus():void;
function set defaultButtonEnabled(_arg1:Boolean):void;
function hideFocus():void;
function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject;
function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject;
}
}//package fl.managers
Section 20
//IFocusManagerComponent (fl.managers.IFocusManagerComponent)
package fl.managers {
public interface IFocusManagerComponent {
function set focusEnabled(_arg1:Boolean):void;
function drawFocus(_arg1:Boolean):void;
function setFocus():void;
function get focusEnabled():Boolean;
function get tabEnabled():Boolean;
function get tabIndex():int;
function get mouseFocusEnabled():Boolean;
}
}//package fl.managers
Section 21
//IFocusManagerGroup (fl.managers.IFocusManagerGroup)
package fl.managers {
public interface IFocusManagerGroup {
function set groupName(_arg1:String):void;
function set selected(_arg1:Boolean):void;
function get groupName():String;
function get selected():Boolean;
}
}//package fl.managers
Section 22
//StyleManager (fl.managers.StyleManager)
package fl.managers {
import fl.core.*;
import flash.text.*;
import flash.utils.*;
public class StyleManager {
private var globalStyles:Object;
private var classToDefaultStylesDict:Dictionary;
private var styleToClassesHash:Object;
private var classToStylesDict:Dictionary;
private var classToInstancesDict:Dictionary;
private static var _instance:StyleManager;
public function StyleManager(){
styleToClassesHash = {};
classToInstancesDict = new Dictionary(true);
classToStylesDict = new Dictionary(true);
classToDefaultStylesDict = new Dictionary(true);
globalStyles = UIComponent.getStyleDefinition();
}
public static function clearComponentStyle(_arg1:Object, _arg2:String):void{
var _local3:Class;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
if (((!((_local4 == null))) && (!((_local4[_arg2] == null))))){
delete _local4[_arg2];
invalidateComponentStyle(_local3, _arg2);
};
}
private static function getClassDef(_arg1:Object):Class{
var component = _arg1;
if ((component is Class)){
return ((component as Class));
};
try {
return ((getDefinitionByName(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
if ((component is UIComponent)){
try {
return ((component.loaderInfo.applicationDomain.getDefinition(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
};
};
};
return (null);
}
public static function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
public static function setComponentStyle(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Class;
var _local5:Object;
_local4 = getClassDef(_arg1);
_local5 = getInstance().classToStylesDict[_local4];
if (_local5 == null){
_local5 = (getInstance().classToStylesDict[_local4] = {});
};
if (_local5 == _arg3){
return;
};
_local5[_arg2] = _arg3;
invalidateComponentStyle(_local4, _arg2);
}
private static function setSharedStyles(_arg1:UIComponent):void{
var _local2:StyleManager;
var _local3:Class;
var _local4:Object;
var _local5:String;
_local2 = getInstance();
_local3 = getClassDef(_arg1);
_local4 = _local2.classToDefaultStylesDict[_local3];
for (_local5 in _local4) {
_arg1.setSharedStyle(_local5, getSharedStyle(_arg1, _local5));
};
}
public static function getComponentStyle(_arg1:Object, _arg2:String):Object{
var _local3:Class;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
return (((_local4)==null) ? null : _local4[_arg2]);
}
private static function getInstance(){
if (_instance == null){
_instance = new (StyleManager);
};
return (_instance);
}
private static function invalidateComponentStyle(_arg1:Class, _arg2:String):void{
var _local3:Dictionary;
var _local4:Object;
var _local5:UIComponent;
_local3 = getInstance().classToInstancesDict[_arg1];
if (_local3 == null){
return;
};
for (_local4 in _local3) {
_local5 = (_local4 as UIComponent);
if (_local5 == null){
} else {
_local5.setSharedStyle(_arg2, getSharedStyle(_local5, _arg2));
};
};
}
private static function invalidateStyle(_arg1:String):void{
var _local2:Dictionary;
var _local3:Object;
_local2 = getInstance().styleToClassesHash[_arg1];
if (_local2 == null){
return;
};
for (_local3 in _local2) {
invalidateComponentStyle(Class(_local3), _arg1);
};
}
public static function registerInstance(_arg1:UIComponent):void{
var inst:StyleManager;
var classDef:Class;
var target:Class;
var defaultStyles:Object;
var styleToClasses:Object;
var n:String;
var instance = _arg1;
inst = getInstance();
classDef = getClassDef(instance);
if (classDef == null){
return;
};
if (inst.classToInstancesDict[classDef] == null){
inst.classToInstancesDict[classDef] = new Dictionary(true);
target = classDef;
while (defaultStyles == null) {
if (target["getStyleDefinition"] != null){
defaultStyles = target["getStyleDefinition"]();
break;
};
try {
target = (instance.loaderInfo.applicationDomain.getDefinition(getQualifiedSuperclassName(target)) as Class);
} catch(err:Error) {
try {
target = (getDefinitionByName(getQualifiedSuperclassName(target)) as Class);
} catch(e:Error) {
defaultStyles = UIComponent.getStyleDefinition();
break;
};
};
};
styleToClasses = inst.styleToClassesHash;
for (n in defaultStyles) {
if (styleToClasses[n] == null){
styleToClasses[n] = new Dictionary(true);
};
styleToClasses[n][classDef] = true;
};
inst.classToDefaultStylesDict[classDef] = defaultStyles;
inst.classToStylesDict[classDef] = {};
};
inst.classToInstancesDict[classDef][instance] = true;
setSharedStyles(instance);
}
public static function getStyle(_arg1:String):Object{
return (getInstance().globalStyles[_arg1]);
}
private static function getSharedStyle(_arg1:UIComponent, _arg2:String):Object{
var _local3:Class;
var _local4:StyleManager;
var _local5:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance();
_local5 = _local4.classToStylesDict[_local3][_arg2];
if (_local5 != null){
return (_local5);
};
_local5 = _local4.globalStyles[_arg2];
if (_local5 != null){
return (_local5);
};
return (_local4.classToDefaultStylesDict[_local3][_arg2]);
}
public static function setStyle(_arg1:String, _arg2:Object):void{
var _local3:Object;
_local3 = getInstance().globalStyles;
if ((((_local3[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
_local3[_arg1] = _arg2;
invalidateStyle(_arg1);
}
}
}//package fl.managers
Section 23
//Bounce (fl.transitions.easing.Bounce)
package fl.transitions.easing {
public class Bounce {
public function Bounce(){
super();
}
public static function easeOut(t:Number, b:Number, c:Number, d:Number):Number{
t = (t / d);
if (t < (1 / 2.75)){
return (((c * ((7.5625 * t) * t)) + b));
};
if (t < (2 / 2.75)){
t = (t - (1.5 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.75)) + b));
};
if (t < (2.5 / 2.75)){
t = (t - (2.25 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.9375)) + b));
};
t = (t - (2.625 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.984375)) + b));
}
public static function easeIn(t:Number, b:Number, c:Number, d:Number):Number{
return (((c - easeOut((d - t), 0, c, d)) + b));
}
public static function easeInOut(t:Number, b:Number, c:Number, d:Number):Number{
if (t < (d / 2)){
return (((easeIn((t * 2), 0, c, d) * 0.5) + b));
};
return ((((easeOut(((t * 2) - d), 0, c, d) * 0.5) + (c * 0.5)) + b));
}
}
}//package fl.transitions.easing
Section 24
//Tween (fl.transitions.Tween)
package fl.transitions {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
public class Tween extends EventDispatcher {
private var _position:Number;// = NAN
public var prevTime:Number;// = NAN
public var prevPos:Number;// = NAN
public var isPlaying:Boolean;// = false
public var begin:Number;// = NAN
private var _fps:Number;// = NAN
private var _time:Number;// = NAN
public var change:Number;// = NAN
private var _finish:Number;// = NAN
public var looping:Boolean;// = false
private var _intervalID:uint;// = 0
public var func:Function;
private var _timer:Timer;// = null
private var _startTime:Number;// = NAN
public var prop:String;// = ""
private var _duration:Number;// = NAN
public var obj:Object;// = null
public var useSeconds:Boolean;// = false
protected static var _mc:MovieClip = new MovieClip();
public function Tween(obj:Object, prop:String, func:Function, begin:Number, finish:Number, duration:Number, useSeconds:Boolean=false){
isPlaying = false;
obj = null;
prop = "";
func = function (t:Number, b:Number, c:Number, d:Number):Number{
return ((((c * t) / d) + b));
};
begin = NaN;
change = NaN;
useSeconds = false;
prevTime = NaN;
prevPos = NaN;
looping = false;
_duration = NaN;
_time = NaN;
_fps = NaN;
_position = NaN;
_startTime = NaN;
_intervalID = 0;
_finish = NaN;
_timer = null;
super();
if (!arguments.length){
return;
};
this.obj = obj;
this.prop = prop;
this.begin = begin;
this.position = begin;
this.duration = duration;
this.useSeconds = useSeconds;
if ((func is Function)){
this.func = func;
};
this.finish = finish;
this._timer = new Timer(100);
this.start();
}
public function continueTo(finish:Number, duration:Number):void{
this.begin = this.position;
this.finish = finish;
if (!isNaN(duration)){
this.duration = duration;
};
this.start();
}
public function stop():void{
this.stopEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_STOP, this._time, this._position));
}
private function fixTime():void{
if (this.useSeconds){
this._startTime = (getTimer() - (this._time * 1000));
};
}
public function set FPS(fps:Number):void{
var oldIsPlaying:Boolean;
oldIsPlaying = this.isPlaying;
this.stopEnterFrame();
this._fps = fps;
if (oldIsPlaying){
this.startEnterFrame();
};
}
public function get finish():Number{
return ((this.begin + this.change));
}
public function get duration():Number{
return (this._duration);
}
protected function startEnterFrame():void{
var milliseconds:Number;
if (isNaN(this._fps)){
_mc.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, false, 0, true);
} else {
milliseconds = (1000 / this._fps);
this._timer.delay = milliseconds;
this._timer.addEventListener(TimerEvent.TIMER, this.timerHandler, false, 0, true);
this._timer.start();
};
this.isPlaying = true;
}
public function set time(t:Number):void{
this.prevTime = this._time;
if (t > this.duration){
if (this.looping){
this.rewind((t - this._duration));
this.update();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_LOOP, this._time, this._position));
} else {
if (this.useSeconds){
this._time = this._duration;
this.update();
};
this.stop();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_FINISH, this._time, this._position));
};
} else {
if (t < 0){
this.rewind();
this.update();
} else {
this._time = t;
this.update();
};
};
}
protected function stopEnterFrame():void{
if (isNaN(this._fps)){
_mc.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
} else {
this._timer.stop();
};
this.isPlaying = false;
}
public function getPosition(t:Number=NaN):Number{
if (isNaN(t)){
t = this._time;
};
return (this.func(t, this.begin, this.change, this._duration));
}
public function set finish(value:Number):void{
this.change = (value - this.begin);
}
public function set duration(d:Number):void{
this._duration = ((d)<=0) ? Infinity : d;
}
public function setPosition(p:Number):void{
this.prevPos = this._position;
if (this.prop.length){
this.obj[this.prop] = (this._position = p);
};
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_CHANGE, this._time, this._position));
}
public function resume():void{
this.fixTime();
this.startEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_RESUME, this._time, this._position));
}
public function fforward():void{
this.time = this._duration;
this.fixTime();
}
protected function onEnterFrame(event:Event):void{
this.nextFrame();
}
public function get position():Number{
return (this.getPosition(this._time));
}
public function yoyo():void{
this.continueTo(this.begin, this.time);
}
public function nextFrame():void{
if (this.useSeconds){
this.time = ((getTimer() - this._startTime) / 1000);
} else {
this.time = (this._time + 1);
};
}
protected function timerHandler(timerEvent:TimerEvent):void{
this.nextFrame();
timerEvent.updateAfterEvent();
}
public function get FPS():Number{
return (this._fps);
}
public function rewind(t:Number=0):void{
this._time = t;
this.fixTime();
this.update();
}
public function set position(p:Number):void{
this.setPosition(p);
}
public function get time():Number{
return (this._time);
}
private function update():void{
this.setPosition(this.getPosition(this._time));
}
public function start():void{
this.rewind();
this.startEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_START, this._time, this._position));
}
public function prevFrame():void{
if (!this.useSeconds){
this.time = (this._time - 1);
};
}
}
}//package fl.transitions
Section 25
//TweenEvent (fl.transitions.TweenEvent)
package fl.transitions {
import flash.events.*;
public class TweenEvent extends Event {
public var time:Number;// = NAN
public var position:Number;// = NAN
public static const MOTION_START:String = "motionStart";
public static const MOTION_STOP:String = "motionStop";
public static const MOTION_LOOP:String = "motionLoop";
public static const MOTION_CHANGE:String = "motionChange";
public static const MOTION_FINISH:String = "motionFinish";
public static const MOTION_RESUME:String = "motionResume";
public function TweenEvent(type:String, time:Number, position:Number, bubbles:Boolean=false, cancelable:Boolean=false){
time = NaN;
position = NaN;
super(type, bubbles, cancelable);
this.time = time;
this.position = position;
}
override public function clone():Event{
return (new TweenEvent(this.type, this.time, this.position, this.bubbles, this.cancelable));
}
}
}//package fl.transitions
Section 26
//AbstractCollection (org.cove.ape.AbstractCollection)
package org.cove.ape {
import flash.display.*;
import flash.utils.*;
public class AbstractCollection {
private var _sprite:Sprite;
private var _isParented:Boolean;
private var _particles:Array;
private var _constraints:Array;
public function AbstractCollection(){
super();
if (getQualifiedClassName(this) == "org.cove.ape::AbstractCollection"){
throw (new ArgumentError("AbstractCollection can't be instantiated directly"));
};
_isParented = false;
_particles = new Array();
_constraints = new Array();
}
public function getAll():Array{
return (particles.concat(constraints));
}
function checkCollisionsVsCollection(ac:AbstractCollection):void{
var plen:int;
var j:int;
var clen:int;
var pga:AbstractParticle;
var acplen:int;
var x:int;
var acclen:int;
var pgb:AbstractParticle;
var cgb:SpringConstraint;
var cga:SpringConstraint;
var n:int;
plen = _particles.length;
j = 0;
while (j < plen) {
pga = _particles[j];
if ((((pga == null)) || (!(pga.collidable)))){
} else {
acplen = ac.particles.length;
x = 0;
while (x < acplen) {
pgb = ac.particles[x];
if (((!((pgb == null))) && (pgb.collidable))){
CollisionDetector.test(pga, pgb);
};
x++;
};
acclen = ac.constraints.length;
x = 0;
while (x < acclen) {
cgb = ac.constraints[x];
if (((((!((cgb == null))) && (cgb.collidable))) && (!(cgb.isConnectedTo(pga))))){
cgb.scp.updatePosition();
CollisionDetector.test(pga, cgb.scp);
};
x++;
};
};
j++;
};
clen = _constraints.length;
j = 0;
while (j < clen) {
cga = _constraints[j];
if ((((cga == null)) || (!(cga.collidable)))){
} else {
acplen = ac.particles.length;
n = 0;
while (n < acplen) {
pgb = ac.particles[n];
if (((((!((pgb == null))) && (pgb.collidable))) && (!(cga.isConnectedTo(pgb))))){
cga.scp.updatePosition();
CollisionDetector.test(pgb, cga.scp);
};
n++;
};
};
j++;
};
}
public function get sprite():Sprite{
if (_sprite != null){
return (_sprite);
};
if (APEngine.container == null){
throw (new Error("The container property of the APEngine class has not been set"));
};
_sprite = new Sprite();
APEngine.container.addChild(_sprite);
return (_sprite);
}
function checkInternalCollisions():void{
var plen:int;
var j:int;
var pa:AbstractParticle;
var i:int;
var clen:int;
var n:int;
var pb:AbstractParticle;
var c:SpringConstraint;
plen = _particles.length;
j = 0;
while (j < plen) {
pa = _particles[j];
if ((((pa == null)) || (!(pa.collidable)))){
} else {
i = (j + 1);
while (i < plen) {
pb = _particles[i];
if (((!((pb == null))) && (pb.collidable))){
CollisionDetector.test(pa, pb);
};
i++;
};
clen = _constraints.length;
n = 0;
while (n < clen) {
c = _constraints[n];
if (((((!((c == null))) && (c.collidable))) && (!(c.isConnectedTo(pa))))){
c.scp.updatePosition();
CollisionDetector.test(pa, c.scp);
};
n++;
};
};
j++;
};
}
public function addParticle(p:AbstractParticle):void{
particles.push(p);
if (isParented){
p.init();
};
}
public function removeConstraint(c:AbstractConstraint):void{
var cpos:int;
cpos = constraints.indexOf(c);
if (cpos == -1){
return;
};
constraints.splice(cpos, 1);
c.cleanup();
}
function get isParented():Boolean{
return (_isParented);
}
public function init():void{
var i:int;
i = 0;
while (i < particles.length) {
particles[i].init();
i++;
};
i = 0;
while (i < constraints.length) {
constraints[i].init();
i++;
};
}
function satisfyConstraints():void{
var len:int;
var i:int;
var c:AbstractConstraint;
len = _constraints.length;
i = 0;
while (i < len) {
c = _constraints[i];
c.resolve();
i++;
};
}
public function paint():void{
var p:AbstractParticle;
var len:int;
var i:int;
var c:SpringConstraint;
len = _particles.length;
i = 0;
while (i < len) {
p = _particles[i];
if (((!(p.fixed)) || (p.alwaysRepaint))){
p.paint();
};
i++;
};
len = _constraints.length;
i = 0;
while (i < len) {
c = _constraints[i];
if (((!(c.fixed)) || (c.alwaysRepaint))){
c.paint();
};
i++;
};
}
public function addConstraint(c:AbstractConstraint):void{
constraints.push(c);
if (isParented){
c.init();
};
}
function set isParented(b:Boolean):void{
_isParented = b;
}
public function removeParticle(p:AbstractParticle):void{
var ppos:int;
ppos = particles.indexOf(p);
if (ppos == -1){
return;
};
particles.splice(ppos, 1);
p.cleanup();
}
public function cleanup():void{
var i:int;
i = 0;
while (i < particles.length) {
particles[i].cleanup();
i++;
};
i = 0;
while (i < constraints.length) {
constraints[i].cleanup();
i++;
};
}
public function get particles():Array{
return (_particles);
}
function integrate(dt2:Number):void{
var len:int;
var i:int;
var p:AbstractParticle;
len = _particles.length;
i = 0;
while (i < len) {
p = _particles[i];
p.update(dt2);
i++;
};
}
public function get constraints():Array{
return (_constraints);
}
}
}//package org.cove.ape
Section 27
//AbstractConstraint (org.cove.ape.AbstractConstraint)
package org.cove.ape {
import flash.utils.*;
public class AbstractConstraint extends AbstractItem {
private var _stiffness:Number;
public function AbstractConstraint(stiffness:Number){
super();
if (getQualifiedClassName(this) == "org.cove.ape::AbstractConstraint"){
throw (new ArgumentError("AbstractConstraint can't be instantiated directly"));
};
this.stiffness = stiffness;
setStyle();
}
public function get stiffness():Number{
return (_stiffness);
}
public function resolve():void{
}
public function set stiffness(s:Number):void{
_stiffness = s;
}
}
}//package org.cove.ape
Section 28
//AbstractItem (org.cove.ape.AbstractItem)
package org.cove.ape {
import flash.display.*;
import flash.events.*;
public class AbstractItem extends EventDispatcher {
var displayObjectOffset:Vector;
var fillColor:uint;
var displayObject:DisplayObject;
var fillAlpha:Number;
private var _solid:Boolean;
private var _visible:Boolean;
var displayObjectRotation:Number;
var lineColor:uint;
var lineAlpha:Number;
var lineThickness:Number;
private var _sprite:Sprite;
private var _alwaysRepaint:Boolean;
public function AbstractItem(){
super();
_solid = true;
_visible = true;
_alwaysRepaint = false;
}
public function setFill(color:uint=0xFFFFFF, alpha:Number=1):void{
fillColor = color;
fillAlpha = alpha;
}
public function init():void{
}
public function cleanup():void{
var i:int;
sprite.graphics.clear();
i = 0;
while (i < sprite.numChildren) {
sprite.removeChildAt(i);
i++;
};
}
public function get solid():Boolean{
return (_solid);
}
public function get sprite():Sprite{
if (_sprite != null){
return (_sprite);
};
if (APEngine.container == null){
throw (new Error("The container property of the APEngine class has not been set"));
};
_sprite = new Sprite();
APEngine.container.addChild(_sprite);
return (_sprite);
}
public function set solid(s:Boolean):void{
_solid = s;
}
public function paint():void{
}
public function set visible(v:Boolean):void{
_visible = v;
sprite.visible = v;
}
public function setStyle(lineThickness:Number=0, lineColor:uint=0, lineAlpha:Number=1, fillColor:uint=0xFFFFFF, fillAlpha:Number=1):void{
setLine(lineThickness, lineColor, lineAlpha);
setFill(fillColor, fillAlpha);
}
public function get visible():Boolean{
return (_visible);
}
public function setLine(thickness:Number=0, color:uint=0, alpha:Number=1):void{
lineThickness = thickness;
lineColor = color;
lineAlpha = alpha;
}
final public function set alwaysRepaint(b:Boolean):void{
_alwaysRepaint = b;
}
final public function get alwaysRepaint():Boolean{
return (_alwaysRepaint);
}
}
}//package org.cove.ape
Section 29
//AbstractParticle (org.cove.ape.AbstractParticle)
package org.cove.ape {
import flash.display.*;
import flash.utils.*;
public class AbstractParticle extends AbstractItem {
private var forceList:Array;
var curr:Vector;
var prev:Vector;
private var collision:Collision;
private var _invMass:Number;
private var _friction:Number;
private var firstCollision:Boolean;
private var _multisample:int;
var samp:Vector;
private var _center:Vector;
private var _fixed:Boolean;
private var _collidable:Boolean;
private var _kfr:Number;
var interval:Interval;
private var _mass:Number;
private var temp:Vector;
private var forces:Vector;
public function AbstractParticle(x:Number, y:Number, isFixed:Boolean, mass:Number, elasticity:Number, friction:Number){
super();
if (getQualifiedClassName(this) == "org.cove.ape::AbstractParticle"){
throw (new ArgumentError("AbstractParticle can't be instantiated directly"));
};
interval = new Interval(0, 0);
curr = new Vector(x, y);
prev = new Vector(x, y);
samp = new Vector();
temp = new Vector();
fixed = isFixed;
forces = new Vector();
forceList = new Array();
collision = new Collision(new Vector(), new Vector());
collidable = true;
firstCollision = false;
this.mass = mass;
this.elasticity = elasticity;
this.friction = friction;
setStyle();
_center = new Vector();
_multisample = 0;
}
public function get px():Number{
return (curr.x);
}
public function get py():Number{
return (curr.y);
}
public function set py(y:Number):void{
curr.y = y;
prev.y = y;
}
function getComponents(collisionNormal:Vector):Collision{
var vel:Vector;
var vdotn:Number;
vel = velocity;
vdotn = collisionNormal.dot(vel);
collision.vn = collisionNormal.mult(vdotn);
collision.vt = vel.minus(collision.vn);
return (collision);
}
public function set px(x:Number):void{
curr.x = x;
prev.x = x;
}
public function setDisplay(d:DisplayObject, offsetX:Number=0, offsetY:Number=0, rotation:Number=0):void{
displayObject = d;
displayObjectRotation = rotation;
displayObjectOffset = new Vector(offsetX, offsetY);
}
public function get multisample():int{
return (_multisample);
}
public function get position():Vector{
return (new Vector(curr.x, curr.y));
}
public function set multisample(m:int):void{
_multisample = m;
}
public function get center():Vector{
_center.setTo(px, py);
return (_center);
}
public function set position(p:Vector):void{
curr.copy(p);
prev.copy(p);
}
function testParticleEvents(p:AbstractParticle):void{
if (hasEventListener(CollisionEvent.COLLIDE)){
dispatchEvent(new CollisionEvent(CollisionEvent.COLLIDE, false, false, p));
};
if (((hasEventListener(CollisionEvent.FIRST_COLLIDE)) && (!(firstCollision)))){
firstCollision = true;
dispatchEvent(new CollisionEvent(CollisionEvent.FIRST_COLLIDE, false, false, p));
};
}
public function set elasticity(k:Number):void{
_kfr = k;
}
public function get fixed():Boolean{
return (_fixed);
}
function get invMass():Number{
return ((fixed) ? 0 : _invMass);
}
public function resetFirstCollision():void{
firstCollision = false;
}
function initDisplay():void{
displayObject.x = displayObjectOffset.x;
displayObject.y = displayObjectOffset.y;
displayObject.rotation = displayObjectRotation;
sprite.addChild(displayObject);
}
private function clearForces():void{
forceList.length = 0;
forces.setTo(0, 0);
}
function resolveCollision(mtd:Vector, vel:Vector, n:Vector, d:Number, o:int, p:AbstractParticle):void{
testParticleEvents(p);
if (((((fixed) || (!(solid)))) || (!(p.solid)))){
return;
};
curr.copy(samp);
curr.plusEquals(mtd);
velocity = vel;
}
public function get elasticity():Number{
return (_kfr);
}
public function set velocity(v:Vector):void{
prev = curr.minus(v);
}
public function set collidable(b:Boolean):void{
_collidable = b;
}
public function update(dt2:Number):void{
var nv:Vector;
if (fixed){
return;
};
accumulateForces();
temp.copy(curr);
nv = velocity.plus(forces.multEquals(dt2));
curr.plusEquals(nv.multEquals(APEngine.damping));
prev.copy(temp);
clearForces();
}
public function addForce(f:IForce):void{
forceList.push(f);
}
public function get velocity():Vector{
return (curr.minus(prev));
}
public function get collidable():Boolean{
return (_collidable);
}
public function set mass(m:Number):void{
if (m <= 0){
throw (new ArgumentError("mass may not be set <= 0"));
};
_mass = m;
_invMass = (1 / _mass);
}
public function set fixed(f:Boolean):void{
_fixed = f;
}
private function accumulateForces():void{
var f:IForce;
var len:int;
var i:int;
var globalForces:Array;
len = forceList.length;
i = 0;
while (i < len) {
f = forceList[i];
forces.plusEquals(f.getValue(_invMass));
i++;
};
globalForces = APEngine.forces;
len = globalForces.length;
i = 0;
while (i < len) {
f = globalForces[i];
forces.plusEquals(f.getValue(_invMass));
i++;
};
}
public function get mass():Number{
return (_mass);
}
public function get friction():Number{
return (_friction);
}
public function set friction(f:Number):void{
if ((((f < 0)) || ((f > 1)))){
throw (new ArgumentError("Legal friction must be >= 0 and <=1"));
};
_friction = f;
}
}
}//package org.cove.ape
Section 30
//APEngine (org.cove.ape.APEngine)
package org.cove.ape {
import flash.display.*;
public final class APEngine {
private static var _damping:Number;
private static var _container:DisplayObjectContainer;
private static var _constraintCollisionCycles:int;
private static var groups:Array;
static var forces:Array;
private static var _constraintCycles:int;
private static var timeStep:Number;
private static var numGroups:int;
public function APEngine(){
super();
}
public static function get container():DisplayObjectContainer{
return (_container);
}
public static function get constraintCollisionCycles():int{
return (_constraintCollisionCycles);
}
public static function removeForce(f:IForce):void{
var fpos:int;
fpos = forces.indexOf(f);
if (fpos == -1){
return;
};
forces.splice(fpos, 1);
}
public static function set damping(d:Number):void{
_damping = d;
}
public static function step():void{
var j:int;
var i:int;
integrate();
j = 0;
while (j < _constraintCycles) {
satisfyConstraints();
j++;
};
i = 0;
while (i < _constraintCollisionCycles) {
satisfyConstraints();
checkCollisions();
i++;
};
}
public static function get constraintCycles():int{
return (_constraintCycles);
}
public static function set constraintCollisionCycles(numCycles:int):void{
_constraintCollisionCycles = numCycles;
}
public static function init(dt:Number=0.25):void{
timeStep = (dt * dt);
numGroups = 0;
groups = new Array();
forces = new Array();
_damping = 1;
_constraintCycles = 0;
_constraintCollisionCycles = 1;
}
public static function addForce(f:IForce):void{
forces.push(f);
}
public static function get damping():Number{
return (_damping);
}
public static function set constraintCycles(numCycles:int):void{
_constraintCycles = numCycles;
}
public static function addGroup(g:Group):void{
groups.push(g);
g.isParented = true;
numGroups++;
g.init();
}
public static function set container(d:DisplayObjectContainer):void{
_container = d;
}
public static function paint():void{
var j:int;
var g:Group;
j = 0;
while (j < numGroups) {
g = groups[j];
g.paint();
j++;
};
}
public static function removeGroup(g:Group):void{
var gpos:int;
gpos = groups.indexOf(g);
if (gpos == -1){
return;
};
groups.splice(gpos, 1);
g.isParented = false;
numGroups--;
g.cleanup();
}
private static function satisfyConstraints():void{
var j:int;
var g:Group;
j = 0;
while (j < numGroups) {
g = groups[j];
g.satisfyConstraints();
j++;
};
}
public static function removeAllForce():void{
forces = new Array();
}
private static function checkCollisions():void{
var j:int;
var g:Group;
j = 0;
while (j < numGroups) {
g = groups[j];
g.checkCollisions();
j++;
};
}
private static function integrate():void{
var j:int;
var g:Group;
j = 0;
while (j < numGroups) {
g = groups[j];
g.integrate(timeStep);
j++;
};
}
}
}//package org.cove.ape
Section 31
//CircleParticle (org.cove.ape.CircleParticle)
package org.cove.ape {
public class CircleParticle extends AbstractParticle {
private var _radius:Number;
public function CircleParticle(x:Number, y:Number, radius:Number, fixed:Boolean=false, mass:Number=1, elasticity:Number=0.3, friction:Number=0){
super(x, y, fixed, mass, elasticity, friction);
_radius = radius;
}
function getProjection(axis:Vector):Interval{
var c:Number;
c = samp.dot(axis);
interval.min = (c - _radius);
interval.max = (c + _radius);
return (interval);
}
override public function init():void{
cleanup();
if (displayObject != null){
initDisplay();
} else {
sprite.graphics.clear();
sprite.graphics.lineStyle(lineThickness, lineColor, lineAlpha);
sprite.graphics.beginFill(fillColor, fillAlpha);
sprite.graphics.drawCircle(0, 0, radius);
sprite.graphics.endFill();
};
paint();
}
public function get radius():Number{
return (_radius);
}
function getIntervalY():Interval{
interval.min = (samp.y - _radius);
interval.max = (samp.y + _radius);
return (interval);
}
public function set radius(r:Number):void{
_radius = r;
}
override public function paint():void{
sprite.x = curr.x;
sprite.y = curr.y;
}
function getIntervalX():Interval{
interval.min = (samp.x - _radius);
interval.max = (samp.x + _radius);
return (interval);
}
}
}//package org.cove.ape
Section 32
//Collision (org.cove.ape.Collision)
package org.cove.ape {
import org.cove.ape.*;
final class Collision {
var vn:Vector;
var vt:Vector;
function Collision(vn:Vector, vt:Vector){
super();
this.vn = vn;
this.vt = vt;
}
}
}//package org.cove.ape
Section 33
//CollisionDetector (org.cove.ape.CollisionDetector)
package org.cove.ape {
import org.cove.ape.*;
final class CollisionDetector {
private static var collNormal:Vector;
private static var cpa:AbstractParticle;
private static var cpb:AbstractParticle;
private static var collDepth:Number;
function CollisionDetector(){
super();
}
private static function testIntervals(intervalA:Interval, intervalB:Interval):Number{
var lenA:Number;
var lenB:Number;
if (intervalA.max < intervalB.min){
return (0);
};
if (intervalB.max < intervalA.min){
return (0);
};
lenA = (intervalB.max - intervalA.min);
lenB = (intervalB.min - intervalA.max);
return (((Math.abs(lenA))<Math.abs(lenB)) ? lenA : lenB);
}
private static function testOBBvsOBB(ra:RectangleParticle, rb:RectangleParticle):Boolean{
var i:int;
var axisA:Vector;
var depthA:Number;
var axisB:Vector;
var depthB:Number;
var absA:Number;
var absB:Number;
var altb:Boolean;
collDepth = Number.POSITIVE_INFINITY;
i = 0;
while (i < 2) {
axisA = ra.axes[i];
depthA = testIntervals(ra.getProjection(axisA), rb.getProjection(axisA));
if (depthA == 0){
return (false);
};
axisB = rb.axes[i];
depthB = testIntervals(ra.getProjection(axisB), rb.getProjection(axisB));
if (depthB == 0){
return (false);
};
absA = Math.abs(depthA);
absB = Math.abs(depthB);
if ((((absA < Math.abs(collDepth))) || ((absB < Math.abs(collDepth))))){
altb = (absA < absB);
collNormal = (altb) ? axisA : axisB;
collDepth = (altb) ? depthA : depthB;
};
i++;
};
cpa = ra;
cpb = rb;
return (true);
}
private static function testTypes(objA:AbstractParticle, objB:AbstractParticle):Boolean{
if ((((objA is RectangleParticle)) && ((objB is RectangleParticle)))){
return (testOBBvsOBB((objA as RectangleParticle), (objB as RectangleParticle)));
};
if ((((objA is CircleParticle)) && ((objB is CircleParticle)))){
return (testCirclevsCircle((objA as CircleParticle), (objB as CircleParticle)));
};
if ((((objA is RectangleParticle)) && ((objB is CircleParticle)))){
return (testOBBvsCircle((objA as RectangleParticle), (objB as CircleParticle)));
};
if ((((objA is CircleParticle)) && ((objB is RectangleParticle)))){
return (testOBBvsCircle((objB as RectangleParticle), (objA as CircleParticle)));
};
return (false);
}
private static function sampVsNorm(objA:AbstractParticle, objB:AbstractParticle):void{
var s:Number;
var t:Number;
var i:int;
if (normVsNorm(objA, objB)){
return;
};
s = (1 / (objA.multisample + 1));
t = s;
i = 0;
while (i <= objA.multisample) {
objA.samp.setTo((objA.prev.x + (t * (objA.curr.x - objA.prev.x))), (objA.prev.y + (t * (objA.curr.y - objA.prev.y))));
if (testTypes(objA, objB)){
CollisionResolver.resolve(cpa, cpb, collNormal, collDepth);
return;
};
t = (t + s);
i++;
};
}
private static function testCirclevsCircle(ca:CircleParticle, cb:CircleParticle):Boolean{
var depthX:Number;
var depthY:Number;
var mag:Number;
depthX = testIntervals(ca.getIntervalX(), cb.getIntervalX());
if (depthX == 0){
return (false);
};
depthY = testIntervals(ca.getIntervalY(), cb.getIntervalY());
if (depthY == 0){
return (false);
};
collNormal = ca.samp.minus(cb.samp);
mag = collNormal.magnitude();
collDepth = ((ca.radius + cb.radius) - mag);
if (collDepth > 0){
collNormal.divEquals(mag);
cpa = ca;
cpb = cb;
return (true);
};
return (false);
}
static function test(objA:AbstractParticle, objB:AbstractParticle):void{
if (((objA.fixed) && (objB.fixed))){
return;
};
if ((((objA.multisample == 0)) && ((objB.multisample == 0)))){
normVsNorm(objA, objB);
} else {
if ((((objA.multisample > 0)) && ((objB.multisample == 0)))){
sampVsNorm(objA, objB);
} else {
if ((((objB.multisample > 0)) && ((objA.multisample == 0)))){
sampVsNorm(objB, objA);
} else {
if (objA.multisample == objB.multisample){
sampVsSamp(objA, objB);
} else {
normVsNorm(objA, objB);
};
};
};
};
}
private static function testOBBvsCircle(ra:RectangleParticle, ca:CircleParticle):Boolean{
var depths:Array;
var i:int;
var r:Number;
var boxAxis:Vector;
var depth:Number;
var vertex:Vector;
var mag:Number;
collDepth = Number.POSITIVE_INFINITY;
depths = new Array(2);
i = 0;
while (i < 2) {
boxAxis = ra.axes[i];
depth = testIntervals(ra.getProjection(boxAxis), ca.getProjection(boxAxis));
if (depth == 0){
return (false);
};
if (Math.abs(depth) < Math.abs(collDepth)){
collNormal = boxAxis;
collDepth = depth;
};
depths[i] = depth;
i++;
};
r = ca.radius;
if ((((Math.abs(depths[0]) < r)) && ((Math.abs(depths[1]) < r)))){
vertex = closestVertexOnOBB(ca.samp, ra);
collNormal = vertex.minus(ca.samp);
mag = collNormal.magnitude();
collDepth = (r - mag);
if (collDepth > 0){
collNormal.divEquals(mag);
} else {
return (false);
};
};
cpa = ra;
cpb = ca;
return (true);
}
private static function closestVertexOnOBB(p:Vector, r:RectangleParticle):Vector{
var d:Vector;
var q:Vector;
var i:int;
var dist:Number;
d = p.minus(r.samp);
q = new Vector(r.samp.x, r.samp.y);
i = 0;
while (i < 2) {
dist = d.dot(r.axes[i]);
if (dist >= 0){
dist = r.extents[i];
} else {
if (dist < 0){
dist = -(r.extents[i]);
};
};
q.plusEquals(r.axes[i].mult(dist));
i++;
};
return (q);
}
private static function normVsNorm(objA:AbstractParticle, objB:AbstractParticle):Boolean{
objA.samp.copy(objA.curr);
objB.samp.copy(objB.curr);
if (testTypes(objA, objB)){
CollisionResolver.resolve(cpa, cpb, collNormal, collDepth);
return (true);
};
return (false);
}
private static function sampVsSamp(objA:AbstractParticle, objB:AbstractParticle):void{
var s:Number;
var t:Number;
var i:int;
if (normVsNorm(objA, objB)){
return;
};
s = (1 / (objA.multisample + 1));
t = s;
i = 0;
while (i <= objA.multisample) {
objA.samp.setTo((objA.prev.x + (t * (objA.curr.x - objA.prev.x))), (objA.prev.y + (t * (objA.curr.y - objA.prev.y))));
objB.samp.setTo((objB.prev.x + (t * (objB.curr.x - objB.prev.x))), (objB.prev.y + (t * (objB.curr.y - objB.prev.y))));
if (testTypes(objA, objB)){
CollisionResolver.resolve(cpa, cpb, collNormal, collDepth);
return;
};
t = (t + s);
i++;
};
}
}
}//package org.cove.ape
Section 34
//CollisionEvent (org.cove.ape.CollisionEvent)
package org.cove.ape {
import flash.events.*;
public class CollisionEvent extends Event {
private var _collidingItem:AbstractItem;
public static const COLLIDE:String = "collide";
public static const FIRST_COLLIDE:String = "firstCollide";
public function CollisionEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, collidingItem:AbstractItem=null){
super(type, bubbles, cancelable);
_collidingItem = collidingItem;
}
public function get collidingItem():AbstractItem{
var scp:SpringConstraintParticle;
if ((_collidingItem is SpringConstraintParticle)){
scp = (_collidingItem as SpringConstraintParticle);
return (scp.parent);
};
return (_collidingItem);
}
}
}//package org.cove.ape
Section 35
//CollisionResolver (org.cove.ape.CollisionResolver)
package org.cove.ape {
import org.cove.ape.*;
final class CollisionResolver {
function CollisionResolver(){
super();
}
static function resolve(pa:AbstractParticle, pb:AbstractParticle, normal:Vector, depth:Number):void{
var mtd:Vector;
var te:Number;
var sumInvMass:Number;
var tf:Number;
var ca:Collision;
var cb:Collision;
var vnA:Vector;
var vnB:Vector;
var mtdA:Vector;
var mtdB:Vector;
mtd = normal.mult(depth);
te = (pa.elasticity + pb.elasticity);
sumInvMass = (pa.invMass + pb.invMass);
tf = MathUtil.clamp((1 - (pa.friction + pb.friction)), 0, 1);
ca = pa.getComponents(normal);
cb = pb.getComponents(normal);
vnA = cb.vn.mult(((te + 1) * pa.invMass)).plus(ca.vn.mult((pb.invMass - (te * pa.invMass)))).divEquals(sumInvMass);
vnB = ca.vn.mult(((te + 1) * pb.invMass)).plus(cb.vn.mult((pa.invMass - (te * pb.invMass)))).divEquals(sumInvMass);
ca.vt.multEquals(tf);
cb.vt.multEquals(tf);
mtdA = mtd.mult((pa.invMass / sumInvMass));
mtdB = mtd.mult((-(pb.invMass) / sumInvMass));
vnA.plusEquals(ca.vt);
vnB.plusEquals(cb.vt);
pa.resolveCollision(mtdA, vnA, normal, depth, -1, pb);
pb.resolveCollision(mtdB, vnB, normal, depth, 1, pa);
}
}
}//package org.cove.ape
Section 36
//Composite (org.cove.ape.Composite)
package org.cove.ape {
public class Composite extends AbstractCollection {
private var delta:Vector;
public function Composite(){
super();
delta = new Vector();
}
private function getRelativeAngle(center:Vector, p:Vector):Number{
delta.setTo((p.x - center.x), (p.y - center.y));
return (Math.atan2(delta.y, delta.x));
}
public function rotateByRadian(angleRadians:Number, center:Vector):void{
var p:AbstractParticle;
var pa:Array;
var len:int;
var i:int;
var radius:Number;
var angle:Number;
pa = particles;
len = pa.length;
i = 0;
while (i < len) {
p = pa[i];
radius = p.center.distance(center);
angle = (getRelativeAngle(center, p.center) + angleRadians);
p.px = ((Math.cos(angle) * radius) + center.x);
p.py = ((Math.sin(angle) * radius) + center.y);
i++;
};
}
public function rotateByAngle(angleDegrees:Number, center:Vector):void{
var angleRadians:Number;
angleRadians = (angleDegrees * MathUtil.PI_OVER_ONE_EIGHTY);
rotateByRadian(angleRadians, center);
}
public function set fixed(b:Boolean):void{
var i:int;
i = 0;
while (i < particles.length) {
particles[i].fixed = b;
i++;
};
}
public function get fixed():Boolean{
var i:int;
i = 0;
while (i < particles.length) {
if (!particles[i].fixed){
return (false);
};
i++;
};
return (true);
}
}
}//package org.cove.ape
Section 37
//Group (org.cove.ape.Group)
package org.cove.ape {
public class Group extends AbstractCollection {
private var _collideInternal:Boolean;
private var _composites:Array;
private var _collisionList:Array;
public function Group(collideInternal:Boolean=false){
super();
_composites = new Array();
_collisionList = new Array();
this.collideInternal = collideInternal;
}
function checkCollisions():void{
var len:int;
var i:int;
var g:Group;
if (collideInternal){
checkCollisionGroupInternal();
};
len = collisionList.length;
i = 0;
while (i < len) {
g = collisionList[i];
if (g == null){
} else {
checkCollisionVsGroup(g);
};
i++;
};
}
public function get composites():Array{
return (_composites);
}
override public function init():void{
var i:int;
super.init();
i = 0;
while (i < composites.length) {
composites[i].init();
i++;
};
}
public function removeCollidable(g:Group):void{
var pos:int;
pos = collisionList.indexOf(g);
if (pos == -1){
return;
};
collisionList.splice(pos, 1);
}
private function checkCollisionVsGroup(g:Group):void{
var gc:Composite;
var clen:int;
var gclen:int;
var i:int;
var c:Composite;
var j:int;
checkCollisionsVsCollection(g);
clen = _composites.length;
gclen = g.composites.length;
i = 0;
while (i < clen) {
c = _composites[i];
if (c == null){
} else {
c.checkCollisionsVsCollection(g);
j = 0;
while (j < gclen) {
gc = g.composites[j];
if (gc == null){
} else {
c.checkCollisionsVsCollection(gc);
};
j++;
};
};
i++;
};
j = 0;
while (j < gclen) {
gc = g.composites[j];
if (gc == null){
} else {
checkCollisionsVsCollection(gc);
};
j++;
};
}
override function satisfyConstraints():void{
var len:int;
var i:int;
var cmp:Composite;
super.satisfyConstraints();
len = _composites.length;
i = 0;
while (i < len) {
cmp = _composites[i];
cmp.satisfyConstraints();
i++;
};
}
public function get collideInternal():Boolean{
return (_collideInternal);
}
public function addCollidableList(list:Array):void{
var i:int;
var g:Group;
i = 0;
while (i < list.length) {
g = list[i];
collisionList.push(g);
i++;
};
}
public function removeComposite(c:Composite):void{
var cpos:int;
cpos = composites.indexOf(c);
if (cpos == -1){
return;
};
composites.splice(cpos, 1);
c.isParented = false;
c.cleanup();
}
override public function cleanup():void{
var i:int;
super.cleanup();
i = 0;
while (i < composites.length) {
composites[i].cleanup();
i++;
};
}
override public function paint():void{
var len:int;
var i:int;
var c:Composite;
super.paint();
len = _composites.length;
i = 0;
while (i < len) {
c = _composites[i];
c.paint();
i++;
};
}
public function addCollidable(g:Group):void{
collisionList.push(g);
}
override public function getAll():Array{
return (particles.concat(constraints).concat(composites));
}
public function get collisionList():Array{
return (_collisionList);
}
override function integrate(dt2:Number):void{
var len:int;
var i:int;
var cmp:Composite;
super.integrate(dt2);
len = _composites.length;
i = 0;
while (i < len) {
cmp = _composites[i];
cmp.integrate(dt2);
i++;
};
}
public function addComposite(c:Composite):void{
composites.push(c);
c.isParented = true;
if (isParented){
c.init();
};
}
private function checkCollisionGroupInternal():void{
var clen:int;
var j:int;
var ca:Composite;
var i:int;
var cb:Composite;
checkInternalCollisions();
clen = _composites.length;
j = 0;
while (j < clen) {
ca = _composites[j];
if (ca == null){
} else {
ca.checkCollisionsVsCollection(this);
i = (j + 1);
while (i < clen) {
cb = _composites[i];
if (cb != null){
ca.checkCollisionsVsCollection(cb);
};
i++;
};
};
j++;
};
}
public function set collideInternal(b:Boolean):void{
_collideInternal = b;
}
}
}//package org.cove.ape
Section 38
//IForce (org.cove.ape.IForce)
package org.cove.ape {
public interface IForce {
function getValue(:Number):Vector;
}
}//package org.cove.ape
Section 39
//Interval (org.cove.ape.Interval)
package org.cove.ape {
final class Interval {
var min:Number;
var max:Number;
function Interval(min:Number, max:Number){
super();
this.min = min;
this.max = max;
}
function toString():String{
return (((min + " : ") + max));
}
}
}//package org.cove.ape
Section 40
//MathUtil (org.cove.ape.MathUtil)
package org.cove.ape {
final class MathUtil {
static var ONE_EIGHTY_OVER_PI:Number = 57.2957795130823;
static var PI_OVER_ONE_EIGHTY:Number = 0.0174532925199433;
function MathUtil(){
super();
}
static function clamp(n:Number, min:Number, max:Number):Number{
if (n < min){
return (min);
};
if (n > max){
return (max);
};
return (n);
}
static function sign(val:Number):int{
if (val < 0){
return (-1);
};
return (1);
}
}
}//package org.cove.ape
Section 41
//RectangleParticle (org.cove.ape.RectangleParticle)
package org.cove.ape {
public class RectangleParticle extends AbstractParticle {
private var _axes:Array;
private var _extents:Array;
private var _radian:Number;
public function RectangleParticle(x:Number, y:Number, width:Number, height:Number, rotation:Number=0, fixed:Boolean=false, mass:Number=1, elasticity:Number=0.3, friction:Number=0){
super(x, y, fixed, mass, elasticity, friction);
_extents = new Array((width / 2), (height / 2));
_axes = new Array(new Vector(0, 0), new Vector(0, 0));
radian = rotation;
}
function getProjection(axis:Vector):Interval{
var radius:Number;
var c:Number;
radius = ((extents[0] * Math.abs(axis.dot(axes[0]))) + (extents[1] * Math.abs(axis.dot(axes[1]))));
c = samp.dot(axis);
interval.min = (c - radius);
interval.max = (c + radius);
return (interval);
}
override public function init():void{
var w:Number;
var h:Number;
cleanup();
if (displayObject != null){
initDisplay();
} else {
w = (extents[0] * 2);
h = (extents[1] * 2);
sprite.graphics.clear();
sprite.graphics.lineStyle(lineThickness, lineColor, lineAlpha);
sprite.graphics.beginFill(fillColor, fillAlpha);
sprite.graphics.drawRect((-(w) / 2), (-(h) / 2), w, h);
sprite.graphics.endFill();
};
paint();
}
public function set width(w:Number):void{
_extents[0] = (w / 2);
}
function get extents():Array{
return (_extents);
}
function get axes():Array{
return (_axes);
}
public function get height():Number{
return ((_extents[1] * 2));
}
private function setAxes(t:Number):void{
var s:Number;
var c:Number;
s = Math.sin(t);
c = Math.cos(t);
axes[0].x = c;
axes[0].y = s;
axes[1].x = -(s);
axes[1].y = c;
}
public function get radian():Number{
return (_radian);
}
public function set angle(a:Number):void{
radian = (a * MathUtil.PI_OVER_ONE_EIGHTY);
}
public function set height(h:Number):void{
_extents[1] = (h / 2);
}
public function get angle():Number{
return ((radian * MathUtil.ONE_EIGHTY_OVER_PI));
}
public function set radian(t:Number):void{
_radian = t;
setAxes(t);
}
override public function paint():void{
sprite.x = curr.x;
sprite.y = curr.y;
sprite.rotation = angle;
}
public function get width():Number{
return ((_extents[0] * 2));
}
}
}//package org.cove.ape
Section 42
//SpringConstraint (org.cove.ape.SpringConstraint)
package org.cove.ape {
import flash.display.*;
public class SpringConstraint extends AbstractConstraint {
private var _collidable:Boolean;
private var p1:AbstractParticle;
private var p2:AbstractParticle;
private var _scp:SpringConstraintParticle;
private var _restLength:Number;
public function SpringConstraint(p1:AbstractParticle, p2:AbstractParticle, stiffness:Number=0.5, collidable:Boolean=false, rectHeight:Number=1, rectScale:Number=1, scaleToLength:Boolean=false){
super(stiffness);
this.p1 = p1;
this.p2 = p2;
checkParticlesLocation();
_restLength = currLength;
setCollidable(collidable, rectHeight, rectScale, scaleToLength);
}
public function get fixed():Boolean{
return (((p1.fixed) && (p2.fixed)));
}
public function set rectScale(s:Number):void{
if (scp == null){
return;
};
scp.rectScale = s;
}
override public function init():void{
cleanup();
if (collidable){
scp.init();
} else {
if (displayObject != null){
initDisplay();
};
};
paint();
}
function initDisplay():void{
if (collidable){
scp.initDisplay();
} else {
displayObject.x = displayObjectOffset.x;
displayObject.y = displayObjectOffset.y;
displayObject.rotation = displayObjectRotation;
sprite.addChild(displayObject);
};
}
public function isConnectedTo(p:AbstractParticle):Boolean{
return ((((p == p1)) || ((p == p2))));
}
public function setDisplay(d:DisplayObject, offsetX:Number=0, offsetY:Number=0, rotation:Number=0):void{
if (collidable){
scp.setDisplay(d, offsetX, offsetY, rotation);
} else {
displayObject = d;
displayObjectRotation = rotation;
displayObjectOffset = new Vector(offsetX, offsetY);
};
}
function get scp():SpringConstraintParticle{
return (_scp);
}
private function checkParticlesLocation():void{
if ((((p1.curr.x == p2.curr.x)) && ((p1.curr.y == p2.curr.y)))){
p2.curr.x = (p2.curr.x + 0.0001);
};
}
public function get radian():Number{
var d:Vector;
d = delta;
return (Math.atan2(d.y, d.x));
}
public function get rectHeight():Number{
return (scp.rectHeight);
}
public function set restLength(r:Number):void{
if (r <= 0){
throw (new ArgumentError("restLength must be greater than 0"));
};
_restLength = r;
}
public function get currLength():Number{
return (p1.curr.distance(p2.curr));
}
public function get fixedEndLimit():Number{
return (scp.fixedEndLimit);
}
function get delta():Vector{
return (p1.curr.minus(p2.curr));
}
public function get angle():Number{
return ((radian * MathUtil.ONE_EIGHTY_OVER_PI));
}
public function get center():Vector{
return (p1.curr.plus(p2.curr).divEquals(2));
}
public function set rectHeight(h:Number):void{
if (scp == null){
return;
};
scp.rectHeight = h;
}
public function setCollidable(b:Boolean, rectHeight:Number, rectScale:Number, scaleToLength:Boolean=false):void{
_collidable = b;
_scp = null;
if (_collidable){
_scp = new SpringConstraintParticle(p1, p2, this, rectHeight, rectScale, scaleToLength);
};
}
override public function paint():void{
var c:Vector;
if (collidable){
scp.paint();
} else {
if (displayObject != null){
c = center;
sprite.x = c.x;
sprite.y = c.y;
sprite.rotation = angle;
} else {
sprite.graphics.clear();
sprite.graphics.lineStyle(lineThickness, lineColor, lineAlpha);
sprite.graphics.moveTo(p1.px, p1.py);
sprite.graphics.lineTo(p2.px, p2.py);
};
};
}
public function get rectScale():Number{
return (scp.rectScale);
}
public function get restLength():Number{
return (_restLength);
}
override public function resolve():void{
var deltaLength:Number;
var diff:Number;
var dmds:Vector;
if (((p1.fixed) && (p2.fixed))){
return;
};
deltaLength = currLength;
diff = ((deltaLength - restLength) / (deltaLength * (p1.invMass + p2.invMass)));
dmds = delta.mult((diff * stiffness));
p1.curr.minusEquals(dmds.mult(p1.invMass));
p2.curr.plusEquals(dmds.mult(p2.invMass));
}
public function get collidable():Boolean{
return (_collidable);
}
public function set fixedEndLimit(f:Number):void{
if (scp == null){
return;
};
scp.fixedEndLimit = f;
}
}
}//package org.cove.ape
Section 43
//SpringConstraintParticle (org.cove.ape.SpringConstraintParticle)
package org.cove.ape {
import flash.display.*;
import org.cove.ape.*;
class SpringConstraintParticle extends RectangleParticle {
private var _fixedEndLimit:Number;
private var rca:Vector;
private var rcb:Vector;
private var _rectScale:Number;
private var s:Number;
var parent:SpringConstraint;
private var scaleToLength:Boolean;
private var p1:AbstractParticle;
private var p2:AbstractParticle;
private var lambda:Vector;
private var avgVelocity:Vector;
private var _rectHeight:Number;
function SpringConstraintParticle(p1:AbstractParticle, p2:AbstractParticle, p:SpringConstraint, rectHeight:Number, rectScale:Number, scaleToLength:Boolean){
super(0, 0, 0, 0, 0, false);
this.p1 = p1;
this.p2 = p2;
lambda = new Vector(0, 0);
avgVelocity = new Vector(0, 0);
parent = p;
this.rectScale = rectScale;
this.rectHeight = rectHeight;
this.scaleToLength = scaleToLength;
fixedEndLimit = 0;
rca = new Vector();
rcb = new Vector();
}
private function setCorners(r:RectangleParticle, i:int):void{
var rx:Number;
var ry:Number;
var axes:Array;
var extents:Array;
var ae0_x:Number;
var ae0_y:Number;
var ae1_x:Number;
var ae1_y:Number;
var emx:Number;
var emy:Number;
var epx:Number;
var epy:Number;
rx = r.curr.x;
ry = r.curr.y;
axes = r.axes;
extents = r.extents;
ae0_x = (axes[0].x * extents[0]);
ae0_y = (axes[0].y * extents[0]);
ae1_x = (axes[1].x * extents[1]);
ae1_y = (axes[1].y * extents[1]);
emx = (ae0_x - ae1_x);
emy = (ae0_y - ae1_y);
epx = (ae0_x + ae1_x);
epy = (ae0_y + ae1_y);
if (i == 0){
rca.x = (rx - epx);
rca.y = (ry - epy);
rcb.x = (rx + emx);
rcb.y = (ry + emy);
} else {
if (i == 1){
rca.x = (rx + emx);
rca.y = (ry + emy);
rcb.x = (rx + epx);
rcb.y = (ry + epy);
} else {
if (i == 2){
rca.x = (rx + epx);
rca.y = (ry + epy);
rcb.x = (rx - emx);
rcb.y = (ry - emy);
} else {
if (i == 3){
rca.x = (rx - emx);
rca.y = (ry - emy);
rcb.x = (rx - epx);
rcb.y = (ry - epy);
};
};
};
};
}
override public function init():void{
var inner:Sprite;
var w:Number;
var h:Number;
if (displayObject != null){
initDisplay();
} else {
inner = new Sprite();
parent.sprite.addChild(inner);
inner.name = "inner";
w = (parent.currLength * rectScale);
h = rectHeight;
inner.graphics.clear();
inner.graphics.lineStyle(parent.lineThickness, parent.lineColor, parent.lineAlpha);
inner.graphics.beginFill(parent.fillColor, parent.fillAlpha);
inner.graphics.drawRect((-(w) / 2), (-(h) / 2), w, h);
inner.graphics.endFill();
};
paint();
}
function updatePosition():void{
var c:Vector;
c = parent.center;
curr.setTo(c.x, c.y);
width = (scaleToLength) ? (parent.currLength * rectScale) : (parent.restLength * rectScale);
height = rectHeight;
radian = parent.radian;
}
private function closestPtSegmentSegment():Number{
var pp1:Vector;
var pq1:Vector;
var pp2:Vector;
var pq2:Vector;
var d1:Vector;
var d2:Vector;
var r:Vector;
var t:Number;
var a:Number;
var e:Number;
var f:Number;
var c:Number;
var b:Number;
var denom:Number;
var c1:Vector;
var c2:Vector;
var c1mc2:Vector;
pp1 = p1.curr;
pq1 = p2.curr;
pp2 = rca;
pq2 = rcb;
d1 = pq1.minus(pp1);
d2 = pq2.minus(pp2);
r = pp1.minus(pp2);
a = d1.dot(d1);
e = d2.dot(d2);
f = d2.dot(r);
c = d1.dot(r);
b = d1.dot(d2);
denom = ((a * e) - (b * b));
if (denom != 0){
s = MathUtil.clamp((((b * f) - (c * e)) / denom), 0, 1);
} else {
s = 0.5;
};
t = (((b * s) + f) / e);
if (t < 0){
t = 0;
s = MathUtil.clamp((-(c) / a), 0, 1);
} else {
if (t > 0){
t = 1;
s = MathUtil.clamp(((b - c) / a), 0, 1);
};
};
c1 = pp1.plus(d1.mult(s));
c2 = pp2.plus(d2.mult(t));
c1mc2 = c1.minus(c2);
return (c1mc2.dot(c1mc2));
}
function get rectHeight():Number{
return (_rectHeight);
}
function get fixedEndLimit():Number{
return (_fixedEndLimit);
}
private function closestParamPoint(c:Vector):Number{
var ab:Vector;
var t:Number;
ab = p2.curr.minus(p1.curr);
t = (ab.dot(c.minus(p1.curr)) / ab.dot(ab));
return (MathUtil.clamp(t, 0, 1));
}
override public function paint():void{
var c:Vector;
var s:Sprite;
c = parent.center;
s = parent.sprite;
if (scaleToLength){
s.getChildByName("inner").width = (parent.currLength * rectScale);
} else {
if (displayObject != null){
s.getChildByName("inner").width = (parent.restLength * rectScale);
};
};
s.x = c.x;
s.y = c.y;
s.rotation = parent.angle;
}
function set rectHeight(r:Number):void{
_rectHeight = r;
}
private function getContactPointParam(p:AbstractParticle):Number{
var t:Number;
var shortestIndex:Number;
var paramList:Array;
var shortestDistance:Number;
var i:int;
var d:Number;
if ((p is CircleParticle)){
t = closestParamPoint(p.curr);
} else {
if ((p is RectangleParticle)){
paramList = new Array(4);
shortestDistance = Number.POSITIVE_INFINITY;
i = 0;
while (i < 4) {
setCorners((p as RectangleParticle), i);
d = closestPtSegmentSegment();
if (d < shortestDistance){
shortestDistance = d;
shortestIndex = i;
paramList[i] = s;
};
i++;
};
t = paramList[shortestIndex];
};
};
return (t);
}
function set fixedEndLimit(f:Number):void{
_fixedEndLimit = f;
}
override public function get fixed():Boolean{
return (parent.fixed);
}
override function get invMass():Number{
if (((p1.fixed) && (p2.fixed))){
return (0);
};
return ((1 / ((p1.mass + p2.mass) / 2)));
}
override function initDisplay():void{
var inner:Sprite;
displayObject.x = displayObjectOffset.x;
displayObject.y = displayObjectOffset.y;
displayObject.rotation = displayObjectRotation;
inner = new Sprite();
inner.name = "inner";
inner.addChild(displayObject);
parent.sprite.addChild(inner);
}
function set rectScale(s:Number):void{
_rectScale = s;
}
override function resolveCollision(mtd:Vector, vel:Vector, n:Vector, d:Number, o:int, p:AbstractParticle):void{
var t:Number;
var c1:Number;
var c2:Number;
var denom:Number;
var corrParticle:AbstractParticle;
testParticleEvents(p);
if (((fixed) || (!(p.solid)))){
return;
};
t = getContactPointParam(p);
c1 = (1 - t);
c2 = t;
if (p1.fixed){
if (c2 <= fixedEndLimit){
return;
};
lambda.setTo((mtd.x / c2), (mtd.y / c2));
p2.curr.plusEquals(lambda);
p2.velocity = vel;
} else {
if (p2.fixed){
if (c1 <= fixedEndLimit){
return;
};
lambda.setTo((mtd.x / c1), (mtd.y / c1));
p1.curr.plusEquals(lambda);
p1.velocity = vel;
} else {
denom = ((c1 * c1) + (c2 * c2));
if (denom == 0){
return;
};
lambda.setTo((mtd.x / denom), (mtd.y / denom));
p1.curr.plusEquals(lambda.mult(c1));
p2.curr.plusEquals(lambda.mult(c2));
if (t == 0.5){
p1.velocity = vel;
p2.velocity = vel;
} else {
corrParticle = ((t)<0.5) ? p1 : p2;
corrParticle.velocity = vel;
};
};
};
}
override public function get elasticity():Number{
return (((p1.elasticity + p2.elasticity) / 2));
}
function get rectScale():Number{
return (_rectScale);
}
override public function get velocity():Vector{
var p1v:Vector;
var p2v:Vector;
p1v = p1.velocity;
p2v = p2.velocity;
avgVelocity.setTo(((p1v.x + p2v.x) / 2), ((p1v.y + p2v.y) / 2));
return (avgVelocity);
}
override public function get mass():Number{
return (((p1.mass + p2.mass) / 2));
}
override public function get friction():Number{
return (((p1.friction + p2.friction) / 2));
}
}
}//package org.cove.ape
Section 44
//Vector (org.cove.ape.Vector)
package org.cove.ape {
public class Vector {
public var x:Number;
public var y:Number;
public function Vector(px:Number=0, py:Number=0){
super();
x = px;
y = py;
}
public function cross(v:Vector):Number{
return (((x * v.y) - (y * v.x)));
}
public function magnitude():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function divEquals(s:Number):Vector{
if (s == 0){
s = 0.0001;
};
x = (x / s);
y = (y / s);
return (this);
}
public function times(v:Vector):Vector{
return (new Vector((x * v.x), (y * v.y)));
}
public function plusEquals(v:Vector):Vector{
x = (x + v.x);
y = (y + v.y);
return (this);
}
public function dot(v:Vector):Number{
return (((x * v.x) + (y * v.y)));
}
public function normalizeEquals():Vector{
var m:Number;
m = magnitude();
if (m == 0){
m = 0.0001;
};
return (multEquals((1 / m)));
}
public function normalize():Vector{
var m:Number;
m = magnitude();
if (m == 0){
m = 0.0001;
};
return (mult((1 / m)));
}
public function copy(v:Vector):void{
x = v.x;
y = v.y;
}
public function minusEquals(v:Vector):Vector{
x = (x - v.x);
y = (y - v.y);
return (this);
}
public function minus(v:Vector):Vector{
return (new Vector((x - v.x), (y - v.y)));
}
public function plus(v:Vector):Vector{
return (new Vector((x + v.x), (y + v.y)));
}
public function toString():String{
return (((x + " : ") + y));
}
public function distance(v:Vector):Number{
var delta:Vector;
delta = this.minus(v);
return (delta.magnitude());
}
public function setTo(px:Number, py:Number):void{
x = px;
y = py;
}
public function multEquals(s:Number):Vector{
x = (x * s);
y = (y * s);
return (this);
}
public function mult(s:Number):Vector{
return (new Vector((x * s), (y * s)));
}
}
}//package org.cove.ape
Section 45
//VectorForce (org.cove.ape.VectorForce)
package org.cove.ape {
public class VectorForce implements IForce {
private var fvx:Number;
private var fvy:Number;
private var value:Vector;
private var scaleMass:Boolean;
public function VectorForce(useMass:Boolean, vx:Number, vy:Number){
super();
fvx = vx;
fvy = vy;
scaleMass = useMass;
value = new Vector(vx, vy);
}
public function set vx(x:Number):void{
fvx = x;
value.x = x;
}
public function set vy(y:Number):void{
fvy = y;
value.y = y;
}
public function set useMass(b:Boolean):void{
scaleMass = b;
}
public function getValue(invmass:Number):Vector{
if (scaleMass){
value.setTo((fvx * invmass), (fvy * invmass));
};
return (value);
}
}
}//package org.cove.ape
Section 46
//SplashScreen_26 (tiles_fla.SplashScreen_26)
package tiles_fla {
import flash.display.*;
import fl.transitions.easing.*;
import fl.transitions.*;
public dynamic class SplashScreen_26 extends MovieClip {
public var myTween2:Tween;
public var gametitle:MovieClip;
public var gametitleball:MovieClip;
public function SplashScreen_26(){
super();
addFrameScript(0, frame1);
}
function frame1(){
myTween2 = new Tween(this.gametitleball, "y", Bounce.easeOut, -200, -44, 2, true);
}
}
}//package tiles_fla
Section 47
//Aha (Aha)
package {
import flash.text.*;
public dynamic class Aha extends Font {
public function Aha(){
super();
}
}
}//package
Section 48
//blipSound (blipSound)
package {
import flash.media.*;
public dynamic class blipSound extends Sound {
public function blipSound(){
super();
}
}
}//package
Section 49
//bumpSound (bumpSound)
package {
import flash.media.*;
public dynamic class bumpSound extends Sound {
public function bumpSound(){
super();
}
}
}//package
Section 50
//Button_disabledSkin (Button_disabledSkin)
package {
import flash.display.*;
public dynamic class Button_disabledSkin extends MovieClip {
public function Button_disabledSkin(){
super();
}
}
}//package
Section 51
//Button_downSkin (Button_downSkin)
package {
import flash.display.*;
public dynamic class Button_downSkin extends MovieClip {
public function Button_downSkin(){
super();
}
}
}//package
Section 52
//Button_emphasizedSkin (Button_emphasizedSkin)
package {
import flash.display.*;
public dynamic class Button_emphasizedSkin extends MovieClip {
public function Button_emphasizedSkin(){
super();
}
}
}//package
Section 53
//Button_overSkin (Button_overSkin)
package {
import flash.display.*;
public dynamic class Button_overSkin extends MovieClip {
public function Button_overSkin(){
super();
}
}
}//package
Section 54
//Button_selectedDisabledSkin (Button_selectedDisabledSkin)
package {
import flash.display.*;
public dynamic class Button_selectedDisabledSkin extends MovieClip {
public function Button_selectedDisabledSkin(){
super();
}
}
}//package
Section 55
//Button_selectedDownSkin (Button_selectedDownSkin)
package {
import flash.display.*;
public dynamic class Button_selectedDownSkin extends MovieClip {
public function Button_selectedDownSkin(){
super();
}
}
}//package
Section 56
//Button_selectedOverSkin (Button_selectedOverSkin)
package {
import flash.display.*;
public dynamic class Button_selectedOverSkin extends MovieClip {
public function Button_selectedOverSkin(){
super();
}
}
}//package
Section 57
//Button_selectedUpSkin (Button_selectedUpSkin)
package {
import flash.display.*;
public dynamic class Button_selectedUpSkin extends MovieClip {
public function Button_selectedUpSkin(){
super();
}
}
}//package
Section 58
//Button_upSkin (Button_upSkin)
package {
import flash.display.*;
public dynamic class Button_upSkin extends MovieClip {
public function Button_upSkin(){
super();
}
}
}//package
Section 59
//CAbout (CAbout)
package {
import fl.controls.*;
import flash.display.*;
import flash.events.*;
public class CAbout extends MovieClip {
public var nextButton:Button;
public var okButton:Button;
public var prevButton:Button;
public var helppanel:CHelp;
private var Parent:CSplashText;
public function CAbout(_Parent:CSplashText=null){
super();
addFrameScript(0, frame1);
helppanel.gotoAndStop(1);
prevButton.addEventListener(MouseEvent.CLICK, prevframe);
nextButton.addEventListener(MouseEvent.CLICK, nextframe);
__setProp_nextButton_CAbout_buttons_1();
__setProp_prevButton_CAbout_buttons_1();
__setProp_okButton_CAbout_buttons_1();
}
public function next(e:MouseEvent){
nextButton.removeEventListener("click", next);
this.nextFrame();
}
public function prevframe(e:MouseEvent){
helppanel.prevFrame();
}
public function prev(e:MouseEvent){
prevButton.removeEventListener("click", prev);
this.prevFrame();
}
function __setProp_okButton_CAbout_buttons_1(){
okButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
okButton.emphasized = false;
okButton.enabled = true;
okButton.label = "";
okButton.labelPlacement = "left";
okButton.selected = false;
okButton.toggle = false;
okButton.visible = true;
okButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
public function nextframe(e:MouseEvent){
helppanel.nextFrame();
}
function frame1(){
this.stop();
nextButton.addEventListener("click", next);
}
function __setProp_prevButton_CAbout_buttons_1(){
prevButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
prevButton.emphasized = false;
prevButton.enabled = true;
prevButton.label = "";
prevButton.labelPlacement = "right";
prevButton.selected = false;
prevButton.toggle = false;
prevButton.visible = true;
prevButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
function __setProp_nextButton_CAbout_buttons_1(){
nextButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
nextButton.emphasized = false;
nextButton.enabled = true;
nextButton.label = "";
nextButton.labelPlacement = "right";
nextButton.selected = false;
nextButton.toggle = false;
nextButton.visible = true;
nextButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
}
}//package
Section 60
//CBall (CBall)
package {
import flash.display.*;
import org.cove.ape.*;
import flash.events.*;
import caurina.transitions.*;
import flash.utils.*;
import flash.filters.*;
import flash.media.*;
import flash.geom.*;
public class CBall extends Group {
public var forceVector:VectorForce;
public var Ball:CircleParticle;
private var dropshadowfilter:DropShadowFilter;
private var stretchsound:stretchSound;
public var isBallOut:Boolean;
private var glowfilter:GlowFilter;
private var speed:Sprite;
private var evtTimer1:Timer;
private var evtTimer2:Timer;
private var evtTimer3:Timer;
public var isForcible:Boolean;
public var isAnimating:Boolean;
public var isStageComplete:Boolean;
private var hitsound:hitHardSound;
public var glowingCircle:Sprite;
public var isStageIncomplete:Boolean;
public var spriteBall:Sprite;
private var previousBlinkerColor:Number;
private var bevel:BevelFilter;
public var isTimeOver:Boolean;
public var radius:Number;
public var isStuck:Boolean;
public var forceMagnitudeCorrection:Number;
public var plussymbol:plusSymbol;
private var dsf:DropShadowFilter;
private var Parent:CMap;
public var isActive:Boolean;
private var NumOfSteadyFrames;
public var blueCircle:CBlueCircle;
private var collidingHole:CHole;
public var invisibleCircle:Sprite;
public var isSelected:Boolean;
private var code:Number;
public var isCloseToFinish:Boolean;
public function CBall(_Parent:CMap, _X:Number, _Y:Number, _radius:Number){
var abstract:Sprite;
super();
Parent = _Parent;
radius = _radius;
dsf = new DropShadowFilter();
dsf.strength = 0.5;
glowfilter = new GlowFilter();
glowfilter.strength = 10;
glowfilter.blurX = 25;
glowfilter.blurY = 25;
glowfilter.color = 13975057;
getSpriteBlueCircle();
Ball = new CircleParticle(_X, _Y, radius, false, 1, 0.4, 0);
Ball.sprite.name = "ball";
abstract = new Sprite();
abstract.addChild(getSpriteGlowingCircle());
abstract.addChild(getSpriteInvisibleCircle());
abstract.addChild(getSpriteBall());
abstract.addChild(getSpriteSymbol());
Ball.setDisplay(abstract);
addParticle(Ball);
collideInternal = true;
forceMagnitudeCorrection = ((29.70806 + (0.02925445 * Parent.FORCECONSTANT)) - ((1.254259E-6 * Parent.FORCECONSTANT) * Parent.FORCECONSTANT));
forceMagnitudeCorrection = (29.70806 + (0.01525445 * Parent.FORCECONSTANT));
forceVector = new VectorForce(true, (Math.random() * 1), (Math.random() * 1));
Ball.addForce(forceVector);
NumOfSteadyFrames = 0;
isSelected = false;
isStageComplete = false;
isStageIncomplete = false;
isBallOut = false;
isTimeOver = false;
isStuck = false;
isAnimating = false;
isCloseToFinish = false;
isForcible = true;
enableMouseEvents();
hitsound = new hitHardSound();
stretchsound = new stretchSound();
Ball.addEventListener(CollisionEvent.COLLIDE, onCollision);
}
public function isMoving():Boolean{
var moving:Boolean;
var velocity:Number;
moving = true;
velocity = Math.sqrt(((Ball.velocity.x * Ball.velocity.x) + (Ball.velocity.y * Ball.velocity.y)));
if ((((velocity < 1)) && ((NumOfSteadyFrames < 20)))){
NumOfSteadyFrames++;
} else {
if ((((velocity < 1)) && ((NumOfSteadyFrames >= 20)))){
if ((((spriteBall.numChildren == 0)) && ((spriteBall.numChildren < 2)))){
spriteBall.addChild(blueCircle);
};
isActive = true;
} else {
if ((((velocity >= 1)) && ((NumOfSteadyFrames > 0)))){
if (spriteBall.numChildren > 0){
spriteBall.removeChildAt(0);
};
NumOfSteadyFrames = 0;
isActive = false;
};
};
};
if (velocity < 0.02){
moving = false;
};
return (moving);
}
private function onCollision(evt:CollisionEvent):void{
var bump:bumpSound;
var collided:*;
var color:ColorTransform;
bump = new bumpSound();
Parent.secondAudioChannel.stop();
Parent.secondAudioChannel = bump.play(0);
Parent.secondAudioChannel.soundTransform = new SoundTransform(0.2);
collided = evt.collidingItem.sprite.name;
if (collided.search("theHole") > -1){
Parent.pauseGame();
animateDrop(evt.collidingItem);
color = Parent.scoreboard.pointsProgressBlinker.transform.colorTransform;
if (collided.search("red") > -1){
var _local5 = Parent.holeCount;
var _local6:int;
var _local7 = (_local5[_local6] + 1);
_local5[_local6] = _local7;
Parent.levelScore = (Parent.levelScore + 100);
color.color = 11796737;
Parent.scoreboard.pointsProgressBlinker.transform.colorTransform = color;
};
if (collided.search("grn") > -1){
_local5 = Parent.holeCount;
_local6 = 1;
_local7 = (_local5[_local6] + 1);
_local5[_local6] = _local7;
Parent.levelScore = (Parent.levelScore + 75);
color.color = 1337091;
Parent.scoreboard.pointsProgressBlinker.transform.colorTransform = color;
};
if (collided.search("blu") > -1){
_local5 = Parent.holeCount;
_local6 = 2;
_local7 = (_local5[_local6] + 1);
_local5[_local6] = _local7;
Parent.levelScore = (Parent.levelScore + 50);
color.color = 149101;
Parent.scoreboard.pointsProgressBlinker.transform.colorTransform = color;
};
Parent.scoreboard.score_point5.text = String(Parent.levelScore);
color.color = 40189;
Parent.scoreboard.bonusProgressBlinker.transform.colorTransform = color;
Parent.scoreboard.bonusProgressBlinker.alpha = 0.2;
isAnimating = true;
evtTimer2 = new Timer(10);
evtTimer2.addEventListener(TimerEvent.TIMER, animateBonus);
evtTimer2.start();
};
if (collided == "minus"){
if (((!(isStuck)) && (isForcible))){
Ball.velocity = new Vector(0, 0);
Ball.fixed = true;
if ((((spriteBall.numChildren == 0)) && ((spriteBall.numChildren < 2)))){
spriteBall.addChild(blueCircle);
blueCircle.play();
};
isStuck = !(isStuck);
} else {
isStuck = !(isStuck);
};
};
}
public function disableMouseEvents(){
spriteBall.removeEventListener(MouseEvent.MOUSE_DOWN, selectBall);
plussymbol.removeEventListener(MouseEvent.MOUSE_DOWN, selectBall);
}
private function selectBall(e:MouseEvent){
spriteBall.removeEventListener(MouseEvent.MOUSE_DOWN, selectBall);
plussymbol.removeEventListener(MouseEvent.MOUSE_DOWN, selectBall);
isSelected = true;
invisibleCircle.addEventListener(MouseEvent.MOUSE_MOVE, prepareBallForRelease);
invisibleCircle.addEventListener(MouseEvent.MOUSE_UP, releaseBall);
}
private function delayforces(e:TimerEvent){
evtTimer3.removeEventListener(TimerEvent.TIMER, delayforces);
isForcible = true;
}
private function getSpriteSymbol():plusSymbol{
var c:ColorTransform;
var d:Number;
c = new ColorTransform();
c.color = 0x444444;
d = (radius * 1.5);
plussymbol = new plusSymbol();
plussymbol.transform.colorTransform = c;
plussymbol.width = ((d * 2) / 4);
plussymbol.height = ((d * 2) / 4);
plussymbol.x = (-(plussymbol.width) / 2);
plussymbol.y = (-(plussymbol.height) / 2);
plussymbol.mouseEnabled = true;
plussymbol.buttonMode = true;
plussymbol.useHandCursor = true;
return (plussymbol);
}
private function prepareBallForRelease(e:MouseEvent){
if (isSelected == true){
setArrow(e);
};
}
private function getSpriteBall():Sprite{
var matrix:Matrix;
var spreadMethod:String;
var colors:Array;
spriteBall = new Sprite();
matrix = new Matrix();
spreadMethod = SpreadMethod.PAD;
matrix.createGradientBox((radius * 2.1), (radius * 2), (0.5 * Math.PI), -(radius), (-(radius) * 1.5));
colors = [0xFFFFFF, 0x333333];
spriteBall.graphics.beginGradientFill("radial", colors, [1, 1], [0, 0xFF], matrix, spreadMethod);
spriteBall.graphics.drawCircle(0, 0, radius);
spriteBall.graphics.endFill();
dropshadowfilter = new DropShadowFilter((radius / 2), 45, 0x888888, 1, radius, radius, 1, 1, false, false, false);
bevel = new BevelFilter();
bevel.blurX = 20;
bevel.blurY = 20;
bevel.angle = 0;
bevel.distance = 3;
spriteBall.filters = [];
spriteBall.mouseEnabled = true;
spriteBall.useHandCursor = true;
spriteBall.buttonMode = true;
return (spriteBall);
}
private function animateDrop(Item:AbstractItem){
var drop:dropSound;
drop = new dropSound();
if ((Item is CHole)){
collidingHole = (Item as CHole);
Ball.position = new Vector(collidingHole.X, collidingHole.Y);
spriteBall.x = collidingHole.X;
spriteBall.y = collidingHole.Y;
Tweener.addTween(collidingHole.spriteHole, {width:0, height:0, time:1});
Parent.previousBallX = collidingHole.X;
Parent.previousBallY = collidingHole.Y;
};
Parent.secondAudioChannel = drop.play(0);
Parent.secondAudioChannel.soundTransform = new SoundTransform(0.5);
Tweener.addTween(spriteBall, {alpha:0, time:1, transition:"easeInOut"});
if (Parent.holeGroup.particles.length == 1){
Parent.tertiaryAudioChannel.stop();
};
Ball.fixed = true;
evtTimer1 = new Timer(2500);
evtTimer1.addEventListener(TimerEvent.TIMER, clearHoleAfterDrop);
evtTimer1.start();
Parent.clearBall();
Parent.clearShadows();
}
private function getSpriteGlowingCircle():Sprite{
glowingCircle = new Sprite();
glowingCircle.graphics.beginFill(14809359);
glowingCircle.graphics.drawCircle(0, 0, 5);
glowingCircle.graphics.endFill();
glowingCircle.alpha = 0.35;
glowingCircle.cacheAsBitmap = true;
return (glowingCircle);
}
public function defocusBall(e:TimerEvent){
evtTimer2.removeEventListener(TimerEvent.TIMER, defocusBall);
spriteBall.addEventListener(MouseEvent.MOUSE_OVER, focusBall);
}
private function releaseBall(e:MouseEvent){
isForcible = false;
blueCircle.stop();
Parent.secondAudioChannel.stop();
Parent.secondAudioChannel = hitsound.play(0);
Parent.secondAudioChannel.soundTransform = new SoundTransform((code / 6));
Parent.hits = 0;
invisibleCircle.removeEventListener(MouseEvent.MOUSE_MOVE, prepareBallForRelease);
invisibleCircle.removeEventListener(MouseEvent.MOUSE_UP, releaseBall);
enableMouseEvents();
isSelected = false;
resetArrow();
Ball.fixed = false;
Ball.addForce(forceVector);
evtTimer3 = new Timer(200);
evtTimer3.addEventListener(TimerEvent.TIMER, delayforces);
evtTimer3.start();
}
private function getSpriteInvisibleCircle():Sprite{
invisibleCircle = new Sprite();
invisibleCircle.graphics.beginFill(0x333333);
invisibleCircle.graphics.drawCircle(0, 0, 500);
invisibleCircle.graphics.endFill();
invisibleCircle.alpha = 0;
return (invisibleCircle);
}
public function enableMouseEvents(){
spriteBall.addEventListener(MouseEvent.MOUSE_DOWN, selectBall);
plussymbol.addEventListener(MouseEvent.MOUSE_DOWN, selectBall);
}
public function isInsideMap(){
if ((((((((Ball.position.x > Parent.boundaryXright)) || ((Ball.position.x < Parent.boundaryXleft)))) || ((Ball.position.y < Parent.boundaryYup)))) || ((Ball.position.y > Parent.boundaryYdown)))){
isBallOut = true;
};
}
private function animateBonus(e:TimerEvent){
var percent:Number;
var color:ColorTransform;
percent = (Parent.scoreboard.percenttimeprogress - 0.01);
if (percent > 0){
Parent.levelBonus = (Parent.levelBonus + 1);
Parent.scoreboard.updateProgress(percent, isCloseToFinish);
Parent.scoreboard.score_bonus.text = String(Parent.levelBonus);
} else {
isAnimating = false;
evtTimer2.removeEventListener(TimerEvent.TIMER, animateBonus);
color = Parent.scoreboard.pointsProgressBlinker.transform.colorTransform;
color.color = 0;
Parent.scoreboard.pointsProgressBlinker.transform.colorTransform = color;
Parent.scoreboard.bonusProgressBlinker.transform.colorTransform = color;
};
}
private function setArrow(e:MouseEvent){
var location:Point;
var yy:Number;
var xx:Number;
var dist:Number;
var angle:Number;
var adj:Number;
var bv:BevelFilter;
var arrow:Sprite;
var dist2:Number;
location = new Point(Ball.position.x, Ball.position.y);
location = e.target.localToGlobal(location);
yy = e.target.mouseY;
xx = e.target.mouseX;
dist = Math.sqrt(((yy * yy) + (xx * xx)));
angle = Math.atan2(yy, xx);
if (spriteBall.numChildren > 0){
spriteBall.removeChildAt(0);
};
if (speed != null){
Parent.removeChild(speed);
speed = null;
};
if (isActive){
dist = Math.min(dist, (6.5 * radius));
} else {
dist = Math.min(dist, (2.5 * radius));
};
Parent.secondAudioChannel.stop();
Parent.secondAudioChannel = stretchsound.play(0);
Parent.secondAudioChannel.soundTransform = new SoundTransform(Math.pow((dist / (7 * radius)), 2));
code = Math.round(((dist / radius) - 2));
if (code >= 0){
adj = ((Math.max(dist, 3) / 1.05) - 2);
if ((dist > radius)){
bv = new BevelFilter();
arrow = new Sprite();
arrow.graphics.moveTo(((radius + 0) * Math.cos(angle)), ((radius + 0) * Math.sin(angle)));
arrow.graphics.lineStyle(2, 0xFF0000);
arrow.graphics.lineTo((adj * Math.cos(angle)), (adj * Math.sin(angle)));
arrow.name = "arrow";
spriteBall.addChild(arrow);
speed = new Sprite();
speed.graphics.moveTo(-236, 116);
speed.graphics.lineStyle(7, 0xFF0000);
speed.graphics.lineTo((-236 + (((234 + 236) * dist) / (6.5 * radius))), 116);
speed.alpha = 0.6;
speed.filters = [bv];
speed.name = "speed";
Parent.addChild(speed);
if (code < 6){
glowingCircle.filters = [];
} else {
glowingCircle.filters = [glowfilter];
};
glowingCircle.visible = true;
glowingCircle.width = (adj * 2);
glowingCircle.height = (adj * 2);
dist2 = Math.pow(dist, 1.2);
dist2 = (dist2 + forceMagnitudeCorrection);
forceVector.vx = (dist2 * Math.cos(angle));
forceVector.vy = (dist2 * Math.sin(angle));
};
};
}
private function clearHoleAfterDrop(e:TimerEvent){
Parent.holeGroup.removeParticle(collidingHole);
if (Parent.holeGroup.particles.length == 0){
isStageComplete = true;
} else {
Parent.drawBall(Parent.previousBallX, Parent.previousBallY);
Parent.blockGroup.addCollidable(Parent.ballGroup);
Parent.holeGroup.addCollidable(Parent.ballGroup);
};
Parent.resumeStage(null);
evtTimer1.removeEventListener(TimerEvent.TIMER, clearHoleAfterDrop);
}
public function delayedDefocusBall(e:MouseEvent){
blueCircle.filters = [];
spriteBall.removeEventListener(MouseEvent.MOUSE_OUT, delayedDefocusBall);
}
public function focusBall(e:MouseEvent){
if (spriteBall.numChildren > 0){
spriteBall.removeChildAt(0);
};
spriteBall.removeEventListener(MouseEvent.MOUSE_OVER, focusBall);
spriteBall.addEventListener(MouseEvent.MOUSE_OUT, delayedDefocusBall);
}
private function resetArrow(){
glowingCircle.visible = false;
glowingCircle.width = 1;
glowingCircle.height = 1;
if (spriteBall.numChildren > 0){
spriteBall.removeChild(spriteBall.getChildAt(0));
};
if (speed != null){
Parent.removeChild(speed);
speed = null;
};
}
private function getSpriteBlueCircle():void{
blueCircle = new CBlueCircle();
blueCircle.name = "blueCircle";
}
}
}//package
Section 61
//CBlock (CBlock)
package {
import flash.display.*;
import org.cove.ape.*;
import flash.filters.*;
import flash.geom.*;
public class CBlock extends RectangleParticle {
public var gradcolor1:Number;
public var X:Number;
public var Y:Number;
public var d:Number;
private var forceConstant:Number;
public var charge:Number;
public var spriteBlock:Sprite;
public var blockBevelFilter:BevelFilter;
public var code:Number;
public var gradcolor2:Number;
public function CBlock(_X:Number, _Y:Number, _d:Number, _fixed:Boolean, _polarity:Number, _charge:Number, _forceConstant:Number){
X = _X;
Y = _Y;
d = _d;
forceConstant = _forceConstant;
super(X, Y, d, d, 0);
fixed = _fixed;
mass = 1;
friction = 0;
code = _polarity;
charge = _charge;
switch (code){
case 1:
gradcolor1 = 5868576;
gradcolor2 = 10995822;
elasticity = 0.4;
sprite.name = "neutral";
charge = 0;
break;
case 2:
gradcolor1 = 13975057;
gradcolor2 = 15240996;
elasticity = 0;
sprite.name = "plus";
charge = Math.abs(charge);
break;
case 3:
gradcolor1 = 1584994;
gradcolor2 = 3368601;
elasticity = 0;
sprite.name = "minus";
charge = -(Math.abs(charge));
break;
case 4:
sprite.name = "spring";
gradcolor1 = 0xE49B00;
gradcolor2 = 16510212;
elasticity = 1;
charge = 0;
break;
case 5:
sprite.name = "mobile";
gradcolor1 = 11077383;
gradcolor2 = 14846602;
elasticity = 0.6;
charge = 0;
fixed = false;
break;
};
blockBevelFilter = new BevelFilter((d / 100), 45, 0xFFFFFF, 0.8, 0, 1, (d / 10), (d / 10), 2, 1, "inner", false);
setDisplay(getSpriteBlock());
}
private function getSpriteBlock():Sprite{
var matrix:Matrix;
var spreadMethod:String;
var colors:Array;
var _local4:ColorTransform;
var _local5:plusSymbol;
var _local6:Sprite;
spriteBlock = new Sprite();
matrix = new Matrix();
spreadMethod = SpreadMethod.PAD;
colors = [gradcolor2, gradcolor1];
matrix.createGradientBox(d, d, (0.5 * Math.PI), (-(d) / 2), (-(d) / 2));
spriteBlock.graphics.beginGradientFill("linear", colors, [1, 1], [0, 0xFF], matrix, spreadMethod);
spriteBlock.graphics.drawRoundRect((-(d) / 2), (-(d) / 2), d, d, (d / 3), (d / 3));
spriteBlock.graphics.endFill();
spriteBlock.filters = [blockBevelFilter];
switch (code){
case 1:
break;
case 2:
_local4 = new ColorTransform();
_local4.color = 13975057;
_local5 = new plusSymbol();
_local5.transform.colorTransform = _local4;
_local5.width = ((d * 2) / 4);
_local5.height = ((d * 2) / 4);
_local5.x = (-(_local5.width) / 2);
_local5.y = (-(_local5.height) / 2);
spriteBlock.addChild(_local5);
break;
case 3:
_local6 = new Sprite();
_local6.graphics.beginFill(gradcolor1);
_local6.graphics.drawRect((-(d) / 5), -1, ((2 * d) / 5), (d / 10));
_local6.graphics.endFill();
spriteBlock.addChild(_local6);
break;
case 4:
break;
case 5:
break;
};
return (spriteBlock);
}
public function getBallComponentForce(ball:CircleParticle):Array{
var r:*;
var r2:*;
var angle:*;
var Fx:Number;
var Fy:Number;
var F:Array;
r = Math.sqrt((((ball.position.x - position.x) * (ball.position.x - position.x)) + ((ball.position.y - position.y) * (ball.position.y - position.y))));
r = (r - (d / 2));
r2 = (r * r);
angle = Math.atan2((ball.position.y - position.y), (ball.position.x - position.x));
Fx = (((forceConstant * charge) / r2) * Math.cos(angle));
Fy = (((forceConstant * charge) / r2) * Math.sin(angle));
F = new Array(Fx, Fy);
return (F);
}
}
}//package
Section 62
//CBlueCircle (CBlueCircle)
package {
import flash.display.*;
public dynamic class CBlueCircle extends MovieClip {
public function CBlueCircle(){
super();
}
}
}//package
Section 63
//CHelp (CHelp)
package {
import flash.display.*;
public dynamic class CHelp extends MovieClip {
public function CHelp(){
super();
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4, 4, frame5);
}
function frame3(){
stop();
}
function frame1(){
stop();
}
function frame4(){
stop();
}
function frame5(){
stop();
}
function frame2(){
stop();
}
}
}//package
Section 64
//CHole (CHole)
package {
import flash.display.*;
import org.cove.ape.*;
import flash.filters.*;
import flash.geom.*;
public class CHole extends RectangleParticle {
public var spriteHole:Sprite;
public var X:Number;
public var Y:Number;
private var color:Number;
public var d:Number;
private var ballRadius:Number;
private var Parent:CMap;
public var points:Number;
public var code:Number;
public function CHole(_Parent:CMap, _X:Number, _Y:Number, _d:Number, _code:Number){
Parent = _Parent;
X = _X;
Y = _Y;
d = _d;
code = _code;
ballRadius = (d / 3);
switch (code){
case 1:
color = 149101;
sprite.name = "theHole-blu";
points = 50;
break;
case 2:
color = 1337091;
sprite.name = "theHole-grn";
points = 75;
break;
case 3:
color = 11796737;
sprite.name = "theHole-red";
points = 100;
break;
};
super(X, Y, ((ballRadius * 2) / 5), 1, 0, true);
setDisplay(getSpriteHole());
}
private function getSpriteHole():Sprite{
var matrix:Matrix;
var spreadMethod:String;
var colors:Array;
spriteHole = new Sprite();
matrix = new Matrix();
spreadMethod = SpreadMethod.PAD;
colors = [0xFFFFFF, color];
matrix.createGradientBox(d, d, (0.5 * Math.PI), (0 - (d / 2)), 0);
spriteHole.graphics.beginGradientFill("radial", colors, [1, 1], [0, 0xFF], matrix, spreadMethod);
spriteHole.graphics.drawCircle(0, 0, (d / 2.5));
spriteHole.graphics.endFill();
spriteHole.filters = [new DropShadowFilter((d / 8), 90, 0x111111, 1, (d / 2), (d / 2), 1, 1, true, false, false)];
return (spriteHole);
}
}
}//package
Section 65
//clkSound (clkSound)
package {
import flash.media.*;
public dynamic class clkSound extends Sound {
public function clkSound(){
super();
}
}
}//package
Section 66
//CMap (CMap)
package {
import flash.display.*;
import org.cove.ape.*;
import flash.events.*;
import flash.utils.*;
import flash.filters.*;
import flash.media.*;
import flash.ui.*;
public class CMap extends MovieClip {
private var chargedBlockArray:Array;
public var offsetX:Number;
public var offsetY:Number;
public var totalHolePoints:Number;
private var startButton:CStartButton;
public var holeCount:Array;
public var splashText:CSplashText;
private var tileArray:Array;
public var boundaryYup:Number;
public var msgText:CMsgText;
private var STARTLEVEL;// = 1
public var isMute:Boolean;
public var boundaryXleft:Number;
private var mapXtiles:Number;
public var boundaryYdown:Number;
private var mutebutton:muteButton;
public var MAXLEVEL;
private var movingBlockArray:Array;
public var eventTimer:Timer;
public var playTimeDuration:Number;
public var secondAudioChannel:SoundChannel;
public var INITIALHOLES;
private var DAMPING;// = 0.991
public var resumeText:CSplashText;
public var levelBonus:Number;
private var shadowArray:Array;
public var clk:clkSound;
public var tileLength:Number;
public var requiredNumberOfHoles:Number;
private var secondaryMap:Array;
public var timeMap:Number;
public var playStopTime:Number;
private var mapYtiles:Number;
public var hits:Number;
public var LEVEL;
public var mapCode:Number;
public var boundaryXright:Number;
public var primaryAudioChannel:SoundChannel;
public var ballRadius:Number;
public var attempts:Number;
public var levelScore:Number;
public var FORCECONSTANT:Number;// = 2500
private var holeArray:Array;
public var previousBallX;
public var previousBallY;
public var playStartTime:Number;
public var scoreboard:CScoreBoard;
private var about:CAbout;
public var holeGroup:Group;
public var mapHeight:Number;
private var FRAMERATE;// = 0.16
public var totalNumberOfHoles:Number;
public var tileSpacing:Number;
public var totalScore:Number;
public var ballGroup:CBall;
public var theme:themeSound;
public var mapWidth:Number;
public var tertiaryAudioChannel:SoundChannel;
private var resumeButton:CStartButton;
public var allMaps:Array;
public var remainingTime:Number;
public var blockGroup:Group;
private var primaryMap:Array;
public function CMap(){
FORCECONSTANT = 2500;
STARTLEVEL = 1;
FRAMERATE = (1 / 6.25);
DAMPING = 0.991;
super();
addFrameScript(0, frame1);
shadowArray = new Array();
allMaps = getMaps();
MAXLEVEL = allMaps.length;
LEVEL = STARTLEVEL;
primaryMap = allMaps[(LEVEL - 1)][0];
secondaryMap = allMaps[(LEVEL - 1)][1];
mapXtiles = primaryMap[0].length;
mapYtiles = primaryMap.length;
attempts = 1;
loadStageParams();
loadStartButton();
totalScore = 0;
isMute = false;
clk = new clkSound();
theme = new themeSound();
primaryAudioChannel = new SoundChannel();
secondAudioChannel = new SoundChannel();
tertiaryAudioChannel = new SoundChannel();
}
private function updateTimes():void{
var blip:blipSound;
playStopTime = getTimer();
playTimeDuration = (playStopTime - playStartTime);
playTimeDuration = (Math.round((playTimeDuration / 100)) / 10);
remainingTime = (timeMap - playTimeDuration);
if ((((remainingTime < 10)) && (!(ballGroup.isCloseToFinish)))){
blip = new blipSound();
tertiaryAudioChannel = blip.play(0, 10);
tertiaryAudioChannel.soundTransform = new SoundTransform(0.5);
ballGroup.isCloseToFinish = true;
};
if (remainingTime < 0){
ballGroup.isTimeOver = true;
};
}
private function applyShadows(){
var px:Number;
var py:Number;
var shadow:Sprite;
px = ballGroup.particles[0].px;
py = ballGroup.particles[0].py;
if (ballGroup.isMoving()){
shadow = new Sprite();
shadow.graphics.beginFill(40189);
shadow.graphics.drawCircle(px, py, (ballRadius / 10));
shadow.graphics.endFill();
shadow.alpha = 0.5;
addChild(shadow);
shadowArray.push(shadow);
if (shadowArray.length > 35){
removeChild(shadowArray[0]);
shadowArray.shift();
};
} else {
clearShadows();
};
}
public function showHeaderForNextStage(e:MouseEvent){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, startEscapeSequence);
clearMsgButton();
loadMap(LEVEL);
if (requiredNumberOfHoles < totalNumberOfHoles){
loadMsgButton("", ((("You must clear atleast " + requiredNumberOfHoles) + " holes to complete level") + LEVEL), "", "Continue", true, true, false);
} else {
loadMsgButton("", ((("You must clear all " + requiredNumberOfHoles) + " holes to complete level") + LEVEL), "", "Continue", true, true, false);
};
clearMap();
msgText.yesButton.addEventListener("click", gotoNextStage);
msgText.noButton1.addEventListener("click", loadStartButton);
}
private function addEffectsToBlocks(){
var dist:Number;
var dy:Number;
var dx:Number;
var glow:GlowFilter;
var i:*;
glow = new GlowFilter();
glow.alpha = 0.6;
i = 0;
while (i < chargedBlockArray.length) {
dy = (chargedBlockArray[i].position.y - ballGroup.particles[0].position.y);
dx = (chargedBlockArray[i].position.x - ballGroup.particles[0].position.x);
dist = Math.sqrt(((dy * dy) + (dx * dx)));
if (dist <= (ballRadius * 5)){
glow.strength = 8;
glow.blurX = 64;
glow.blurY = 64;
if (chargedBlockArray[i].sprite.name == "minus"){
glow.color = 11265790;
} else {
if (chargedBlockArray[i].sprite.name == "plus"){
glow.color = 16707440;
};
};
chargedBlockArray[i].spriteBlock.filters = [glow];
} else {
if ((((dist > (ballRadius * 5))) && ((dist <= (ballRadius * 10))))){
glow.strength = 5;
glow.blurX = 16;
glow.blurY = 16;
if (chargedBlockArray[i].sprite.name == "minus"){
glow.color = 11265790;
} else {
if (chargedBlockArray[i].sprite.name == "plus"){
glow.color = 16707440;
};
};
chargedBlockArray[i].spriteBlock.filters = [glow];
} else {
chargedBlockArray[i].spriteBlock.filters = [chargedBlockArray[i].blockBevelFilter];
};
};
i++;
};
}
private function drawHole(){
var theHoleX:Number;
var theHoleY:Number;
var i:*;
var j:*;
var hole:CHole;
holeGroup = new Group();
holeGroup.collideInternal = true;
holeArray = new Array();
INITIALHOLES = 0;
totalHolePoints = 0;
i = 1;
while (i <= mapXtiles) {
j = 1;
while (j <= mapYtiles) {
if (secondaryMap[(j - 1)][(i - 1)] > 0){
INITIALHOLES++;
switch (secondaryMap[(j - 1)][(i - 1)]){
case 1:
totalHolePoints = (totalHolePoints + 50);
break;
case 2:
totalHolePoints = (totalHolePoints + 75);
break;
case 3:
totalHolePoints = (totalHolePoints + 100);
break;
};
theHoleX = (offsetX + ((i - 1) * (tileLength + tileSpacing)));
theHoleY = (offsetY + ((j - 1) * (tileLength + tileSpacing)));
hole = new CHole(this, theHoleX, theHoleY, tileLength, secondaryMap[(j - 1)][(i - 1)]);
holeGroup.addParticle(hole);
holeArray.push(holeGroup);
};
j++;
};
i++;
};
APEngine.addGroup(holeGroup);
}
private function revealStartButton(e:MouseEvent){
msgText.yesButton.removeEventListener("click", revealStartButton);
msgText.visible = false;
startButton.visible = true;
startButton.enabled = true;
splashText.visible = true;
splashText.splashButton.addEventListener("click", startGame);
}
private function loadMuteButton(){
mutebutton = new muteButton(this);
mutebutton.x = 135;
mutebutton.y = 98;
addChild(mutebutton);
}
public function restartStage(e:MouseEvent){
clearMsgButton();
clearShadows();
clearBall();
clearMap();
clearHole();
startGame();
}
private function clearScore(){
scoreboard.score_level.text = "0";
scoreboard.score_score.text = "0";
}
public function clearShadows(){
while (shadowArray.length > 0) {
removeChild(shadowArray[0]);
shadowArray.shift();
};
}
private function startEscapeSequence(e:KeyboardEvent){
var key:uint;
key = e.keyCode;
if (key == Keyboard.ESCAPE){
tertiaryAudioChannel = clk.play(0);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, startEscapeSequence);
pauseGame();
loadResumeButton();
};
}
private function clearMsgButton(){
if (msgText != null){
removeChild(msgText);
msgText = null;
};
}
function frame1(){
stop();
}
private function updateScores(flag:Boolean):void{
scoreboard.score_score.text = (remainingTime.toFixed(1) + "s");
if (flag == false){
scoreboard.updateProgress(Math.min((remainingTime / timeMap), 1), ballGroup.isCloseToFinish);
};
}
public function prepareForReplay2(e:TimerEvent){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, startEscapeSequence);
LEVEL = LEVEL;
loadMap(LEVEL);
loadBallCoordinates();
primaryAudioChannel.stop();
clearShadows();
clearBall();
clearMap();
clearHole();
loadMsgButton((("Game Over!. You have " + (3 - attempts)) + " more chances"), ("Score " + ((totalScore + levelScore) + levelBonus)), "", "Retry", true, true, false);
attempts++;
msgText.yesButton.addEventListener("click", restartStage);
msgText.noButton1.addEventListener("click", loadStartButton);
eventTimer.removeEventListener(TimerEvent.TIMER, prepareForReplay);
}
public function loadMap(level){
var i:*;
var j:*;
primaryMap = allMaps[(level - 1)][0];
secondaryMap = allMaps[(level - 1)][1];
timeMap = allMaps[(level - 1)][2][0];
requiredNumberOfHoles = allMaps[(level - 1)][3][0];
mapCode = allMaps[(level - 1)][4][0];
totalNumberOfHoles = 0;
i = 1;
while (i <= mapXtiles) {
j = 1;
while (j <= mapYtiles) {
if (secondaryMap[(j - 1)][(i - 1)] > 0){
totalNumberOfHoles++;
};
j++;
};
i++;
};
}
private function clearResumeButton(){
resumeText.splashButton.removeEventListener("click", resumeStage);
removeChild(resumeButton);
removeChild(resumeText);
resumeButton = null;
resumeText = null;
}
public function clearHole(){
APEngine.removeGroup(holeGroup);
holeGroup = null;
}
public function onEnterFrame(event:Event):void{
var gameover:gameOverSound;
var i:*;
updateTimes();
if (ballGroup != null){
if (((!(ballGroup.isStageComplete)) && (!(ballGroup.isTimeOver)))){
updateScores(ballGroup.isAnimating);
};
applyShadows();
applyForceOnBall(((ballGroup.isMoving()) && (ballGroup.isForcible)));
addEffectsToBlocks();
ballGroup.isInsideMap();
if (((ballGroup.isTimeOver) && (((totalNumberOfHoles - holeGroup.particles.length) < requiredNumberOfHoles)))){
gameover = new gameOverSound();
tertiaryAudioChannel = gameover.play(0);
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
clearShadows();
if (attempts < 3){
eventTimer = new Timer(50, 1);
eventTimer.addEventListener(TimerEvent.TIMER, prepareForReplay);
eventTimer.start();
} else {
LEVEL = 1;
loadMap(LEVEL);
loadBallCoordinates();
eventTimer = new Timer(50, 1);
eventTimer.addEventListener(TimerEvent.TIMER, prepareForFinish);
eventTimer.start();
};
} else {
if (((ballGroup.isTimeOver) && (((totalNumberOfHoles - holeGroup.particles.length) >= requiredNumberOfHoles)))){
ballGroup.isStageComplete = true;
};
};
if (((ballGroup.isBallOut) && (((totalNumberOfHoles - holeGroup.particles.length) < requiredNumberOfHoles)))){
gameover = new gameOverSound();
tertiaryAudioChannel = gameover.play(0);
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
clearShadows();
if (attempts < 3){
eventTimer = new Timer(50, 1);
eventTimer.addEventListener(TimerEvent.TIMER, prepareForReplay2);
eventTimer.start();
} else {
LEVEL = 1;
loadMap(LEVEL);
loadBallCoordinates();
eventTimer = new Timer(50, 1);
eventTimer.addEventListener(TimerEvent.TIMER, prepareForFinish);
eventTimer.start();
};
} else {
if (((ballGroup.isBallOut) && (((totalNumberOfHoles - holeGroup.particles.length) >= requiredNumberOfHoles)))){
ballGroup.isStageComplete = true;
};
};
if (ballGroup.isStageComplete){
pauseGame();
ballGroup.isStageComplete = false;
clearShadows();
if (LEVEL < allMaps.length){
eventTimer = new Timer(50, 1);
eventTimer.addEventListener(TimerEvent.TIMER, prepareForNextStage);
eventTimer.start();
} else {
LEVEL = LEVEL;
loadMap(LEVEL);
loadBallCoordinates();
eventTimer = new Timer(50, 1);
eventTimer.addEventListener(TimerEvent.TIMER, prepareForComplete);
eventTimer.start();
};
};
};
APEngine.step();
ballGroup.paint();
if (holeGroup != null){
holeGroup.paint();
};
if (movingBlockArray.length > 0){
i = 0;
while (i < movingBlockArray.length) {
movingBlockArray[i].paint();
i++;
};
};
}
public function loadBallCoordinates():void{
var i:*;
var j:*;
i = 1;
while (i <= mapXtiles) {
j = 1;
while (j <= mapYtiles) {
if (secondaryMap[(j - 1)][(i - 1)] < 0){
previousBallX = (offsetX + ((i - 1) * (tileLength + tileSpacing)));
previousBallY = (offsetY + ((j - 1) * (tileLength + tileSpacing)));
};
j++;
};
i++;
};
}
private function loadBackground(){
var rowstartcolor:Number;
var color:Number;
var i:*;
var j:*;
var tile:CTile;
rowstartcolor = 8;
tileArray = new Array();
i = 1;
while (i <= mapXtiles) {
if (rowstartcolor == 9){
rowstartcolor = 8;
} else {
if (rowstartcolor == 8){
rowstartcolor = 9;
};
};
color = rowstartcolor;
j = 1;
while (j <= (mapYtiles + 2)) {
tile = new CTile(this, (offsetX + ((i - 1) * (tileLength + tileSpacing))), (offsetY + ((j - 1) * (tileLength + tileSpacing))), tileLength, color);
addChild(tile);
if (color == 9){
color = 8;
} else {
if (color == 8){
color = 9;
};
};
tileArray.push(tile);
j++;
};
i++;
};
}
public function prepareForReplay(e:TimerEvent){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, startEscapeSequence);
LEVEL = LEVEL;
loadMap(LEVEL);
loadBallCoordinates();
primaryAudioChannel.stop();
clearShadows();
clearBall();
clearMap();
clearHole();
loadMsgButton((("Time Out!. You have " + (3 - attempts)) + " more chances"), ("Score " + ((totalScore + levelScore) + levelBonus)), "", "Retry", true, true, false);
attempts++;
msgText.yesButton.addEventListener("click", restartStage);
msgText.noButton1.addEventListener("click", loadStartButton);
eventTimer.removeEventListener(TimerEvent.TIMER, prepareForReplay);
}
public function resumeStage(e:MouseEvent){
if (resumeButton != null){
clearResumeButton();
};
tertiaryAudioChannel = clk.play(0);
clearMuteButton();
loadMuteButton();
if (!isMute){
primaryAudioChannel = theme.play(0, 100000);
primaryAudioChannel.soundTransform = new SoundTransform(0.1);
};
playStartTime = (playStartTime + getTimer());
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, startEscapeSequence);
stage.focus = stage;
}
private function loopSound(e:Event){
primaryAudioChannel = theme.play(0);
primaryAudioChannel.soundTransform = new SoundTransform(0.1);
}
private function clearMuteButton(){
removeChild(mutebutton);
mutebutton = null;
}
public function pauseGame(){
primaryAudioChannel.stop();
playStartTime = (playStartTime - getTimer());
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function getMaps():Array{
var Map1:Array;
var Map2:Array;
var Time:Array;
var stageMapArray:Array;
stageMapArray = new Array();
Map2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
Map1 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,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 1, 1, 1, 0], [0, 0, 1, 0, 0, 2, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 3, 0], [0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0], [0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0], [0, 0, 1, 0, 0, 2, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 3, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
Time = [180];
stageMapArray.push(new Array(Map1, Map2, Time, [1], ["2522"]));
return (stageMapArray);
}
public function loadScoreBoard(){
scoreboard = new CScoreBoard(this);
addChild(scoreboard);
scoreboard.score_score.text = String(remainingTime);
scoreboard.score_level.text = (((("level " + LEVEL) + " [") + mapCode) + "]");
scoreboard.score_score.text = (timeMap + "s");
scoreboard.score_try.visible = true;
if (requiredNumberOfHoles > 1){
scoreboard.score_try.text = (("Clear " + requiredNumberOfHoles) + " holes");
} else {
scoreboard.score_try.text = (("Clear " + requiredNumberOfHoles) + " hole");
};
scoreboard.score_point5.text = String(levelScore);
scoreboard.score_bonus.text = String(levelBonus);
}
private function clearBackground(){
var i:*;
i = 0;
while (i < tileArray.length) {
removeChild(tileArray[i]);
i++;
};
tileArray = [];
}
private function revealStartButtonToExit(){
startButton.visible = true;
splashText.visible = true;
splashText.splashButton.addEventListener("click", startGame);
}
private function loadStageParams(){
stage.showDefaultContextMenu = false;
tileLength = 26.3;
tileSpacing = 0.4;
mapWidth = (mapXtiles * (tileLength + tileSpacing));
mapHeight = (mapYtiles * (tileLength + tileSpacing));
offsetX = (((-(mapWidth) / 2) + (tileLength / 2)) + 0.5);
offsetY = (((-(mapHeight) / 2) - (tileLength / 2)) - 1);
boundaryXleft = (offsetX - (tileLength / 2));
boundaryXright = ((offsetX + mapWidth) - (tileLength / 2));
boundaryYup = (offsetY - (tileLength / 2));
boundaryYdown = (offsetY + mapHeight);
previousBallX = (offsetX + (mapWidth / 2));
previousBallY = ((offsetY + (mapHeight / 2)) + (1 * tileLength));
ballRadius = (tileLength / 2.7);
APEngine.init(FRAMERATE);
APEngine.container = this;
APEngine.damping = DAMPING;
}
public function drawBall(xx:Number, yy:Number){
var vec:Vector;
ballGroup = new CBall(this, xx, yy, ballRadius);
APEngine.addGroup(ballGroup);
vec = new Vector((Math.random() * 2), (Math.random() * 2));
ballGroup.Ball.velocity = vec;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function drawMap(){
var i:*;
var j:*;
var block:CBlock;
blockGroup = new Group();
blockGroup.collideInternal = true;
chargedBlockArray = new Array();
movingBlockArray = new Array();
i = 1;
while (i <= mapXtiles) {
j = 1;
while (j <= mapYtiles) {
if ((((((primaryMap[(j - 1)][(i - 1)] == 1)) || ((primaryMap[(j - 1)][(i - 1)] == 4)))) || ((primaryMap[(j - 1)][(i - 1)] == 5)))){
block = new CBlock((offsetX + ((i - 1) * (tileLength + tileSpacing))), (offsetY + ((j - 1) * (tileLength + tileSpacing))), tileLength, true, primaryMap[(j - 1)][(i - 1)], 1, FORCECONSTANT);
blockGroup.addParticle(block);
if (primaryMap[(j - 1)][(i - 1)] == 5){
movingBlockArray.push(block);
};
};
j++;
};
i++;
};
i = 1;
while (i <= mapXtiles) {
j = 1;
while (j <= mapYtiles) {
if ((((primaryMap[(j - 1)][(i - 1)] == 2)) || ((primaryMap[(j - 1)][(i - 1)] == 3)))){
block = new CBlock((offsetX + ((i - 1) * (tileLength + tileSpacing))), (offsetY + ((j - 1) * (tileLength + tileSpacing))), tileLength, true, primaryMap[(j - 1)][(i - 1)], 1, FORCECONSTANT);
blockGroup.addParticle(block);
chargedBlockArray.push(block);
};
j++;
};
i++;
};
APEngine.addGroup(blockGroup);
}
private function prepareForFinish(e:TimerEvent){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, startEscapeSequence);
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
attempts = 1;
primaryAudioChannel.stop();
clearShadows();
clearBall();
clearMap();
clearHole();
clearScore();
clearScoreBoard();
totalScore = (totalScore + (levelScore + levelBonus));
loadMsgButton("Game Over", ("Score " + totalScore), "", "Ok", false, false, true);
levelScore = 0;
levelBonus = 0;
msgText.noButton2.addEventListener("click", loadStartButton);
eventTimer.removeEventListener(TimerEvent.TIMER, prepareForFinish);
}
private function loadStartButton(e:MouseEvent=null){
clearMsgButton();
startButton = new CStartButton(-90, -110, 200, 228);
addChild(startButton);
splashText = new CSplashText(this);
addChild(splashText);
splashText.splashButton.addEventListener("click", startGame);
}
private function applyForceOnBall(flag:Boolean){
var forceVector1:Array;
var forceVector2:Array;
var ballForceVector:VectorForce;
var dist:Number;
var dy:Number;
var dx:Number;
var i:*;
forceVector2 = new Array(0, 0);
if (flag){
i = 0;
while (i < chargedBlockArray.length) {
forceVector1 = chargedBlockArray[i].getBallComponentForce(ballGroup.particles[0]);
forceVector2[0] = (forceVector2[0] + forceVector1[0]);
forceVector2[1] = (forceVector2[1] + forceVector1[1]);
i++;
};
ballForceVector = new VectorForce(true, forceVector2[0], forceVector2[1]);
ballGroup.particles[0].addForce(ballForceVector);
};
}
private function hideabout(e:MouseEvent){
tertiaryAudioChannel = clk.play(0);
removeChild(about);
about.okButton.removeEventListener("click", hideabout);
about = null;
playStartTime = getTimer();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.focus = stage;
}
public function clearScoreBoard(){
removeChild(scoreboard);
scoreboard = null;
}
private function prepareForComplete(e:TimerEvent){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
LEVEL = 1;
attempts = 1;
primaryAudioChannel.stop();
clearShadows();
clearBall();
clearMap();
clearHole();
clearScore();
clearScoreBoard();
totalScore = (totalScore + (levelScore + levelBonus));
loadMsgButton("You have cleared all levels!!!", ("Score " + totalScore), "", "Ok", false, false, true);
msgText.visible = true;
msgText.noButton2.addEventListener("click", loadStartButton);
eventTimer.removeEventListener(TimerEvent.TIMER, prepareForFinish);
}
private function clearStartButton(){
splashText.splashButton.removeEventListener("click", startGame);
removeChild(startButton);
removeChild(splashText);
startButton = null;
splashText = null;
}
public function gotoNextStage(e:MouseEvent){
clearMsgButton();
clearShadows();
clearBall();
clearMap();
clearHole();
startGame();
}
public function prepareForNextStage(e:TimerEvent){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, startEscapeSequence);
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
LEVEL = (LEVEL + 1);
loadMap(LEVEL);
loadBallCoordinates();
attempts = 1;
primaryAudioChannel.stop();
clearShadows();
clearBall();
clearMap();
clearHole();
totalScore = (totalScore + (levelScore + levelBonus));
loadMsgButton((("Level " + (LEVEL - 1)) + " cleared"), ("Score " + totalScore), "", "Continue", true, true, false);
msgText.yesButton.addEventListener("click", showHeaderForNextStage);
msgText.noButton1.addEventListener("click", loadStartButton);
eventTimer.removeEventListener(TimerEvent.TIMER, prepareForNextStage);
}
public function startGame(e:MouseEvent=null){
var i:Number;
if (scoreboard != null){
clearScore();
clearScoreBoard();
};
if (splashText != null){
if (splashText.mapcode.text != ""){
i = 0;
while (i < allMaps.length) {
if (allMaps[i][4][0] == splashText.mapcode.text){
LEVEL = (i + 1);
break;
};
i++;
};
if (i == allMaps.length){
splashText.mapcode.text = "bad code";
return;
};
};
};
loadMap(LEVEL);
drawHole();
drawMap();
if (attempts > 3){
attempts = 1;
};
hits = 0;
levelScore = 0;
levelBonus = 0;
playTimeDuration = 0;
holeCount = new Array(0, 0, 0);
loadScoreBoard();
loadBallCoordinates();
drawBall(previousBallX, previousBallY);
blockGroup.addCollidable(ballGroup);
holeGroup.addCollidable(ballGroup);
if (mutebutton != null){
clearMuteButton();
};
loadMuteButton();
if (startButton != null){
clearStartButton();
};
tertiaryAudioChannel = clk.play(0);
if (!isMute){
primaryAudioChannel = theme.play(0, 100000);
primaryAudioChannel.soundTransform = new SoundTransform(0.1);
};
stage.addEventListener(KeyboardEvent.KEY_DOWN, startEscapeSequence);
if ((((LEVEL == 1)) && ((attempts == 1)))){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
about = new CAbout();
about.y = ((-(about.height) / 2) - 15);
about.x = -230;
addChild(about);
about.okButton.addEventListener("click", hideabout);
} else {
playStartTime = getTimer();
};
stage.focus = stage;
}
private function loadResumeButton(){
resumeButton = new CStartButton(-90, -110, 200, 228);
addChild(resumeButton);
resumeText = new CSplashText(this);
resumeText.splashButton.label = "resume";
addChild(resumeText);
resumeText.mapcode.visible = false;
resumeText.mapcodelabel.visible = false;
resumeText.splashButton.addEventListener("click", resumeStage);
}
public function clearMap(){
APEngine.removeGroup(blockGroup);
blockGroup = null;
}
private function loadMsgButton(msg1:String, msg2:String, msg3:String, lbl:String, arg1:Boolean, arg2:Boolean, arg3:Boolean){
msgText = new CMsgText();
addChild(msgText);
msgText.y = (msgText.y + 30);
msgText.msg1.embedFonts = true;
msgText.msg2.embedFonts = true;
msgText.msg3.embedFonts = true;
msgText.msg1.text = msg1;
msgText.msg2.text = msg2;
msgText.msg3.text = msg3;
msgText.yesButton.label = lbl;
msgText.yesButton.visible = arg1;
msgText.noButton1.visible = arg2;
msgText.noButton2.visible = arg3;
}
public function clearBall(){
APEngine.removeGroup(ballGroup);
ballGroup.cleanup();
}
}
}//package
Section 67
//CMsgText (CMsgText)
package {
import fl.controls.*;
import flash.display.*;
import flash.text.*;
public dynamic class CMsgText extends MovieClip {
public var noButton1:Button;
public var noButton2:Button;
public var msg1:TextField;
public var msg2:TextField;
public var msg3:TextField;
public var yesButton:Button;
public function CMsgText(){
super();
__setProp_noButton2_CMsgText_msgButton_1();
__setProp_yesButton_CMsgText_msgButton_1();
__setProp_noButton1_CMsgText_msgButton_1();
}
function __setProp_noButton1_CMsgText_msgButton_1(){
noButton1["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
noButton1.emphasized = false;
noButton1.enabled = true;
noButton1.label = "Cancel";
noButton1.labelPlacement = "right";
noButton1.selected = true;
noButton1.toggle = false;
noButton1.visible = true;
noButton1["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
function __setProp_yesButton_CMsgText_msgButton_1(){
yesButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
yesButton.emphasized = false;
yesButton.enabled = true;
yesButton.label = "Continue";
yesButton.labelPlacement = "right";
yesButton.selected = true;
yesButton.toggle = false;
yesButton.visible = true;
yesButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
function __setProp_noButton2_CMsgText_msgButton_1(){
noButton2["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
noButton2.emphasized = false;
noButton2.enabled = true;
noButton2.label = "Exit";
noButton2.labelPlacement = "right";
noButton2.selected = true;
noButton2.toggle = false;
noButton2.visible = true;
noButton2["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
}
}//package
Section 68
//CScoreBoard (CScoreBoard)
package {
import fl.controls.*;
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.filters.*;
import flash.net.*;
public class CScoreBoard extends MovieClip {
public var pointsButton:Button;
public var timeprogress:Sprite;
public var bonusButton:Button;
public var score_bonus:TextField;
public var bg:MovieClip;
public var pointsButtonXoffset:Number;
public var timeButton:Button;
public var score_try:TextField;
public var score_level:TextField;
public var score_score:TextField;
public var about:CAbout;
public var pointsProgressBlinker:MovieClip;
public var Parent:CMap;
public var percenttimeprogress:Number;
public var score_point5:TextField;
public var bonusProgressBlinker:MovieClip;
public function CScoreBoard(_Parent:CMap){
super();
Parent = _Parent;
score_level.embedFonts = true;
score_try.embedFonts = true;
score_score.embedFonts = true;
score_bonus.embedFonts = true;
score_point5.embedFonts = true;
this.x = ((Parent.offsetX - (Parent.tileLength / 2)) + 1.5);
this.y = ((Parent.offsetY + Parent.mapHeight) + 6);
timeprogress = new Sprite();
timeprogress.graphics.beginFill(40189);
timeprogress.graphics.drawRoundRect((timeButton.x + 1), (timeButton.y + 1.5), (timeButton.width - 2), 13, 5);
timeprogress.graphics.endFill();
timeprogress.alpha = 0.2;
addChild(timeprogress);
pointsButtonXoffset = ((pointsButton.x + 35) + 0.5);
__setProp_pointsButton_CScoreBoard_Buttons_1();
__setProp_bonusButton_CScoreBoard_Buttons_1();
__setProp_timeButton_CScoreBoard_Buttons_1();
}
public function updateProgress(percent:Number, flag:Boolean){
removeChild(timeprogress);
percenttimeprogress = percent;
timeprogress = new Sprite();
if (flag == false){
timeprogress.graphics.beginFill(40189);
} else {
timeprogress.graphics.beginFill(11796737);
};
timeprogress.graphics.drawRoundRect((timeButton.x + 1), (timeButton.y + 0.5), (percent * (timeButton.width - 2)), 13, 5);
timeprogress.graphics.endFill();
timeprogress.alpha = 0.2;
addChild(timeprogress);
}
function __setProp_pointsButton_CScoreBoard_Buttons_1(){
pointsButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
pointsButton.emphasized = false;
pointsButton.enabled = true;
pointsButton.label = "";
pointsButton.labelPlacement = "right";
pointsButton.selected = false;
pointsButton.toggle = false;
pointsButton.visible = true;
pointsButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
public function loadXMLMap(e:MouseEvent){
var fileFilter:FileFilter;
var fileReference:FileReference;
var e = e;
fileFilter = new FileFilter("Map XML Files (*.xml)", "*.xml");
fileReference = new FileReference();
fileReference.addEventListener(Event.SELECT, function (e:Event):void{
var selectHandler:*;
e.target.name;
});
fileReference.browse([fileFilter]);
}
function __setProp_bonusButton_CScoreBoard_Buttons_1(){
bonusButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
bonusButton.emphasized = false;
bonusButton.enabled = true;
bonusButton.label = "";
bonusButton.labelPlacement = "right";
bonusButton.selected = false;
bonusButton.toggle = false;
bonusButton.visible = true;
bonusButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
public function reset(e:MouseEvent=null){
var i:*;
var j:*;
Parent.clearShadows();
Parent.clearBall();
Parent.clearMap();
Parent.clearHole();
i = 1;
while (i < 2000000) {
j = ((i * i) + ((i * i) * i));
i++;
};
Parent.startGame();
}
public function hideabout(e:MouseEvent){
removeChild(about);
Parent.addEventListener(Event.ENTER_FRAME, Parent.onEnterFrame);
}
public function showabout(e:MouseEvent){
Parent.clearShadows();
Parent.removeEventListener(Event.ENTER_FRAME, Parent.onEnterFrame);
addChild(about);
about.okButton.addEventListener("click", hideabout);
}
function __setProp_timeButton_CScoreBoard_Buttons_1(){
timeButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
timeButton.emphasized = false;
timeButton.enabled = true;
timeButton.label = "";
timeButton.labelPlacement = "right";
timeButton.selected = false;
timeButton.toggle = false;
timeButton.visible = true;
timeButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
public function updatePointProgress(pointArray:Array){
var bevel1:BevelFilter;
var pointprogress:Sprite;
bevel1 = new BevelFilter();
bevel1.blurX = 12;
bevel1.blurY = 12;
bevel1.angle = 90;
bevel1.strength = 0.5;
pointprogress = new Sprite();
pointprogress.graphics.beginFill(pointArray[1]);
pointprogress.graphics.drawRoundRect(pointsButtonXoffset, (pointsButton.y + 1), ((pointArray[0] * ((pointsButton.width - 2) - 35)) + 0.3), 13.5, 5);
pointprogress.graphics.endFill();
pointprogress.alpha = 0.8;
pointprogress.filters = [bevel1];
addChild(pointprogress);
pointsButtonXoffset = (pointsButtonXoffset + (pointArray[0] * ((pointsButton.width - 2) - 35)));
}
}
}//package
Section 69
//CSplashText (CSplashText)
package {
import fl.controls.*;
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.filters.*;
import flash.system.*;
public class CSplashText extends MovieClip {
private var previewOffsetY:Number;
private var previewOffsetX:Number;
public var mapcode:TextInput;
public var mapcodelabel:TextField;
public var quitButton:SimpleButton;
private var factor:Number;
public var splashButton:Button;
public var about:CAbout;
private var enablePreview:Boolean;
private var Parent:CMap;
private var preview:Sprite;
public var helpButton:Button;
public function CSplashText(_Parent:CMap){
var scoreButton:Button;
var tf:TextFormat;
super();
Parent = _Parent;
this.y = 60;
this.x = 2;
factor = 7;
previewOffsetX = (Parent.offsetX / factor);
previewOffsetY = (Parent.offsetY / factor);
enablePreview = false;
if (enablePreview){
preview = new Sprite();
addChild(preview);
};
mouseEnabled = true;
buttonMode = true;
scoreButton = new Button();
scoreButton.enabled = false;
scoreButton.label = "scores";
scoreButton.move(((this.helpButton.x + 47) + 2), this.helpButton.y);
scoreButton.width = 47;
scoreButton.height = 22;
addChild(scoreButton);
tf = new TextFormat();
tf.color = 0xFF;
tf.font = "Aharoni";
tf.size = 9;
tf.align = "center";
mapcode.setStyle("textFormat", tf);
this.helpButton.addEventListener("click", showabout);
this.quitButton.addEventListener("click", quitGame);
__setProp_helpButton_CSplashText_splashButton_1();
__setProp_splashButton_CSplashText_splashButton_1();
__setProp_mapcode_CSplashText_splashButton_1();
}
private function backward(e:MouseEvent){
if (Parent.LEVEL > 1){
Parent.LEVEL = (Parent.LEVEL - 1);
Parent.splashText.splashButton.label = ("level " + Parent.LEVEL);
Parent.previousBallX = (Parent.offsetX + (Parent.mapWidth / 2));
Parent.previousBallY = ((Parent.offsetY + (Parent.mapHeight / 2)) + (1 * Parent.tileLength));
if (enablePreview){
clearPreview();
loadPreview();
};
};
}
private function loadPreview(){
var tilelength:Number;
var tilespacing:Number;
var Map:Array;
var hMap:Array;
var mapXtiles:Number;
var mapYtiles:Number;
var i:*;
var j:*;
var block:CBlock;
var hole:CHole;
tilelength = (Parent.tileLength / factor);
tilespacing = (Parent.tileSpacing / factor);
Map = Parent.allMaps[(Parent.LEVEL - 1)][0];
hMap = Parent.allMaps[(Parent.LEVEL - 1)][1];
mapXtiles = Map[0].length;
mapYtiles = Map.length;
i = 1;
while (i <= mapXtiles) {
j = 1;
while (j <= mapYtiles) {
if (Map[(j - 1)][(i - 1)] > 0){
block = new CBlock(0, 0, tilelength, true, Map[(j - 1)][(i - 1)], 1, Parent.FORCECONSTANT);
block.spriteBlock.x = ((previewOffsetX + ((tilelength * 3) / 2)) + ((i - 1) * (tilelength + tilespacing)));
block.spriteBlock.y = (((previewOffsetY + (tilelength / 3)) - (Parent.mapHeight / factor)) + ((j - 1) * (tilelength + tilespacing)));
preview.addChild(block.spriteBlock);
};
if (hMap[(j - 1)][(i - 1)] > 0){
hole = new CHole(Parent, 0, 0, tilelength, hMap[(j - 1)][(i - 1)]);
hole.spriteHole.x = ((previewOffsetX + ((tilelength * 3) / 2)) + ((i - 1) * (tilelength + tilespacing)));
hole.spriteHole.y = (((previewOffsetY + (tilelength / 3)) - (Parent.mapHeight / factor)) + ((j - 1) * (tilelength + tilespacing)));
preview.addChild(hole.spriteHole);
};
j++;
};
i++;
};
}
function __setProp_mapcode_CSplashText_splashButton_1(){
mapcode["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
mapcode.displayAsPassword = false;
mapcode.editable = true;
mapcode.enabled = true;
mapcode.maxChars = 7;
mapcode.restrict = "";
mapcode.text = "";
mapcode.visible = true;
mapcode["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
public function hideabout(e:MouseEvent){
about.okButton.removeEventListener("click", hideabout);
Parent.tertiaryAudioChannel = Parent.clk.play(0);
removeChild(about);
about = null;
}
function __setProp_splashButton_CSplashText_splashButton_1(){
splashButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
splashButton.emphasized = false;
splashButton.enabled = true;
splashButton.label = "play";
splashButton.labelPlacement = "top";
splashButton.selected = true;
splashButton.toggle = false;
splashButton.visible = true;
splashButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
public function showabout(e:MouseEvent){
Parent.tertiaryAudioChannel = Parent.clk.play(0);
Parent.clearShadows();
Parent.removeEventListener(Event.ENTER_FRAME, Parent.onEnterFrame);
about = new CAbout(this);
about.y = ((-(about.height) / 2) - 70);
about.x = -230;
addChild(about);
about.okButton.addEventListener("click", hideabout);
}
public function clearPreview(){
while (preview.numChildren > 0) {
preview.removeChildAt(0);
};
}
function __setProp_helpButton_CSplashText_splashButton_1(){
helpButton["componentInspectorSetting"] = true;
//unresolved jump
var _slot1 = e;
helpButton.emphasized = false;
helpButton.enabled = true;
helpButton.label = "help";
helpButton.labelPlacement = "top";
helpButton.selected = true;
helpButton.toggle = false;
helpButton.visible = true;
helpButton["componentInspectorSetting"] = false;
//unresolved jump
var _slot1 = e;
}
private function forward(e:MouseEvent){
if (Parent.LEVEL < Parent.MAXLEVEL){
Parent.LEVEL = (Parent.LEVEL + 1);
Parent.splashText.splashButton.label = ("level " + Parent.LEVEL);
Parent.previousBallX = (Parent.offsetX + (Parent.mapWidth / 2));
Parent.previousBallY = ((Parent.offsetY + (Parent.mapHeight / 2)) + (1 * Parent.tileLength));
if (enablePreview){
clearPreview();
loadPreview();
};
};
}
private function clearShadow(e:MouseEvent){
this.filters = [];
if (enablePreview){
clearPreview();
};
}
public function quitGame(e:MouseEvent=null){
Parent.tertiaryAudioChannel = Parent.clk.play(0);
fscommand("quit");
}
private function dropShadow(e:MouseEvent=null){
var shadow:DropShadowFilter;
shadow = new DropShadowFilter(3, 70, 0x888888, 1, 5, 5);
shadow.inner = false;
this.filters = [shadow];
if (enablePreview){
loadPreview();
};
}
}
}//package
Section 70
//CStartButton (CStartButton)
package {
import flash.display.*;
import flash.filters.*;
public class CStartButton extends MovieClip {
public function CStartButton(_x:Number, _y:Number, _w:Number, _h:Number){
var shadow:DropShadowFilter;
super();
addFrameScript(0, frame1);
this.x = _x;
this.y = _y;
this.width = _w;
this.height = _h;
shadow = new DropShadowFilter(5, 85, 0xCCCCCC, 0.5, 15, 15);
shadow.inner = false;
this.filters = [shadow];
}
function frame1(){
gotoAndStop(1);
stop();
}
}
}//package
Section 71
//CStartMenu (CStartMenu)
package {
import flash.display.*;
public dynamic class CStartMenu extends MovieClip {
public function CStartMenu(){
super();
}
}
}//package
Section 72
//CTile (CTile)
package {
import flash.display.*;
import flash.geom.*;
public class CTile extends Sprite {
private var gradcolor1:Number;
public var X:Number;
public var d:Number;
public var Y:Number;
private var Parent:CMap;
public var code:Number;
private var gradcolor2:Number;
public function CTile(_Parent:CMap, _X:Number, _Y:Number, _d:Number, _code:Number){
super();
Parent = _Parent;
X = _X;
Y = _Y;
d = _d;
code = _code;
switch (code){
case 8:
gradcolor1 = 14543793;
gradcolor2 = 14543793;
break;
case 9:
gradcolor1 = 0xFFFFFF;
gradcolor2 = 0xFFFFFF;
break;
};
drawTile();
}
private function drawTile(){
var matrix:Matrix;
var spreadMethod:String;
var colors:Array;
matrix = new Matrix();
spreadMethod = SpreadMethod.PAD;
colors = [gradcolor2, gradcolor1];
matrix.createGradientBox(d, d, (0.5 * Math.PI), (X - (d / 2)), (Y - (d / 2)));
this.graphics.beginGradientFill("linear", colors, [1, 1], [0, 0xFF], matrix, spreadMethod);
this.graphics.drawRect((X - (d / 2)), (Y - (d / 2)), d, d);
this.graphics.endFill();
}
}
}//package
Section 73
//dropSound (dropSound)
package {
import flash.media.*;
public dynamic class dropSound extends Sound {
public function dropSound(){
super();
}
}
}//package
Section 74
//focusRectSkin (focusRectSkin)
package {
import flash.display.*;
public dynamic class focusRectSkin extends MovieClip {
public function focusRectSkin(){
super();
}
}
}//package
Section 75
//gameOverSound (gameOverSound)
package {
import flash.media.*;
public dynamic class gameOverSound extends Sound {
public function gameOverSound(){
super();
}
}
}//package
Section 76
//hitHardSound (hitHardSound)
package {
import flash.media.*;
public dynamic class hitHardSound extends Sound {
public function hitHardSound(){
super();
}
}
}//package
Section 77
//muteButton (muteButton)
package {
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.media.*;
public class muteButton extends SimpleButton {
public var Parent:CMap;
public function muteButton(_Parent:CMap){
super();
Parent = _Parent;
if (Parent.isMute){
mute();
} else {
addEventListener("click", mute);
};
}
public function mute(e:MouseEvent=null){
Parent.primaryAudioChannel.soundTransform = new SoundTransform(0);
Parent.isMute = true;
if (filters.length == 0){
filters = [new GlowFilter()];
};
addEventListener("click", unmute);
removeEventListener("click", mute);
}
private function unmute(e:MouseEvent){
filters = [];
Parent.isMute = false;
Parent.primaryAudioChannel = Parent.theme.play();
Parent.primaryAudioChannel.soundTransform = new SoundTransform(0.1);
addEventListener("click", mute);
removeEventListener("click", unmute);
}
}
}//package
Section 78
//plusSymbol (plusSymbol)
package {
import flash.display.*;
public dynamic class plusSymbol extends MovieClip {
public function plusSymbol(){
super();
}
}
}//package
Section 79
//springSymbol (springSymbol)
package {
import flash.display.*;
public dynamic class springSymbol extends MovieClip {
public function springSymbol(){
super();
}
}
}//package
Section 80
//stretchSound (stretchSound)
package {
import flash.media.*;
public dynamic class stretchSound extends Sound {
public function stretchSound(){
super();
}
}
}//package
Section 81
//TextInput_disabledSkin (TextInput_disabledSkin)
package {
import flash.display.*;
public dynamic class TextInput_disabledSkin extends MovieClip {
public function TextInput_disabledSkin(){
super();
}
}
}//package
Section 82
//TextInput_upSkin (TextInput_upSkin)
package {
import flash.display.*;
public dynamic class TextInput_upSkin extends MovieClip {
public function TextInput_upSkin(){
super();
}
}
}//package
Section 83
//themeSound (themeSound)
package {
import flash.media.*;
public dynamic class themeSound extends Sound {
public function themeSound(){
super();
}
}
}//package