Section 1
//b2CircleShape (Box2D.Collision.Shapes.b2CircleShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2CircleShape extends b2Shape {
b2internal var m_p:b2Vec2;
public function b2CircleShape(_arg1:Number=0){
m_p = new b2Vec2();
super();
m_type = e_circleShape;
m_radius = _arg1;
}
override public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2Transform, _arg4:b2Vec2):Number{
var _local9:Number;
var _local5:b2Vec2 = b2Math.MulX(_arg3, m_p);
var _local6:Number = -((b2Math.Dot(_arg1, _local5) - _arg2));
if (_local6 < (-(m_radius) + Number.MIN_VALUE)){
return (0);
};
if (_local6 > m_radius){
_arg4.SetV(_local5);
return (((Math.PI * m_radius) * m_radius));
};
var _local7:Number = (m_radius * m_radius);
var _local8:Number = (_local6 * _local6);
_local9 = ((_local7 * (Math.asin((_local6 / m_radius)) + (Math.PI / 2))) + (_local6 * Math.sqrt((_local7 - _local8))));
var _local10:Number = (((-2 / 3) * Math.pow((_local7 - _local8), 1.5)) / _local9);
_arg4.x = (_local5.x + (_arg1.x * _local10));
_arg4.y = (_local5.y + (_arg1.y * _local10));
return (_local9);
}
override public function TestPoint(_arg1:b2Transform, _arg2:b2Vec2):Boolean{
var _local3:b2Mat22 = _arg1.R;
var _local4:Number = (_arg1.position.x + ((_local3.col1.x * m_p.x) + (_local3.col2.x * m_p.y)));
var _local5:Number = (_arg1.position.y + ((_local3.col1.y * m_p.x) + (_local3.col2.y * m_p.y)));
_local4 = (_arg2.x - _local4);
_local5 = (_arg2.y - _local5);
return ((((_local4 * _local4) + (_local5 * _local5)) <= (m_radius * m_radius)));
}
public function GetRadius():Number{
return (m_radius);
}
override public function Set(_arg1:b2Shape):void{
var _local2:b2CircleShape;
super.Set(_arg1);
if ((_arg1 is b2CircleShape)){
_local2 = (_arg1 as b2CircleShape);
m_p.SetV(_local2.m_p);
};
}
override public function ComputeMass(_arg1:b2MassData, _arg2:Number):void{
_arg1.mass = (((_arg2 * b2Settings.b2_pi) * m_radius) * m_radius);
_arg1.center.SetV(m_p);
_arg1.I = (_arg1.mass * (((0.5 * m_radius) * m_radius) + ((m_p.x * m_p.x) + (m_p.y * m_p.y))));
}
override public function RayCast(_arg1:b2RayCastOutput, _arg2:b2RayCastInput, _arg3:b2Transform):Boolean{
var _local8:Number;
var _local4:b2Mat22 = _arg3.R;
var _local5:Number = (_arg3.position.x + ((_local4.col1.x * m_p.x) + (_local4.col2.x * m_p.y)));
var _local6:Number = (_arg3.position.y + ((_local4.col1.y * m_p.x) + (_local4.col2.y * m_p.y)));
var _local7:Number = (_arg2.p1.x - _local5);
_local8 = (_arg2.p1.y - _local6);
var _local9:Number = (((_local7 * _local7) + (_local8 * _local8)) - (m_radius * m_radius));
var _local10:Number = (_arg2.p2.x - _arg2.p1.x);
var _local11:Number = (_arg2.p2.y - _arg2.p1.y);
var _local12:Number = ((_local7 * _local10) + (_local8 * _local11));
var _local13:Number = ((_local10 * _local10) + (_local11 * _local11));
var _local14:Number = ((_local12 * _local12) - (_local13 * _local9));
if ((((_local14 < 0)) || ((_local13 < Number.MIN_VALUE)))){
return (false);
};
var _local15:Number = -((_local12 + Math.sqrt(_local14)));
if ((((0 <= _local15)) && ((_local15 <= (_arg2.maxFraction * _local13))))){
_local15 = (_local15 / _local13);
_arg1.fraction = _local15;
_arg1.normal.x = (_local7 + (_local15 * _local10));
_arg1.normal.y = (_local8 + (_local15 * _local11));
_arg1.normal.Normalize();
return (true);
};
return (false);
}
public function SetLocalPosition(_arg1:b2Vec2):void{
m_p.SetV(_arg1);
}
public function SetRadius(_arg1:Number):void{
m_radius = _arg1;
}
override public function Copy():b2Shape{
var _local1:b2Shape = new b2CircleShape();
_local1.Set(this);
return (_local1);
}
override public function ComputeAABB(_arg1:b2AABB, _arg2:b2Transform):void{
var _local3:b2Mat22 = _arg2.R;
var _local4:Number = (_arg2.position.x + ((_local3.col1.x * m_p.x) + (_local3.col2.x * m_p.y)));
var _local5:Number = (_arg2.position.y + ((_local3.col1.y * m_p.x) + (_local3.col2.y * m_p.y)));
_arg1.lowerBound.Set((_local4 - m_radius), (_local5 - m_radius));
_arg1.upperBound.Set((_local4 + m_radius), (_local5 + m_radius));
}
public function GetLocalPosition():b2Vec2{
return (m_p);
}
}
}//package Box2D.Collision.Shapes
Section 2
//b2EdgeShape (Box2D.Collision.Shapes.b2EdgeShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2EdgeShape extends b2Shape {
b2internal var m_normal:b2Vec2;
b2internal var m_cornerConvex1:Boolean;
b2internal var m_cornerConvex2:Boolean;
b2internal var m_cornerDir1:b2Vec2;
b2internal var m_v1:b2Vec2;
b2internal var m_v2:b2Vec2;
private var s_supportVec:b2Vec2;
b2internal var m_coreV1:b2Vec2;
b2internal var m_coreV2:b2Vec2;
b2internal var m_cornerDir2:b2Vec2;
b2internal var m_nextEdge:b2EdgeShape;
b2internal var m_direction:b2Vec2;
b2internal var m_prevEdge:b2EdgeShape;
b2internal var m_length:Number;
public function b2EdgeShape(_arg1:b2Vec2, _arg2:b2Vec2){
s_supportVec = new b2Vec2();
m_v1 = new b2Vec2();
m_v2 = new b2Vec2();
m_coreV1 = new b2Vec2();
m_coreV2 = new b2Vec2();
m_normal = new b2Vec2();
m_direction = new b2Vec2();
m_cornerDir1 = new b2Vec2();
m_cornerDir2 = new b2Vec2();
super();
m_type = e_edgeShape;
m_prevEdge = null;
m_nextEdge = null;
m_v1 = _arg1;
m_v2 = _arg2;
m_direction.Set((m_v2.x - m_v1.x), (m_v2.y - m_v1.y));
m_length = m_direction.Normalize();
m_normal.Set(m_direction.y, -(m_direction.x));
m_coreV1.Set(((-(b2Settings.b2_toiSlop) * (m_normal.x - m_direction.x)) + m_v1.x), ((-(b2Settings.b2_toiSlop) * (m_normal.y - m_direction.y)) + m_v1.y));
m_coreV2.Set(((-(b2Settings.b2_toiSlop) * (m_normal.x + m_direction.x)) + m_v2.x), ((-(b2Settings.b2_toiSlop) * (m_normal.y + m_direction.y)) + m_v2.y));
m_cornerDir1 = m_normal;
m_cornerDir2.Set(-(m_normal.x), -(m_normal.y));
}
override public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2Transform, _arg4:b2Vec2):Number{
var _local5:b2Vec2 = new b2Vec2((_arg1.x * _arg2), (_arg1.y * _arg2));
var _local6:b2Vec2 = b2Math.MulX(_arg3, m_v1);
var _local7:b2Vec2 = b2Math.MulX(_arg3, m_v2);
var _local8:Number = (b2Math.Dot(_arg1, _local6) - _arg2);
var _local9:Number = (b2Math.Dot(_arg1, _local7) - _arg2);
if (_local8 > 0){
if (_local9 > 0){
return (0);
};
_local6.x = (((-(_local9) / (_local8 - _local9)) * _local6.x) + ((_local8 / (_local8 - _local9)) * _local7.x));
_local6.y = (((-(_local9) / (_local8 - _local9)) * _local6.y) + ((_local8 / (_local8 - _local9)) * _local7.y));
} else {
if (_local9 > 0){
_local7.x = (((-(_local9) / (_local8 - _local9)) * _local6.x) + ((_local8 / (_local8 - _local9)) * _local7.x));
_local7.y = (((-(_local9) / (_local8 - _local9)) * _local6.y) + ((_local8 / (_local8 - _local9)) * _local7.y));
};
};
_arg4.x = (((_local5.x + _local6.x) + _local7.x) / 3);
_arg4.y = (((_local5.y + _local6.y) + _local7.y) / 3);
return ((0.5 * (((_local6.x - _local5.x) * (_local7.y - _local5.y)) - ((_local6.y - _local5.y) * (_local7.x - _local5.x)))));
}
override public function ComputeAABB(_arg1:b2AABB, _arg2:b2Transform):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local3:b2Mat22 = _arg2.R;
_local4 = (_arg2.position.x + ((_local3.col1.x * m_v1.x) + (_local3.col2.x * m_v1.y)));
_local5 = (_arg2.position.y + ((_local3.col1.y * m_v1.x) + (_local3.col2.y * m_v1.y)));
_local6 = (_arg2.position.x + ((_local3.col1.x * m_v2.x) + (_local3.col2.x * m_v2.y)));
_local7 = (_arg2.position.y + ((_local3.col1.y * m_v2.x) + (_local3.col2.y * m_v2.y)));
if (_local4 < _local6){
_arg1.lowerBound.x = _local4;
_arg1.upperBound.x = _local6;
} else {
_arg1.lowerBound.x = _local6;
_arg1.upperBound.x = _local4;
};
if (_local5 < _local7){
_arg1.lowerBound.y = _local5;
_arg1.upperBound.y = _local7;
} else {
_arg1.lowerBound.y = _local7;
_arg1.upperBound.y = _local5;
};
}
public function GetCorner1Vector():b2Vec2{
return (m_cornerDir1);
}
public function GetCorner2Vector():b2Vec2{
return (m_cornerDir2);
}
public function GetDirectionVector():b2Vec2{
return (m_direction);
}
public function GetCoreVertex1():b2Vec2{
return (m_coreV1);
}
public function GetCoreVertex2():b2Vec2{
return (m_coreV2);
}
public function GetFirstVertex(_arg1:b2Transform):b2Vec2{
var _local2:b2Mat22 = _arg1.R;
return (new b2Vec2((_arg1.position.x + ((_local2.col1.x * m_coreV1.x) + (_local2.col2.x * m_coreV1.y))), (_arg1.position.y + ((_local2.col1.y * m_coreV1.x) + (_local2.col2.y * m_coreV1.y)))));
}
public function GetNormalVector():b2Vec2{
return (m_normal);
}
public function GetNextEdge():b2EdgeShape{
return (m_nextEdge);
}
override public function RayCast(_arg1:b2RayCastOutput, _arg2:b2RayCastInput, _arg3:b2Transform):Boolean{
var _local4:b2Mat22;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local5:Number = (_arg2.p2.x - _arg2.p1.x);
var _local6:Number = (_arg2.p2.y - _arg2.p1.y);
_local4 = _arg3.R;
var _local7:Number = (_arg3.position.x + ((_local4.col1.x * m_v1.x) + (_local4.col2.x * m_v1.y)));
var _local8:Number = (_arg3.position.y + ((_local4.col1.y * m_v1.x) + (_local4.col2.y * m_v1.y)));
var _local9:Number = ((_arg3.position.y + ((_local4.col1.y * m_v2.x) + (_local4.col2.y * m_v2.y))) - _local8);
var _local10:Number = -(((_arg3.position.x + ((_local4.col1.x * m_v2.x) + (_local4.col2.x * m_v2.y))) - _local7));
var _local11:Number = (100 * Number.MIN_VALUE);
var _local12:Number = -(((_local5 * _local9) + (_local6 * _local10)));
if (_local12 > _local11){
_local13 = (_arg2.p1.x - _local7);
_local14 = (_arg2.p1.y - _local8);
_local15 = ((_local13 * _local9) + (_local14 * _local10));
if ((((0 <= _local15)) && ((_local15 <= (_arg2.maxFraction * _local12))))){
_local16 = ((-(_local5) * _local14) + (_local6 * _local13));
if (((((-(_local11) * _local12) <= _local16)) && ((_local16 <= (_local12 * (1 + _local11)))))){
_local15 = (_local15 / _local12);
_arg1.fraction = _local15;
_local17 = Math.sqrt(((_local9 * _local9) + (_local10 * _local10)));
_arg1.normal.x = (_local9 / _local17);
_arg1.normal.y = (_local10 / _local17);
return (true);
};
};
};
return (false);
}
override public function ComputeMass(_arg1:b2MassData, _arg2:Number):void{
_arg1.mass = 0;
_arg1.center.SetV(m_v1);
_arg1.I = 0;
}
public function Corner1IsConvex():Boolean{
return (m_cornerConvex1);
}
public function Corner2IsConvex():Boolean{
return (m_cornerConvex2);
}
public function Support(_arg1:b2Transform, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:b2Mat22 = _arg1.R;
var _local5:Number = (_arg1.position.x + ((_local4.col1.x * m_coreV1.x) + (_local4.col2.x * m_coreV1.y)));
var _local6:Number = (_arg1.position.y + ((_local4.col1.y * m_coreV1.x) + (_local4.col2.y * m_coreV1.y)));
var _local7:Number = (_arg1.position.x + ((_local4.col1.x * m_coreV2.x) + (_local4.col2.x * m_coreV2.y)));
var _local8:Number = (_arg1.position.y + ((_local4.col1.y * m_coreV2.x) + (_local4.col2.y * m_coreV2.y)));
if (((_local5 * _arg2) + (_local6 * _arg3)) > ((_local7 * _arg2) + (_local8 * _arg3))){
s_supportVec.x = _local5;
s_supportVec.y = _local6;
} else {
s_supportVec.x = _local7;
s_supportVec.y = _local8;
};
return (s_supportVec);
}
b2internal function SetNextEdge(_arg1:b2EdgeShape, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Boolean):void{
m_nextEdge = _arg1;
m_coreV2 = _arg2;
m_cornerDir2 = _arg3;
m_cornerConvex2 = _arg4;
}
public function GetPrevEdge():b2EdgeShape{
return (m_prevEdge);
}
public function GetVertex1():b2Vec2{
return (m_v1);
}
public function GetVertex2():b2Vec2{
return (m_v2);
}
b2internal function SetPrevEdge(_arg1:b2EdgeShape, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Boolean):void{
m_prevEdge = _arg1;
m_coreV1 = _arg2;
m_cornerDir1 = _arg3;
m_cornerConvex1 = _arg4;
}
public function GetLength():Number{
return (m_length);
}
override public function TestPoint(_arg1:b2Transform, _arg2:b2Vec2):Boolean{
return (false);
}
}
}//package Box2D.Collision.Shapes
Section 3
//b2MassData (Box2D.Collision.Shapes.b2MassData)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
public class b2MassData {
public var mass:Number;// = 0
public var center:b2Vec2;
public var I:Number;// = 0
public function b2MassData(){
center = new b2Vec2(0, 0);
super();
}
}
}//package Box2D.Collision.Shapes
Section 4
//b2PolygonShape (Box2D.Collision.Shapes.b2PolygonShape)
package Box2D.Collision.Shapes {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2PolygonShape extends b2Shape {
b2internal var m_vertexCount:int;
b2internal var m_vertices:Array;
b2internal var m_centroid:b2Vec2;
b2internal var m_normals:Array;
private static var s_mat:b2Mat22 = new b2Mat22();
public function b2PolygonShape(){
m_type = e_polygonShape;
m_centroid = new b2Vec2();
m_vertices = new Array();
m_normals = new Array();
}
override public function Set(_arg1:b2Shape):void{
var _local2:b2PolygonShape;
var _local3:int;
super.Set(_arg1);
if ((_arg1 is b2PolygonShape)){
_local2 = (_arg1 as b2PolygonShape);
m_centroid.SetV(_local2.m_centroid);
m_vertexCount = _local2.m_vertexCount;
Reserve(m_vertexCount);
_local3 = 0;
while (_local3 < m_vertexCount) {
m_vertices[_local3].SetV(_local2.m_vertices[_local3]);
m_normals[_local3].SetV(_local2.m_normals[_local3]);
_local3++;
};
};
}
override public function ComputeAABB(_arg1:b2AABB, _arg2:b2Transform):void{
var _local10:Number;
var _local11:Number;
var _local3:b2Mat22 = _arg2.R;
var _local4:b2Vec2 = m_vertices[0];
var _local5:Number = (_arg2.position.x + ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y)));
var _local6:Number = (_arg2.position.y + ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y)));
var _local7:Number = _local5;
var _local8:Number = _local6;
var _local9 = 1;
while (_local9 < m_vertexCount) {
_local4 = m_vertices[_local9];
_local10 = (_arg2.position.x + ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y)));
_local11 = (_arg2.position.y + ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y)));
_local5 = ((_local5 < _local10)) ? _local5 : _local10;
_local6 = ((_local6 < _local11)) ? _local6 : _local11;
_local7 = ((_local7 > _local10)) ? _local7 : _local10;
_local8 = ((_local8 > _local11)) ? _local8 : _local11;
_local9++;
};
_arg1.lowerBound.x = (_local5 - m_radius);
_arg1.lowerBound.y = (_local6 - m_radius);
_arg1.upperBound.x = (_local7 + m_radius);
_arg1.upperBound.y = (_local8 + m_radius);
}
override public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2Transform, _arg4:b2Vec2):Number{
var _local12:int;
var _local22:b2Vec2;
var _local23:Boolean;
var _local24:b2MassData;
var _local25:Number;
var _local5:b2Vec2 = b2Math.MulTMV(_arg3.R, _arg1);
var _local6:Number = (_arg2 - b2Math.Dot(_arg1, _arg3.position));
var _local7:Array = new Array();
var _local8:int;
var _local9 = -1;
var _local10 = -1;
var _local11:Boolean;
_local12 = 0;
while (_local12 < m_vertexCount) {
_local7[_local12] = (b2Math.Dot(_local5, m_vertices[_local12]) - _local6);
_local23 = (_local7[_local12] < -(Number.MIN_VALUE));
if (_local12 > 0){
if (_local23){
if (!_local11){
_local9 = (_local12 - 1);
_local8++;
};
} else {
if (_local11){
_local10 = (_local12 - 1);
_local8++;
};
};
};
_local11 = _local23;
_local12++;
};
switch (_local8){
case 0:
if (_local11){
_local24 = new b2MassData();
ComputeMass(_local24, 1);
_arg4.SetV(b2Math.MulX(_arg3, _local24.center));
return (_local24.mass);
};
return (0);
case 1:
if (_local9 == -1){
_local9 = (m_vertexCount - 1);
} else {
_local10 = (m_vertexCount - 1);
};
break;
};
var _local13:int = ((_local9 + 1) % m_vertexCount);
var _local14:int = ((_local10 + 1) % m_vertexCount);
var _local15:Number = ((0 - _local7[_local9]) / (_local7[_local13] - _local7[_local9]));
var _local16:Number = ((0 - _local7[_local10]) / (_local7[_local14] - _local7[_local10]));
var _local17:b2Vec2 = new b2Vec2(((m_vertices[_local9].x * (1 - _local15)) + (m_vertices[_local13].x * _local15)), ((m_vertices[_local9].y * (1 - _local15)) + (m_vertices[_local13].y * _local15)));
var _local18:b2Vec2 = new b2Vec2(((m_vertices[_local10].x * (1 - _local16)) + (m_vertices[_local14].x * _local16)), ((m_vertices[_local10].y * (1 - _local16)) + (m_vertices[_local14].y * _local16)));
var _local19:Number = 0;
var _local20:b2Vec2 = new b2Vec2();
var _local21:b2Vec2 = m_vertices[_local13];
_local12 = _local13;
while (_local12 != _local14) {
_local12 = ((_local12 + 1) % m_vertexCount);
if (_local12 == _local14){
_local22 = _local18;
} else {
_local22 = m_vertices[_local12];
};
_local25 = (0.5 * (((_local21.x - _local17.x) * (_local22.y - _local17.y)) - ((_local21.y - _local17.y) * (_local22.x - _local17.x))));
_local19 = (_local19 + _local25);
_local20.x = (_local20.x + ((_local25 * ((_local17.x + _local21.x) + _local22.x)) / 3));
_local20.y = (_local20.y + ((_local25 * ((_local17.y + _local21.y) + _local22.y)) / 3));
_local21 = _local22;
};
_local20.Multiply((1 / _local19));
_arg4.SetV(b2Math.MulX(_arg3, _local20));
return (_local19);
}
public function GetVertices():Array{
return (m_vertices);
}
public function SetAsOrientedBox(_arg1:Number, _arg2:Number, _arg3:b2Vec2=null, _arg4:Number=0):void{
m_vertexCount = 4;
Reserve(4);
m_vertices[0].Set(-(_arg1), -(_arg2));
m_vertices[1].Set(_arg1, -(_arg2));
m_vertices[2].Set(_arg1, _arg2);
m_vertices[3].Set(-(_arg1), _arg2);
m_normals[0].Set(0, -1);
m_normals[1].Set(1, 0);
m_normals[2].Set(0, 1);
m_normals[3].Set(-1, 0);
m_centroid = _arg3;
var _local5:b2Transform = new b2Transform();
_local5.position = _arg3;
_local5.R.Set(_arg4);
var _local6:int;
while (_local6 < m_vertexCount) {
m_vertices[_local6] = b2Math.MulX(_local5, m_vertices[_local6]);
m_normals[_local6] = b2Math.MulMV(_local5.R, m_normals[_local6]);
_local6++;
};
}
override public function Copy():b2Shape{
var _local1:b2PolygonShape = new b2PolygonShape();
_local1.Set(this);
return (_local1);
}
public function SetAsBox(_arg1:Number, _arg2:Number):void{
m_vertexCount = 4;
Reserve(4);
m_vertices[0].Set(-(_arg1), -(_arg2));
m_vertices[1].Set(_arg1, -(_arg2));
m_vertices[2].Set(_arg1, _arg2);
m_vertices[3].Set(-(_arg1), _arg2);
m_normals[0].Set(0, -1);
m_normals[1].Set(1, 0);
m_normals[2].Set(0, 1);
m_normals[3].Set(-1, 0);
m_centroid.SetZero();
}
private function Reserve(_arg1:int):void{
var _local2:int = m_vertices.length;
while (_local2 < _arg1) {
m_vertices[_local2] = new b2Vec2();
m_normals[_local2] = new b2Vec2();
_local2++;
};
}
public function GetNormals():Array{
return (m_normals);
}
public function SetAsArray(_arg1:Array, _arg2:Number=0):void{
var _local4:b2Vec2;
var _local3:Array = new Array();
for each (_local4 in _arg1) {
_local3.push(_local4);
};
SetAsVector(_local3, _arg2);
}
override public function RayCast(_arg1:b2RayCastOutput, _arg2:b2RayCastInput, _arg3:b2Transform):Boolean{
var _local6:Number;
var _local7:Number;
var _local8:b2Mat22;
var _local9:b2Vec2;
var _local18:Number;
var _local19:Number;
var _local4:Number = 0;
var _local5:Number = _arg2.maxFraction;
_local6 = (_arg2.p1.x - _arg3.position.x);
_local7 = (_arg2.p1.y - _arg3.position.y);
_local8 = _arg3.R;
var _local10:Number = ((_local6 * _local8.col1.x) + (_local7 * _local8.col1.y));
var _local11:Number = ((_local6 * _local8.col2.x) + (_local7 * _local8.col2.y));
_local6 = (_arg2.p2.x - _arg3.position.x);
_local7 = (_arg2.p2.y - _arg3.position.y);
_local8 = _arg3.R;
var _local12:Number = ((_local6 * _local8.col1.x) + (_local7 * _local8.col1.y));
var _local13:Number = ((_local6 * _local8.col2.x) + (_local7 * _local8.col2.y));
var _local14:Number = (_local12 - _local10);
var _local15:Number = (_local13 - _local11);
var _local16 = -1;
var _local17:int;
while (_local17 < m_vertexCount) {
_local9 = m_vertices[_local17];
_local6 = (_local9.x - _local10);
_local7 = (_local9.y - _local11);
_local9 = m_normals[_local17];
_local18 = ((_local9.x * _local6) + (_local9.y * _local7));
_local19 = ((_local9.x * _local14) + (_local9.y * _local15));
if (_local19 == 0){
if (_local18 < 0){
return (false);
};
} else {
if ((((_local19 < 0)) && ((_local18 < (_local4 * _local19))))){
_local4 = (_local18 / _local19);
_local16 = _local17;
} else {
if ((((_local19 > 0)) && ((_local18 < (_local5 * _local19))))){
_local5 = (_local18 / _local19);
};
};
};
if (_local5 < (_local4 - Number.MIN_VALUE)){
return (false);
};
_local17++;
};
if (_local16 >= 0){
_arg1.fraction = _local4;
_local8 = _arg3.R;
_local9 = m_normals[_local16];
_arg1.normal.x = ((_local8.col1.x * _local9.x) + (_local8.col2.x * _local9.y));
_arg1.normal.y = ((_local8.col1.y * _local9.x) + (_local8.col2.y * _local9.y));
return (true);
};
return (false);
}
override public function ComputeMass(_arg1:b2MassData, _arg2:Number):void{
var _local11:b2Vec2;
var _local12:b2Vec2;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
if (m_vertexCount == 2){
_arg1.center.x = (0.5 * (m_vertices[0].x + m_vertices[1].x));
_arg1.center.y = (0.5 * (m_vertices[0].y + m_vertices[1].y));
_arg1.mass = 0;
_arg1.I = 0;
return;
};
var _local3:Number = 0;
var _local4:Number = 0;
var _local5:Number = 0;
var _local6:Number = 0;
var _local7:Number = 0;
var _local8:Number = 0;
var _local9:Number = (1 / 3);
var _local10:int;
while (_local10 < m_vertexCount) {
_local11 = m_vertices[_local10];
_local12 = (((_local10 + 1) < m_vertexCount)) ? m_vertices[int((_local10 + 1))] : m_vertices[0];
_local13 = (_local11.x - _local7);
_local14 = (_local11.y - _local8);
_local15 = (_local12.x - _local7);
_local16 = (_local12.y - _local8);
_local17 = ((_local13 * _local16) - (_local14 * _local15));
_local18 = (0.5 * _local17);
_local5 = (_local5 + _local18);
_local3 = (_local3 + ((_local18 * _local9) * ((_local7 + _local11.x) + _local12.x)));
_local4 = (_local4 + ((_local18 * _local9) * ((_local8 + _local11.y) + _local12.y)));
_local19 = _local7;
_local20 = _local8;
_local21 = _local13;
_local22 = _local14;
_local23 = _local15;
_local24 = _local16;
_local25 = ((_local9 * ((0.25 * (((_local21 * _local21) + (_local23 * _local21)) + (_local23 * _local23))) + ((_local19 * _local21) + (_local19 * _local23)))) + ((0.5 * _local19) * _local19));
_local26 = ((_local9 * ((0.25 * (((_local22 * _local22) + (_local24 * _local22)) + (_local24 * _local24))) + ((_local20 * _local22) + (_local20 * _local24)))) + ((0.5 * _local20) * _local20));
_local6 = (_local6 + (_local17 * (_local25 + _local26)));
_local10++;
};
_arg1.mass = (_arg2 * _local5);
_local3 = (_local3 * (1 / _local5));
_local4 = (_local4 * (1 / _local5));
_arg1.center.Set(_local3, _local4);
_arg1.I = (_arg2 * _local6);
}
public function SetAsEdge(_arg1:b2Vec2, _arg2:b2Vec2):void{
m_vertexCount = 2;
Reserve(2);
m_vertices[0].SetV(_arg1);
m_vertices[1].SetV(_arg2);
m_centroid.x = (0.5 * (_arg1.x + _arg2.x));
m_centroid.y = (0.5 * (_arg1.y + _arg2.y));
m_normals[0] = b2Math.CrossVF(b2Math.SubtractVV(_arg2, _arg1), 1);
m_normals[0].Normalize();
m_normals[1].x = -(m_normals[0].x);
m_normals[1].y = -(m_normals[0].y);
}
public function GetVertexCount():int{
return (m_vertexCount);
}
private function Validate():Boolean{
return (false);
}
public function SetAsVector(_arg1:Array, _arg2:Number=0):void{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:b2Vec2;
if (_arg2 == 0){
_arg2 = _arg1.length;
};
b2Settings.b2Assert((2 <= _arg2));
m_vertexCount = _arg2;
Reserve(_arg2);
_local3 = 0;
while (_local3 < m_vertexCount) {
m_vertices[_local3].SetV(_arg1[_local3]);
_local3++;
};
_local3 = 0;
while (_local3 < m_vertexCount) {
_local4 = _local3;
_local5 = (((_local3 + 1) < m_vertexCount)) ? (_local3 + 1) : 0;
_local6 = b2Math.SubtractVV(m_vertices[_local5], m_vertices[_local4]);
b2Settings.b2Assert((_local6.LengthSquared() > Number.MIN_VALUE));
m_normals[_local3].SetV(b2Math.CrossVF(_local6, 1));
m_normals[_local3].Normalize();
_local3++;
};
m_centroid = ComputeCentroid(m_vertices, m_vertexCount);
}
public function GetSupport(_arg1:b2Vec2):int{
var _local5:Number;
var _local2:int;
var _local3:Number = ((m_vertices[0].x * _arg1.x) + (m_vertices[0].y * _arg1.y));
var _local4 = 1;
while (_local4 < m_vertexCount) {
_local5 = ((m_vertices[_local4].x * _arg1.x) + (m_vertices[_local4].y * _arg1.y));
if (_local5 > _local3){
_local2 = _local4;
_local3 = _local5;
};
_local4++;
};
return (_local2);
}
public function GetSupportVertex(_arg1:b2Vec2):b2Vec2{
var _local5:Number;
var _local2:int;
var _local3:Number = ((m_vertices[0].x * _arg1.x) + (m_vertices[0].y * _arg1.y));
var _local4 = 1;
while (_local4 < m_vertexCount) {
_local5 = ((m_vertices[_local4].x * _arg1.x) + (m_vertices[_local4].y * _arg1.y));
if (_local5 > _local3){
_local2 = _local4;
_local3 = _local5;
};
_local4++;
};
return (m_vertices[_local2]);
}
override public function TestPoint(_arg1:b2Transform, _arg2:b2Vec2):Boolean{
var _local3:b2Vec2;
var _local10:Number;
var _local4:b2Mat22 = _arg1.R;
var _local5:Number = (_arg2.x - _arg1.position.x);
var _local6:Number = (_arg2.y - _arg1.position.y);
var _local7:Number = ((_local5 * _local4.col1.x) + (_local6 * _local4.col1.y));
var _local8:Number = ((_local5 * _local4.col2.x) + (_local6 * _local4.col2.y));
var _local9:int;
while (_local9 < m_vertexCount) {
_local3 = m_vertices[_local9];
_local5 = (_local7 - _local3.x);
_local6 = (_local8 - _local3.y);
_local3 = m_normals[_local9];
_local10 = ((_local3.x * _local5) + (_local3.y * _local6));
if (_local10 > 0){
return (false);
};
_local9++;
};
return (true);
}
b2internal static function ComputeOBB(_arg1:b2OBB, _arg2:Array, _arg3:int):void{
var _local4:int;
var _local7:b2Vec2;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:int;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:b2Mat22;
var _local5:Array = new Array((_arg3 + 1));
_local4 = 0;
while (_local4 < _arg3) {
_local5[_local4] = _arg2[_local4];
_local4++;
};
_local5[_arg3] = _local5[0];
var _local6:Number = Number.MAX_VALUE;
_local4 = 1;
while (_local4 <= _arg3) {
_local7 = _local5[int((_local4 - 1))];
_local8 = (_local5[_local4].x - _local7.x);
_local9 = (_local5[_local4].y - _local7.y);
_local10 = Math.sqrt(((_local8 * _local8) + (_local9 * _local9)));
_local8 = (_local8 / _local10);
_local9 = (_local9 / _local10);
_local11 = -(_local9);
_local12 = _local8;
_local13 = Number.MAX_VALUE;
_local14 = Number.MAX_VALUE;
_local15 = -(Number.MAX_VALUE);
_local16 = -(Number.MAX_VALUE);
_local17 = 0;
while (_local17 < _arg3) {
_local19 = (_local5[_local17].x - _local7.x);
_local20 = (_local5[_local17].y - _local7.y);
_local21 = ((_local8 * _local19) + (_local9 * _local20));
_local22 = ((_local11 * _local19) + (_local12 * _local20));
if (_local21 < _local13){
_local13 = _local21;
};
if (_local22 < _local14){
_local14 = _local22;
};
if (_local21 > _local15){
_local15 = _local21;
};
if (_local22 > _local16){
_local16 = _local22;
};
_local17++;
};
_local18 = ((_local15 - _local13) * (_local16 - _local14));
if (_local18 < (0.95 * _local6)){
_local6 = _local18;
_arg1.R.col1.x = _local8;
_arg1.R.col1.y = _local9;
_arg1.R.col2.x = _local11;
_arg1.R.col2.y = _local12;
_local23 = (0.5 * (_local13 + _local15));
_local24 = (0.5 * (_local14 + _local16));
_local25 = _arg1.R;
_arg1.center.x = (_local7.x + ((_local25.col1.x * _local23) + (_local25.col2.x * _local24)));
_arg1.center.y = (_local7.y + ((_local25.col1.y * _local23) + (_local25.col2.y * _local24)));
_arg1.extents.x = (0.5 * (_local15 - _local13));
_arg1.extents.y = (0.5 * (_local16 - _local14));
};
_local4++;
};
}
public static function AsVector(_arg1:Array, _arg2:Number):b2PolygonShape{
var _local3:b2PolygonShape = new (b2PolygonShape);
_local3.SetAsVector(_arg1, _arg2);
return (_local3);
}
public static function AsArray(_arg1:Array, _arg2:Number):b2PolygonShape{
var _local3:b2PolygonShape = new (b2PolygonShape);
_local3.SetAsArray(_arg1, _arg2);
return (_local3);
}
public static function AsBox(_arg1:Number, _arg2:Number):b2PolygonShape{
var _local3:b2PolygonShape = new (b2PolygonShape);
_local3.SetAsBox(_arg1, _arg2);
return (_local3);
}
public static function AsOrientedBox(_arg1:Number, _arg2:Number, _arg3:b2Vec2=null, _arg4:Number=0):b2PolygonShape{
var _local5:b2PolygonShape = new (b2PolygonShape);
_local5.SetAsOrientedBox(_arg1, _arg2, _arg3, _arg4);
return (_local5);
}
public static function ComputeCentroid(_arg1:Array, _arg2:uint):b2Vec2{
var _local3:b2Vec2;
var _local7:Number;
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
_local3 = new b2Vec2();
var _local4:Number = 0;
var _local5:Number = 0;
var _local6:Number = 0;
_local7 = (1 / 3);
var _local8:int;
while (_local8 < _arg2) {
_local9 = _arg1[_local8];
_local10 = (((_local8 + 1) < _arg2)) ? _arg1[int((_local8 + 1))] : _arg1[0];
_local11 = (_local9.x - _local5);
_local12 = (_local9.y - _local6);
_local13 = (_local10.x - _local5);
_local14 = (_local10.y - _local6);
_local15 = ((_local11 * _local14) - (_local12 * _local13));
_local16 = (0.5 * _local15);
_local4 = (_local4 + _local16);
_local3.x = (_local3.x + ((_local16 * _local7) * ((_local5 + _local9.x) + _local10.x)));
_local3.y = (_local3.y + ((_local16 * _local7) * ((_local6 + _local9.y) + _local10.y)));
_local8++;
};
_local3.x = (_local3.x * (1 / _local4));
_local3.y = (_local3.y * (1 / _local4));
return (_local3);
}
public static function AsEdge(_arg1:b2Vec2, _arg2:b2Vec2):b2PolygonShape{
var _local3:b2PolygonShape = new (b2PolygonShape);
_local3.SetAsEdge(_arg1, _arg2);
return (_local3);
}
}
}//package Box2D.Collision.Shapes
Section 5
//b2Shape (Box2D.Collision.Shapes.b2Shape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2Shape {
b2internal var m_radius:Number;
b2internal var m_type:int;
b2internal static const e_polygonShape:int = 1;
public static const e_hitCollide:int = 1;
public static const e_missCollide:int = 0;
b2internal static const e_edgeShape:int = 2;
b2internal static const e_shapeTypeCount:int = 3;
b2internal static const e_unknownShape:int = -1;
b2internal static const e_circleShape:int = 0;
public static const e_startsInsideCollide:int = -1;
public function b2Shape(){
m_type = e_unknownShape;
m_radius = b2Settings.b2_linearSlop;
}
public function RayCast(_arg1:b2RayCastOutput, _arg2:b2RayCastInput, _arg3:b2Transform):Boolean{
return (false);
}
public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2Transform, _arg4:b2Vec2):Number{
return (0);
}
public function Set(_arg1:b2Shape):void{
m_radius = _arg1.m_radius;
}
public function ComputeMass(_arg1:b2MassData, _arg2:Number):void{
}
public function GetType():int{
return (m_type);
}
public function Copy():b2Shape{
return (null);
}
public function ComputeAABB(_arg1:b2AABB, _arg2:b2Transform):void{
}
public function TestPoint(_arg1:b2Transform, _arg2:b2Vec2):Boolean{
return (false);
}
public static function TestOverlap(_arg1:b2Shape, _arg2:b2Transform, _arg3:b2Shape, _arg4:b2Transform):Boolean{
var _local5:b2DistanceInput = new b2DistanceInput();
_local5.proxyA = new b2DistanceProxy();
_local5.proxyA.Set(_arg1);
_local5.proxyB = new b2DistanceProxy();
_local5.proxyB.Set(_arg3);
_local5.transformA = _arg2;
_local5.transformB = _arg4;
_local5.useRadii = true;
var _local6:b2SimplexCache = new b2SimplexCache();
_local6.count = 0;
var _local7:b2DistanceOutput = new b2DistanceOutput();
b2Distance.Distance(_local7, _local6, _local5);
return ((_local7.distance < (10 * Number.MIN_VALUE)));
}
}
}//package Box2D.Collision.Shapes
Section 6
//b2AABB (Box2D.Collision.b2AABB)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2AABB {
public var upperBound:b2Vec2;
public var lowerBound:b2Vec2;
public function b2AABB(){
lowerBound = new b2Vec2();
upperBound = new b2Vec2();
super();
}
public function Contains(_arg1:b2AABB):Boolean{
var _local2:Boolean;
_local2 = ((_local2) && ((lowerBound.x <= _arg1.lowerBound.x)));
_local2 = ((_local2) && ((lowerBound.y <= _arg1.lowerBound.y)));
_local2 = ((_local2) && ((_arg1.upperBound.x <= upperBound.x)));
_local2 = ((_local2) && ((_arg1.upperBound.y <= upperBound.y)));
return (_local2);
}
public function RayCast(_arg1:b2RayCastOutput, _arg2:b2RayCastInput):Boolean{
var _local11:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local3:Number = -(Number.MAX_VALUE);
var _local4:Number = Number.MAX_VALUE;
var _local5:Number = _arg2.p1.x;
var _local6:Number = _arg2.p1.y;
var _local7:Number = (_arg2.p2.x - _arg2.p1.x);
var _local8:Number = (_arg2.p2.y - _arg2.p1.y);
var _local9:Number = Math.abs(_local7);
var _local10:Number = Math.abs(_local8);
_local11 = _arg1.normal;
if (_local9 < Number.MIN_VALUE){
if ((((_local5 < lowerBound.x)) || ((upperBound.x < _local5)))){
return (false);
};
} else {
_local12 = (1 / _local7);
_local13 = ((lowerBound.x - _local5) * _local12);
_local14 = ((upperBound.x - _local5) * _local12);
_local16 = -1;
if (_local13 > _local14){
_local15 = _local13;
_local13 = _local14;
_local14 = _local15;
_local16 = 1;
};
if (_local13 > _local3){
_local11.x = _local16;
_local11.y = 0;
_local3 = _local13;
};
_local4 = Math.min(_local4, _local14);
if (_local3 > _local4){
return (false);
};
};
if (_local10 < Number.MIN_VALUE){
if ((((_local6 < lowerBound.y)) || ((upperBound.y < _local6)))){
return (false);
};
} else {
_local12 = (1 / _local8);
_local13 = ((lowerBound.y - _local6) * _local12);
_local14 = ((upperBound.y - _local6) * _local12);
_local16 = -1;
if (_local13 > _local14){
_local15 = _local13;
_local13 = _local14;
_local14 = _local15;
_local16 = 1;
};
if (_local13 > _local3){
_local11.y = _local16;
_local11.x = 0;
_local3 = _local13;
};
_local4 = Math.min(_local4, _local14);
if (_local3 > _local4){
return (false);
};
};
_arg1.fraction = _local3;
return (true);
}
public function GetCenter():b2Vec2{
return (new b2Vec2(((lowerBound.x + upperBound.x) / 2), ((lowerBound.y + upperBound.y) / 2)));
}
public function IsValid():Boolean{
var _local1:Number = (upperBound.x - lowerBound.x);
var _local2:Number = (upperBound.y - lowerBound.y);
var _local3:Boolean = (((_local1 >= 0)) && ((_local2 >= 0)));
_local3 = ((((_local3) && (lowerBound.IsValid()))) && (upperBound.IsValid()));
return (_local3);
}
public function TestOverlap(_arg1:b2AABB):Boolean{
var _local2:Number = (_arg1.lowerBound.x - upperBound.x);
var _local3:Number = (_arg1.lowerBound.y - upperBound.y);
var _local4:Number = (lowerBound.x - _arg1.upperBound.x);
var _local5:Number = (lowerBound.y - _arg1.upperBound.y);
if ((((_local2 > 0)) || ((_local3 > 0)))){
return (false);
};
if ((((_local4 > 0)) || ((_local5 > 0)))){
return (false);
};
return (true);
}
public function GetExtents():b2Vec2{
return (new b2Vec2(((upperBound.x - lowerBound.x) / 2), ((upperBound.y - lowerBound.y) / 2)));
}
public function Combine(_arg1:b2AABB, _arg2:b2AABB):void{
lowerBound.x = Math.min(_arg1.lowerBound.x, _arg2.lowerBound.x);
lowerBound.y = Math.min(_arg1.lowerBound.y, _arg2.lowerBound.y);
upperBound.x = Math.max(_arg1.upperBound.x, _arg2.upperBound.x);
upperBound.y = Math.max(_arg1.upperBound.y, _arg2.upperBound.y);
}
public static function Combine(_arg1:b2AABB, _arg2:b2AABB):b2AABB{
var _local3:b2AABB = new (b2AABB);
_local3.Combine(_arg1, _arg2);
return (_local3);
}
}
}//package Box2D.Collision
Section 7
//b2Collision (Box2D.Collision.b2Collision)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Collision {
public static const b2_nullFeature:uint = 0xFF;
private static var b2CollidePolyTempVec:b2Vec2 = new b2Vec2();
private static var s_v12:b2Vec2 = new b2Vec2();
private static var s_v11:b2Vec2 = new b2Vec2();
private static var s_edgeBO:Array = new Array(1);
private static var s_tangent2:b2Vec2 = new b2Vec2();
private static var s_planePoint:b2Vec2 = new b2Vec2();
private static var s_localTangent:b2Vec2 = new b2Vec2();
private static var s_clipPoints1:Array = MakeClipPointVector();
private static var s_clipPoints2:Array = MakeClipPointVector();
private static var s_localNormal:b2Vec2 = new b2Vec2();
private static var s_edgeAO:Array = new Array(1);
private static var s_tangent:b2Vec2 = new b2Vec2();
private static var s_normal:b2Vec2 = new b2Vec2();
private static var s_incidentEdge:Array = MakeClipPointVector();
public static function EdgeSeparation(_arg1:b2PolygonShape, _arg2:b2Transform, _arg3:int, _arg4:b2PolygonShape, _arg5:b2Transform):Number{
var _local11:b2Mat22;
var _local12:b2Vec2;
var _local25:Number;
var _local6:int = _arg1.m_vertexCount;
var _local7:Array = _arg1.m_vertices;
var _local8:Array = _arg1.m_normals;
var _local9:int = _arg4.m_vertexCount;
var _local10:Array = _arg4.m_vertices;
_local11 = _arg2.R;
_local12 = _local8[_arg3];
var _local13:Number = ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y));
var _local14:Number = ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y));
_local11 = _arg5.R;
var _local15:Number = ((_local11.col1.x * _local13) + (_local11.col1.y * _local14));
var _local16:Number = ((_local11.col2.x * _local13) + (_local11.col2.y * _local14));
var _local17:int;
var _local18:Number = Number.MAX_VALUE;
var _local19:int;
while (_local19 < _local9) {
_local12 = _local10[_local19];
_local25 = ((_local12.x * _local15) + (_local12.y * _local16));
if (_local25 < _local18){
_local18 = _local25;
_local17 = _local19;
};
_local19++;
};
_local12 = _local7[_arg3];
_local11 = _arg2.R;
var _local20:Number = (_arg2.position.x + ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y)));
var _local21:Number = (_arg2.position.y + ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y)));
_local12 = _local10[_local17];
_local11 = _arg5.R;
var _local22:Number = (_arg5.position.x + ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y)));
var _local23:Number = (_arg5.position.y + ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y)));
_local22 = (_local22 - _local20);
_local23 = (_local23 - _local21);
var _local24:Number = ((_local22 * _local13) + (_local23 * _local14));
return (_local24);
}
public static function ClipSegmentToLine(_arg1:Array, _arg2:Array, _arg3:b2Vec2, _arg4:Number):int{
var _local5:ClipVertex;
var _local6:int;
var _local7:b2Vec2;
var _local9:Number;
var _local11:Number;
var _local12:b2Vec2;
var _local13:ClipVertex;
_local6 = 0;
_local5 = _arg2[0];
_local7 = _local5.v;
_local5 = _arg2[1];
var _local8:b2Vec2 = _local5.v;
_local9 = (((_arg3.x * _local7.x) + (_arg3.y * _local7.y)) - _arg4);
var _local10:Number = (((_arg3.x * _local8.x) + (_arg3.y * _local8.y)) - _arg4);
if (_local9 <= 0){
var _temp1 = _local6;
_local6 = (_local6 + 1);
_arg1[_temp1].Set(_arg2[0]);
};
if (_local10 <= 0){
var _temp2 = _local6;
_local6 = (_local6 + 1);
_arg1[_temp2].Set(_arg2[1]);
};
if ((_local9 * _local10) < 0){
_local11 = (_local9 / (_local9 - _local10));
_local5 = _arg1[_local6];
_local12 = _local5.v;
_local12.x = (_local7.x + (_local11 * (_local8.x - _local7.x)));
_local12.y = (_local7.y + (_local11 * (_local8.y - _local7.y)));
_local5 = _arg1[_local6];
if (_local9 > 0){
_local13 = _arg2[0];
_local5.id = _local13.id;
} else {
_local13 = _arg2[1];
_local5.id = _local13.id;
};
_local6++;
};
return (_local6);
}
private static function MakeClipPointVector():Array{
var _local1:Array = new Array(2);
_local1[0] = new ClipVertex();
_local1[1] = new ClipVertex();
return (_local1);
}
public static function CollideCircles(_arg1:b2Manifold, _arg2:b2CircleShape, _arg3:b2Transform, _arg4:b2CircleShape, _arg5:b2Transform):void{
var _local6:b2Mat22;
var _local7:b2Vec2;
_arg1.m_pointCount = 0;
_local6 = _arg3.R;
_local7 = _arg2.m_p;
var _local8:Number = (_arg3.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y)));
var _local9:Number = (_arg3.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y)));
_local6 = _arg5.R;
_local7 = _arg4.m_p;
var _local10:Number = (_arg5.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y)));
var _local11:Number = (_arg5.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y)));
var _local12:Number = (_local10 - _local8);
var _local13:Number = (_local11 - _local9);
var _local14:Number = ((_local12 * _local12) + (_local13 * _local13));
var _local15:Number = (_arg2.m_radius + _arg4.m_radius);
if (_local14 > (_local15 * _local15)){
return;
};
_arg1.m_type = b2Manifold.e_circles;
_arg1.m_localPoint.SetV(_arg2.m_p);
_arg1.m_localPlaneNormal.SetZero();
_arg1.m_pointCount = 1;
_arg1.m_points[0].m_localPoint.SetV(_arg4.m_p);
_arg1.m_points[0].m_id.key = 0;
}
public static function FindIncidentEdge(_arg1:Array, _arg2:b2PolygonShape, _arg3:b2Transform, _arg4:int, _arg5:b2PolygonShape, _arg6:b2Transform):void{
var _local12:b2Mat22;
var _local13:b2Vec2;
var _local20:ClipVertex;
var _local23:Number;
var _local7:int = _arg2.m_vertexCount;
var _local8:Array = _arg2.m_normals;
var _local9:int = _arg5.m_vertexCount;
var _local10:Array = _arg5.m_vertices;
var _local11:Array = _arg5.m_normals;
_local12 = _arg3.R;
_local13 = _local8[_arg4];
var _local14:Number = ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y));
var _local15:Number = ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y));
_local12 = _arg6.R;
var _local16:Number = ((_local12.col1.x * _local14) + (_local12.col1.y * _local15));
_local15 = ((_local12.col2.x * _local14) + (_local12.col2.y * _local15));
_local14 = _local16;
var _local17:int;
var _local18:Number = Number.MAX_VALUE;
var _local19:int;
while (_local19 < _local9) {
_local13 = _local11[_local19];
_local23 = ((_local14 * _local13.x) + (_local15 * _local13.y));
if (_local23 < _local18){
_local18 = _local23;
_local17 = _local19;
};
_local19++;
};
var _local21:int = _local17;
var _local22:int = (((_local21 + 1) < _local9)) ? (_local21 + 1) : 0;
_local20 = _arg1[0];
_local13 = _local10[_local21];
_local12 = _arg6.R;
_local20.v.x = (_arg6.position.x + ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y)));
_local20.v.y = (_arg6.position.y + ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y)));
_local20.id.features.referenceEdge = _arg4;
_local20.id.features.incidentEdge = _local21;
_local20.id.features.incidentVertex = 0;
_local20 = _arg1[1];
_local13 = _local10[_local22];
_local12 = _arg6.R;
_local20.v.x = (_arg6.position.x + ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y)));
_local20.v.y = (_arg6.position.y + ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y)));
_local20.id.features.referenceEdge = _arg4;
_local20.id.features.incidentEdge = _local22;
_local20.id.features.incidentVertex = 1;
}
public static function CollidePolygonAndCircle(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2Transform, _arg4:b2CircleShape, _arg5:b2Transform):void{
var _local6:b2ManifoldPoint;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:b2Vec2;
var _local12:b2Mat22;
var _local17:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
_arg1.m_pointCount = 0;
_local12 = _arg5.R;
_local11 = _arg4.m_p;
var _local13:Number = (_arg5.position.x + ((_local12.col1.x * _local11.x) + (_local12.col2.x * _local11.y)));
var _local14:Number = (_arg5.position.y + ((_local12.col1.y * _local11.x) + (_local12.col2.y * _local11.y)));
_local7 = (_local13 - _arg3.position.x);
_local8 = (_local14 - _arg3.position.y);
_local12 = _arg3.R;
var _local15:Number = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
var _local16:Number = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
var _local18:int;
var _local19:Number = -(Number.MAX_VALUE);
var _local20:Number = (_arg2.m_radius + _arg4.m_radius);
var _local21:int = _arg2.m_vertexCount;
var _local22:Array = _arg2.m_vertices;
var _local23:Array = _arg2.m_normals;
var _local24:int;
while (_local24 < _local21) {
_local11 = _local22[_local24];
_local7 = (_local15 - _local11.x);
_local8 = (_local16 - _local11.y);
_local11 = _local23[_local24];
_local31 = ((_local11.x * _local7) + (_local11.y * _local8));
if (_local31 > _local20){
return;
};
if (_local31 > _local19){
_local19 = _local31;
_local18 = _local24;
};
_local24++;
};
var _local25:int = _local18;
var _local26:int = (((_local25 + 1) < _local21)) ? (_local25 + 1) : 0;
var _local27:b2Vec2 = _local22[_local25];
var _local28:b2Vec2 = _local22[_local26];
if (_local19 < Number.MIN_VALUE){
_arg1.m_pointCount = 1;
_arg1.m_type = b2Manifold.e_faceA;
_arg1.m_localPlaneNormal.SetV(_local23[_local18]);
_arg1.m_localPoint.x = (0.5 * (_local27.x + _local28.x));
_arg1.m_localPoint.y = (0.5 * (_local27.y + _local28.y));
_arg1.m_points[0].m_localPoint.SetV(_arg4.m_p);
_arg1.m_points[0].m_id.key = 0;
return;
};
var _local29:Number = (((_local15 - _local27.x) * (_local28.x - _local27.x)) + ((_local16 - _local27.y) * (_local28.y - _local27.y)));
var _local30:Number = (((_local15 - _local28.x) * (_local27.x - _local28.x)) + ((_local16 - _local28.y) * (_local27.y - _local28.y)));
if (_local29 <= 0){
if ((((_local15 - _local27.x) * (_local15 - _local27.x)) + ((_local16 - _local27.y) * (_local16 - _local27.y))) > (_local20 * _local20)){
return;
};
_arg1.m_pointCount = 1;
_arg1.m_type = b2Manifold.e_faceA;
_arg1.m_localPlaneNormal.x = (_local15 - _local27.x);
_arg1.m_localPlaneNormal.y = (_local16 - _local27.y);
_arg1.m_localPlaneNormal.Normalize();
_arg1.m_localPoint.SetV(_local27);
_arg1.m_points[0].m_localPoint.SetV(_arg4.m_p);
_arg1.m_points[0].m_id.key = 0;
} else {
if (_local30 <= 0){
if ((((_local15 - _local28.x) * (_local15 - _local28.x)) + ((_local16 - _local28.y) * (_local16 - _local28.y))) > (_local20 * _local20)){
return;
};
_arg1.m_pointCount = 1;
_arg1.m_type = b2Manifold.e_faceA;
_arg1.m_localPlaneNormal.x = (_local15 - _local28.x);
_arg1.m_localPlaneNormal.y = (_local16 - _local28.y);
_arg1.m_localPlaneNormal.Normalize();
_arg1.m_localPoint.SetV(_local28);
_arg1.m_points[0].m_localPoint.SetV(_arg4.m_p);
_arg1.m_points[0].m_id.key = 0;
} else {
_local32 = (0.5 * (_local27.x + _local28.x));
_local33 = (0.5 * (_local27.y + _local28.y));
_local19 = (((_local15 - _local32) * _local23[_local25].x) + ((_local16 - _local33) * _local23[_local25].y));
if (_local19 > _local20){
return;
};
_arg1.m_pointCount = 1;
_arg1.m_type = b2Manifold.e_faceA;
_arg1.m_localPlaneNormal.x = _local23[_local25].x;
_arg1.m_localPlaneNormal.y = _local23[_local25].y;
_arg1.m_localPlaneNormal.Normalize();
_arg1.m_localPoint.Set(_local32, _local33);
_arg1.m_points[0].m_localPoint.SetV(_arg4.m_p);
_arg1.m_points[0].m_id.key = 0;
};
};
}
public static function CollidePolygons(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2Transform, _arg4:b2PolygonShape, _arg5:b2Transform):void{
var _local6:ClipVertex;
var _local12:b2PolygonShape;
var _local13:b2PolygonShape;
var _local14:b2Transform;
var _local15:b2Transform;
var _local16:int;
var _local17:uint;
var _local20:b2Mat22;
var _local25:b2Vec2;
var _local39:int;
var _local42:Number;
var _local43:b2ManifoldPoint;
var _local44:Number;
var _local45:Number;
_arg1.m_pointCount = 0;
var _local7:Number = (_arg2.m_radius + _arg4.m_radius);
var _local8:int;
s_edgeAO[0] = _local8;
var _local9:Number = FindMaxSeparation(s_edgeAO, _arg2, _arg3, _arg4, _arg5);
_local8 = s_edgeAO[0];
if (_local9 > _local7){
return;
};
var _local10:int;
s_edgeBO[0] = _local10;
var _local11:Number = FindMaxSeparation(s_edgeBO, _arg4, _arg5, _arg2, _arg3);
_local10 = s_edgeBO[0];
if (_local11 > _local7){
return;
};
var _local18:Number = 0.98;
var _local19:Number = 0.001;
if (_local11 > ((_local18 * _local9) + _local19)){
_local12 = _arg4;
_local13 = _arg2;
_local14 = _arg5;
_local15 = _arg3;
_local16 = _local10;
_arg1.m_type = b2Manifold.e_faceB;
_local17 = 1;
} else {
_local12 = _arg2;
_local13 = _arg4;
_local14 = _arg3;
_local15 = _arg5;
_local16 = _local8;
_arg1.m_type = b2Manifold.e_faceA;
_local17 = 0;
};
var _local21:Array = s_incidentEdge;
FindIncidentEdge(_local21, _local12, _local14, _local16, _local13, _local15);
var _local22:int = _local12.m_vertexCount;
var _local23:Array = _local12.m_vertices;
var _local24:b2Vec2 = _local23[_local16];
if ((_local16 + 1) < _local22){
_local25 = _local23[int((_local16 + 1))];
} else {
_local25 = _local23[0];
};
var _local26:b2Vec2 = s_localTangent;
_local26.Set((_local25.x - _local24.x), (_local25.y - _local24.y));
_local26.Normalize();
var _local27:b2Vec2 = s_localNormal;
_local27.x = _local26.y;
_local27.y = -(_local26.x);
var _local28:b2Vec2 = s_planePoint;
_local28.Set((0.5 * (_local24.x + _local25.x)), (0.5 * (_local24.y + _local25.y)));
var _local29:b2Vec2 = s_tangent;
_local20 = _local14.R;
_local29.x = ((_local20.col1.x * _local26.x) + (_local20.col2.x * _local26.y));
_local29.y = ((_local20.col1.y * _local26.x) + (_local20.col2.y * _local26.y));
var _local30:b2Vec2 = s_tangent2;
_local30.x = -(_local29.x);
_local30.y = -(_local29.y);
var _local31:b2Vec2 = s_normal;
_local31.x = _local29.y;
_local31.y = -(_local29.x);
var _local32:b2Vec2 = s_v11;
var _local33:b2Vec2 = s_v12;
_local32.x = (_local14.position.x + ((_local20.col1.x * _local24.x) + (_local20.col2.x * _local24.y)));
_local32.y = (_local14.position.y + ((_local20.col1.y * _local24.x) + (_local20.col2.y * _local24.y)));
_local33.x = (_local14.position.x + ((_local20.col1.x * _local25.x) + (_local20.col2.x * _local25.y)));
_local33.y = (_local14.position.y + ((_local20.col1.y * _local25.x) + (_local20.col2.y * _local25.y)));
var _local34:Number = ((_local31.x * _local32.x) + (_local31.y * _local32.y));
var _local35:Number = (((-(_local29.x) * _local32.x) - (_local29.y * _local32.y)) + _local7);
var _local36:Number = (((_local29.x * _local33.x) + (_local29.y * _local33.y)) + _local7);
var _local37:Array = s_clipPoints1;
var _local38:Array = s_clipPoints2;
_local39 = ClipSegmentToLine(_local37, _local21, _local30, _local35);
if (_local39 < 2){
return;
};
_local39 = ClipSegmentToLine(_local38, _local37, _local29, _local36);
if (_local39 < 2){
return;
};
_arg1.m_localPlaneNormal.SetV(_local27);
_arg1.m_localPoint.SetV(_local28);
var _local40:int;
var _local41:int;
while (_local41 < b2Settings.b2_maxManifoldPoints) {
_local6 = _local38[_local41];
_local42 = (((_local31.x * _local6.v.x) + (_local31.y * _local6.v.y)) - _local34);
if (_local42 <= _local7){
_local43 = _arg1.m_points[_local40];
_local20 = _local15.R;
_local44 = (_local6.v.x - _local15.position.x);
_local45 = (_local6.v.y - _local15.position.y);
_local43.m_localPoint.x = ((_local44 * _local20.col1.x) + (_local45 * _local20.col1.y));
_local43.m_localPoint.y = ((_local44 * _local20.col2.x) + (_local45 * _local20.col2.y));
_local43.m_id.Set(_local6.id);
_local43.m_id.features.flip = _local17;
_local40++;
};
_local41++;
};
_arg1.m_pointCount = _local40;
}
public static function FindMaxSeparation(_arg1:Array, _arg2:b2PolygonShape, _arg3:b2Transform, _arg4:b2PolygonShape, _arg5:b2Transform):Number{
var _local8:b2Vec2;
var _local9:b2Mat22;
var _local22:int;
var _local23:Number;
var _local24:int;
var _local25:Number;
var _local6:int = _arg2.m_vertexCount;
var _local7:Array = _arg2.m_normals;
_local9 = _arg5.R;
_local8 = _arg4.m_centroid;
var _local10:Number = (_arg5.position.x + ((_local9.col1.x * _local8.x) + (_local9.col2.x * _local8.y)));
var _local11:Number = (_arg5.position.y + ((_local9.col1.y * _local8.x) + (_local9.col2.y * _local8.y)));
_local9 = _arg3.R;
_local8 = _arg2.m_centroid;
_local10 = (_local10 - (_arg3.position.x + ((_local9.col1.x * _local8.x) + (_local9.col2.x * _local8.y))));
_local11 = (_local11 - (_arg3.position.y + ((_local9.col1.y * _local8.x) + (_local9.col2.y * _local8.y))));
var _local12:Number = ((_local10 * _arg3.R.col1.x) + (_local11 * _arg3.R.col1.y));
var _local13:Number = ((_local10 * _arg3.R.col2.x) + (_local11 * _arg3.R.col2.y));
var _local14:int;
var _local15:Number = -(Number.MAX_VALUE);
var _local16:int;
while (_local16 < _local6) {
_local8 = _local7[_local16];
_local25 = ((_local8.x * _local12) + (_local8.y * _local13));
if (_local25 > _local15){
_local15 = _local25;
_local14 = _local16;
};
_local16++;
};
var _local17:Number = EdgeSeparation(_arg2, _arg3, _local14, _arg4, _arg5);
var _local18:int = (((_local14 - 1) >= 0)) ? (_local14 - 1) : (_local6 - 1);
var _local19:Number = EdgeSeparation(_arg2, _arg3, _local18, _arg4, _arg5);
var _local20:int = (((_local14 + 1) < _local6)) ? (_local14 + 1) : 0;
var _local21:Number = EdgeSeparation(_arg2, _arg3, _local20, _arg4, _arg5);
if ((((_local19 > _local17)) && ((_local19 > _local21)))){
_local24 = -1;
_local22 = _local18;
_local23 = _local19;
} else {
if (_local21 > _local17){
_local24 = 1;
_local22 = _local20;
_local23 = _local21;
} else {
_arg1[0] = _local14;
return (_local17);
};
};
while (true) {
if (_local24 == -1){
_local14 = (((_local22 - 1) >= 0)) ? (_local22 - 1) : (_local6 - 1);
} else {
_local14 = (((_local22 + 1) < _local6)) ? (_local22 + 1) : 0;
};
_local17 = EdgeSeparation(_arg2, _arg3, _local14, _arg4, _arg5);
if (_local17 > _local23){
_local22 = _local14;
_local23 = _local17;
} else {
break;
};
};
_arg1[0] = _local22;
return (_local23);
}
public static function TestOverlap(_arg1:b2AABB, _arg2:b2AABB):Boolean{
var _local3:b2Vec2 = _arg2.lowerBound;
var _local4:b2Vec2 = _arg1.upperBound;
var _local5:Number = (_local3.x - _local4.x);
var _local6:Number = (_local3.y - _local4.y);
_local3 = _arg1.lowerBound;
_local4 = _arg2.upperBound;
var _local7:Number = (_local3.x - _local4.x);
var _local8:Number = (_local3.y - _local4.y);
if ((((_local5 > 0)) || ((_local6 > 0)))){
return (false);
};
if ((((_local7 > 0)) || ((_local8 > 0)))){
return (false);
};
return (true);
}
}
}//package Box2D.Collision
Section 8
//b2ContactID (Box2D.Collision.b2ContactID)
package Box2D.Collision {
import Box2D.Common.*;
public class b2ContactID {
b2internal var _key:uint;
public var features:Features;
public function b2ContactID(){
features = new Features();
super();
features._m_id = this;
}
public function Set(_arg1:b2ContactID):void{
key = _arg1._key;
}
public function Copy():b2ContactID{
var _local1:b2ContactID = new b2ContactID();
_local1.key = key;
return (_local1);
}
public function set key(_arg1:uint):void{
_key = _arg1;
features._referenceEdge = (_key & 0xFF);
features._incidentEdge = (((_key & 0xFF00) >> 8) & 0xFF);
features._incidentVertex = (((_key & 0xFF0000) >> 16) & 0xFF);
features._flip = (((_key & 4278190080) >> 24) & 0xFF);
}
public function get key():uint{
return (_key);
}
}
}//package Box2D.Collision
Section 9
//b2ContactPoint (Box2D.Collision.b2ContactPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
public class b2ContactPoint {
public var friction:Number;
public var separation:Number;
public var normal:b2Vec2;
public var position:b2Vec2;
public var restitution:Number;
public var shape1:b2Shape;
public var shape2:b2Shape;
public var id:b2ContactID;
public var velocity:b2Vec2;
public function b2ContactPoint(){
position = new b2Vec2();
velocity = new b2Vec2();
normal = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Collision
Section 10
//b2Distance (Box2D.Collision.b2Distance)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Distance {
private static var b2_gjkIters:int;
private static var b2_gjkMaxIters:int;
private static var s_saveB:Array = new Array(3);
private static var s_simplex:b2Simplex = new b2Simplex();
private static var b2_gjkCalls:int;
private static var s_saveA:Array = new Array(3);
public static function Distance(_arg1:b2DistanceOutput, _arg2:b2SimplexCache, _arg3:b2DistanceInput):void{
var _local17:int;
var _local18:b2Vec2;
var _local20:b2Vec2;
var _local21:b2SimplexVertex;
var _local22:Boolean;
var _local23:Number;
var _local24:Number;
var _local25:b2Vec2;
b2_gjkCalls++;
var _local4:b2DistanceProxy = _arg3.proxyA;
var _local5:b2DistanceProxy = _arg3.proxyB;
var _local6:b2Transform = _arg3.transformA;
var _local7:b2Transform = _arg3.transformB;
var _local8:b2Simplex = s_simplex;
_local8.ReadCache(_arg2, _local4, _local6, _local5, _local7);
var _local9:Array = _local8.m_vertices;
var _local10 = 20;
var _local11:Array = s_saveA;
var _local12:Array = s_saveB;
var _local13:int;
var _local14:b2Vec2 = _local8.GetClosestPoint();
var _local15:Number = _local14.LengthSquared();
var _local16:Number = _local15;
var _local19:int;
while (_local19 < _local10) {
_local13 = _local8.m_count;
_local17 = 0;
while (_local17 < _local13) {
_local11[_local17] = _local9[_local17].indexA;
_local12[_local17] = _local9[_local17].indexB;
_local17++;
};
switch (_local8.m_count){
case 1:
break;
case 2:
_local8.Solve2();
break;
case 3:
_local8.Solve3();
break;
default:
b2Settings.b2Assert(false);
};
if (_local8.m_count == 3){
break;
};
_local18 = _local8.GetClosestPoint();
_local16 = _local18.LengthSquared();
if (_local16 > _local15){
};
_local15 = _local16;
_local20 = _local8.GetSearchDirection();
if (_local20.LengthSquared() < (Number.MIN_VALUE * Number.MIN_VALUE)){
break;
};
_local21 = _local9[_local8.m_count];
_local21.indexA = _local4.GetSupport(b2Math.MulTMV(_local6.R, _local20.GetNegative()));
_local21.wA = b2Math.MulX(_local6, _local4.GetVertex(_local21.indexA));
_local21.indexB = _local5.GetSupport(b2Math.MulTMV(_local7.R, _local20));
_local21.wB = b2Math.MulX(_local7, _local5.GetVertex(_local21.indexB));
_local21.w = b2Math.SubtractVV(_local21.wB, _local21.wA);
_local19++;
b2_gjkIters++;
_local22 = false;
_local17 = 0;
while (_local17 < _local13) {
if ((((_local21.indexA == _local11[_local17])) && ((_local21.indexB == _local12[_local17])))){
_local22 = true;
break;
};
_local17++;
};
if (_local22){
break;
};
_local8.m_count++;
};
b2_gjkMaxIters = b2Math.Max(b2_gjkMaxIters, _local19);
_local8.GetWitnessPoints(_arg1.pointA, _arg1.pointB);
_arg1.distance = b2Math.SubtractVV(_arg1.pointA, _arg1.pointB).Length();
_arg1.iterations = _local19;
_local8.WriteCache(_arg2);
if (_arg3.useRadii){
_local23 = _local4.m_radius;
_local24 = _local5.m_radius;
if ((((_arg1.distance > (_local23 + _local24))) && ((_arg1.distance > Number.MIN_VALUE)))){
_arg1.distance = (_arg1.distance - (_local23 + _local24));
_local25 = b2Math.SubtractVV(_arg1.pointB, _arg1.pointA);
_local25.Normalize();
_arg1.pointA.x = (_arg1.pointA.x + (_local23 * _local25.x));
_arg1.pointA.y = (_arg1.pointA.y + (_local23 * _local25.y));
_arg1.pointB.x = (_arg1.pointB.x - (_local24 * _local25.x));
_arg1.pointB.y = (_arg1.pointB.y - (_local24 * _local25.y));
} else {
_local18 = new b2Vec2();
_local18.x = (0.5 * (_arg1.pointA.x + _arg1.pointB.x));
_local18.y = (0.5 * (_arg1.pointA.y + _arg1.pointB.y));
_arg1.pointA.x = (_arg1.pointB.x = _local18.x);
_arg1.pointA.y = (_arg1.pointB.y = _local18.y);
_arg1.distance = 0;
};
};
}
}
}//package Box2D.Collision
Section 11
//b2DistanceInput (Box2D.Collision.b2DistanceInput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2DistanceInput {
public var proxyA:b2DistanceProxy;
public var proxyB:b2DistanceProxy;
public var transformA:b2Transform;
public var transformB:b2Transform;
public var useRadii:Boolean;
}
}//package Box2D.Collision
Section 12
//b2DistanceOutput (Box2D.Collision.b2DistanceOutput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2DistanceOutput {
public var pointA:b2Vec2;
public var distance:Number;
public var iterations:int;
public var pointB:b2Vec2;
public function b2DistanceOutput(){
pointA = new b2Vec2();
pointB = new b2Vec2();
super();
}
}
}//package Box2D.Collision
Section 13
//b2DistanceProxy (Box2D.Collision.b2DistanceProxy)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2DistanceProxy {
public var m_radius:Number;
public var m_vertices:Array;
public var m_count:int;
public function GetVertex(_arg1:int):b2Vec2{
b2Settings.b2Assert((((0 <= _arg1)) && ((_arg1 < m_count))));
return (m_vertices[_arg1]);
}
public function Set(_arg1:b2Shape):void{
var _local2:b2CircleShape;
var _local3:b2PolygonShape;
switch (_arg1.GetType()){
case b2Shape.e_circleShape:
_local2 = (_arg1 as b2CircleShape);
m_vertices = new Array(1, true);
m_vertices[0] = _local2.m_p;
m_count = 1;
m_radius = _local2.m_radius;
break;
case b2Shape.e_polygonShape:
_local3 = (_arg1 as b2PolygonShape);
m_vertices = _local3.m_vertices;
m_count = _local3.m_vertexCount;
m_radius = _local3.m_radius;
break;
default:
b2Settings.b2Assert(false);
};
}
public function GetSupportVertex(_arg1:b2Vec2):b2Vec2{
var _local5:Number;
var _local2:int;
var _local3:Number = ((m_vertices[0].x * _arg1.x) + (m_vertices[0].y * _arg1.y));
var _local4 = 1;
while (_local4 < m_count) {
_local5 = ((m_vertices[_local4].x * _arg1.x) + (m_vertices[_local4].y * _arg1.y));
if (_local5 > _local3){
_local2 = _local4;
_local3 = _local5;
};
_local4++;
};
return (m_vertices[_local2]);
}
public function GetVertexCount():int{
return (m_count);
}
public function GetSupport(_arg1:b2Vec2):Number{
var _local5:Number;
var _local2:int;
var _local3:Number = ((m_vertices[0].x * _arg1.x) + (m_vertices[0].y * _arg1.y));
var _local4 = 1;
while (_local4 < m_count) {
_local5 = ((m_vertices[_local4].x * _arg1.x) + (m_vertices[_local4].y * _arg1.y));
if (_local5 > _local3){
_local2 = _local4;
_local3 = _local5;
};
_local4++;
};
return (_local2);
}
}
}//package Box2D.Collision
Section 14
//b2DynamicTree (Box2D.Collision.b2DynamicTree)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2DynamicTree {
private var m_insertionCount:int;
private var m_root:b2DynamicTreeNode;
private var m_freeList:b2DynamicTreeNode;
private var m_path:uint;
public function b2DynamicTree(){
m_root = null;
m_freeList = null;
m_path = 0;
m_insertionCount = 0;
}
private function RemoveLeaf(_arg1:b2DynamicTreeNode):void{
var _local4:b2DynamicTreeNode;
var _local5:b2AABB;
if (_arg1 == m_root){
m_root = null;
return;
};
var _local2:b2DynamicTreeNode = _arg1.parent;
var _local3:b2DynamicTreeNode = _local2.parent;
if (_local2.child1 == _arg1){
_local4 = _local2.child2;
} else {
_local4 = _local2.child1;
};
if (_local3){
if (_local3.child1 == _local2){
_local3.child1 = _local4;
} else {
_local3.child2 = _local4;
};
_local4.parent = _local3;
FreeNode(_local2);
while (_local3) {
_local5 = _local3.aabb;
_local3.aabb = b2AABB.Combine(_local3.child1.aabb, _local3.child2.aabb);
if (_local5.Contains(_local3.aabb)){
break;
};
_local3 = _local3.parent;
};
} else {
m_root = _local4;
_local4.parent = null;
FreeNode(_local2);
};
}
public function GetFatAABB(_arg1:b2DynamicTreeNode):b2AABB{
return (_arg1.aabb);
}
public function Query(_arg1:Function, _arg2:b2AABB):void{
var _local5:b2DynamicTreeNode;
var _local6:Boolean;
if (m_root == null){
return;
};
var _local3:Array = new Array();
var _local4:int;
var _temp1 = _local4;
_local4 = (_local4 + 1);
var _local7 = _temp1;
_local3[_local7] = m_root;
while (_local4 > 0) {
--_local4;
_local5 = _local3[_local4];
if (_local5.aabb.TestOverlap(_arg2)){
if (_local5.IsLeaf()){
_local6 = _arg1(_local5);
if (!_local6){
return;
};
} else {
var _temp2 = _local4;
_local4 = (_local4 + 1);
var _local8 = _temp2;
_local3[_local8] = _local5.child1;
var _temp3 = _local4;
_local4 = (_local4 + 1);
var _local9 = _temp3;
_local3[_local9] = _local5.child2;
};
};
};
}
public function RayCast(_arg1:Function, _arg2:b2RayCastInput):void{
var _local3:b2Vec2;
var _local9:b2AABB;
var _local10:Number;
var _local11:Number;
var _local14:b2DynamicTreeNode;
var _local15:b2Vec2;
var _local16:b2Vec2;
var _local17:Number;
var _local18:b2RayCastInput;
if (m_root == null){
return;
};
_local3 = _arg2.p1;
var _local4:b2Vec2 = _arg2.p2;
var _local5:b2Vec2 = b2Math.SubtractVV(_local3, _local4);
_local5.Normalize();
var _local6:b2Vec2 = b2Math.CrossFV(1, _local5);
var _local7:b2Vec2 = b2Math.AbsV(_local6);
var _local8:Number = _arg2.maxFraction;
_local9 = new b2AABB();
_local10 = (_local3.x + (_local8 * (_local4.x - _local3.x)));
_local11 = (_local3.y + (_local8 * (_local4.y - _local3.y)));
_local9.lowerBound.x = Math.min(_local3.x, _local10);
_local9.lowerBound.y = Math.min(_local3.y, _local11);
_local9.upperBound.x = Math.max(_local3.x, _local10);
_local9.upperBound.y = Math.max(_local3.y, _local11);
var _local12:Array = new Array();
var _local13:int;
var _temp1 = _local13;
_local13 = (_local13 + 1);
var _local19 = _temp1;
_local12[_local19] = m_root;
while (_local13 > 0) {
--_local13;
_local14 = _local12[_local13];
if (_local14.aabb.TestOverlap(_local9) == false){
} else {
_local15 = _local14.aabb.GetCenter();
_local16 = _local14.aabb.GetExtents();
_local17 = ((Math.abs(((_local6.x * (_local3.x - _local15.x)) + (_local6.y * (_local3.y - _local15.y)))) - (_local7.x * _local16.x)) - (_local7.y * _local16.y));
if (_local17 > 0){
} else {
if (_local14.IsLeaf()){
_local18 = new b2RayCastInput();
_local18.p1 = _arg2.p1;
_local18.p2 = _arg2.p2;
_local18.maxFraction = _arg2.maxFraction;
_local8 = _arg1(_local18, _local14);
if (_local8 == 0){
return;
};
_local10 = (_local3.x + (_local8 * (_local4.x - _local3.x)));
_local11 = (_local3.y + (_local8 * (_local4.y - _local3.y)));
_local9.lowerBound.x = Math.min(_local3.x, _local10);
_local9.lowerBound.y = Math.min(_local3.y, _local11);
_local9.upperBound.x = Math.max(_local3.x, _local10);
_local9.upperBound.y = Math.max(_local3.y, _local11);
} else {
var _temp2 = _local13;
_local13 = (_local13 + 1);
var _local20 = _temp2;
_local12[_local20] = _local14.child1;
var _temp3 = _local13;
_local13 = (_local13 + 1);
var _local21 = _temp3;
_local12[_local21] = _local14.child2;
};
};
};
};
}
public function GetUserData(_arg1:b2DynamicTreeNode){
return (_arg1.userData);
}
private function FreeNode(_arg1:b2DynamicTreeNode):void{
_arg1.parent = m_freeList;
m_freeList = _arg1;
}
public function Rebalance(_arg1:int):void{
var _local3:b2DynamicTreeNode;
var _local4:uint;
if (m_root == null){
return;
};
var _local2:int;
while (_local2 < _arg1) {
_local3 = m_root;
_local4 = 0;
while (_local3.IsLeaf() == false) {
_local3 = (((m_path >> _local4) & 1)) ? _local3.child2 : _local3.child1;
_local4 = ((_local4 + 1) & 31);
};
m_path++;
RemoveLeaf(_local3);
InsertLeaf(_local3);
_local2++;
};
}
public function CreateProxy(_arg1:b2AABB, _arg2):b2DynamicTreeNode{
var _local3:b2DynamicTreeNode;
var _local4:Number;
var _local5:Number;
_local3 = AllocateNode();
_local4 = b2Settings.b2_aabbExtension;
_local5 = b2Settings.b2_aabbExtension;
_local3.aabb.lowerBound.x = (_arg1.lowerBound.x - _local4);
_local3.aabb.lowerBound.y = (_arg1.lowerBound.y - _local5);
_local3.aabb.upperBound.x = (_arg1.upperBound.x + _local4);
_local3.aabb.upperBound.y = (_arg1.upperBound.y + _local5);
_local3.userData = _arg2;
InsertLeaf(_local3);
return (_local3);
}
public function DestroyProxy(_arg1:b2DynamicTreeNode):void{
RemoveLeaf(_arg1);
FreeNode(_arg1);
}
private function InsertLeaf(_arg1:b2DynamicTreeNode):void{
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
m_insertionCount++;
if (m_root == null){
m_root = _arg1;
m_root.parent = null;
return;
};
var _local2:b2Vec2 = _arg1.aabb.GetCenter();
var _local3:b2DynamicTreeNode = m_root;
if (_local3.IsLeaf() == false){
do {
_local6 = _local3.child1;
_local7 = _local3.child2;
_local8 = (Math.abs((((_local6.aabb.lowerBound.x + _local6.aabb.upperBound.x) / 2) - _local2.x)) + Math.abs((((_local6.aabb.lowerBound.y + _local6.aabb.upperBound.y) / 2) - _local2.y)));
_local9 = (Math.abs((((_local7.aabb.lowerBound.x + _local7.aabb.upperBound.x) / 2) - _local2.x)) + Math.abs((((_local7.aabb.lowerBound.y + _local7.aabb.upperBound.y) / 2) - _local2.y)));
if (_local8 < _local9){
_local3 = _local6;
} else {
_local3 = _local7;
};
} while (_local3.IsLeaf() == false);
};
var _local4:b2DynamicTreeNode = _local3.parent;
var _local5:b2DynamicTreeNode = AllocateNode();
_local5.parent = _local4;
_local5.userData = null;
_local5.aabb.Combine(_arg1.aabb, _local3.aabb);
if (_local4){
if (_local3.parent.child1 == _local3){
_local4.child1 = _local5;
} else {
_local4.child2 = _local5;
};
_local5.child1 = _local3;
_local5.child2 = _arg1;
_local3.parent = _local5;
_arg1.parent = _local5;
do {
} while (!(_local4.aabb.Contains(_local5.aabb)));
} else {
_local5.child1 = _local3;
_local5.child2 = _arg1;
_local3.parent = _local5;
_arg1.parent = _local5;
m_root = _local5;
};
}
public function MoveProxy(_arg1:b2DynamicTreeNode, _arg2:b2AABB, _arg3:b2Vec2):Boolean{
var _local4:Number;
var _local5:Number;
b2Settings.b2Assert(_arg1.IsLeaf());
if (_arg1.aabb.Contains(_arg2)){
return (false);
};
RemoveLeaf(_arg1);
_local4 = (b2Settings.b2_aabbExtension + (b2Settings.b2_aabbMultiplier * ((_arg3.x > 0)) ? _arg3.x : -(_arg3.x)));
_local5 = (b2Settings.b2_aabbExtension + (b2Settings.b2_aabbMultiplier * ((_arg3.y > 0)) ? _arg3.y : -(_arg3.y)));
_arg1.aabb.lowerBound.x = (_arg2.lowerBound.x - _local4);
_arg1.aabb.lowerBound.y = (_arg2.lowerBound.y - _local5);
_arg1.aabb.upperBound.x = (_arg2.upperBound.x + _local4);
_arg1.aabb.upperBound.y = (_arg2.upperBound.y + _local5);
InsertLeaf(_arg1);
return (true);
}
private function AllocateNode():b2DynamicTreeNode{
var _local1:b2DynamicTreeNode;
if (m_freeList){
_local1 = m_freeList;
m_freeList = _local1.parent;
_local1.parent = null;
_local1.child1 = null;
_local1.child2 = null;
return (_local1);
};
return (new b2DynamicTreeNode());
}
}
}//package Box2D.Collision
Section 15
//b2DynamicTreeBroadPhase (Box2D.Collision.b2DynamicTreeBroadPhase)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2DynamicTreeBroadPhase implements IBroadPhase {
private var m_moveBuffer:Array;
private var m_tree:b2DynamicTree;
private var m_pairBuffer:Array;
private var m_pairCount:int;// = 0
private var m_proxyCount:int;
public function b2DynamicTreeBroadPhase(){
m_tree = new b2DynamicTree();
m_moveBuffer = new Array();
m_pairBuffer = new Array();
super();
}
public function Validate():void{
}
private function UnBufferMove(_arg1:b2DynamicTreeNode):void{
var _local2:int = m_moveBuffer.indexOf(_arg1);
m_moveBuffer.splice(_local2, 1);
}
private function BufferMove(_arg1:b2DynamicTreeNode):void{
m_moveBuffer[m_moveBuffer.length] = _arg1;
}
private function ComparePairs(_arg1:b2DynamicTreePair, _arg2:b2DynamicTreePair):int{
return (0);
}
public function GetProxyCount():int{
return (m_proxyCount);
}
public function GetFatAABB(_arg1):b2AABB{
return (m_tree.GetFatAABB(_arg1));
}
public function Query(_arg1:Function, _arg2:b2AABB):void{
m_tree.Query(_arg1, _arg2);
}
public function Rebalance(_arg1:int):void{
m_tree.Rebalance(_arg1);
}
public function TestOverlap(_arg1, _arg2):Boolean{
var _local3:b2AABB = m_tree.GetFatAABB(_arg1);
var _local4:b2AABB = m_tree.GetFatAABB(_arg2);
return (_local3.TestOverlap(_local4));
}
public function UpdatePairs(_arg1:Function):void{
var queryProxy:b2DynamicTreeNode;
var i:int;
var fatAABB:b2AABB;
var primaryPair:b2DynamicTreePair;
var userDataA:*;
var userDataB:*;
var pair:b2DynamicTreePair;
var callback = _arg1;
m_pairCount = 0;
for each (queryProxy in m_moveBuffer) {
var QueryCallback:Function = function (_arg1:b2DynamicTreeNode):Boolean{
if (_arg1 == queryProxy){
return (true);
};
if (m_pairCount == m_pairBuffer.length){
m_pairBuffer[m_pairCount] = new b2DynamicTreePair();
};
var _local2:b2DynamicTreePair = m_pairBuffer[m_pairCount];
_local2.proxyA = ((_arg1 < queryProxy)) ? _arg1 : queryProxy;
_local2.proxyB = ((_arg1 >= queryProxy)) ? _arg1 : queryProxy;
m_pairCount++;
return (true);
};
fatAABB = m_tree.GetFatAABB(queryProxy);
m_tree.Query(QueryCallback, fatAABB);
};
m_moveBuffer.length = 0;
i = 0;
while (i < m_pairCount) {
primaryPair = m_pairBuffer[i];
userDataA = m_tree.GetUserData(primaryPair.proxyA);
userDataB = m_tree.GetUserData(primaryPair.proxyB);
callback(userDataA, userDataB);
i = (i + 1);
while (i < m_pairCount) {
pair = m_pairBuffer[i];
if (((!((pair.proxyA == primaryPair.proxyA))) || (!((pair.proxyB == primaryPair.proxyB))))){
break;
};
i = (i + 1);
};
};
}
public function RayCast(_arg1:Function, _arg2:b2RayCastInput):void{
m_tree.RayCast(_arg1, _arg2);
}
public function CreateProxy(_arg1:b2AABB, _arg2){
var _local3:b2DynamicTreeNode = m_tree.CreateProxy(_arg1, _arg2);
m_proxyCount++;
BufferMove(_local3);
return (_local3);
}
public function GetUserData(_arg1){
return (m_tree.GetUserData(_arg1));
}
public function DestroyProxy(_arg1):void{
UnBufferMove(_arg1);
m_proxyCount--;
m_tree.DestroyProxy(_arg1);
}
public function MoveProxy(_arg1, _arg2:b2AABB, _arg3:b2Vec2):void{
var _local4:Boolean = m_tree.MoveProxy(_arg1, _arg2, _arg3);
if (_local4){
BufferMove(_arg1);
};
}
}
}//package Box2D.Collision
Section 16
//b2DynamicTreeNode (Box2D.Collision.b2DynamicTreeNode)
package Box2D.Collision {
public class b2DynamicTreeNode {
public var aabb:b2AABB;
public var parent:b2DynamicTreeNode;
public var userData;
public var child2:b2DynamicTreeNode;
public var child1:b2DynamicTreeNode;
public function b2DynamicTreeNode(){
aabb = new b2AABB();
super();
}
public function IsLeaf():Boolean{
return ((child1 == null));
}
}
}//package Box2D.Collision
Section 17
//b2DynamicTreePair (Box2D.Collision.b2DynamicTreePair)
package Box2D.Collision {
public class b2DynamicTreePair {
public var proxyA:b2DynamicTreeNode;
public var proxyB:b2DynamicTreeNode;
}
}//package Box2D.Collision
Section 18
//b2Manifold (Box2D.Collision.b2Manifold)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Manifold {
public var m_pointCount:int;// = 0
public var m_localPlaneNormal:b2Vec2;
public var m_type:int;
public var m_points:Array;
public var m_localPoint:b2Vec2;
public static const e_circles:int = 1;
public static const e_faceA:int = 2;
public static const e_faceB:int = 4;
public function b2Manifold(){
m_points = new Array(b2Settings.b2_maxManifoldPoints);
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
m_points[_local1] = new b2ManifoldPoint();
_local1++;
};
m_localPlaneNormal = new b2Vec2();
m_localPoint = new b2Vec2();
}
public function Set(_arg1:b2Manifold):void{
m_pointCount = _arg1.m_pointCount;
var _local2:int;
while (_local2 < b2Settings.b2_maxManifoldPoints) {
(m_points[_local2] as b2ManifoldPoint).Set(_arg1.m_points[_local2]);
_local2++;
};
m_localPlaneNormal.SetV(_arg1.m_localPlaneNormal);
m_localPoint.SetV(_arg1.m_localPoint);
m_type = _arg1.m_type;
}
public function Reset():void{
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
(m_points[_local1] as b2ManifoldPoint).Reset();
_local1++;
};
m_localPlaneNormal.SetZero();
m_localPoint.SetZero();
m_type = 0;
m_pointCount = 0;
}
public function Copy():b2Manifold{
var _local1:b2Manifold = new b2Manifold();
_local1.Set(this);
return (_local1);
}
}
}//package Box2D.Collision
Section 19
//b2ManifoldPoint (Box2D.Collision.b2ManifoldPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2ManifoldPoint {
public var m_localPoint:b2Vec2;
public var m_tangentImpulse:Number;
public var m_normalImpulse:Number;
public var m_id:b2ContactID;
public function b2ManifoldPoint(){
m_localPoint = new b2Vec2();
m_id = new b2ContactID();
super();
Reset();
}
public function Set(_arg1:b2ManifoldPoint):void{
m_localPoint.SetV(_arg1.m_localPoint);
m_normalImpulse = _arg1.m_normalImpulse;
m_tangentImpulse = _arg1.m_tangentImpulse;
m_id.Set(_arg1.m_id);
}
public function Reset():void{
m_localPoint.SetZero();
m_normalImpulse = 0;
m_tangentImpulse = 0;
m_id.key = 0;
}
}
}//package Box2D.Collision
Section 20
//b2OBB (Box2D.Collision.b2OBB)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2OBB {
public var R:b2Mat22;
public var center:b2Vec2;
public var extents:b2Vec2;
public function b2OBB(){
R = new b2Mat22();
center = new b2Vec2();
extents = new b2Vec2();
super();
}
}
}//package Box2D.Collision
Section 21
//b2RayCastInput (Box2D.Collision.b2RayCastInput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2RayCastInput {
public var p1:b2Vec2;
public var maxFraction:Number;
public var p2:b2Vec2;
public function b2RayCastInput(_arg1:b2Vec2=null, _arg2:b2Vec2=null, _arg3:Number=1){
p1 = new b2Vec2();
p2 = new b2Vec2();
super();
if (_arg1){
this.p1.SetV(_arg1);
};
if (_arg2){
this.p2.SetV(_arg2);
};
this.maxFraction = _arg3;
}
}
}//package Box2D.Collision
Section 22
//b2RayCastOutput (Box2D.Collision.b2RayCastOutput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2RayCastOutput {
public var fraction:Number;
public var normal:b2Vec2;
public function b2RayCastOutput(){
normal = new b2Vec2();
super();
}
}
}//package Box2D.Collision
Section 23
//b2SeparationFunction (Box2D.Collision.b2SeparationFunction)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
class b2SeparationFunction {
public var m_proxyA:b2DistanceProxy;
public var m_proxyB:b2DistanceProxy;
public var m_type:int;
public var m_axis:b2Vec2;
public var m_localPoint:b2Vec2;
public static const e_faceA:int = 2;
public static const e_faceB:int = 4;
public static const e_points:int = 1;
function b2SeparationFunction(){
m_localPoint = new b2Vec2();
m_axis = new b2Vec2();
super();
}
public function Initialize(_arg1:b2SimplexCache, _arg2:b2DistanceProxy, _arg3:b2Transform, _arg4:b2DistanceProxy, _arg5:b2Transform):void{
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:b2Vec2;
var _local12:b2Vec2;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:b2Mat22;
var _local20:b2Vec2;
var _local21:Number;
var _local22:Number;
var _local23:b2Vec2;
var _local24:b2Vec2;
var _local25:b2Vec2;
var _local26:b2Vec2;
var _local27:Number;
var _local28:Number;
var _local29:b2Vec2;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
m_proxyA = _arg2;
m_proxyB = _arg4;
var _local6:int = _arg1.count;
b2Settings.b2Assert((((0 < _local6)) && ((_local6 < 3))));
if (_local6 == 1){
m_type = e_points;
_local7 = m_proxyA.GetVertex(_arg1.indexA[0]);
_local10 = m_proxyB.GetVertex(_arg1.indexB[0]);
_local20 = _local7;
_local19 = _arg3.R;
_local13 = (_arg3.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local14 = (_arg3.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local20 = _local10;
_local19 = _arg5.R;
_local15 = (_arg5.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local16 = (_arg5.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
m_axis.x = (_local15 - _local13);
m_axis.y = (_local16 - _local14);
m_axis.Normalize();
} else {
if (_arg1.indexB[0] == _arg1.indexB[1]){
m_type = e_faceA;
_local8 = m_proxyA.GetVertex(_arg1.indexA[0]);
_local9 = m_proxyA.GetVertex(_arg1.indexA[1]);
_local10 = m_proxyB.GetVertex(_arg1.indexB[0]);
m_localPoint.x = (0.5 * (_local8.x + _local9.x));
m_localPoint.y = (0.5 * (_local8.y + _local9.y));
m_axis = b2Math.CrossVF(b2Math.SubtractVV(_local9, _local8), 1);
m_axis.Normalize();
_local20 = m_axis;
_local19 = _arg3.R;
_local17 = ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y));
_local18 = ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y));
_local20 = m_localPoint;
_local19 = _arg3.R;
_local13 = (_arg3.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local14 = (_arg3.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local20 = _local10;
_local19 = _arg5.R;
_local15 = (_arg5.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local16 = (_arg5.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local21 = (((_local15 - _local13) * _local17) + ((_local16 - _local14) * _local18));
if (_local21 < 0){
m_axis.NegativeSelf();
};
} else {
if (_arg1.indexA[0] == _arg1.indexA[0]){
m_type = e_faceB;
_local11 = m_proxyB.GetVertex(_arg1.indexB[0]);
_local12 = m_proxyB.GetVertex(_arg1.indexB[1]);
_local7 = m_proxyA.GetVertex(_arg1.indexA[0]);
m_localPoint.x = (0.5 * (_local11.x + _local12.x));
m_localPoint.y = (0.5 * (_local11.y + _local12.y));
m_axis = b2Math.CrossVF(b2Math.SubtractVV(_local12, _local11), 1);
m_axis.Normalize();
_local20 = m_axis;
_local19 = _arg5.R;
_local17 = ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y));
_local18 = ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y));
_local20 = m_localPoint;
_local19 = _arg5.R;
_local15 = (_arg5.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local16 = (_arg5.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local20 = _local7;
_local19 = _arg3.R;
_local13 = (_arg3.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local14 = (_arg3.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local21 = (((_local13 - _local15) * _local17) + ((_local14 - _local16) * _local18));
if (_local21 < 0){
m_axis.NegativeSelf();
};
} else {
_local8 = m_proxyA.GetVertex(_arg1.indexA[0]);
_local9 = m_proxyA.GetVertex(_arg1.indexA[1]);
_local11 = m_proxyB.GetVertex(_arg1.indexB[0]);
_local12 = m_proxyB.GetVertex(_arg1.indexB[1]);
_local23 = b2Math.MulX(_arg3, _local7);
_local24 = b2Math.MulMV(_arg3.R, b2Math.SubtractVV(_local9, _local8));
_local25 = b2Math.MulX(_arg5, _local10);
_local26 = b2Math.MulMV(_arg5.R, b2Math.SubtractVV(_local12, _local11));
_local27 = ((_local24.x * _local24.x) + (_local24.y * _local24.y));
_local28 = ((_local26.x * _local26.x) + (_local26.y * _local26.y));
_local29 = b2Math.SubtractVV(_local26, _local24);
_local30 = ((_local24.x * _local29.x) + (_local24.y * _local29.y));
_local31 = ((_local26.x * _local29.x) + (_local26.y * _local29.y));
_local32 = ((_local24.x * _local26.x) + (_local24.y * _local26.y));
_local33 = ((_local27 * _local28) - (_local32 * _local32));
_local21 = 0;
if (_local33 != 0){
_local21 = b2Math.Clamp((((_local32 * _local31) - (_local30 * _local28)) / _local33), 0, 1);
};
_local34 = (((_local32 * _local21) + _local31) / _local28);
if (_local34 < 0){
_local34 = 0;
_local21 = b2Math.Clamp(((_local32 - _local30) / _local27), 0, 1);
};
_local7 = new b2Vec2();
_local7.x = (_local8.x + (_local21 * (_local9.x - _local8.x)));
_local7.y = (_local8.y + (_local21 * (_local9.y - _local8.y)));
_local10 = new b2Vec2();
_local10.x = (_local11.x + (_local21 * (_local12.x - _local11.x)));
_local10.y = (_local11.y + (_local21 * (_local12.y - _local11.y)));
if ((((_local21 == 0)) || ((_local21 == 1)))){
m_type = e_faceB;
m_axis = b2Math.CrossVF(b2Math.SubtractVV(_local12, _local11), 1);
m_axis.Normalize();
m_localPoint = _local10;
_local20 = m_axis;
_local19 = _arg5.R;
_local17 = ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y));
_local18 = ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y));
_local20 = m_localPoint;
_local19 = _arg5.R;
_local15 = (_arg5.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local16 = (_arg5.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local20 = _local7;
_local19 = _arg3.R;
_local13 = (_arg3.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local14 = (_arg3.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local22 = (((_local13 - _local15) * _local17) + ((_local14 - _local16) * _local18));
if (_local21 < 0){
m_axis.NegativeSelf();
};
} else {
m_type = e_faceA;
m_axis = b2Math.CrossVF(b2Math.SubtractVV(_local9, _local8), 1);
m_localPoint = _local7;
_local20 = m_axis;
_local19 = _arg3.R;
_local17 = ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y));
_local18 = ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y));
_local20 = m_localPoint;
_local19 = _arg3.R;
_local13 = (_arg3.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local14 = (_arg3.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local20 = _local10;
_local19 = _arg5.R;
_local15 = (_arg5.position.x + ((_local19.col1.x * _local20.x) + (_local19.col2.x * _local20.y)));
_local16 = (_arg5.position.y + ((_local19.col1.y * _local20.x) + (_local19.col2.y * _local20.y)));
_local22 = (((_local15 - _local13) * _local17) + ((_local16 - _local14) * _local18));
if (_local21 < 0){
m_axis.NegativeSelf();
};
};
};
};
};
}
public function Evaluate(_arg1:b2Transform, _arg2:b2Transform):Number{
var _local3:b2Vec2;
var _local4:b2Vec2;
var _local5:b2Vec2;
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:Number;
var _local10:b2Vec2;
switch (m_type){
case e_points:
_local3 = b2Math.MulTMV(_arg1.R, m_axis);
_local4 = b2Math.MulTMV(_arg2.R, m_axis.GetNegative());
_local5 = m_proxyA.GetSupportVertex(_local3);
_local6 = m_proxyB.GetSupportVertex(_local4);
_local7 = b2Math.MulX(_arg1, _local5);
_local8 = b2Math.MulX(_arg2, _local6);
_local9 = (((_local8.x - _local7.x) * m_axis.x) + ((_local8.y - _local7.y) * m_axis.y));
return (_local9);
case e_faceA:
_local10 = b2Math.MulMV(_arg1.R, m_axis);
_local7 = b2Math.MulX(_arg1, m_localPoint);
_local4 = b2Math.MulTMV(_arg2.R, _local10.GetNegative());
_local6 = m_proxyB.GetSupportVertex(_local4);
_local8 = b2Math.MulX(_arg2, _local6);
_local9 = (((_local8.x - _local7.x) * _local10.x) + ((_local8.y - _local7.y) * _local10.y));
return (_local9);
case e_faceB:
_local10 = b2Math.MulMV(_arg2.R, m_axis);
_local8 = b2Math.MulX(_arg2, m_localPoint);
_local3 = b2Math.MulTMV(_arg1.R, _local10.GetNegative());
_local5 = m_proxyA.GetSupportVertex(_local3);
_local7 = b2Math.MulX(_arg1, _local5);
_local9 = (((_local7.x - _local8.x) * _local10.x) + ((_local7.y - _local8.y) * _local10.y));
return (_local9);
default:
b2Settings.b2Assert(false);
return (0);
};
}
}
}//package Box2D.Collision
Section 24
//b2Simplex (Box2D.Collision.b2Simplex)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
class b2Simplex {
public var m_v1:b2SimplexVertex;
public var m_v2:b2SimplexVertex;
public var m_v3:b2SimplexVertex;
public var m_vertices:Array;
public var m_count:int;
function b2Simplex(){
m_v1 = new b2SimplexVertex();
m_v2 = new b2SimplexVertex();
m_v3 = new b2SimplexVertex();
m_vertices = new Array(3);
super();
m_vertices[0] = m_v1;
m_vertices[1] = m_v2;
m_vertices[2] = m_v3;
}
public function GetSearchDirection():b2Vec2{
var _local1:b2Vec2;
var _local2:Number;
switch (m_count){
case 1:
return (m_v1.w.GetNegative());
case 2:
_local1 = b2Math.SubtractVV(m_v2.w, m_v1.w);
_local2 = b2Math.CrossVV(_local1, m_v1.w.GetNegative());
if (_local2 > 0){
return (b2Math.CrossFV(1, _local1));
};
return (b2Math.CrossVF(_local1, 1));
default:
b2Settings.b2Assert(false);
return (new b2Vec2());
};
}
public function WriteCache(_arg1:b2SimplexCache):void{
_arg1.metric = GetMetric();
_arg1.count = uint(m_count);
var _local2:Array = m_vertices;
var _local3:int;
while (_local3 < m_count) {
_arg1.indexA[_local3] = uint(_local2[_local3].indexA);
_arg1.indexB[_local3] = uint(_local2[_local3].indexB);
_local3++;
};
}
public function GetMetric():Number{
switch (m_count){
case 0:
b2Settings.b2Assert(false);
return (0);
case 1:
return (0);
case 2:
return (b2Math.SubtractVV(m_v1.w, m_v2.w).Length());
case 3:
return (b2Math.CrossVV(b2Math.SubtractVV(m_v2.w, m_v1.w), b2Math.SubtractVV(m_v3.w, m_v1.w)));
default:
b2Settings.b2Assert(false);
return (0);
};
}
public function ReadCache(_arg1:b2SimplexCache, _arg2:b2DistanceProxy, _arg3:b2Transform, _arg4:b2DistanceProxy, _arg5:b2Transform):void{
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local10:b2SimplexVertex;
var _local11:Number;
var _local12:Number;
b2Settings.b2Assert((((0 <= _arg1.count)) && ((_arg1.count <= 3))));
m_count = _arg1.count;
var _local8:Array = m_vertices;
var _local9:int;
while (_local9 < m_count) {
_local10 = _local8[_local9];
_local10.indexA = _arg1.indexA[_local9];
_local10.indexB = _arg1.indexB[_local9];
_local6 = _arg2.GetVertex(_local10.indexA);
_local7 = _arg4.GetVertex(_local10.indexB);
_local10.wA = b2Math.MulX(_arg3, _local6);
_local10.wB = b2Math.MulX(_arg5, _local7);
_local10.w = b2Math.SubtractVV(_local10.wB, _local10.wA);
_local10.a = 0;
_local9++;
};
if (m_count > 1){
_local11 = _arg1.metric;
_local12 = GetMetric();
if ((((((_local12 < (0.5 * _local11))) || (((2 * _local11) < _local12)))) || ((_local12 < Number.MIN_VALUE)))){
m_count = 0;
};
};
if (m_count == 0){
_local10 = _local8[0];
_local10.indexA = 0;
_local10.indexB = 0;
_local6 = _arg2.GetVertex(0);
_local7 = _arg4.GetVertex(0);
_local10.wA = b2Math.MulX(_arg3, _local6);
_local10.wB = b2Math.MulX(_arg5, _local7);
_local10.w = b2Math.SubtractVV(_local10.wB, _local10.wA);
m_count = 1;
};
}
public function GetWitnessPoints(_arg1:b2Vec2, _arg2:b2Vec2):void{
switch (m_count){
case 0:
b2Settings.b2Assert(false);
break;
case 1:
_arg1.SetV(m_v1.wA);
_arg2.SetV(m_v1.wB);
break;
case 2:
_arg1.x = ((m_v1.a * m_v1.wA.x) + (m_v2.a * m_v2.wA.x));
_arg1.y = ((m_v1.a * m_v1.wA.y) + (m_v2.a * m_v2.wA.y));
_arg2.x = ((m_v1.a * m_v1.wB.x) + (m_v2.a * m_v2.wB.x));
_arg2.y = ((m_v1.a * m_v1.wB.y) + (m_v2.a * m_v2.wB.y));
break;
case 3:
_arg2.x = (_arg1.x = (((m_v1.a * m_v1.wA.x) + (m_v2.a * m_v2.wA.x)) + (m_v3.a * m_v3.wA.x)));
_arg2.y = (_arg1.y = (((m_v1.a * m_v1.wA.y) + (m_v2.a * m_v2.wA.y)) + (m_v3.a * m_v3.wA.y)));
break;
default:
b2Settings.b2Assert(false);
break;
};
}
public function Solve2():void{
var _local1:b2Vec2 = m_v1.w;
var _local2:b2Vec2 = m_v2.w;
var _local3:b2Vec2 = b2Math.SubtractVV(_local2, _local1);
var _local4:Number = -(((_local1.x * _local3.x) + (_local1.y * _local3.y)));
if (_local4 <= 0){
m_v1.a = 1;
m_count = 1;
return;
};
var _local5:Number = ((_local2.x * _local3.x) + (_local2.y * _local3.y));
if (_local5 <= 0){
m_v2.a = 1;
m_count = 1;
m_v1.Set(m_v2);
return;
};
var _local6:Number = (1 / (_local5 + _local4));
m_v1.a = (_local5 * _local6);
m_v2.a = (_local4 * _local6);
m_count = 2;
}
public function Solve3():void{
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local1:b2Vec2 = m_v1.w;
var _local2:b2Vec2 = m_v2.w;
var _local3:b2Vec2 = m_v3.w;
var _local4:b2Vec2 = b2Math.SubtractVV(_local2, _local1);
var _local5:Number = b2Math.Dot(_local1, _local4);
var _local6:Number = b2Math.Dot(_local2, _local4);
var _local7:Number = _local6;
var _local8:Number = -(_local5);
var _local9:b2Vec2 = b2Math.SubtractVV(_local3, _local1);
var _local10:Number = b2Math.Dot(_local1, _local9);
var _local11:Number = b2Math.Dot(_local3, _local9);
var _local12:Number = _local11;
var _local13:Number = -(_local10);
var _local14:b2Vec2 = b2Math.SubtractVV(_local3, _local2);
var _local15:Number = b2Math.Dot(_local2, _local14);
var _local16:Number = b2Math.Dot(_local3, _local14);
var _local17:Number = _local16;
var _local18:Number = -(_local15);
var _local19:Number = b2Math.CrossVV(_local4, _local9);
var _local20:Number = (_local19 * b2Math.CrossVV(_local2, _local3));
var _local21:Number = (_local19 * b2Math.CrossVV(_local3, _local1));
var _local22:Number = (_local19 * b2Math.CrossVV(_local1, _local2));
if ((((_local8 <= 0)) && ((_local13 <= 0)))){
m_v1.a = 1;
m_count = 1;
return;
};
if ((((((_local7 > 0)) && ((_local8 > 0)))) && ((_local22 <= 0)))){
_local24 = (1 / (_local7 + _local8));
m_v1.a = (_local7 * _local24);
m_v2.a = (_local8 * _local24);
m_count = 2;
return;
};
if ((((((_local12 > 0)) && ((_local13 > 0)))) && ((_local21 <= 0)))){
_local25 = (1 / (_local12 + _local13));
m_v1.a = (_local12 * _local25);
m_v3.a = (_local13 * _local25);
m_count = 2;
m_v2.Set(m_v3);
return;
};
if ((((_local7 <= 0)) && ((_local18 <= 0)))){
m_v2.a = 1;
m_count = 1;
m_v1.Set(m_v2);
return;
};
if ((((_local12 <= 0)) && ((_local17 <= 0)))){
m_v3.a = 1;
m_count = 1;
m_v1.Set(m_v3);
return;
};
if ((((((_local17 > 0)) && ((_local18 > 0)))) && ((_local20 <= 0)))){
_local26 = (1 / (_local17 + _local18));
m_v2.a = (_local17 * _local26);
m_v3.a = (_local18 * _local26);
m_count = 2;
m_v1.Set(m_v3);
return;
};
var _local23:Number = (1 / ((_local20 + _local21) + _local22));
m_v1.a = (_local20 * _local23);
m_v2.a = (_local21 * _local23);
m_v3.a = (_local22 * _local23);
m_count = 3;
}
public function GetClosestPoint():b2Vec2{
switch (m_count){
case 0:
b2Settings.b2Assert(false);
return (new b2Vec2());
case 1:
return (m_v1.w);
case 2:
return (new b2Vec2(((m_v1.a * m_v1.w.x) + (m_v2.a * m_v2.w.x)), ((m_v1.a * m_v1.w.y) + (m_v2.a * m_v2.w.y))));
default:
b2Settings.b2Assert(false);
return (new b2Vec2());
};
}
}
}//package Box2D.Collision
Section 25
//b2SimplexCache (Box2D.Collision.b2SimplexCache)
package Box2D.Collision {
public class b2SimplexCache {
public var metric:Number;
public var count:uint;
public var indexB:Array;
public var indexA:Array;
public function b2SimplexCache(){
indexA = new Array(3);
indexB = new Array(3);
super();
}
}
}//package Box2D.Collision
Section 26
//b2SimplexVertex (Box2D.Collision.b2SimplexVertex)
package Box2D.Collision {
import Box2D.Common.Math.*;
class b2SimplexVertex {
public var a:Number;
public var wA:b2Vec2;
public var wB:b2Vec2;
public var indexA:int;
public var indexB:int;
public var w:b2Vec2;
public function Set(_arg1:b2SimplexVertex):void{
wA.SetV(_arg1.wA);
wB.SetV(_arg1.wB);
w.SetV(_arg1.w);
a = _arg1.a;
indexA = _arg1.indexA;
indexB = _arg1.indexB;
}
}
}//package Box2D.Collision
Section 27
//b2TimeOfImpact (Box2D.Collision.b2TimeOfImpact)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2TimeOfImpact {
private static var b2_toiCalls:int = 0;
private static var s_xfA:b2Transform = new b2Transform();
private static var s_distanceInput:b2DistanceInput = new b2DistanceInput();
private static var s_xfB:b2Transform = new b2Transform();
private static var s_distanceOutput:b2DistanceOutput = new b2DistanceOutput();
private static var b2_toiMaxRootIters:int = 0;
private static var s_cache:b2SimplexCache = new b2SimplexCache();
private static var b2_toiRootIters:int = 0;
private static var b2_toiIters:int = 0;
private static var b2_toiMaxIters:int = 0;
private static var s_fcn:b2SeparationFunction = new b2SeparationFunction();
public static function TimeOfImpact(_arg1:b2TOIInput):Number{
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:int;
var _local19:Number;
var _local20:Number;
b2_toiCalls++;
var _local2:b2DistanceProxy = _arg1.proxyA;
var _local3:b2DistanceProxy = _arg1.proxyB;
var _local4:b2Sweep = _arg1.sweepA;
var _local5:b2Sweep = _arg1.sweepB;
b2Settings.b2Assert((_local4.t0 == _local5.t0));
b2Settings.b2Assert(((1 - _local4.t0) > Number.MIN_VALUE));
var _local6:Number = (_local2.m_radius + _local3.m_radius);
var _local7:Number = _arg1.tolerance;
var _local8:Number = 0;
var _local9 = 1000;
var _local10:int;
var _local11:Number = 0;
s_cache.count = 0;
s_distanceInput.useRadii = false;
while (true) {
_local4.GetTransform(s_xfA, _local8);
_local5.GetTransform(s_xfB, _local8);
s_distanceInput.proxyA = _local2;
s_distanceInput.proxyB = _local3;
s_distanceInput.transformA = s_xfA;
s_distanceInput.transformB = s_xfB;
b2Distance.Distance(s_distanceOutput, s_cache, s_distanceInput);
if (s_distanceOutput.distance <= 0){
_local8 = 1;
break;
};
s_fcn.Initialize(s_cache, _local2, s_xfA, _local3, s_xfB);
_local12 = s_fcn.Evaluate(s_xfA, s_xfB);
if (_local12 <= 0){
_local8 = 1;
break;
};
if (_local10 == 0){
if (_local12 > _local6){
_local11 = b2Math.Max((_local6 - _local7), (0.75 * _local6));
} else {
_local11 = b2Math.Max((_local12 - _local7), (0.02 * _local6));
};
};
if ((_local12 - _local11) < (0.5 * _local7)){
if (_local10 == 0){
_local8 = 1;
break;
};
break;
};
_local13 = _local8;
_local14 = _local8;
_local15 = 1;
_local16 = _local12;
_local4.GetTransform(s_xfA, _local15);
_local5.GetTransform(s_xfB, _local15);
_local17 = s_fcn.Evaluate(s_xfA, s_xfB);
if (_local17 >= _local11){
_local8 = 1;
break;
};
_local18 = 0;
while (true) {
if ((_local18 & 1)){
_local19 = (_local14 + (((_local11 - _local16) * (_local15 - _local14)) / (_local17 - _local16)));
} else {
_local19 = (0.5 * (_local14 + _local15));
};
_local4.GetTransform(s_xfA, _local19);
_local5.GetTransform(s_xfB, _local19);
_local20 = s_fcn.Evaluate(s_xfA, s_xfB);
if (b2Math.Abs((_local20 - _local11)) < (0.025 * _local7)){
_local13 = _local19;
break;
};
if (_local20 > _local11){
_local14 = _local19;
_local16 = _local20;
} else {
_local15 = _local19;
_local17 = _local20;
};
_local18++;
b2_toiRootIters++;
if (_local18 == 50){
break;
};
};
b2_toiMaxRootIters = b2Math.Max(b2_toiMaxRootIters, _local18);
if (_local13 < ((1 + (100 * Number.MIN_VALUE)) * _local8)){
break;
};
_local8 = _local13;
_local10++;
b2_toiIters++;
if (_local10 == _local9){
break;
};
};
b2_toiMaxIters = b2Math.Max(b2_toiMaxIters, _local10);
return (_local8);
}
}
}//package Box2D.Collision
Section 28
//b2TOIInput (Box2D.Collision.b2TOIInput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2TOIInput {
public var proxyA:b2DistanceProxy;
public var proxyB:b2DistanceProxy;
public var sweepA:b2Sweep;
public var sweepB:b2Sweep;
public var tolerance:Number;
public function b2TOIInput(){
proxyA = new b2DistanceProxy();
proxyB = new b2DistanceProxy();
sweepA = new b2Sweep();
sweepB = new b2Sweep();
super();
}
}
}//package Box2D.Collision
Section 29
//b2WorldManifold (Box2D.Collision.b2WorldManifold)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2WorldManifold {
public var m_normal:b2Vec2;
public var m_points:Array;
public function b2WorldManifold(){
m_normal = new b2Vec2();
super();
m_points = new Array(b2Settings.b2_maxManifoldPoints);
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
m_points[_local1] = new b2Vec2();
_local1++;
};
}
public function Initialize(_arg1:b2Manifold, _arg2:b2Transform, _arg3:Number, _arg4:b2Transform, _arg5:Number):void{
var _local6:int;
var _local7:b2Vec2;
var _local8:b2Mat22;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
if (_arg1.m_pointCount == 0){
return;
};
switch (_arg1.m_type){
case b2Manifold.e_circles:
_local8 = _arg2.R;
_local7 = _arg1.m_localPoint;
_local15 = ((_arg2.position.x + (_local8.col1.x * _local7.x)) + (_local8.col2.x * _local7.y));
_local16 = ((_arg2.position.y + (_local8.col1.y * _local7.x)) + (_local8.col2.y * _local7.y));
_local8 = _arg4.R;
_local7 = _arg1.m_points[0].m_localPoint;
_local17 = ((_arg4.position.x + (_local8.col1.x * _local7.x)) + (_local8.col2.x * _local7.y));
_local18 = ((_arg4.position.y + (_local8.col1.y * _local7.x)) + (_local8.col2.y * _local7.y));
_local19 = (_local17 - _local15);
_local20 = (_local18 - _local16);
_local21 = ((_local19 * _local19) + (_local20 * _local20));
if (_local21 > (Number.MIN_VALUE * Number.MIN_VALUE)){
_local26 = Math.sqrt(_local21);
m_normal.x = (_local19 / _local26);
m_normal.y = (_local20 / _local26);
} else {
m_normal.x = 1;
m_normal.y = 0;
};
_local22 = (_local15 + (_arg3 * m_normal.x));
_local23 = (_local16 + (_arg3 * m_normal.y));
_local24 = (_local17 - (_arg5 * m_normal.x));
_local25 = (_local18 - (_arg5 * m_normal.y));
m_points[0].x = (0.5 * (_local22 + _local24));
m_points[0].y = (0.5 * (_local23 + _local25));
break;
case b2Manifold.e_faceA:
_local8 = _arg2.R;
_local7 = _arg1.m_localPlaneNormal;
_local9 = ((_local8.col1.x * _local7.x) + (_local8.col2.x * _local7.y));
_local10 = ((_local8.col1.y * _local7.x) + (_local8.col2.y * _local7.y));
_local8 = _arg2.R;
_local7 = _arg1.m_localPoint;
_local11 = ((_arg2.position.x + (_local8.col1.x * _local7.x)) + (_local8.col2.x * _local7.y));
_local12 = ((_arg2.position.y + (_local8.col1.y * _local7.x)) + (_local8.col2.y * _local7.y));
m_normal.x = _local9;
m_normal.y = _local10;
_local6 = 0;
while (_local6 < _arg1.m_pointCount) {
_local8 = _arg4.R;
_local7 = _arg1.m_points[_local6].m_localPoint;
_local13 = ((_arg4.position.x + (_local8.col1.x * _local7.x)) + (_local8.col2.x * _local7.y));
_local14 = ((_arg4.position.y + (_local8.col1.y * _local7.x)) + (_local8.col2.y * _local7.y));
m_points[_local6].x = (_local13 + ((0.5 * (((_arg3 - ((_local13 - _local11) * _local9)) - ((_local14 - _local12) * _local10)) - _arg5)) * _local9));
m_points[_local6].y = (_local14 + ((0.5 * (((_arg3 - ((_local13 - _local11) * _local9)) - ((_local14 - _local12) * _local10)) - _arg5)) * _local10));
_local6++;
};
break;
case b2Manifold.e_faceB:
_local8 = _arg4.R;
_local7 = _arg1.m_localPlaneNormal;
_local9 = ((_local8.col1.x * _local7.x) + (_local8.col2.x * _local7.y));
_local10 = ((_local8.col1.y * _local7.x) + (_local8.col2.y * _local7.y));
_local8 = _arg4.R;
_local7 = _arg1.m_localPoint;
_local11 = ((_arg4.position.x + (_local8.col1.x * _local7.x)) + (_local8.col2.x * _local7.y));
_local12 = ((_arg4.position.y + (_local8.col1.y * _local7.x)) + (_local8.col2.y * _local7.y));
m_normal.x = -(_local9);
m_normal.y = -(_local10);
_local6 = 0;
while (_local6 < _arg1.m_pointCount) {
_local8 = _arg2.R;
_local7 = _arg1.m_points[_local6].m_localPoint;
_local13 = ((_arg2.position.x + (_local8.col1.x * _local7.x)) + (_local8.col2.x * _local7.y));
_local14 = ((_arg2.position.y + (_local8.col1.y * _local7.x)) + (_local8.col2.y * _local7.y));
m_points[_local6].x = (_local13 + ((0.5 * (((_arg5 - ((_local13 - _local11) * _local9)) - ((_local14 - _local12) * _local10)) - _arg3)) * _local9));
m_points[_local6].y = (_local14 + ((0.5 * (((_arg5 - ((_local13 - _local11) * _local9)) - ((_local14 - _local12) * _local10)) - _arg3)) * _local10));
_local6++;
};
break;
};
}
}
}//package Box2D.Collision
Section 30
//ClipVertex (Box2D.Collision.ClipVertex)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class ClipVertex {
public var id:b2ContactID;
public var v:b2Vec2;
public function ClipVertex(){
v = new b2Vec2();
id = new b2ContactID();
super();
}
public function Set(_arg1:ClipVertex):void{
v.SetV(_arg1.v);
id.Set(_arg1.id);
}
}
}//package Box2D.Collision
Section 31
//Features (Box2D.Collision.Features)
package Box2D.Collision {
import Box2D.Common.*;
public class Features {
b2internal var _referenceEdge:int;
b2internal var _incidentEdge:int;
b2internal var _flip:int;
b2internal var _incidentVertex:int;
b2internal var _m_id:b2ContactID;
public function get referenceEdge():int{
return (_referenceEdge);
}
public function set incidentVertex(_arg1:int):void{
_incidentVertex = _arg1;
_m_id._key = ((_m_id._key & 4278255615) | ((_incidentVertex << 16) & 0xFF0000));
}
public function get flip():int{
return (_flip);
}
public function get incidentEdge():int{
return (_incidentEdge);
}
public function set referenceEdge(_arg1:int):void{
_referenceEdge = _arg1;
_m_id._key = ((_m_id._key & 4294967040) | (_referenceEdge & 0xFF));
}
public function get incidentVertex():int{
return (_incidentVertex);
}
public function set flip(_arg1:int):void{
_flip = _arg1;
_m_id._key = ((_m_id._key & 0xFFFFFF) | ((_flip << 24) & 4278190080));
}
public function set incidentEdge(_arg1:int):void{
_incidentEdge = _arg1;
_m_id._key = ((_m_id._key & 4294902015) | ((_incidentEdge << 8) & 0xFF00));
}
}
}//package Box2D.Collision
Section 32
//IBroadPhase (Box2D.Collision.IBroadPhase)
package Box2D.Collision {
import Box2D.Common.Math.*;
public interface IBroadPhase {
function GetFatAABB(_arg1):b2AABB;
function Query(_arg1:Function, _arg2:b2AABB):void;
function Rebalance(_arg1:int):void;
function GetUserData(_arg1);
function UpdatePairs(_arg1:Function):void;
function CreateProxy(_arg1:b2AABB, _arg2);
function DestroyProxy(_arg1):void;
function TestOverlap(_arg1, _arg2):Boolean;
function Validate():void;
function GetProxyCount():int;
function RayCast(_arg1:Function, _arg2:b2RayCastInput):void;
function MoveProxy(_arg1, _arg2:b2AABB, _arg3:b2Vec2):void;
}
}//package Box2D.Collision
Section 33
//b2Mat22 (Box2D.Common.Math.b2Mat22)
package Box2D.Common.Math {
public class b2Mat22 {
public var col1:b2Vec2;
public var col2:b2Vec2;
public function b2Mat22(){
col1 = new b2Vec2();
col2 = new b2Vec2();
super();
col1.x = (col2.y = 1);
}
public function SetIdentity():void{
col1.x = 1;
col2.x = 0;
col1.y = 0;
col2.y = 1;
}
public function SetVV(_arg1:b2Vec2, _arg2:b2Vec2):void{
col1.SetV(_arg1);
col2.SetV(_arg2);
}
public function Set(_arg1:Number):void{
var _local2:Number;
_local2 = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
col1.x = _local2;
col2.x = -(_local3);
col1.y = _local3;
col2.y = _local2;
}
public function SetZero():void{
col1.x = 0;
col2.x = 0;
col1.y = 0;
col2.y = 0;
}
public function SetM(_arg1:b2Mat22):void{
col1.SetV(_arg1.col1);
col2.SetV(_arg1.col2);
}
public function AddM(_arg1:b2Mat22):void{
col1.x = (col1.x + _arg1.col1.x);
col1.y = (col1.y + _arg1.col1.y);
col2.x = (col2.x + _arg1.col2.x);
col2.y = (col2.y + _arg1.col2.y);
}
public function Abs():void{
col1.Abs();
col2.Abs();
}
public function Copy():b2Mat22{
var _local1:b2Mat22 = new b2Mat22();
_local1.SetM(this);
return (_local1);
}
public function GetInverse(_arg1:b2Mat22):b2Mat22{
var _local3:Number;
var _local6:Number;
var _local2:Number = col1.x;
_local3 = col2.x;
var _local4:Number = col1.y;
var _local5:Number = col2.y;
_local6 = ((_local2 * _local5) - (_local3 * _local4));
if (_local6 != 0){
_local6 = (1 / _local6);
};
_arg1.col1.x = (_local6 * _local5);
_arg1.col2.x = (-(_local6) * _local3);
_arg1.col1.y = (-(_local6) * _local4);
_arg1.col2.y = (_local6 * _local2);
return (_arg1);
}
public function GetAngle():Number{
return (Math.atan2(col1.y, col1.x));
}
public function Solve(_arg1:b2Vec2, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:Number = col1.x;
var _local5:Number = col2.x;
var _local6:Number = col1.y;
var _local7:Number = col2.y;
var _local8:Number = ((_local4 * _local7) - (_local5 * _local6));
if (_local8 != 0){
_local8 = (1 / _local8);
};
_arg1.x = (_local8 * ((_local7 * _arg2) - (_local5 * _arg3)));
_arg1.y = (_local8 * ((_local4 * _arg3) - (_local6 * _arg2)));
return (_arg1);
}
public static function FromAngle(_arg1:Number):b2Mat22{
var _local2:b2Mat22 = new (b2Mat22);
_local2.Set(_arg1);
return (_local2);
}
public static function FromVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Mat22{
var _local3:b2Mat22 = new (b2Mat22);
_local3.SetVV(_arg1, _arg2);
return (_local3);
}
}
}//package Box2D.Common.Math
Section 34
//b2Mat33 (Box2D.Common.Math.b2Mat33)
package Box2D.Common.Math {
public class b2Mat33 {
public var col1:b2Vec3;
public var col2:b2Vec3;
public var col3:b2Vec3;
public function b2Mat33(_arg1:b2Vec3=null, _arg2:b2Vec3=null, _arg3:b2Vec3=null){
col1 = new b2Vec3();
col2 = new b2Vec3();
col3 = new b2Vec3();
super();
if (((((!(_arg1)) && (!(_arg2)))) && (!(_arg3)))){
col1.SetZero();
col2.SetZero();
col3.SetZero();
} else {
col1.SetV(_arg1);
col2.SetV(_arg2);
col3.SetV(_arg3);
};
}
public function SetIdentity():void{
col1.x = 1;
col2.x = 0;
col3.x = 0;
col1.y = 0;
col2.y = 1;
col3.y = 0;
col1.z = 0;
col2.z = 0;
col3.z = 1;
}
public function Solve22(_arg1:b2Vec2, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:Number;
var _local6:Number;
_local4 = col1.x;
var _local5:Number = col2.x;
_local6 = col1.y;
var _local7:Number = col2.y;
var _local8:Number = ((_local4 * _local7) - (_local5 * _local6));
if (_local8 != 0){
_local8 = (1 / _local8);
};
_arg1.x = (_local8 * ((_local7 * _arg2) - (_local5 * _arg3)));
_arg1.y = (_local8 * ((_local4 * _arg3) - (_local6 * _arg2)));
return (_arg1);
}
public function SetZero():void{
col1.x = 0;
col2.x = 0;
col3.x = 0;
col1.y = 0;
col2.y = 0;
col3.y = 0;
col1.z = 0;
col2.z = 0;
col3.z = 0;
}
public function SetM(_arg1:b2Mat33):void{
col1.SetV(_arg1.col1);
col2.SetV(_arg1.col2);
col3.SetV(_arg1.col3);
}
public function AddM(_arg1:b2Mat33):void{
col1.x = (col1.x + _arg1.col1.x);
col1.y = (col1.y + _arg1.col1.y);
col1.z = (col1.z + _arg1.col1.z);
col2.x = (col2.x + _arg1.col2.x);
col2.y = (col2.y + _arg1.col2.y);
col2.z = (col2.z + _arg1.col2.z);
col3.x = (col3.x + _arg1.col3.x);
col3.y = (col3.y + _arg1.col3.y);
col3.z = (col3.z + _arg1.col3.z);
}
public function SetVVV(_arg1:b2Vec3, _arg2:b2Vec3, _arg3:b2Vec3):void{
col1.SetV(_arg1);
col2.SetV(_arg2);
col3.SetV(_arg3);
}
public function Copy():b2Mat33{
return (new b2Mat33(col1, col2, col3));
}
public function Solve33(_arg1:b2Vec3, _arg2:Number, _arg3:Number, _arg4:Number):b2Vec3{
var _local5:Number = col1.x;
var _local6:Number = col1.y;
var _local7:Number = col1.z;
var _local8:Number = col2.x;
var _local9:Number = col2.y;
var _local10:Number = col2.z;
var _local11:Number = col3.x;
var _local12:Number = col3.y;
var _local13:Number = col3.z;
var _local14:Number = (((_local5 * ((_local9 * _local13) - (_local10 * _local12))) + (_local6 * ((_local10 * _local11) - (_local8 * _local13)))) + (_local7 * ((_local8 * _local12) - (_local9 * _local11))));
if (_local14 != 0){
_local14 = (1 / _local14);
};
_arg1.x = (_local14 * (((_arg2 * ((_local9 * _local13) - (_local10 * _local12))) + (_arg3 * ((_local10 * _local11) - (_local8 * _local13)))) + (_arg4 * ((_local8 * _local12) - (_local9 * _local11)))));
_arg1.y = (_local14 * (((_local5 * ((_arg3 * _local13) - (_arg4 * _local12))) + (_local6 * ((_arg4 * _local11) - (_arg2 * _local13)))) + (_local7 * ((_arg2 * _local12) - (_arg3 * _local11)))));
_arg1.z = (_local14 * (((_local5 * ((_local9 * _arg4) - (_local10 * _arg3))) + (_local6 * ((_local10 * _arg2) - (_local8 * _arg4)))) + (_local7 * ((_local8 * _arg3) - (_local9 * _arg2)))));
return (_arg1);
}
}
}//package Box2D.Common.Math
Section 35
//b2Math (Box2D.Common.Math.b2Math)
package Box2D.Common.Math {
public class b2Math {
public static const b2Transform_identity:b2Transform = new b2Transform(b2Vec2_zero, b2Mat22_identity);
public static const b2Mat22_identity:b2Mat22 = b2Mat22.FromVV(new b2Vec2(1, 0), new b2Vec2(0, 1));
public static const b2Vec2_zero:b2Vec2 = new b2Vec2(0, 0);
public static function AddVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg1.x + _arg2.x), (_arg1.y + _arg2.y));
return (_local3);
}
public static function AbsM(_arg1:b2Mat22):b2Mat22{
var _local2:b2Mat22 = b2Mat22.FromVV(AbsV(_arg1.col1), AbsV(_arg1.col2));
return (_local2);
}
public static function SubtractVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg1.x - _arg2.x), (_arg1.y - _arg2.y));
return (_local3);
}
public static function MulMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Mat22 = b2Mat22.FromVV(MulMV(_arg1, _arg2.col1), MulMV(_arg1, _arg2.col2));
return (_local3);
}
public static function NextPowerOfTwo(_arg1:uint):uint{
_arg1 = (_arg1 | ((_arg1 >> 1) & 2147483647));
_arg1 = (_arg1 | ((_arg1 >> 2) & 1073741823));
_arg1 = (_arg1 | ((_arg1 >> 4) & 268435455));
_arg1 = (_arg1 | ((_arg1 >> 8) & 0xFFFFFF));
_arg1 = (_arg1 | ((_arg1 >> 16) & 0xFFFF));
return ((_arg1 + 1));
}
public static function Max(_arg1:Number, _arg2:Number):Number{
return (((_arg1 > _arg2)) ? _arg1 : _arg2);
}
public static function MulMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(((_arg1.col1.x * _arg2.x) + (_arg1.col2.x * _arg2.y)), ((_arg1.col1.y * _arg2.x) + (_arg1.col2.y * _arg2.y)));
return (_local3);
}
public static function CrossVF(_arg1:b2Vec2, _arg2:Number):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg2 * _arg1.y), (-(_arg2) * _arg1.x));
return (_local3);
}
public static function MaxV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(Max(_arg1.x, _arg2.x), Max(_arg1.y, _arg2.y));
return (_local3);
}
public static function AbsV(_arg1:b2Vec2):b2Vec2{
var _local2:b2Vec2 = new b2Vec2(Abs(_arg1.x), Abs(_arg1.y));
return (_local2);
}
public static function Distance(_arg1:b2Vec2, _arg2:b2Vec2):Number{
var _local3:Number = (_arg1.x - _arg2.x);
var _local4:Number = (_arg1.y - _arg2.y);
return (Math.sqrt(((_local3 * _local3) + (_local4 * _local4))));
}
public static function MulTMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Vec2 = new b2Vec2(Dot(_arg1.col1, _arg2.col1), Dot(_arg1.col2, _arg2.col1));
var _local4:b2Vec2 = new b2Vec2(Dot(_arg1.col1, _arg2.col2), Dot(_arg1.col2, _arg2.col2));
var _local5:b2Mat22 = b2Mat22.FromVV(_local3, _local4);
return (_local5);
}
public static function DistanceSquared(_arg1:b2Vec2, _arg2:b2Vec2):Number{
var _local3:Number = (_arg1.x - _arg2.x);
var _local4:Number = (_arg1.y - _arg2.y);
return (((_local3 * _local3) + (_local4 * _local4)));
}
public static function RandomRange(_arg1:Number, _arg2:Number):Number{
var _local3:Number = Math.random();
_local3 = (((_arg2 - _arg1) * _local3) + _arg1);
return (_local3);
}
public static function Clamp(_arg1:Number, _arg2:Number, _arg3:Number):Number{
return (((_arg1 < _arg2)) ? _arg2 : ((_arg1 > _arg3)) ? _arg3 : _arg1);
}
public static function MulXT(_arg1:b2Transform, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
var _local4:Number;
_local3 = SubtractVV(_arg2, _arg1.position);
_local4 = ((_local3.x * _arg1.R.col1.x) + (_local3.y * _arg1.R.col1.y));
_local3.y = ((_local3.x * _arg1.R.col2.x) + (_local3.y * _arg1.R.col2.y));
_local3.x = _local4;
return (_local3);
}
public static function AddMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Mat22 = b2Mat22.FromVV(AddVV(_arg1.col1, _arg2.col1), AddVV(_arg1.col2, _arg2.col2));
return (_local3);
}
public static function Random():Number{
return (((Math.random() * 2) - 1));
}
public static function MinV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(Min(_arg1.x, _arg2.x), Min(_arg1.y, _arg2.y));
return (_local3);
}
public static function CrossVV(_arg1:b2Vec2, _arg2:b2Vec2):Number{
return (((_arg1.x * _arg2.y) - (_arg1.y * _arg2.x)));
}
public static function MulTMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(Dot(_arg2, _arg1.col1), Dot(_arg2, _arg1.col2));
return (_local3);
}
public static function Dot(_arg1:b2Vec2, _arg2:b2Vec2):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
public static function Abs(_arg1:Number):Number{
return (((_arg1 > 0)) ? _arg1 : -(_arg1));
}
public static function CrossFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((-(_arg1) * _arg2.y), (_arg1 * _arg2.x));
return (_local3);
}
public static function Min(_arg1:Number, _arg2:Number):Number{
return (((_arg1 < _arg2)) ? _arg1 : _arg2);
}
public static function ClampV(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2):b2Vec2{
return (MaxV(_arg2, MinV(_arg1, _arg3)));
}
public static function MulFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg1 * _arg2.x), (_arg1 * _arg2.y));
return (_local3);
}
public static function Swap(_arg1:Array, _arg2:Array):void{
var _local3:* = _arg1[0];
_arg1[0] = _arg2[0];
_arg2[0] = _local3;
}
public static function MulX(_arg1:b2Transform, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = MulMV(_arg1.R, _arg2);
_local3.x = (_local3.x + _arg1.position.x);
_local3.y = (_local3.y + _arg1.position.y);
return (_local3);
}
public static function IsPowerOfTwo(_arg1:uint):Boolean{
var _local2:Boolean = (((_arg1 > 0)) && (((_arg1 & (_arg1 - 1)) == 0)));
return (_local2);
}
public static function IsValid(_arg1:Number):Boolean{
return (isFinite(_arg1));
}
}
}//package Box2D.Common.Math
Section 36
//b2Sweep (Box2D.Common.Math.b2Sweep)
package Box2D.Common.Math {
public class b2Sweep {
public var localCenter:b2Vec2;
public var a:Number;
public var c:b2Vec2;
public var c0:b2Vec2;
public var a0:Number;
public var t0:Number;
public function b2Sweep(){
localCenter = new b2Vec2();
c0 = new b2Vec2();
c = new b2Vec2();
super();
}
public function Advance(_arg1:Number):void{
var _local2:Number;
if ((((t0 < _arg1)) && (((1 - t0) > Number.MIN_VALUE)))){
_local2 = ((_arg1 - t0) / (1 - t0));
c0.x = (((1 - _local2) * c0.x) + (_local2 * c.x));
c0.y = (((1 - _local2) * c0.y) + (_local2 * c.y));
a0 = (((1 - _local2) * a0) + (_local2 * a));
t0 = _arg1;
};
}
public function Set(_arg1:b2Sweep):void{
localCenter.SetV(_arg1.localCenter);
c0.SetV(_arg1.c0);
c.SetV(_arg1.c);
a0 = _arg1.a0;
a = _arg1.a;
t0 = _arg1.t0;
}
public function Copy():b2Sweep{
var _local1:b2Sweep = new b2Sweep();
_local1.localCenter.SetV(localCenter);
_local1.c0.SetV(c0);
_local1.c.SetV(c);
_local1.a0 = a0;
_local1.a = a;
_local1.t0 = t0;
return (_local1);
}
public function GetTransform(_arg1:b2Transform, _arg2:Number):void{
_arg1.position.x = (((1 - _arg2) * c0.x) + (_arg2 * c.x));
_arg1.position.y = (((1 - _arg2) * c0.y) + (_arg2 * c.y));
var _local3:Number = (((1 - _arg2) * a0) + (_arg2 * a));
_arg1.R.Set(_local3);
var _local4:b2Mat22 = _arg1.R;
_arg1.position.x = (_arg1.position.x - ((_local4.col1.x * localCenter.x) + (_local4.col2.x * localCenter.y)));
_arg1.position.y = (_arg1.position.y - ((_local4.col1.y * localCenter.x) + (_local4.col2.y * localCenter.y)));
}
}
}//package Box2D.Common.Math
Section 37
//b2Transform (Box2D.Common.Math.b2Transform)
package Box2D.Common.Math {
public class b2Transform {
public var position:b2Vec2;
public var R:b2Mat22;
public function b2Transform(_arg1:b2Vec2=null, _arg2:b2Mat22=null):void{
position = new b2Vec2();
R = new b2Mat22();
super();
if (_arg1){
position.SetV(_arg1);
R.SetM(_arg2);
};
}
public function Initialize(_arg1:b2Vec2, _arg2:b2Mat22):void{
position.SetV(_arg1);
R.SetM(_arg2);
}
public function Set(_arg1:b2Transform):void{
position.SetV(_arg1.position);
R.SetM(_arg1.R);
}
public function SetIdentity():void{
position.SetZero();
R.SetIdentity();
}
public function GetAngle():Number{
return (Math.atan2(R.col1.y, R.col1.x));
}
}
}//package Box2D.Common.Math
Section 38
//b2Vec2 (Box2D.Common.Math.b2Vec2)
package Box2D.Common.Math {
public class b2Vec2 {
public var y:Number;
public var x:Number;
public function b2Vec2(_arg1:Number=0, _arg2:Number=0):void{
x = _arg1;
y = _arg2;
}
public function NegativeSelf():void{
x = -(x);
y = -(y);
}
public function Set(_arg1:Number=0, _arg2:Number=0):void{
x = _arg1;
y = _arg2;
}
public function LengthSquared():Number{
return (((x * x) + (y * y)));
}
public function Multiply(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
}
public function Length():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function Add(_arg1:b2Vec2):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
}
public function MulM(_arg1:b2Mat22):void{
var _local2:Number = x;
x = ((_arg1.col1.x * _local2) + (_arg1.col2.x * y));
y = ((_arg1.col1.y * _local2) + (_arg1.col2.y * y));
}
public function SetZero():void{
x = 0;
y = 0;
}
public function GetNegative():b2Vec2{
return (new b2Vec2(-(x), -(y)));
}
public function Normalize():Number{
var _local1:Number = Math.sqrt(((x * x) + (y * y)));
if (_local1 < Number.MIN_VALUE){
return (0);
};
var _local2:Number = (1 / _local1);
x = (x * _local2);
y = (y * _local2);
return (_local1);
}
public function CrossVF(_arg1:Number):void{
var _local2:Number = x;
x = (_arg1 * y);
y = (-(_arg1) * _local2);
}
public function MaxV(_arg1:b2Vec2):void{
x = ((x > _arg1.x)) ? x : _arg1.x;
y = ((y > _arg1.y)) ? y : _arg1.y;
}
public function SetV(_arg1:b2Vec2):void{
x = _arg1.x;
y = _arg1.y;
}
public function Copy():b2Vec2{
return (new b2Vec2(x, y));
}
public function CrossFV(_arg1:Number):void{
var _local2:Number = x;
x = (-(_arg1) * y);
y = (_arg1 * _local2);
}
public function Abs():void{
if (x < 0){
x = -(x);
};
if (y < 0){
y = -(y);
};
}
public function Subtract(_arg1:b2Vec2):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
}
public function MinV(_arg1:b2Vec2):void{
x = ((x < _arg1.x)) ? x : _arg1.x;
y = ((y < _arg1.y)) ? y : _arg1.y;
}
public function MulTM(_arg1:b2Mat22):void{
var _local2:Number = b2Math.Dot(this, _arg1.col1);
y = b2Math.Dot(this, _arg1.col2);
x = _local2;
}
public function IsValid():Boolean{
return (((b2Math.IsValid(x)) && (b2Math.IsValid(y))));
}
public static function Make(_arg1:Number, _arg2:Number):b2Vec2{
return (new b2Vec2(_arg1, _arg2));
}
}
}//package Box2D.Common.Math
Section 39
//b2Vec3 (Box2D.Common.Math.b2Vec3)
package Box2D.Common.Math {
public class b2Vec3 {
public var x:Number;
public var y:Number;
public var z:Number;
public function b2Vec3(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
}
public function NegativeSelf():void{
x = -(x);
y = -(y);
z = -(z);
}
public function Set(_arg1:Number, _arg2:Number, _arg3:Number):void{
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
}
public function Multiply(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
z = (z * _arg1);
}
public function Add(_arg1:b2Vec3):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
z = (z + _arg1.z);
}
public function SetZero():void{
x = (y = (z = 0));
}
public function GetNegative():b2Vec3{
return (new b2Vec3(-(x), -(y), -(z)));
}
public function SetV(_arg1:b2Vec3):void{
x = _arg1.x;
y = _arg1.y;
z = _arg1.z;
}
public function Copy():b2Vec3{
return (new b2Vec3(x, y, z));
}
public function Subtract(_arg1:b2Vec3):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
z = (z - _arg1.z);
}
}
}//package Box2D.Common.Math
Section 40
//b2Color (Box2D.Common.b2Color)
package Box2D.Common {
import Box2D.Common.Math.*;
public class b2Color {
private var _r:uint;// = 0
private var _g:uint;// = 0
private var _b:uint;// = 0
public function b2Color(_arg1:Number, _arg2:Number, _arg3:Number){
_r = uint((0xFF * b2Math.Clamp(_arg1, 0, 1)));
_g = uint((0xFF * b2Math.Clamp(_arg2, 0, 1)));
_b = uint((0xFF * b2Math.Clamp(_arg3, 0, 1)));
}
public function Set(_arg1:Number, _arg2:Number, _arg3:Number):void{
_r = uint((0xFF * b2Math.Clamp(_arg1, 0, 1)));
_g = uint((0xFF * b2Math.Clamp(_arg2, 0, 1)));
_b = uint((0xFF * b2Math.Clamp(_arg3, 0, 1)));
}
public function set b(_arg1:Number):void{
_b = uint((0xFF * b2Math.Clamp(_arg1, 0, 1)));
}
public function get color():uint{
return ((((_r << 16) | (_g << 8)) | _b));
}
public function set r(_arg1:Number):void{
_r = uint((0xFF * b2Math.Clamp(_arg1, 0, 1)));
}
public function set g(_arg1:Number):void{
_g = uint((0xFF * b2Math.Clamp(_arg1, 0, 1)));
}
}
}//package Box2D.Common
Section 41
//b2internal (Box2D.Common.b2internal)
package Box2D.Common {
public namespace b2internal = "http://www.box2d.org/ns/b2internal";
}//package Box2D.Common
Section 42
//b2Settings (Box2D.Common.b2Settings)
package Box2D.Common {
public class b2Settings {
public static const b2_polygonRadius:Number = (2 * b2_linearSlop);
public static const b2_pi:Number = 3.14159265358979;
public static const b2_aabbExtension:Number = 0.1;
public static const b2_linearSleepTolerance:Number = 0.01;
public static const b2_maxTranslationSquared:Number = 4;
public static const b2_angularSlop:Number = 0.0349065850398866;
public static const b2_linearSlop:Number = 0.005;
public static const b2_maxRotation:Number = 1.5707963267949;
public static const b2_maxRotationSquared:Number = 2.46740110027234;
public static const b2_angularSleepTolerance:Number = 0.0349065850398866;
public static const b2_timeToSleep:Number = 0.5;
public static const b2_maxTOIJointsPerIsland:int = 32;
public static const b2_contactBaumgarte:Number = 0.2;
public static const b2_maxTOIContactsPerIsland:int = 32;
public static const b2_maxManifoldPoints:int = 2;
public static const b2_maxAngularCorrection:Number = 0.139626340159546;
public static const b2_velocityThreshold:Number = 1;
public static const USHRT_MAX:int = 0xFFFF;
public static const VERSION:String = "2.1alpha";
public static const b2_toiSlop:Number = 0.04;
public static const b2_maxTranslation:Number = 2;
public static const b2_aabbMultiplier:Number = 2;
public static const b2_maxLinearCorrection:Number = 0.2;
public static function b2MixFriction(_arg1:Number, _arg2:Number):Number{
return (Math.sqrt((_arg1 * _arg2)));
}
public static function b2MixRestitution(_arg1:Number, _arg2:Number):Number{
return (((_arg1 > _arg2)) ? _arg1 : _arg2);
}
public static function b2Assert(_arg1:Boolean):void{
if (!_arg1){
throw ("Assertion Failed");
};
}
}
}//package Box2D.Common
Section 43
//b2CircleContact (Box2D.Dynamics.Contacts.b2CircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2CircleContact extends b2Contact {
override b2internal function Evaluate():void{
var _local1:b2Body = m_fixtureA.GetBody();
var _local2:b2Body = m_fixtureB.GetBody();
b2Collision.CollideCircles(m_manifold, (m_fixtureA.GetShape() as b2CircleShape), _local1.m_xf, (m_fixtureB.GetShape() as b2CircleShape), _local2.m_xf);
}
public function Reset(_arg1:b2Fixture, _arg2:b2Fixture):void{
super.Reset(_arg1, _arg2);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1):b2Contact{
return (new (b2CircleContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 44
//b2Contact (Box2D.Dynamics.Contacts.b2Contact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Contact {
b2internal var m_prev:b2Contact;
b2internal var m_next:b2Contact;
b2internal var m_oldManifold:b2Manifold;
b2internal var m_manifold:b2Manifold;
b2internal var m_fixtureB:b2Fixture;
b2internal var m_fixtureA:b2Fixture;
b2internal var m_nodeA:b2ContactEdge;
b2internal var m_flags:uint;
b2internal var m_toi:Number;
b2internal var m_nodeB:b2ContactEdge;
b2internal static var e_sensorFlag:uint = 1;
private static var s_input:b2TOIInput = new b2TOIInput();
b2internal static var e_touchingFlag:uint = 16;
b2internal static var e_enabledFlag:uint = 32;
b2internal static var e_continuousFlag:uint = 2;
b2internal static var e_toiFlag:uint = 8;
b2internal static var e_islandFlag:uint = 4;
b2internal static var e_filterFlag:uint = 64;
public function b2Contact(){
m_nodeA = new b2ContactEdge();
m_nodeB = new b2ContactEdge();
m_manifold = new b2Manifold();
m_oldManifold = new b2Manifold();
super();
}
public function IsContinuous():Boolean{
return (((m_flags & e_continuousFlag) == e_continuousFlag));
}
public function GetNext():b2Contact{
return (m_next);
}
public function FlagForFiltering():void{
m_flags = (m_flags | e_filterFlag);
}
public function IsEnabled():Boolean{
return (((m_flags & e_enabledFlag) == e_enabledFlag));
}
public function SetSensor(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_sensorFlag);
} else {
m_flags = (m_flags & ~(e_sensorFlag));
};
}
public function SetEnabled(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_enabledFlag);
} else {
m_flags = (m_flags & ~(e_enabledFlag));
};
}
public function IsSensor():Boolean{
return (((m_flags & e_sensorFlag) == e_sensorFlag));
}
public function GetManifold():b2Manifold{
return (m_manifold);
}
b2internal function Update(_arg1:b2ContactListener):void{
var _local8:b2Shape;
var _local9:b2Shape;
var _local10:b2Transform;
var _local11:b2Transform;
var _local12:int;
var _local13:b2ManifoldPoint;
var _local14:b2ContactID;
var _local15:int;
var _local16:b2ManifoldPoint;
var _local2:b2Manifold = m_oldManifold;
m_oldManifold = m_manifold;
m_manifold = _local2;
m_flags = (m_flags | e_enabledFlag);
var _local3:Boolean;
var _local4 = ((m_flags & e_touchingFlag) == e_touchingFlag);
var _local5:b2Body = m_fixtureA.m_body;
var _local6:b2Body = m_fixtureB.m_body;
var _local7:Boolean = m_fixtureA.m_aabb.TestOverlap(m_fixtureB.m_aabb);
if ((m_flags & e_sensorFlag)){
if (_local7){
_local8 = m_fixtureA.GetShape();
_local9 = m_fixtureB.GetShape();
_local10 = _local5.GetTransform();
_local11 = _local6.GetTransform();
_local3 = b2Shape.TestOverlap(_local8, _local10, _local9, _local11);
};
m_manifold.m_pointCount = 0;
} else {
if (((((((!((_local5.GetType() == b2Body.b2_dynamicBody))) || (_local5.IsBullet()))) || (!((_local6.GetType() == b2Body.b2_dynamicBody))))) || (_local6.IsBullet()))){
m_flags = (m_flags | e_continuousFlag);
} else {
m_flags = (m_flags & ~(e_continuousFlag));
};
if (_local7){
Evaluate();
_local3 = (m_manifold.m_pointCount > 0);
_local12 = 0;
while (_local12 < m_manifold.m_pointCount) {
_local13 = m_manifold.m_points[_local12];
_local13.m_normalImpulse = 0;
_local13.m_tangentImpulse = 0;
_local14 = _local13.m_id;
_local15 = 0;
while (_local15 < m_oldManifold.m_pointCount) {
_local16 = m_oldManifold.m_points[_local15];
if (_local16.m_id.key == _local14.key){
_local13.m_normalImpulse = _local16.m_normalImpulse;
_local13.m_tangentImpulse = _local16.m_tangentImpulse;
break;
};
_local15++;
};
_local12++;
};
} else {
m_manifold.m_pointCount = 0;
};
if (_local3 != _local4){
_local5.SetAwake(true);
_local6.SetAwake(true);
};
};
if (_local3){
m_flags = (m_flags | e_touchingFlag);
} else {
m_flags = (m_flags & ~(e_touchingFlag));
};
if ((((_local4 == false)) && ((_local3 == true)))){
_arg1.BeginContact(this);
};
if ((((_local4 == true)) && ((_local3 == false)))){
_arg1.EndContact(this);
};
if ((m_flags & e_sensorFlag) == 0){
_arg1.PreSolve(this, m_oldManifold);
};
}
public function GetWorldManifold(_arg1:b2WorldManifold):void{
var _local2:b2Body = m_fixtureA.GetBody();
var _local3:b2Body = m_fixtureB.GetBody();
var _local4:b2Shape = m_fixtureA.GetShape();
var _local5:b2Shape = m_fixtureB.GetShape();
_arg1.Initialize(m_manifold, _local2.GetTransform(), _local4.m_radius, _local3.GetTransform(), _local5.m_radius);
}
public function IsTouching():Boolean{
return (((m_flags & e_touchingFlag) == e_touchingFlag));
}
public function GetFixtureA():b2Fixture{
return (m_fixtureA);
}
public function GetFixtureB():b2Fixture{
return (m_fixtureB);
}
b2internal function Reset(_arg1:b2Fixture=null, _arg2:b2Fixture=null):void{
m_flags = e_enabledFlag;
if (((!(_arg1)) || (!(_arg2)))){
m_fixtureA = null;
m_fixtureB = null;
return;
};
if (((_arg1.IsSensor()) || (_arg2.IsSensor()))){
m_flags = (m_flags | e_sensorFlag);
};
var _local3:b2Body = _arg1.GetBody();
var _local4:b2Body = _arg2.GetBody();
if (((((((!((_local3.GetType() == b2Body.b2_dynamicBody))) || (_local3.IsBullet()))) || (!((_local4.GetType() == b2Body.b2_dynamicBody))))) || (_local4.IsBullet()))){
m_flags = (m_flags | e_continuousFlag);
};
m_fixtureA = _arg1;
m_fixtureB = _arg2;
m_manifold.m_pointCount = 0;
m_prev = null;
m_next = null;
m_nodeA.contact = null;
m_nodeA.prev = null;
m_nodeA.next = null;
m_nodeA.other = null;
m_nodeB.contact = null;
m_nodeB.prev = null;
m_nodeB.next = null;
m_nodeB.other = null;
}
b2internal function ComputeTOI(_arg1:b2Sweep, _arg2:b2Sweep):Number{
s_input.proxyA.Set(m_fixtureA.GetShape());
s_input.proxyB.Set(m_fixtureB.GetShape());
s_input.sweepA = _arg1;
s_input.sweepB = _arg2;
s_input.tolerance = b2Settings.b2_linearSlop;
return (b2TimeOfImpact.TimeOfImpact(s_input));
}
b2internal function Evaluate():void{
}
}
}//package Box2D.Dynamics.Contacts
Section 45
//b2ContactConstraint (Box2D.Dynamics.Contacts.b2ContactConstraint)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2ContactConstraint {
public var type:int;
public var normalMass:b2Mat22;
public var K:b2Mat22;
public var manifold:b2Manifold;
public var radius:Number;
public var bodyA:b2Body;
public var bodyB:b2Body;
public var points:Array;
public var localPoint:b2Vec2;
public var pointCount:int;
public var normal:b2Vec2;
public var restitution:Number;
public var localPlaneNormal:b2Vec2;
public var friction:Number;
public function b2ContactConstraint(){
localPlaneNormal = new b2Vec2();
localPoint = new b2Vec2();
normal = new b2Vec2();
normalMass = new b2Mat22();
K = new b2Mat22();
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
points[_local1] = new b2ContactConstraintPoint();
_local1++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 46
//b2ContactConstraintPoint (Box2D.Dynamics.Contacts.b2ContactConstraintPoint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
public class b2ContactConstraintPoint {
public var localPoint:b2Vec2;
public var normalImpulse:Number;
public var rA:b2Vec2;
public var rB:b2Vec2;
public var tangentImpulse:Number;
public var equalizedMass:Number;
public var tangentMass:Number;
public var normalMass:Number;
public var velocityBias:Number;
public function b2ContactConstraintPoint(){
localPoint = new b2Vec2();
rA = new b2Vec2();
rB = new b2Vec2();
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 47
//b2ContactEdge (Box2D.Dynamics.Contacts.b2ContactEdge)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
public class b2ContactEdge {
public var other:b2Body;
public var prev:b2ContactEdge;
public var contact:b2Contact;
public var next:b2ContactEdge;
}
}//package Box2D.Dynamics.Contacts
Section 48
//b2ContactFactory (Box2D.Dynamics.Contacts.b2ContactFactory)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2ContactFactory {
private var m_allocator;
private var m_registers:Array;
public function b2ContactFactory(_arg1){
m_allocator = _arg1;
InitializeRegisters();
}
b2internal function InitializeRegisters():void{
var _local2:int;
m_registers = new Array(b2Shape.e_shapeTypeCount);
var _local1:int;
while (_local1 < b2Shape.e_shapeTypeCount) {
m_registers[_local1] = new Array(b2Shape.e_shapeTypeCount);
_local2 = 0;
while (_local2 < b2Shape.e_shapeTypeCount) {
m_registers[_local1][_local2] = new b2ContactRegister();
_local2++;
};
_local1++;
};
AddType(b2CircleContact.Create, b2CircleContact.Destroy, b2Shape.e_circleShape, b2Shape.e_circleShape);
AddType(b2PolyAndCircleContact.Create, b2PolyAndCircleContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_circleShape);
AddType(b2PolygonContact.Create, b2PolygonContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_polygonShape);
AddType(b2EdgeAndCircleContact.Create, b2EdgeAndCircleContact.Destroy, b2Shape.e_edgeShape, b2Shape.e_circleShape);
AddType(b2PolyAndEdgeContact.Create, b2PolyAndEdgeContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_edgeShape);
}
public function Destroy(_arg1:b2Contact):void{
if (_arg1.m_manifold.m_pointCount > 0){
_arg1.m_fixtureA.m_body.SetAwake(true);
_arg1.m_fixtureB.m_body.SetAwake(true);
};
var _local2:int = _arg1.m_fixtureA.GetType();
var _local3:int = _arg1.m_fixtureB.GetType();
var _local4:b2ContactRegister = m_registers[_local2][_local3];
_local4.poolCount++;
_arg1.m_next = _local4.pool;
_local4.pool = _arg1;
var _local5:Function = _local4.destroyFcn;
_local5(_arg1, m_allocator);
}
b2internal function AddType(_arg1:Function, _arg2:Function, _arg3:int, _arg4:int):void{
m_registers[_arg3][_arg4].createFcn = _arg1;
m_registers[_arg3][_arg4].destroyFcn = _arg2;
m_registers[_arg3][_arg4].primary = true;
if (_arg3 != _arg4){
m_registers[_arg4][_arg3].createFcn = _arg1;
m_registers[_arg4][_arg3].destroyFcn = _arg2;
m_registers[_arg4][_arg3].primary = false;
};
}
public function Create(_arg1:b2Fixture, _arg2:b2Fixture):b2Contact{
var _local6:b2Contact;
var _local3:int = _arg1.GetType();
var _local4:int = _arg2.GetType();
var _local5:b2ContactRegister = m_registers[_local3][_local4];
if (_local5.pool){
_local6 = _local5.pool;
_local5.pool = _local6.m_next;
_local5.poolCount--;
_local6.Reset(_arg1, _arg2);
return (_local6);
};
var _local7:Function = _local5.createFcn;
if (_local7 != null){
if (_local5.primary){
_local6 = _local7(m_allocator);
_local6.Reset(_arg1, _arg2);
return (_local6);
};
_local6 = _local7(m_allocator);
_local6.Reset(_arg2, _arg1);
return (_local6);
//unresolved jump
};
return (null);
}
}
}//package Box2D.Dynamics.Contacts
Section 49
//b2ContactRegister (Box2D.Dynamics.Contacts.b2ContactRegister)
package Box2D.Dynamics.Contacts {
public class b2ContactRegister {
public var primary:Boolean;
public var poolCount:int;
public var createFcn:Function;
public var destroyFcn:Function;
public var pool:b2Contact;
}
}//package Box2D.Dynamics.Contacts
Section 50
//b2ContactSolver (Box2D.Dynamics.Contacts.b2ContactSolver)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2ContactSolver {
private var m_constraintCount:int;
b2internal var m_constraints:Array;
private var m_allocator;
private var m_step:b2TimeStep;
private static var s_psm:b2PositionSolverManifold = new b2PositionSolverManifold();
private static var s_worldManifold:b2WorldManifold = new b2WorldManifold();
public function b2ContactSolver(){
m_step = new b2TimeStep();
m_constraints = new Array();
super();
}
public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Vec2;
var _local3:b2Vec2;
var _local4:b2Mat22;
var _local6:b2ContactConstraint;
var _local7:b2Body;
var _local8:b2Body;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:int;
var _local19:int;
var _local20:b2ContactConstraintPoint;
var _local21:Number;
var _local22:Number;
var _local23:b2ContactConstraintPoint;
var _local5:int;
while (_local5 < m_constraintCount) {
_local6 = m_constraints[_local5];
_local7 = _local6.bodyA;
_local8 = _local6.bodyB;
_local9 = _local7.m_invMass;
_local10 = _local7.m_invI;
_local11 = _local8.m_invMass;
_local12 = _local8.m_invI;
_local13 = _local6.normal.x;
_local14 = _local6.normal.y;
_local15 = _local14;
_local16 = -(_local13);
if (_arg1.warmStarting){
_local19 = _local6.pointCount;
_local18 = 0;
while (_local18 < _local19) {
_local20 = _local6.points[_local18];
_local6.points[_local18].normalImpulse = (_local20.normalImpulse * _arg1.dtRatio);
_local20.tangentImpulse = (_local20.tangentImpulse * _arg1.dtRatio);
_local21 = ((_local20.normalImpulse * _local13) + (_local20.tangentImpulse * _local15));
_local22 = ((_local20.normalImpulse * _local14) + (_local20.tangentImpulse * _local16));
_local7.m_angularVelocity = (_local7.m_angularVelocity - (_local10 * ((_local20.rA.x * _local22) - (_local20.rA.y * _local21))));
_local7.m_linearVelocity.x = (_local7.m_linearVelocity.x - (_local9 * _local21));
_local7.m_linearVelocity.y = (_local7.m_linearVelocity.y - (_local9 * _local22));
_local8.m_angularVelocity = (_local8.m_angularVelocity + (_local12 * ((_local20.rB.x * _local22) - (_local20.rB.y * _local21))));
_local8.m_linearVelocity.x = (_local8.m_linearVelocity.x + (_local11 * _local21));
_local8.m_linearVelocity.y = (_local8.m_linearVelocity.y + (_local11 * _local22));
_local18++;
};
} else {
_local19 = _local6.pointCount;
_local18 = 0;
while (_local18 < _local19) {
_local23 = _local6.points[_local18];
_local23.normalImpulse = 0;
_local23.tangentImpulse = 0;
_local18++;
};
};
_local5++;
};
}
public function SolvePositionConstraints(_arg1:Number):Boolean{
var _local4:b2ContactConstraint;
var _local5:b2Body;
var _local6:b2Body;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:b2Vec2;
var _local12:int;
var _local13:b2ContactConstraintPoint;
var _local14:b2Vec2;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local2:Number = 0;
var _local3:int;
while (_local3 < m_constraintCount) {
_local4 = m_constraints[_local3];
_local5 = _local4.bodyA;
_local6 = _local4.bodyB;
_local7 = (_local5.m_mass * _local5.m_invMass);
_local8 = (_local5.m_mass * _local5.m_invI);
_local9 = (_local6.m_mass * _local6.m_invMass);
_local10 = (_local6.m_mass * _local6.m_invI);
s_psm.Initialize(_local4);
_local11 = s_psm.m_normal;
_local12 = 0;
while (_local12 < _local4.pointCount) {
_local13 = _local4.points[_local12];
_local14 = s_psm.m_points[_local12];
_local15 = s_psm.m_separations[_local12];
_local16 = (_local14.x - _local5.m_sweep.c.x);
_local17 = (_local14.y - _local5.m_sweep.c.y);
_local18 = (_local14.x - _local6.m_sweep.c.x);
_local19 = (_local14.y - _local6.m_sweep.c.y);
_local2 = ((_local2 < _local15)) ? _local2 : _local15;
_local20 = b2Math.Clamp((_arg1 * (_local15 + b2Settings.b2_linearSlop)), -(b2Settings.b2_maxLinearCorrection), 0);
_local21 = (-(_local13.equalizedMass) * _local20);
_local22 = (_local21 * _local11.x);
_local23 = (_local21 * _local11.y);
_local5.m_sweep.c.x = (_local5.m_sweep.c.x - (_local7 * _local22));
_local5.m_sweep.c.y = (_local5.m_sweep.c.y - (_local7 * _local23));
_local5.m_sweep.a = (_local5.m_sweep.a - (_local8 * ((_local16 * _local23) - (_local17 * _local22))));
_local5.SynchronizeTransform();
_local6.m_sweep.c.x = (_local6.m_sweep.c.x + (_local9 * _local22));
_local6.m_sweep.c.y = (_local6.m_sweep.c.y + (_local9 * _local23));
_local6.m_sweep.a = (_local6.m_sweep.a + (_local10 * ((_local18 * _local23) - (_local19 * _local22))));
_local6.SynchronizeTransform();
_local12++;
};
_local3++;
};
return ((_local2 > (-1.5 * b2Settings.b2_linearSlop)));
}
public function Initialize(_arg1:b2TimeStep, _arg2:Array, _arg3:int, _arg4):void{
var _local5:b2Contact;
var _local6:int;
var _local7:b2Vec2;
var _local8:b2Mat22;
var _local9:b2Fixture;
var _local10:b2Fixture;
var _local11:b2Shape;
var _local12:b2Shape;
var _local13:Number;
var _local14:Number;
var _local15:b2Body;
var _local16:b2Body;
var _local17:b2Manifold;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:b2ContactConstraint;
var _local29:uint;
var _local30:b2ManifoldPoint;
var _local31:b2ContactConstraintPoint;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:Number;
var _local43:Number;
var _local44:Number;
var _local45:Number;
var _local46:Number;
var _local47:Number;
var _local48:b2ContactConstraintPoint;
var _local49:b2ContactConstraintPoint;
var _local50:Number;
var _local51:Number;
var _local52:Number;
var _local53:Number;
var _local54:Number;
var _local55:Number;
var _local56:Number;
var _local57:Number;
var _local58:Number;
var _local59:Number;
var _local60:Number;
var _local61:Number;
m_step.Set(_arg1);
m_allocator = _arg4;
m_constraintCount = _arg3;
while (m_constraints.length < m_constraintCount) {
m_constraints[m_constraints.length] = new b2ContactConstraint();
};
_local6 = 0;
while (_local6 < _arg3) {
_local5 = _arg2[_local6];
_local9 = _local5.m_fixtureA;
_local10 = _local5.m_fixtureB;
_local11 = _local9.m_shape;
_local12 = _local10.m_shape;
_local13 = _local11.m_radius;
_local14 = _local12.m_radius;
_local15 = _local9.m_body;
_local16 = _local10.m_body;
_local17 = _local5.GetManifold();
_local18 = b2Settings.b2MixFriction(_local9.GetFriction(), _local10.GetFriction());
_local19 = b2Settings.b2MixRestitution(_local9.GetRestitution(), _local10.GetRestitution());
_local20 = _local15.m_linearVelocity.x;
_local21 = _local15.m_linearVelocity.y;
_local22 = _local16.m_linearVelocity.x;
_local23 = _local16.m_linearVelocity.y;
_local24 = _local15.m_angularVelocity;
_local25 = _local16.m_angularVelocity;
b2Settings.b2Assert((_local17.m_pointCount > 0));
s_worldManifold.Initialize(_local17, _local15.m_xf, _local13, _local16.m_xf, _local14);
_local26 = s_worldManifold.m_normal.x;
_local27 = s_worldManifold.m_normal.y;
_local28 = m_constraints[_local6];
_local28.bodyA = _local15;
_local28.bodyB = _local16;
_local28.manifold = _local17;
_local28.normal.x = _local26;
_local28.normal.y = _local27;
_local28.pointCount = _local17.m_pointCount;
_local28.friction = _local18;
_local28.restitution = _local19;
_local28.localPlaneNormal.x = _local17.m_localPlaneNormal.x;
_local28.localPlaneNormal.y = _local17.m_localPlaneNormal.y;
_local28.localPoint.x = _local17.m_localPoint.x;
_local28.localPoint.y = _local17.m_localPoint.y;
_local28.radius = (_local13 + _local14);
_local28.type = _local17.m_type;
_local29 = 0;
while (_local29 < _local28.pointCount) {
_local30 = _local17.m_points[_local29];
_local31 = _local28.points[_local29];
_local31.normalImpulse = _local30.m_normalImpulse;
_local31.tangentImpulse = _local30.m_tangentImpulse;
_local31.localPoint.SetV(_local30.m_localPoint);
_local32 = (_local31.rA.x = (s_worldManifold.m_points[_local29].x - _local15.m_sweep.c.x));
_local33 = (_local31.rA.y = (s_worldManifold.m_points[_local29].y - _local15.m_sweep.c.y));
_local34 = (_local31.rB.x = (s_worldManifold.m_points[_local29].x - _local16.m_sweep.c.x));
_local35 = (_local31.rB.y = (s_worldManifold.m_points[_local29].y - _local16.m_sweep.c.y));
_local36 = ((_local32 * _local27) - (_local33 * _local26));
_local37 = ((_local34 * _local27) - (_local35 * _local26));
_local36 = (_local36 * _local36);
_local37 = (_local37 * _local37);
_local38 = (((_local15.m_invMass + _local16.m_invMass) + (_local15.m_invI * _local36)) + (_local16.m_invI * _local37));
_local31.normalMass = (1 / _local38);
_local39 = ((_local15.m_mass * _local15.m_invMass) + (_local16.m_mass * _local16.m_invMass));
_local39 = (_local39 + (((_local15.m_mass * _local15.m_invI) * _local36) + ((_local16.m_mass * _local16.m_invI) * _local37)));
_local31.equalizedMass = (1 / _local39);
_local40 = _local27;
_local41 = -(_local26);
_local42 = ((_local32 * _local41) - (_local33 * _local40));
_local43 = ((_local34 * _local41) - (_local35 * _local40));
_local42 = (_local42 * _local42);
_local43 = (_local43 * _local43);
_local44 = (((_local15.m_invMass + _local16.m_invMass) + (_local15.m_invI * _local42)) + (_local16.m_invI * _local43));
_local31.tangentMass = (1 / _local44);
_local31.velocityBias = 0;
_local45 = (((_local22 + (-(_local25) * _local35)) - _local20) - (-(_local24) * _local33));
_local46 = (((_local23 + (_local25 * _local34)) - _local21) - (_local24 * _local32));
_local47 = ((_local28.normal.x * _local45) + (_local28.normal.y * _local46));
if (_local47 < -(b2Settings.b2_velocityThreshold)){
_local31.velocityBias = (_local31.velocityBias + (-(_local28.restitution) * _local47));
};
_local29++;
};
if (_local28.pointCount == 2){
_local48 = _local28.points[0];
_local49 = _local28.points[1];
_local50 = _local15.m_invMass;
_local51 = _local15.m_invI;
_local52 = _local16.m_invMass;
_local53 = _local16.m_invI;
_local54 = ((_local48.rA.x * _local27) - (_local48.rA.y * _local26));
_local55 = ((_local48.rB.x * _local27) - (_local48.rB.y * _local26));
_local56 = ((_local49.rA.x * _local27) - (_local49.rA.y * _local26));
_local57 = ((_local49.rB.x * _local27) - (_local49.rB.y * _local26));
_local58 = (((_local50 + _local52) + ((_local51 * _local54) * _local54)) + ((_local53 * _local55) * _local55));
_local59 = (((_local50 + _local52) + ((_local51 * _local56) * _local56)) + ((_local53 * _local57) * _local57));
_local60 = (((_local50 + _local52) + ((_local51 * _local54) * _local56)) + ((_local53 * _local55) * _local57));
_local61 = 100;
if ((_local58 * _local58) < (_local61 * ((_local58 * _local59) - (_local60 * _local60)))){
_local28.K.col1.Set(_local58, _local60);
_local28.K.col2.Set(_local60, _local59);
_local28.K.GetInverse(_local28.normalMass);
} else {
_local28.pointCount = 1;
};
};
_local6++;
};
}
public function SolveVelocityConstraints():void{
var _local1:int;
var _local2:b2ContactConstraintPoint;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:b2Mat22;
var _local23:b2Vec2;
var _local25:b2ContactConstraint;
var _local26:b2Body;
var _local27:b2Body;
var _local28:Number;
var _local29:Number;
var _local30:b2Vec2;
var _local31:b2Vec2;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:int;
var _local43:b2ContactConstraintPoint;
var _local44:b2ContactConstraintPoint;
var _local45:Number;
var _local46:Number;
var _local47:Number;
var _local48:Number;
var _local49:Number;
var _local50:Number;
var _local51:Number;
var _local52:Number;
var _local53:Number;
var _local54:Number;
var _local55:Number;
var _local56:Number;
var _local57:Number;
var _local24:int;
while (_local24 < m_constraintCount) {
_local25 = m_constraints[_local24];
_local26 = _local25.bodyA;
_local27 = _local25.bodyB;
_local28 = _local26.m_angularVelocity;
_local29 = _local27.m_angularVelocity;
_local30 = _local26.m_linearVelocity;
_local31 = _local27.m_linearVelocity;
_local32 = _local26.m_invMass;
_local33 = _local26.m_invI;
_local34 = _local27.m_invMass;
_local35 = _local27.m_invI;
_local36 = _local25.normal.x;
_local37 = _local25.normal.y;
_local38 = _local37;
_local39 = -(_local36);
_local40 = _local25.friction;
_local1 = 0;
while (_local1 < _local25.pointCount) {
_local2 = _local25.points[_local1];
_local7 = (((_local31.x - (_local29 * _local2.rB.y)) - _local30.x) + (_local28 * _local2.rA.y));
_local8 = (((_local31.y + (_local29 * _local2.rB.x)) - _local30.y) - (_local28 * _local2.rA.x));
_local10 = ((_local7 * _local38) + (_local8 * _local39));
_local11 = (_local2.tangentMass * -(_local10));
_local12 = (_local40 * _local2.normalImpulse);
_local13 = b2Math.Clamp((_local2.tangentImpulse + _local11), -(_local12), _local12);
_local11 = (_local13 - _local2.tangentImpulse);
_local14 = (_local11 * _local38);
_local15 = (_local11 * _local39);
_local30.x = (_local30.x - (_local32 * _local14));
_local30.y = (_local30.y - (_local32 * _local15));
_local28 = (_local28 - (_local33 * ((_local2.rA.x * _local15) - (_local2.rA.y * _local14))));
_local31.x = (_local31.x + (_local34 * _local14));
_local31.y = (_local31.y + (_local34 * _local15));
_local29 = (_local29 + (_local35 * ((_local2.rB.x * _local15) - (_local2.rB.y * _local14))));
_local2.tangentImpulse = _local13;
_local1++;
};
_local42 = _local25.pointCount;
if (_local25.pointCount == 1){
_local2 = _local25.points[0];
_local7 = (((_local31.x + (-(_local29) * _local2.rB.y)) - _local30.x) - (-(_local28) * _local2.rA.y));
_local8 = (((_local31.y + (_local29 * _local2.rB.x)) - _local30.y) - (_local28 * _local2.rA.x));
_local9 = ((_local7 * _local36) + (_local8 * _local37));
_local11 = (-(_local2.normalMass) * (_local9 - _local2.velocityBias));
_local13 = (_local2.normalImpulse + _local11);
_local13 = ((_local13 > 0)) ? _local13 : 0;
_local11 = (_local13 - _local2.normalImpulse);
_local14 = (_local11 * _local36);
_local15 = (_local11 * _local37);
_local30.x = (_local30.x - (_local32 * _local14));
_local30.y = (_local30.y - (_local32 * _local15));
_local28 = (_local28 - (_local33 * ((_local2.rA.x * _local15) - (_local2.rA.y * _local14))));
_local31.x = (_local31.x + (_local34 * _local14));
_local31.y = (_local31.y + (_local34 * _local15));
_local29 = (_local29 + (_local35 * ((_local2.rB.x * _local15) - (_local2.rB.y * _local14))));
_local2.normalImpulse = _local13;
} else {
_local43 = _local25.points[0];
_local44 = _local25.points[1];
_local45 = _local43.normalImpulse;
_local46 = _local44.normalImpulse;
_local47 = (((_local31.x - (_local29 * _local43.rB.y)) - _local30.x) + (_local28 * _local43.rA.y));
_local48 = (((_local31.y + (_local29 * _local43.rB.x)) - _local30.y) - (_local28 * _local43.rA.x));
_local49 = (((_local31.x - (_local29 * _local44.rB.y)) - _local30.x) + (_local28 * _local44.rA.y));
_local50 = (((_local31.y + (_local29 * _local44.rB.x)) - _local30.y) - (_local28 * _local44.rA.x));
_local51 = ((_local47 * _local36) + (_local48 * _local37));
_local52 = ((_local49 * _local36) + (_local50 * _local37));
_local53 = (_local51 - _local43.velocityBias);
_local54 = (_local52 - _local44.velocityBias);
_local22 = _local25.K;
_local53 = (_local53 - ((_local22.col1.x * _local45) + (_local22.col2.x * _local46)));
_local54 = (_local54 - ((_local22.col1.y * _local45) + (_local22.col2.y * _local46)));
_local55 = 0.001;
while (true) {
_local22 = _local25.normalMass;
_local56 = -(((_local22.col1.x * _local53) + (_local22.col2.x * _local54)));
_local57 = -(((_local22.col1.y * _local53) + (_local22.col2.y * _local54)));
if ((((_local56 >= 0)) && ((_local57 >= 0)))){
_local16 = (_local56 - _local45);
_local17 = (_local57 - _local46);
_local18 = (_local16 * _local36);
_local19 = (_local16 * _local37);
_local20 = (_local17 * _local36);
_local21 = (_local17 * _local37);
_local30.x = (_local30.x - (_local32 * (_local18 + _local20)));
_local30.y = (_local30.y - (_local32 * (_local19 + _local21)));
_local28 = (_local28 - (_local33 * ((((_local43.rA.x * _local19) - (_local43.rA.y * _local18)) + (_local44.rA.x * _local21)) - (_local44.rA.y * _local20))));
_local31.x = (_local31.x + (_local34 * (_local18 + _local20)));
_local31.y = (_local31.y + (_local34 * (_local19 + _local21)));
_local29 = (_local29 + (_local35 * ((((_local43.rB.x * _local19) - (_local43.rB.y * _local18)) + (_local44.rB.x * _local21)) - (_local44.rB.y * _local20))));
_local43.normalImpulse = _local56;
_local44.normalImpulse = _local57;
break;
};
_local56 = (-(_local43.normalMass) * _local53);
_local57 = 0;
_local51 = 0;
_local52 = ((_local25.K.col1.y * _local56) + _local54);
if ((((_local56 >= 0)) && ((_local52 >= 0)))){
_local16 = (_local56 - _local45);
_local17 = (_local57 - _local46);
_local18 = (_local16 * _local36);
_local19 = (_local16 * _local37);
_local20 = (_local17 * _local36);
_local21 = (_local17 * _local37);
_local30.x = (_local30.x - (_local32 * (_local18 + _local20)));
_local30.y = (_local30.y - (_local32 * (_local19 + _local21)));
_local28 = (_local28 - (_local33 * ((((_local43.rA.x * _local19) - (_local43.rA.y * _local18)) + (_local44.rA.x * _local21)) - (_local44.rA.y * _local20))));
_local31.x = (_local31.x + (_local34 * (_local18 + _local20)));
_local31.y = (_local31.y + (_local34 * (_local19 + _local21)));
_local29 = (_local29 + (_local35 * ((((_local43.rB.x * _local19) - (_local43.rB.y * _local18)) + (_local44.rB.x * _local21)) - (_local44.rB.y * _local20))));
_local43.normalImpulse = _local56;
_local44.normalImpulse = _local57;
break;
};
_local56 = 0;
_local57 = (-(_local44.normalMass) * _local54);
_local51 = ((_local25.K.col2.x * _local57) + _local53);
_local52 = 0;
if ((((_local57 >= 0)) && ((_local51 >= 0)))){
_local16 = (_local56 - _local45);
_local17 = (_local57 - _local46);
_local18 = (_local16 * _local36);
_local19 = (_local16 * _local37);
_local20 = (_local17 * _local36);
_local21 = (_local17 * _local37);
_local30.x = (_local30.x - (_local32 * (_local18 + _local20)));
_local30.y = (_local30.y - (_local32 * (_local19 + _local21)));
_local28 = (_local28 - (_local33 * ((((_local43.rA.x * _local19) - (_local43.rA.y * _local18)) + (_local44.rA.x * _local21)) - (_local44.rA.y * _local20))));
_local31.x = (_local31.x + (_local34 * (_local18 + _local20)));
_local31.y = (_local31.y + (_local34 * (_local19 + _local21)));
_local29 = (_local29 + (_local35 * ((((_local43.rB.x * _local19) - (_local43.rB.y * _local18)) + (_local44.rB.x * _local21)) - (_local44.rB.y * _local20))));
_local43.normalImpulse = _local56;
_local44.normalImpulse = _local57;
break;
};
_local56 = 0;
_local57 = 0;
_local51 = _local53;
_local52 = _local54;
if ((((_local51 >= 0)) && ((_local52 >= 0)))){
_local16 = (_local56 - _local45);
_local17 = (_local57 - _local46);
_local18 = (_local16 * _local36);
_local19 = (_local16 * _local37);
_local20 = (_local17 * _local36);
_local21 = (_local17 * _local37);
_local30.x = (_local30.x - (_local32 * (_local18 + _local20)));
_local30.y = (_local30.y - (_local32 * (_local19 + _local21)));
_local28 = (_local28 - (_local33 * ((((_local43.rA.x * _local19) - (_local43.rA.y * _local18)) + (_local44.rA.x * _local21)) - (_local44.rA.y * _local20))));
_local31.x = (_local31.x + (_local34 * (_local18 + _local20)));
_local31.y = (_local31.y + (_local34 * (_local19 + _local21)));
_local29 = (_local29 + (_local35 * ((((_local43.rB.x * _local19) - (_local43.rB.y * _local18)) + (_local44.rB.x * _local21)) - (_local44.rB.y * _local20))));
_local43.normalImpulse = _local56;
_local44.normalImpulse = _local57;
break;
};
break;
};
};
_local26.m_angularVelocity = _local28;
_local27.m_angularVelocity = _local29;
_local24++;
};
}
public function FinalizeVelocityConstraints():void{
var _local2:b2ContactConstraint;
var _local3:b2Manifold;
var _local4:int;
var _local5:b2ManifoldPoint;
var _local6:b2ContactConstraintPoint;
var _local1:int;
while (_local1 < m_constraintCount) {
_local2 = m_constraints[_local1];
_local3 = _local2.manifold;
_local4 = 0;
while (_local4 < _local2.pointCount) {
_local5 = _local3.m_points[_local4];
_local6 = _local2.points[_local4];
_local5.m_normalImpulse = _local6.normalImpulse;
_local5.m_tangentImpulse = _local6.tangentImpulse;
_local4++;
};
_local1++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 51
//b2EdgeAndCircleContact (Box2D.Dynamics.Contacts.b2EdgeAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2EdgeAndCircleContact extends b2Contact {
override b2internal function Evaluate():void{
var _local1:b2Body = m_fixtureA.GetBody();
var _local2:b2Body = m_fixtureB.GetBody();
b2CollideEdgeAndCircle(m_manifold, (m_fixtureA.GetShape() as b2EdgeShape), _local1.m_xf, (m_fixtureB.GetShape() as b2CircleShape), _local2.m_xf);
}
private function b2CollideEdgeAndCircle(_arg1:b2Manifold, _arg2:b2EdgeShape, _arg3:b2Transform, _arg4:b2CircleShape, _arg5:b2Transform):void{
}
public function Reset(_arg1:b2Fixture, _arg2:b2Fixture):void{
super.Reset(_arg1, _arg2);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1):b2Contact{
return (new (b2EdgeAndCircleContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 52
//b2PolyAndCircleContact (Box2D.Dynamics.Contacts.b2PolyAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolyAndCircleContact extends b2Contact {
override b2internal function Evaluate():void{
var _local1:b2Body = m_fixtureA.m_body;
var _local2:b2Body = m_fixtureB.m_body;
b2Collision.CollidePolygonAndCircle(m_manifold, (m_fixtureA.GetShape() as b2PolygonShape), _local1.m_xf, (m_fixtureB.GetShape() as b2CircleShape), _local2.m_xf);
}
public function Reset(_arg1:b2Fixture, _arg2:b2Fixture):void{
super.Reset(_arg1, _arg2);
b2Settings.b2Assert((_arg1.GetType() == b2Shape.e_polygonShape));
b2Settings.b2Assert((_arg2.GetType() == b2Shape.e_circleShape));
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1):b2Contact{
return (new (b2PolyAndCircleContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 53
//b2PolyAndEdgeContact (Box2D.Dynamics.Contacts.b2PolyAndEdgeContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolyAndEdgeContact extends b2Contact {
override b2internal function Evaluate():void{
var _local1:b2Body = m_fixtureA.GetBody();
var _local2:b2Body = m_fixtureB.GetBody();
b2CollidePolyAndEdge(m_manifold, (m_fixtureA.GetShape() as b2PolygonShape), _local1.m_xf, (m_fixtureB.GetShape() as b2EdgeShape), _local2.m_xf);
}
private function b2CollidePolyAndEdge(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2Transform, _arg4:b2EdgeShape, _arg5:b2Transform):void{
}
public function Reset(_arg1:b2Fixture, _arg2:b2Fixture):void{
super.Reset(_arg1, _arg2);
b2Settings.b2Assert((_arg1.GetType() == b2Shape.e_polygonShape));
b2Settings.b2Assert((_arg2.GetType() == b2Shape.e_edgeShape));
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1):b2Contact{
return (new (b2PolyAndEdgeContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 54
//b2PolygonContact (Box2D.Dynamics.Contacts.b2PolygonContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolygonContact extends b2Contact {
override b2internal function Evaluate():void{
var _local1:b2Body = m_fixtureA.GetBody();
var _local2:b2Body = m_fixtureB.GetBody();
b2Collision.CollidePolygons(m_manifold, (m_fixtureA.GetShape() as b2PolygonShape), _local1.m_xf, (m_fixtureB.GetShape() as b2PolygonShape), _local2.m_xf);
}
public function Reset(_arg1:b2Fixture, _arg2:b2Fixture):void{
super.Reset(_arg1, _arg2);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1):b2Contact{
return (new (b2PolygonContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 55
//b2PositionSolverManifold (Box2D.Dynamics.Contacts.b2PositionSolverManifold)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
class b2PositionSolverManifold {
public var m_points:Array;
public var m_normal:b2Vec2;
public var m_separations:Array;
private static var circlePointA:b2Vec2 = new b2Vec2();
private static var circlePointB:b2Vec2 = new b2Vec2();
function b2PositionSolverManifold(){
m_normal = new b2Vec2();
m_separations = new Array(b2Settings.b2_maxManifoldPoints);
m_points = new Array(b2Settings.b2_maxManifoldPoints);
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
m_points[_local1] = new b2Vec2();
_local1++;
};
}
public function Initialize(_arg1:b2ContactConstraint):void{
var _local2:int;
var _local3:Number;
var _local4:Number;
var _local5:b2Mat22;
var _local6:b2Vec2;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
b2Settings.b2Assert((_arg1.pointCount > 0));
switch (_arg1.type){
case b2Manifold.e_circles:
_local5 = _arg1.bodyA.m_xf.R;
_local6 = _arg1.localPoint;
_local9 = (_arg1.bodyA.m_xf.position.x + ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y)));
_local10 = (_arg1.bodyA.m_xf.position.y + ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y)));
_local5 = _arg1.bodyB.m_xf.R;
_local6 = _arg1.points[0].localPoint;
_local11 = (_arg1.bodyB.m_xf.position.x + ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y)));
_local12 = (_arg1.bodyB.m_xf.position.y + ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y)));
_local13 = (_local11 - _local9);
_local14 = (_local12 - _local10);
_local15 = ((_local13 * _local13) + (_local14 * _local14));
if (_local15 > (Number.MIN_VALUE * Number.MIN_VALUE)){
_local16 = Math.sqrt(_local15);
m_normal.x = (_local13 / _local16);
m_normal.y = (_local14 / _local16);
} else {
m_normal.x = 1;
m_normal.y = 0;
};
m_points[0].x = (0.5 * (_local9 + _local11));
m_points[0].y = (0.5 * (_local10 + _local12));
m_separations[0] = (((_local13 * m_normal.x) + (_local14 * m_normal.y)) - _arg1.radius);
break;
case b2Manifold.e_faceA:
_local5 = _arg1.bodyA.m_xf.R;
_local6 = _arg1.localPlaneNormal;
m_normal.x = ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y));
m_normal.y = ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y));
_local5 = _arg1.bodyA.m_xf.R;
_local6 = _arg1.localPoint;
_local7 = (_arg1.bodyA.m_xf.position.x + ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y)));
_local8 = (_arg1.bodyA.m_xf.position.y + ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y)));
_local5 = _arg1.bodyB.m_xf.R;
_local2 = 0;
while (_local2 < _arg1.pointCount) {
_local6 = _arg1.points[_local2].localPoint;
_local3 = (_arg1.bodyB.m_xf.position.x + ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y)));
_local4 = (_arg1.bodyB.m_xf.position.y + ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y)));
m_separations[_local2] = ((((_local3 - _local7) * m_normal.x) + ((_local4 - _local8) * m_normal.y)) - _arg1.radius);
m_points[_local2].x = _local3;
m_points[_local2].y = _local4;
_local2++;
};
break;
case b2Manifold.e_faceB:
_local5 = _arg1.bodyB.m_xf.R;
_local6 = _arg1.localPlaneNormal;
m_normal.x = ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y));
m_normal.y = ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y));
_local5 = _arg1.bodyB.m_xf.R;
_local6 = _arg1.localPoint;
_local7 = (_arg1.bodyB.m_xf.position.x + ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y)));
_local8 = (_arg1.bodyB.m_xf.position.y + ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y)));
_local5 = _arg1.bodyA.m_xf.R;
_local2 = 0;
while (_local2 < _arg1.pointCount) {
_local6 = _arg1.points[_local2].localPoint;
_local3 = (_arg1.bodyA.m_xf.position.x + ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y)));
_local4 = (_arg1.bodyA.m_xf.position.y + ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y)));
m_separations[_local2] = ((((_local3 - _local7) * m_normal.x) + ((_local4 - _local8) * m_normal.y)) - _arg1.radius);
m_points[_local2].Set(_local3, _local4);
_local2++;
};
m_normal.x = (m_normal.x * -1);
m_normal.y = (m_normal.y * -1);
break;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 56
//b2Controller (Box2D.Dynamics.Controllers.b2Controller)
package Box2D.Dynamics.Controllers {
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2Controller {
b2internal var m_world:b2World;
b2internal var m_prev:b2Controller;
b2internal var m_next:b2Controller;
protected var m_bodyList:b2ControllerEdge;
protected var m_bodyCount:int;
public function AddBody(_arg1:b2Body):void{
var _local2:b2ControllerEdge = new b2ControllerEdge();
_local2.controller = this;
_local2.body = _arg1;
_local2.nextBody = m_bodyList;
_local2.prevBody = null;
m_bodyList = _local2;
if (_local2.nextBody){
_local2.nextBody.prevBody = _local2;
};
m_bodyCount++;
_local2.nextController = _arg1.m_controllerList;
_local2.prevController = null;
_arg1.m_controllerList = _local2;
if (_local2.nextController){
_local2.nextController.prevController = _local2;
};
_arg1.m_controllerCount++;
}
public function Draw(_arg1:b2DebugDraw):void{
}
public function RemoveBody(_arg1:b2Body):void{
var _local2:b2ControllerEdge = _arg1.m_controllerList;
while (((_local2) && (!((_local2.controller == this))))) {
_local2 = _local2.nextController;
};
if (_local2.prevBody){
_local2.prevBody.nextBody = _local2.nextBody;
};
if (_local2.nextBody){
_local2.nextBody.prevBody = _local2.prevBody;
};
if (_local2.nextController){
_local2.nextController.prevController = _local2.prevController;
};
if (_local2.prevController){
_local2.prevController.nextController = _local2.nextController;
};
if (m_bodyList == _local2){
m_bodyList = _local2.nextBody;
};
if (_arg1.m_controllerList == _local2){
_arg1.m_controllerList = _local2.nextController;
};
_arg1.m_controllerCount--;
m_bodyCount--;
}
public function GetNext():b2Controller{
return (m_next);
}
public function Clear():void{
while (m_bodyList) {
RemoveBody(m_bodyList.body);
};
}
public function Step(_arg1:b2TimeStep):void{
}
public function GetBodyList():b2ControllerEdge{
return (m_bodyList);
}
public function GetWorld():b2World{
return (m_world);
}
}
}//package Box2D.Dynamics.Controllers
Section 57
//b2ControllerEdge (Box2D.Dynamics.Controllers.b2ControllerEdge)
package Box2D.Dynamics.Controllers {
import Box2D.Dynamics.*;
public class b2ControllerEdge {
public var body:b2Body;
public var nextBody:b2ControllerEdge;
public var nextController:b2ControllerEdge;
public var prevBody:b2ControllerEdge;
public var prevController:b2ControllerEdge;
public var controller:b2Controller;
}
}//package Box2D.Dynamics.Controllers
Section 58
//b2DistanceJoint (Box2D.Dynamics.Joints.b2DistanceJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2DistanceJoint extends b2Joint {
private var m_localAnchor1:b2Vec2;
private var m_localAnchor2:b2Vec2;
private var m_length:Number;
private var m_mass:Number;
private var m_bias:Number;
private var m_gamma:Number;
private var m_u:b2Vec2;
private var m_impulse:Number;
private var m_dampingRatio:Number;
private var m_frequencyHz:Number;
public function b2DistanceJoint(_arg1:b2DistanceJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_u = new b2Vec2();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchorA);
m_localAnchor2.SetV(_arg1.localAnchorB);
m_length = _arg1.length;
m_frequencyHz = _arg1.frequencyHz;
m_dampingRatio = _arg1.dampingRatio;
m_impulse = 0;
m_gamma = 0;
m_bias = 0;
}
public function SetFrequency(_arg1:Number):void{
m_frequencyHz = _arg1;
}
public function GetFrequency():Number{
return (m_frequencyHz);
}
public function SetLength(_arg1:Number):void{
m_length = _arg1;
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:Number;
var _local4:b2Body;
var _local5:b2Body;
var _local7:Number;
var _local9:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
_local4 = m_bodyA;
_local5 = m_bodyB;
_local2 = _local4.m_xf.R;
var _local6:Number = (m_localAnchor1.x - _local4.m_sweep.localCenter.x);
_local7 = (m_localAnchor1.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local6) + (_local2.col2.x * _local7));
_local7 = ((_local2.col1.y * _local6) + (_local2.col2.y * _local7));
_local6 = _local3;
_local2 = _local5.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local5.m_sweep.localCenter.x);
_local9 = (m_localAnchor2.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local3;
m_u.x = (((_local5.m_sweep.c.x + _local8) - _local4.m_sweep.c.x) - _local6);
m_u.y = (((_local5.m_sweep.c.y + _local9) - _local4.m_sweep.c.y) - _local7);
var _local10:Number = Math.sqrt(((m_u.x * m_u.x) + (m_u.y * m_u.y)));
if (_local10 > b2Settings.b2_linearSlop){
m_u.Multiply((1 / _local10));
} else {
m_u.SetZero();
};
var _local11:Number = ((_local6 * m_u.y) - (_local7 * m_u.x));
var _local12:Number = ((_local8 * m_u.y) - (_local9 * m_u.x));
var _local13:Number = (((_local4.m_invMass + ((_local4.m_invI * _local11) * _local11)) + _local5.m_invMass) + ((_local5.m_invI * _local12) * _local12));
m_mass = ((_local13)!=0) ? (1 / _local13) : 0;
if (m_frequencyHz > 0){
_local14 = (_local10 - m_length);
_local15 = ((2 * Math.PI) * m_frequencyHz);
_local16 = (((2 * m_mass) * m_dampingRatio) * _local15);
_local17 = ((m_mass * _local15) * _local15);
m_gamma = (_arg1.dt * (_local16 + (_arg1.dt * _local17)));
m_gamma = ((m_gamma)!=0) ? (1 / m_gamma) : 0;
m_bias = (((_local14 * _arg1.dt) * _local17) * m_gamma);
m_mass = (_local13 + m_gamma);
m_mass = ((m_mass)!=0) ? (1 / m_mass) : 0;
};
if (_arg1.warmStarting){
m_impulse = (m_impulse * _arg1.dtRatio);
_local18 = (m_impulse * m_u.x);
_local19 = (m_impulse * m_u.y);
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x - (_local4.m_invMass * _local18));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y - (_local4.m_invMass * _local19));
_local4.m_angularVelocity = (_local4.m_angularVelocity - (_local4.m_invI * ((_local6 * _local19) - (_local7 * _local18))));
_local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + (_local5.m_invMass * _local18));
_local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + (_local5.m_invMass * _local19));
_local5.m_angularVelocity = (_local5.m_angularVelocity + (_local5.m_invI * ((_local8 * _local19) - (_local9 * _local18))));
} else {
m_impulse = 0;
};
}
public function SetDampingRatio(_arg1:Number):void{
m_dampingRatio = _arg1;
}
public function GetLength():Number{
return (m_length);
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2(((_arg1 * m_impulse) * m_u.x), ((_arg1 * m_impulse) * m_u.y)));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local2:b2Mat22;
if (m_frequencyHz > 0){
return (true);
};
var _local3:b2Body = m_bodyA;
var _local4:b2Body = m_bodyB;
_local2 = _local3.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
var _local6:Number = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
var _local7:Number = ((_local2.col1.x * _local5) + (_local2.col2.x * _local6));
_local6 = ((_local2.col1.y * _local5) + (_local2.col2.y * _local6));
_local5 = _local7;
_local2 = _local4.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local4.m_sweep.localCenter.y);
_local7 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local7;
var _local10:Number = (((_local4.m_sweep.c.x + _local8) - _local3.m_sweep.c.x) - _local5);
var _local11:Number = (((_local4.m_sweep.c.y + _local9) - _local3.m_sweep.c.y) - _local6);
var _local12:Number = Math.sqrt(((_local10 * _local10) + (_local11 * _local11)));
_local10 = (_local10 / _local12);
_local11 = (_local11 / _local12);
var _local13:Number = (_local12 - m_length);
_local13 = b2Math.Clamp(_local13, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
var _local14:Number = (-(m_mass) * _local13);
m_u.Set(_local10, _local11);
var _local15:Number = (_local14 * m_u.x);
var _local16:Number = (_local14 * m_u.y);
_local3.m_sweep.c.x = (_local3.m_sweep.c.x - (_local3.m_invMass * _local15));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y - (_local3.m_invMass * _local16));
_local3.m_sweep.a = (_local3.m_sweep.a - (_local3.m_invI * ((_local5 * _local16) - (_local6 * _local15))));
_local4.m_sweep.c.x = (_local4.m_sweep.c.x + (_local4.m_invMass * _local15));
_local4.m_sweep.c.y = (_local4.m_sweep.c.y + (_local4.m_invMass * _local16));
_local4.m_sweep.a = (_local4.m_sweep.a + (_local4.m_invI * ((_local8 * _local16) - (_local9 * _local15))));
_local3.SynchronizeTransform();
_local4.SynchronizeTransform();
return ((b2Math.Abs(_local13) < b2Settings.b2_linearSlop));
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:b2Body = m_bodyA;
var _local4:b2Body = m_bodyB;
_local2 = _local3.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
var _local6:Number = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
var _local7:Number = ((_local2.col1.x * _local5) + (_local2.col2.x * _local6));
_local6 = ((_local2.col1.y * _local5) + (_local2.col2.y * _local6));
_local5 = _local7;
_local2 = _local4.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local4.m_sweep.localCenter.y);
_local7 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local7;
var _local10:Number = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local6));
var _local11:Number = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local5));
var _local12:Number = (_local4.m_linearVelocity.x + (-(_local4.m_angularVelocity) * _local9));
var _local13:Number = (_local4.m_linearVelocity.y + (_local4.m_angularVelocity * _local8));
var _local14:Number = ((m_u.x * (_local12 - _local10)) + (m_u.y * (_local13 - _local11)));
var _local15:Number = (-(m_mass) * ((_local14 + m_bias) + (m_gamma * m_impulse)));
m_impulse = (m_impulse + _local15);
var _local16:Number = (_local15 * m_u.x);
var _local17:Number = (_local15 * m_u.y);
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x - (_local3.m_invMass * _local16));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y - (_local3.m_invMass * _local17));
_local3.m_angularVelocity = (_local3.m_angularVelocity - (_local3.m_invI * ((_local5 * _local17) - (_local6 * _local16))));
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x + (_local4.m_invMass * _local16));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y + (_local4.m_invMass * _local17));
_local4.m_angularVelocity = (_local4.m_angularVelocity + (_local4.m_invI * ((_local8 * _local17) - (_local9 * _local16))));
}
public function GetDampingRatio():Number{
return (m_dampingRatio);
}
}
}//package Box2D.Dynamics.Joints
Section 59
//b2DistanceJointDef (Box2D.Dynamics.Joints.b2DistanceJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class b2DistanceJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var length:Number;
public var dampingRatio:Number;
public var localAnchorB:b2Vec2;
public var frequencyHz:Number;
public function b2DistanceJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_distanceJoint;
length = 1;
frequencyHz = 0;
dampingRatio = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2):void{
bodyA = _arg1;
bodyB = _arg2;
localAnchorA.SetV(bodyA.GetLocalPoint(_arg3));
localAnchorB.SetV(bodyB.GetLocalPoint(_arg4));
var _local5:Number = (_arg4.x - _arg3.x);
var _local6:Number = (_arg4.y - _arg3.y);
length = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
frequencyHz = 0;
dampingRatio = 0;
}
}
}//package Box2D.Dynamics.Joints
Section 60
//b2FrictionJoint (Box2D.Dynamics.Joints.b2FrictionJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2FrictionJoint extends b2Joint {
private var m_maxTorque:Number;
private var m_angularImpulse:Number;
public var m_linearMass:b2Mat22;
private var m_localAnchorA:b2Vec2;
private var m_localAnchorB:b2Vec2;
public var m_angularMass:Number;
private var m_maxForce:Number;
private var m_linearImpulse:b2Vec2;
public function b2FrictionJoint(_arg1:b2FrictionJointDef){
m_localAnchorA = new b2Vec2();
m_localAnchorB = new b2Vec2();
m_linearMass = new b2Mat22();
m_linearImpulse = new b2Vec2();
super(_arg1);
m_localAnchorA.SetV(_arg1.localAnchorA);
m_localAnchorB.SetV(_arg1.localAnchorB);
m_linearMass.SetZero();
m_angularMass = 0;
m_linearImpulse.SetZero();
m_angularImpulse = 0;
m_maxForce = _arg1.maxForce;
m_maxTorque = _arg1.maxTorque;
}
public function SetMaxForce(_arg1:Number):void{
m_maxForce = _arg1;
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:Number;
var _local4:b2Body;
var _local5:b2Body;
var _local6:Number;
var _local8:Number;
var _local10:Number;
var _local12:Number;
var _local13:Number;
var _local14:b2Mat22;
var _local15:b2Vec2;
_local4 = m_bodyA;
_local5 = m_bodyB;
_local2 = _local4.m_xf.R;
_local6 = (m_localAnchorA.x - _local4.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchorA.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local6) + (_local2.col2.x * _local7));
_local7 = ((_local2.col1.y * _local6) + (_local2.col2.y * _local7));
_local6 = _local3;
_local2 = _local5.m_xf.R;
_local8 = (m_localAnchorB.x - _local5.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchorB.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local3;
_local10 = _local4.m_invMass;
var _local11:Number = _local5.m_invMass;
_local12 = _local4.m_invI;
_local13 = _local5.m_invI;
_local14 = new b2Mat22();
_local14.col1.x = (_local10 + _local11);
_local14.col2.x = 0;
_local14.col1.y = 0;
_local14.col2.y = (_local10 + _local11);
_local14.col1.x = (_local14.col1.x + ((_local12 * _local7) * _local7));
_local14.col2.x = (_local14.col2.x + ((-(_local12) * _local6) * _local7));
_local14.col1.y = (_local14.col1.y + ((-(_local12) * _local6) * _local7));
_local14.col2.y = (_local14.col2.y + ((_local12 * _local6) * _local6));
_local14.col1.x = (_local14.col1.x + ((_local13 * _local9) * _local9));
_local14.col2.x = (_local14.col2.x + ((-(_local13) * _local8) * _local9));
_local14.col1.y = (_local14.col1.y + ((-(_local13) * _local8) * _local9));
_local14.col2.y = (_local14.col2.y + ((_local13 * _local8) * _local8));
_local14.GetInverse(m_linearMass);
m_angularMass = (_local12 + _local13);
if (m_angularMass > 0){
m_angularMass = (1 / m_angularMass);
};
if (_arg1.warmStarting){
m_linearImpulse.x = (m_linearImpulse.x * _arg1.dtRatio);
m_linearImpulse.y = (m_linearImpulse.y * _arg1.dtRatio);
m_angularImpulse = (m_angularImpulse * _arg1.dtRatio);
_local15 = m_linearImpulse;
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x - (_local10 * _local15.x));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y - (_local10 * _local15.y));
_local4.m_angularVelocity = (_local4.m_angularVelocity - (_local12 * (((_local6 * _local15.y) - (_local7 * _local15.x)) + m_angularImpulse)));
_local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + (_local11 * _local15.x));
_local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + (_local11 * _local15.y));
_local5.m_angularVelocity = (_local5.m_angularVelocity + (_local13 * (((_local8 * _local15.y) - (_local9 * _local15.x)) + m_angularImpulse)));
} else {
m_linearImpulse.SetZero();
m_angularImpulse = 0;
};
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchorB));
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchorA));
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_angularImpulse));
}
public function SetMaxTorque(_arg1:Number):void{
m_maxTorque = _arg1;
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
return (true);
}
public function GetMaxTorque():Number{
return (m_maxTorque);
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:Number;
var _local18:Number;
var _local4:b2Body = m_bodyA;
var _local5:b2Body = m_bodyB;
var _local6:b2Vec2 = _local4.m_linearVelocity;
var _local7:Number = _local4.m_angularVelocity;
var _local8:b2Vec2 = _local5.m_linearVelocity;
var _local9:Number = _local5.m_angularVelocity;
var _local10:Number = _local4.m_invMass;
var _local11:Number = _local5.m_invMass;
var _local12:Number = _local4.m_invI;
var _local13:Number = _local5.m_invI;
_local2 = _local4.m_xf.R;
var _local14:Number = (m_localAnchorA.x - _local4.m_sweep.localCenter.x);
var _local15:Number = (m_localAnchorA.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local14) + (_local2.col2.x * _local15));
_local15 = ((_local2.col1.y * _local14) + (_local2.col2.y * _local15));
_local14 = _local3;
_local2 = _local5.m_xf.R;
var _local16:Number = (m_localAnchorB.x - _local5.m_sweep.localCenter.x);
var _local17:Number = (m_localAnchorB.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local16) + (_local2.col2.x * _local17));
_local17 = ((_local2.col1.y * _local16) + (_local2.col2.y * _local17));
_local16 = _local3;
var _local19:Number = (_local9 - _local7);
var _local20:Number = (-(m_angularMass) * _local19);
var _local21:Number = m_angularImpulse;
_local18 = (_arg1.dt * m_maxTorque);
m_angularImpulse = b2Math.Clamp((m_angularImpulse + _local20), -(_local18), _local18);
_local20 = (m_angularImpulse - _local21);
_local7 = (_local7 - (_local12 * _local20));
_local9 = (_local9 + (_local13 * _local20));
var _local22:Number = (((_local8.x - (_local9 * _local17)) - _local6.x) + (_local7 * _local15));
var _local23:Number = (((_local8.y + (_local9 * _local16)) - _local6.y) - (_local7 * _local14));
var _local24:b2Vec2 = b2Math.MulMV(m_linearMass, new b2Vec2(-(_local22), -(_local23)));
var _local25:b2Vec2 = m_linearImpulse.Copy();
m_linearImpulse.Add(_local24);
_local18 = (_arg1.dt * m_maxForce);
if (m_linearImpulse.LengthSquared() > (_local18 * _local18)){
m_linearImpulse.Normalize();
m_linearImpulse.Multiply(_local18);
};
_local24 = b2Math.SubtractVV(m_linearImpulse, _local25);
_local6.x = (_local6.x - (_local10 * _local24.x));
_local6.y = (_local6.y - (_local10 * _local24.y));
_local7 = (_local7 - (_local12 * ((_local14 * _local24.y) - (_local15 * _local24.x))));
_local8.x = (_local8.x + (_local11 * _local24.x));
_local8.y = (_local8.y + (_local11 * _local24.y));
_local9 = (_local9 + (_local13 * ((_local16 * _local24.y) - (_local17 * _local24.x))));
_local4.m_angularVelocity = _local7;
_local5.m_angularVelocity = _local9;
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2((_arg1 * m_linearImpulse.x), (_arg1 * m_linearImpulse.y)));
}
public function GetMaxForce():Number{
return (m_maxForce);
}
}
}//package Box2D.Dynamics.Joints
Section 61
//b2FrictionJointDef (Box2D.Dynamics.Joints.b2FrictionJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class b2FrictionJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var maxTorque:Number;
public var maxForce:Number;
public var localAnchorB:b2Vec2;
public function b2FrictionJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_frictionJoint;
maxForce = 0;
maxTorque = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2):void{
bodyA = _arg1;
bodyB = _arg2;
localAnchorA.SetV(bodyA.GetLocalPoint(_arg3));
localAnchorB.SetV(bodyB.GetLocalPoint(_arg3));
}
}
}//package Box2D.Dynamics.Joints
Section 62
//b2GearJoint (Box2D.Dynamics.Joints.b2GearJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2GearJoint extends b2Joint {
private var m_ground2:b2Body;
private var m_groundAnchor1:b2Vec2;
private var m_groundAnchor2:b2Vec2;
private var m_localAnchor1:b2Vec2;
private var m_localAnchor2:b2Vec2;
private var m_ratio:Number;
private var m_mass:Number;
private var m_impulse:Number;
private var m_prismatic2:b2PrismaticJoint;
private var m_ground1:b2Body;
private var m_revolute1:b2RevoluteJoint;
private var m_revolute2:b2RevoluteJoint;
private var m_prismatic1:b2PrismaticJoint;
private var m_constant:Number;
private var m_J:b2Jacobian;
public function b2GearJoint(_arg1:b2GearJointDef){
var _local4:Number;
var _local5:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_J = new b2Jacobian();
super(_arg1);
var _local2:int = _arg1.joint1.m_type;
var _local3:int = _arg1.joint2.m_type;
m_revolute1 = null;
m_prismatic1 = null;
m_revolute2 = null;
m_prismatic2 = null;
m_ground1 = _arg1.joint1.GetBodyA();
m_bodyA = _arg1.joint1.GetBodyB();
if (_local2 == b2Joint.e_revoluteJoint){
m_revolute1 = (_arg1.joint1 as b2RevoluteJoint);
m_groundAnchor1.SetV(m_revolute1.m_localAnchor1);
m_localAnchor1.SetV(m_revolute1.m_localAnchor2);
_local4 = m_revolute1.GetJointAngle();
} else {
m_prismatic1 = (_arg1.joint1 as b2PrismaticJoint);
m_groundAnchor1.SetV(m_prismatic1.m_localAnchor1);
m_localAnchor1.SetV(m_prismatic1.m_localAnchor2);
_local4 = m_prismatic1.GetJointTranslation();
};
m_ground2 = _arg1.joint2.GetBodyA();
m_bodyB = _arg1.joint2.GetBodyB();
if (_local3 == b2Joint.e_revoluteJoint){
m_revolute2 = (_arg1.joint2 as b2RevoluteJoint);
m_groundAnchor2.SetV(m_revolute2.m_localAnchor1);
m_localAnchor2.SetV(m_revolute2.m_localAnchor2);
_local5 = m_revolute2.GetJointAngle();
} else {
m_prismatic2 = (_arg1.joint2 as b2PrismaticJoint);
m_groundAnchor2.SetV(m_prismatic2.m_localAnchor1);
m_localAnchor2.SetV(m_prismatic2.m_localAnchor2);
_local5 = m_prismatic2.GetJointTranslation();
};
m_ratio = _arg1.ratio;
m_constant = (_local4 + (m_ratio * _local5));
m_impulse = 0;
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Body;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:b2Mat22;
var _local11:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local2:b2Body = m_ground1;
var _local3:b2Body = m_ground2;
_local4 = m_bodyA;
var _local5:b2Body = m_bodyB;
var _local14:Number = 0;
m_J.SetZero();
if (m_revolute1){
m_J.angularA = -1;
_local14 = (_local14 + _local4.m_invI);
} else {
_local10 = _local2.m_xf.R;
_local11 = m_prismatic1.m_localXAxis1;
_local6 = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y));
_local7 = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y));
_local10 = _local4.m_xf.R;
_local8 = (m_localAnchor1.x - _local4.m_sweep.localCenter.x);
_local9 = (m_localAnchor1.y - _local4.m_sweep.localCenter.y);
_local13 = ((_local10.col1.x * _local8) + (_local10.col2.x * _local9));
_local9 = ((_local10.col1.y * _local8) + (_local10.col2.y * _local9));
_local8 = _local13;
_local12 = ((_local8 * _local7) - (_local9 * _local6));
m_J.linearA.Set(-(_local6), -(_local7));
m_J.angularA = -(_local12);
_local14 = (_local14 + (_local4.m_invMass + ((_local4.m_invI * _local12) * _local12)));
};
if (m_revolute2){
m_J.angularB = -(m_ratio);
_local14 = (_local14 + ((m_ratio * m_ratio) * _local5.m_invI));
} else {
_local10 = _local3.m_xf.R;
_local11 = m_prismatic2.m_localXAxis1;
_local6 = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y));
_local7 = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y));
_local10 = _local5.m_xf.R;
_local8 = (m_localAnchor2.x - _local5.m_sweep.localCenter.x);
_local9 = (m_localAnchor2.y - _local5.m_sweep.localCenter.y);
_local13 = ((_local10.col1.x * _local8) + (_local10.col2.x * _local9));
_local9 = ((_local10.col1.y * _local8) + (_local10.col2.y * _local9));
_local8 = _local13;
_local12 = ((_local8 * _local7) - (_local9 * _local6));
m_J.linearB.Set((-(m_ratio) * _local6), (-(m_ratio) * _local7));
m_J.angularB = (-(m_ratio) * _local12);
_local14 = (_local14 + ((m_ratio * m_ratio) * (_local5.m_invMass + ((_local5.m_invI * _local12) * _local12))));
};
m_mass = ((_local14 > 0)) ? (1 / _local14) : 0;
if (_arg1.warmStarting){
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x + ((_local4.m_invMass * m_impulse) * m_J.linearA.x));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y + ((_local4.m_invMass * m_impulse) * m_J.linearA.y));
_local4.m_angularVelocity = (_local4.m_angularVelocity + ((_local4.m_invI * m_impulse) * m_J.angularA));
_local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + ((_local5.m_invMass * m_impulse) * m_J.linearB.x));
_local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + ((_local5.m_invMass * m_impulse) * m_J.linearB.y));
_local5.m_angularVelocity = (_local5.m_angularVelocity + ((_local5.m_invI * m_impulse) * m_J.angularB));
} else {
m_impulse = 0;
};
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
var _local4:Number = m_J.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
var _local5:Number = (-(m_mass) * _local4);
m_impulse = (m_impulse + _local5);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local2.m_invMass * _local5) * m_J.linearA.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local2.m_invMass * _local5) * m_J.linearA.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local2.m_invI * _local5) * m_J.angularA));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local3.m_invMass * _local5) * m_J.linearB.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local3.m_invMass * _local5) * m_J.linearB.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local3.m_invI * _local5) * m_J.angularB));
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
public function SetRatio(_arg1:Number):void{
m_ratio = _arg1;
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2(((_arg1 * m_impulse) * m_J.linearB.x), ((_arg1 * m_impulse) * m_J.linearB.y)));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local5:Number;
var _local6:Number;
var _local2:Number = 0;
var _local3:b2Body = m_bodyA;
var _local4:b2Body = m_bodyB;
if (m_revolute1){
_local5 = m_revolute1.GetJointAngle();
} else {
_local5 = m_prismatic1.GetJointTranslation();
};
if (m_revolute2){
_local6 = m_revolute2.GetJointAngle();
} else {
_local6 = m_prismatic2.GetJointTranslation();
};
var _local7:Number = (m_constant - (_local5 + (m_ratio * _local6)));
var _local8:Number = (-(m_mass) * _local7);
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + ((_local3.m_invMass * _local8) * m_J.linearA.x));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + ((_local3.m_invMass * _local8) * m_J.linearA.y));
_local3.m_sweep.a = (_local3.m_sweep.a + ((_local3.m_invI * _local8) * m_J.angularA));
_local4.m_sweep.c.x = (_local4.m_sweep.c.x + ((_local4.m_invMass * _local8) * m_J.linearB.x));
_local4.m_sweep.c.y = (_local4.m_sweep.c.y + ((_local4.m_invMass * _local8) * m_J.linearB.y));
_local4.m_sweep.a = (_local4.m_sweep.a + ((_local4.m_invI * _local8) * m_J.angularB));
_local3.SynchronizeTransform();
_local4.SynchronizeTransform();
return ((_local2 < b2Settings.b2_linearSlop));
}
override public function GetReactionTorque(_arg1:Number):Number{
var _local2:b2Mat22 = m_bodyB.m_xf.R;
var _local3:Number = (m_localAnchor1.x - m_bodyB.m_sweep.localCenter.x);
var _local4:Number = (m_localAnchor1.y - m_bodyB.m_sweep.localCenter.y);
var _local5:Number = ((_local2.col1.x * _local3) + (_local2.col2.x * _local4));
_local4 = ((_local2.col1.y * _local3) + (_local2.col2.y * _local4));
_local3 = _local5;
var _local6:Number = (m_impulse * m_J.linearB.x);
var _local7:Number = (m_impulse * m_J.linearB.y);
return ((_arg1 * (((m_impulse * m_J.angularB) - (_local3 * _local7)) + (_local4 * _local6))));
}
public function GetRatio():Number{
return (m_ratio);
}
}
}//package Box2D.Dynamics.Joints
Section 63
//b2GearJointDef (Box2D.Dynamics.Joints.b2GearJointDef)
package Box2D.Dynamics.Joints {
public class b2GearJointDef extends b2JointDef {
public var joint1:b2Joint;
public var joint2:b2Joint;
public var ratio:Number;
public function b2GearJointDef(){
type = b2Joint.e_gearJoint;
joint1 = null;
joint2 = null;
ratio = 1;
}
}
}//package Box2D.Dynamics.Joints
Section 64
//b2Jacobian (Box2D.Dynamics.Joints.b2Jacobian)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2Jacobian {
public var angularB:Number;
public var linearA:b2Vec2;
public var linearB:b2Vec2;
public var angularA:Number;
public function b2Jacobian(){
linearA = new b2Vec2();
linearB = new b2Vec2();
super();
}
public function Set(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):void{
linearA.SetV(_arg1);
angularA = _arg2;
linearB.SetV(_arg3);
angularB = _arg4;
}
public function SetZero():void{
linearA.SetZero();
angularA = 0;
linearB.SetZero();
angularB = 0;
}
public function Compute(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):Number{
return ((((((linearA.x * _arg1.x) + (linearA.y * _arg1.y)) + (angularA * _arg2)) + ((linearB.x * _arg3.x) + (linearB.y * _arg3.y))) + (angularB * _arg4)));
}
}
}//package Box2D.Dynamics.Joints
Section 65
//b2Joint (Box2D.Dynamics.Joints.b2Joint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Joint {
b2internal var m_islandFlag:Boolean;
b2internal var m_prev:b2Joint;
b2internal var m_invMassA:Number;
b2internal var m_localCenterA:b2Vec2;
b2internal var m_type:int;
b2internal var m_bodyA:b2Body;
b2internal var m_bodyB:b2Body;
b2internal var m_edgeA:b2JointEdge;
b2internal var m_edgeB:b2JointEdge;
b2internal var m_next:b2Joint;
private var m_userData;
b2internal var m_invMassB:Number;
b2internal var m_localCenterB:b2Vec2;
b2internal var m_invIB:Number;
b2internal var m_collideConnected:Boolean;
b2internal var m_invIA:Number;
b2internal static const e_prismaticJoint:int = 2;
b2internal static const e_weldJoint:int = 8;
b2internal static const e_equalLimits:int = 3;
b2internal static const e_frictionJoint:int = 9;
b2internal static const e_lineJoint:int = 7;
b2internal static const e_gearJoint:int = 6;
b2internal static const e_atUpperLimit:int = 2;
b2internal static const e_atLowerLimit:int = 1;
b2internal static const e_revoluteJoint:int = 1;
b2internal static const e_inactiveLimit:int = 0;
b2internal static const e_pulleyJoint:int = 4;
b2internal static const e_unknownJoint:int = 0;
b2internal static const e_distanceJoint:int = 3;
b2internal static const e_mouseJoint:int = 5;
public function b2Joint(_arg1:b2JointDef){
m_edgeA = new b2JointEdge();
m_edgeB = new b2JointEdge();
m_localCenterA = new b2Vec2();
m_localCenterB = new b2Vec2();
super();
b2Settings.b2Assert(!((_arg1.bodyA == _arg1.bodyB)));
m_type = _arg1.type;
m_prev = null;
m_next = null;
m_bodyA = _arg1.bodyA;
m_bodyB = _arg1.bodyB;
m_collideConnected = _arg1.collideConnected;
m_islandFlag = false;
m_userData = _arg1.userData;
}
b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
}
public function GetBodyB():b2Body{
return (m_bodyB);
}
public function GetNext():b2Joint{
return (m_next);
}
public function GetAnchorA():b2Vec2{
return (null);
}
public function GetType():int{
return (m_type);
}
public function GetAnchorB():b2Vec2{
return (null);
}
public function GetBodyA():b2Body{
return (m_bodyA);
}
public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
public function GetUserData(){
return (m_userData);
}
public function GetReactionForce(_arg1:Number):b2Vec2{
return (null);
}
b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
return (false);
}
public function IsActive():Boolean{
return (((m_bodyA.IsActive()) && (m_bodyB.IsActive())));
}
public function SetUserData(_arg1):void{
m_userData = _arg1;
}
b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
}
b2internal function FinalizeVelocityConstraints():void{
}
b2internal static function Destroy(_arg1:b2Joint, _arg2):void{
}
b2internal static function Create(_arg1:b2JointDef, _arg2):b2Joint{
var _local3:b2Joint;
switch (_arg1.type){
case e_distanceJoint:
_local3 = new b2DistanceJoint((_arg1 as b2DistanceJointDef));
break;
case e_mouseJoint:
_local3 = new b2MouseJoint((_arg1 as b2MouseJointDef));
break;
case e_prismaticJoint:
_local3 = new b2PrismaticJoint((_arg1 as b2PrismaticJointDef));
break;
case e_revoluteJoint:
_local3 = new b2RevoluteJoint((_arg1 as b2RevoluteJointDef));
break;
case e_pulleyJoint:
_local3 = new b2PulleyJoint((_arg1 as b2PulleyJointDef));
break;
case e_gearJoint:
_local3 = new b2GearJoint((_arg1 as b2GearJointDef));
break;
case e_lineJoint:
_local3 = new b2LineJoint((_arg1 as b2LineJointDef));
break;
case e_weldJoint:
_local3 = new b2WeldJoint((_arg1 as b2WeldJointDef));
break;
case e_frictionJoint:
_local3 = new b2FrictionJoint((_arg1 as b2FrictionJointDef));
break;
default:
break;
};
return (_local3);
}
}
}//package Box2D.Dynamics.Joints
Section 66
//b2JointDef (Box2D.Dynamics.Joints.b2JointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointDef {
public var bodyB:b2Body;
public var type:int;
public var userData;
public var collideConnected:Boolean;
public var bodyA:b2Body;
public function b2JointDef(){
type = b2Joint.e_unknownJoint;
userData = null;
bodyA = null;
bodyB = null;
collideConnected = false;
}
}
}//package Box2D.Dynamics.Joints
Section 67
//b2JointEdge (Box2D.Dynamics.Joints.b2JointEdge)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointEdge {
public var other:b2Body;
public var next:b2JointEdge;
public var prev:b2JointEdge;
public var joint:b2Joint;
}
}//package Box2D.Dynamics.Joints
Section 68
//b2LineJoint (Box2D.Dynamics.Joints.b2LineJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2LineJoint extends b2Joint {
private var m_a1:Number;
private var m_a2:Number;
private var m_perp:b2Vec2;
private var m_lowerTranslation:Number;
b2internal var m_localXAxis1:b2Vec2;
private var m_impulse:b2Vec2;
private var m_enableLimit:Boolean;
private var m_maxMotorForce:Number;
private var m_localYAxis1:b2Vec2;
private var m_s2:Number;
private var m_axis:b2Vec2;
private var m_motorMass:Number;
private var m_s1:Number;
private var m_upperTranslation:Number;
b2internal var m_localAnchor1:b2Vec2;
b2internal var m_localAnchor2:b2Vec2;
private var m_limitState:int;
private var m_motorImpulse:Number;
private var m_motorSpeed:Number;
private var m_enableMotor:Boolean;
private var m_K:b2Mat22;
public function b2LineJoint(_arg1:b2LineJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_localXAxis1 = new b2Vec2();
m_localYAxis1 = new b2Vec2();
m_axis = new b2Vec2();
m_perp = new b2Vec2();
m_K = new b2Mat22();
m_impulse = new b2Vec2();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchorA);
m_localAnchor2.SetV(_arg1.localAnchorB);
m_localXAxis1.SetV(_arg1.localAxisA);
m_localYAxis1.x = -(m_localXAxis1.y);
m_localYAxis1.y = m_localXAxis1.x;
m_impulse.SetZero();
m_motorMass = 0;
m_motorImpulse = 0;
m_lowerTranslation = _arg1.lowerTranslation;
m_upperTranslation = _arg1.upperTranslation;
m_maxMotorForce = _arg1.maxMotorForce;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
m_limitState = e_inactiveLimit;
m_axis.SetZero();
m_perp.SetZero();
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:b2Vec2;
var _local19:b2Vec2;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
var _local4:b2Vec2 = _local2.m_linearVelocity;
var _local5:Number = _local2.m_angularVelocity;
var _local6:b2Vec2 = _local3.m_linearVelocity;
var _local7:Number = _local3.m_angularVelocity;
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local13 = ((((m_axis.x * (_local6.x - _local4.x)) + (m_axis.y * (_local6.y - _local4.y))) + (m_a2 * _local7)) - (m_a1 * _local5));
_local14 = (m_motorMass * (m_motorSpeed - _local13));
_local15 = m_motorImpulse;
_local16 = (_arg1.dt * m_maxMotorForce);
m_motorImpulse = b2Math.Clamp((m_motorImpulse + _local14), -(_local16), _local16);
_local14 = (m_motorImpulse - _local15);
_local8 = (_local14 * m_axis.x);
_local9 = (_local14 * m_axis.y);
_local10 = (_local14 * m_a1);
_local11 = (_local14 * m_a2);
_local4.x = (_local4.x - (m_invMassA * _local8));
_local4.y = (_local4.y - (m_invMassA * _local9));
_local5 = (_local5 - (m_invIA * _local10));
_local6.x = (_local6.x + (m_invMassB * _local8));
_local6.y = (_local6.y + (m_invMassB * _local9));
_local7 = (_local7 + (m_invIB * _local11));
};
var _local12:Number = ((((m_perp.x * (_local6.x - _local4.x)) + (m_perp.y * (_local6.y - _local4.y))) + (m_s2 * _local7)) - (m_s1 * _local5));
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local17 = ((((m_axis.x * (_local6.x - _local4.x)) + (m_axis.y * (_local6.y - _local4.y))) + (m_a2 * _local7)) - (m_a1 * _local5));
_local18 = m_impulse.Copy();
_local19 = m_K.Solve(new b2Vec2(), -(_local12), -(_local17));
m_impulse.Add(_local19);
if (m_limitState == e_atLowerLimit){
m_impulse.y = b2Math.Max(m_impulse.y, 0);
} else {
if (m_limitState == e_atUpperLimit){
m_impulse.y = b2Math.Min(m_impulse.y, 0);
};
};
_local20 = (-(_local12) - ((m_impulse.y - _local18.y) * m_K.col2.x));
if (m_K.col1.x != 0){
_local21 = ((_local20 / m_K.col1.x) + _local18.x);
} else {
_local21 = _local18.x;
};
m_impulse.x = _local21;
_local19.x = (m_impulse.x - _local18.x);
_local19.y = (m_impulse.y - _local18.y);
_local8 = ((_local19.x * m_perp.x) + (_local19.y * m_axis.x));
_local9 = ((_local19.x * m_perp.y) + (_local19.y * m_axis.y));
_local10 = ((_local19.x * m_s1) + (_local19.y * m_a1));
_local11 = ((_local19.x * m_s2) + (_local19.y * m_a2));
_local4.x = (_local4.x - (m_invMassA * _local8));
_local4.y = (_local4.y - (m_invMassA * _local9));
_local5 = (_local5 - (m_invIA * _local10));
_local6.x = (_local6.x + (m_invMassB * _local8));
_local6.y = (_local6.y + (m_invMassB * _local9));
_local7 = (_local7 + (m_invIB * _local11));
} else {
if (m_K.col1.x != 0){
_local22 = (-(_local12) / m_K.col1.x);
} else {
_local22 = 0;
};
m_impulse.x = (m_impulse.x + _local22);
_local8 = (_local22 * m_perp.x);
_local9 = (_local22 * m_perp.y);
_local10 = (_local22 * m_s1);
_local11 = (_local22 * m_s2);
_local4.x = (_local4.x - (m_invMassA * _local8));
_local4.y = (_local4.y - (m_invMassA * _local9));
_local5 = (_local5 - (m_invIA * _local10));
_local6.x = (_local6.x + (m_invMassB * _local8));
_local6.y = (_local6.y + (m_invMassB * _local9));
_local7 = (_local7 + (m_invIB * _local11));
};
_local2.m_linearVelocity.SetV(_local4);
_local2.m_angularVelocity = _local5;
_local3.m_linearVelocity.SetV(_local6);
_local3.m_angularVelocity = _local7;
}
public function GetUpperLimit():Number{
return (m_upperTranslation);
}
public function GetLowerLimit():Number{
return (m_lowerTranslation);
}
public function EnableMotor(_arg1:Boolean):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_enableMotor = _arg1;
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
public function GetJointTranslation():Number{
var _local3:b2Mat22;
var _local1:b2Body = m_bodyA;
var _local2:b2Body = m_bodyB;
var _local4:b2Vec2 = _local1.GetWorldPoint(m_localAnchor1);
var _local5:b2Vec2 = _local2.GetWorldPoint(m_localAnchor2);
var _local6:Number = (_local5.x - _local4.x);
var _local7:Number = (_local5.y - _local4.y);
var _local8:b2Vec2 = _local1.GetWorldVector(m_localXAxis1);
var _local9:Number = ((_local8.x * _local6) + (_local8.y * _local7));
return (_local9);
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2((_arg1 * ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.y) * m_axis.x))), (_arg1 * ((m_impulse.x * m_perp.y) + ((m_motorImpulse + m_impulse.y) * m_axis.y)))));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local2:Number;
var _local3:Number;
var _local10:b2Mat22;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local4:b2Body = m_bodyA;
var _local5:b2Body = m_bodyB;
var _local6:b2Vec2 = _local4.m_sweep.c;
var _local7:Number = _local4.m_sweep.a;
var _local8:b2Vec2 = _local5.m_sweep.c;
var _local9:Number = _local5.m_sweep.a;
var _local16:Number = 0;
var _local17:Number = 0;
var _local18:Boolean;
var _local19:Number = 0;
var _local20:b2Mat22 = b2Mat22.FromAngle(_local7);
var _local21:b2Mat22 = b2Mat22.FromAngle(_local9);
_local10 = _local20;
var _local22:Number = (m_localAnchor1.x - m_localCenterA.x);
var _local23:Number = (m_localAnchor1.y - m_localCenterA.y);
_local11 = ((_local10.col1.x * _local22) + (_local10.col2.x * _local23));
_local23 = ((_local10.col1.y * _local22) + (_local10.col2.y * _local23));
_local22 = _local11;
_local10 = _local21;
var _local24:Number = (m_localAnchor2.x - m_localCenterB.x);
var _local25:Number = (m_localAnchor2.y - m_localCenterB.y);
_local11 = ((_local10.col1.x * _local24) + (_local10.col2.x * _local25));
_local25 = ((_local10.col1.y * _local24) + (_local10.col2.y * _local25));
_local24 = _local11;
var _local26:Number = (((_local8.x + _local24) - _local6.x) - _local22);
var _local27:Number = (((_local8.y + _local25) - _local6.y) - _local23);
if (m_enableLimit){
m_axis = b2Math.MulMV(_local20, m_localXAxis1);
m_a1 = (((_local26 + _local22) * m_axis.y) - ((_local27 + _local23) * m_axis.x));
m_a2 = ((_local24 * m_axis.y) - (_local25 * m_axis.x));
_local34 = ((m_axis.x * _local26) + (m_axis.y * _local27));
if (b2Math.Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
_local19 = b2Math.Clamp(_local34, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local16 = b2Math.Abs(_local34);
_local18 = true;
} else {
if (_local34 <= m_lowerTranslation){
_local19 = b2Math.Clamp(((_local34 - m_lowerTranslation) + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local16 = (m_lowerTranslation - _local34);
_local18 = true;
} else {
if (_local34 >= m_upperTranslation){
_local19 = b2Math.Clamp(((_local34 - m_upperTranslation) + b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
_local16 = (_local34 - m_upperTranslation);
_local18 = true;
};
};
};
};
m_perp = b2Math.MulMV(_local20, m_localYAxis1);
m_s1 = (((_local26 + _local22) * m_perp.y) - ((_local27 + _local23) * m_perp.x));
m_s2 = ((_local24 * m_perp.y) - (_local25 * m_perp.x));
var _local28:b2Vec2 = new b2Vec2();
var _local29:Number = ((m_perp.x * _local26) + (m_perp.y * _local27));
_local16 = b2Math.Max(_local16, b2Math.Abs(_local29));
_local17 = 0;
if (_local18){
_local12 = m_invMassA;
_local13 = m_invMassB;
_local14 = m_invIA;
_local15 = m_invIB;
m_K.col1.x = (((_local12 + _local13) + ((_local14 * m_s1) * m_s1)) + ((_local15 * m_s2) * m_s2));
m_K.col1.y = (((_local14 * m_s1) * m_a1) + ((_local15 * m_s2) * m_a2));
m_K.col2.x = m_K.col1.y;
m_K.col2.y = (((_local12 + _local13) + ((_local14 * m_a1) * m_a1)) + ((_local15 * m_a2) * m_a2));
m_K.Solve(_local28, -(_local29), -(_local19));
} else {
_local12 = m_invMassA;
_local13 = m_invMassB;
_local14 = m_invIA;
_local15 = m_invIB;
_local35 = (((_local12 + _local13) + ((_local14 * m_s1) * m_s1)) + ((_local15 * m_s2) * m_s2));
if (_local35 != 0){
_local36 = (-(_local29) / _local35);
} else {
_local36 = 0;
};
_local28.x = _local36;
_local28.y = 0;
};
var _local30:Number = ((_local28.x * m_perp.x) + (_local28.y * m_axis.x));
var _local31:Number = ((_local28.x * m_perp.y) + (_local28.y * m_axis.y));
var _local32:Number = ((_local28.x * m_s1) + (_local28.y * m_a1));
var _local33:Number = ((_local28.x * m_s2) + (_local28.y * m_a2));
_local6.x = (_local6.x - (m_invMassA * _local30));
_local6.y = (_local6.y - (m_invMassA * _local31));
_local7 = (_local7 - (m_invIA * _local32));
_local8.x = (_local8.x + (m_invMassB * _local30));
_local8.y = (_local8.y + (m_invMassB * _local31));
_local9 = (_local9 + (m_invIB * _local33));
_local4.m_sweep.a = _local7;
_local5.m_sweep.a = _local9;
_local4.SynchronizeTransform();
_local5.SynchronizeTransform();
return ((((_local16 <= b2Settings.b2_linearSlop)) && ((_local17 <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(_arg1:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_motorSpeed = _arg1;
}
public function GetJointSpeed():Number{
var _local3:b2Mat22;
var _local1:b2Body = m_bodyA;
var _local2:b2Body = m_bodyB;
_local3 = _local1.m_xf.R;
var _local4:Number = (m_localAnchor1.x - _local1.m_sweep.localCenter.x);
var _local5:Number = (m_localAnchor1.y - _local1.m_sweep.localCenter.y);
var _local6:Number = ((_local3.col1.x * _local4) + (_local3.col2.x * _local5));
_local5 = ((_local3.col1.y * _local4) + (_local3.col2.y * _local5));
_local4 = _local6;
_local3 = _local2.m_xf.R;
var _local7:Number = (m_localAnchor2.x - _local2.m_sweep.localCenter.x);
var _local8:Number = (m_localAnchor2.y - _local2.m_sweep.localCenter.y);
_local6 = ((_local3.col1.x * _local7) + (_local3.col2.x * _local8));
_local8 = ((_local3.col1.y * _local7) + (_local3.col2.y * _local8));
_local7 = _local6;
var _local9:Number = (_local1.m_sweep.c.x + _local4);
var _local10:Number = (_local1.m_sweep.c.y + _local5);
var _local11:Number = (_local2.m_sweep.c.x + _local7);
var _local12:Number = (_local2.m_sweep.c.y + _local8);
var _local13:Number = (_local11 - _local9);
var _local14:Number = (_local12 - _local10);
var _local15:b2Vec2 = _local1.GetWorldVector(m_localXAxis1);
var _local16:b2Vec2 = _local1.m_linearVelocity;
var _local17:b2Vec2 = _local2.m_linearVelocity;
var _local18:Number = _local1.m_angularVelocity;
var _local19:Number = _local2.m_angularVelocity;
var _local20:Number = (((_local13 * (-(_local18) * _local15.y)) + (_local14 * (_local18 * _local15.x))) + ((_local15.x * (((_local17.x + (-(_local19) * _local8)) - _local16.x) - (-(_local18) * _local5))) + (_local15.y * (((_local17.y + (_local19 * _local7)) - _local16.y) - (_local18 * _local4)))));
return (_local20);
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local5:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
m_localCenterA.SetV(_local2.GetLocalCenter());
m_localCenterB.SetV(_local3.GetLocalCenter());
var _local6:b2Transform = _local2.GetTransform();
var _local7:b2Transform = _local3.GetTransform();
_local4 = _local2.m_xf.R;
var _local8:Number = (m_localAnchor1.x - m_localCenterA.x);
var _local9:Number = (m_localAnchor1.y - m_localCenterA.y);
_local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local5;
_local4 = _local3.m_xf.R;
var _local10:Number = (m_localAnchor2.x - m_localCenterB.x);
var _local11:Number = (m_localAnchor2.y - m_localCenterB.y);
_local5 = ((_local4.col1.x * _local10) + (_local4.col2.x * _local11));
_local11 = ((_local4.col1.y * _local10) + (_local4.col2.y * _local11));
_local10 = _local5;
var _local12:Number = (((_local3.m_sweep.c.x + _local10) - _local2.m_sweep.c.x) - _local8);
var _local13:Number = (((_local3.m_sweep.c.y + _local11) - _local2.m_sweep.c.y) - _local9);
m_invMassA = _local2.m_invMass;
m_invMassB = _local3.m_invMass;
m_invIA = _local2.m_invI;
m_invIB = _local3.m_invI;
m_axis.SetV(b2Math.MulMV(_local6.R, m_localXAxis1));
m_a1 = (((_local12 + _local8) * m_axis.y) - ((_local13 + _local9) * m_axis.x));
m_a2 = ((_local10 * m_axis.y) - (_local11 * m_axis.x));
m_motorMass = (((m_invMassA + m_invMassB) + ((m_invIA * m_a1) * m_a1)) + ((m_invIB * m_a2) * m_a2));
m_motorMass = ((m_motorMass > Number.MIN_VALUE)) ? (1 / m_motorMass) : 0;
m_perp.SetV(b2Math.MulMV(_local6.R, m_localYAxis1));
m_s1 = (((_local12 + _local8) * m_perp.y) - ((_local13 + _local9) * m_perp.x));
m_s2 = ((_local10 * m_perp.y) - (_local11 * m_perp.x));
var _local14:Number = m_invMassA;
var _local15:Number = m_invMassB;
var _local16:Number = m_invIA;
var _local17:Number = m_invIB;
m_K.col1.x = (((_local14 + _local15) + ((_local16 * m_s1) * m_s1)) + ((_local17 * m_s2) * m_s2));
m_K.col1.y = (((_local16 * m_s1) * m_a1) + ((_local17 * m_s2) * m_a2));
m_K.col2.x = m_K.col1.y;
m_K.col2.y = (((_local14 + _local15) + ((_local16 * m_a1) * m_a1)) + ((_local17 * m_a2) * m_a2));
if (m_enableLimit){
_local18 = ((m_axis.x * _local12) + (m_axis.y * _local13));
if (b2Math.Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
m_limitState = e_equalLimits;
} else {
if (_local18 <= m_lowerTranslation){
if (m_limitState != e_atLowerLimit){
m_limitState = e_atLowerLimit;
m_impulse.y = 0;
};
} else {
if (_local18 >= m_upperTranslation){
if (m_limitState != e_atUpperLimit){
m_limitState = e_atUpperLimit;
m_impulse.y = 0;
};
} else {
m_limitState = e_inactiveLimit;
m_impulse.y = 0;
};
};
};
} else {
m_limitState = e_inactiveLimit;
};
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (_arg1.warmStarting){
m_impulse.x = (m_impulse.x * _arg1.dtRatio);
m_impulse.y = (m_impulse.y * _arg1.dtRatio);
m_motorImpulse = (m_motorImpulse * _arg1.dtRatio);
_local19 = ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.y) * m_axis.x));
_local20 = ((m_impulse.x * m_perp.y) + ((m_motorImpulse + m_impulse.y) * m_axis.y));
_local21 = ((m_impulse.x * m_s1) + ((m_motorImpulse + m_impulse.y) * m_a1));
_local22 = ((m_impulse.x * m_s2) + ((m_motorImpulse + m_impulse.y) * m_a2));
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - (m_invMassA * _local19));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (m_invMassA * _local20));
_local2.m_angularVelocity = (_local2.m_angularVelocity - (m_invIA * _local21));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (m_invMassB * _local19));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (m_invMassB * _local20));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (m_invIB * _local22));
} else {
m_impulse.SetZero();
m_motorImpulse = 0;
};
}
public function GetMotorForce():Number{
return (m_motorImpulse);
}
public function SetMaxMotorForce(_arg1:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_maxMotorForce = _arg1;
}
public function EnableLimit(_arg1:Boolean):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_enableLimit = _arg1;
}
public function GetMaxMotorForce():Number{
return (m_maxMotorForce);
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_impulse.y));
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
return (m_enableMotor);
}
public function SetLimits(_arg1:Number, _arg2:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_lowerTranslation = _arg1;
m_upperTranslation = _arg2;
}
}
}//package Box2D.Dynamics.Joints
Section 69
//b2LineJointDef (Box2D.Dynamics.Joints.b2LineJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class b2LineJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var localAnchorB:b2Vec2;
public var upperTranslation:Number;
public var enableMotor:Boolean;
public var localAxisA:b2Vec2;
public var enableLimit:Boolean;
public var motorSpeed:Number;
public var maxMotorForce:Number;
public var lowerTranslation:Number;
public function b2LineJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
localAxisA = new b2Vec2();
super();
type = b2Joint.e_lineJoint;
localAxisA.Set(1, 0);
enableLimit = false;
lowerTranslation = 0;
upperTranslation = 0;
enableMotor = false;
maxMotorForce = 0;
motorSpeed = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2):void{
bodyA = _arg1;
bodyB = _arg2;
localAnchorA = bodyA.GetLocalPoint(_arg3);
localAnchorB = bodyB.GetLocalPoint(_arg3);
localAxisA = bodyA.GetLocalVector(_arg4);
}
}
}//package Box2D.Dynamics.Joints
Section 70
//b2MouseJoint (Box2D.Dynamics.Joints.b2MouseJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2MouseJoint extends b2Joint {
private var K2:b2Mat22;
private var K1:b2Mat22;
private var m_beta:Number;
private var K:b2Mat22;
private var m_target:b2Vec2;
private var m_gamma:Number;
private var m_mass:b2Mat22;
private var m_impulse:b2Vec2;
private var m_localAnchor:b2Vec2;
private var m_C:b2Vec2;
private var m_maxForce:Number;
private var m_dampingRatio:Number;
private var m_frequencyHz:Number;
public function b2MouseJoint(_arg1:b2MouseJointDef){
var _local2:Number;
var _local4:b2Mat22;
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
m_localAnchor = new b2Vec2();
m_target = new b2Vec2();
m_impulse = new b2Vec2();
m_mass = new b2Mat22();
m_C = new b2Vec2();
super(_arg1);
m_target.SetV(_arg1.target);
_local2 = (m_target.x - m_bodyB.m_xf.position.x);
var _local3:Number = (m_target.y - m_bodyB.m_xf.position.y);
_local4 = m_bodyB.m_xf.R;
m_localAnchor.x = ((_local2 * _local4.col1.x) + (_local3 * _local4.col1.y));
m_localAnchor.y = ((_local2 * _local4.col2.x) + (_local3 * _local4.col2.y));
m_maxForce = _arg1.maxForce;
m_impulse.SetZero();
m_frequencyHz = _arg1.frequencyHz;
m_dampingRatio = _arg1.dampingRatio;
m_beta = 0;
m_gamma = 0;
}
public function SetFrequency(_arg1:Number):void{
m_frequencyHz = _arg1;
}
public function SetTarget(_arg1:b2Vec2):void{
if (m_bodyB.IsAwake() == false){
m_bodyB.SetAwake(true);
};
m_target = _arg1;
}
public function GetFrequency():Number{
return (m_frequencyHz);
}
public function SetMaxForce(_arg1:Number):void{
m_maxForce = _arg1;
}
public function SetDampingRatio(_arg1:Number):void{
m_dampingRatio = _arg1;
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local7:b2Mat22;
var _local11:Number;
var _local12:Number;
var _local2:b2Body = m_bodyB;
var _local3:Number = _local2.GetMass();
var _local4:Number = ((2 * Math.PI) * m_frequencyHz);
var _local5:Number = (((2 * _local3) * m_dampingRatio) * _local4);
var _local6:Number = ((_local3 * _local4) * _local4);
m_gamma = (_arg1.dt * (_local5 + (_arg1.dt * _local6)));
m_gamma = ((m_gamma)!=0) ? (1 / m_gamma) : 0;
m_beta = ((_arg1.dt * _local6) * m_gamma);
_local7 = _local2.m_xf.R;
var _local8:Number = (m_localAnchor.x - _local2.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor.y - _local2.m_sweep.localCenter.y);
var _local10:Number = ((_local7.col1.x * _local8) + (_local7.col2.x * _local9));
_local9 = ((_local7.col1.y * _local8) + (_local7.col2.y * _local9));
_local8 = _local10;
_local11 = _local2.m_invMass;
_local12 = _local2.m_invI;
K1.col1.x = _local11;
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = _local11;
K2.col1.x = ((_local12 * _local9) * _local9);
K2.col2.x = ((-(_local12) * _local8) * _local9);
K2.col1.y = ((-(_local12) * _local8) * _local9);
K2.col2.y = ((_local12 * _local8) * _local8);
K.SetM(K1);
K.AddM(K2);
K.col1.x = (K.col1.x + m_gamma);
K.col2.y = (K.col2.y + m_gamma);
K.GetInverse(m_mass);
m_C.x = ((_local2.m_sweep.c.x + _local8) - m_target.x);
m_C.y = ((_local2.m_sweep.c.y + _local9) - m_target.y);
_local2.m_angularVelocity = (_local2.m_angularVelocity * 0.98);
m_impulse.x = (m_impulse.x * _arg1.dtRatio);
m_impulse.y = (m_impulse.y * _arg1.dtRatio);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local11 * m_impulse.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local11 * m_impulse.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local12 * ((_local8 * m_impulse.y) - (_local9 * m_impulse.x))));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor));
}
override public function GetAnchorA():b2Vec2{
return (m_target);
}
public function GetTarget():b2Vec2{
return (m_target);
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2((_arg1 * m_impulse.x), (_arg1 * m_impulse.y)));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
return (true);
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local2:b2Body = m_bodyB;
_local3 = _local2.m_xf.R;
var _local6:Number = (m_localAnchor.x - _local2.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchor.y - _local2.m_sweep.localCenter.y);
_local4 = ((_local3.col1.x * _local6) + (_local3.col2.x * _local7));
_local7 = ((_local3.col1.y * _local6) + (_local3.col2.y * _local7));
_local6 = _local4;
var _local8:Number = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local7));
var _local9:Number = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local6));
_local3 = m_mass;
_local4 = ((_local8 + (m_beta * m_C.x)) + (m_gamma * m_impulse.x));
_local5 = ((_local9 + (m_beta * m_C.y)) + (m_gamma * m_impulse.y));
var _local10:Number = -(((_local3.col1.x * _local4) + (_local3.col2.x * _local5)));
var _local11:Number = -(((_local3.col1.y * _local4) + (_local3.col2.y * _local5)));
var _local12:Number = m_impulse.x;
var _local13:Number = m_impulse.y;
m_impulse.x = (m_impulse.x + _local10);
m_impulse.y = (m_impulse.y + _local11);
var _local14:Number = (_arg1.dt * m_maxForce);
if (m_impulse.LengthSquared() > (_local14 * _local14)){
m_impulse.Multiply((_local14 / m_impulse.Length()));
};
_local10 = (m_impulse.x - _local12);
_local11 = (m_impulse.y - _local13);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local10));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local11));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local6 * _local11) - (_local7 * _local10))));
}
public function GetMaxForce():Number{
return (m_maxForce);
}
public function GetDampingRatio():Number{
return (m_dampingRatio);
}
}
}//package Box2D.Dynamics.Joints
Section 71
//b2MouseJointDef (Box2D.Dynamics.Joints.b2MouseJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2MouseJointDef extends b2JointDef {
public var target:b2Vec2;
public var maxForce:Number;
public var dampingRatio:Number;
public var frequencyHz:Number;
public function b2MouseJointDef(){
target = new b2Vec2();
super();
type = b2Joint.e_mouseJoint;
maxForce = 0;
frequencyHz = 5;
dampingRatio = 0.7;
}
}
}//package Box2D.Dynamics.Joints
Section 72
//b2PrismaticJoint (Box2D.Dynamics.Joints.b2PrismaticJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PrismaticJoint extends b2Joint {
private var m_a1:Number;
private var m_a2:Number;
private var m_perp:b2Vec2;
private var m_lowerTranslation:Number;
b2internal var m_localXAxis1:b2Vec2;
private var m_refAngle:Number;
private var m_impulse:b2Vec3;
private var m_enableLimit:Boolean;
private var m_maxMotorForce:Number;
private var m_localYAxis1:b2Vec2;
private var m_s2:Number;
private var m_axis:b2Vec2;
private var m_motorMass:Number;
private var m_s1:Number;
private var m_upperTranslation:Number;
b2internal var m_localAnchor1:b2Vec2;
b2internal var m_localAnchor2:b2Vec2;
private var m_limitState:int;
private var m_motorImpulse:Number;
private var m_motorSpeed:Number;
private var m_enableMotor:Boolean;
private var m_K:b2Mat33;
public function b2PrismaticJoint(_arg1:b2PrismaticJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_localXAxis1 = new b2Vec2();
m_localYAxis1 = new b2Vec2();
m_axis = new b2Vec2();
m_perp = new b2Vec2();
m_K = new b2Mat33();
m_impulse = new b2Vec3();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchorA);
m_localAnchor2.SetV(_arg1.localAnchorB);
m_localXAxis1.SetV(_arg1.localAxisA);
m_localYAxis1.x = -(m_localXAxis1.y);
m_localYAxis1.y = m_localXAxis1.x;
m_refAngle = _arg1.referenceAngle;
m_impulse.SetZero();
m_motorMass = 0;
m_motorImpulse = 0;
m_lowerTranslation = _arg1.lowerTranslation;
m_upperTranslation = _arg1.upperTranslation;
m_maxMotorForce = _arg1.maxMotorForce;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
m_limitState = e_inactiveLimit;
m_axis.SetZero();
m_perp.SetZero();
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:b2Vec3;
var _local20:b2Vec3;
var _local21:Number;
var _local22:Number;
var _local23:b2Vec2;
var _local24:b2Vec2;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
var _local4:b2Vec2 = _local2.m_linearVelocity;
var _local5:Number = _local2.m_angularVelocity;
var _local6:b2Vec2 = _local3.m_linearVelocity;
var _local7:Number = _local3.m_angularVelocity;
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local14 = ((((m_axis.x * (_local6.x - _local4.x)) + (m_axis.y * (_local6.y - _local4.y))) + (m_a2 * _local7)) - (m_a1 * _local5));
_local15 = (m_motorMass * (m_motorSpeed - _local14));
_local16 = m_motorImpulse;
_local17 = (_arg1.dt * m_maxMotorForce);
m_motorImpulse = b2Math.Clamp((m_motorImpulse + _local15), -(_local17), _local17);
_local15 = (m_motorImpulse - _local16);
_local8 = (_local15 * m_axis.x);
_local9 = (_local15 * m_axis.y);
_local10 = (_local15 * m_a1);
_local11 = (_local15 * m_a2);
_local4.x = (_local4.x - (m_invMassA * _local8));
_local4.y = (_local4.y - (m_invMassA * _local9));
_local5 = (_local5 - (m_invIA * _local10));
_local6.x = (_local6.x + (m_invMassB * _local8));
_local6.y = (_local6.y + (m_invMassB * _local9));
_local7 = (_local7 + (m_invIB * _local11));
};
var _local12:Number = ((((m_perp.x * (_local6.x - _local4.x)) + (m_perp.y * (_local6.y - _local4.y))) + (m_s2 * _local7)) - (m_s1 * _local5));
var _local13:Number = (_local7 - _local5);
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local18 = ((((m_axis.x * (_local6.x - _local4.x)) + (m_axis.y * (_local6.y - _local4.y))) + (m_a2 * _local7)) - (m_a1 * _local5));
_local19 = m_impulse.Copy();
_local20 = m_K.Solve33(new b2Vec3(), -(_local12), -(_local13), -(_local18));
m_impulse.Add(_local20);
if (m_limitState == e_atLowerLimit){
m_impulse.z = b2Math.Max(m_impulse.z, 0);
} else {
if (m_limitState == e_atUpperLimit){
m_impulse.z = b2Math.Min(m_impulse.z, 0);
};
};
_local21 = (-(_local12) - ((m_impulse.z - _local19.z) * m_K.col3.x));
_local22 = (-(_local13) - ((m_impulse.z - _local19.z) * m_K.col3.y));
_local23 = m_K.Solve22(new b2Vec2(), _local21, _local22);
m_K.Solve22(new b2Vec2(), _local21, _local22).x = (_local23.x + _local19.x);
_local23.y = (_local23.y + _local19.y);
m_impulse.x = _local23.x;
m_impulse.y = _local23.y;
_local20.x = (m_impulse.x - _local19.x);
_local20.y = (m_impulse.y - _local19.y);
_local20.z = (m_impulse.z - _local19.z);
_local8 = ((_local20.x * m_perp.x) + (_local20.z * m_axis.x));
_local9 = ((_local20.x * m_perp.y) + (_local20.z * m_axis.y));
_local10 = (((_local20.x * m_s1) + _local20.y) + (_local20.z * m_a1));
_local11 = (((_local20.x * m_s2) + _local20.y) + (_local20.z * m_a2));
_local4.x = (_local4.x - (m_invMassA * _local8));
_local4.y = (_local4.y - (m_invMassA * _local9));
_local5 = (_local5 - (m_invIA * _local10));
_local6.x = (_local6.x + (m_invMassB * _local8));
_local6.y = (_local6.y + (m_invMassB * _local9));
_local7 = (_local7 + (m_invIB * _local11));
} else {
_local24 = m_K.Solve22(new b2Vec2(), -(_local12), -(_local13));
m_impulse.x = (m_impulse.x + _local24.x);
m_impulse.y = (m_impulse.y + _local24.y);
_local8 = (_local24.x * m_perp.x);
_local9 = (_local24.x * m_perp.y);
_local10 = ((_local24.x * m_s1) + _local24.y);
_local11 = ((_local24.x * m_s2) + _local24.y);
_local4.x = (_local4.x - (m_invMassA * _local8));
_local4.y = (_local4.y - (m_invMassA * _local9));
_local5 = (_local5 - (m_invIA * _local10));
_local6.x = (_local6.x + (m_invMassB * _local8));
_local6.y = (_local6.y + (m_invMassB * _local9));
_local7 = (_local7 + (m_invIB * _local11));
};
_local2.m_linearVelocity.SetV(_local4);
_local2.m_angularVelocity = _local5;
_local3.m_linearVelocity.SetV(_local6);
_local3.m_angularVelocity = _local7;
}
public function GetUpperLimit():Number{
return (m_upperTranslation);
}
public function GetLowerLimit():Number{
return (m_lowerTranslation);
}
public function EnableMotor(_arg1:Boolean):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_enableMotor = _arg1;
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
public function GetJointTranslation():Number{
var _local3:b2Mat22;
var _local1:b2Body = m_bodyA;
var _local2:b2Body = m_bodyB;
var _local4:b2Vec2 = _local1.GetWorldPoint(m_localAnchor1);
var _local5:b2Vec2 = _local2.GetWorldPoint(m_localAnchor2);
var _local6:Number = (_local5.x - _local4.x);
var _local7:Number = (_local5.y - _local4.y);
var _local8:b2Vec2 = _local1.GetWorldVector(m_localXAxis1);
var _local9:Number = ((_local8.x * _local6) + (_local8.y * _local7));
return (_local9);
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2((_arg1 * ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.z) * m_axis.x))), (_arg1 * ((m_impulse.x * m_perp.y) + ((m_motorImpulse + m_impulse.z) * m_axis.y)))));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local2:Number;
var _local3:Number;
var _local10:b2Mat22;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:b2Vec2;
var _local4:b2Body = m_bodyA;
var _local5:b2Body = m_bodyB;
var _local6:b2Vec2 = _local4.m_sweep.c;
var _local7:Number = _local4.m_sweep.a;
var _local8:b2Vec2 = _local5.m_sweep.c;
var _local9:Number = _local5.m_sweep.a;
var _local16:Number = 0;
var _local17:Number = 0;
var _local18:Boolean;
var _local19:Number = 0;
var _local20:b2Mat22 = b2Mat22.FromAngle(_local7);
var _local21:b2Mat22 = b2Mat22.FromAngle(_local9);
_local10 = _local20;
var _local22:Number = (m_localAnchor1.x - m_localCenterA.x);
var _local23:Number = (m_localAnchor1.y - m_localCenterA.y);
_local11 = ((_local10.col1.x * _local22) + (_local10.col2.x * _local23));
_local23 = ((_local10.col1.y * _local22) + (_local10.col2.y * _local23));
_local22 = _local11;
_local10 = _local21;
var _local24:Number = (m_localAnchor2.x - m_localCenterB.x);
var _local25:Number = (m_localAnchor2.y - m_localCenterB.y);
_local11 = ((_local10.col1.x * _local24) + (_local10.col2.x * _local25));
_local25 = ((_local10.col1.y * _local24) + (_local10.col2.y * _local25));
_local24 = _local11;
var _local26:Number = (((_local8.x + _local24) - _local6.x) - _local22);
var _local27:Number = (((_local8.y + _local25) - _local6.y) - _local23);
if (m_enableLimit){
m_axis = b2Math.MulMV(_local20, m_localXAxis1);
m_a1 = (((_local26 + _local22) * m_axis.y) - ((_local27 + _local23) * m_axis.x));
m_a2 = ((_local24 * m_axis.y) - (_local25 * m_axis.x));
_local35 = ((m_axis.x * _local26) + (m_axis.y * _local27));
if (b2Math.Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
_local19 = b2Math.Clamp(_local35, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local16 = b2Math.Abs(_local35);
_local18 = true;
} else {
if (_local35 <= m_lowerTranslation){
_local19 = b2Math.Clamp(((_local35 - m_lowerTranslation) + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local16 = (m_lowerTranslation - _local35);
_local18 = true;
} else {
if (_local35 >= m_upperTranslation){
_local19 = b2Math.Clamp(((_local35 - m_upperTranslation) + b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
_local16 = (_local35 - m_upperTranslation);
_local18 = true;
};
};
};
};
m_perp = b2Math.MulMV(_local20, m_localYAxis1);
m_s1 = (((_local26 + _local22) * m_perp.y) - ((_local27 + _local23) * m_perp.x));
m_s2 = ((_local24 * m_perp.y) - (_local25 * m_perp.x));
var _local28:b2Vec3 = new b2Vec3();
var _local29:Number = ((m_perp.x * _local26) + (m_perp.y * _local27));
var _local30:Number = ((_local9 - _local7) - m_refAngle);
_local16 = b2Math.Max(_local16, b2Math.Abs(_local29));
_local17 = b2Math.Abs(_local30);
if (_local18){
_local12 = m_invMassA;
_local13 = m_invMassB;
_local14 = m_invIA;
_local15 = m_invIB;
m_K.col1.x = (((_local12 + _local13) + ((_local14 * m_s1) * m_s1)) + ((_local15 * m_s2) * m_s2));
m_K.col1.y = ((_local14 * m_s1) + (_local15 * m_s2));
m_K.col1.z = (((_local14 * m_s1) * m_a1) + ((_local15 * m_s2) * m_a2));
m_K.col2.x = m_K.col1.y;
m_K.col2.y = (_local14 + _local15);
m_K.col2.z = ((_local14 * m_a1) + (_local15 * m_a2));
m_K.col3.x = m_K.col1.z;
m_K.col3.y = m_K.col2.z;
m_K.col3.z = (((_local12 + _local13) + ((_local14 * m_a1) * m_a1)) + ((_local15 * m_a2) * m_a2));
m_K.Solve33(_local28, -(_local29), -(_local30), -(_local19));
} else {
_local12 = m_invMassA;
_local13 = m_invMassB;
_local14 = m_invIA;
_local15 = m_invIB;
_local36 = (((_local12 + _local13) + ((_local14 * m_s1) * m_s1)) + ((_local15 * m_s2) * m_s2));
_local37 = ((_local14 * m_s1) + (_local15 * m_s2));
_local38 = (_local14 + _local15);
m_K.col1.Set(_local36, _local37, 0);
m_K.col2.Set(_local37, _local38, 0);
_local39 = m_K.Solve22(new b2Vec2(), -(_local29), -(_local30));
_local28.x = _local39.x;
_local28.y = _local39.y;
_local28.z = 0;
};
var _local31:Number = ((_local28.x * m_perp.x) + (_local28.z * m_axis.x));
var _local32:Number = ((_local28.x * m_perp.y) + (_local28.z * m_axis.y));
var _local33:Number = (((_local28.x * m_s1) + _local28.y) + (_local28.z * m_a1));
var _local34:Number = (((_local28.x * m_s2) + _local28.y) + (_local28.z * m_a2));
_local6.x = (_local6.x - (m_invMassA * _local31));
_local6.y = (_local6.y - (m_invMassA * _local32));
_local7 = (_local7 - (m_invIA * _local33));
_local8.x = (_local8.x + (m_invMassB * _local31));
_local8.y = (_local8.y + (m_invMassB * _local32));
_local9 = (_local9 + (m_invIB * _local34));
_local4.m_sweep.a = _local7;
_local5.m_sweep.a = _local9;
_local4.SynchronizeTransform();
_local5.SynchronizeTransform();
return ((((_local16 <= b2Settings.b2_linearSlop)) && ((_local17 <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(_arg1:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_motorSpeed = _arg1;
}
public function GetJointSpeed():Number{
var _local3:b2Mat22;
var _local1:b2Body = m_bodyA;
var _local2:b2Body = m_bodyB;
_local3 = _local1.m_xf.R;
var _local4:Number = (m_localAnchor1.x - _local1.m_sweep.localCenter.x);
var _local5:Number = (m_localAnchor1.y - _local1.m_sweep.localCenter.y);
var _local6:Number = ((_local3.col1.x * _local4) + (_local3.col2.x * _local5));
_local5 = ((_local3.col1.y * _local4) + (_local3.col2.y * _local5));
_local4 = _local6;
_local3 = _local2.m_xf.R;
var _local7:Number = (m_localAnchor2.x - _local2.m_sweep.localCenter.x);
var _local8:Number = (m_localAnchor2.y - _local2.m_sweep.localCenter.y);
_local6 = ((_local3.col1.x * _local7) + (_local3.col2.x * _local8));
_local8 = ((_local3.col1.y * _local7) + (_local3.col2.y * _local8));
_local7 = _local6;
var _local9:Number = (_local1.m_sweep.c.x + _local4);
var _local10:Number = (_local1.m_sweep.c.y + _local5);
var _local11:Number = (_local2.m_sweep.c.x + _local7);
var _local12:Number = (_local2.m_sweep.c.y + _local8);
var _local13:Number = (_local11 - _local9);
var _local14:Number = (_local12 - _local10);
var _local15:b2Vec2 = _local1.GetWorldVector(m_localXAxis1);
var _local16:b2Vec2 = _local1.m_linearVelocity;
var _local17:b2Vec2 = _local2.m_linearVelocity;
var _local18:Number = _local1.m_angularVelocity;
var _local19:Number = _local2.m_angularVelocity;
var _local20:Number = (((_local13 * (-(_local18) * _local15.y)) + (_local14 * (_local18 * _local15.x))) + ((_local15.x * (((_local17.x + (-(_local19) * _local8)) - _local16.x) - (-(_local18) * _local5))) + (_local15.y * (((_local17.y + (_local19 * _local7)) - _local16.y) - (_local18 * _local4)))));
return (_local20);
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local5:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
m_localCenterA.SetV(_local2.GetLocalCenter());
m_localCenterB.SetV(_local3.GetLocalCenter());
var _local6:b2Transform = _local2.GetTransform();
var _local7:b2Transform = _local3.GetTransform();
_local4 = _local2.m_xf.R;
var _local8:Number = (m_localAnchor1.x - m_localCenterA.x);
var _local9:Number = (m_localAnchor1.y - m_localCenterA.y);
_local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local5;
_local4 = _local3.m_xf.R;
var _local10:Number = (m_localAnchor2.x - m_localCenterB.x);
var _local11:Number = (m_localAnchor2.y - m_localCenterB.y);
_local5 = ((_local4.col1.x * _local10) + (_local4.col2.x * _local11));
_local11 = ((_local4.col1.y * _local10) + (_local4.col2.y * _local11));
_local10 = _local5;
var _local12:Number = (((_local3.m_sweep.c.x + _local10) - _local2.m_sweep.c.x) - _local8);
var _local13:Number = (((_local3.m_sweep.c.y + _local11) - _local2.m_sweep.c.y) - _local9);
m_invMassA = _local2.m_invMass;
m_invMassB = _local3.m_invMass;
m_invIA = _local2.m_invI;
m_invIB = _local3.m_invI;
m_axis.SetV(b2Math.MulMV(_local6.R, m_localXAxis1));
m_a1 = (((_local12 + _local8) * m_axis.y) - ((_local13 + _local9) * m_axis.x));
m_a2 = ((_local10 * m_axis.y) - (_local11 * m_axis.x));
m_motorMass = (((m_invMassA + m_invMassB) + ((m_invIA * m_a1) * m_a1)) + ((m_invIB * m_a2) * m_a2));
if (m_motorMass > Number.MIN_VALUE){
m_motorMass = (1 / m_motorMass);
};
m_perp.SetV(b2Math.MulMV(_local6.R, m_localYAxis1));
m_s1 = (((_local12 + _local8) * m_perp.y) - ((_local13 + _local9) * m_perp.x));
m_s2 = ((_local10 * m_perp.y) - (_local11 * m_perp.x));
var _local14:Number = m_invMassA;
var _local15:Number = m_invMassB;
var _local16:Number = m_invIA;
var _local17:Number = m_invIB;
m_K.col1.x = (((_local14 + _local15) + ((_local16 * m_s1) * m_s1)) + ((_local17 * m_s2) * m_s2));
m_K.col1.y = ((_local16 * m_s1) + (_local17 * m_s2));
m_K.col1.z = (((_local16 * m_s1) * m_a1) + ((_local17 * m_s2) * m_a2));
m_K.col2.x = m_K.col1.y;
m_K.col2.y = (_local16 + _local17);
m_K.col2.z = ((_local16 * m_a1) + (_local17 * m_a2));
m_K.col3.x = m_K.col1.z;
m_K.col3.y = m_K.col2.z;
m_K.col3.z = (((_local14 + _local15) + ((_local16 * m_a1) * m_a1)) + ((_local17 * m_a2) * m_a2));
if (m_enableLimit){
_local18 = ((m_axis.x * _local12) + (m_axis.y * _local13));
if (b2Math.Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
m_limitState = e_equalLimits;
} else {
if (_local18 <= m_lowerTranslation){
if (m_limitState != e_atLowerLimit){
m_limitState = e_atLowerLimit;
m_impulse.z = 0;
};
} else {
if (_local18 >= m_upperTranslation){
if (m_limitState != e_atUpperLimit){
m_limitState = e_atUpperLimit;
m_impulse.z = 0;
};
} else {
m_limitState = e_inactiveLimit;
m_impulse.z = 0;
};
};
};
} else {
m_limitState = e_inactiveLimit;
};
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (_arg1.warmStarting){
m_impulse.x = (m_impulse.x * _arg1.dtRatio);
m_impulse.y = (m_impulse.y * _arg1.dtRatio);
m_motorImpulse = (m_motorImpulse * _arg1.dtRatio);
_local19 = ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.z) * m_axis.x));
_local20 = ((m_impulse.x * m_perp.y) + ((m_motorImpulse + m_impulse.z) * m_axis.y));
_local21 = (((m_impulse.x * m_s1) + m_impulse.y) + ((m_motorImpulse + m_impulse.z) * m_a1));
_local22 = (((m_impulse.x * m_s2) + m_impulse.y) + ((m_motorImpulse + m_impulse.z) * m_a2));
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - (m_invMassA * _local19));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (m_invMassA * _local20));
_local2.m_angularVelocity = (_local2.m_angularVelocity - (m_invIA * _local21));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (m_invMassB * _local19));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (m_invMassB * _local20));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (m_invIB * _local22));
} else {
m_impulse.SetZero();
m_motorImpulse = 0;
};
}
public function GetMotorForce():Number{
return (m_motorImpulse);
}
public function SetMaxMotorForce(_arg1:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_maxMotorForce = _arg1;
}
public function EnableLimit(_arg1:Boolean):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_enableLimit = _arg1;
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_impulse.y));
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
return (m_enableMotor);
}
public function SetLimits(_arg1:Number, _arg2:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_lowerTranslation = _arg1;
m_upperTranslation = _arg2;
}
}
}//package Box2D.Dynamics.Joints
Section 73
//b2PrismaticJointDef (Box2D.Dynamics.Joints.b2PrismaticJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class b2PrismaticJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var motorSpeed:Number;
public var referenceAngle:Number;
public var localAnchorB:b2Vec2;
public var upperTranslation:Number;
public var lowerTranslation:Number;
public var localAxisA:b2Vec2;
public var enableLimit:Boolean;
public var enableMotor:Boolean;
public var maxMotorForce:Number;
public function b2PrismaticJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
localAxisA = new b2Vec2();
super();
type = b2Joint.e_prismaticJoint;
localAxisA.Set(1, 0);
referenceAngle = 0;
enableLimit = false;
lowerTranslation = 0;
upperTranslation = 0;
enableMotor = false;
maxMotorForce = 0;
motorSpeed = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2):void{
bodyA = _arg1;
bodyB = _arg2;
localAnchorA = bodyA.GetLocalPoint(_arg3);
localAnchorB = bodyB.GetLocalPoint(_arg3);
localAxisA = bodyA.GetLocalVector(_arg4);
referenceAngle = (bodyB.GetAngle() - bodyA.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 74
//b2PulleyJoint (Box2D.Dynamics.Joints.b2PulleyJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PulleyJoint extends b2Joint {
private var m_limitState1:int;
private var m_limitState2:int;
private var m_ground:b2Body;
private var m_maxLength2:Number;
private var m_maxLength1:Number;
private var m_impulse:Number;
private var m_constant:Number;
private var m_state:int;
private var m_ratio:Number;
private var m_groundAnchor1:b2Vec2;
private var m_groundAnchor2:b2Vec2;
private var m_localAnchor1:b2Vec2;
private var m_localAnchor2:b2Vec2;
private var m_limitMass1:Number;
private var m_limitMass2:Number;
private var m_pulleyMass:Number;
private var m_limitImpulse1:Number;
private var m_limitImpulse2:Number;
private var m_u1:b2Vec2;
private var m_u2:b2Vec2;
b2internal static const b2_minPulleyLength:Number = 2;
public function b2PulleyJoint(_arg1:b2PulleyJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_u1 = new b2Vec2();
m_u2 = new b2Vec2();
super(_arg1);
m_ground = m_bodyA.m_world.m_groundBody;
m_groundAnchor1.x = (_arg1.groundAnchorA.x - m_ground.m_xf.position.x);
m_groundAnchor1.y = (_arg1.groundAnchorA.y - m_ground.m_xf.position.y);
m_groundAnchor2.x = (_arg1.groundAnchorB.x - m_ground.m_xf.position.x);
m_groundAnchor2.y = (_arg1.groundAnchorB.y - m_ground.m_xf.position.y);
m_localAnchor1.SetV(_arg1.localAnchorA);
m_localAnchor2.SetV(_arg1.localAnchorB);
m_ratio = _arg1.ratio;
m_constant = (_arg1.lengthA + (m_ratio * _arg1.lengthB));
m_maxLength1 = b2Math.Min(_arg1.maxLengthA, (m_constant - (m_ratio * b2_minPulleyLength)));
m_maxLength2 = b2Math.Min(_arg1.maxLengthB, ((m_constant - b2_minPulleyLength) / m_ratio));
m_impulse = 0;
m_limitImpulse1 = 0;
m_limitImpulse2 = 0;
}
public function GetGroundAnchorB():b2Vec2{
var _local1:b2Vec2 = m_ground.m_xf.position.Copy();
_local1.Add(m_groundAnchor2);
return (_local1);
}
public function GetGroundAnchorA():b2Vec2{
var _local1:b2Vec2 = m_ground.m_xf.position.Copy();
_local1.Add(m_groundAnchor1);
return (_local1);
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2(((_arg1 * m_impulse) * m_u2.x), ((_arg1 * m_impulse) * m_u2.y)));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local4:b2Mat22;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
var _local5:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var _local6:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var _local7:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var _local8:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
var _local24:Number = 0;
if (m_state == e_atUpperLimit){
_local4 = _local2.m_xf.R;
_local9 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local10 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local23 = ((_local4.col1.x * _local9) + (_local4.col2.x * _local10));
_local10 = ((_local4.col1.y * _local9) + (_local4.col2.y * _local10));
_local9 = _local23;
_local4 = _local3.m_xf.R;
_local11 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local12 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local23 = ((_local4.col1.x * _local11) + (_local4.col2.x * _local12));
_local12 = ((_local4.col1.y * _local11) + (_local4.col2.y * _local12));
_local11 = _local23;
_local13 = (_local2.m_sweep.c.x + _local9);
_local14 = (_local2.m_sweep.c.y + _local10);
_local15 = (_local3.m_sweep.c.x + _local11);
_local16 = (_local3.m_sweep.c.y + _local12);
m_u1.Set((_local13 - _local5), (_local14 - _local6));
m_u2.Set((_local15 - _local7), (_local16 - _local8));
_local17 = m_u1.Length();
_local18 = m_u2.Length();
if (_local17 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / _local17));
} else {
m_u1.SetZero();
};
if (_local18 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / _local18));
} else {
m_u2.SetZero();
};
_local19 = ((m_constant - _local17) - (m_ratio * _local18));
_local24 = b2Math.Max(_local24, -(_local19));
_local19 = b2Math.Clamp((_local19 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local20 = (-(m_pulleyMass) * _local19);
_local13 = (-(_local20) * m_u1.x);
_local14 = (-(_local20) * m_u1.y);
_local15 = ((-(m_ratio) * _local20) * m_u2.x);
_local16 = ((-(m_ratio) * _local20) * m_u2.y);
_local2.m_sweep.c.x = (_local2.m_sweep.c.x + (_local2.m_invMass * _local13));
_local2.m_sweep.c.y = (_local2.m_sweep.c.y + (_local2.m_invMass * _local14));
_local2.m_sweep.a = (_local2.m_sweep.a + (_local2.m_invI * ((_local9 * _local14) - (_local10 * _local13))));
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + (_local3.m_invMass * _local15));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + (_local3.m_invMass * _local16));
_local3.m_sweep.a = (_local3.m_sweep.a + (_local3.m_invI * ((_local11 * _local16) - (_local12 * _local15))));
_local2.SynchronizeTransform();
_local3.SynchronizeTransform();
};
if (m_limitState1 == e_atUpperLimit){
_local4 = _local2.m_xf.R;
_local9 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local10 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local23 = ((_local4.col1.x * _local9) + (_local4.col2.x * _local10));
_local10 = ((_local4.col1.y * _local9) + (_local4.col2.y * _local10));
_local9 = _local23;
_local13 = (_local2.m_sweep.c.x + _local9);
_local14 = (_local2.m_sweep.c.y + _local10);
m_u1.Set((_local13 - _local5), (_local14 - _local6));
_local17 = m_u1.Length();
if (_local17 > b2Settings.b2_linearSlop){
m_u1.x = (m_u1.x * (1 / _local17));
m_u1.y = (m_u1.y * (1 / _local17));
} else {
m_u1.SetZero();
};
_local19 = (m_maxLength1 - _local17);
_local24 = b2Math.Max(_local24, -(_local19));
_local19 = b2Math.Clamp((_local19 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local20 = (-(m_limitMass1) * _local19);
_local13 = (-(_local20) * m_u1.x);
_local14 = (-(_local20) * m_u1.y);
_local2.m_sweep.c.x = (_local2.m_sweep.c.x + (_local2.m_invMass * _local13));
_local2.m_sweep.c.y = (_local2.m_sweep.c.y + (_local2.m_invMass * _local14));
_local2.m_sweep.a = (_local2.m_sweep.a + (_local2.m_invI * ((_local9 * _local14) - (_local10 * _local13))));
_local2.SynchronizeTransform();
};
if (m_limitState2 == e_atUpperLimit){
_local4 = _local3.m_xf.R;
_local11 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local12 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local23 = ((_local4.col1.x * _local11) + (_local4.col2.x * _local12));
_local12 = ((_local4.col1.y * _local11) + (_local4.col2.y * _local12));
_local11 = _local23;
_local15 = (_local3.m_sweep.c.x + _local11);
_local16 = (_local3.m_sweep.c.y + _local12);
m_u2.Set((_local15 - _local7), (_local16 - _local8));
_local18 = m_u2.Length();
if (_local18 > b2Settings.b2_linearSlop){
m_u2.x = (m_u2.x * (1 / _local18));
m_u2.y = (m_u2.y * (1 / _local18));
} else {
m_u2.SetZero();
};
_local19 = (m_maxLength2 - _local18);
_local24 = b2Math.Max(_local24, -(_local19));
_local19 = b2Math.Clamp((_local19 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local20 = (-(m_limitMass2) * _local19);
_local15 = (-(_local20) * m_u2.x);
_local16 = (-(_local20) * m_u2.y);
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + (_local3.m_invMass * _local15));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + (_local3.m_invMass * _local16));
_local3.m_sweep.a = (_local3.m_sweep.a + (_local3.m_invI * ((_local11 * _local16) - (_local12 * _local15))));
_local3.SynchronizeTransform();
};
return ((_local24 < b2Settings.b2_linearSlop));
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
var _local6:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
_local2 = m_bodyA;
_local3 = m_bodyB;
_local4 = _local2.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local6 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
var _local7:Number = ((_local4.col1.x * _local5) + (_local4.col2.x * _local6));
_local6 = ((_local4.col1.y * _local5) + (_local4.col2.y * _local6));
_local5 = _local7;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local7 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local7;
var _local10:Number = (_local2.m_sweep.c.x + _local5);
var _local11:Number = (_local2.m_sweep.c.y + _local6);
var _local12:Number = (_local3.m_sweep.c.x + _local8);
var _local13:Number = (_local3.m_sweep.c.y + _local9);
var _local14:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var _local15:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var _local16:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var _local17:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
m_u1.Set((_local10 - _local14), (_local11 - _local15));
m_u2.Set((_local12 - _local16), (_local13 - _local17));
var _local18:Number = m_u1.Length();
var _local19:Number = m_u2.Length();
if (_local18 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / _local18));
} else {
m_u1.SetZero();
};
if (_local19 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / _local19));
} else {
m_u2.SetZero();
};
var _local20:Number = ((m_constant - _local18) - (m_ratio * _local19));
if (_local20 > 0){
m_state = e_inactiveLimit;
m_impulse = 0;
} else {
m_state = e_atUpperLimit;
};
if (_local18 < m_maxLength1){
m_limitState1 = e_inactiveLimit;
m_limitImpulse1 = 0;
} else {
m_limitState1 = e_atUpperLimit;
};
if (_local19 < m_maxLength2){
m_limitState2 = e_inactiveLimit;
m_limitImpulse2 = 0;
} else {
m_limitState2 = e_atUpperLimit;
};
var _local21:Number = ((_local5 * m_u1.y) - (_local6 * m_u1.x));
var _local22:Number = ((_local8 * m_u2.y) - (_local9 * m_u2.x));
m_limitMass1 = (_local2.m_invMass + ((_local2.m_invI * _local21) * _local21));
m_limitMass2 = (_local3.m_invMass + ((_local3.m_invI * _local22) * _local22));
m_pulleyMass = (m_limitMass1 + ((m_ratio * m_ratio) * m_limitMass2));
m_limitMass1 = (1 / m_limitMass1);
m_limitMass2 = (1 / m_limitMass2);
m_pulleyMass = (1 / m_pulleyMass);
if (_arg1.warmStarting){
m_impulse = (m_impulse * _arg1.dtRatio);
m_limitImpulse1 = (m_limitImpulse1 * _arg1.dtRatio);
m_limitImpulse2 = (m_limitImpulse2 * _arg1.dtRatio);
_local23 = ((-(m_impulse) - m_limitImpulse1) * m_u1.x);
_local24 = ((-(m_impulse) - m_limitImpulse1) * m_u1.y);
_local25 = (((-(m_ratio) * m_impulse) - m_limitImpulse2) * m_u2.x);
_local26 = (((-(m_ratio) * m_impulse) - m_limitImpulse2) * m_u2.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local23));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local24));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local24) - (_local6 * _local23))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local25));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local26));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local26) - (_local9 * _local25))));
} else {
m_impulse = 0;
m_limitImpulse1 = 0;
m_limitImpulse2 = 0;
};
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
public function GetRatio():Number{
return (m_ratio);
}
public function GetLength2():Number{
var _local1:b2Vec2 = m_bodyB.GetWorldPoint(m_localAnchor2);
var _local2:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var _local3:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
var _local4:Number = (_local1.x - _local2);
var _local5:Number = (_local1.y - _local3);
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
_local4 = _local2.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
var _local6:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
var _local7:Number = ((_local4.col1.x * _local5) + (_local4.col2.x * _local6));
_local6 = ((_local4.col1.y * _local5) + (_local4.col2.y * _local6));
_local5 = _local7;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local7 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local7;
if (m_state == e_atUpperLimit){
_local10 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6));
_local11 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5));
_local12 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local9));
_local13 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local8));
_local18 = (-(((m_u1.x * _local10) + (m_u1.y * _local11))) - (m_ratio * ((m_u2.x * _local12) + (m_u2.y * _local13))));
_local19 = (m_pulleyMass * -(_local18));
_local20 = m_impulse;
m_impulse = b2Math.Max(0, (m_impulse + _local19));
_local19 = (m_impulse - _local20);
_local14 = (-(_local19) * m_u1.x);
_local15 = (-(_local19) * m_u1.y);
_local16 = ((-(m_ratio) * _local19) * m_u2.x);
_local17 = ((-(m_ratio) * _local19) * m_u2.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local14));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local15));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local15) - (_local6 * _local14))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local16));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local17));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local17) - (_local9 * _local16))));
};
if (m_limitState1 == e_atUpperLimit){
_local10 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6));
_local11 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5));
_local18 = -(((m_u1.x * _local10) + (m_u1.y * _local11)));
_local19 = (-(m_limitMass1) * _local18);
_local20 = m_limitImpulse1;
m_limitImpulse1 = b2Math.Max(0, (m_limitImpulse1 + _local19));
_local19 = (m_limitImpulse1 - _local20);
_local14 = (-(_local19) * m_u1.x);
_local15 = (-(_local19) * m_u1.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local14));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local15));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local15) - (_local6 * _local14))));
};
if (m_limitState2 == e_atUpperLimit){
_local12 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local9));
_local13 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local8));
_local18 = -(((m_u2.x * _local12) + (m_u2.y * _local13)));
_local19 = (-(m_limitMass2) * _local18);
_local20 = m_limitImpulse2;
m_limitImpulse2 = b2Math.Max(0, (m_limitImpulse2 + _local19));
_local19 = (m_limitImpulse2 - _local20);
_local16 = (-(_local19) * m_u2.x);
_local17 = (-(_local19) * m_u2.y);
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local16));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local17));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local17) - (_local9 * _local16))));
};
}
public function GetLength1():Number{
var _local1:b2Vec2 = m_bodyA.GetWorldPoint(m_localAnchor1);
var _local2:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var _local3:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var _local4:Number = (_local1.x - _local2);
var _local5:Number = (_local1.y - _local3);
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
}
}//package Box2D.Dynamics.Joints
Section 75
//b2PulleyJointDef (Box2D.Dynamics.Joints.b2PulleyJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class b2PulleyJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var groundAnchorA:b2Vec2;
public var groundAnchorB:b2Vec2;
public var localAnchorB:b2Vec2;
public var ratio:Number;
public var maxLengthA:Number;
public var lengthA:Number;
public var lengthB:Number;
public var maxLengthB:Number;
public function b2PulleyJointDef(){
groundAnchorA = new b2Vec2();
groundAnchorB = new b2Vec2();
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_pulleyJoint;
groundAnchorA.Set(-1, 1);
groundAnchorB.Set(1, 1);
localAnchorA.Set(-1, 0);
localAnchorB.Set(1, 0);
lengthA = 0;
maxLengthA = 0;
lengthB = 0;
maxLengthB = 0;
ratio = 1;
collideConnected = true;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2, _arg5:b2Vec2, _arg6:b2Vec2, _arg7:Number):void{
bodyA = _arg1;
bodyB = _arg2;
groundAnchorA.SetV(_arg3);
groundAnchorB.SetV(_arg4);
localAnchorA = bodyA.GetLocalPoint(_arg5);
localAnchorB = bodyB.GetLocalPoint(_arg6);
var _local8:Number = (_arg5.x - _arg3.x);
var _local9:Number = (_arg5.y - _arg3.y);
lengthA = Math.sqrt(((_local8 * _local8) + (_local9 * _local9)));
var _local10:Number = (_arg6.x - _arg4.x);
var _local11:Number = (_arg6.y - _arg4.y);
lengthB = Math.sqrt(((_local10 * _local10) + (_local11 * _local11)));
ratio = _arg7;
var _local12:Number = (lengthA + (ratio * lengthB));
maxLengthA = (_local12 - (ratio * b2PulleyJoint.b2_minPulleyLength));
maxLengthB = ((_local12 - b2PulleyJoint.b2_minPulleyLength) / ratio);
}
}
}//package Box2D.Dynamics.Joints
Section 76
//b2RevoluteJoint (Box2D.Dynamics.Joints.b2RevoluteJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2RevoluteJoint extends b2Joint {
private var m_mass:b2Mat33;
private var m_impulse:b2Vec3;
private var m_enableLimit:Boolean;
private var m_limitState:int;
private var m_motorMass:Number;
private var reduced:b2Vec2;
b2internal var m_localAnchor1:b2Vec2;
b2internal var m_localAnchor2:b2Vec2;
private var K1:b2Mat22;
private var K2:b2Mat22;
private var K3:b2Mat22;
private var K:b2Mat22;
private var m_motorImpulse:Number;
private var impulse2:b2Vec2;
private var impulse3:b2Vec3;
private var m_enableMotor:Boolean;
private var m_referenceAngle:Number;
private var m_upperAngle:Number;
private var m_motorSpeed:Number;
private var m_lowerAngle:Number;
private var m_maxMotorTorque:Number;
private static var tImpulse:b2Vec2 = new b2Vec2();
public function b2RevoluteJoint(_arg1:b2RevoluteJointDef){
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
K3 = new b2Mat22();
impulse3 = new b2Vec3();
impulse2 = new b2Vec2();
reduced = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_impulse = new b2Vec3();
m_mass = new b2Mat33();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchorA);
m_localAnchor2.SetV(_arg1.localAnchorB);
m_referenceAngle = _arg1.referenceAngle;
m_impulse.SetZero();
m_motorImpulse = 0;
m_lowerAngle = _arg1.lowerAngle;
m_upperAngle = _arg1.upperAngle;
m_maxMotorTorque = _arg1.maxMotorTorque;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
m_limitState = e_inactiveLimit;
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local2:b2Body = m_bodyA;
var _local3:b2Body = m_bodyB;
var _local11:b2Vec2 = _local2.m_linearVelocity;
var _local12:Number = _local2.m_angularVelocity;
var _local13:b2Vec2 = _local3.m_linearVelocity;
var _local14:Number = _local3.m_angularVelocity;
var _local15:Number = _local2.m_invMass;
var _local16:Number = _local3.m_invMass;
var _local17:Number = _local2.m_invI;
var _local18:Number = _local3.m_invI;
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local19 = ((_local14 - _local12) - m_motorSpeed);
_local20 = (m_motorMass * -(_local19));
_local21 = m_motorImpulse;
_local22 = (_arg1.dt * m_maxMotorTorque);
m_motorImpulse = b2Math.Clamp((m_motorImpulse + _local20), -(_local22), _local22);
_local20 = (m_motorImpulse - _local21);
_local12 = (_local12 - (_local17 * _local20));
_local14 = (_local14 + (_local18 * _local20));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local4 = _local2.m_xf.R;
_local7 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local8 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local7) + (_local4.col2.x * _local8));
_local8 = ((_local4.col1.y * _local7) + (_local4.col2.y * _local8));
_local7 = _local5;
_local4 = _local3.m_xf.R;
_local9 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local10 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local9) + (_local4.col2.x * _local10));
_local10 = ((_local4.col1.y * _local9) + (_local4.col2.y * _local10));
_local9 = _local5;
_local23 = (((_local13.x + (-(_local14) * _local10)) - _local11.x) - (-(_local12) * _local8));
_local24 = (((_local13.y + (_local14 * _local9)) - _local11.y) - (_local12 * _local7));
_local25 = (_local14 - _local12);
m_mass.Solve33(impulse3, -(_local23), -(_local24), -(_local25));
if (m_limitState == e_equalLimits){
m_impulse.Add(impulse3);
} else {
if (m_limitState == e_atLowerLimit){
_local6 = (m_impulse.z + impulse3.z);
if (_local6 < 0){
m_mass.Solve22(reduced, -(_local23), -(_local24));
impulse3.x = reduced.x;
impulse3.y = reduced.y;
impulse3.z = -(m_impulse.z);
m_impulse.x = (m_impulse.x + reduced.x);
m_impulse.y = (m_impulse.y + reduced.y);
m_impulse.z = 0;
};
} else {
if (m_limitState == e_atUpperLimit){
_local6 = (m_impulse.z + impulse3.z);
if (_local6 > 0){
m_mass.Solve22(reduced, -(_local23), -(_local24));
impulse3.x = reduced.x;
impulse3.y = reduced.y;
impulse3.z = -(m_impulse.z);
m_impulse.x = (m_impulse.x + reduced.x);
m_impulse.y = (m_impulse.y + reduced.y);
m_impulse.z = 0;
};
};
};
};
_local11.x = (_local11.x - (_local15 * impulse3.x));
_local11.y = (_local11.y - (_local15 * impulse3.y));
_local12 = (_local12 - (_local17 * (((_local7 * impulse3.y) - (_local8 * impulse3.x)) + impulse3.z)));
_local13.x = (_local13.x + (_local16 * impulse3.x));
_local13.y = (_local13.y + (_local16 * impulse3.y));
_local14 = (_local14 + (_local18 * (((_local9 * impulse3.y) - (_local10 * impulse3.x)) + impulse3.z)));
} else {
_local4 = _local2.m_xf.R;
_local7 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local8 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local7) + (_local4.col2.x * _local8));
_local8 = ((_local4.col1.y * _local7) + (_local4.col2.y * _local8));
_local7 = _local5;
_local4 = _local3.m_xf.R;
_local9 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
_local10 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local9) + (_local4.col2.x * _local10));
_local10 = ((_local4.col1.y * _local9) + (_local4.col2.y * _local10));
_local9 = _local5;
_local26 = (((_local13.x + (-(_local14) * _local10)) - _local11.x) - (-(_local12) * _local8));
_local27 = (((_local13.y + (_local14 * _local9)) - _local11.y) - (_local12 * _local7));
m_mass.Solve22(impulse2, -(_local26), -(_local27));
m_impulse.x = (m_impulse.x + impulse2.x);
m_impulse.y = (m_impulse.y + impulse2.y);
_local11.x = (_local11.x - (_local15 * impulse2.x));
_local11.y = (_local11.y - (_local15 * impulse2.y));
_local12 = (_local12 - (_local17 * ((_local7 * impulse2.y) - (_local8 * impulse2.x))));
_local13.x = (_local13.x + (_local16 * impulse2.x));
_local13.y = (_local13.y + (_local16 * impulse2.y));
_local14 = (_local14 + (_local18 * ((_local9 * impulse2.y) - (_local10 * impulse2.x))));
};
_local2.m_linearVelocity.SetV(_local11);
_local2.m_angularVelocity = _local12;
_local3.m_linearVelocity.SetV(_local13);
_local3.m_angularVelocity = _local14;
}
public function GetUpperLimit():Number{
return (m_upperAngle);
}
public function GetLowerLimit():Number{
return (m_lowerAngle);
}
public function EnableMotor(_arg1:Boolean):void{
m_enableMotor = _arg1;
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2((_arg1 * m_impulse.x), (_arg1 * m_impulse.y)));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:b2Mat22;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local5:b2Body = m_bodyA;
var _local6:b2Body = m_bodyB;
var _local7:Number = 0;
var _local8:Number = 0;
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local25 = ((_local6.m_sweep.a - _local5.m_sweep.a) - m_referenceAngle);
_local26 = 0;
if (m_limitState == e_equalLimits){
_local3 = b2Math.Clamp((_local25 - m_lowerAngle), -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
_local26 = (-(m_motorMass) * _local3);
_local7 = b2Math.Abs(_local3);
} else {
if (m_limitState == e_atLowerLimit){
_local3 = (_local25 - m_lowerAngle);
_local7 = -(_local3);
_local3 = b2Math.Clamp((_local3 + b2Settings.b2_angularSlop), -(b2Settings.b2_maxAngularCorrection), 0);
_local26 = (-(m_motorMass) * _local3);
} else {
if (m_limitState == e_atUpperLimit){
_local3 = (_local25 - m_upperAngle);
_local7 = _local3;
_local3 = b2Math.Clamp((_local3 - b2Settings.b2_angularSlop), 0, b2Settings.b2_maxAngularCorrection);
_local26 = (-(m_motorMass) * _local3);
};
};
};
_local5.m_sweep.a = (_local5.m_sweep.a - (_local5.m_invI * _local26));
_local6.m_sweep.a = (_local6.m_sweep.a + (_local6.m_invI * _local26));
_local5.SynchronizeTransform();
_local6.SynchronizeTransform();
};
_local4 = _local5.m_xf.R;
var _local12:Number = (m_localAnchor1.x - _local5.m_sweep.localCenter.x);
var _local13:Number = (m_localAnchor1.y - _local5.m_sweep.localCenter.y);
_local9 = ((_local4.col1.x * _local12) + (_local4.col2.x * _local13));
_local13 = ((_local4.col1.y * _local12) + (_local4.col2.y * _local13));
_local12 = _local9;
_local4 = _local6.m_xf.R;
var _local14:Number = (m_localAnchor2.x - _local6.m_sweep.localCenter.x);
var _local15:Number = (m_localAnchor2.y - _local6.m_sweep.localCenter.y);
_local9 = ((_local4.col1.x * _local14) + (_local4.col2.x * _local15));
_local15 = ((_local4.col1.y * _local14) + (_local4.col2.y * _local15));
_local14 = _local9;
var _local16:Number = (((_local6.m_sweep.c.x + _local14) - _local5.m_sweep.c.x) - _local12);
var _local17:Number = (((_local6.m_sweep.c.y + _local15) - _local5.m_sweep.c.y) - _local13);
var _local18:Number = ((_local16 * _local16) + (_local17 * _local17));
var _local19:Number = Math.sqrt(_local18);
_local8 = _local19;
var _local20:Number = _local5.m_invMass;
var _local21:Number = _local6.m_invMass;
var _local22:Number = _local5.m_invI;
var _local23:Number = _local6.m_invI;
var _local24:Number = (10 * b2Settings.b2_linearSlop);
if (_local18 > (_local24 * _local24)){
_local27 = (_local16 / _local19);
_local28 = (_local17 / _local19);
_local29 = (_local20 + _local21);
_local30 = (1 / _local29);
_local10 = (_local30 * -(_local16));
_local11 = (_local30 * -(_local17));
_local31 = 0.5;
_local5.m_sweep.c.x = (_local5.m_sweep.c.x - ((_local31 * _local20) * _local10));
_local5.m_sweep.c.y = (_local5.m_sweep.c.y - ((_local31 * _local20) * _local11));
_local6.m_sweep.c.x = (_local6.m_sweep.c.x + ((_local31 * _local21) * _local10));
_local6.m_sweep.c.y = (_local6.m_sweep.c.y + ((_local31 * _local21) * _local11));
_local16 = (((_local6.m_sweep.c.x + _local14) - _local5.m_sweep.c.x) - _local12);
_local17 = (((_local6.m_sweep.c.y + _local15) - _local5.m_sweep.c.y) - _local13);
};
K1.col1.x = (_local20 + _local21);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (_local20 + _local21);
K2.col1.x = ((_local22 * _local13) * _local13);
K2.col2.x = ((-(_local22) * _local12) * _local13);
K2.col1.y = ((-(_local22) * _local12) * _local13);
K2.col2.y = ((_local22 * _local12) * _local12);
K3.col1.x = ((_local23 * _local15) * _local15);
K3.col2.x = ((-(_local23) * _local14) * _local15);
K3.col1.y = ((-(_local23) * _local14) * _local15);
K3.col2.y = ((_local23 * _local14) * _local14);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Solve(tImpulse, -(_local16), -(_local17));
_local10 = tImpulse.x;
_local11 = tImpulse.y;
_local5.m_sweep.c.x = (_local5.m_sweep.c.x - (_local5.m_invMass * _local10));
_local5.m_sweep.c.y = (_local5.m_sweep.c.y - (_local5.m_invMass * _local11));
_local5.m_sweep.a = (_local5.m_sweep.a - (_local5.m_invI * ((_local12 * _local11) - (_local13 * _local10))));
_local6.m_sweep.c.x = (_local6.m_sweep.c.x + (_local6.m_invMass * _local10));
_local6.m_sweep.c.y = (_local6.m_sweep.c.y + (_local6.m_invMass * _local11));
_local6.m_sweep.a = (_local6.m_sweep.a + (_local6.m_invI * ((_local14 * _local11) - (_local15 * _local10))));
_local5.SynchronizeTransform();
_local6.SynchronizeTransform();
return ((((_local8 <= b2Settings.b2_linearSlop)) && ((_local7 <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(_arg1:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_motorSpeed = _arg1;
}
public function SetMaxMotorTorque(_arg1:Number):void{
m_maxMotorTorque = _arg1;
}
public function GetJointAngle():Number{
return (((m_bodyB.m_sweep.a - m_bodyA.m_sweep.a) - m_referenceAngle));
}
public function GetJointSpeed():Number{
return ((m_bodyB.m_angularVelocity - m_bodyA.m_angularVelocity));
}
public function GetMotorTorque():Number{
return (m_maxMotorTorque);
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
var _local5:Number;
var _local7:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
_local2 = m_bodyA;
_local3 = m_bodyB;
if (((m_enableMotor) || (m_enableLimit))){
};
_local4 = _local2.m_xf.R;
var _local6:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local7 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local6) + (_local4.col2.x * _local7));
_local7 = ((_local4.col1.y * _local6) + (_local4.col2.y * _local7));
_local6 = _local5;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local5;
var _local10:Number = _local2.m_invMass;
var _local11:Number = _local3.m_invMass;
var _local12:Number = _local2.m_invI;
var _local13:Number = _local3.m_invI;
m_mass.col1.x = (((_local10 + _local11) + ((_local7 * _local7) * _local12)) + ((_local9 * _local9) * _local13));
m_mass.col2.x = (((-(_local7) * _local6) * _local12) - ((_local9 * _local8) * _local13));
m_mass.col3.x = ((-(_local7) * _local12) - (_local9 * _local13));
m_mass.col1.y = m_mass.col2.x;
m_mass.col2.y = (((_local10 + _local11) + ((_local6 * _local6) * _local12)) + ((_local8 * _local8) * _local13));
m_mass.col3.y = ((_local6 * _local12) + (_local8 * _local13));
m_mass.col1.z = m_mass.col3.x;
m_mass.col2.z = m_mass.col3.y;
m_mass.col3.z = (_local12 + _local13);
m_motorMass = (1 / (_local12 + _local13));
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (m_enableLimit){
_local14 = ((_local3.m_sweep.a - _local2.m_sweep.a) - m_referenceAngle);
if (b2Math.Abs((m_upperAngle - m_lowerAngle)) < (2 * b2Settings.b2_angularSlop)){
m_limitState = e_equalLimits;
} else {
if (_local14 <= m_lowerAngle){
if (m_limitState != e_atLowerLimit){
m_impulse.z = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (_local14 >= m_upperAngle){
if (m_limitState != e_atUpperLimit){
m_impulse.z = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_impulse.z = 0;
};
};
};
} else {
m_limitState = e_inactiveLimit;
};
if (_arg1.warmStarting){
m_impulse.x = (m_impulse.x * _arg1.dtRatio);
m_impulse.y = (m_impulse.y * _arg1.dtRatio);
m_motorImpulse = (m_motorImpulse * _arg1.dtRatio);
_local15 = m_impulse.x;
_local16 = m_impulse.y;
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - (_local10 * _local15));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (_local10 * _local16));
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local12 * ((((_local6 * _local16) - (_local7 * _local15)) + m_motorImpulse) + m_impulse.z)));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local11 * _local15));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local11 * _local16));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local13 * ((((_local8 * _local16) - (_local9 * _local15)) + m_motorImpulse) + m_impulse.z)));
} else {
m_impulse.SetZero();
m_motorImpulse = 0;
};
}
public function EnableLimit(_arg1:Boolean):void{
m_enableLimit = _arg1;
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_impulse.z));
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
return (m_enableMotor);
}
public function SetLimits(_arg1:Number, _arg2:Number):void{
m_lowerAngle = _arg1;
m_upperAngle = _arg2;
}
}
}//package Box2D.Dynamics.Joints
Section 77
//b2RevoluteJointDef (Box2D.Dynamics.Joints.b2RevoluteJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class b2RevoluteJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var referenceAngle:Number;
public var localAnchorB:b2Vec2;
public var motorSpeed:Number;
public var upperAngle:Number;
public var lowerAngle:Number;
public var enableLimit:Boolean;
public var enableMotor:Boolean;
public var maxMotorTorque:Number;
public function b2RevoluteJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_revoluteJoint;
localAnchorA.Set(0, 0);
localAnchorB.Set(0, 0);
referenceAngle = 0;
lowerAngle = 0;
upperAngle = 0;
maxMotorTorque = 0;
motorSpeed = 0;
enableLimit = false;
enableMotor = false;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2):void{
bodyA = _arg1;
bodyB = _arg2;
localAnchorA = bodyA.GetLocalPoint(_arg3);
localAnchorB = bodyB.GetLocalPoint(_arg3);
referenceAngle = (bodyB.GetAngle() - bodyA.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 78
//b2WeldJoint (Box2D.Dynamics.Joints.b2WeldJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2WeldJoint extends b2Joint {
private var m_impulse:b2Vec3;
private var m_referenceAngle:Number;
private var m_localAnchorA:b2Vec2;
private var m_localAnchorB:b2Vec2;
private var m_mass:b2Mat33;
public function b2WeldJoint(_arg1:b2WeldJointDef){
m_localAnchorA = new b2Vec2();
m_localAnchorB = new b2Vec2();
m_impulse = new b2Vec3();
m_mass = new b2Mat33();
super(_arg1);
m_localAnchorA.SetV(_arg1.localAnchorA);
m_localAnchorB.SetV(_arg1.localAnchorB);
m_referenceAngle = _arg1.referenceAngle;
m_impulse.SetZero();
m_mass = new b2Mat33();
}
override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:Number;
var _local4:b2Body = m_bodyA;
var _local5:b2Body = m_bodyB;
var _local6:b2Vec2 = _local4.m_linearVelocity;
var _local7:Number = _local4.m_angularVelocity;
var _local8:b2Vec2 = _local5.m_linearVelocity;
var _local9:Number = _local5.m_angularVelocity;
var _local10:Number = _local4.m_invMass;
var _local11:Number = _local5.m_invMass;
var _local12:Number = _local4.m_invI;
var _local13:Number = _local5.m_invI;
_local2 = _local4.m_xf.R;
var _local14:Number = (m_localAnchorA.x - _local4.m_sweep.localCenter.x);
var _local15:Number = (m_localAnchorA.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local14) + (_local2.col2.x * _local15));
_local15 = ((_local2.col1.y * _local14) + (_local2.col2.y * _local15));
_local14 = _local3;
_local2 = _local5.m_xf.R;
var _local16:Number = (m_localAnchorB.x - _local5.m_sweep.localCenter.x);
var _local17:Number = (m_localAnchorB.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local16) + (_local2.col2.x * _local17));
_local17 = ((_local2.col1.y * _local16) + (_local2.col2.y * _local17));
_local16 = _local3;
var _local18:Number = (((_local8.x - (_local9 * _local17)) - _local6.x) + (_local7 * _local15));
var _local19:Number = (((_local8.y + (_local9 * _local16)) - _local6.y) - (_local7 * _local14));
var _local20:Number = (_local9 - _local7);
var _local21:b2Vec3 = new b2Vec3();
m_mass.Solve33(_local21, -(_local18), -(_local19), -(_local20));
m_impulse.Add(_local21);
_local6.x = (_local6.x - (_local10 * _local21.x));
_local6.y = (_local6.y - (_local10 * _local21.y));
_local7 = (_local7 - (_local12 * (((_local14 * _local21.y) - (_local15 * _local21.x)) + _local21.z)));
_local8.x = (_local8.x + (_local11 * _local21.x));
_local8.y = (_local8.y + (_local11 * _local21.y));
_local9 = (_local9 + (_local13 * (((_local16 * _local21.y) - (_local17 * _local21.x)) + _local21.z)));
_local4.m_angularVelocity = _local7;
_local5.m_angularVelocity = _local9;
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_impulse.z));
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2((_arg1 * m_impulse.x), (_arg1 * m_impulse.y)));
}
override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{
var _local2:b2Mat22;
var _local3:Number;
var _local4:b2Body = m_bodyA;
var _local5:b2Body = m_bodyB;
_local2 = _local4.m_xf.R;
var _local6:Number = (m_localAnchorA.x - _local4.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchorA.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local6) + (_local2.col2.x * _local7));
_local7 = ((_local2.col1.y * _local6) + (_local2.col2.y * _local7));
_local6 = _local3;
_local2 = _local5.m_xf.R;
var _local8:Number = (m_localAnchorB.x - _local5.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchorB.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local3;
var _local10:Number = _local4.m_invMass;
var _local11:Number = _local5.m_invMass;
var _local12:Number = _local4.m_invI;
var _local13:Number = _local5.m_invI;
var _local14:Number = (((_local5.m_sweep.c.x + _local8) - _local4.m_sweep.c.x) - _local6);
var _local15:Number = (((_local5.m_sweep.c.y + _local9) - _local4.m_sweep.c.y) - _local7);
var _local16:Number = ((_local5.m_sweep.a - _local4.m_sweep.a) - m_referenceAngle);
var _local17:Number = (10 * b2Settings.b2_linearSlop);
var _local18:Number = Math.sqrt(((_local14 * _local14) + (_local15 * _local15)));
var _local19:Number = b2Math.Abs(_local16);
if (_local18 > _local17){
_local12 = (_local12 * 1);
_local13 = (_local13 * 1);
};
m_mass.col1.x = (((_local10 + _local11) + ((_local7 * _local7) * _local12)) + ((_local9 * _local9) * _local13));
m_mass.col2.x = (((-(_local7) * _local6) * _local12) - ((_local9 * _local8) * _local13));
m_mass.col3.x = ((-(_local7) * _local12) - (_local9 * _local13));
m_mass.col1.y = m_mass.col2.x;
m_mass.col2.y = (((_local10 + _local11) + ((_local6 * _local6) * _local12)) + ((_local8 * _local8) * _local13));
m_mass.col3.y = ((_local6 * _local12) + (_local8 * _local13));
m_mass.col1.z = m_mass.col3.x;
m_mass.col2.z = m_mass.col3.y;
m_mass.col3.z = (_local12 + _local13);
var _local20:b2Vec3 = new b2Vec3();
m_mass.Solve33(_local20, -(_local14), -(_local15), -(_local16));
_local4.m_sweep.c.x = (_local4.m_sweep.c.x - (_local10 * _local20.x));
_local4.m_sweep.c.y = (_local4.m_sweep.c.y - (_local10 * _local20.y));
_local4.m_sweep.a = (_local4.m_sweep.a - (_local12 * (((_local6 * _local20.y) - (_local7 * _local20.x)) + _local20.z)));
_local5.m_sweep.c.x = (_local5.m_sweep.c.x + (_local11 * _local20.x));
_local5.m_sweep.c.y = (_local5.m_sweep.c.y + (_local11 * _local20.y));
_local5.m_sweep.a = (_local5.m_sweep.a + (_local13 * (((_local8 * _local20.y) - (_local9 * _local20.x)) + _local20.z)));
_local4.SynchronizeTransform();
_local5.SynchronizeTransform();
return ((((_local18 <= b2Settings.b2_linearSlop)) && ((_local19 <= b2Settings.b2_angularSlop))));
}
override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:Number;
var _local4:b2Body;
var _local5:b2Body;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
_local4 = m_bodyA;
_local5 = m_bodyB;
_local2 = _local4.m_xf.R;
_local6 = (m_localAnchorA.x - _local4.m_sweep.localCenter.x);
_local7 = (m_localAnchorA.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local6) + (_local2.col2.x * _local7));
_local7 = ((_local2.col1.y * _local6) + (_local2.col2.y * _local7));
_local6 = _local3;
_local2 = _local5.m_xf.R;
_local8 = (m_localAnchorB.x - _local5.m_sweep.localCenter.x);
_local9 = (m_localAnchorB.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local3;
_local10 = _local4.m_invMass;
_local11 = _local5.m_invMass;
_local12 = _local4.m_invI;
_local13 = _local5.m_invI;
m_mass.col1.x = (((_local10 + _local11) + ((_local7 * _local7) * _local12)) + ((_local9 * _local9) * _local13));
m_mass.col2.x = (((-(_local7) * _local6) * _local12) - ((_local9 * _local8) * _local13));
m_mass.col3.x = ((-(_local7) * _local12) - (_local9 * _local13));
m_mass.col1.y = m_mass.col2.x;
m_mass.col2.y = (((_local10 + _local11) + ((_local6 * _local6) * _local12)) + ((_local8 * _local8) * _local13));
m_mass.col3.y = ((_local6 * _local12) + (_local8 * _local13));
m_mass.col1.z = m_mass.col3.x;
m_mass.col2.z = m_mass.col3.y;
m_mass.col3.z = (_local12 + _local13);
if (_arg1.warmStarting){
m_impulse.x = (m_impulse.x * _arg1.dtRatio);
m_impulse.y = (m_impulse.y * _arg1.dtRatio);
m_impulse.z = (m_impulse.z * _arg1.dtRatio);
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x - (_local10 * m_impulse.x));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y - (_local10 * m_impulse.y));
_local4.m_angularVelocity = (_local4.m_angularVelocity - (_local12 * (((_local6 * m_impulse.y) - (_local7 * m_impulse.x)) + m_impulse.z)));
_local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + (_local11 * m_impulse.x));
_local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + (_local11 * m_impulse.y));
_local5.m_angularVelocity = (_local5.m_angularVelocity + (_local13 * (((_local8 * m_impulse.y) - (_local9 * m_impulse.x)) + m_impulse.z)));
} else {
m_impulse.SetZero();
};
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchorA));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchorB));
}
}
}//package Box2D.Dynamics.Joints
Section 79
//b2WeldJointDef (Box2D.Dynamics.Joints.b2WeldJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class b2WeldJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var referenceAngle:Number;
public var localAnchorB:b2Vec2;
public function b2WeldJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_weldJoint;
referenceAngle = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2):void{
bodyA = _arg1;
bodyB = _arg2;
localAnchorA.SetV(bodyA.GetLocalPoint(_arg3));
localAnchorB.SetV(bodyB.GetLocalPoint(_arg3));
referenceAngle = (bodyB.GetAngle() - bodyA.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 80
//b2Body (Box2D.Dynamics.b2Body)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Controllers.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2Body {
b2internal var m_xf:b2Transform;
b2internal var m_controllerCount:int;
b2internal var m_contactList:b2ContactEdge;
b2internal var m_invI:Number;
b2internal var m_fixtureCount:int;
b2internal var m_torque:Number;
b2internal var m_angularVelocity:Number;
b2internal var m_flags:uint;
b2internal var m_linearVelocity:b2Vec2;
b2internal var m_world:b2World;
b2internal var m_inertiaScale:Number;
b2internal var m_controllerList:b2ControllerEdge;
b2internal var m_fixtureList:b2Fixture;
b2internal var m_mass:Number;
b2internal var m_next:b2Body;
b2internal var m_force:b2Vec2;
b2internal var m_sweep:b2Sweep;
private var m_userData;
b2internal var m_invMass:Number;
b2internal var m_prev:b2Body;
b2internal var m_linearDamping:Number;
b2internal var m_type:int;
b2internal var m_angularDamping:Number;
b2internal var m_islandIndex:int;
b2internal var m_jointList:b2JointEdge;
b2internal var m_sleepTime:Number;
b2internal var m_I:Number;
b2internal static var e_fixedRotationFlag:uint = 16;
public static var b2_kinematicBody:uint = 1;
b2internal static var e_bulletFlag:uint = 8;
b2internal static var e_activeFlag:uint = 32;
b2internal static var e_allowSleepFlag:uint = 4;
b2internal static var e_awakeFlag:uint = 2;
public static var b2_dynamicBody:uint = 2;
b2internal static var e_islandFlag:uint = 1;
private static var s_xf1:b2Transform = new b2Transform();
public static var b2_staticBody:uint = 0;
public function b2Body(_arg1:b2BodyDef, _arg2:b2World){
m_xf = new b2Transform();
m_sweep = new b2Sweep();
m_linearVelocity = new b2Vec2();
m_force = new b2Vec2();
super();
m_flags = 0;
if (_arg1.bullet){
m_flags = (m_flags | e_bulletFlag);
};
if (_arg1.fixedRotation){
m_flags = (m_flags | e_fixedRotationFlag);
};
if (_arg1.allowSleep){
m_flags = (m_flags | e_allowSleepFlag);
};
if (_arg1.awake){
m_flags = (m_flags | e_awakeFlag);
};
if (_arg1.active){
m_flags = (m_flags | e_activeFlag);
};
m_world = _arg2;
m_xf.position.SetV(_arg1.position);
m_xf.R.Set(_arg1.angle);
m_sweep.localCenter.SetZero();
m_sweep.t0 = 1;
m_sweep.a0 = (m_sweep.a = _arg1.angle);
var _local3:b2Mat22 = m_xf.R;
var _local4:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
m_sweep.c.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
m_jointList = null;
m_controllerList = null;
m_contactList = null;
m_controllerCount = 0;
m_prev = null;
m_next = null;
m_linearVelocity.SetV(_arg1.linearVelocity);
m_angularVelocity = _arg1.angularVelocity;
m_linearDamping = _arg1.linearDamping;
m_angularDamping = _arg1.angularDamping;
m_force.Set(0, 0);
m_torque = 0;
m_sleepTime = 0;
m_type = _arg1.type;
if (m_type == b2_dynamicBody){
m_mass = 1;
m_invMass = 1;
} else {
m_mass = 0;
m_invMass = 0;
};
m_I = 0;
m_invI = 0;
m_inertiaScale = _arg1.inertiaScale;
m_userData = _arg1.userData;
m_fixtureList = null;
m_fixtureCount = 0;
}
public function SetLinearVelocity(_arg1:b2Vec2):void{
if (m_type == b2_staticBody){
return;
};
m_linearVelocity.SetV(_arg1);
}
public function ResetMassData():void{
var _local4:b2MassData;
m_mass = 0;
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_sweep.localCenter.SetZero();
if ((((m_type == b2_staticBody)) || ((m_type == b2_kinematicBody)))){
return;
};
var _local1:b2Vec2 = b2Vec2.Make(0, 0);
var _local2:b2Fixture = m_fixtureList;
while (_local2) {
if (_local2.m_density == 0){
} else {
_local4 = _local2.GetMassData();
m_mass = (m_mass + _local4.mass);
_local1.x = (_local1.x + (_local4.center.x * _local4.mass));
_local1.y = (_local1.y + (_local4.center.y * _local4.mass));
m_I = (m_I + _local4.I);
};
_local2 = _local2.m_next;
};
if (m_mass > 0){
m_invMass = (1 / m_mass);
_local1.x = (_local1.x * m_invMass);
_local1.y = (_local1.y * m_invMass);
} else {
m_mass = 1;
m_invMass = 1;
};
if ((((m_I > 0)) && (((m_flags & e_fixedRotationFlag) == 0)))){
m_I = (m_I - (m_mass * ((_local1.x * _local1.x) + (_local1.y * _local1.y))));
m_I = (m_I * m_inertiaScale);
b2Settings.b2Assert((m_I > 0));
m_invI = (1 / m_I);
} else {
m_I = 0;
m_invI = 0;
};
var _local3:b2Vec2 = m_sweep.c.Copy();
m_sweep.localCenter.SetV(_local1);
m_sweep.c0.SetV(b2Math.MulX(m_xf, m_sweep.localCenter));
m_sweep.c.SetV(m_sweep.c0);
m_linearVelocity.x = (m_linearVelocity.x + (m_angularVelocity * -((m_sweep.c.y - _local3.y))));
m_linearVelocity.y = (m_linearVelocity.y + (m_angularVelocity * (m_sweep.c.x - _local3.x)));
}
public function GetMassData(_arg1:b2MassData):void{
_arg1.mass = m_mass;
_arg1.I = m_I;
_arg1.center.SetV(m_sweep.localCenter);
}
public function Merge(_arg1:b2Body):void{
var _local2:b2Fixture;
var _local3:b2Body;
var _local4:b2Body;
var _local11:b2Fixture;
_local2 = _arg1.m_fixtureList;
while (_local2) {
_local11 = _local2.m_next;
_arg1.m_fixtureCount--;
_local2.m_next = m_fixtureList;
m_fixtureList = _local2;
m_fixtureCount++;
_local2.m_body = _local4;
_local2 = _local11;
};
_local3.m_fixtureCount = 0;
_local3 = this;
_local4 = _arg1;
var _local5:b2Vec2 = _local3.GetWorldCenter();
var _local6:b2Vec2 = _local4.GetWorldCenter();
var _local7:b2Vec2 = _local3.GetLinearVelocity().Copy();
var _local8:b2Vec2 = _local4.GetLinearVelocity().Copy();
var _local9:Number = _local3.GetAngularVelocity();
var _local10:Number = _local4.GetAngularVelocity();
_local3.ResetMassData();
SynchronizeFixtures();
}
b2internal function SynchronizeTransform():void{
m_xf.R.Set(m_sweep.a);
var _local1:b2Mat22 = m_xf.R;
var _local2:b2Vec2 = m_sweep.localCenter;
m_xf.position.x = (m_sweep.c.x - ((_local1.col1.x * _local2.x) + (_local1.col2.x * _local2.y)));
m_xf.position.y = (m_sweep.c.y - ((_local1.col1.y * _local2.x) + (_local1.col2.y * _local2.y)));
}
public function SetMassData(_arg1:b2MassData):void{
b2Settings.b2Assert((m_world.IsLocked() == false));
if (m_world.IsLocked() == true){
return;
};
if (m_type != b2_dynamicBody){
return;
};
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_mass = _arg1.mass;
if (m_mass <= 0){
m_mass = 1;
};
m_invMass = (1 / m_mass);
if ((((_arg1.I > 0)) && (((m_flags & e_fixedRotationFlag) == 0)))){
m_I = (_arg1.I - (m_mass * ((_arg1.center.x * _arg1.center.x) + (_arg1.center.y * _arg1.center.y))));
m_invI = (1 / m_I);
};
var _local2:b2Vec2 = m_sweep.c.Copy();
m_sweep.localCenter.SetV(_arg1.center);
m_sweep.c0.SetV(b2Math.MulX(m_xf, m_sweep.localCenter));
m_sweep.c.SetV(m_sweep.c0);
m_linearVelocity.x = (m_linearVelocity.x + (m_angularVelocity * -((m_sweep.c.y - _local2.y))));
m_linearVelocity.y = (m_linearVelocity.y + (m_angularVelocity * (m_sweep.c.x - _local2.x)));
}
public function GetDefinition():b2BodyDef{
var _local1:b2BodyDef = new b2BodyDef();
_local1.type = GetType();
_local1.allowSleep = ((m_flags & e_allowSleepFlag) == e_allowSleepFlag);
_local1.angle = GetAngle();
_local1.angularDamping = m_angularDamping;
_local1.angularVelocity = m_angularVelocity;
_local1.fixedRotation = ((m_flags & e_fixedRotationFlag) == e_fixedRotationFlag);
_local1.bullet = ((m_flags & e_bulletFlag) == e_bulletFlag);
_local1.awake = ((m_flags & e_awakeFlag) == e_awakeFlag);
_local1.linearDamping = m_linearDamping;
_local1.linearVelocity.SetV(GetLinearVelocity());
_local1.position = GetPosition();
_local1.userData = GetUserData();
return (_local1);
}
public function GetControllerList():b2ControllerEdge{
return (m_controllerList);
}
public function GetFixtureList():b2Fixture{
return (m_fixtureList);
}
public function SetAngularVelocity(_arg1:Number):void{
if (m_type == b2_staticBody){
return;
};
m_angularVelocity = _arg1;
}
public function GetAngle():Number{
return (m_sweep.a);
}
public function GetLinearVelocityFromLocalPoint(_arg1:b2Vec2):b2Vec2{
var _local2:b2Mat22 = m_xf.R;
var _local3:b2Vec2 = new b2Vec2(((_local2.col1.x * _arg1.x) + (_local2.col2.x * _arg1.y)), ((_local2.col1.y * _arg1.x) + (_local2.col2.y * _arg1.y)));
_local3.x = (_local3.x + m_xf.position.x);
_local3.y = (_local3.y + m_xf.position.y);
return (new b2Vec2((m_linearVelocity.x - (m_angularVelocity * (_local3.y - m_sweep.c.y))), (m_linearVelocity.y + (m_angularVelocity * (_local3.x - m_sweep.c.x)))));
}
public function GetNext():b2Body{
return (m_next);
}
public function GetMass():Number{
return (m_mass);
}
public function ApplyForce(_arg1:b2Vec2, _arg2:b2Vec2):void{
if (m_type != b2_dynamicBody){
return;
};
if (IsAwake() == false){
SetAwake(true);
};
m_force.x = (m_force.x + _arg1.x);
m_force.y = (m_force.y + _arg1.y);
m_torque = (m_torque + (((_arg2.x - m_sweep.c.x) * _arg1.y) - ((_arg2.y - m_sweep.c.y) * _arg1.x)));
}
public function CreateFixture(_arg1:b2FixtureDef):b2Fixture{
var _local3:IBroadPhase;
if (m_world.IsLocked() == true){
return (null);
};
var _local2:b2Fixture = new b2Fixture();
_local2.Create(this, m_xf, _arg1);
if ((m_flags & e_activeFlag)){
_local3 = m_world.m_contactManager.m_broadPhase;
_local2.CreateProxy(_local3, m_xf);
};
_local2.m_next = m_fixtureList;
m_fixtureList = _local2;
m_fixtureCount++;
_local2.m_body = this;
if (_local2.m_density > 0){
ResetMassData();
};
m_world.m_flags = (m_world.m_flags | b2World.e_newFixture);
return (_local2);
}
public function SetTransform(_arg1:b2Transform):void{
SetPositionAndAngle(_arg1.position, _arg1.GetAngle());
}
public function IsAwake():Boolean{
return (((m_flags & e_awakeFlag) == e_awakeFlag));
}
public function GetWorldVector(_arg1:b2Vec2):b2Vec2{
return (b2Math.MulMV(m_xf.R, _arg1));
}
b2internal function Advance(_arg1:Number):void{
m_sweep.Advance(_arg1);
m_sweep.c.SetV(m_sweep.c0);
m_sweep.a = m_sweep.a0;
SynchronizeTransform();
}
public function SetAwake(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_awakeFlag);
m_sleepTime = 0;
} else {
m_flags = (m_flags & ~(e_awakeFlag));
m_sleepTime = 0;
m_linearVelocity.SetZero();
m_angularVelocity = 0;
m_force.SetZero();
m_torque = 0;
};
}
public function GetUserData(){
return (m_userData);
}
public function GetWorldCenter():b2Vec2{
return (m_sweep.c);
}
public function SetUserData(_arg1):void{
m_userData = _arg1;
}
public function GetLocalVector(_arg1:b2Vec2):b2Vec2{
return (b2Math.MulTMV(m_xf.R, _arg1));
}
public function GetPosition():b2Vec2{
return (m_xf.position);
}
public function GetLinearVelocityFromWorldPoint(_arg1:b2Vec2):b2Vec2{
return (new b2Vec2((m_linearVelocity.x - (m_angularVelocity * (_arg1.y - m_sweep.c.y))), (m_linearVelocity.y + (m_angularVelocity * (_arg1.x - m_sweep.c.x)))));
}
public function CreateFixture2(_arg1:b2Shape, _arg2:Number=0):b2Fixture{
var _local3:b2FixtureDef = new b2FixtureDef();
_local3.shape = _arg1;
_local3.density = _arg2;
return (CreateFixture(_local3));
}
public function GetLinearDamping():Number{
return (m_linearDamping);
}
public function GetLocalCenter():b2Vec2{
return (m_sweep.localCenter);
}
public function SetPosition(_arg1:b2Vec2):void{
SetPositionAndAngle(_arg1, GetAngle());
}
private function connectEdges(_arg1:b2EdgeShape, _arg2:b2EdgeShape, _arg3:Number):Number{
var _local4:Number = Math.atan2(_arg2.GetDirectionVector().y, _arg2.GetDirectionVector().x);
var _local5:Number = Math.tan(((_local4 - _arg3) * 0.5));
var _local6:b2Vec2 = b2Math.MulFV(_local5, _arg2.GetDirectionVector());
_local6 = b2Math.SubtractVV(_local6, _arg2.GetNormalVector());
_local6 = b2Math.MulFV(b2Settings.b2_toiSlop, _local6);
_local6 = b2Math.AddVV(_local6, _arg2.GetVertex1());
var _local7:b2Vec2 = b2Math.AddVV(_arg1.GetDirectionVector(), _arg2.GetDirectionVector());
_local7.Normalize();
var _local8 = (b2Math.Dot(_arg1.GetDirectionVector(), _arg2.GetNormalVector()) > 0);
_arg1.SetNextEdge(_arg2, _local6, _local7, _local8);
_arg2.SetPrevEdge(_arg1, _local6, _local7, _local8);
return (_local4);
}
public function GetType():uint{
return (m_type);
}
public function GetAngularDamping():Number{
return (m_angularDamping);
}
public function SetType(_arg1:uint):void{
if (m_type == _arg1){
return;
};
m_type = _arg1;
ResetMassData();
if (m_type == b2_staticBody){
m_linearVelocity.SetZero();
m_angularVelocity = 0;
};
SetAwake(true);
m_force.SetZero();
m_torque = 0;
var _local2:b2ContactEdge = m_contactList;
while (_local2) {
_local2.contact.FlagForFiltering();
_local2 = _local2.next;
};
}
public function SetAngularDamping(_arg1:Number):void{
m_angularDamping = _arg1;
}
public function GetInertia():Number{
return (m_I);
}
public function SetAngle(_arg1:Number):void{
SetPositionAndAngle(GetPosition(), _arg1);
}
public function GetJointList():b2JointEdge{
return (m_jointList);
}
public function GetLocalPoint(_arg1:b2Vec2):b2Vec2{
return (b2Math.MulXT(m_xf, _arg1));
}
public function ApplyImpulse(_arg1:b2Vec2, _arg2:b2Vec2):void{
if (m_type != b2_dynamicBody){
return;
};
if (IsAwake() == false){
SetAwake(true);
};
m_linearVelocity.x = (m_linearVelocity.x + (m_invMass * _arg1.x));
m_linearVelocity.y = (m_linearVelocity.y + (m_invMass * _arg1.y));
m_angularVelocity = (m_angularVelocity + (m_invI * (((_arg2.x - m_sweep.c.x) * _arg1.y) - ((_arg2.y - m_sweep.c.y) * _arg1.x))));
}
public function GetContactList():b2ContactEdge{
return (m_contactList);
}
public function GetAngularVelocity():Number{
return (m_angularVelocity);
}
public function DestroyFixture(_arg1:b2Fixture):void{
var _local6:b2Contact;
var _local7:b2Fixture;
var _local8:b2Fixture;
var _local9:IBroadPhase;
if (m_world.IsLocked() == true){
return;
};
var _local2:b2Fixture = m_fixtureList;
var _local3:b2Fixture;
var _local4:Boolean;
while (_local2 != null) {
if (_local2 == _arg1){
if (_local3){
_local3.m_next = _arg1.m_next;
} else {
m_fixtureList = _arg1.m_next;
};
_local4 = true;
break;
};
_local3 = _local2;
_local2 = _local2.m_next;
};
var _local5:b2ContactEdge = m_contactList;
while (_local5) {
_local6 = _local5.contact;
_local5 = _local5.next;
_local7 = _local6.GetFixtureA();
_local8 = _local6.GetFixtureB();
if ((((_arg1 == _local7)) || ((_arg1 == _local8)))){
m_world.m_contactManager.Destroy(_local6);
};
};
if ((m_flags & e_activeFlag)){
_local9 = m_world.m_contactManager.m_broadPhase;
_arg1.DestroyProxy(_local9);
};
_arg1.Destroy();
_arg1.m_body = null;
_arg1.m_next = null;
m_fixtureCount--;
ResetMassData();
}
public function IsSleepingAllowed():Boolean{
return (((m_flags & e_allowSleepFlag) == e_allowSleepFlag));
}
public function GetTransform():b2Transform{
return (m_xf);
}
b2internal function SynchronizeFixtures():void{
var _local4:b2Fixture;
var _local1:b2Transform = s_xf1;
_local1.R.Set(m_sweep.a0);
var _local2:b2Mat22 = _local1.R;
var _local3:b2Vec2 = m_sweep.localCenter;
_local1.position.x = (m_sweep.c0.x - ((_local2.col1.x * _local3.x) + (_local2.col2.x * _local3.y)));
_local1.position.y = (m_sweep.c0.y - ((_local2.col1.y * _local3.x) + (_local2.col2.y * _local3.y)));
var _local5:IBroadPhase = m_world.m_contactManager.m_broadPhase;
_local4 = m_fixtureList;
while (_local4) {
_local4.Synchronize(_local5, _local1, m_xf);
_local4 = _local4.m_next;
};
}
public function SetSleepingAllowed(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_allowSleepFlag);
} else {
m_flags = (m_flags & ~(e_allowSleepFlag));
SetAwake(true);
};
}
public function SetBullet(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_bulletFlag);
} else {
m_flags = (m_flags & ~(e_bulletFlag));
};
}
public function SetPositionAndAngle(_arg1:b2Vec2, _arg2:Number):void{
var _local3:b2Fixture;
if (m_world.IsLocked() == true){
return;
};
m_xf.R.Set(_arg2);
m_xf.position.SetV(_arg1);
var _local4:b2Mat22 = m_xf.R;
var _local5:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((_local4.col1.x * _local5.x) + (_local4.col2.x * _local5.y));
m_sweep.c.y = ((_local4.col1.y * _local5.x) + (_local4.col2.y * _local5.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
m_sweep.a0 = (m_sweep.a = _arg2);
var _local6:IBroadPhase = m_world.m_contactManager.m_broadPhase;
_local3 = m_fixtureList;
while (_local3) {
_local3.Synchronize(_local6, m_xf, m_xf);
_local3 = _local3.m_next;
};
m_world.m_contactManager.FindNewContacts();
}
public function IsFixedRotation():Boolean{
return (((m_flags & e_fixedRotationFlag) == e_fixedRotationFlag));
}
public function SetActive(_arg1:Boolean):void{
var _local2:IBroadPhase;
var _local3:b2Fixture;
var _local4:b2ContactEdge;
var _local5:b2ContactEdge;
if (_arg1 == IsActive()){
return;
};
if (_arg1){
m_flags = (m_flags | e_activeFlag);
_local2 = m_world.m_contactManager.m_broadPhase;
_local3 = m_fixtureList;
while (_local3) {
_local3.CreateProxy(_local2, m_xf);
_local3 = _local3.m_next;
};
} else {
m_flags = (m_flags & ~(e_activeFlag));
_local2 = m_world.m_contactManager.m_broadPhase;
_local3 = m_fixtureList;
while (_local3) {
_local3.DestroyProxy(_local2);
_local3 = _local3.m_next;
};
_local4 = m_contactList;
while (_local4) {
_local5 = _local4;
_local4 = _local4.next;
m_world.m_contactManager.Destroy(_local5.contact);
};
m_contactList = null;
};
}
public function IsActive():Boolean{
return (((m_flags & e_activeFlag) == e_activeFlag));
}
b2internal function ShouldCollide(_arg1:b2Body):Boolean{
if (((!((m_type == b2_dynamicBody))) && (!((_arg1.m_type == b2_dynamicBody))))){
return (false);
};
var _local2:b2JointEdge = m_jointList;
while (_local2) {
if (_local2.other == _arg1){
if (_local2.joint.m_collideConnected == false){
return (false);
};
};
_local2 = _local2.next;
};
return (true);
}
public function IsBullet():Boolean{
return (((m_flags & e_bulletFlag) == e_bulletFlag));
}
public function GetWorldPoint(_arg1:b2Vec2):b2Vec2{
var _local2:b2Mat22 = m_xf.R;
var _local3:b2Vec2 = new b2Vec2(((_local2.col1.x * _arg1.x) + (_local2.col2.x * _arg1.y)), ((_local2.col1.y * _arg1.x) + (_local2.col2.y * _arg1.y)));
_local3.x = (_local3.x + m_xf.position.x);
_local3.y = (_local3.y + m_xf.position.y);
return (_local3);
}
public function SetFixedRotation(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_fixedRotationFlag);
} else {
m_flags = (m_flags & ~(e_fixedRotationFlag));
};
ResetMassData();
}
public function GetLinearVelocity():b2Vec2{
return (m_linearVelocity);
}
public function Split(_arg1:Function):b2Body{
var _local7:b2Fixture;
var _local13:b2Fixture;
var _local2:b2Vec2 = GetLinearVelocity().Copy();
var _local3:Number = GetAngularVelocity();
var _local4:b2Vec2 = GetWorldCenter();
var _local5:b2Body = this;
var _local6:b2Body = m_world.CreateBody(GetDefinition());
var _local8:b2Fixture = _local5.m_fixtureList;
while (_local8) {
if (_arg1(_local8)){
_local13 = _local8.m_next;
if (_local7){
_local7.m_next = _local13;
} else {
_local5.m_fixtureList = _local13;
};
_local5.m_fixtureCount--;
_local8.m_next = _local6.m_fixtureList;
_local6.m_fixtureList = _local8;
_local6.m_fixtureCount++;
_local8.m_body = _local6;
_local8 = _local13;
} else {
_local7 = _local8;
_local8 = _local8.m_next;
};
};
_local5.ResetMassData();
_local6.ResetMassData();
var _local9:b2Vec2 = _local5.GetWorldCenter();
var _local10:b2Vec2 = _local6.GetWorldCenter();
var _local11:b2Vec2 = b2Math.AddVV(_local2, b2Math.CrossFV(_local3, b2Math.SubtractVV(_local9, _local4)));
var _local12:b2Vec2 = b2Math.AddVV(_local2, b2Math.CrossFV(_local3, b2Math.SubtractVV(_local10, _local4)));
_local5.SetLinearVelocity(_local11);
_local6.SetLinearVelocity(_local12);
_local5.SetAngularVelocity(_local3);
_local6.SetAngularVelocity(_local3);
_local5.SynchronizeFixtures();
_local6.SynchronizeFixtures();
return (_local6);
}
public function SetLinearDamping(_arg1:Number):void{
m_linearDamping = _arg1;
}
public function GetWorld():b2World{
return (m_world);
}
public function ApplyTorque(_arg1:Number):void{
if (m_type != b2_dynamicBody){
return;
};
if (IsAwake() == false){
SetAwake(true);
};
m_torque = (m_torque + _arg1);
}
}
}//package Box2D.Dynamics
Section 81
//b2BodyDef (Box2D.Dynamics.b2BodyDef)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
public class b2BodyDef {
public var angularDamping:Number;
public var bullet:Boolean;
public var awake:Boolean;
public var active:Boolean;
public var allowSleep:Boolean;
public var angle:Number;
public var userData;
public var fixedRotation:Boolean;
public var linearDamping:Number;
public var angularVelocity:Number;
public var linearVelocity:b2Vec2;
public var position:b2Vec2;
public var inertiaScale:Number;
public var type:uint;
public function b2BodyDef(){
position = new b2Vec2();
linearVelocity = new b2Vec2();
super();
userData = null;
position.Set(0, 0);
angle = 0;
linearVelocity.Set(0, 0);
angularVelocity = 0;
linearDamping = 0;
angularDamping = 0;
allowSleep = true;
awake = true;
fixedRotation = false;
bullet = false;
type = b2Body.b2_staticBody;
active = true;
inertiaScale = 1;
}
}
}//package Box2D.Dynamics
Section 82
//b2ContactFilter (Box2D.Dynamics.b2ContactFilter)
package Box2D.Dynamics {
import Box2D.Common.*;
public class b2ContactFilter {
b2internal static var b2_defaultFilter:b2ContactFilter = new (b2ContactFilter);
;
public function ShouldCollide(_arg1:b2Fixture, _arg2:b2Fixture):Boolean{
var _local3:b2FilterData = _arg1.GetFilterData();
var _local4:b2FilterData = _arg2.GetFilterData();
if ((((_local3.groupIndex == _local4.groupIndex)) && (!((_local3.groupIndex == 0))))){
return ((_local3.groupIndex > 0));
};
var _local5:Boolean = ((!(((_local3.maskBits & _local4.categoryBits) == 0))) && (!(((_local3.categoryBits & _local4.maskBits) == 0))));
return (_local5);
}
public function RayCollide(_arg1, _arg2:b2Fixture):Boolean{
if (!_arg1){
return (true);
};
return (ShouldCollide((_arg1 as b2Fixture), _arg2));
}
}
}//package Box2D.Dynamics
Section 83
//b2ContactImpulse (Box2D.Dynamics.b2ContactImpulse)
package Box2D.Dynamics {
import Box2D.Common.*;
public class b2ContactImpulse {
public var tangentImpulses:Array;
public var normalImpulses:Array;
public function b2ContactImpulse(){
normalImpulses = new Array(b2Settings.b2_maxManifoldPoints);
tangentImpulses = new Array(b2Settings.b2_maxManifoldPoints);
super();
}
}
}//package Box2D.Dynamics
Section 84
//b2ContactListener (Box2D.Dynamics.b2ContactListener)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2ContactListener {
b2internal static var b2_defaultListener:b2ContactListener = new (b2ContactListener);
;
public function PreSolve(_arg1:b2Contact, _arg2:b2Manifold):void{
}
public function EndContact(_arg1:b2Contact):void{
}
public function PostSolve(_arg1:b2Contact, _arg2:b2ContactImpulse):void{
}
public function BeginContact(_arg1:b2Contact):void{
}
}
}//package Box2D.Dynamics
Section 85
//b2ContactManager (Box2D.Dynamics.b2ContactManager)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2ContactManager {
b2internal var m_world:b2World;
b2internal var m_contactCount:int;
b2internal var m_contactFactory:b2ContactFactory;
b2internal var m_contactFilter:b2ContactFilter;
b2internal var m_broadPhase:IBroadPhase;
b2internal var m_contactList:b2Contact;
b2internal var m_contactListener:b2ContactListener;
b2internal var m_allocator;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2ContactManager(){
m_world = null;
m_contactCount = 0;
m_contactFilter = b2ContactFilter.b2_defaultFilter;
m_contactListener = b2ContactListener.b2_defaultListener;
m_contactFactory = new b2ContactFactory(m_allocator);
m_broadPhase = new b2DynamicTreeBroadPhase();
}
public function FindNewContacts():void{
m_broadPhase.UpdatePairs(AddPair);
}
public function Destroy(_arg1:b2Contact):void{
var _local2:b2Fixture = _arg1.GetFixtureA();
var _local3:b2Fixture = _arg1.GetFixtureB();
var _local4:b2Body = _local2.GetBody();
var _local5:b2Body = _local3.GetBody();
if (_arg1.IsTouching()){
m_contactListener.EndContact(_arg1);
};
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_world.m_contactList){
m_world.m_contactList = _arg1.m_next;
};
if (_arg1.m_nodeA.prev){
_arg1.m_nodeA.prev.next = _arg1.m_nodeA.next;
};
if (_arg1.m_nodeA.next){
_arg1.m_nodeA.next.prev = _arg1.m_nodeA.prev;
};
if (_arg1.m_nodeA == _local4.m_contactList){
_local4.m_contactList = _arg1.m_nodeA.next;
};
if (_arg1.m_nodeB.prev){
_arg1.m_nodeB.prev.next = _arg1.m_nodeB.next;
};
if (_arg1.m_nodeB.next){
_arg1.m_nodeB.next.prev = _arg1.m_nodeB.prev;
};
if (_arg1.m_nodeB == _local5.m_contactList){
_local5.m_contactList = _arg1.m_nodeB.next;
};
m_contactFactory.Destroy(_arg1);
m_contactCount--;
}
public function AddPair(_arg1, _arg2):void{
var _local9:b2Fixture;
var _local10:b2Fixture;
var _local3:b2Fixture = (_arg1 as b2Fixture);
var _local4:b2Fixture = (_arg2 as b2Fixture);
var _local5:b2Body = _local3.GetBody();
var _local6:b2Body = _local4.GetBody();
if (_local5 == _local6){
return;
};
var _local7:b2ContactEdge = _local6.GetContactList();
while (_local7) {
if (_local7.other == _local5){
_local9 = _local7.contact.GetFixtureA();
_local10 = _local7.contact.GetFixtureB();
if ((((_local9 == _local3)) && ((_local10 == _local4)))){
return;
};
if ((((_local9 == _local4)) && ((_local10 == _local3)))){
return;
};
};
_local7 = _local7.next;
};
if (_local6.ShouldCollide(_local5) == false){
return;
};
if (m_contactFilter.ShouldCollide(_local3, _local4) == false){
return;
};
var _local8:b2Contact = m_contactFactory.Create(_local3, _local4);
_local3 = _local8.GetFixtureA();
_local4 = _local8.GetFixtureB();
_local5 = _local3.m_body;
_local6 = _local4.m_body;
_local8.m_prev = null;
_local8.m_next = m_world.m_contactList;
if (m_world.m_contactList != null){
m_world.m_contactList.m_prev = _local8;
};
m_world.m_contactList = _local8;
_local8.m_nodeA.contact = _local8;
_local8.m_nodeA.other = _local6;
_local8.m_nodeA.prev = null;
_local8.m_nodeA.next = _local5.m_contactList;
if (_local5.m_contactList != null){
_local5.m_contactList.prev = _local8.m_nodeA;
};
_local5.m_contactList = _local8.m_nodeA;
_local8.m_nodeB.contact = _local8;
_local8.m_nodeB.other = _local5;
_local8.m_nodeB.prev = null;
_local8.m_nodeB.next = _local6.m_contactList;
if (_local6.m_contactList != null){
_local6.m_contactList.prev = _local8.m_nodeB;
};
_local6.m_contactList = _local8.m_nodeB;
m_world.m_contactCount++;
}
public function Collide():void{
var _local2:b2Fixture;
var _local3:b2Fixture;
var _local4:b2Body;
var _local5:b2Body;
var _local6:*;
var _local7:*;
var _local8:Boolean;
var _local9:b2Contact;
var _local1:b2Contact = m_world.m_contactList;
while (_local1) {
_local2 = _local1.GetFixtureA();
_local3 = _local1.GetFixtureB();
_local4 = _local2.GetBody();
_local5 = _local3.GetBody();
if ((((_local4.IsAwake() == false)) && ((_local5.IsAwake() == false)))){
_local1 = _local1.GetNext();
} else {
if ((_local1.m_flags & b2Contact.e_filterFlag)){
if (_local5.ShouldCollide(_local4) == false){
_local9 = _local1;
_local1 = _local9.GetNext();
Destroy(_local9);
continue;
};
if (m_contactFilter.ShouldCollide(_local2, _local3) == false){
_local9 = _local1;
_local1 = _local9.GetNext();
Destroy(_local9);
continue;
};
_local1.m_flags = (_local1.m_flags & ~(b2Contact.e_filterFlag));
};
_local6 = _local2.m_proxy;
_local7 = _local3.m_proxy;
_local8 = m_broadPhase.TestOverlap(_local6, _local7);
if (_local8 == false){
_local9 = _local1;
_local1 = _local9.GetNext();
Destroy(_local9);
} else {
_local1.Update(m_contactListener);
_local1 = _local1.GetNext();
};
};
};
}
}
}//package Box2D.Dynamics
Section 86
//b2DebugDraw (Box2D.Dynamics.b2DebugDraw)
package Box2D.Dynamics {
import flash.display.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2DebugDraw {
private var m_xformScale:Number;// = 1
private var m_fillAlpha:Number;// = 1
private var m_alpha:Number;// = 1
private var m_lineThickness:Number;// = 1
private var m_drawFlags:uint;
b2internal var m_sprite:Sprite;
private var m_drawScale:Number;// = 1
public static var e_centerOfMassBit:uint = 16;
public static var e_shapeBit:uint = 1;
public static var e_aabbBit:uint = 4;
public static var e_controllerBit:uint = 32;
public static var e_pairBit:uint = 8;
public static var e_jointBit:uint = 2;
public function b2DebugDraw(){
m_drawFlags = 0;
}
public function SetDrawScale(_arg1:Number):void{
m_drawScale = _arg1;
}
public function GetFillAlpha():Number{
return (m_fillAlpha);
}
public function GetAlpha():Number{
return (m_alpha);
}
public function GetLineThickness():Number{
return (m_lineThickness);
}
public function GetDrawScale():Number{
return (m_drawScale);
}
public function DrawSolidPolygon(_arg1:Array, _arg2:int, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.moveTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
m_sprite.graphics.beginFill(_arg3.color, m_fillAlpha);
var _local4 = 1;
while (_local4 < _arg2) {
m_sprite.graphics.lineTo((_arg1[_local4].x * m_drawScale), (_arg1[_local4].y * m_drawScale));
_local4++;
};
m_sprite.graphics.lineTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
m_sprite.graphics.endFill();
}
public function DrawCircle(_arg1:b2Vec2, _arg2:Number, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.drawCircle((_arg1.x * m_drawScale), (_arg1.y * m_drawScale), (_arg2 * m_drawScale));
}
public function DrawSolidCircle(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg4.color, m_alpha);
m_sprite.graphics.moveTo(0, 0);
m_sprite.graphics.beginFill(_arg4.color, m_fillAlpha);
m_sprite.graphics.drawCircle((_arg1.x * m_drawScale), (_arg1.y * m_drawScale), (_arg2 * m_drawScale));
m_sprite.graphics.endFill();
m_sprite.graphics.moveTo((_arg1.x * m_drawScale), (_arg1.y * m_drawScale));
m_sprite.graphics.lineTo(((_arg1.x + (_arg3.x * _arg2)) * m_drawScale), ((_arg1.y + (_arg3.y * _arg2)) * m_drawScale));
}
public function ClearFlags(_arg1:uint):void{
m_drawFlags = (m_drawFlags & ~(_arg1));
}
public function GetSprite():Sprite{
return (m_sprite);
}
public function GetXFormScale():Number{
return (m_xformScale);
}
public function SetFlags(_arg1:uint):void{
m_drawFlags = _arg1;
}
public function SetSprite(_arg1:Sprite):void{
m_sprite = _arg1;
}
public function DrawTransform(_arg1:b2Transform):void{
m_sprite.graphics.lineStyle(m_lineThickness, 0xFF0000, m_alpha);
m_sprite.graphics.moveTo((_arg1.position.x * m_drawScale), (_arg1.position.y * m_drawScale));
m_sprite.graphics.lineTo(((_arg1.position.x + (m_xformScale * _arg1.R.col1.x)) * m_drawScale), ((_arg1.position.y + (m_xformScale * _arg1.R.col1.y)) * m_drawScale));
m_sprite.graphics.lineStyle(m_lineThickness, 0xFF00, m_alpha);
m_sprite.graphics.moveTo((_arg1.position.x * m_drawScale), (_arg1.position.y * m_drawScale));
m_sprite.graphics.lineTo(((_arg1.position.x + (m_xformScale * _arg1.R.col2.x)) * m_drawScale), ((_arg1.position.y + (m_xformScale * _arg1.R.col2.y)) * m_drawScale));
}
public function AppendFlags(_arg1:uint):void{
m_drawFlags = (m_drawFlags | _arg1);
}
public function DrawSegment(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.moveTo((_arg1.x * m_drawScale), (_arg1.y * m_drawScale));
m_sprite.graphics.lineTo((_arg2.x * m_drawScale), (_arg2.y * m_drawScale));
}
public function SetXFormScale(_arg1:Number):void{
m_xformScale = _arg1;
}
public function GetFlags():uint{
return (m_drawFlags);
}
public function DrawPolygon(_arg1:Array, _arg2:int, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.moveTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
var _local4 = 1;
while (_local4 < _arg2) {
m_sprite.graphics.lineTo((_arg1[_local4].x * m_drawScale), (_arg1[_local4].y * m_drawScale));
_local4++;
};
m_sprite.graphics.lineTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
}
public function SetFillAlpha(_arg1:Number):void{
m_fillAlpha = _arg1;
}
public function SetAlpha(_arg1:Number):void{
m_alpha = _arg1;
}
public function SetLineThickness(_arg1:Number):void{
m_lineThickness = _arg1;
}
}
}//package Box2D.Dynamics
Section 87
//b2DestructionListener (Box2D.Dynamics.b2DestructionListener)
package Box2D.Dynamics {
import Box2D.Dynamics.Joints.*;
public class b2DestructionListener {
public function SayGoodbyeFixture(_arg1:b2Fixture):void{
}
public function SayGoodbyeJoint(_arg1:b2Joint):void{
}
}
}//package Box2D.Dynamics
Section 88
//b2FilterData (Box2D.Dynamics.b2FilterData)
package Box2D.Dynamics {
public class b2FilterData {
public var maskBits:uint;// = 0xFFFF
public var groupIndex:int;// = 0
public var categoryBits:uint;// = 1
public function Copy():b2FilterData{
var _local1:b2FilterData = new b2FilterData();
_local1.categoryBits = categoryBits;
_local1.maskBits = maskBits;
_local1.groupIndex = groupIndex;
return (_local1);
}
}
}//package Box2D.Dynamics
Section 89
//b2Fixture (Box2D.Dynamics.b2Fixture)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2Fixture {
b2internal var m_next:b2Fixture;
b2internal var m_shape:b2Shape;
b2internal var m_restitution:Number;
b2internal var m_friction:Number;
b2internal var m_proxy;
b2internal var m_filter:b2FilterData;
b2internal var m_density:Number;
private var m_massData:b2MassData;
b2internal var m_isSensor:Boolean;
b2internal var m_userData;
b2internal var m_aabb:b2AABB;
b2internal var m_body:b2Body;
public function b2Fixture(){
m_filter = new b2FilterData();
super();
m_aabb = new b2AABB();
m_userData = null;
m_body = null;
m_next = null;
m_shape = null;
m_density = 0;
m_friction = 0;
m_restitution = 0;
}
public function TestPoint(_arg1:b2Vec2):Boolean{
return (m_shape.TestPoint(m_body.GetTransform(), _arg1));
}
public function SetDensity(_arg1:Number):void{
m_density = _arg1;
}
public function SetRestitution(_arg1:Number):void{
m_restitution = _arg1;
}
public function GetNext():b2Fixture{
return (m_next);
}
public function GetShape():b2Shape{
return (m_shape);
}
public function GetFriction():Number{
return (m_friction);
}
public function GetDensity():Number{
return (m_density);
}
public function GetMassData(_arg1:b2MassData=null):b2MassData{
if (_arg1 == null){
_arg1 = new b2MassData();
};
m_shape.ComputeMass(_arg1, m_density);
return (_arg1);
}
public function GetAABB():b2AABB{
return (m_aabb);
}
public function GetType():int{
return (m_shape.GetType());
}
public function GetFilterData():b2FilterData{
return (m_filter.Copy());
}
b2internal function Destroy():void{
m_shape = null;
}
public function GetRestitution():Number{
return (m_restitution);
}
public function SetFriction(_arg1:Number):void{
m_friction = _arg1;
}
b2internal function Create(_arg1:b2Body, _arg2:b2Transform, _arg3:b2FixtureDef):void{
m_userData = _arg3.userData;
m_friction = _arg3.friction;
m_restitution = _arg3.restitution;
m_body = _arg1;
m_next = null;
m_filter = _arg3.filter.Copy();
m_isSensor = _arg3.isSensor;
m_shape = _arg3.shape.Copy();
m_density = _arg3.density;
}
public function IsSensor():Boolean{
return (m_isSensor);
}
public function RayCast(_arg1:b2RayCastOutput, _arg2:b2RayCastInput):Boolean{
return (m_shape.RayCast(_arg1, _arg2, m_body.GetTransform()));
}
public function GetUserData(){
return (m_userData);
}
b2internal function Synchronize(_arg1:IBroadPhase, _arg2:b2Transform, _arg3:b2Transform):void{
if (!m_proxy){
return;
};
var _local4:b2AABB = new b2AABB();
var _local5:b2AABB = new b2AABB();
m_shape.ComputeAABB(_local4, _arg2);
m_shape.ComputeAABB(_local5, _arg3);
m_aabb.Combine(_local4, _local5);
var _local6:b2Vec2 = b2Math.SubtractVV(_arg3.position, _arg2.position);
_arg1.MoveProxy(m_proxy, m_aabb, _local6);
}
b2internal function CreateProxy(_arg1:IBroadPhase, _arg2:b2Transform):void{
m_shape.ComputeAABB(m_aabb, _arg2);
m_proxy = _arg1.CreateProxy(m_aabb, this);
}
public function SetFilterData(_arg1:b2FilterData):void{
var _local3:b2Contact;
var _local4:b2Fixture;
var _local5:b2Fixture;
m_filter = _arg1.Copy();
if (m_body){
return;
};
var _local2:b2ContactEdge = m_body.GetContactList();
while (_local2) {
_local3 = _local2.contact;
_local4 = _local3.GetFixtureA();
_local5 = _local3.GetFixtureB();
if ((((_local4 == this)) || ((_local5 == this)))){
_local3.FlagForFiltering();
};
_local2 = _local2.next;
};
}
b2internal function DestroyProxy(_arg1:IBroadPhase):void{
if (m_proxy == null){
return;
};
_arg1.DestroyProxy(m_proxy);
m_proxy = null;
}
public function SetUserData(_arg1):void{
m_userData = _arg1;
}
public function GetBody():b2Body{
return (m_body);
}
public function SetSensor(_arg1:Boolean):void{
var _local3:b2Contact;
var _local4:b2Fixture;
var _local5:b2Fixture;
if (m_isSensor == _arg1){
return;
};
m_isSensor = _arg1;
if (m_body == null){
return;
};
var _local2:b2ContactEdge = m_body.GetContactList();
while (_local2) {
_local3 = _local2.contact;
_local4 = _local3.GetFixtureA();
_local5 = _local3.GetFixtureB();
if ((((_local4 == this)) || ((_local5 == this)))){
_local3.SetSensor(((_local4.IsSensor()) || (_local5.IsSensor())));
};
_local2 = _local2.next;
};
}
}
}//package Box2D.Dynamics
Section 90
//b2FixtureDef (Box2D.Dynamics.b2FixtureDef)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
public class b2FixtureDef {
public var shape:b2Shape;
public var isSensor:Boolean;
public var density:Number;
public var restitution:Number;
public var userData;
public var filter:b2FilterData;
public var friction:Number;
public function b2FixtureDef(){
filter = new b2FilterData();
super();
shape = null;
userData = null;
friction = 0.2;
restitution = 0;
density = 0;
filter.categoryBits = 1;
filter.maskBits = 0xFFFF;
filter.groupIndex = 0;
isSensor = false;
}
}
}//package Box2D.Dynamics
Section 91
//b2Island (Box2D.Dynamics.b2Island)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2Island {
private var m_contactSolver:b2ContactSolver;
private var m_listener:b2ContactListener;
private var m_bodyCapacity:int;
b2internal var m_bodies:Array;
b2internal var m_bodyCount:int;
b2internal var m_jointCapacity:int;
b2internal var m_contactCount:int;
b2internal var m_contacts:Array;
b2internal var m_contactCapacity:int;
b2internal var m_jointCount:int;
private var m_allocator;
b2internal var m_joints:Array;
private static var s_impulse:b2ContactImpulse = new b2ContactImpulse();
public function b2Island(){
m_bodies = new Array();
m_contacts = new Array();
m_joints = new Array();
}
public function AddBody(_arg1:b2Body):void{
_arg1.m_islandIndex = m_bodyCount;
var _local2 = m_bodyCount++;
m_bodies[_local2] = _arg1;
}
public function AddJoint(_arg1:b2Joint):void{
var _local2 = m_jointCount++;
m_joints[_local2] = _arg1;
}
public function Report(_arg1:Array):void{
var _local3:b2Contact;
var _local4:b2ContactConstraint;
var _local5:int;
if (m_listener == null){
return;
};
var _local2:int;
while (_local2 < m_contactCount) {
_local3 = m_contacts[_local2];
_local4 = _arg1[_local2];
_local5 = 0;
while (_local5 < _local4.pointCount) {
s_impulse.normalImpulses[_local5] = _local4.points[_local5].normalImpulse;
s_impulse.tangentImpulses[_local5] = _local4.points[_local5].tangentImpulse;
_local5++;
};
m_listener.PostSolve(_local3, s_impulse);
_local2++;
};
}
public function AddContact(_arg1:b2Contact):void{
var _local2 = m_contactCount++;
m_contacts[_local2] = _arg1;
}
public function Solve(_arg1:b2TimeStep, _arg2:b2Vec2, _arg3:Boolean):void{
var _local4:int;
var _local5:int;
var _local6:b2Body;
var _local7:b2Joint;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Boolean;
var _local13:Boolean;
var _local14:Boolean;
var _local15:Number;
var _local16:Number;
var _local17:Number;
_local4 = 0;
while (_local4 < m_bodyCount) {
_local6 = m_bodies[_local4];
if (_local6.GetType() != b2Body.b2_dynamicBody){
} else {
_local6.m_linearVelocity.x = (_local6.m_linearVelocity.x + (_arg1.dt * (_arg2.x + (_local6.m_invMass * _local6.m_force.x))));
_local6.m_linearVelocity.y = (_local6.m_linearVelocity.y + (_arg1.dt * (_arg2.y + (_local6.m_invMass * _local6.m_force.y))));
_local6.m_angularVelocity = (_local6.m_angularVelocity + ((_arg1.dt * _local6.m_invI) * _local6.m_torque));
_local6.m_linearVelocity.Multiply(b2Math.Clamp((1 - (_arg1.dt * _local6.m_linearDamping)), 0, 1));
_local6.m_angularVelocity = (_local6.m_angularVelocity * b2Math.Clamp((1 - (_arg1.dt * _local6.m_angularDamping)), 0, 1));
};
_local4++;
};
m_contactSolver.Initialize(_arg1, m_contacts, m_contactCount, m_allocator);
var _local8:b2ContactSolver = m_contactSolver;
_local8.InitVelocityConstraints(_arg1);
_local4 = 0;
while (_local4 < m_jointCount) {
_local7 = m_joints[_local4];
_local7.InitVelocityConstraints(_arg1);
_local4++;
};
_local4 = 0;
while (_local4 < _arg1.velocityIterations) {
_local5 = 0;
while (_local5 < m_jointCount) {
_local7 = m_joints[_local5];
_local7.SolveVelocityConstraints(_arg1);
_local5++;
};
_local8.SolveVelocityConstraints();
_local4++;
};
_local4 = 0;
while (_local4 < m_jointCount) {
_local7 = m_joints[_local4];
_local7.FinalizeVelocityConstraints();
_local4++;
};
_local8.FinalizeVelocityConstraints();
_local4 = 0;
while (_local4 < m_bodyCount) {
_local6 = m_bodies[_local4];
if (_local6.GetType() == b2Body.b2_staticBody){
} else {
_local9 = (_arg1.dt * _local6.m_linearVelocity.x);
_local10 = (_arg1.dt * _local6.m_linearVelocity.y);
if (((_local9 * _local9) + (_local10 * _local10)) > b2Settings.b2_maxTranslationSquared){
_local6.m_linearVelocity.Normalize();
_local6.m_linearVelocity.x = (_local6.m_linearVelocity.x * (b2Settings.b2_maxTranslation * _arg1.inv_dt));
_local6.m_linearVelocity.y = (_local6.m_linearVelocity.y * (b2Settings.b2_maxTranslation * _arg1.inv_dt));
};
_local11 = (_arg1.dt * _local6.m_angularVelocity);
if (((_arg1.dt * _local6.m_angularVelocity) * _local11) > b2Settings.b2_maxRotationSquared){
if (_local6.m_angularVelocity < 0){
_local6.m_angularVelocity = (-(b2Settings.b2_maxRotation) * _arg1.inv_dt);
} else {
_local6.m_angularVelocity = (b2Settings.b2_maxRotation * _arg1.inv_dt);
};
};
_local6.m_sweep.c0.SetV(_local6.m_sweep.c);
_local6.m_sweep.a0 = _local6.m_sweep.a;
_local6.m_sweep.c.x = (_local6.m_sweep.c.x + (_arg1.dt * _local6.m_linearVelocity.x));
_local6.m_sweep.c.y = (_local6.m_sweep.c.y + (_arg1.dt * _local6.m_linearVelocity.y));
_local6.m_sweep.a = (_local6.m_sweep.a + (_arg1.dt * _local6.m_angularVelocity));
_local6.SynchronizeTransform();
};
_local4++;
};
_local4 = 0;
while (_local4 < _arg1.positionIterations) {
_local12 = _local8.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
_local13 = true;
_local5 = 0;
while (_local5 < m_jointCount) {
_local7 = m_joints[_local5];
_local14 = _local7.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
_local13 = ((_local13) && (_local14));
_local5++;
};
if (((_local12) && (_local13))){
break;
};
_local4++;
};
Report(_local8.m_constraints);
if (_arg3){
_local15 = Number.MAX_VALUE;
_local16 = (b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance);
_local17 = (b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance);
_local4 = 0;
while (_local4 < m_bodyCount) {
_local6 = m_bodies[_local4];
if (_local6.GetType() == b2Body.b2_staticBody){
} else {
if ((_local6.m_flags & b2Body.e_allowSleepFlag) == 0){
_local6.m_sleepTime = 0;
_local15 = 0;
};
if (((((((_local6.m_flags & b2Body.e_allowSleepFlag) == 0)) || (((_local6.m_angularVelocity * _local6.m_angularVelocity) > _local17)))) || ((b2Math.Dot(_local6.m_linearVelocity, _local6.m_linearVelocity) > _local16)))){
_local6.m_sleepTime = 0;
_local15 = 0;
} else {
_local6.m_sleepTime = (_local6.m_sleepTime + _arg1.dt);
_local15 = b2Math.Min(_local15, _local6.m_sleepTime);
};
};
_local4++;
};
if (_local15 >= b2Settings.b2_timeToSleep){
_local4 = 0;
while (_local4 < m_bodyCount) {
_local6 = m_bodies[_local4];
_local6.SetAwake(false);
_local4++;
};
};
};
}
public function Clear():void{
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
}
public function SolveTOI(_arg1:b2TimeStep):void{
var _local2:int;
var _local3:int;
var _local6:b2Body;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Boolean;
var _local11:Boolean;
var _local12:Boolean;
m_contactSolver.Initialize(_arg1, m_contacts, m_contactCount, m_allocator);
var _local4:b2ContactSolver = m_contactSolver;
_local2 = 0;
while (_local2 < m_jointCount) {
m_joints[_local2].InitVelocityConstraints(_arg1);
_local2++;
};
_local2 = 0;
while (_local2 < _arg1.velocityIterations) {
_local4.SolveVelocityConstraints();
_local3 = 0;
while (_local3 < m_jointCount) {
m_joints[_local3].SolveVelocityConstraints(_arg1);
_local3++;
};
_local2++;
};
_local2 = 0;
while (_local2 < m_bodyCount) {
_local6 = m_bodies[_local2];
if (_local6.GetType() == b2Body.b2_staticBody){
} else {
_local7 = (_arg1.dt * _local6.m_linearVelocity.x);
_local8 = (_arg1.dt * _local6.m_linearVelocity.y);
if (((_local7 * _local7) + (_local8 * _local8)) > b2Settings.b2_maxTranslationSquared){
_local6.m_linearVelocity.Normalize();
_local6.m_linearVelocity.x = (_local6.m_linearVelocity.x * (b2Settings.b2_maxTranslation * _arg1.inv_dt));
_local6.m_linearVelocity.y = (_local6.m_linearVelocity.y * (b2Settings.b2_maxTranslation * _arg1.inv_dt));
};
_local9 = (_arg1.dt * _local6.m_angularVelocity);
if (((_arg1.dt * _local6.m_angularVelocity) * _local9) > b2Settings.b2_maxRotationSquared){
if (_local6.m_angularVelocity < 0){
_local6.m_angularVelocity = (-(b2Settings.b2_maxRotation) * _arg1.inv_dt);
} else {
_local6.m_angularVelocity = (b2Settings.b2_maxRotation * _arg1.inv_dt);
};
};
_local6.m_sweep.c0.SetV(_local6.m_sweep.c);
_local6.m_sweep.a0 = _local6.m_sweep.a;
_local6.m_sweep.c.x = (_local6.m_sweep.c.x + (_arg1.dt * _local6.m_linearVelocity.x));
_local6.m_sweep.c.y = (_local6.m_sweep.c.y + (_arg1.dt * _local6.m_linearVelocity.y));
_local6.m_sweep.a = (_local6.m_sweep.a + (_arg1.dt * _local6.m_angularVelocity));
_local6.SynchronizeTransform();
};
_local2++;
};
var _local5:Number = 0.75;
_local2 = 0;
while (_local2 < _arg1.positionIterations) {
_local10 = _local4.SolvePositionConstraints(_local5);
_local11 = true;
_local3 = 0;
while (_local3 < m_jointCount) {
_local12 = m_joints[_local3].SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
_local11 = ((_local11) && (_local12));
_local3++;
};
if (((_local10) && (_local11))){
break;
};
_local2++;
};
Report(_local4.m_constraints);
}
public function Initialize(_arg1:int, _arg2:int, _arg3:int, _arg4, _arg5:b2ContactListener, _arg6:b2ContactSolver):void{
var _local7:int;
m_bodyCapacity = _arg1;
m_contactCapacity = _arg2;
m_jointCapacity = _arg3;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_allocator = _arg4;
m_listener = _arg5;
m_contactSolver = _arg6;
_local7 = m_bodies.length;
while (_local7 < _arg1) {
m_bodies[_local7] = null;
_local7++;
};
_local7 = m_contacts.length;
while (_local7 < _arg2) {
m_contacts[_local7] = null;
_local7++;
};
_local7 = m_joints.length;
while (_local7 < _arg3) {
m_joints[_local7] = null;
_local7++;
};
}
}
}//package Box2D.Dynamics
Section 92
//b2TimeStep (Box2D.Dynamics.b2TimeStep)
package Box2D.Dynamics {
public class b2TimeStep {
public var warmStarting:Boolean;
public var inv_dt:Number;
public var dt:Number;
public var velocityIterations:int;
public var dtRatio:Number;
public var positionIterations:int;
public function Set(_arg1:b2TimeStep):void{
dt = _arg1.dt;
inv_dt = _arg1.inv_dt;
positionIterations = _arg1.positionIterations;
velocityIterations = _arg1.velocityIterations;
warmStarting = _arg1.warmStarting;
}
}
}//package Box2D.Dynamics
Section 93
//b2World (Box2D.Dynamics.b2World)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Controllers.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2World {
private var m_inv_dt0:Number;
private var m_contactSolver:b2ContactSolver;
private var m_controllerList:b2Controller;
b2internal var m_contactList:b2Contact;
private var m_controllerCount:int;
private var m_allowSleep:Boolean;
private var m_island:b2Island;
b2internal var m_flags:int;
private var m_jointCount:int;
private var m_bodyCount:int;
private var s_stack:Array;
private var m_destructionListener:b2DestructionListener;
b2internal var m_groundBody:b2Body;
b2internal var m_contactCount:int;
private var m_debugDraw:b2DebugDraw;
b2internal var m_bodyList:b2Body;
private var m_jointList:b2Joint;
private var m_gravity:b2Vec2;
b2internal var m_contactManager:b2ContactManager;
public static const e_newFixture:int = 1;
public static const e_locked:int = 2;
private static var s_timestep:b2TimeStep = new b2TimeStep();
private static var s_queue:Array = new Array();
private static var s_timestep2:b2TimeStep = new b2TimeStep();
private static var s_backupA:b2Sweep = new b2Sweep();
private static var m_continuousPhysics:Boolean;
private static var m_warmStarting:Boolean;
private static var s_xf:b2Transform = new b2Transform();
private static var s_backupB:b2Sweep = new b2Sweep();
private static var s_jointColor:b2Color = new b2Color(0.5, 0.8, 0.8);
public function b2World(_arg1:b2Vec2, _arg2:Boolean){
s_stack = new Array();
m_contactManager = new b2ContactManager();
m_contactSolver = new b2ContactSolver();
m_island = new b2Island();
super();
m_destructionListener = null;
m_debugDraw = null;
m_bodyList = null;
m_contactList = null;
m_jointList = null;
m_controllerList = null;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_controllerCount = 0;
m_warmStarting = true;
m_continuousPhysics = true;
m_allowSleep = _arg2;
m_gravity = _arg1;
m_inv_dt0 = 0;
m_contactManager.m_world = this;
var _local3:b2BodyDef = new b2BodyDef();
m_groundBody = CreateBody(_local3);
}
b2internal function DrawJoint(_arg1:b2Joint):void{
var _local11:b2PulleyJoint;
var _local12:b2Vec2;
var _local13:b2Vec2;
var _local2:b2Body = _arg1.GetBodyA();
var _local3:b2Body = _arg1.GetBodyB();
var _local4:b2Transform = _local2.m_xf;
var _local5:b2Transform = _local3.m_xf;
var _local6:b2Vec2 = _local4.position;
var _local7:b2Vec2 = _local5.position;
var _local8:b2Vec2 = _arg1.GetAnchorA();
var _local9:b2Vec2 = _arg1.GetAnchorB();
var _local10:b2Color = s_jointColor;
switch (_arg1.m_type){
case b2Joint.e_distanceJoint:
m_debugDraw.DrawSegment(_local8, _local9, _local10);
break;
case b2Joint.e_pulleyJoint:
_local11 = (_arg1 as b2PulleyJoint);
_local12 = _local11.GetGroundAnchorA();
_local13 = _local11.GetGroundAnchorB();
m_debugDraw.DrawSegment(_local12, _local8, _local10);
m_debugDraw.DrawSegment(_local13, _local9, _local10);
m_debugDraw.DrawSegment(_local12, _local13, _local10);
break;
case b2Joint.e_mouseJoint:
m_debugDraw.DrawSegment(_local8, _local9, _local10);
break;
default:
if (_local2 != m_groundBody){
m_debugDraw.DrawSegment(_local6, _local8, _local10);
};
m_debugDraw.DrawSegment(_local8, _local9, _local10);
if (_local3 != m_groundBody){
m_debugDraw.DrawSegment(_local7, _local9, _local10);
};
};
}
public function RayCastAll(_arg1:b2Vec2, _arg2:b2Vec2):Array{
var result:Array;
var RayCastAllWrapper:Function;
var point1 = _arg1;
var point2 = _arg2;
RayCastAllWrapper = function (_arg1:b2Fixture, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Number):Number{
result[result.length] = _arg1;
return (1);
};
result = new Array();
RayCast(RayCastAllWrapper, point1, point2);
return (result);
}
public function QueryAABB(_arg1:Function, _arg2:b2AABB):void{
var broadPhase:IBroadPhase;
var WorldQueryWrapper:Function;
var callback = _arg1;
var aabb = _arg2;
WorldQueryWrapper = function (_arg1):Boolean{
return (callback(broadPhase.GetUserData(_arg1)));
};
broadPhase = m_contactManager.m_broadPhase;
broadPhase.Query(WorldQueryWrapper, aabb);
}
public function GetJointCount():int{
return (m_jointCount);
}
public function SetDebugDraw(_arg1:b2DebugDraw):void{
m_debugDraw = _arg1;
}
public function SetContinuousPhysics(_arg1:Boolean):void{
m_continuousPhysics = _arg1;
}
public function GetProxyCount():int{
return (m_contactManager.m_broadPhase.GetProxyCount());
}
public function DrawDebugData():void{
var _local2:int;
var _local3:b2Body;
var _local4:b2Fixture;
var _local5:b2Shape;
var _local6:b2Joint;
var _local7:IBroadPhase;
var _local11:b2Transform;
var _local16:b2Controller;
var _local17:b2Contact;
var _local18:b2Fixture;
var _local19:b2Fixture;
var _local20:b2Vec2;
var _local21:b2Vec2;
var _local22:b2AABB;
if (m_debugDraw == null){
return;
};
m_debugDraw.m_sprite.graphics.clear();
var _local1:uint = m_debugDraw.GetFlags();
var _local8:b2Vec2 = new b2Vec2();
var _local9:b2Vec2 = new b2Vec2();
var _local10:b2Vec2 = new b2Vec2();
var _local12:b2AABB = new b2AABB();
var _local13:b2AABB = new b2AABB();
var _local14:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()];
var _local15:b2Color = new b2Color(0, 0, 0);
if ((_local1 & b2DebugDraw.e_shapeBit)){
_local3 = m_bodyList;
while (_local3) {
_local11 = _local3.m_xf;
_local4 = _local3.GetFixtureList();
while (_local4) {
_local5 = _local4.GetShape();
if (_local3.IsActive() == false){
_local15.Set(0.5, 0.5, 0.3);
DrawShape(_local5, _local11, _local15);
} else {
if (_local3.GetType() == b2Body.b2_staticBody){
_local15.Set(0.5, 0.9, 0.5);
DrawShape(_local5, _local11, _local15);
} else {
if (_local3.GetType() == b2Body.b2_kinematicBody){
_local15.Set(0.5, 0.5, 0.9);
DrawShape(_local5, _local11, _local15);
} else {
if (_local3.IsAwake() == false){
_local15.Set(0.6, 0.6, 0.6);
DrawShape(_local5, _local11, _local15);
} else {
_local15.Set(0.9, 0.7, 0.7);
DrawShape(_local5, _local11, _local15);
};
};
};
};
_local4 = _local4.m_next;
};
_local3 = _local3.m_next;
};
};
if ((_local1 & b2DebugDraw.e_jointBit)){
_local6 = m_jointList;
while (_local6) {
DrawJoint(_local6);
_local6 = _local6.m_next;
};
};
if ((_local1 & b2DebugDraw.e_controllerBit)){
_local16 = m_controllerList;
while (_local16) {
_local16.Draw(m_debugDraw);
_local16 = _local16.m_next;
};
};
if ((_local1 & b2DebugDraw.e_pairBit)){
_local15.Set(0.3, 0.9, 0.9);
_local17 = m_contactManager.m_contactList;
while (_local17) {
_local18 = _local17.GetFixtureA();
_local19 = _local17.GetFixtureB();
_local20 = _local18.GetAABB().GetCenter();
_local21 = _local19.GetAABB().GetCenter();
m_debugDraw.DrawSegment(_local20, _local21, _local15);
_local17 = _local17.GetNext();
};
};
if ((_local1 & b2DebugDraw.e_aabbBit)){
_local7 = m_contactManager.m_broadPhase;
_local14 = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()];
_local3 = m_bodyList;
while (_local3) {
if (_local3.IsActive() == false){
} else {
_local4 = _local3.GetFixtureList();
while (_local4) {
_local22 = _local7.GetFatAABB(_local4.m_proxy);
_local14[0].Set(_local22.lowerBound.x, _local22.lowerBound.y);
_local14[1].Set(_local22.upperBound.x, _local22.lowerBound.y);
_local14[2].Set(_local22.upperBound.x, _local22.upperBound.y);
_local14[3].Set(_local22.lowerBound.x, _local22.upperBound.y);
m_debugDraw.DrawPolygon(_local14, 4, _local15);
_local4 = _local4.GetNext();
};
};
_local3 = _local3.GetNext();
};
};
if ((_local1 & b2DebugDraw.e_centerOfMassBit)){
_local3 = m_bodyList;
while (_local3) {
_local11 = s_xf;
_local11.R = _local3.m_xf.R;
_local11.position = _local3.GetWorldCenter();
m_debugDraw.DrawTransform(_local11);
_local3 = _local3.m_next;
};
};
}
public function DestroyBody(_arg1:b2Body):void{
var _local6:b2JointEdge;
var _local7:b2ControllerEdge;
var _local8:b2ContactEdge;
var _local9:b2Fixture;
if (IsLocked() == true){
return;
};
var _local2:b2JointEdge = _arg1.m_jointList;
while (_local2) {
_local6 = _local2;
_local2 = _local2.next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeJoint(_local6.joint);
};
DestroyJoint(_local6.joint);
};
var _local3:b2ControllerEdge = _arg1.m_controllerList;
while (_local3) {
_local7 = _local3;
_local3 = _local3.nextController;
_local7.controller.RemoveBody(_arg1);
};
var _local4:b2ContactEdge = _arg1.m_contactList;
while (_local4) {
_local8 = _local4;
_local4 = _local4.next;
m_contactManager.Destroy(_local8.contact);
};
_arg1.m_contactList = null;
var _local5:b2Fixture = _arg1.m_fixtureList;
while (_local5) {
_local9 = _local5;
_local5 = _local5.m_next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeFixture(_local9);
};
_local9.DestroyProxy(m_contactManager.m_broadPhase);
_local9.Destroy();
};
_arg1.m_fixtureList = null;
_arg1.m_fixtureCount = 0;
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_bodyList){
m_bodyList = _arg1.m_next;
};
m_bodyCount--;
}
b2internal function DrawShape(_arg1:b2Shape, _arg2:b2Transform, _arg3:b2Color):void{
var _local4:b2CircleShape;
var _local5:b2Vec2;
var _local6:Number;
var _local7:b2Vec2;
var _local8:int;
var _local9:b2PolygonShape;
var _local10:int;
var _local11:Array;
var _local12:Array;
var _local13:b2EdgeShape;
switch (_arg1.m_type){
case b2Shape.e_circleShape:
_local4 = (_arg1 as b2CircleShape);
_local5 = b2Math.MulX(_arg2, _local4.m_p);
_local6 = _local4.m_radius;
_local7 = _arg2.R.col1;
m_debugDraw.DrawSolidCircle(_local5, _local6, _local7, _arg3);
break;
case b2Shape.e_polygonShape:
_local9 = (_arg1 as b2PolygonShape);
_local10 = _local9.GetVertexCount();
_local11 = _local9.GetVertices();
_local12 = new Array(_local10);
_local8 = 0;
while (_local8 < _local10) {
_local12[_local8] = b2Math.MulX(_arg2, _local11[_local8]);
_local8++;
};
m_debugDraw.DrawSolidPolygon(_local12, _local10, _arg3);
break;
case b2Shape.e_edgeShape:
_local13 = (_arg1 as b2EdgeShape);
m_debugDraw.DrawSegment(b2Math.MulX(_arg2, _local13.GetVertex1()), b2Math.MulX(_arg2, _local13.GetVertex2()), _arg3);
break;
};
}
public function GetGroundBody():b2Body{
return (m_groundBody);
}
public function DestroyController(_arg1:b2Controller):void{
_arg1.Clear();
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1 == m_controllerList){
m_controllerList = _arg1.m_next;
};
m_controllerCount--;
}
b2internal function Solve(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local10:int;
var _local11:int;
var _local12:b2Body;
var _local13:b2ContactEdge;
var _local14:b2JointEdge;
var _local3:b2Controller = m_controllerList;
while (_local3) {
_local3.Step(_arg1);
_local3 = _local3.m_next;
};
var _local4:b2Island = m_island;
_local4.Initialize(m_bodyCount, m_contactCount, m_jointCount, null, m_contactManager.m_contactListener, m_contactSolver);
_local2 = m_bodyList;
while (_local2) {
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
_local2 = _local2.m_next;
};
var _local5:b2Contact = m_contactList;
while (_local5) {
_local5.m_flags = (_local5.m_flags & ~(b2Contact.e_islandFlag));
_local5 = _local5.m_next;
};
var _local6:b2Joint = m_jointList;
while (_local6) {
_local6.m_islandFlag = false;
_local6 = _local6.m_next;
};
var _local7:int = m_bodyCount;
var _local8:Array = s_stack;
var _local9:b2Body = m_bodyList;
while (_local9) {
if ((_local9.m_flags & b2Body.e_islandFlag)){
} else {
if ((((_local9.IsAwake() == false)) || ((_local9.IsActive() == false)))){
} else {
if (_local9.GetType() == b2Body.b2_staticBody){
} else {
_local4.Clear();
_local10 = 0;
var _temp1 = _local10;
_local10 = (_local10 + 1);
var _local15 = _temp1;
_local8[_local15] = _local9;
_local9.m_flags = (_local9.m_flags | b2Body.e_islandFlag);
while (_local10 > 0) {
--_local10;
_local2 = _local8[_local10];
_local4.AddBody(_local2);
if (_local2.IsAwake() == false){
_local2.SetAwake(true);
};
if (_local2.GetType() == b2Body.b2_staticBody){
} else {
_local13 = _local2.m_contactList;
while (_local13) {
if ((_local13.contact.m_flags & b2Contact.e_islandFlag)){
} else {
if ((((((_local13.contact.IsSensor() == true)) || ((_local13.contact.IsEnabled() == false)))) || ((_local13.contact.IsTouching() == false)))){
} else {
_local4.AddContact(_local13.contact);
_local13.contact.m_flags = (_local13.contact.m_flags | b2Contact.e_islandFlag);
_local12 = _local13.other;
if ((_local12.m_flags & b2Body.e_islandFlag)){
} else {
var _temp2 = _local10;
_local10 = (_local10 + 1);
var _local16 = _temp2;
_local8[_local16] = _local12;
_local12.m_flags = (_local12.m_flags | b2Body.e_islandFlag);
};
};
};
_local13 = _local13.next;
};
_local14 = _local2.m_jointList;
while (_local14) {
if (_local14.joint.m_islandFlag == true){
} else {
_local12 = _local14.other;
if (_local12.IsActive() == false){
} else {
_local4.AddJoint(_local14.joint);
_local14.joint.m_islandFlag = true;
if ((_local12.m_flags & b2Body.e_islandFlag)){
} else {
var _temp3 = _local10;
_local10 = (_local10 + 1);
_local16 = _temp3;
_local8[_local16] = _local12;
_local12.m_flags = (_local12.m_flags | b2Body.e_islandFlag);
};
};
};
_local14 = _local14.next;
};
};
};
_local4.Solve(_arg1, m_gravity, m_allowSleep);
_local11 = 0;
while (_local11 < _local4.m_bodyCount) {
_local2 = _local4.m_bodies[_local11];
if (_local2.GetType() == b2Body.b2_staticBody){
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
};
_local11++;
};
};
};
};
_local9 = _local9.m_next;
};
_local11 = 0;
while (_local11 < _local8.length) {
if (!_local8[_local11]){
break;
};
_local8[_local11] = null;
_local11++;
};
_local2 = m_bodyList;
while (_local2) {
if ((((_local2.IsAwake() == false)) || ((_local2.IsActive() == false)))){
} else {
if (_local2.GetType() == b2Body.b2_staticBody){
} else {
_local2.SynchronizeFixtures();
};
};
_local2 = _local2.m_next;
};
m_contactManager.FindNewContacts();
}
public function SetGravity(_arg1:b2Vec2):void{
m_gravity = _arg1;
}
public function SetContactFilter(_arg1:b2ContactFilter):void{
m_contactManager.m_contactFilter = _arg1;
}
b2internal function SolveTOI(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Fixture;
var _local4:b2Fixture;
var _local5:b2Body;
var _local6:b2Body;
var _local7:b2ContactEdge;
var _local8:b2Joint;
var _local11:b2Contact;
var _local12:b2Contact;
var _local13:Number;
var _local14:b2Body;
var _local15:int;
var _local16:int;
var _local17:b2TimeStep;
var _local18:int;
var _local19:Number;
var _local20:Number;
var _local21:b2JointEdge;
var _local22:b2Body;
var _local9:b2Island = m_island;
_local9.Initialize(m_bodyCount, b2Settings.b2_maxTOIContactsPerIsland, b2Settings.b2_maxTOIJointsPerIsland, null, m_contactManager.m_contactListener, m_contactSolver);
var _local10:Array = s_queue;
_local2 = m_bodyList;
while (_local2) {
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
_local2.m_sweep.t0 = 0;
_local2 = _local2.m_next;
};
_local11 = m_contactList;
while (_local11) {
_local11.m_flags = (_local11.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
_local11 = _local11.m_next;
};
_local8 = m_jointList;
while (_local8) {
_local8.m_islandFlag = false;
_local8 = _local8.m_next;
};
while (true) {
_local12 = null;
_local13 = 1;
_local11 = m_contactList;
for (;_local11;(_local11 = _local11.m_next)) {
if ((((((_local11.IsSensor() == true)) || ((_local11.IsEnabled() == false)))) || ((_local11.IsContinuous() == false)))){
} else {
_local19 = 1;
if ((_local11.m_flags & b2Contact.e_toiFlag)){
_local19 = _local11.m_toi;
} else {
_local3 = _local11.m_fixtureA;
_local4 = _local11.m_fixtureB;
_local5 = _local3.m_body;
_local6 = _local4.m_body;
if (((((!((_local5.GetType() == b2Body.b2_dynamicBody))) || ((_local5.IsAwake() == false)))) && (((!((_local6.GetType() == b2Body.b2_dynamicBody))) || ((_local6.IsAwake() == false)))))){
continue;
};
_local20 = _local5.m_sweep.t0;
if (_local5.m_sweep.t0 < _local6.m_sweep.t0){
_local20 = _local6.m_sweep.t0;
_local5.m_sweep.Advance(_local20);
} else {
if (_local6.m_sweep.t0 < _local5.m_sweep.t0){
_local20 = _local5.m_sweep.t0;
_local6.m_sweep.Advance(_local20);
};
};
_local19 = _local11.ComputeTOI(_local5.m_sweep, _local6.m_sweep);
b2Settings.b2Assert((((0 <= _local19)) && ((_local19 <= 1))));
if ((((_local19 > 0)) && ((_local19 < 1)))){
_local19 = (((1 - _local19) * _local20) + _local19);
if (_local19 > 1){
_local19 = 1;
};
};
_local11.m_toi = _local19;
_local11.m_flags = (_local11.m_flags | b2Contact.e_toiFlag);
};
if ((((Number.MIN_VALUE < _local19)) && ((_local19 < _local13)))){
_local12 = _local11;
_local13 = _local19;
};
};
};
if ((((_local12 == null)) || (((1 - (100 * Number.MIN_VALUE)) < _local13)))){
break;
};
_local3 = _local12.m_fixtureA;
_local4 = _local12.m_fixtureB;
_local5 = _local3.m_body;
_local6 = _local4.m_body;
s_backupA.Set(_local5.m_sweep);
s_backupB.Set(_local6.m_sweep);
_local5.Advance(_local13);
_local6.Advance(_local13);
_local12.Update(m_contactManager.m_contactListener);
_local12.m_flags = (_local12.m_flags & ~(b2Contact.e_toiFlag));
if ((((_local12.IsSensor() == true)) || ((_local12.IsEnabled() == false)))){
_local5.m_sweep.Set(s_backupA);
_local6.m_sweep.Set(s_backupB);
_local5.SynchronizeTransform();
_local6.SynchronizeTransform();
} else {
if (_local12.IsTouching() == false){
} else {
_local14 = _local5;
if (_local14.GetType() != b2Body.b2_dynamicBody){
_local14 = _local6;
};
_local9.Clear();
_local15 = 0;
_local16 = 0;
var _temp1 = _local16;
_local16 = (_local16 + 1);
_local10[(_local15 + _temp1)] = _local14;
_local14.m_flags = (_local14.m_flags | b2Body.e_islandFlag);
while (_local16 > 0) {
var _temp2 = _local15;
_local15 = (_local15 + 1);
_local2 = _local10[_temp2];
_local16--;
_local9.AddBody(_local2);
if (_local2.IsAwake() == false){
_local2.SetAwake(true);
};
if (_local2.GetType() != b2Body.b2_dynamicBody){
} else {
_local7 = _local2.m_contactList;
while (_local7) {
if (_local9.m_contactCount == _local9.m_contactCapacity){
break;
};
if ((_local7.contact.m_flags & b2Contact.e_islandFlag)){
} else {
if ((((((_local7.contact.IsSensor() == true)) || ((_local7.contact.IsEnabled() == false)))) || ((_local7.contact.IsTouching() == false)))){
} else {
_local9.AddContact(_local7.contact);
_local7.contact.m_flags = (_local7.contact.m_flags | b2Contact.e_islandFlag);
_local22 = _local7.other;
if ((_local22.m_flags & b2Body.e_islandFlag)){
} else {
if (_local22.GetType() != b2Body.b2_staticBody){
_local22.Advance(_local13);
_local22.SetAwake(true);
};
_local10[(_local15 + _local16)] = _local22;
_local16++;
_local22.m_flags = (_local22.m_flags | b2Body.e_islandFlag);
};
};
};
_local7 = _local7.next;
};
_local21 = _local2.m_jointList;
while (_local21) {
if (_local9.m_jointCount == _local9.m_jointCapacity){
} else {
if (_local21.joint.m_islandFlag == true){
} else {
_local22 = _local21.other;
if (_local22.IsActive() == false){
} else {
_local9.AddJoint(_local21.joint);
_local21.joint.m_islandFlag = true;
if ((_local22.m_flags & b2Body.e_islandFlag)){
} else {
if (_local22.GetType() != b2Body.b2_staticBody){
_local22.Advance(_local13);
_local22.SetAwake(true);
};
_local10[(_local15 + _local16)] = _local22;
_local16++;
_local22.m_flags = (_local22.m_flags | b2Body.e_islandFlag);
};
};
};
};
_local21 = _local21.next;
};
};
};
_local17 = s_timestep;
_local17.warmStarting = false;
_local17.dt = ((1 - _local13) * _arg1.dt);
_local17.inv_dt = (1 / _local17.dt);
_local17.dtRatio = 0;
_local17.velocityIterations = _arg1.velocityIterations;
_local17.positionIterations = _arg1.positionIterations;
_local9.SolveTOI(_local17);
_local18 = 0;
while (_local18 < _local9.m_bodyCount) {
_local2 = _local9.m_bodies[_local18];
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
if (_local2.IsAwake() == false){
} else {
if (_local2.GetType() != b2Body.b2_dynamicBody){
} else {
_local2.SynchronizeFixtures();
_local7 = _local2.m_contactList;
while (_local7) {
_local7.contact.m_flags = (_local7.contact.m_flags & ~(b2Contact.e_toiFlag));
_local7 = _local7.next;
};
};
};
_local18++;
};
_local18 = 0;
while (_local18 < _local9.m_contactCount) {
_local11 = _local9.m_contacts[_local18];
_local9.m_contacts[_local18].m_flags = (_local11.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
_local18++;
};
_local18 = 0;
while (_local18 < _local9.m_jointCount) {
_local8 = _local9.m_joints[_local18];
_local8.m_islandFlag = false;
_local18++;
};
m_contactManager.FindNewContacts();
};
};
};
}
public function GetJointList():b2Joint{
return (m_jointList);
}
public function GetContactCount():int{
return (m_contactCount);
}
public function GetBodyList():b2Body{
return (m_bodyList);
}
public function GetGravity():b2Vec2{
return (m_gravity);
}
public function RayCastOne(_arg1:b2Vec2, _arg2:b2Vec2):b2Fixture{
var result:b2Fixture;
var RayCastOneWrapper:Function;
var point1 = _arg1;
var point2 = _arg2;
RayCastOneWrapper = function (_arg1:b2Fixture, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Number):Number{
result = _arg1;
return (_arg4);
};
RayCast(RayCastOneWrapper, point1, point2);
return (result);
}
public function Validate():void{
m_contactManager.m_broadPhase.Validate();
}
public function SetWarmStarting(_arg1:Boolean):void{
m_warmStarting = _arg1;
}
public function QueryPoint(_arg1:Function, _arg2:b2Vec2):void{
var broadPhase:IBroadPhase;
var WorldQueryWrapper:Function;
var callback = _arg1;
var p = _arg2;
WorldQueryWrapper = function (_arg1):Boolean{
var _local2:b2Fixture = (broadPhase.GetUserData(_arg1) as b2Fixture);
if (_local2.TestPoint(p)){
return (callback(_local2));
};
return (true);
};
broadPhase = m_contactManager.m_broadPhase;
var aabb:b2AABB = new b2AABB();
aabb.lowerBound.Set((p.x - b2Settings.b2_linearSlop), (p.y - b2Settings.b2_linearSlop));
aabb.upperBound.Set((p.x + b2Settings.b2_linearSlop), (p.y + b2Settings.b2_linearSlop));
broadPhase.Query(WorldQueryWrapper, aabb);
}
public function CreateJoint(_arg1:b2JointDef):b2Joint{
var _local5:b2ContactEdge;
var _local2:b2Joint = b2Joint.Create(_arg1, null);
_local2.m_prev = null;
_local2.m_next = m_jointList;
if (m_jointList){
m_jointList.m_prev = _local2;
};
m_jointList = _local2;
m_jointCount++;
_local2.m_edgeA.joint = _local2;
_local2.m_edgeA.other = _local2.m_bodyB;
_local2.m_edgeA.prev = null;
_local2.m_edgeA.next = _local2.m_bodyA.m_jointList;
if (_local2.m_bodyA.m_jointList){
_local2.m_bodyA.m_jointList.prev = _local2.m_edgeA;
};
_local2.m_bodyA.m_jointList = _local2.m_edgeA;
_local2.m_edgeB.joint = _local2;
_local2.m_edgeB.other = _local2.m_bodyA;
_local2.m_edgeB.prev = null;
_local2.m_edgeB.next = _local2.m_bodyB.m_jointList;
if (_local2.m_bodyB.m_jointList){
_local2.m_bodyB.m_jointList.prev = _local2.m_edgeB;
};
_local2.m_bodyB.m_jointList = _local2.m_edgeB;
var _local3:b2Body = _arg1.bodyA;
var _local4:b2Body = _arg1.bodyB;
if (_arg1.collideConnected == false){
_local5 = _local4.GetContactList();
while (_local5) {
if (_local5.other == _local3){
_local5.contact.FlagForFiltering();
};
_local5 = _local5.next;
};
};
return (_local2);
}
public function GetContactList():b2Contact{
return (m_contactList);
}
public function DestroyJoint(_arg1:b2Joint):void{
var _local5:b2ContactEdge;
var _local2:Boolean = _arg1.m_collideConnected;
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_jointList){
m_jointList = _arg1.m_next;
};
var _local3:b2Body = _arg1.m_bodyA;
var _local4:b2Body = _arg1.m_bodyB;
_local3.SetAwake(true);
_local4.SetAwake(true);
if (_arg1.m_edgeA.prev){
_arg1.m_edgeA.prev.next = _arg1.m_edgeA.next;
};
if (_arg1.m_edgeA.next){
_arg1.m_edgeA.next.prev = _arg1.m_edgeA.prev;
};
if (_arg1.m_edgeA == _local3.m_jointList){
_local3.m_jointList = _arg1.m_edgeA.next;
};
_arg1.m_edgeA.prev = null;
_arg1.m_edgeA.next = null;
if (_arg1.m_edgeB.prev){
_arg1.m_edgeB.prev.next = _arg1.m_edgeB.next;
};
if (_arg1.m_edgeB.next){
_arg1.m_edgeB.next.prev = _arg1.m_edgeB.prev;
};
if (_arg1.m_edgeB == _local4.m_jointList){
_local4.m_jointList = _arg1.m_edgeB.next;
};
_arg1.m_edgeB.prev = null;
_arg1.m_edgeB.next = null;
b2Joint.Destroy(_arg1, null);
m_jointCount--;
if (_local2 == false){
_local5 = _local4.GetContactList();
while (_local5) {
if (_local5.other == _local3){
_local5.contact.FlagForFiltering();
};
_local5 = _local5.next;
};
};
}
public function SetContactListener(_arg1:b2ContactListener):void{
m_contactManager.m_contactListener = _arg1;
}
public function CreateController(_arg1:b2Controller):b2Controller{
if (_arg1.m_world != this){
throw (new Error("Controller can only be a member of one world"));
};
_arg1.m_next = m_controllerList;
_arg1.m_prev = null;
if (m_controllerList){
m_controllerList.m_prev = _arg1;
};
m_controllerList = _arg1;
m_controllerCount++;
_arg1.m_world = this;
return (_arg1);
}
public function QueryShape(_arg1:Function, _arg2:b2Shape, _arg3:b2Transform=null):void{
var broadPhase:IBroadPhase;
var WorldQueryWrapper:Function;
var callback = _arg1;
var shape = _arg2;
var transform = _arg3;
WorldQueryWrapper = function (_arg1):Boolean{
var _local2:b2Fixture = (broadPhase.GetUserData(_arg1) as b2Fixture);
if (b2Shape.TestOverlap(shape, transform, _local2.GetShape(), _local2.GetBody().GetTransform())){
return (callback(_local2));
};
return (true);
};
if (transform == null){
transform = new b2Transform();
transform.SetIdentity();
};
broadPhase = m_contactManager.m_broadPhase;
var aabb:b2AABB = new b2AABB();
shape.ComputeAABB(aabb, transform);
broadPhase.Query(WorldQueryWrapper, aabb);
}
public function CreateBody(_arg1:b2BodyDef):b2Body{
if (IsLocked() == true){
return (null);
};
var _local2:b2Body = new b2Body(_arg1, this);
_local2.m_prev = null;
_local2.m_next = m_bodyList;
if (m_bodyList){
m_bodyList.m_prev = _local2;
};
m_bodyList = _local2;
m_bodyCount++;
return (_local2);
}
public function RemoveController(_arg1:b2Controller):void{
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (m_controllerList == _arg1){
m_controllerList = _arg1.m_next;
};
m_controllerCount--;
}
public function SetDestructionListener(_arg1:b2DestructionListener):void{
m_destructionListener = _arg1;
}
public function RayCast(_arg1:Function, _arg2:b2Vec2, _arg3:b2Vec2):void{
var broadPhase:IBroadPhase;
var output:b2RayCastOutput;
var RayCastWrapper:Function;
var callback = _arg1;
var point1 = _arg2;
var point2 = _arg3;
RayCastWrapper = function (_arg1:b2RayCastInput, _arg2):Number{
var _local6:Number;
var _local7:b2Vec2;
var _local3:* = broadPhase.GetUserData(_arg2);
var _local4:b2Fixture = (_local3 as b2Fixture);
var _local5:Boolean = _local4.RayCast(output, _arg1);
if (_local5){
_local6 = output.fraction;
_local7 = new b2Vec2((((1 - _local6) * point1.x) + (_local6 * point2.x)), (((1 - _local6) * point1.y) + (_local6 * point2.y)));
return (callback(_local4, _local7, output.normal, _local6));
};
return (_arg1.maxFraction);
};
broadPhase = m_contactManager.m_broadPhase;
output = new b2RayCastOutput();
var input:b2RayCastInput = new b2RayCastInput(point1, point2);
broadPhase.RayCast(RayCastWrapper, input);
}
public function Step(_arg1:Number, _arg2:int, _arg3:int):void{
if ((m_flags & e_newFixture)){
m_contactManager.FindNewContacts();
m_flags = (m_flags & ~(e_newFixture));
};
m_flags = (m_flags | e_locked);
var _local4:b2TimeStep = s_timestep2;
_local4.dt = _arg1;
_local4.velocityIterations = _arg2;
_local4.positionIterations = _arg3;
if (_arg1 > 0){
_local4.inv_dt = (1 / _arg1);
} else {
_local4.inv_dt = 0;
};
_local4.dtRatio = (m_inv_dt0 * _arg1);
_local4.warmStarting = m_warmStarting;
m_contactManager.Collide();
if (_local4.dt > 0){
Solve(_local4);
};
if (((m_continuousPhysics) && ((_local4.dt > 0)))){
SolveTOI(_local4);
};
if (_local4.dt > 0){
m_inv_dt0 = _local4.inv_dt;
};
m_flags = (m_flags & ~(e_locked));
}
public function IsLocked():Boolean{
return (((m_flags & e_locked) > 0));
}
public function ClearForces():void{
var _local1:b2Body = m_bodyList;
while (_local1) {
_local1.m_force.SetZero();
_local1.m_torque = 0;
_local1 = _local1.m_next;
};
}
public function GetBodyCount():int{
return (m_bodyCount);
}
public function SetBroadPhase(_arg1:IBroadPhase):void{
var _local4:b2Fixture;
var _local2:IBroadPhase = m_contactManager.m_broadPhase;
m_contactManager.m_broadPhase = _arg1;
var _local3:b2Body = m_bodyList;
while (_local3) {
_local4 = _local3.m_fixtureList;
while (_local4) {
_local4.m_proxy = _arg1.CreateProxy(_local2.GetFatAABB(_local4.m_proxy), _local4);
_local4 = _local4.m_next;
};
_local3 = _local3.m_next;
};
}
public function AddController(_arg1:b2Controller):b2Controller{
_arg1.m_next = m_controllerList;
_arg1.m_prev = null;
m_controllerList = _arg1;
_arg1.m_world = this;
m_controllerCount++;
return (_arg1);
}
}
}//package Box2D.Dynamics
Section 94
//SoundShortcuts (caurina.transitions.properties.SoundShortcuts)
package caurina.transitions.properties {
import flash.media.*;
import caurina.transitions.*;
public class SoundShortcuts {
public function SoundShortcuts(){
trace("This is an static class and should not be instantiated.");
}
public static function init():void{
Tweener.registerSpecialProperty("_sound_volume", _sound_volume_get, _sound_volume_set);
Tweener.registerSpecialProperty("_sound_pan", _sound_pan_get, _sound_pan_set);
}
public static function _sound_pan_set(_arg1:Object, _arg2:Number, _arg3:Array, _arg4:Object=null):void{
var _local5:SoundTransform = _arg1.soundTransform;
_local5.pan = _arg2;
_arg1.soundTransform = _local5;
}
public static function _sound_volume_set(_arg1:Object, _arg2:Number, _arg3:Array, _arg4:Object=null):void{
var _local5:SoundTransform = _arg1.soundTransform;
_local5.volume = _arg2;
_arg1.soundTransform = _local5;
}
public static function _sound_pan_get(_arg1:Object, _arg2:Array, _arg3:Object=null):Number{
return (_arg1.soundTransform.pan);
}
public static function _sound_volume_get(_arg1:Object, _arg2:Array, _arg3:Object=null):Number{
return (_arg1.soundTransform.volume);
}
}
}//package caurina.transitions.properties
Section 95
//AuxFunctions (caurina.transitions.AuxFunctions)
package caurina.transitions {
public class AuxFunctions {
public static function concatObjects(... _args):Object{
var _local3:Object;
var _local5:String;
var _local2:Object = {};
var _local4:int;
while (_local4 < _args.length) {
_local3 = _args[_local4];
for (_local5 in _local3) {
if (_local3[_local5] == null){
delete _local2[_local5];
} else {
_local2[_local5] = _local3[_local5];
};
};
_local4++;
};
return (_local2);
}
public static function numberToG(_arg1:Number):Number{
return (((_arg1 & 0xFF00) >> 8));
}
public static function numberToR(_arg1:Number):Number{
return (((_arg1 & 0xFF0000) >> 16));
}
public static function isInArray(_arg1:String, _arg2:Array):Boolean{
var _local3:uint = _arg2.length;
var _local4:uint;
while (_local4 < _local3) {
if (_arg2[_local4] == _arg1){
return (true);
};
_local4++;
};
return (false);
}
public static function getObjectLength(_arg1:Object):uint{
var _local3:String;
var _local2:uint;
for (_local3 in _arg1) {
_local2++;
};
return (_local2);
}
public static function numberToB(_arg1:Number):Number{
return ((_arg1 & 0xFF));
}
}
}//package caurina.transitions
Section 96
//Equations (caurina.transitions.Equations)
package caurina.transitions {
public class Equations {
public function Equations(){
trace("Equations is a static class and should not be instantiated.");
}
public static function easeOutBounce(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
if (_arg1 < (1 / 2.75)){
return (((_arg3 * ((7.5625 * _arg1) * _arg1)) + _arg2));
};
if (_arg1 < (2 / 2.75)){
_arg1 = (_arg1 - (1.5 / 2.75));
return (((_arg3 * (((7.5625 * _arg1) * _arg1) + 0.75)) + _arg2));
};
if (_arg1 < (2.5 / 2.75)){
_arg1 = (_arg1 - (2.25 / 2.75));
return (((_arg3 * (((7.5625 * _arg1) * _arg1) + 0.9375)) + _arg2));
};
_arg1 = (_arg1 - (2.625 / 2.75));
return (((_arg3 * (((7.5625 * _arg1) * _arg1) + 0.984375)) + _arg2));
}
public static function easeInOutElastic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local7:Number;
if (_arg1 == 0){
return (_arg2);
};
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 == 2){
return ((_arg2 + _arg3));
};
var _local6:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.period)))) ? (_arg4 * (0.3 * 1.5)) : _arg5.period;
var _local8:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.amplitude)))) ? 0 : _arg5.amplitude;
if (((!(Boolean(_local8))) || ((_local8 < Math.abs(_arg3))))){
_local8 = _arg3;
_local7 = (_local6 / 4);
} else {
_local7 = ((_local6 / (2 * Math.PI)) * Math.asin((_arg3 / _local8)));
};
if (_arg1 < 1){
--_arg1;
return (((-0.5 * ((_local8 * Math.pow(2, (10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _local6)))) + _arg2));
};
--_arg1;
return ((((((_local8 * Math.pow(2, (-10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _local6))) * 0.5) + _arg3) + _arg2));
}
public static function easeInOutQuad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return (((((_arg3 / 2) * _arg1) * _arg1) + _arg2));
};
--_arg1;
return ((((-(_arg3) / 2) * ((_arg1 * (_arg1 - 2)) - 1)) + _arg2));
}
public static function easeInOutBounce(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (((easeInBounce((_arg1 * 2), 0, _arg3, _arg4) * 0.5) + _arg2));
};
return ((((easeOutBounce(((_arg1 * 2) - _arg4), 0, _arg3, _arg4) * 0.5) + (_arg3 * 0.5)) + _arg2));
}
public static function easeInOutBack(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local6:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.overshoot)))) ? 1.70158 : _arg5.overshoot;
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
_local6 = (_local6 * 1.525);
return ((((_arg3 / 2) * ((_arg1 * _arg1) * (((_local6 + 1) * _arg1) - _local6))) + _arg2));
};
_arg1 = (_arg1 - 2);
_local6 = (_local6 * 1.525);
return ((((_arg3 / 2) * (((_arg1 * _arg1) * (((_local6 + 1) * _arg1) + _local6)) + 2)) + _arg2));
}
public static function easeOutInCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutCubic((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInCubic(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeNone(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeOutBack(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local6:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.overshoot)))) ? 1.70158 : _arg5.overshoot;
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * (((_arg1 * _arg1) * (((_local6 + 1) * _arg1) + _local6)) + 1)) + _arg2));
}
public static function easeInOutSine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return ((((-(_arg3) / 2) * (Math.cos(((Math.PI * _arg1) / _arg4)) - 1)) + _arg2));
}
public static function easeInBack(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local6:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.overshoot)))) ? 1.70158 : _arg5.overshoot;
_arg1 = (_arg1 / _arg4);
return (((((_arg3 * _arg1) * _arg1) * (((_local6 + 1) * _arg1) - _local6)) + _arg2));
}
public static function easeInQuart(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return ((((((_arg3 * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
}
public static function easeOutInQuint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutQuint((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInQuint(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeOutInBounce(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutBounce((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInBounce(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
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(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return (((_arg1)==_arg4) ? (_arg2 + _arg3) : (((_arg3 * 1.001) * (-(Math.pow(2, ((-10 * _arg1) / _arg4))) + 1)) + _arg2));
}
public static function easeOutInBack(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutBack((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInBack(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeInExpo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return (((_arg1)==0) ? _arg2 : (((_arg3 * Math.pow(2, (10 * ((_arg1 / _arg4) - 1)))) + _arg2) - (_arg3 * 0.001)));
}
public static function easeInCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return (((((_arg3 * _arg1) * _arg1) * _arg1) + _arg2));
}
public static function easeInQuint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return (((((((_arg3 * _arg1) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
}
public static function easeInOutCirc(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return ((((-(_arg3) / 2) * (Math.sqrt((1 - (_arg1 * _arg1))) - 1)) + _arg2));
};
_arg1 = (_arg1 - 2);
return ((((_arg3 / 2) * (Math.sqrt((1 - (_arg1 * _arg1))) + 1)) + _arg2));
}
public static function easeInQuad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return ((((_arg3 * _arg1) * _arg1) + _arg2));
}
public static function easeInBounce(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return (((_arg3 - easeOutBounce((_arg4 - _arg1), 0, _arg3, _arg4)) + _arg2));
}
public static function easeOutInExpo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutExpo((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInExpo(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeOutQuart(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((-(_arg3) * ((((_arg1 * _arg1) * _arg1) * _arg1) - 1)) + _arg2));
}
public static function easeInSine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return ((((-(_arg3) * Math.cos(((_arg1 / _arg4) * (Math.PI / 2)))) + _arg3) + _arg2));
}
public static function easeInOutQuart(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return (((((((_arg3 / 2) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
};
_arg1 = (_arg1 - 2);
return ((((-(_arg3) / 2) * ((((_arg1 * _arg1) * _arg1) * _arg1) - 2)) + _arg2));
}
public static function easeOutQuad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return ((((-(_arg3) * _arg1) * (_arg1 - 2)) + _arg2));
}
public static function easeOutInElastic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutElastic((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInElastic(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeInElastic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local7:Number;
if (_arg1 == 0){
return (_arg2);
};
_arg1 = (_arg1 / _arg4);
if (_arg1 == 1){
return ((_arg2 + _arg3));
};
var _local6:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.period)))) ? (_arg4 * 0.3) : _arg5.period;
var _local8:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.amplitude)))) ? 0 : _arg5.amplitude;
if (((!(Boolean(_local8))) || ((_local8 < Math.abs(_arg3))))){
_local8 = _arg3;
_local7 = (_local6 / 4);
} else {
_local7 = ((_local6 / (2 * Math.PI)) * Math.asin((_arg3 / _local8)));
};
--_arg1;
return ((-(((_local8 * Math.pow(2, (10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _local6)))) + _arg2));
}
public static function easeOutCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * (((_arg1 * _arg1) * _arg1) + 1)) + _arg2));
}
public static function easeOutQuint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * (((((_arg1 * _arg1) * _arg1) * _arg1) * _arg1) + 1)) + _arg2));
}
public static function easeOutInQuad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutQuad((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInQuad(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeOutSine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return (((_arg3 * Math.sin(((_arg1 / _arg4) * (Math.PI / 2)))) + _arg2));
}
public static function easeInOutCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return ((((((_arg3 / 2) * _arg1) * _arg1) * _arg1) + _arg2));
};
_arg1 = (_arg1 - 2);
return ((((_arg3 / 2) * (((_arg1 * _arg1) * _arg1) + 2)) + _arg2));
}
public static function easeInOutQuint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return ((((((((_arg3 / 2) * _arg1) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
};
_arg1 = (_arg1 - 2);
return ((((_arg3 / 2) * (((((_arg1 * _arg1) * _arg1) * _arg1) * _arg1) + 2)) + _arg2));
}
public static function easeInCirc(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return (((-(_arg3) * (Math.sqrt((1 - (_arg1 * _arg1))) - 1)) + _arg2));
}
public static function easeOutInSine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutSine((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInSine(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeInOutExpo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 == 0){
return (_arg2);
};
if (_arg1 == _arg4){
return ((_arg2 + _arg3));
};
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return (((((_arg3 / 2) * Math.pow(2, (10 * (_arg1 - 1)))) + _arg2) - (_arg3 * 0.0005)));
};
--_arg1;
return (((((_arg3 / 2) * 1.0005) * (-(Math.pow(2, (-10 * _arg1))) + 2)) + _arg2));
}
public static function easeOutElastic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local7:Number;
if (_arg1 == 0){
return (_arg2);
};
_arg1 = (_arg1 / _arg4);
if (_arg1 == 1){
return ((_arg2 + _arg3));
};
var _local6:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.period)))) ? (_arg4 * 0.3) : _arg5.period;
var _local8:Number = (((!(Boolean(_arg5))) || (isNaN(_arg5.amplitude)))) ? 0 : _arg5.amplitude;
if (((!(Boolean(_local8))) || ((_local8 < Math.abs(_arg3))))){
_local8 = _arg3;
_local7 = (_local6 / 4);
} else {
_local7 = ((_local6 / (2 * Math.PI)) * Math.asin((_arg3 / _local8)));
};
return (((((_local8 * Math.pow(2, (-10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _local6))) + _arg3) + _arg2));
}
public static function easeOutCirc(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * Math.sqrt((1 - (_arg1 * _arg1)))) + _arg2));
}
public static function easeOutInQuart(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutQuart((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInQuart(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeOutInCirc(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutCirc((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInCirc(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
}
}//package caurina.transitions
Section 97
//PropertyInfoObj (caurina.transitions.PropertyInfoObj)
package caurina.transitions {
public class PropertyInfoObj {
public var modifierParameters:Array;
public var isSpecialProperty:Boolean;
public var valueComplete:Number;
public var modifierFunction:Function;
public var extra:Object;
public var valueStart:Number;
public var hasModifier:Boolean;
public var arrayIndex:Number;
public var originalValueComplete:Object;
public function PropertyInfoObj(_arg1:Number, _arg2:Number, _arg3:Object, _arg4:Number, _arg5:Object, _arg6:Boolean, _arg7:Function, _arg8:Array){
valueStart = _arg1;
valueComplete = _arg2;
originalValueComplete = _arg3;
arrayIndex = _arg4;
extra = _arg5;
isSpecialProperty = _arg6;
hasModifier = Boolean(_arg7);
modifierFunction = _arg7;
modifierParameters = _arg8;
}
public function toString():String{
var _local1 = "\n[PropertyInfoObj ";
_local1 = (_local1 + ("valueStart:" + String(valueStart)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("valueComplete:" + String(valueComplete)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("originalValueComplete:" + String(originalValueComplete)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("arrayIndex:" + String(arrayIndex)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("extra:" + String(extra)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("isSpecialProperty:" + String(isSpecialProperty)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("hasModifier:" + String(hasModifier)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("modifierFunction:" + String(modifierFunction)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("modifierParameters:" + String(modifierParameters)));
_local1 = (_local1 + "]\n");
return (_local1);
}
public function clone():PropertyInfoObj{
var _local1:PropertyInfoObj = new PropertyInfoObj(valueStart, valueComplete, originalValueComplete, arrayIndex, extra, isSpecialProperty, modifierFunction, modifierParameters);
return (_local1);
}
}
}//package caurina.transitions
Section 98
//SpecialProperty (caurina.transitions.SpecialProperty)
package caurina.transitions {
public class SpecialProperty {
public var parameters:Array;
public var getValue:Function;
public var preProcess:Function;
public var setValue:Function;
public function SpecialProperty(_arg1:Function, _arg2:Function, _arg3:Array=null, _arg4:Function=null){
getValue = _arg1;
setValue = _arg2;
parameters = _arg3;
preProcess = _arg4;
}
public function toString():String{
var _local1 = "";
_local1 = (_local1 + "[SpecialProperty ");
_local1 = (_local1 + ("getValue:" + String(getValue)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("setValue:" + String(setValue)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("parameters:" + String(parameters)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("preProcess:" + String(preProcess)));
_local1 = (_local1 + "]");
return (_local1);
}
}
}//package caurina.transitions
Section 99
//SpecialPropertyModifier (caurina.transitions.SpecialPropertyModifier)
package caurina.transitions {
public class SpecialPropertyModifier {
public var getValue:Function;
public var modifyValues:Function;
public function SpecialPropertyModifier(_arg1:Function, _arg2:Function){
modifyValues = _arg1;
getValue = _arg2;
}
public function toString():String{
var _local1 = "";
_local1 = (_local1 + "[SpecialPropertyModifier ");
_local1 = (_local1 + ("modifyValues:" + String(modifyValues)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("getValue:" + String(getValue)));
_local1 = (_local1 + "]");
return (_local1);
}
}
}//package caurina.transitions
Section 100
//SpecialPropertySplitter (caurina.transitions.SpecialPropertySplitter)
package caurina.transitions {
public class SpecialPropertySplitter {
public var parameters:Array;
public var splitValues:Function;
public function SpecialPropertySplitter(_arg1:Function, _arg2:Array){
splitValues = _arg1;
parameters = _arg2;
}
public function toString():String{
var _local1 = "";
_local1 = (_local1 + "[SpecialPropertySplitter ");
_local1 = (_local1 + ("splitValues:" + String(splitValues)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("parameters:" + String(parameters)));
_local1 = (_local1 + "]");
return (_local1);
}
}
}//package caurina.transitions
Section 101
//Tweener (caurina.transitions.Tweener)
package caurina.transitions {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class Tweener {
private static var _timeScale:Number = 1;
private static var _currentTimeFrame:Number;
private static var _specialPropertySplitterList:Object;
private static var _engineExists:Boolean = false;
private static var _specialPropertyModifierList:Object;
private static var _currentTime:Number;
private static var _tweenList:Array;
private static var _specialPropertyList:Object;
private static var _transitionList:Object;
private static var _inited:Boolean = false;
private static var __tweener_controller__:MovieClip;
public function Tweener(){
trace("Tweener is a static class and should not be instantiated.");
}
public static function registerSpecialPropertyModifier(_arg1:String, _arg2:Function, _arg3:Function):void{
if (!_inited){
init();
};
var _local4:SpecialPropertyModifier = new SpecialPropertyModifier(_arg2, _arg3);
_specialPropertyModifierList[_arg1] = _local4;
}
public static function registerSpecialProperty(_arg1:String, _arg2:Function, _arg3:Function, _arg4:Array=null, _arg5:Function=null):void{
if (!_inited){
init();
};
var _local6:SpecialProperty = new SpecialProperty(_arg2, _arg3, _arg4, _arg5);
_specialPropertyList[_arg1] = _local6;
}
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 _local1:int;
if (_tweenList.length == 0){
return (false);
};
_local1 = 0;
while (_local1 < _tweenList.length) {
if ((((_tweenList[_local1] == undefined)) || (!(_tweenList[_local1].isPaused)))){
if (!updateTweenByIndex(_local1)){
removeTweenByIndex(_local1);
};
if (_tweenList[_local1] == null){
removeTweenByIndex(_local1, true);
_local1--;
};
};
_local1++;
};
return (true);
}
public static function addCaller(_arg1:Object=null, _arg2:Object=null):Boolean{
var _local3:Number;
var _local4:Array;
var _local8:Function;
var _local9:TweenListObj;
var _local10:Number;
var _local11:String;
if (!Boolean(_arg1)){
return (false);
};
if ((_arg1 is Array)){
_local4 = _arg1.concat();
} else {
_local4 = [_arg1];
};
var _local5:Object = _arg2;
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
var _local6:Number = (isNaN(_local5.time)) ? 0 : _local5.time;
var _local7:Number = (isNaN(_local5.delay)) ? 0 : _local5.delay;
if (typeof(_local5.transition) == "string"){
_local11 = _local5.transition.toLowerCase();
_local8 = _transitionList[_local11];
} else {
_local8 = _local5.transition;
};
if (!Boolean(_local8)){
_local8 = _transitionList["easeoutexpo"];
};
_local3 = 0;
while (_local3 < _local4.length) {
if (_local5.useFrames == true){
_local9 = new TweenListObj(_local4[_local3], (_currentTimeFrame + (_local7 / _timeScale)), (_currentTimeFrame + ((_local7 + _local6) / _timeScale)), true, _local8, _local5.transitionParams);
} else {
_local9 = new TweenListObj(_local4[_local3], (_currentTime + ((_local7 * 1000) / _timeScale)), (_currentTime + (((_local7 * 1000) + (_local6 * 1000)) / _timeScale)), false, _local8, _local5.transitionParams);
};
_local9.properties = null;
_local9.onStart = _local5.onStart;
_local9.onUpdate = _local5.onUpdate;
_local9.onComplete = _local5.onComplete;
_local9.onOverwrite = _local5.onOverwrite;
_local9.onStartParams = _local5.onStartParams;
_local9.onUpdateParams = _local5.onUpdateParams;
_local9.onCompleteParams = _local5.onCompleteParams;
_local9.onOverwriteParams = _local5.onOverwriteParams;
_local9.onStartScope = _local5.onStartScope;
_local9.onUpdateScope = _local5.onUpdateScope;
_local9.onCompleteScope = _local5.onCompleteScope;
_local9.onOverwriteScope = _local5.onOverwriteScope;
_local9.onErrorScope = _local5.onErrorScope;
_local9.isCaller = true;
_local9.count = _local5.count;
_local9.waitFrames = _local5.waitFrames;
_tweenList.push(_local9);
if ((((_local6 == 0)) && ((_local7 == 0)))){
_local10 = (_tweenList.length - 1);
updateTweenByIndex(_local10);
removeTweenByIndex(_local10);
};
_local3++;
};
return (true);
}
public static function pauseAllTweens():Boolean{
var _local2:uint;
if (!Boolean(_tweenList)){
return (false);
};
var _local1:Boolean;
_local2 = 0;
while (_local2 < _tweenList.length) {
pauseTweenByIndex(_local2);
_local1 = true;
_local2++;
};
return (_local1);
}
public static function removeTweens(_arg1:Object, ... _args):Boolean{
var _local4:uint;
var _local3:Array = new Array();
_local4 = 0;
while (_local4 < _args.length) {
if ((((typeof(_args[_local4]) == "string")) && (!(AuxFunctions.isInArray(_args[_local4], _local3))))){
_local3.push(_args[_local4]);
};
_local4++;
};
return (affectTweens(removeTweenByIndex, _arg1, _local3));
}
public static function splitTweens(_arg1:Number, _arg2:Array):uint{
var _local5:uint;
var _local6:String;
var _local7:Boolean;
var _local3:TweenListObj = _tweenList[_arg1];
var _local4:TweenListObj = _local3.clone(false);
_local5 = 0;
while (_local5 < _arg2.length) {
_local6 = _arg2[_local5];
if (Boolean(_local3.properties[_local6])){
_local3.properties[_local6] = undefined;
delete _local3.properties[_local6];
};
_local5++;
};
for (_local6 in _local4.properties) {
_local7 = false;
_local5 = 0;
while (_local5 < _arg2.length) {
if (_arg2[_local5] == _local6){
_local7 = true;
break;
};
_local5++;
};
if (!_local7){
_local4.properties[_local6] = undefined;
delete _local4.properties[_local6];
};
};
_tweenList.push(_local4);
return ((_tweenList.length - 1));
}
public static function updateFrame():void{
_currentTimeFrame++;
}
public static function resumeTweenByIndex(_arg1:Number):Boolean{
var _local2:TweenListObj = _tweenList[_arg1];
if ((((_local2 == null)) || (!(_local2.isPaused)))){
return (false);
};
var _local3:Number = getCurrentTweeningTime(_local2);
_local2.timeStart = (_local2.timeStart + (_local3 - _local2.timePaused));
_local2.timeComplete = (_local2.timeComplete + (_local3 - _local2.timePaused));
_local2.timePaused = undefined;
_local2.isPaused = false;
return (true);
}
public static function getVersion():String{
return ("AS3 1.31.71");
}
public static function onEnterFrame(_arg1:Event):void{
updateTime();
updateFrame();
var _local2:Boolean;
_local2 = updateTweens();
if (!_local2){
stopEngine();
};
}
public static function updateTime():void{
_currentTime = getTimer();
}
private static function updateTweenByIndex(_arg1:Number):Boolean{
var tTweening:TweenListObj;
var mustUpdate:Boolean;
var nv:Number;
var t:Number;
var b:Number;
var c:Number;
var d:Number;
var pName:String;
var eventScope:Object;
var tScope:Object;
var tProperty:Object;
var pv:Number;
var i = _arg1;
tTweening = _tweenList[i];
if ((((tTweening == null)) || (!(Boolean(tTweening.scope))))){
return (false);
};
var isOver:Boolean;
var cTime:Number = getCurrentTweeningTime(tTweening);
if (cTime >= tTweening.timeStart){
tScope = tTweening.scope;
if (tTweening.isCaller){
do {
t = (((tTweening.timeComplete - tTweening.timeStart) / tTweening.count) * (tTweening.timesCalled + 1));
b = tTweening.timeStart;
c = (tTweening.timeComplete - tTweening.timeStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, b, c, d);
} while (!(cTime >= nv));
} 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;
try {
tTweening.onStart.apply(eventScope, tTweening.onStartParams);
} catch(e:Error) {
handleError(tTweening, e, "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;
try {
tTweening.onUpdate.apply(eventScope, tTweening.onUpdateParams);
} catch(e:Error) {
handleError(tTweening, e, "onUpdate");
};
};
} else {
tTweening.updatesSkipped++;
};
};
if (((isOver) && (Boolean(tTweening.onComplete)))){
eventScope = (Boolean(tTweening.onCompleteScope)) ? tTweening.onCompleteScope : tScope;
try {
tTweening.onComplete.apply(eventScope, tTweening.onCompleteParams);
} catch(e:Error) {
handleError(tTweening, e, "onComplete");
};
};
return (!(isOver));
};
return (true);
}
public static function setTimeScale(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
if (isNaN(_arg1)){
_arg1 = 1;
};
if (_arg1 < 1E-5){
_arg1 = 1E-5;
};
if (_arg1 != _timeScale){
if (_tweenList != null){
_local2 = 0;
while (_local2 < _tweenList.length) {
_local3 = getCurrentTweeningTime(_tweenList[_local2]);
_tweenList[_local2].timeStart = (_local3 - (((_local3 - _tweenList[_local2].timeStart) * _timeScale) / _arg1));
_tweenList[_local2].timeComplete = (_local3 - (((_local3 - _tweenList[_local2].timeComplete) * _timeScale) / _arg1));
if (_tweenList[_local2].timePaused != undefined){
_tweenList[_local2].timePaused = (_local3 - (((_local3 - _tweenList[_local2].timePaused) * _timeScale) / _arg1));
};
_local2++;
};
};
_timeScale = _arg1;
};
}
public static function resumeAllTweens():Boolean{
var _local2:uint;
if (!Boolean(_tweenList)){
return (false);
};
var _local1:Boolean;
_local2 = 0;
while (_local2 < _tweenList.length) {
resumeTweenByIndex(_local2);
_local1 = true;
_local2++;
};
return (_local1);
}
private static function handleError(_arg1:TweenListObj, _arg2:Error, _arg3:String):void{
var eventScope:Object;
var pTweening = _arg1;
var pError = _arg2;
var pCallBackName = _arg3;
if (((Boolean(pTweening.onError)) && ((pTweening.onError is Function)))){
eventScope = (Boolean(pTweening.onErrorScope)) ? pTweening.onErrorScope : pTweening.scope;
try {
pTweening.onError.apply(eventScope, [pTweening.scope, pError]);
} catch(metaError:Error) {
printError(((((String(pTweening.scope) + " raised an error while executing the 'onError' handler. Original error:\n ") + pError.getStackTrace()) + "\nonError error: ") + metaError.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 _local2:uint;
if (!Boolean(_tweenList)){
return (false);
};
var _local1:Boolean;
_local2 = 0;
while (_local2 < _tweenList.length) {
removeTweenByIndex(_local2);
_local1 = true;
_local2++;
};
return (_local1);
}
public static function addTween(_arg1:Object=null, _arg2:Object=null):Boolean{
var _local3:Number;
var _local4:Number;
var _local5:String;
var _local6:Array;
var _local13:Function;
var _local14:Object;
var _local15:TweenListObj;
var _local16:Number;
var _local17:Array;
var _local18:Array;
var _local19:Array;
var _local20:String;
if (!Boolean(_arg1)){
return (false);
};
if ((_arg1 is Array)){
_local6 = _arg1.concat();
} else {
_local6 = [_arg1];
};
var _local7:Object = TweenListObj.makePropertiesChain(_arg2);
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
var _local8:Number = (isNaN(_local7.time)) ? 0 : _local7.time;
var _local9:Number = (isNaN(_local7.delay)) ? 0 : _local7.delay;
var _local10:Array = new Array();
var _local11:Object = {time:true, delay:true, useFrames:true, skipUpdates:true, transition:true, transitionParams:true, onStart:true, onUpdate:true, onComplete:true, onOverwrite:true, onError:true, rounded:true, onStartParams:true, onUpdateParams:true, onCompleteParams:true, onOverwriteParams:true, onStartScope:true, onUpdateScope:true, onCompleteScope:true, onOverwriteScope:true, onErrorScope:true};
var _local12:Object = new Object();
for (_local5 in _local7) {
if (!_local11[_local5]){
if (_specialPropertySplitterList[_local5]){
_local17 = _specialPropertySplitterList[_local5].splitValues(_local7[_local5], _specialPropertySplitterList[_local5].parameters);
_local3 = 0;
while (_local3 < _local17.length) {
if (_specialPropertySplitterList[_local17[_local3].name]){
_local18 = _specialPropertySplitterList[_local17[_local3].name].splitValues(_local17[_local3].value, _specialPropertySplitterList[_local17[_local3].name].parameters);
_local4 = 0;
while (_local4 < _local18.length) {
_local10[_local18[_local4].name] = {valueStart:undefined, valueComplete:_local18[_local4].value, arrayIndex:_local18[_local4].arrayIndex, isSpecialProperty:false};
_local4++;
};
} else {
_local10[_local17[_local3].name] = {valueStart:undefined, valueComplete:_local17[_local3].value, arrayIndex:_local17[_local3].arrayIndex, isSpecialProperty:false};
};
_local3++;
};
} else {
if (_specialPropertyModifierList[_local5] != undefined){
_local19 = _specialPropertyModifierList[_local5].modifyValues(_local7[_local5]);
_local3 = 0;
while (_local3 < _local19.length) {
_local12[_local19[_local3].name] = {modifierParameters:_local19[_local3].parameters, modifierFunction:_specialPropertyModifierList[_local5].getValue};
_local3++;
};
} else {
_local10[_local5] = {valueStart:undefined, valueComplete:_local7[_local5]};
};
};
};
};
for (_local5 in _local10) {
if (_specialPropertyList[_local5] != undefined){
_local10[_local5].isSpecialProperty = true;
} else {
if (_local6[0][_local5] == undefined){
printError((((("The property '" + _local5) + "' doesn't seem to be a normal object property of ") + String(_local6[0])) + " or a registered special property."));
};
};
};
for (_local5 in _local12) {
if (_local10[_local5] != undefined){
_local10[_local5].modifierParameters = _local12[_local5].modifierParameters;
_local10[_local5].modifierFunction = _local12[_local5].modifierFunction;
};
};
if (typeof(_local7.transition) == "string"){
_local20 = _local7.transition.toLowerCase();
_local13 = _transitionList[_local20];
} else {
_local13 = _local7.transition;
};
if (!Boolean(_local13)){
_local13 = _transitionList["easeoutexpo"];
};
_local3 = 0;
while (_local3 < _local6.length) {
_local14 = new Object();
for (_local5 in _local10) {
_local14[_local5] = new PropertyInfoObj(_local10[_local5].valueStart, _local10[_local5].valueComplete, _local10[_local5].valueComplete, _local10[_local5].arrayIndex, {}, _local10[_local5].isSpecialProperty, _local10[_local5].modifierFunction, _local10[_local5].modifierParameters);
};
if (_local7.useFrames == true){
_local15 = new TweenListObj(_local6[_local3], (_currentTimeFrame + (_local9 / _timeScale)), (_currentTimeFrame + ((_local9 + _local8) / _timeScale)), true, _local13, _local7.transitionParams);
} else {
_local15 = new TweenListObj(_local6[_local3], (_currentTime + ((_local9 * 1000) / _timeScale)), (_currentTime + (((_local9 * 1000) + (_local8 * 1000)) / _timeScale)), false, _local13, _local7.transitionParams);
};
_local15.properties = _local14;
_local15.onStart = _local7.onStart;
_local15.onUpdate = _local7.onUpdate;
_local15.onComplete = _local7.onComplete;
_local15.onOverwrite = _local7.onOverwrite;
_local15.onError = _local7.onError;
_local15.onStartParams = _local7.onStartParams;
_local15.onUpdateParams = _local7.onUpdateParams;
_local15.onCompleteParams = _local7.onCompleteParams;
_local15.onOverwriteParams = _local7.onOverwriteParams;
_local15.onStartScope = _local7.onStartScope;
_local15.onUpdateScope = _local7.onUpdateScope;
_local15.onCompleteScope = _local7.onCompleteScope;
_local15.onOverwriteScope = _local7.onOverwriteScope;
_local15.onErrorScope = _local7.onErrorScope;
_local15.rounded = _local7.rounded;
_local15.skipUpdates = _local7.skipUpdates;
removeTweensByTime(_local15.scope, _local15.properties, _local15.timeStart, _local15.timeComplete);
_tweenList.push(_local15);
if ((((_local8 == 0)) && ((_local9 == 0)))){
_local16 = (_tweenList.length - 1);
updateTweenByIndex(_local16);
removeTweenByIndex(_local16);
};
_local3++;
};
return (true);
}
public static function registerTransition(_arg1:String, _arg2:Function):void{
if (!_inited){
init();
};
_transitionList[_arg1] = _arg2;
}
public static function printError(_arg1:String):void{
trace(("## [Tweener] Error: " + _arg1));
}
private static function affectTweens(_arg1:Function, _arg2:Object, _arg3:Array):Boolean{
var _local5:uint;
var _local6:Array;
var _local7:uint;
var _local8:uint;
var _local9:uint;
var _local4:Boolean;
if (!Boolean(_tweenList)){
return (false);
};
_local5 = 0;
while (_local5 < _tweenList.length) {
if (((_tweenList[_local5]) && ((_tweenList[_local5].scope == _arg2)))){
if (_arg3.length == 0){
_arg1(_local5);
_local4 = true;
} else {
_local6 = new Array();
_local7 = 0;
while (_local7 < _arg3.length) {
if (Boolean(_tweenList[_local5].properties[_arg3[_local7]])){
_local6.push(_arg3[_local7]);
};
_local7++;
};
if (_local6.length > 0){
_local8 = AuxFunctions.getObjectLength(_tweenList[_local5].properties);
if (_local8 == _local6.length){
_arg1(_local5);
_local4 = true;
} else {
_local9 = splitTweens(_local5, _local6);
_arg1(_local9);
_local4 = true;
};
};
};
};
_local5++;
};
return (_local4);
}
public static function getTweens(_arg1:Object):Array{
var _local2:uint;
var _local3:String;
if (!Boolean(_tweenList)){
return ([]);
};
var _local4:Array = new Array();
_local2 = 0;
while (_local2 < _tweenList.length) {
if (((Boolean(_tweenList[_local2])) && ((_tweenList[_local2].scope == _arg1)))){
for (_local3 in _tweenList[_local2].properties) {
_local4.push(_local3);
};
};
_local2++;
};
return (_local4);
}
public static function isTweening(_arg1:Object):Boolean{
var _local2:uint;
if (!Boolean(_tweenList)){
return (false);
};
_local2 = 0;
while (_local2 < _tweenList.length) {
if (((Boolean(_tweenList[_local2])) && ((_tweenList[_local2].scope == _arg1)))){
return (true);
};
_local2++;
};
return (false);
}
public static function pauseTweenByIndex(_arg1:Number):Boolean{
var _local2:TweenListObj = _tweenList[_arg1];
if ((((_local2 == null)) || (_local2.isPaused))){
return (false);
};
_local2.timePaused = getCurrentTweeningTime(_local2);
_local2.isPaused = true;
return (true);
}
public static function getCurrentTweeningTime(_arg1:Object):Number{
return ((_arg1.useFrames) ? _currentTimeFrame : _currentTime);
}
public static function getTweenCount(_arg1:Object):Number{
var _local2:uint;
if (!Boolean(_tweenList)){
return (0);
};
var _local3:Number = 0;
_local2 = 0;
while (_local2 < _tweenList.length) {
if (((Boolean(_tweenList[_local2])) && ((_tweenList[_local2].scope == _arg1)))){
_local3 = (_local3 + AuxFunctions.getObjectLength(_tweenList[_local2].properties));
};
_local2++;
};
return (_local3);
}
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(_arg1:Object, _arg2:Object, _arg3:Number, _arg4:Number):Boolean{
var removedLocally:Boolean;
var i:uint;
var pName:String;
var eventScope:Object;
var p_scope = _arg1;
var p_properties = _arg2;
var p_timeStart = _arg3;
var p_timeComplete = _arg4;
var removed:Boolean;
var tl:uint = _tweenList.length;
i = 0;
while (i < tl) {
if (((Boolean(_tweenList[i])) && ((p_scope == _tweenList[i].scope)))){
if ((((p_timeComplete > _tweenList[i].timeStart)) && ((p_timeStart < _tweenList[i].timeComplete)))){
removedLocally = false;
for (pName in _tweenList[i].properties) {
if (Boolean(p_properties[pName])){
if (Boolean(_tweenList[i].onOverwrite)){
eventScope = (Boolean(_tweenList[i].onOverwriteScope)) ? _tweenList[i].onOverwriteScope : _tweenList[i].scope;
try {
_tweenList[i].onOverwrite.apply(eventScope, _tweenList[i].onOverwriteParams);
} catch(e:Error) {
handleError(_tweenList[i], e, "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(_arg1:String, _arg2:Function, _arg3:Array=null):void{
if (!_inited){
init();
};
var _local4:SpecialPropertySplitter = new SpecialPropertySplitter(_arg2, _arg3);
_specialPropertySplitterList[_arg1] = _local4;
}
public static function removeTweenByIndex(_arg1:Number, _arg2:Boolean=false):Boolean{
_tweenList[_arg1] = null;
if (_arg2){
_tweenList.splice(_arg1, 1);
};
return (true);
}
public static function resumeTweens(_arg1:Object, ... _args):Boolean{
var _local4:uint;
var _local3:Array = new Array();
_local4 = 0;
while (_local4 < _args.length) {
if ((((typeof(_args[_local4]) == "string")) && (!(AuxFunctions.isInArray(_args[_local4], _local3))))){
_local3.push(_args[_local4]);
};
_local4++;
};
return (affectTweens(resumeTweenByIndex, _arg1, _local3));
}
public static function pauseTweens(_arg1:Object, ... _args):Boolean{
var _local4:uint;
var _local3:Array = new Array();
_local4 = 0;
while (_local4 < _args.length) {
if ((((typeof(_args[_local4]) == "string")) && (!(AuxFunctions.isInArray(_args[_local4], _local3))))){
_local3.push(_args[_local4]);
};
_local4++;
};
return (affectTweens(pauseTweenByIndex, _arg1, _local3));
}
}
}//package caurina.transitions
Section 102
//TweenListObj (caurina.transitions.TweenListObj)
package caurina.transitions {
public class TweenListObj {
public var hasStarted:Boolean;
public var onUpdate:Function;
public var useFrames:Boolean;
public var count:Number;
public var onOverwriteParams:Array;
public var timeStart:Number;
public var timeComplete:Number;
public var onStartParams:Array;
public var onUpdateScope:Object;
public var rounded:Boolean;
public var onUpdateParams:Array;
public var properties:Object;
public var onComplete:Function;
public var transitionParams:Object;
public var updatesSkipped:Number;
public var onStart:Function;
public var onOverwriteScope:Object;
public var skipUpdates:Number;
public var onStartScope:Object;
public var scope:Object;
public var isCaller:Boolean;
public var timePaused:Number;
public var transition:Function;
public var onCompleteParams:Array;
public var onError:Function;
public var timesCalled:Number;
public var onErrorScope:Object;
public var onOverwrite:Function;
public var isPaused:Boolean;
public var waitFrames:Boolean;
public var onCompleteScope:Object;
public function TweenListObj(_arg1:Object, _arg2:Number, _arg3:Number, _arg4:Boolean, _arg5:Function, _arg6:Object){
scope = _arg1;
timeStart = _arg2;
timeComplete = _arg3;
useFrames = _arg4;
transition = _arg5;
transitionParams = _arg6;
properties = new Object();
isPaused = false;
timePaused = undefined;
isCaller = false;
updatesSkipped = 0;
timesCalled = 0;
skipUpdates = 0;
hasStarted = false;
}
public function clone(_arg1:Boolean):TweenListObj{
var _local3:String;
var _local2:TweenListObj = new TweenListObj(scope, timeStart, timeComplete, useFrames, transition, transitionParams);
_local2.properties = new Array();
for (_local3 in properties) {
_local2.properties[_local3] = properties[_local3].clone();
};
_local2.skipUpdates = skipUpdates;
_local2.updatesSkipped = updatesSkipped;
if (!_arg1){
_local2.onStart = onStart;
_local2.onUpdate = onUpdate;
_local2.onComplete = onComplete;
_local2.onOverwrite = onOverwrite;
_local2.onError = onError;
_local2.onStartParams = onStartParams;
_local2.onUpdateParams = onUpdateParams;
_local2.onCompleteParams = onCompleteParams;
_local2.onOverwriteParams = onOverwriteParams;
_local2.onStartScope = onStartScope;
_local2.onUpdateScope = onUpdateScope;
_local2.onCompleteScope = onCompleteScope;
_local2.onOverwriteScope = onOverwriteScope;
_local2.onErrorScope = onErrorScope;
};
_local2.rounded = rounded;
_local2.isPaused = isPaused;
_local2.timePaused = timePaused;
_local2.isCaller = isCaller;
_local2.count = count;
_local2.timesCalled = timesCalled;
_local2.waitFrames = waitFrames;
_local2.hasStarted = hasStarted;
return (_local2);
}
public function toString():String{
var _local3:String;
var _local1 = "\n[TweenListObj ";
_local1 = (_local1 + ("scope:" + String(scope)));
_local1 = (_local1 + ", properties:");
var _local2:Boolean;
for (_local3 in properties) {
if (!_local2){
_local1 = (_local1 + ",");
};
_local1 = (_local1 + ("[name:" + properties[_local3].name));
_local1 = (_local1 + (",valueStart:" + properties[_local3].valueStart));
_local1 = (_local1 + (",valueComplete:" + properties[_local3].valueComplete));
_local1 = (_local1 + "]");
_local2 = false;
};
_local1 = (_local1 + (", timeStart:" + String(timeStart)));
_local1 = (_local1 + (", timeComplete:" + String(timeComplete)));
_local1 = (_local1 + (", useFrames:" + String(useFrames)));
_local1 = (_local1 + (", transition:" + String(transition)));
_local1 = (_local1 + (", transitionParams:" + String(transitionParams)));
if (skipUpdates){
_local1 = (_local1 + (", skipUpdates:" + String(skipUpdates)));
};
if (updatesSkipped){
_local1 = (_local1 + (", updatesSkipped:" + String(updatesSkipped)));
};
if (Boolean(onStart)){
_local1 = (_local1 + (", onStart:" + String(onStart)));
};
if (Boolean(onUpdate)){
_local1 = (_local1 + (", onUpdate:" + String(onUpdate)));
};
if (Boolean(onComplete)){
_local1 = (_local1 + (", onComplete:" + String(onComplete)));
};
if (Boolean(onOverwrite)){
_local1 = (_local1 + (", onOverwrite:" + String(onOverwrite)));
};
if (Boolean(onError)){
_local1 = (_local1 + (", onError:" + String(onError)));
};
if (onStartParams){
_local1 = (_local1 + (", onStartParams:" + String(onStartParams)));
};
if (onUpdateParams){
_local1 = (_local1 + (", onUpdateParams:" + String(onUpdateParams)));
};
if (onCompleteParams){
_local1 = (_local1 + (", onCompleteParams:" + String(onCompleteParams)));
};
if (onOverwriteParams){
_local1 = (_local1 + (", onOverwriteParams:" + String(onOverwriteParams)));
};
if (onStartScope){
_local1 = (_local1 + (", onStartScope:" + String(onStartScope)));
};
if (onUpdateScope){
_local1 = (_local1 + (", onUpdateScope:" + String(onUpdateScope)));
};
if (onCompleteScope){
_local1 = (_local1 + (", onCompleteScope:" + String(onCompleteScope)));
};
if (onOverwriteScope){
_local1 = (_local1 + (", onOverwriteScope:" + String(onOverwriteScope)));
};
if (onErrorScope){
_local1 = (_local1 + (", onErrorScope:" + String(onErrorScope)));
};
if (rounded){
_local1 = (_local1 + (", rounded:" + String(rounded)));
};
if (isPaused){
_local1 = (_local1 + (", isPaused:" + String(isPaused)));
};
if (timePaused){
_local1 = (_local1 + (", timePaused:" + String(timePaused)));
};
if (isCaller){
_local1 = (_local1 + (", isCaller:" + String(isCaller)));
};
if (count){
_local1 = (_local1 + (", count:" + String(count)));
};
if (timesCalled){
_local1 = (_local1 + (", timesCalled:" + String(timesCalled)));
};
if (waitFrames){
_local1 = (_local1 + (", waitFrames:" + String(waitFrames)));
};
if (hasStarted){
_local1 = (_local1 + (", hasStarted:" + String(hasStarted)));
};
_local1 = (_local1 + "]\n");
return (_local1);
}
public static function makePropertiesChain(_arg1:Object):Object{
var _local3:Object;
var _local4:Object;
var _local5:Object;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local2:Object = _arg1.base;
if (_local2){
_local3 = {};
if ((_local2 is Array)){
_local4 = [];
_local8 = 0;
while (_local8 < _local2.length) {
_local4.push(_local2[_local8]);
_local8++;
};
} else {
_local4 = [_local2];
};
_local4.push(_arg1);
_local6 = _local4.length;
_local7 = 0;
while (_local7 < _local6) {
if (_local4[_local7]["base"]){
_local5 = AuxFunctions.concatObjects(makePropertiesChain(_local4[_local7]["base"]), _local4[_local7]);
} else {
_local5 = _local4[_local7];
};
_local3 = AuxFunctions.concatObjects(_local3, _local5);
_local7++;
};
if (_local3["base"]){
delete _local3["base"];
};
return (_local3);
//unresolved jump
};
return (_arg1);
}
}
}//package caurina.transitions
Section 103
//CompleteBox (core.gamecomplete.CompleteBox)
package core.gamecomplete {
import flash.display.*;
import core.objects.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class CompleteBox extends Box {
public function CompleteBox(_arg1:Number, _arg2:Number):void{
super(_arg1, _arg2);
}
override public function update():void{
updateSkin();
leftLeg.update();
rightLeg.update();
tie.update();
checkLimit();
}
override protected function createSkin():void{
var _local1:Class = engine.assets.getAssetClass(SKIN_CLASS_NAME);
skin = new (_local1);
CompleteEngine.getInstance().canvas.player.addChild(skin);
updateSkin();
skinInner = (skin.getChildByName("inner") as MovieClip);
skinLeftLeg = (skinInner.getChildByName("leftLeg") as Sprite);
skinRightLeg = (skinInner.getChildByName("rightLeg") as Sprite);
skinTie = (skinInner.getChildByName("tie") as Sprite);
skinInner.stop();
skinDist = new Sprite();
skinDist.graphics.clear();
skinDist.graphics.lineStyle(0, 0xFF0000, 0.7);
engine.canvas.support.addChild(skinDist);
var _local2:int = (1 + Math.floor((Math.random() * 3)));
skinInner.gotoAndStop(_local2);
}
private function checkLimit():void{
var _local1:Number = body.GetLinearVelocity().y;
var _local2:Number = (body.GetPosition().y * CompleteEngine.getInstance().physScale);
if ((((_local1 > 0)) && ((_local2 > 520)))){
CompleteEngine.getInstance().destroyObject(this);
};
}
override public function destroy():void{
skin.parent.removeChild(skin);
CompleteEngine.getInstance().world.DestroyBody(body);
}
override protected function createBody():void{
var _local1:b2BodyDef = new b2BodyDef();
_local1.type = b2Body.b2_dynamicBody;
_local1.position.Set((x / engine.physScale), (y / engine.physScale));
_local1.userData = this;
body = CompleteEngine.getInstance().world.CreateBody(_local1);
var _local2:b2PolygonShape = new b2PolygonShape();
var _local3:Number = ((width / engine.physScale) / 2);
var _local4:Number = ((height / engine.physScale) / 2);
_local2.SetAsBox(_local3, _local4);
fixture = body.CreateFixture2(_local2, 1);
fixture.SetRestitution(0.2);
fixture.SetFriction(0.5);
fixture.SetUserData(this);
var _local5:b2FilterData = new b2FilterData();
_local5.categoryBits = 2;
_local5.maskBits = (0xFFFF & ~(2));
fixture.SetFilterData(_local5);
}
}
}//package core.gamecomplete
Section 104
//CompleteEngine (core.gamecomplete.CompleteEngine)
package core.gamecomplete {
import flash.events.*;
import core.*;
import flash.display.*;
import core.objects.*;
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class CompleteEngine {
private var container:Sprite;
public var world:b2World;
private var objects:Array;
public var physScale:Number;// = 30
public var canvas:CoreCanvas;
private var velocityIterations:int;// = 10
public var timeStep:Number;// = 0.0333333333333333
private var positionIterations:int;// = 10
private static var instance:CompleteEngine;
private function updateObjects():void{
var _local2:BaseObject;
var _local1:uint;
while (_local1 < objects.length) {
_local2 = objects[_local1];
_local2.update();
_local1++;
};
}
private function initBox2d():void{
var _local1:b2Vec2 = new b2Vec2(0, 10);
var _local2:Boolean;
world = new b2World(_local1, _local2);
var _local3:b2DebugDraw = new b2DebugDraw();
var _local4:Sprite = canvas.debug;
_local4.mouseEnabled = false;
_local4.mouseChildren = false;
_local3.SetSprite(_local4);
_local3.SetDrawScale(physScale);
_local3.SetFillAlpha(0.7);
_local3.SetLineThickness(1);
_local3.SetFlags(((b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit) | b2DebugDraw.e_pairBit));
world.SetDebugDraw(_local3);
}
private function init():void{
}
public function destroyObject(_arg1:BaseObject):void{
var _local2:int = objects.indexOf(_arg1);
objects.splice(_local2, 1);
_arg1.destroy();
if ((_arg1 is CompleteBox)){
createCompleteBox();
};
}
private function efHandler(_arg1:Event):void{
world.Step(timeStep, velocityIterations, positionIterations);
updateObjects();
}
private function initObjects():void{
objects = [];
var _local1:int;
while (_local1 < 5) {
createCompleteBox();
_local1++;
};
}
private function createCompleteBox():void{
var _local6:b2Vec2;
var _local1:Number = (100 + Math.floor((Math.random() * (640 - 200))));
var _local2:Number = (320 - _local1);
var _local3:CompleteBox = new CompleteBox(_local1, 520);
var _local4:Number = (_local2 * 0.1);
var _local5:Number = (50 + Math.floor((Math.random() * 30)));
_local6 = new b2Vec2(_local4, -(_local5));
var _local7:b2Vec2 = _local3.body.GetWorldCenter().Copy();
var _local8:Number = ((-7 + (Math.random() * 14)) / physScale);
_local7.x = (_local7.x + _local8);
_local3.body.ApplyImpulse(_local6, _local7);
objects.push(_local3);
}
public function destroy():void{
var _local2:BaseObject;
canvas.level.removeEventListener(Event.ENTER_FRAME, efHandler);
var _local1:int;
while (_local1 < objects.length) {
_local2 = objects[_local1];
_local2.destroy();
_local1++;
};
}
public function levelStart(_arg1:Sprite):void{
this.container = _arg1;
canvas = new CoreCanvas(_arg1);
initBox2d();
initObjects();
canvas.level.addEventListener(Event.ENTER_FRAME, efHandler);
}
public static function getInstance():CompleteEngine{
if (instance == null){
instance = new (CompleteEngine);
};
return (instance);
}
}
}//package core.gamecomplete
Section 105
//BoxZ (core.gfx.BoxZ)
package core.gfx {
import core.*;
import flash.display.*;
import caurina.transitions.*;
public class BoxZ {
private var engine:CoreEngine;
private var lifeTime:int;
private var time:int;
private var manager:BoxZManager;
private var startX:Number;
public var x:Number;
public var y:Number;
private var skin:Sprite;
private var radius:Number;
public function BoxZ(_arg1:Number, _arg2:Number, _arg3:BoxZManager):void{
this.x = _arg1;
this.y = _arg2;
this.manager = _arg3;
init();
}
private function createSkin():void{
var _local1:Class = engine.assets.getAssetClass("ZAsset");
skin = new (_local1);
engine.canvas.joints.addChild(skin);
updateSkin();
skin.alpha = 0;
Tweener.addTween(skin, {alpha:1, time:0.5, transition:"linear"});
}
private function updateSkin():void{
skin.x = x;
skin.y = y;
}
public function update():void{
y = (y - 1);
x = (startX + (radius * Math.sin((((time / 180) * Math.PI) * 6))));
updateSkin();
time++;
if (time == (lifeTime - 15)){
Tweener.addTween(skin, {alpha:0, time:0.5, transition:"linear"});
} else {
if (time >= lifeTime){
destroy();
};
};
}
private function init():void{
engine = CoreEngine.getInstance();
startX = x;
createSkin();
time = 0;
lifeTime = 100;
radius = Math.floor((5 + (Math.random() * 10)));
}
private function destroy():void{
skin.parent.removeChild(skin);
manager.removeZ(this);
}
}
}//package core.gfx
Section 106
//BoxZManager (core.gfx.BoxZManager)
package core.gfx {
import core.objects.*;
public class BoxZManager {
private var box:Box;
private var time:int;
private var timeDelay:int;
private var zs:Array;
public function BoxZManager(_arg1:Box):void{
this.box = _arg1;
init();
}
private function updateZs():void{
var _local2:BoxZ;
var _local1:int = (zs.length - 1);
while (_local1 >= 0) {
_local2 = zs[_local1];
_local2.update();
_local1--;
};
}
public function removeZ(_arg1:BoxZ):void{
var _local2:int = zs.indexOf(_arg1);
zs.splice(_local2, 1);
}
public function update():void{
if (box.state == Box.STATE_SLEEP){
time++;
if (time >= timeDelay){
time = 0;
createZ();
};
};
updateZs();
}
private function init():void{
zs = [];
time = 0;
timeDelay = 40;
}
private function createZ():void{
var _local1:Number = ((box.skin.x - 10) + (-10 + Math.floor((Math.random() * 20))));
var _local2:Number = ((box.skin.y - 30) + (-5 + Math.floor((Math.random() * 10))));
var _local3:BoxZ = new BoxZ(_local1, _local2, this);
zs.push(_local3);
}
}
}//package core.gfx
Section 107
//BaseObject (core.objects.BaseObject)
package core.objects {
import core.*;
import flash.display.*;
public class BaseObject {
protected var engine:CoreEngine;
public var x:Number;
public var y:Number;
public var skin:Sprite;
public function BaseObject(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
init();
}
protected function init():void{
engine = CoreEngine.getInstance();
}
public function update():void{
}
public function destroy():void{
}
}
}//package core.objects
Section 108
//BodyObject (core.objects.BodyObject)
package core.objects {
import core.*;
import flash.display.*;
import core.shapes.*;
import Box2D.Dynamics.*;
import flash.geom.*;
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import geom.*;
import caurina.transitions.*;
public class BodyObject extends BaseObject {
public var fixture:b2Fixture;
public var mat:BodyMaterial;
public var body:b2Body;
protected var isDead:Boolean;
public static const DYNAMIC_CIRCLE_CLASS_NAME:String = "DynamicCircleAsset";
public static const STICKY_CIRCLE_CLASS_NAME:String = "StickyCircleAsset";
public static const DYNAMIC_RECT_CLASS_NAME:String = "DynamicRectAsset";
public static const STATIC_CIRCLE_CLASS_NAME:String = "StaticCircleAsset";
public static const STICKY_RECT_CLASS_NAME:String = "StickyRectAsset";
public static const STATIC_RECT_CLASS_NAME:String = "StaticRectAsset";
public function BodyObject(_arg1:Number, _arg2:Number, _arg3:BodyMaterial):void{
this.mat = _arg3;
isDead = false;
super(_arg1, _arg2);
}
private function destroyJoints():void{
var _local2:BaseObject;
var _local1:int = (engine.objects.length - 1);
while (_local1 >= 0) {
_local2 = engine.objects[_local1];
if ((_local2 is DistanceJoint)){
checkDistJoint((_local2 as DistanceJoint));
} else {
if ((_local2 is Hinge)){
checkHinge((_local2 as Hinge));
};
};
_local1--;
};
}
protected function createBody():void{
var _local1:b2BodyDef = new b2BodyDef();
_local1.type = ((mat.density == 0)) ? b2Body.b2_staticBody : b2Body.b2_dynamicBody;
_local1.position.Set((x / engine.physScale), (y / engine.physScale));
_local1.userData = this;
_local1.linearDamping = 0.1;
_local1.angularDamping = 0.1;
body = engine.world.CreateBody(_local1);
}
private function checkHinge(_arg1:Hinge):void{
if ((((body == _arg1.joint.GetBodyA())) || ((body == _arg1.joint.GetBodyB())))){
engine.destroyObject(_arg1);
};
}
private function tweenComplete():void{
skin.parent.removeChild(skin);
}
public function collideWithKiller():void{
isDead = true;
}
override protected function init():void{
super.init();
createBody();
createSkin();
}
public function addPolyShape(_arg1:PolyShape, _arg2:Point):void{
createPolyShapeBody(_arg1, _arg2);
createPolyShapeSkin(_arg1, _arg2);
}
protected function createCircleShapeBody(_arg1:CircleShape, _arg2:Point):void{
var _local3:b2CircleShape = new b2CircleShape((_arg1.radius / engine.physScale));
_local3.SetLocalPosition(body.GetLocalPoint(new b2Vec2((_arg2.x / engine.physScale), (_arg2.y / engine.physScale))));
fixture = body.CreateFixture2(_local3, mat.density);
fixture.SetRestitution(mat.restitution);
fixture.SetFriction(mat.friction);
fixture.SetUserData(this);
var _local4:b2FilterData = new b2FilterData();
_local4.maskBits = (0xFFFF & ~(2));
fixture.SetFilterData(_local4);
body.SetAwake(true);
}
override public function update():void{
if (mat.density > 0){
updateSkin();
};
if (isDead){
engine.destroyObject(this);
};
}
protected function createSkin():void{
skin = new Sprite();
skin.graphics.clear();
engine.canvas.objects.addChild(skin);
updateSkin();
}
protected function createPolyShapeBody(_arg1:PolyShape, _arg2:Point):void{
var _local3:int;
var _local5:Array;
var _local6:Array;
var _local7:GeomPoly;
var _local4:GeomPoly = GeomPoly.getGeomPoly(0, 0, _arg1.vertices);
if (_local4.isConvex()){
actuallyCreatePolyShape(_arg1.vertices, _arg2);
} else {
_local5 = GeomPoly.triangulate(_local4);
if (_local5){
_local6 = GeomPoly.polygonizeTriangles(_local5);
if (_local6){
_local3 = 0;
while (_local3 < _local6.length) {
_local7 = _local6[_local3];
actuallyCreatePolyShape(_local7.vertices.reverse(), _arg2);
_local3++;
};
};
};
};
body.SetAwake(true);
}
public function addCircleShape(_arg1:CircleShape, _arg2:Point):void{
createCircleShapeBody(_arg1, _arg2);
createCircleShapeSkin(_arg1, _arg2);
}
private function checkDistJoint(_arg1:DistanceJoint):void{
if (_arg1.joint){
if ((((body == _arg1.joint.GetBodyA())) || ((body == _arg1.joint.GetBodyB())))){
engine.destroyObject(_arg1);
};
};
}
protected function updateSkin():void{
var _local1:b2Vec2;
var _local2:Number;
_local1 = body.GetPosition();
_local2 = body.GetAngle();
skin.x = (_local1.x * engine.physScale);
skin.y = (_local1.y * engine.physScale);
skin.rotation = ((_local2 * 180) / Math.PI);
}
public function collideWithBodyObj(_arg1:Number):void{
}
protected function createCircleShapeSkin(_arg1:CircleShape, _arg2:Point):void{
_arg1.draw(skin, mat);
}
protected function createPolyShapeSkin(_arg1:PolyShape, _arg2:Point):void{
_arg1.draw(skin, mat);
}
override public function destroy():void{
destroyJoints();
Tweener.addTween(skin, {scaleX:0, scaleY:0, time:0.3, transition:"easeoutquad", onComplete:tweenComplete});
engine.world.DestroyBody(body);
}
private function actuallyCreatePolyShape(_arg1:Array, _arg2:Point):void{
var _local7:b2Vec2;
var _local3:b2PolygonShape = new b2PolygonShape();
var _local4:Array = [];
var _local5:int;
while (_local5 < _arg1.length) {
_local7 = new b2Vec2();
_local7.SetV(body.GetLocalPoint(new b2Vec2(((_arg1[_local5].x + _arg2.x) / engine.physScale), ((_arg1[_local5].y + _arg2.y) / engine.physScale))));
_local4.push(_local7);
_local5++;
};
_local3.SetAsArray(_local4, _local4.length);
fixture = body.CreateFixture2(_local3, mat.density);
fixture.SetRestitution(mat.restitution);
fixture.SetFriction(mat.friction);
fixture.SetUserData(this);
var _local6:b2FilterData = new b2FilterData();
_local6.maskBits = (0xFFFF & ~(2));
fixture.SetFilterData(_local6);
}
}
}//package core.objects
Section 109
//Bottle (core.objects.Bottle)
package core.objects {
import core.*;
public class Bottle extends SimpleObject {
public function Bottle(_arg1:Number, _arg2:Number):void{
super(_arg1, _arg2);
}
override protected function init():void{
verticesRaw = [0, 0, 19, -1, 19, 19, 24, 28, 34, 31, 43, 38, 43, 97, 37, 104, -16, 104, -23, 99, -23, 38, -16, 32, -4, 28, 1, 19];
mat = new BodyMaterial(null);
mat.density = 0.2;
mat.friction = 0.1;
mat.restitution = 0.4;
super.init();
}
override protected function createSkin():void{
var _local1:Class = engine.assets.getAssetClass("BottleAsset");
skin = new (_local1);
engine.canvas.objects.addChild(skin);
}
}
}//package core.objects
Section 110
//Box (core.objects.Box)
package core.objects {
import core.*;
import flash.display.*;
import Box2D.Dynamics.*;
import flash.geom.*;
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import core.gfx.*;
public class Box extends BodyObject {
protected var skinDist:Sprite;
protected var leftLeg:BoxLeg;
protected var skinLeftLeg:Sprite;
protected var width:Number;// = 60
protected var tie:BoxTie;
public var totalDist:Number;
protected var rightLeg:BoxLeg;
protected var skinTie:Sprite;
public var state:String;
protected var skinInner:MovieClip;
protected var lastPoint:Point;
protected var height:Number;// = 60
protected var zManager:BoxZManager;
protected var skinRightLeg:Sprite;
public static const STATE_DISTURBED:String = "StateDisturbed";
public static const SKIN_CLASS_NAME:String = "BoxAsset";
public static const REQUIRED_DISTANCE:Number = 100;
public static const STATE_SLEEP:String = "StateSleep";
public static const STATE_AWAKE:String = "StateAwake";
public function Box(_arg1:Number, _arg2:Number):void{
super(_arg1, _arg2, new BodyMaterial(BodyMaterial.TYPE_BOX));
}
private function updateState():void{
var _local5:int;
var _local6:Number;
var _local1:b2Vec2 = body.GetPosition();
var _local2:Number = (_local1.x * engine.physScale);
var _local3:Number = (_local1.y * engine.physScale);
var _local4:Number = (((lastPoint.x - _local2) * (lastPoint.x - _local2)) + ((lastPoint.y - _local3) * (lastPoint.y - _local3)));
if (_local4 > 1){
};
lastPoint.x = _local2;
lastPoint.y = _local3;
totalDist = (totalDist + _local4);
if ((((totalDist > REQUIRED_DISTANCE)) && (!((state == STATE_AWAKE))))){
state = STATE_AWAKE;
_local5 = (3 + Math.floor((Math.random() * 3)));
skinInner.gotoAndStop(_local5);
engine.levelComplete();
};
if (state == STATE_SLEEP){
_local6 = body.GetLinearVelocity().Length();
if (_local6 > 0.2){
state = STATE_DISTURBED;
skinInner.gotoAndStop(2);
};
} else {
if (state == STATE_DISTURBED){
if (!body.IsAwake()){
state = STATE_SLEEP;
skinInner.gotoAndStop(1);
};
};
};
}
override public function update():void{
updateState();
updateSkin();
leftLeg.update();
rightLeg.update();
tie.update();
zManager.update();
}
override protected function init():void{
super.init();
totalDist = 0;
state = STATE_SLEEP;
leftLeg = new BoxLeg((x - 20), (y + 27), this, skinLeftLeg);
rightLeg = new BoxLeg((x + 20), (y + 27), this, skinRightLeg);
tie = new BoxTie(x, (y + 29), this, skinTie);
lastPoint = new Point(x, y);
zManager = new BoxZManager(this);
}
override protected function createSkin():void{
var _local1:Class = engine.assets.getAssetClass(SKIN_CLASS_NAME);
skin = new (_local1);
engine.canvas.player.addChild(skin);
updateSkin();
skinInner = (skin.getChildByName("inner") as MovieClip);
skinLeftLeg = (skinInner.getChildByName("leftLeg") as Sprite);
skinRightLeg = (skinInner.getChildByName("rightLeg") as Sprite);
skinTie = (skinInner.getChildByName("tie") as Sprite);
skinInner.stop();
skinDist = new Sprite();
skinDist.graphics.clear();
skinDist.graphics.lineStyle(0, 0xFF0000, 0.7);
engine.canvas.support.addChild(skinDist);
}
override protected function createBody():void{
var _local1:b2BodyDef = new b2BodyDef();
_local1.type = b2Body.b2_dynamicBody;
_local1.position.Set((x / engine.physScale), (y / engine.physScale));
_local1.userData = this;
body = engine.world.CreateBody(_local1);
var _local2:b2PolygonShape = new b2PolygonShape();
var _local3:Number = ((width / engine.physScale) / 2);
var _local4:Number = ((height / engine.physScale) / 2);
_local2.SetAsBox(_local3, _local4);
fixture = body.CreateFixture2(_local2, 1);
fixture.SetRestitution(0.2);
fixture.SetFriction(0.5);
fixture.SetUserData(this);
}
}
}//package core.objects
Section 111
//BoxLeg (core.objects.BoxLeg)
package core.objects {
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
public class BoxLeg extends BaseObject {
private var body:b2Body;
private var joint:b2RevoluteJoint;
private var box:Box;
private var fixture:b2Fixture;
public function BoxLeg(_arg1:Number, _arg2:Number, _arg3:Box, _arg4:Sprite):void{
this.box = _arg3;
this.skin = _arg4;
super(_arg1, _arg2);
}
private function updateSkin():void{
var _local1:Number = body.GetAngle();
skin.rotation = (-(box.skin.rotation) + ((_local1 * 180) / Math.PI));
}
override public function update():void{
updateSkin();
}
override protected function init():void{
super.init();
createBody();
}
private function createBody():void{
var _local1:Number;
_local1 = 5;
var _local2:Number = 30;
var _local3:b2BodyDef = new b2BodyDef();
_local3.type = b2Body.b2_dynamicBody;
_local3.position.Set((x / engine.physScale), ((y + (_local2 / 2)) / engine.physScale));
_local3.angularDamping = 5;
_local3.userData = this;
body = engine.world.CreateBody(_local3);
var _local4:b2PolygonShape = new b2PolygonShape();
_local4.SetAsBox(((_local1 / 2) / engine.physScale), ((_local2 / 2) / engine.physScale));
fixture = body.CreateFixture2(_local4, 0.001);
fixture.SetUserData(this);
var _local5:b2FilterData = new b2FilterData();
_local5.categoryBits = 2;
_local5.maskBits = (0xFFFF & ~(2));
fixture.SetFilterData(_local5);
var _local6:b2RevoluteJointDef = new b2RevoluteJointDef();
var _local7:b2Vec2 = new b2Vec2((x / engine.physScale), (y / engine.physScale));
_local6.Initialize(box.body, body, _local7);
joint = (engine.world.CreateJoint(_local6) as b2RevoluteJoint);
}
}
}//package core.objects
Section 112
//BoxTie (core.objects.BoxTie)
package core.objects {
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
public class BoxTie extends BaseObject {
private var body:b2Body;
private var joint:b2RevoluteJoint;
private var box:Box;
private var fixture:b2Fixture;
public function BoxTie(_arg1:Number, _arg2:Number, _arg3:Box, _arg4:Sprite):void{
this.box = _arg3;
this.skin = _arg4;
super(_arg1, _arg2);
}
private function updateSkin():void{
var _local1:Number = body.GetAngle();
skin.rotation = (-(box.skin.rotation) + ((_local1 * 180) / Math.PI));
}
override public function update():void{
updateSkin();
}
override protected function init():void{
super.init();
createBody();
}
private function createBody():void{
var _local1:Number;
_local1 = 5;
var _local2:Number = 30;
var _local3:b2BodyDef = new b2BodyDef();
_local3.type = b2Body.b2_dynamicBody;
_local3.position.Set((x / engine.physScale), ((y + (_local2 / 2)) / engine.physScale));
_local3.angularDamping = 5;
_local3.userData = this;
body = engine.world.CreateBody(_local3);
var _local4:b2PolygonShape = new b2PolygonShape();
_local4.SetAsBox(((_local1 / 2) / engine.physScale), ((_local2 / 2) / engine.physScale));
fixture = body.CreateFixture2(_local4, 0.001);
fixture.SetUserData(this);
var _local5:b2FilterData = new b2FilterData();
_local5.categoryBits = 2;
_local5.maskBits = (0xFFFF & ~(2));
fixture.SetFilterData(_local5);
var _local6:b2RevoluteJointDef = new b2RevoluteJointDef();
var _local7:b2Vec2 = new b2Vec2((x / engine.physScale), (y / engine.physScale));
_local6.Initialize(box.body, body, _local7);
joint = (engine.world.CreateJoint(_local6) as b2RevoluteJoint);
}
}
}//package core.objects
Section 113
//Chain (core.objects.Chain)
package core.objects {
import flash.display.*;
import Box2D.Dynamics.*;
import flash.geom.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
public class Chain extends BaseObject {
private var links:Array;
public var hinges:Array;
public var y2:Number;
public var x2:Number;
public function Chain(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
this.x2 = _arg3;
this.y2 = _arg4;
super(_arg1, _arg2);
}
protected function getBodyObjByPoint(_arg1:Point):BodyObject{
var _local3:BaseObject;
var _local4:BodyObject;
var _local2:int;
while (_local2 < engine.objects.length) {
_local3 = engine.objects[_local2];
if ((_local3 is BodyObject)){
_local4 = (_local3 as BodyObject);
if (_local4.skin.hitTestPoint(_arg1.x, _arg1.y, true)){
return (_local4);
};
};
_local2++;
};
return (null);
}
private function createPhys():void{
var _local5:int;
var _local6:ChainLink;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:ChainLink;
var _local18:ChainLink;
var _local1:Number = (x2 - x);
var _local2:Number = (y2 - y);
var _local3:Number = Math.sqrt((((x2 - x) * (x2 - x)) + ((y2 - y) * (y2 - y))));
var _local4:int = Math.floor((_local3 / ChainLink.LENGTH));
links = [];
hinges = [];
_local5 = 0;
while (_local5 < _local4) {
_local13 = (x + ((_local1 / _local4) * _local5));
_local14 = (y + ((_local2 / _local4) * _local5));
_local15 = (x + ((_local1 / _local4) * (_local5 + 1)));
_local16 = (y + ((_local2 / _local4) * (_local5 + 1)));
_local6 = new ChainLink(_local13, _local14, _local15, _local16, this);
links.push(_local6);
_local5++;
};
_local5 = 1;
while (_local5 < links.length) {
_local17 = links[(_local5 - 1)];
_local18 = links[_local5];
_local13 = (x + ((_local1 / _local4) * _local5));
_local14 = (y + ((_local2 / _local4) * _local5));
createHinge(_local13, _local14, _local17.body, _local18.body);
_local5++;
};
var _local7:ChainLink = links[0];
var _local8:ChainLink = links[(links.length - 1)];
var _local9:BodyObject = getBodyObjByPoint(new Point(x, y));
var _local10:b2Body = (_local9) ? _local9.body : engine.world.GetGroundBody();
var _local11:BodyObject = getBodyObjByPoint(new Point(x2, y2));
var _local12:b2Body = (_local11) ? _local11.body : engine.world.GetGroundBody();
createHinge(x, y, _local10, _local7.body);
createHinge(x2, y2, _local12, _local8.body);
}
private function createHinge(_arg1:Number, _arg2:Number, _arg3:b2Body, _arg4:b2Body):void{
var _local5:b2RevoluteJointDef = new b2RevoluteJointDef();
var _local6:b2Vec2 = new b2Vec2((_arg1 / engine.physScale), (_arg2 / engine.physScale));
_local5.Initialize(_arg3, _arg4, _local6);
_local5.userData = this;
var _local7:b2RevoluteJoint = (engine.world.CreateJoint(_local5) as b2RevoluteJoint);
hinges.push(_local7);
}
protected function createSkin():void{
skin = new Sprite();
engine.canvas.joints.addChild(skin);
}
override protected function init():void{
super.init();
createSkin();
createPhys();
}
override public function update():void{
updateLinks();
}
public function destroyLink(_arg1:ChainLink):void{
var _local2:int = links.indexOf(_arg1);
links.splice(_local2, 1);
_arg1.destroy();
}
private function updateLinks():void{
var _local2:ChainLink;
var _local1:int;
while (_local1 < links.length) {
_local2 = links[_local1];
_local2.update();
_local1++;
};
}
}
}//package core.objects
Section 114
//ChainLink (core.objects.ChainLink)
package core.objects {
import core.*;
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
public class ChainLink extends BaseObject {
private var mat:BodyMaterial;
private var chain:Chain;
private var isDead:Boolean;
private var fixture:b2Fixture;
private var startAngle:Number;
private var x2:Number;
private var y2:Number;
public var body:b2Body;
public static const LENGTH:Number = 20;
public static const HEIGHT:Number = 10;
public function ChainLink(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Chain):void{
this.x2 = _arg3;
this.y2 = _arg4;
this.chain = _arg5;
super(_arg1, _arg2);
}
private function destroyJoints():void{
var _local2:b2RevoluteJoint;
var _local1:int = (chain.hinges.length - 1);
while (_local1 >= 0) {
_local2 = chain.hinges[_local1];
if ((((_local2.GetBodyA() == body)) || ((_local2.GetBodyB() == body)))){
chain.hinges.splice(_local1, 1);
engine.world.DestroyJoint(_local2);
};
_local1--;
};
}
private function updateSkin():void{
var _local1:b2Vec2 = body.GetPosition();
var _local2:Number = body.GetAngle();
skin.x = (_local1.x * engine.physScale);
skin.y = (_local1.y * engine.physScale);
skin.rotation = (((startAngle + _local2) * 180) / Math.PI);
}
private function createSkin():void{
skin = new Sprite();
chain.skin.addChild(skin);
var _local1:Class = engine.assets.getAssetClass("ChainLinkAsset");
var _local2:Sprite = new (_local1);
skin.addChild(_local2);
updateSkin();
}
public function collideWithKiller():void{
isDead = true;
}
override protected function init():void{
super.init();
isDead = false;
mat = new BodyMaterial(BodyMaterial.TYPE_WOOD);
createBody();
createSkin();
}
override public function update():void{
updateSkin();
if (isDead){
chain.destroyLink(this);
};
}
override public function destroy():void{
destroyJoints();
skin.parent.removeChild(skin);
engine.world.DestroyBody(body);
}
private function createBody():void{
var _local4:Number;
startAngle = Math.atan2((y2 - y), (x2 - x));
var _local1:Number = (x + ((x2 - x) / 2));
var _local2:Number = (y + ((y2 - y) / 2));
var _local3:Number = ((LENGTH / 2) / engine.physScale);
_local4 = ((HEIGHT / 2) / engine.physScale);
var _local5:b2BodyDef = new b2BodyDef();
_local5.type = b2Body.b2_dynamicBody;
_local5.position.Set((_local1 / engine.physScale), (_local2 / engine.physScale));
_local5.userData = this;
_local5.linearDamping = 0.1;
_local5.angularDamping = 0.1;
body = engine.world.CreateBody(_local5);
var _local6:b2PolygonShape = new b2PolygonShape();
_local6.SetAsOrientedBox(_local3, _local4, new b2Vec2(0, 0), startAngle);
fixture = body.CreateFixture2(_local6, mat.density);
fixture.SetFriction(mat.friction);
fixture.SetRestitution(mat.restitution);
fixture.SetUserData(this);
var _local7:b2FilterData = new b2FilterData();
_local7.categoryBits = 4;
_local7.maskBits = ((0xFFFF & ~(2)) & ~(4));
fixture.SetFilterData(_local7);
}
}
}//package core.objects
Section 115
//DistanceJoint (core.objects.DistanceJoint)
package core.objects {
import flash.display.*;
import Box2D.Dynamics.*;
import flash.geom.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
public class DistanceJoint extends BaseObject {
private var skinAnchor2:Sprite;
private var skinContainer:Sprite;
public var joint:b2DistanceJoint;
private var y2:Number;
private var x2:Number;
private var skinAnchor1:Sprite;
public static const SKIN_CLASS_NAME:String = "DistanceJointAsset";
public function DistanceJoint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
this.x2 = _arg3;
this.y2 = _arg4;
super(_arg1, _arg2);
}
protected function getBodyByPoint(_arg1:Point):b2Body{
var _local3:BaseObject;
var _local4:BodyObject;
var _local2:int;
while (_local2 < engine.objects.length) {
_local3 = engine.objects[_local2];
if ((_local3 is BodyObject)){
_local4 = (_local3 as BodyObject);
if (_local4.skin.hitTestPoint(_arg1.x, _arg1.y, true)){
return (_local4.body);
};
};
_local2++;
};
return (engine.world.GetGroundBody());
}
private function updateSkin():void{
var _local1:b2Vec2 = joint.GetAnchorA().Copy();
var _local2:b2Vec2 = joint.GetAnchorB().Copy();
_local1.Multiply(engine.physScale);
_local2.Multiply(engine.physScale);
var _local3:Number = Math.atan2((_local2.y - _local1.y), (_local2.x - _local1.x));
skinContainer.x = _local1.x;
skinContainer.y = _local1.y;
skinContainer.rotation = ((_local3 * 180) / Math.PI);
skinAnchor1.x = _local1.x;
skinAnchor1.y = _local1.y;
skinAnchor2.x = _local2.x;
skinAnchor2.y = _local2.y;
}
override public function update():void{
if (joint){
updateSkin();
};
}
protected function createJoint():void{
var _local3:b2DistanceJointDef;
var _local4:b2Vec2;
var _local5:b2Vec2;
var _local1:b2Body = getBodyByPoint(new Point(x, y));
var _local2:b2Body = getBodyByPoint(new Point(x2, y2));
if (((((_local1) && (_local2))) && (!((_local1 == _local2))))){
_local3 = new b2DistanceJointDef();
_local4 = new b2Vec2((x / engine.physScale), (y / engine.physScale));
_local5 = new b2Vec2((x2 / engine.physScale), (y2 / engine.physScale));
_local3.Initialize(_local1, _local2, _local4, _local5);
_local3.userData = this;
_local3.collideConnected = true;
joint = (engine.world.CreateJoint(_local3) as b2DistanceJoint);
};
}
override protected function init():void{
super.init();
createJoint();
createSkin();
skinAnchor1.visible = false;
skinAnchor2.visible = false;
}
protected function createSkin():void{
var _local4:b2Vec2;
var _local5:b2Vec2;
var _local6:Number;
var _local7:Matrix;
var _local1:Class = engine.assets.getAssetClass(SKIN_CLASS_NAME);
skin = new (_local1);
skinAnchor1 = (skin.getChildByName("vertex1") as Sprite);
skinAnchor2 = (skin.getChildByName("vertex2") as Sprite);
skinContainer = (skin.getChildByName("container") as Sprite);
var _local2:Class = engine.assets.getAssetClass("DistJointLineAsset");
var _local3:BitmapData = new _local2(0, 0);
if (joint){
_local4 = joint.GetAnchorA().Copy();
_local5 = joint.GetAnchorB().Copy();
_local4.Multiply(engine.physScale);
_local5.Multiply(engine.physScale);
_local6 = Math.sqrt((((_local5.x - _local4.x) * (_local5.x - _local4.x)) + ((_local5.y - _local4.y) * (_local5.y - _local4.y))));
skinContainer.graphics.clear();
_local7 = new Matrix();
_local7.translate(0, -2);
skinContainer.graphics.beginBitmapFill(_local3, _local7, true, true);
skinContainer.graphics.drawRect(0, -2, _local6, 4);
skinContainer.graphics.endFill();
updateSkin();
} else {
skin.alpha = 0.2;
};
engine.canvas.joints.addChild(skin);
}
override public function destroy():void{
skin.parent.removeChild(skin);
if (joint){
engine.world.DestroyJoint(joint);
};
}
}
}//package core.objects
Section 116
//Hinge (core.objects.Hinge)
package core.objects {
import Box2D.Dynamics.*;
import flash.geom.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
public class Hinge extends BaseObject {
protected var obj1:BodyObject;
public var joint:b2RevoluteJoint;
protected var obj2:BodyObject;
public static const SKIN_CLASS_NAME:String = "HingeAsset";
public function Hinge(_arg1:Number, _arg2:Number):void{
super(_arg1, _arg2);
}
protected function updateSkin():void{
var _local1:b2Vec2 = joint.GetAnchorA().Copy();
_local1.Multiply(engine.physScale);
skin.x = _local1.x;
skin.y = _local1.y;
}
override public function update():void{
if (joint){
updateSkin();
};
}
protected function createJoint():void{
var _local2:b2Body;
var _local3:b2RevoluteJointDef;
var _local4:b2Vec2;
var _local1:Point = new Point(x, y);
obj1 = getBodyObjByPoint(_local1);
if (obj1){
obj2 = getOtherBodyObjByPoint(obj1, _local1);
if (obj2){
_local2 = obj2.body;
} else {
_local2 = engine.world.GetGroundBody();
};
_local3 = new b2RevoluteJointDef();
_local4 = new b2Vec2((x / engine.physScale), (y / engine.physScale));
_local3.Initialize(obj1.body, _local2, _local4);
_local3.userData = this;
joint = (engine.world.CreateJoint(_local3) as b2RevoluteJoint);
};
}
override protected function init():void{
super.init();
createJoint();
createSkin();
}
override public function destroy():void{
skin.parent.removeChild(skin);
if (joint){
engine.world.DestroyJoint(joint);
};
}
protected function createSkin():void{
var _local1:Class = engine.assets.getAssetClass(SKIN_CLASS_NAME);
skin = new (_local1);
skin.x = x;
skin.y = y;
if (!joint){
skin.alpha = 0.2;
};
engine.canvas.joints.addChild(skin);
}
protected function getBodyObjByPoint(_arg1:Point):BodyObject{
var _local3:BaseObject;
var _local4:BodyObject;
var _local2:int;
while (_local2 < engine.objects.length) {
_local3 = engine.objects[_local2];
if ((_local3 is BodyObject)){
_local4 = (_local3 as BodyObject);
if ((_local4 is BoxLeg)){
} else {
if (_local4.skin.hitTestPoint(_arg1.x, _arg1.y, true)){
return (_local4);
};
};
};
_local2++;
};
return (null);
}
protected function getOtherBodyObjByPoint(_arg1:BodyObject, _arg2:Point):BodyObject{
var _local4:BaseObject;
var _local5:BodyObject;
var _local3:int;
while (_local3 < engine.objects.length) {
_local4 = engine.objects[_local3];
if ((_local4 is BodyObject)){
_local5 = (_local4 as BodyObject);
if ((_local5 is BoxLeg)){
} else {
if (((!((_local5 == _arg1))) && (_local5.skin.hitTestPoint(_arg2.x, _arg2.y, true)))){
return (_local5);
};
};
};
_local3++;
};
return (null);
}
}
}//package core.objects
Section 117
//Monitor (core.objects.Monitor)
package core.objects {
import core.*;
public class Monitor extends SimpleObject {
public function Monitor(_arg1:Number, _arg2:Number):void{
super(_arg1, _arg2);
}
override protected function init():void{
verticesRaw = [0, 0, 44, 0, 44, 41, 29, 43, 39, 49, 8, 49, 16, 43, 0, 41];
mat = new BodyMaterial(null);
mat.density = 0.5;
mat.friction = 0.2;
mat.restitution = 0.2;
super.init();
}
override protected function createSkin():void{
var _local1:Class = engine.assets.getAssetClass("MonitorAsset");
skin = new (_local1);
engine.canvas.objects.addChild(skin);
}
}
}//package core.objects
Section 118
//Motor (core.objects.Motor)
package core.objects {
import flash.display.*;
import Box2D.Dynamics.*;
import flash.geom.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
public class Motor extends Hinge {
private var skinCw:Sprite;
private var skinCcw:Sprite;
public var torque:Number;
private var sign:Number;
public static const SKIN_CLASS_NAME:String = "MotorAsset";
public function Motor(_arg1:Number, _arg2:Number, _arg3:Number):void{
this.torque = _arg3;
super(_arg1, _arg2);
}
override protected function createSkin():void{
var _local1:Class = engine.assets.getAssetClass(SKIN_CLASS_NAME);
skin = new (_local1);
skin.x = x;
skin.y = y;
if (!joint){
skin.alpha = 0.2;
};
skinCw = (skin.getChildByName("cw") as Sprite);
skinCcw = (skin.getChildByName("ccw") as Sprite);
skinCw.visible = false;
skinCcw.visible = false;
if (torque > 0){
skinCw.visible = true;
} else {
skinCcw.visible = true;
};
if (sign == 1){
skin.scaleX = -1;
};
engine.canvas.joints.addChild(skin);
}
override protected function updateSkin():void{
var _local1:Number;
super.updateSkin();
if (joint){
_local1 = joint.GetJointAngle();
skin.rotation = (((sign * _local1) * 180) / Math.PI);
};
}
override protected function createJoint():void{
var _local1:Point;
var _local2:b2Body;
var _local3:b2RevoluteJointDef;
var _local4:b2Vec2;
_local1 = new Point(x, y);
obj1 = getBodyObjByPoint(_local1);
sign = -1;
if (obj1){
obj2 = getOtherBodyObjByPoint(obj1, _local1);
if (obj2){
sign = 1;
_local2 = obj2.body;
} else {
_local2 = engine.world.GetGroundBody();
};
_local3 = new b2RevoluteJointDef();
_local4 = new b2Vec2((x / engine.physScale), (y / engine.physScale));
_local3.Initialize(obj1.body, _local2, _local4);
_local3.userData = this;
_local3.enableMotor = true;
_local3.motorSpeed = (-(torque) * 2);
_local3.maxMotorTorque = 1000;
joint = (engine.world.CreateJoint(_local3) as b2RevoluteJoint);
};
}
}
}//package core.objects
Section 119
//ShapeSensor (core.objects.ShapeSensor)
package core.objects {
import core.shapes.*;
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
public class ShapeSensor extends BaseObject {
public var body:b2Body;
private var mouseJoint:b2MouseJoint;
private var fixture:b2Fixture;
public var stickyObj:StickyBodyObject;
private var contactObjects:Array;
public function ShapeSensor(_arg1:Number, _arg2:Number):void{
super(_arg1, _arg2);
}
public function createRectShape(_arg1:RectShape):void{
if (fixture){
body.DestroyFixture(fixture);
fixture = null;
};
var _local2:b2PolygonShape = new b2PolygonShape();
var _local3:Number = (_arg1.width / 2);
var _local4:Number = (_arg1.height / 2);
_local2.SetAsOrientedBox((_local3 / engine.physScale), (_local4 / engine.physScale), new b2Vec2(0, 0), ((_arg1.rotation * Math.PI) / 180));
fixture = body.CreateFixture2(_local2, 1);
fixture.SetSensor(true);
fixture.SetUserData(this);
var _local5:b2FilterData = new b2FilterData();
_local5.maskBits = (0xFFFF & ~(2));
fixture.SetFilterData(_local5);
}
public function preUpdate():void{
body.SetAwake(true);
var _local1:b2Vec2 = new b2Vec2((engine.canvas.level.mouseX / engine.physScale), (engine.canvas.level.mouseY / engine.physScale));
body.SetPositionAndAngle(_local1, 0);
}
override protected function init():void{
super.init();
contactObjects = [];
createBody();
}
public function createCircleShape(_arg1:CircleShape):void{
if (fixture){
body.DestroyFixture(fixture);
fixture = null;
};
var _local2:b2CircleShape = new b2CircleShape((_arg1.radius / engine.physScale));
fixture = body.CreateFixture2(_local2, 1);
fixture.SetSensor(true);
fixture.SetUserData(this);
var _local3:b2FilterData = new b2FilterData();
_local3.maskBits = (0xFFFF & ~(2));
fixture.SetFilterData(_local3);
}
override public function update():void{
var _local2:BaseObject;
var _local3:BaseObject;
var _local4:BaseObject;
contactObjects = [];
var _local1:b2Contact = engine.world.GetContactList();
while (_local1) {
_local2 = _local1.GetFixtureA().GetUserData();
_local3 = _local1.GetFixtureB().GetUserData();
if ((((_local2 == this)) && (_local1.IsTouching()))){
addContactObj(_local3, _local1);
};
if ((((_local3 == this)) && (_local1.IsTouching()))){
addContactObj(_local2, _local1);
};
_local1 = _local1.GetNext();
};
stickyObj = null;
if (contactObjects.length == 1){
_local4 = contactObjects[0];
if ((_local4 is StickyBodyObject)){
stickyObj = (_local4 as StickyBodyObject);
};
};
}
private function createMouseJoint():void{
var _local1:Number = engine.canvas.level.mouseX;
var _local2:Number = engine.canvas.level.mouseY;
var _local3:b2Vec2 = new b2Vec2((_local1 / engine.physScale), (_local2 / engine.physScale));
body.SetPosition(_local3);
if (mouseJoint){
engine.world.DestroyJoint(mouseJoint);
mouseJoint = null;
};
var _local4:b2MouseJointDef = new b2MouseJointDef();
_local4.bodyA = engine.world.GetGroundBody();
_local4.bodyB = body;
_local4.target.Set((_local1 / engine.physScale), (_local2 / engine.physScale));
_local4.maxForce = (3000 * body.GetMass());
_local4.dampingRatio = 0;
_local4.frequencyHz = 20;
mouseJoint = (engine.world.CreateJoint(_local4) as b2MouseJoint);
}
override public function destroy():void{
if (body){
engine.world.DestroyBody(body);
};
if (mouseJoint){
engine.world.DestroyJoint(mouseJoint);
mouseJoint = null;
};
}
private function createBody():void{
var _local1:b2BodyDef = new b2BodyDef();
_local1.type = b2Body.b2_dynamicBody;
_local1.userData = this;
body = engine.world.CreateBody(_local1);
}
private function addContactObj(_arg1:BaseObject, _arg2:b2Contact):void{
var _local3:int = contactObjects.indexOf(_arg1);
if (_local3 == -1){
contactObjects.push(_arg1);
};
}
}
}//package core.objects
Section 120
//SimpleObject (core.objects.SimpleObject)
package core.objects {
import core.*;
import Box2D.Dynamics.*;
import flash.geom.*;
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import geom.*;
public class SimpleObject extends BaseObject {
protected var mat:BodyMaterial;
protected var body:b2Body;
private var fixture:b2Fixture;
protected var verticesRaw:Array;
public function SimpleObject(_arg1:Number, _arg2:Number):void{
super(_arg1, _arg2);
}
protected function actuallyCreatePolyShape(_arg1:Array, _arg2:Point):void{
var _local7:b2Vec2;
var _local3:b2PolygonShape = new b2PolygonShape();
var _local4:Array = [];
var _local5:int;
while (_local5 < _arg1.length) {
_local7 = new b2Vec2();
_local7.SetV(body.GetLocalPoint(new b2Vec2(((_arg1[_local5].x + _arg2.x) / engine.physScale), ((_arg1[_local5].y + _arg2.y) / engine.physScale))));
_local4.push(_local7);
_local5++;
};
_local3.SetAsArray(_local4, _local4.length);
fixture = body.CreateFixture2(_local3, mat.density);
fixture.SetRestitution(mat.restitution);
fixture.SetFriction(mat.friction);
fixture.SetUserData(this);
var _local6:b2FilterData = new b2FilterData();
_local6.maskBits = (0xFFFF & ~(2));
fixture.SetFilterData(_local6);
}
protected function updateSkin():void{
var _local1:b2Vec2 = body.GetPosition();
var _local2:Number = body.GetAngle();
skin.x = (_local1.x * engine.physScale);
skin.y = (_local1.y * engine.physScale);
skin.rotation = ((_local2 * 180) / Math.PI);
}
override protected function init():void{
super.init();
createBody();
createSkin();
}
override public function update():void{
updateSkin();
}
protected function createSkin():void{
}
protected function createBody():void{
var _local6:Point;
var _local7:Array;
var _local8:Array;
var _local9:GeomPoly;
var _local1:b2BodyDef = new b2BodyDef();
_local1.type = ((mat.density == 0)) ? b2Body.b2_staticBody : b2Body.b2_dynamicBody;
_local1.position.Set((x / engine.physScale), (y / engine.physScale));
_local1.userData = this;
_local1.linearDamping = 0.1;
_local1.angularDamping = 0.1;
body = engine.world.CreateBody(_local1);
var _local2:Array = [];
var _local3:int;
while (_local3 < verticesRaw.length) {
_local6 = new Point(verticesRaw[_local3], verticesRaw[(_local3 + 1)]);
_local2.push(_local6);
_local3 = (_local3 + 2);
};
var _local4:Point = new Point(x, y);
var _local5:GeomPoly = GeomPoly.getGeomPoly(0, 0, _local2);
if (_local5.isConvex()){
actuallyCreatePolyShape(_local2, _local4);
} else {
_local7 = GeomPoly.triangulate(_local5);
if (_local7){
_local8 = GeomPoly.polygonizeTriangles(_local7);
if (_local8){
_local3 = 0;
while (_local3 < _local8.length) {
_local9 = _local8[_local3];
actuallyCreatePolyShape(_local9.vertices.reverse(), _local4);
_local3++;
};
};
};
};
}
}
}//package core.objects
Section 121
//StickyBodyObject (core.objects.StickyBodyObject)
package core.objects {
import core.*;
import flash.display.*;
import core.shapes.*;
import flash.geom.*;
public class StickyBodyObject extends BodyObject {
public function StickyBodyObject(_arg1:Number, _arg2:Number):void{
super(_arg1, _arg2, new BodyMaterial(BodyMaterial.TYPE_WOOD));
}
override protected function createSkin():void{
super.createSkin();
}
override protected function createCircleShapeSkin(_arg1:CircleShape, _arg2:Point):void{
var _local3:Sprite = new Sprite();
var _local4:BitmapData = CoreCanvas.stickyBMD;
_arg1.draw(_local3, mat);
var _local5:Point = skin.globalToLocal(_arg2);
_local3.x = _local5.x;
_local3.y = _local5.y;
skin.addChild(_local3);
}
override protected function createPolyShapeSkin(_arg1:PolyShape, _arg2:Point):void{
var _local4:Sprite;
var _local5:Point;
var _local3:BitmapData = CoreCanvas.stickyBMD;
_local4 = new Sprite();
_arg1.draw(_local4, mat);
_local5 = skin.globalToLocal(_arg2);
_local4.x = _local5.x;
_local4.y = _local5.y;
_local4.rotation = -(skin.rotation);
skin.addChild(_local4);
}
}
}//package core.objects
Section 122
//BaseShape (core.shapes.BaseShape)
package core.shapes {
import core.*;
import flash.display.*;
public class BaseShape {
public function BaseShape():void{
init();
}
protected function init():void{
}
public function draw(_arg1:Sprite, _arg2:BodyMaterial):void{
}
public function getStringDef():String{
return ("");
}
}
}//package core.shapes
Section 123
//CircleShape (core.shapes.CircleShape)
package core.shapes {
import core.*;
import flash.display.*;
public class CircleShape extends BaseShape {
public var radius:Number;
public static const NAME:String = "CircleShape";
public static const SKIN_CLASS_NAME:String = "ShapeCircleAsset";
public function CircleShape(_arg1:Number):void{
this.radius = _arg1;
super();
}
override public function draw(_arg1:Sprite, _arg2:BodyMaterial):void{
_arg1.graphics.clear();
_arg1.graphics.lineStyle(2, _arg2.edgeColor);
_arg1.graphics.beginBitmapFill(_arg2.bmd, null, true, true);
_arg1.graphics.drawCircle(0, 0, radius);
_arg1.graphics.endFill();
}
override public function getStringDef():String{
var _local1 = (NAME + "_");
_local1 = (_local1 + radius);
return (_local1);
}
public static function parseStringDef(_arg1:String):CircleShape{
var _local2:Array = _arg1.split("_");
var _local3:Number = _local2[1];
var _local4:CircleShape = new CircleShape(_local3);
return (_local4);
}
}
}//package core.shapes
Section 124
//PolyShape (core.shapes.PolyShape)
package core.shapes {
import core.*;
import flash.display.*;
public class PolyShape extends BaseShape {
public var vertices:Array;
public static const NAME:String = "PolyShape";
public function PolyShape(_arg1:Array):void{
this.vertices = _arg1;
super();
}
override public function draw(_arg1:Sprite, _arg2:BodyMaterial):void{
var _local3:Array = vertices;
_arg1.graphics.clear();
_arg1.graphics.lineStyle(2, _arg2.edgeColor);
_arg1.graphics.beginBitmapFill(_arg2.bmd, null, true, true);
_arg1.graphics.moveTo(_local3[0].x, _local3[0].y);
var _local4 = 1;
while (_local4 < _local3.length) {
_arg1.graphics.lineTo(_local3[_local4].x, _local3[_local4].y);
_local4++;
};
_arg1.graphics.lineTo(_local3[0].x, _local3[0].y);
_arg1.graphics.endFill();
}
override public function getStringDef():String{
var _local1 = (NAME + "_");
return (_local1);
}
public static function parseStringDef(_arg1:String):PolyShape{
var _local2:Array = _arg1.split("_");
var _local3:PolyShape = new PolyShape([]);
return (_local3);
}
}
}//package core.shapes
Section 125
//RectShape (core.shapes.RectShape)
package core.shapes {
import core.*;
import flash.display.*;
import flash.geom.*;
import Box2D.Common.Math.*;
public class RectShape extends PolyShape {
public var width:Number;
public var height:Number;
public var rotation:Number;
public static const NAME:String = "RectShape";
public static const SKIN_CLASS_NAME:String = "ShapeRectAsset";
public function RectShape(_arg1:Number, _arg2:Number, _arg3:Number=0):void{
this.width = _arg1;
this.height = _arg2;
this.rotation = _arg3;
super(getVertices());
}
override public function draw(_arg1:Sprite, _arg2:BodyMaterial):void{
var _local3:Array = getVertices();
_arg1.graphics.clear();
_arg1.graphics.lineStyle(2, _arg2.edgeColor);
_arg1.graphics.beginBitmapFill(_arg2.bmd, null, true, true);
_arg1.graphics.moveTo(_local3[0].x, _local3[0].y);
var _local4 = 1;
while (_local4 < _local3.length) {
_arg1.graphics.lineTo(_local3[_local4].x, _local3[_local4].y);
_local4++;
};
_arg1.graphics.lineTo(_local3[0].x, _local3[0].y);
_arg1.graphics.endFill();
}
override public function getStringDef():String{
var _local1 = (NAME + "_");
_local1 = (_local1 + (width + "_"));
_local1 = (_local1 + (height + "_"));
_local1 = (_local1 + rotation);
return (_local1);
}
public function getVertices():Array{
var _local9:b2Vec2;
var _local1:Array = [];
var _local2:Number = Math.sin(((rotation * Math.PI) / 180));
var _local3:Number = Math.cos(((rotation * Math.PI) / 180));
var _local4:Number = (width / 2);
var _local5:Number = (height / 2);
var _local6:Array = [new b2Vec2(-(_local4), -(_local5)), new b2Vec2(_local4, -(_local5)), new b2Vec2(_local4, _local5), new b2Vec2(-(_local4), _local5)];
var _local7:b2Mat22 = new b2Mat22();
_local7.Set(((rotation * Math.PI) / 180));
var _local8:uint;
while (_local8 < _local6.length) {
_local9 = _local6[_local8];
_local9 = b2Math.MulMV(_local7, _local9);
_local1[_local8] = new Point(_local9.x, _local9.y);
_local8++;
};
return (_local1);
}
public static function parseStringDef(_arg1:String):RectShape{
var _local2:Array = _arg1.split("_");
var _local3:Number = _local2[1];
var _local4:Number = _local2[2];
var _local5:Number = _local2[3];
var _local6:RectShape = new RectShape(_local3, _local4, _local5);
return (_local6);
}
}
}//package core.shapes
Section 126
//AddShapeTool (core.tools.AddShapeTool)
package core.tools {
import flash.events.*;
import core.*;
import flash.display.*;
import core.objects.*;
import core.shapes.*;
import flash.geom.*;
public class AddShapeTool extends BaseTool {
private var skinCross:Sprite;
private var potentialObj:StickyBodyObject;
private var mat:BodyMaterial;
private var mouseDown:Boolean;
private var currentShape:BaseShape;
private var skinShape:Sprite;
public var shapes:Array;
private var sensor:ShapeSensor;
private var skinShapeContainer:Sprite;
public function AddShapeTool():void{
}
public function update():void{
var _local2:Point;
var _local1:Point = new Point(engine.canvas.container.mouseX, engine.canvas.container.mouseY);
skinShape.x = _local1.x;
skinShape.y = _local1.y;
check3();
if (potentialObj){
skinCross.visible = false;
} else {
skinCross.visible = true;
};
if (((mouseDown) && (potentialObj))){
_local2 = _local1.clone();
engine.shapeUsed(currentShape);
shapes.splice(0, 1);
if ((currentShape is CircleShape)){
potentialObj.addCircleShape((currentShape as CircleShape), _local2);
getNextShape();
} else {
if ((currentShape is PolyShape)){
potentialObj.addPolyShape((currentShape as PolyShape), _local2);
getNextShape();
};
};
engine.sounds.playSound(engine.sounds.sndAddShape, 1);
};
mouseDown = false;
}
private function mouseUpHandler(_arg1:MouseEvent):void{
}
public function preUpdate():void{
sensor.preUpdate();
}
private function check3():void{
sensor.update();
potentialObj = sensor.stickyObj;
}
public function destroy():void{
if (skinShape.parent){
skinShape.parent.removeChild(skinShape);
};
sensor.destroy();
engine.canvas.container.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
engine.canvas.container.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
private function createSensor():void{
if ((currentShape is CircleShape)){
sensor.createCircleShape((currentShape as CircleShape));
} else {
if ((currentShape is RectShape)){
sensor.createRectShape((currentShape as RectShape));
};
};
}
override protected function init():void{
super.init();
var _local1:Class = engine.assets.getAssetClass("AddShapeAsset");
skinShape = new (_local1);
skinShapeContainer = (skinShape.getChildByName("container") as Sprite);
skinCross = (skinShape.getChildByName("cross") as Sprite);
skinShapeContainer.alpha = 0.5;
engine.canvas.shapes.addChild(skinShape);
mat = new BodyMaterial(BodyMaterial.TYPE_WOOD);
sensor = new ShapeSensor(0, 0);
engine.canvas.container.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
engine.canvas.container.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
private function drawRectCross():void{
skinCross.graphics.clear();
skinCross.graphics.lineStyle(2, 10040115);
var _local1:Number = skinShapeContainer.width;
var _local2:Number = skinShapeContainer.height;
var _local3:Number = ((_local1 >= _local2)) ? _local2 : _local1;
var _local4:Number = 5;
skinCross.graphics.moveTo(((-(_local3) / 2) - _local4), ((-(_local3) / 2) - _local4));
skinCross.graphics.lineTo(((_local3 / 2) + _local4), ((_local3 / 2) + _local4));
skinCross.graphics.moveTo(((_local3 / 2) + _local4), ((-(_local3) / 2) - _local4));
skinCross.graphics.lineTo(((-(_local3) / 2) - _local4), ((_local3 / 2) + _local4));
}
public function start():void{
getNextShape();
}
private function mouseDownHandler(_arg1:MouseEvent):void{
mouseDown = true;
}
public function initShapes(_arg1:Array):void{
this.shapes = _arg1;
}
private function drawCircleCross():void{
skinCross.graphics.clear();
skinCross.graphics.lineStyle(2, 10040115);
var _local1:Number = skinShapeContainer.width;
var _local2:Number = skinShapeContainer.height;
var _local3:Number = -2;
skinCross.graphics.moveTo(((-(_local1) / 2) - _local3), ((-(_local2) / 2) - _local3));
skinCross.graphics.lineTo(((_local1 / 2) + _local3), ((_local2 / 2) + _local3));
skinCross.graphics.moveTo(((_local1 / 2) + _local3), ((-(_local2) / 2) - _local3));
skinCross.graphics.lineTo(((-(_local1) / 2) - _local3), ((_local2 / 2) + _local3));
}
private function getBodyObjectUnderPoint(_arg1:Point):BodyObject{
var _local3:BodyObject;
var _local2:int;
while (_local2 < engine.objects.length) {
_local3 = engine.objects[_local2];
if ((((_local3 is BodyObject)) && (_local3.skin.hitTestPoint(_arg1.x, _arg1.y, true)))){
return (_local3);
};
_local2++;
};
return (null);
}
private function getNextShape():void{
if (shapes.length > 0){
currentShape = shapes[0];
currentShape.draw(skinShapeContainer, mat);
if ((currentShape is CircleShape)){
drawCircleCross();
} else {
if ((currentShape is RectShape)){
drawRectCross();
};
};
engine.shapeSelected(currentShape);
createSensor();
} else {
destroy();
};
}
private function getStickyObjBySprite(_arg1:Sprite):StickyBodyObject{
var _local3:BaseObject;
var _local4:StickyBodyObject;
var _local2:int;
while (_local2 < engine.objects.length) {
_local3 = engine.objects[_local2];
if ((_local3 is StickyBodyObject)){
_local4 = (_local3 as StickyBodyObject);
if (_local4.skin == _arg1){
return (_local4);
};
};
_local2++;
};
return (null);
}
}
}//package core.tools
Section 127
//BaseTool (core.tools.BaseTool)
package core.tools {
import core.*;
public class BaseTool {
protected var engine:CoreEngine;
public function BaseTool():void{
init();
}
protected function init():void{
engine = CoreEngine.getInstance();
}
}
}//package core.tools
Section 128
//ObjectTool (core.tools.ObjectTool)
package core.tools {
import flash.events.*;
import flash.display.*;
import core.objects.*;
import Box2D.Dynamics.*;
import flash.geom.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
public class ObjectTool extends BaseTool {
private var mouseJoint:b2MouseJoint;
override protected function init():void{
super.init();
engine.canvas.level.stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
private function mouseDownHandler(_arg1:MouseEvent):void{
var _local2:Number = engine.canvas.level.mouseX;
var _local3:Number = engine.canvas.level.mouseY;
var _local4:BodyObject = getBodyObjByPoint(new Point(_local2, _local3));
if (_local4){
run(_local4, false);
};
}
public function update():void{
var _local1:b2Vec2;
var _local2:Graphics;
var _local3:b2Vec2;
var _local4:b2Vec2;
if (mouseJoint){
_local1 = new b2Vec2((engine.canvas.level.mouseX / engine.physScale), (engine.canvas.level.mouseY / engine.physScale));
mouseJoint.SetTarget(_local1);
_local2 = engine.canvas.gui.graphics;
_local3 = mouseJoint.GetAnchorA().Copy();
_local4 = mouseJoint.GetAnchorB().Copy();
_local3.Multiply(engine.physScale);
_local4.Multiply(engine.physScale);
_local2.clear();
_local2.lineStyle(0, 1, 1);
_local2.moveTo(_local3.x, _local3.y);
_local2.lineTo(_local4.x, _local4.y);
_local2.beginFill(0, 1);
_local2.drawCircle(_local3.x, _local3.y, 3);
_local2.drawCircle(_local4.x, _local4.y, 3);
_local2.endFill();
};
}
private function mouseUpHandler(_arg1:MouseEvent):void{
engine.world.DestroyJoint(mouseJoint);
mouseJoint = null;
engine.canvas.level.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
var _local2:Graphics = engine.canvas.gui.graphics;
_local2.clear();
}
protected function getBodyObjByPoint(_arg1:Point):BodyObject{
var _local3:BaseObject;
var _local4:BodyObject;
var _local2:int;
while (_local2 < engine.objects.length) {
_local3 = engine.objects[_local2];
if ((_local3 is BodyObject)){
_local4 = (_local3 as BodyObject);
if (_local4.skin.hitTestPoint(_arg1.x, _arg1.y, true)){
return (_local4);
};
};
_local2++;
};
return (null);
}
public function run(_arg1:BaseObject, _arg2:Boolean):void{
var _local3:b2Body;
var _local4:b2MouseJointDef;
if (_arg2){
} else {
_local3 = engine.getBodyFromObj(_arg1);
if (_local3){
_local4 = new b2MouseJointDef();
_local4.bodyA = engine.world.GetGroundBody();
_local4.bodyB = _local3;
_local4.target.Set((engine.canvas.level.mouseX / engine.physScale), (engine.canvas.level.mouseY / engine.physScale));
_local4.maxForce = (300 * _local3.GetMass());
mouseJoint = (engine.world.CreateJoint(_local4) as b2MouseJoint);
engine.canvas.level.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
};
};
}
}
}//package core.tools
Section 129
//ShapeItem (core.view.ShapeItem)
package core.view {
import core.*;
import flash.display.*;
import core.shapes.*;
public class ShapeItem extends Sprite {
public var shape:BaseShape;
private var back:MovieClip;
private var container:Sprite;
private var engine:CoreEngine;
private var skinShape:Sprite;
private var window:Sprite;
public function ShapeItem(_arg1:BaseShape):void{
this.shape = _arg1;
init();
}
private function createShape():void{
var _local2:Number;
var _local3:Number;
var _local1:Number = 50;
skinShape = new Sprite();
shape.draw(skinShape, new BodyMaterial(BodyMaterial.TYPE_WOOD));
if ((shape is CircleShape)){
if (skinShape.width > _local1){
skinShape.width = (skinShape.height = _local1);
};
} else {
if ((shape is RectShape)){
if ((((skinShape.width > _local1)) || ((skinShape.height > _local1)))){
_local2 = ((skinShape.width >= skinShape.height)) ? skinShape.width : skinShape.height;
_local3 = (_local1 / _local2);
skinShape.width = (skinShape.width * _local3);
skinShape.height = (skinShape.height * _local3);
};
};
};
container.addChild(skinShape);
}
private function init():void{
engine = CoreEngine.getInstance();
var _local1:Class = engine.assets.getAssetClass("ShapePreviewItemAsset");
window = new (_local1);
addChild(window);
back = (window.getChildByName("back") as MovieClip);
container = (window.getChildByName("container") as Sprite);
back.stop();
createShape();
}
public function hide():void{
visible = false;
}
public function select():void{
back.gotoAndStop(2);
}
}
}//package core.view
Section 130
//ShapesPreview (core.view.ShapesPreview)
package core.view {
import core.*;
import flash.display.*;
import core.shapes.*;
public class ShapesPreview extends Sprite {
private var itemsContainer:Sprite;
private var engine:CoreEngine;
private var items:Array;
private var window:Sprite;
public function ShapesPreview():void{
init();
}
public function selectShape(_arg1:BaseShape):void{
var _local2:ShapeItem = getItemByShape(_arg1);
_local2.select();
}
private function getItemByShape(_arg1:BaseShape):ShapeItem{
var _local3:ShapeItem;
var _local2:int;
while (_local2 < items.length) {
_local3 = items[_local2];
if (_local3.shape == _arg1){
return (_local3);
};
_local2++;
};
return (null);
}
private function createItems():void{
var _local3:ShapeItem;
var _local1:Array = engine.addShapeTool.shapes;
items = [];
var _local2:int;
while (_local2 < _local1.length) {
_local3 = new ShapeItem(_local1[_local2]);
_local3.x = (_local2 * 55);
itemsContainer.addChild(_local3);
items.push(_local3);
_local2++;
};
}
private function init():void{
engine = CoreEngine.getInstance();
var _local1:Class = engine.assets.getAssetClass("ShapesPreviewWindow");
window = new (_local1);
engine.canvas.gui.addChild(window);
itemsContainer = (window.getChildByName("itemsContainer") as Sprite);
itemsContainer.x = 5;
itemsContainer.y = 5;
createItems();
}
public function hideShape(_arg1:BaseShape):void{
var _local2:ShapeItem = getItemByShape(_arg1);
_local2.hide();
}
}
}//package core.view
Section 131
//WakeupMeter (core.view.WakeupMeter)
package core.view {
import core.*;
import flash.display.*;
import core.objects.*;
public class WakeupMeter {
private var skinInner:Sprite;
private var engine:CoreEngine;
private var skinBar:Sprite;
private var progressWidth:Number;
private var skin:Sprite;
public function WakeupMeter():void{
init();
}
public function update():void{
var _local1:Number = (engine.box.totalDist / Box.REQUIRED_DISTANCE);
if (_local1 > 1){
_local1 = 1;
};
skinBar.x = (_local1 * progressWidth);
}
private function init():void{
engine = CoreEngine.getInstance();
var _local1:Class = engine.assets.getAssetClass("WakeupAsset");
skin = new (_local1);
engine.canvas.gui.addChild(skin);
skin.x = 515;
skin.y = (480 - 40);
skinInner = (skin.getChildByName("inner") as Sprite);
skinBar = (skinInner.getChildByName("bar") as Sprite);
progressWidth = 115;
skinBar.x = 0;
}
}
}//package core.view
Section 132
//BodyMaterial (core.BodyMaterial)
package core {
import flash.display.*;
public class BodyMaterial {
public var friction:Number;
public var edgeColor:int;
public var density:Number;
public var restitution:Number;
public var isKiller:Boolean;
public var bmd:BitmapData;
public var type:String;
public static const TYPE_METAL:String = "TypeMetal";
public static const TYPE_BOX:String = "TypeBox";
public static const TYPE_KILLER:String = "TypeKiller";
public static const TYPE_WOOD:String = "TypeWood";
public static const TYPE_RUBBER:String = "TypeRubber";
public static const TYPE_BRICK:String = "TypeBrick";
public function BodyMaterial(_arg1:String):void{
this.type = _arg1;
init();
}
private function init():void{
isKiller = false;
switch (type){
case TYPE_WOOD:
case TYPE_BOX:
density = 0.6;
friction = 0.4;
restitution = 0.4;
bmd = CoreCanvas.stickyBMD;
edgeColor = 4270366;
break;
case TYPE_METAL:
density = 2;
friction = 0.74;
restitution = 0.1;
bmd = CoreCanvas.dynamicBMD;
edgeColor = 1778995;
break;
case TYPE_BRICK:
density = 0;
friction = 1;
restitution = 0.1;
bmd = CoreCanvas.staticBMD;
edgeColor = 5127480;
break;
case TYPE_KILLER:
density = 1;
friction = 0.5;
restitution = 0.2;
isKiller = true;
bmd = CoreCanvas.killerBMD;
edgeColor = 1709076;
break;
case TYPE_RUBBER:
density = 1;
friction = 1.5;
restitution = 2;
bmd = CoreCanvas.rubberBMD;
edgeColor = 6180385;
break;
};
}
}
}//package core
Section 133
//ContactsManager (core.ContactsManager)
package core {
import core.objects.*;
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
public class ContactsManager extends b2ContactListener {
private var engine:CoreEngine;
public function ContactsManager():void{
engine = CoreEngine.getInstance();
}
private function checkObjs(_arg1:BaseObject, _arg2:BaseObject, _arg3:b2Contact):void{
var _local5:b2Vec2;
var _local6:b2Vec2;
var _local4:SoundsManager = SoundsManager.getInstance();
if ((_arg1 is BodyObject)){
if ((_arg2 is BodyObject)){
if ((_arg1 as BodyObject).mat.type == BodyMaterial.TYPE_KILLER){
if ((_arg2 as BodyObject).mat.type == BodyMaterial.TYPE_KILLER){
_arg3.SetEnabled(false);
(_arg1 as BodyObject).collideWithKiller();
(_arg2 as BodyObject).collideWithKiller();
_local4.playSound(_local4.sndHitKiller, 1);
} else {
if ((_arg2 as BodyObject).mat.type == BodyMaterial.TYPE_WOOD){
_arg3.SetEnabled(false);
(_arg2 as BodyObject).collideWithKiller();
_local4.playSound(_local4.sndHitKiller, 1);
};
};
} else {
if (((((_arg1 as BodyObject).mat.type == BodyMaterial.TYPE_RUBBER)) || (((_arg2 as BodyObject).mat.type == BodyMaterial.TYPE_RUBBER)))){
_local5 = _arg3.GetFixtureA().GetBody().GetLinearVelocity().Copy();
_local6 = _arg3.GetFixtureB().GetBody().GetLinearVelocity().Copy();
_local5.Subtract(_local6);
if (_local5.Length() > 1){
_local4.playSound(_local4.sndHitRubber, 1);
};
} else {
if ((_arg1 as BodyObject).mat.type == BodyMaterial.TYPE_WOOD){
if ((_arg2 as BodyObject).mat.type == BodyMaterial.TYPE_KILLER){
_arg3.SetEnabled(false);
(_arg1 as BodyObject).collideWithKiller();
_local4.playSound(_local4.sndHitKiller, 1);
};
};
};
};
} else {
if ((_arg2 is ChainLink)){
if ((_arg1 as BodyObject).mat.type == BodyMaterial.TYPE_KILLER){
_arg3.SetEnabled(false);
(_arg2 as ChainLink).collideWithKiller();
_local4.playSound(_local4.sndKillerHitChain, 1);
};
};
};
} else {
if ((_arg1 is ChainLink)){
if ((((_arg2 is BodyObject)) && (((_arg2 as BodyObject).mat.type == BodyMaterial.TYPE_KILLER)))){
_arg3.SetEnabled(false);
(_arg1 as ChainLink).collideWithKiller();
_local4.playSound(_local4.sndKillerHitChain, 1);
};
};
};
}
override public function PreSolve(_arg1:b2Contact, _arg2:b2Manifold):void{
var _local3:b2Fixture = _arg1.GetFixtureA();
var _local4:b2Fixture = _arg1.GetFixtureB();
var _local5:BaseObject = (_local3.GetUserData() as BaseObject);
var _local6:BaseObject = (_local4.GetUserData() as BaseObject);
if ((((((_local5 is BaseObject)) && ((_local6 is BaseObject)))) && (_arg1.IsTouching()))){
checkObjs(_local5, _local6, _arg1);
};
}
}
}//package core
Section 134
//CoreAssets (core.CoreAssets)
package core {
import flash.events.*;
import flash.display.*;
import flash.system.*;
public class CoreAssets extends EventDispatcher {
private var Assets:Class;
private var appDomain:ApplicationDomain;
public var inited:Boolean;
private static var instance:CoreAssets;
public function CoreAssets():void{
Assets = CoreAssets_Assets;
super();
inited = false;
}
public function init():void{
var _local1:Loader = new Loader();
_local1.contentLoaderInfo.addEventListener(Event.INIT, assetsInitHandler);
_local1.loadBytes(new Assets());
}
private function assetsInitHandler(_arg1:Event):void{
appDomain = _arg1.target.content.loaderInfo.applicationDomain;
inited = true;
dispatchEvent(new Event(Event.INIT));
}
public function getAssetClass(_arg1:String):Class{
if (!appDomain.hasDefinition(_arg1)){
trace((("*Error*: There is no definition of class '" + _arg1) + "'"));
return (null);
};
return ((appDomain.getDefinition(_arg1) as Class));
}
public static function getInstance():CoreAssets{
if (!instance){
instance = new (CoreAssets);
};
return (instance);
}
}
}//package core
Section 135
//CoreAssets_Assets (core.CoreAssets_Assets)
package core {
import mx.core.*;
public class CoreAssets_Assets extends ByteArrayAsset {
}
}//package core
Section 136
//CoreCanvas (core.CoreCanvas)
package core {
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
public class CoreCanvas {
public var player:Sprite;
public var container:Sprite;
public var joints:Sprite;
public var shapes:Sprite;
public var level:Sprite;
public var objects:Sprite;
public var support:Sprite;
public var backGfx:Sprite;
public var debug:Sprite;
public var gui:Sprite;
public static var stickyBMD:BitmapData;
public static var rubberBMD:BitmapData;
public static var dynamicBMD:BitmapData;
public static var staticBMD:BitmapData;
public static var killerBMD:BitmapData;
public function CoreCanvas(_arg1:Sprite):void{
this.container = _arg1;
level = new Sprite();
_arg1.addChild(level);
backGfx = new Sprite();
level.addChild(backGfx);
objects = new Sprite();
level.addChild(objects);
player = new Sprite();
level.addChild(player);
joints = new Sprite();
level.addChild(joints);
shapes = new Sprite();
level.addChild(shapes);
support = new Sprite();
level.addChild(support);
gui = new Sprite();
level.addChild(gui);
debug = new Sprite();
level.addChild(debug);
var _local2:DropShadowFilter = new DropShadowFilter(4, 45, 0, 0.5);
level.filters = [_local2];
level.scrollRect = new Rectangle(0, 0, 640, 480);
}
public static function init():void{
var _local1:CoreEngine = CoreEngine.getInstance();
var _local2:Class = _local1.assets.getAssetClass("StaticBMDAsset");
staticBMD = new _local2(0, 0);
var _local3:Class = _local1.assets.getAssetClass("DynamicBMDAsset");
dynamicBMD = new _local3(0, 0);
var _local4:Class = _local1.assets.getAssetClass("StickyBMDAsset");
stickyBMD = new _local4(0, 0);
var _local5:Class = _local1.assets.getAssetClass("KillerBMDAsset");
killerBMD = new _local5(0, 0);
var _local6:Class = _local1.assets.getAssetClass("RubberBMDAsset");
rubberBMD = new _local6(0, 0);
}
}
}//package core
Section 137
//CoreEngine (core.CoreEngine)
package core {
import flash.events.*;
import flash.display.*;
import core.objects.*;
import core.shapes.*;
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import core.view.*;
import core.tools.*;
public class CoreEngine extends EventDispatcher {
public var assets:CoreAssets;
private var wakeupMeter:WakeupMeter;
public var currentLevel:CoreLevel;
public var world:b2World;
public var objects:Array;
public var isLevelRestart:Boolean;
public var addShapeTool:AddShapeTool;
public var timeStep:Number;// = 0.0333333333333333
private var positionIterations:int;// = 10
private var hintsManager:HintsManager;
public var sounds:SoundsManager;
public var box:Box;
public var physScale:Number;// = 30
private var contactsManager:ContactsManager;
public var canvas:CoreCanvas;
private var velocityIterations:int;// = 10
public var shapesPreview:ShapesPreview;
private var objectTool:ObjectTool;
public var elapsedTime:int;
public static const LEVEL_COMPLETE:String = "LevelComplete";
private static var instance:CoreEngine;
public function CoreEngine():void{
init();
}
public function levelAbort():void{
var _local2:BaseObject;
canvas.level.removeEventListener(Event.ENTER_FRAME, efHandler);
var _local1:int;
while (_local1 < objects.length) {
_local2 = objects[_local1];
_local2.destroy();
_local1++;
};
if (addShapeTool){
addShapeTool.destroy();
};
}
private function init():void{
}
public function initialize():void{
assets = CoreAssets.getInstance();
sounds = SoundsManager.getInstance();
CoreCanvas.init();
}
private function updateObjects():void{
var _local2:BaseObject;
var _local1:uint;
while (_local1 < objects.length) {
_local2 = objects[_local1];
_local2.update();
_local1++;
};
}
public function getBodyFromObj(_arg1:BaseObject):b2Body{
var _local2:b2Body;
if ((_arg1 is BodyObject)){
_local2 = (_arg1 as BodyObject).body;
} else {
if ((_arg1 is ShapeSensor)){
_local2 = (_arg1 as ShapeSensor).body;
};
};
return (_local2);
}
public function levelStart(_arg1:CoreLevel, _arg2:Sprite):void{
currentLevel = _arg1;
canvas = new CoreCanvas(_arg2);
initBox2d();
wakeupMeter = new WakeupMeter();
hintsManager = new HintsManager();
elapsedTime = 0;
canvas.level.addEventListener(Event.ENTER_FRAME, efHandler);
}
private function initBox2d():void{
var _local1:b2Vec2 = new b2Vec2(0, 10);
var _local2:Boolean;
world = new b2World(_local1, _local2);
var _local3:b2DebugDraw = new b2DebugDraw();
var _local4:Sprite = canvas.debug;
_local4.mouseEnabled = false;
_local4.mouseChildren = false;
_local3.SetSprite(_local4);
_local3.SetDrawScale(physScale);
_local3.SetFillAlpha(0.7);
_local3.SetLineThickness(1);
_local3.SetFlags(((b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit) | b2DebugDraw.e_pairBit));
world.SetDebugDraw(_local3);
contactsManager = new ContactsManager();
world.SetContactListener(contactsManager);
}
public function destroyObject(_arg1:BaseObject):void{
var _local2:int = objects.indexOf(_arg1);
objects.splice(_local2, 1);
_arg1.destroy();
}
public function shapeSelected(_arg1:BaseShape):void{
shapesPreview.selectShape(_arg1);
}
public function levelComplete():void{
dispatchEvent(new CoreEvent(LEVEL_COMPLETE));
}
private function efHandler(_arg1:Event):void{
if (addShapeTool){
addShapeTool.preUpdate();
};
world.Step(timeStep, velocityIterations, positionIterations);
updateObjects();
if (addShapeTool){
addShapeTool.update();
};
wakeupMeter.update();
hintsManager.update();
elapsedTime++;
}
public function destroy():void{
}
public function shapeUsed(_arg1:BaseShape):void{
shapesPreview.hideShape(_arg1);
}
public static function getInstance():CoreEngine{
if (instance == null){
instance = new (CoreEngine);
};
return (instance);
}
}
}//package core
Section 138
//CoreEvent (core.CoreEvent)
package core {
import flash.events.*;
public class CoreEvent extends Event {
public var data:Object;
public function CoreEvent(_arg1:String, _arg2:Object=null, _arg3:Boolean=false, _arg4:Boolean=false):void{
super(_arg1, _arg3, _arg4);
this.data = _arg2;
}
}
}//package core
Section 139
//CoreLevel (core.CoreLevel)
package core {
public class CoreLevel {
public var isCompleted:Boolean;
public var isOpen:Boolean;
public var score:int;
public var id:int;
public var completeTime:int;
public function CoreLevel(_arg1:int):void{
this.id = _arg1;
isCompleted = false;
isOpen = false;
score = 0;
}
public function complete(_arg1:int):void{
isCompleted = true;
completeTime = _arg1;
var _local2:int = (500 - Math.floor((completeTime / 10)));
if (_local2 > score){
score = _local2;
};
}
}
}//package core
Section 140
//HintsManager (core.HintsManager)
package core {
import flash.display.*;
import caurina.transitions.*;
public class HintsManager {
private var delayTime:int;
private var engine:CoreEngine;
private var hints:Array;
private var time:int;
public function HintsManager():void{
init();
}
private function startHint():void{
var _local1:Sprite = hints[0];
hints.splice(0, 1);
var _local2:Number = _local1.y;
_local1.y = (_local1.y - 30);
Tweener.addTween(_local1, {alpha:1, y:_local2, time:1, transition:"easeoutquad"});
}
public function update():void{
if (time >= delayTime){
time = 0;
if (hints.length > 0){
startHint();
};
};
time++;
}
private function init():void{
var _local2:Sprite;
var _local3:int;
var _local4:Sprite;
engine = CoreEngine.getInstance();
delayTime = 100;
time = (delayTime - 10);
hints = [];
var _local1:Class = engine.assets.getAssetClass(("LevelHints" + engine.currentLevel.id));
if (_local1){
_local2 = new (_local1);
engine.canvas.gui.addChild(_local2);
_local3 = 0;
while (_local3 < _local2.numChildren) {
_local4 = (_local2.getChildByName(("h" + _local3)) as Sprite);
if (_local4){
_local4.alpha = 0;
hints.push(_local4);
} else {
break;
};
_local3++;
};
};
}
}
}//package core
Section 141
//SoundsManager (core.SoundsManager)
package core {
import game.model.*;
import flash.media.*;
public class SoundsManager {
public var sndHitBox:Sound;
private var engine:CoreEngine;
public var sndAddShape:Sound;
public var sndImpact:Sound;
public var sndHitKiller:Sound;
public var sndHitRubber:Sound;
public var sndKillerHitChain:Sound;
private var sndChannel:SoundChannel;
private static var instance:SoundsManager;
public function SoundsManager():void{
init();
}
private function init():void{
engine = CoreEngine.getInstance();
var _local1:Class = engine.assets.getAssetClass("SndImpact");
sndImpact = new (_local1);
var _local2:Class = engine.assets.getAssetClass("SndHitBox");
sndHitBox = new (_local2);
var _local3:Class = engine.assets.getAssetClass("SndAddShape");
sndAddShape = new (_local3);
var _local4:Class = engine.assets.getAssetClass("SndHitRubber");
sndHitRubber = new (_local4);
var _local5:Class = engine.assets.getAssetClass("SndHitKiller");
sndHitKiller = new (_local5);
var _local6:Class = engine.assets.getAssetClass("SndKillerHitChain");
sndKillerHitChain = new (_local6);
}
public function playSound(_arg1:Sound, _arg2:Number):void{
if (SaveData.getInstance().soundEnabled){
sndChannel = _arg1.play(0, 0, new SoundTransform(_arg2));
};
}
public static function getInstance():SoundsManager{
if (instance == null){
instance = new (SoundsManager);
};
return (instance);
}
}
}//package core
Section 142
//AdLoader (CPMStar.AdLoader)
package CPMStar {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.system.*;
public class AdLoader extends Sprite {
private var cpmstarLoader:Loader;
private var contentspotid:String;
public function AdLoader(_arg1:String){
this.contentspotid = _arg1;
addEventListener(Event.ADDED, addedHandler);
}
private function dispatchHandler(_arg1:Event):void{
dispatchEvent(_arg1);
}
private function addedHandler(_arg1:Event):void{
removeEventListener(Event.ADDED, addedHandler);
Security.allowDomain("server.cpmstar.com");
var _local2 = "http://server.cpmstar.com/adviewas3.swf";
var _local3:DisplayObjectContainer = parent;
cpmstarLoader = new Loader();
cpmstarLoader.contentLoaderInfo.addEventListener(Event.INIT, dispatchHandler);
cpmstarLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, dispatchHandler);
cpmstarLoader.load(new URLRequest(((_local2 + "?contentspotid=") + contentspotid)));
addChild(cpmstarLoader);
}
}
}//package CPMStar
Section 143
//EditorCloseCommand (editor.controller.EditorCloseCommand)
package editor.controller {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import org.puremvc.as3.patterns.command.*;
import editor.view.*;
public class EditorCloseCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:EditorMediator = (facade.retrieveMediator(EditorMediator.NAME) as EditorMediator);
_local2.destroy();
var _local3:GridProxy = (facade.retrieveProxy(GridProxy.NAME) as GridProxy);
_local3.destroy();
var _local4:EditorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
_local4.destroy();
facade.removeProxy(LevelProxy.NAME);
}
}
}//package editor.controller
Section 144
//EditorStartCommand (editor.controller.EditorStartCommand)
package editor.controller {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import editor.view.components.*;
import org.puremvc.as3.patterns.command.*;
import game.view.*;
import editor.view.*;
public class EditorStartCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:EditorProxy = new EditorProxy();
facade.registerProxy(_local2);
var _local3:LevelProxy = new LevelProxy();
facade.registerProxy(_local3);
var _local4:GridProxy = new GridProxy();
facade.registerProxy(_local4);
var _local5:EditorView = new EditorView();
var _local6:AppMediator = (facade.retrieveMediator(AppMediator.NAME) as AppMediator);
_local6.getViewContainer().addChild(_local5);
var _local7:EditorMediator = new EditorMediator(_local5);
facade.registerMediator(_local7);
}
}
}//package editor.controller
Section 145
//ELevelAbortCommand (editor.controller.ELevelAbortCommand)
package editor.controller {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import org.puremvc.as3.patterns.command.*;
import editor.view.*;
public class ELevelAbortCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:LevelProxy = (facade.retrieveProxy(LevelProxy.NAME) as LevelProxy);
_local2.levelAbort();
var _local3:LevelTestMediator = (facade.retrieveMediator(LevelTestMediator.NAME) as LevelTestMediator);
_local3.destroy();
var _local4:ELevelCompleteMediator = (facade.retrieveMediator(ELevelCompleteMediator.NAME) as ELevelCompleteMediator);
if (_local4){
_local4.destroy();
};
}
}
}//package editor.controller
Section 146
//ELevelCompleteCommand (editor.controller.ELevelCompleteCommand)
package editor.controller {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import editor.view.components.*;
import org.puremvc.as3.patterns.command.*;
import game.view.*;
import editor.view.*;
public class ELevelCompleteCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:LevelProxy = (facade.retrieveProxy(LevelProxy.NAME) as LevelProxy);
var _local3:AppMediator = (facade.retrieveMediator(AppMediator.NAME) as AppMediator);
var _local4:ELevelCompleteView = new ELevelCompleteView();
_local3.getViewContainer().addChild(_local4);
var _local5:ELevelCompleteMediator = new ELevelCompleteMediator(_local4);
facade.registerMediator(_local5);
}
}
}//package editor.controller
Section 147
//ELevelStartCommand (editor.controller.ELevelStartCommand)
package editor.controller {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import editor.view.components.*;
import org.puremvc.as3.patterns.command.*;
import game.view.*;
import editor.view.*;
public class ELevelStartCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:LevelTestView = new LevelTestView();
var _local3:AppMediator = (facade.retrieveMediator(AppMediator.NAME) as AppMediator);
_local3.getViewContainer().addChild(_local2);
var _local4:LevelTestMediator = new LevelTestMediator(_local2);
facade.registerMediator(_local4);
var _local5:LevelProxy = (facade.retrieveProxy(LevelProxy.NAME) as LevelProxy);
_local5.levelStart((_arg1.getBody() as Boolean));
}
}
}//package editor.controller
Section 148
//GridOffCommand (editor.controller.GridOffCommand)
package editor.controller {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import org.puremvc.as3.patterns.command.*;
public class GridOffCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:GridProxy = (facade.retrieveProxy(GridProxy.NAME) as GridProxy);
_local2.gridOff();
}
}
}//package editor.controller
Section 149
//GridOnCommand (editor.controller.GridOnCommand)
package editor.controller {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import org.puremvc.as3.patterns.command.*;
public class GridOnCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:GridProxy = (facade.retrieveProxy(GridProxy.NAME) as GridProxy);
_local2.gridOn();
}
}
}//package editor.controller
Section 150
//ObjectAddCommand (editor.controller.ObjectAddCommand)
package editor.controller {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import editor.model.objects.*;
import org.puremvc.as3.patterns.command.*;
public class ObjectAddCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:EditorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
_local2.objectAdd((_arg1.getBody() as BaseObjectDef));
}
}
}//package editor.controller
Section 151
//ObjectRemoveCommand (editor.controller.ObjectRemoveCommand)
package editor.controller {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import editor.model.objects.*;
import org.puremvc.as3.patterns.command.*;
public class ObjectRemoveCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:EditorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
_local2.objectRemove((_arg1.getBody() as BaseObjectDef));
}
}
}//package editor.controller
Section 152
//ObjectsSelectCommand (editor.controller.ObjectsSelectCommand)
package editor.controller {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import org.puremvc.as3.patterns.command.*;
public class ObjectsSelectCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:EditorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
_local2.objectsSelect((_arg1.getBody() as Array));
}
}
}//package editor.controller
Section 153
//ShapeAddCommand (editor.controller.ShapeAddCommand)
package editor.controller {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import core.shapes.*;
import org.puremvc.as3.patterns.command.*;
public class ShapeAddCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:EditorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
var _local3:Array = (_arg1.getBody() as Array);
var _local4:BaseShape = _local3[0];
var _local5:int = _local3[1];
_local2.shapeAdd(_local4, _local5);
}
}
}//package editor.controller
Section 154
//ShapeRemoveCommand (editor.controller.ShapeRemoveCommand)
package editor.controller {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import core.shapes.*;
import org.puremvc.as3.patterns.command.*;
public class ShapeRemoveCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:EditorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
var _local3:Array = (_arg1.getBody() as Array);
var _local4:BaseShape = _local3[0];
var _local5:int = _local3[1];
_local2.shapeRemove(_local4, _local5);
}
}
}//package editor.controller
Section 155
//ToolSelectCommand (editor.controller.ToolSelectCommand)
package editor.controller {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import org.puremvc.as3.patterns.command.*;
public class ToolSelectCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:EditorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
_local2.selectedTool = (_arg1.getBody() as Tool);
}
}
}//package editor.controller
Section 156
//BaseObjectDef (editor.model.objects.BaseObjectDef)
package editor.model.objects {
import flash.display.*;
import flash.geom.*;
public class BaseObjectDef {
public var x:Number;
public var y:Number;
public var skin:Sprite;
public static const TYPE_KILLER:String = "TypeKiller";
public static const TYPE_WOOD:String = "TypeWood";
public static const TYPE_METAL:String = "TypeMetal";
public static const TYPE_RUBBER:String = "TypeRubber";
public static const TYPE_BRICK:String = "TypeBrick";
public function BaseObjectDef(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
public function isPointInside(_arg1:Point):Boolean{
return (false);
}
public function isRectInside(_arg1:Rectangle):Boolean{
return (false);
}
public function getSkin():Sprite{
return (skin);
}
public function translate(_arg1:Number, _arg2:Number):void{
x = (x + _arg1);
y = (y + _arg2);
}
public function getBoundingBox():Rectangle{
return (new Rectangle(-10, -10, 20, 20));
}
public function getStringDef():String{
return ("");
}
}
}//package editor.model.objects
Section 157
//ChainDef (editor.model.objects.ChainDef)
package editor.model.objects {
import flash.geom.*;
public class ChainDef extends BaseObjectDef {
public var y2:Number;
public var x2:Number;
public static const NAME:String = "ChainDef";
public function ChainDef(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
this.x2 = _arg3;
this.y2 = _arg4;
super(_arg1, _arg2);
}
override public function isPointInside(_arg1:Point):Boolean{
var _local2:Number = Math.sqrt((((_arg1.x - x) * (_arg1.x - x)) + ((_arg1.y - y) * (_arg1.y - y))));
return (((_local2 < 5)) ? true : false);
}
override public function translate(_arg1:Number, _arg2:Number):void{
x = (x + _arg1);
y = (y + _arg2);
x2 = (x2 + _arg1);
y2 = (y2 + _arg2);
}
override public function isRectInside(_arg1:Rectangle):Boolean{
return ((((((((x > _arg1.x)) && ((x < (_arg1.x + _arg1.width))))) && ((y > _arg1.y)))) && ((y < (_arg1.y + _arg1.height)))));
}
override public function getStringDef():String{
var _local1 = (NAME + "_");
_local1 = (_local1 + (x + "_"));
_local1 = (_local1 + (y + "_"));
_local1 = (_local1 + (x2 + "_"));
_local1 = (_local1 + y2);
return (_local1);
}
public static function parseStringDef(_arg1:String):ChainDef{
var _local2:Array = _arg1.split("_");
var _local3:uint = _local2[1];
var _local4:uint = _local2[2];
var _local5:Number = _local2[3];
var _local6:Number = _local2[4];
var _local7:ChainDef = new ChainDef(_local3, _local4, _local5, _local6);
return (_local7);
}
}
}//package editor.model.objects
Section 158
//CircleDef (editor.model.objects.CircleDef)
package editor.model.objects {
import flash.geom.*;
public class CircleDef extends BaseObjectDef {
public var r:Number;
public var type:String;
public static const NAME:String = "CircleDef";
public function CircleDef(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:String):void{
this.r = _arg3;
this.type = _arg4;
super(_arg1, _arg2);
}
override public function getBoundingBox():Rectangle{
return (new Rectangle(-(r), -(r), (r * 2), (r * 2)));
}
override public function isPointInside(_arg1:Point):Boolean{
var _local2:Number = Math.sqrt((((_arg1.x - x) * (_arg1.x - x)) + ((_arg1.y - y) * (_arg1.y - y))));
return (((_local2 < r)) ? true : false);
}
override public function isRectInside(_arg1:Rectangle):Boolean{
return ((((((((x > _arg1.x)) && ((x < (_arg1.x + _arg1.width))))) && ((y > _arg1.y)))) && ((y < (_arg1.y + _arg1.height)))));
}
override public function getStringDef():String{
var _local1 = (NAME + "_");
_local1 = (_local1 + (x + "_"));
_local1 = (_local1 + (y + "_"));
_local1 = (_local1 + (r + "_"));
_local1 = (_local1 + type);
return (_local1);
}
public static function parseStringDef(_arg1:String):CircleDef{
var _local2:Array = _arg1.split("_");
var _local3:Number = _local2[1];
var _local4:Number = _local2[2];
var _local5:Number = _local2[3];
var _local6:String = _local2[4];
var _local7:CircleDef = new CircleDef(_local3, _local4, _local5, _local6);
return (_local7);
}
}
}//package editor.model.objects
Section 159
//DistJointDef (editor.model.objects.DistJointDef)
package editor.model.objects {
import flash.geom.*;
public class DistJointDef extends BaseObjectDef {
public var x1:Number;
public var y1:Number;
public var y2:Number;
public var x2:Number;
public static const NAME:String = "DistJointDef";
public function DistJointDef(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):void{
this.x1 = _arg3;
this.y1 = _arg4;
this.x2 = _arg5;
this.y2 = _arg6;
super(_arg1, _arg2);
}
override public function isPointInside(_arg1:Point):Boolean{
var _local2:Boolean;
var _local3:Boolean;
if ((((((_arg1.x > (x1 - 2))) && ((_arg1.x < (x2 + 2))))) || ((((_arg1.x > (x2 - 2))) && ((_arg1.x < (x1 + 2))))))){
_local2 = true;
};
if ((((((_arg1.y > (y1 - 2))) && ((_arg1.y < (y2 + 2))))) || ((((_arg1.y > (y2 - 2))) && ((_arg1.y < (y1 + 2))))))){
_local3 = true;
};
if (((!(_local2)) || (!(_local3)))){
return (false);
};
var _local4:Number = Math.sqrt((((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2))));
var _local5:Number = Math.sqrt((((_arg1.x - x1) * (_arg1.x - x1)) + ((_arg1.y - y1) * (_arg1.y - y1))));
var _local6:Number = Math.sqrt((((_arg1.x - x2) * (_arg1.x - x2)) + ((_arg1.y - y2) * (_arg1.y - y2))));
return ((((_local5 + _local6) - _local4) < 2));
}
override public function isRectInside(_arg1:Rectangle):Boolean{
return ((((((((x > _arg1.x)) && ((x < (_arg1.x + _arg1.width))))) && ((y > _arg1.y)))) && ((y < (_arg1.y + _arg1.height)))));
}
override public function translate(_arg1:Number, _arg2:Number):void{
x = (x + _arg1);
y = (y + _arg2);
x1 = (x1 + _arg1);
y1 = (y1 + _arg2);
x2 = (x2 + _arg1);
y2 = (y2 + _arg2);
}
override public function getStringDef():String{
var _local1 = (NAME + "_");
_local1 = (_local1 + (x + "_"));
_local1 = (_local1 + (y + "_"));
_local1 = (_local1 + (x1 + "_"));
_local1 = (_local1 + (y1 + "_"));
_local1 = (_local1 + (x2 + "_"));
_local1 = (_local1 + y2);
return (_local1);
}
public static function parseStringDef(_arg1:String):DistJointDef{
var _local2:Array = _arg1.split("_");
var _local3:uint = _local2[1];
var _local4:uint = _local2[2];
var _local5:Number = _local2[3];
var _local6:Number = _local2[4];
var _local7:Number = _local2[5];
var _local8:Number = _local2[6];
var _local9:DistJointDef = new DistJointDef(_local3, _local4, _local5, _local6, _local7, _local8);
return (_local9);
}
}
}//package editor.model.objects
Section 160
//MotorDef (editor.model.objects.MotorDef)
package editor.model.objects {
public class MotorDef extends RevJointDef {
public var torque:Number;
public static const NAME:String = "Motor";
public function MotorDef(_arg1:Number, _arg2:Number, _arg3:Number=0):void{
this.torque = _arg3;
super(_arg1, _arg2);
}
override public function getStringDef():String{
var _local1 = (NAME + "_");
_local1 = (_local1 + (x + "_"));
_local1 = (_local1 + (y + "_"));
_local1 = (_local1 + torque);
return (_local1);
}
public static function parseStringDef(_arg1:String):MotorDef{
var _local2:Array = _arg1.split("_");
var _local3:Number = _local2[1];
var _local4:Number = _local2[2];
var _local5:Number = _local2[3];
var _local6:MotorDef = new MotorDef(_local3, _local4, _local5);
return (_local6);
}
}
}//package editor.model.objects
Section 161
//PlayerDef (editor.model.objects.PlayerDef)
package editor.model.objects {
public class PlayerDef extends RectDef {
public static const NAME:String = "PlayerDef";
public function PlayerDef(_arg1:Number, _arg2:Number):void{
super(_arg1, _arg2, 60, 60, BaseObjectDef.TYPE_METAL);
}
override public function getStringDef():String{
var _local1 = (NAME + "_");
_local1 = (_local1 + (x + "_"));
_local1 = (_local1 + y);
return (_local1);
}
public static function parseStringDef(_arg1:String):PlayerDef{
var _local2:Array = _arg1.split("_");
var _local3:Number = _local2[1];
var _local4:Number = _local2[2];
var _local5:PlayerDef = new PlayerDef(_local3, _local4);
return (_local5);
}
}
}//package editor.model.objects
Section 162
//PolyDef (editor.model.objects.PolyDef)
package editor.model.objects {
import flash.geom.*;
import geom.*;
public class PolyDef extends BaseObjectDef {
public var vertices:Array;
public var type:String;
public static const NAME:String = "PolyDef";
public function PolyDef(_arg1:Number, _arg2:Number, _arg3:Array, _arg4:String):void{
this.vertices = _arg3;
this.type = _arg4;
super(_arg1, _arg2);
}
override public function getBoundingBox():Rectangle{
var _local1:Rectangle = getGeomPoly().getBoundingBox();
_local1.x = (_local1.x - x);
_local1.y = (_local1.y - y);
return (_local1);
}
private function getGeomPoly():GeomPoly{
var _local3:Vector;
var _local1:Array = [];
var _local2:uint;
while (_local2 < vertices.length) {
_local3 = new Vector((x + vertices[_local2].x), (y + vertices[_local2].y));
_local1.push(_local3);
_local2++;
};
return (new GeomPoly(_local1));
}
public function isSimple():Boolean{
return (getGeomPoly().isSimple());
}
override public function isRectInside(_arg1:Rectangle):Boolean{
if (!(((((((x > _arg1.x)) && ((x < (_arg1.x + _arg1.width))))) && ((y > _arg1.y)))) && ((y < (_arg1.y + _arg1.height))))){
return (getGeomPoly().isRectInside(_arg1));
};
return (true);
}
override public function getStringDef():String{
var _local1 = (NAME + "_");
_local1 = (_local1 + (x + "_"));
_local1 = (_local1 + (y + "_"));
_local1 = (_local1 + (type + "_"));
var _local2:uint;
while (_local2 < vertices.length) {
_local1 = (_local1 + ((vertices[_local2].x + ",") + vertices[_local2].y));
if (_local2 < (vertices.length - 1)){
_local1 = (_local1 + "_");
};
_local2++;
};
return (_local1);
}
override public function isPointInside(_arg1:Point):Boolean{
return (getGeomPoly().isPointInside(_arg1));
}
public static function parseStringDef(_arg1:String):PolyDef{
var _local9:Array;
var _local2:Array = _arg1.split("_");
var _local3:Number = _local2[1];
var _local4:Number = _local2[2];
var _local5:String = _local2[3];
var _local6:Array = [];
var _local7:uint = 4;
while (_local7 < _local2.length) {
_local9 = _local2[_local7].split(",");
_local6.push(new Point(_local9[0], _local9[1]));
_local7++;
};
var _local8:PolyDef = new PolyDef(_local3, _local4, _local6, _local5);
return (_local8);
}
}
}//package editor.model.objects
Section 163
//RectDef (editor.model.objects.RectDef)
package editor.model.objects {
import flash.geom.*;
import Box2D.Common.Math.*;
public class RectDef extends PolyDef {
public var width:Number;
public var height:Number;
public var rotation:Number;
public static const NAME:String = "RectDef";
public function RectDef(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:String, _arg6:Number=0):void{
setDimensions(_arg3, _arg4);
setRotation(_arg6);
super(_arg1, _arg2, vertices, _arg5);
}
public function setRotation(_arg1:Number):void{
this.rotation = _arg1;
updateVertices();
}
private function updateVertices():void{
var _local8:b2Vec2;
var _local1:Number = Math.sin(((rotation * Math.PI) / 180));
var _local2:Number = Math.cos(((rotation * Math.PI) / 180));
var _local3:Number = (width / 2);
var _local4:Number = (height / 2);
var _local5:Array = [new b2Vec2(-(_local3), -(_local4)), new b2Vec2(_local3, -(_local4)), new b2Vec2(_local3, _local4), new b2Vec2(-(_local3), _local4)];
var _local6:b2Mat22 = new b2Mat22();
_local6.Set(((rotation * Math.PI) / 180));
var _local7:uint;
while (_local7 < _local5.length) {
_local8 = _local5[_local7];
_local8 = b2Math.MulMV(_local6, _local8);
vertices[_local7] = new Point(_local8.x, _local8.y);
_local7++;
};
}
override public function getStringDef():String{
var _local1 = (NAME + "_");
_local1 = (_local1 + (x + "_"));
_local1 = (_local1 + (y + "_"));
_local1 = (_local1 + (width + "_"));
_local1 = (_local1 + (height + "_"));
_local1 = (_local1 + (type + "_"));
_local1 = (_local1 + rotation);
return (_local1);
}
public function setDimensions(_arg1:Number, _arg2:Number):void{
this.width = _arg1;
this.height = _arg2;
vertices = [];
updateVertices();
}
public static function parseStringDef(_arg1:String):RectDef{
var _local2:Array = _arg1.split("_");
var _local3:Number = _local2[1];
var _local4:Number = _local2[2];
var _local5:Number = _local2[3];
var _local6:Number = _local2[4];
var _local7:String = _local2[5];
var _local8:Number = _local2[6];
var _local9:RectDef = new RectDef(_local3, _local4, _local5, _local6, _local7, _local8);
return (_local9);
}
}
}//package editor.model.objects
Section 164
//RevJointDef (editor.model.objects.RevJointDef)
package editor.model.objects {
import flash.geom.*;
public class RevJointDef extends BaseObjectDef {
public static const NAME:String = "RevJoint";
public function RevJointDef(_arg1:Number, _arg2:Number):void{
super(_arg1, _arg2);
}
override public function getBoundingBox():Rectangle{
return (new Rectangle(-10, -10, (10 * 2), (10 * 2)));
}
override public function isPointInside(_arg1:Point):Boolean{
var _local2:Number = Math.sqrt((((_arg1.x - x) * (_arg1.x - x)) + ((_arg1.y - y) * (_arg1.y - y))));
return (((_local2 < 5)) ? true : false);
}
override public function isRectInside(_arg1:Rectangle):Boolean{
return ((((((((x > _arg1.x)) && ((x < (_arg1.x + _arg1.width))))) && ((y > _arg1.y)))) && ((y < (_arg1.y + _arg1.height)))));
}
override public function getStringDef():String{
var _local1 = (NAME + "_");
_local1 = (_local1 + (x + "_"));
_local1 = (_local1 + y);
return (_local1);
}
public static function parseStringDef(_arg1:String):RevJointDef{
var _local2:Array = _arg1.split("_");
var _local3:Number = _local2[1];
var _local4:Number = _local2[2];
var _local5:RevJointDef = new RevJointDef(_local3, _local4);
return (_local5);
}
}
}//package editor.model.objects
Section 165
//SimpleObjDef (editor.model.objects.SimpleObjDef)
package editor.model.objects {
import flash.geom.*;
public class SimpleObjDef extends BaseObjectDef {
public var type:String;
public static const TYPE_MONITOR:String = "TypeMonitor";
public static const TYPE_BOTTLE:String = "TypeBottle";
public static const NAME:String = "SimpleObjDef";
public function SimpleObjDef(_arg1:Number, _arg2:Number, _arg3:String):void{
this.type = _arg3;
super(_arg1, _arg2);
}
override public function getBoundingBox():Rectangle{
return (new Rectangle(-10, -10, (10 * 2), (10 * 2)));
}
override public function isPointInside(_arg1:Point):Boolean{
var _local2:Number = Math.sqrt((((_arg1.x - x) * (_arg1.x - x)) + ((_arg1.y - y) * (_arg1.y - y))));
return (((_local2 < 5)) ? true : false);
}
override public function isRectInside(_arg1:Rectangle):Boolean{
return ((((((((x > _arg1.x)) && ((x < (_arg1.x + _arg1.width))))) && ((y > _arg1.y)))) && ((y < (_arg1.y + _arg1.height)))));
}
override public function getStringDef():String{
var _local1 = (NAME + "_");
_local1 = (_local1 + (x + "_"));
_local1 = (_local1 + (y + "_"));
_local1 = (_local1 + type);
return (_local1);
}
public static function parseStringDef(_arg1:String):SimpleObjDef{
var _local2:Array = _arg1.split("_");
var _local3:Number = _local2[1];
var _local4:Number = _local2[2];
var _local5:String = _local2[3];
var _local6:SimpleObjDef = new SimpleObjDef(_local3, _local4, _local5);
return (_local6);
}
}
}//package editor.model.objects
Section 166
//EditorAssets (editor.model.EditorAssets)
package editor.model {
import flash.events.*;
import flash.display.*;
import flash.system.*;
public class EditorAssets extends EventDispatcher {
private var Assets:Class;
private var appDomain:ApplicationDomain;
private static var instance:EditorAssets;
public function EditorAssets(){
Assets = EditorAssets_Assets;
super();
}
public function init():void{
var _local1:Loader = new Loader();
_local1.contentLoaderInfo.addEventListener(Event.INIT, assetsInitHandler);
_local1.loadBytes(new Assets());
}
public function GameAssets():void{
}
private function assetsInitHandler(_arg1:Event):void{
appDomain = _arg1.target.content.loaderInfo.applicationDomain;
dispatchEvent(new Event(Event.INIT));
}
public function getAssetClass(_arg1:String):Class{
if (!appDomain.hasDefinition(_arg1)){
trace((("*Error*: There is no definition of class '" + _arg1) + "'"));
return (null);
};
return ((appDomain.getDefinition(_arg1) as Class));
}
public static function getInstance():EditorAssets{
if (!instance){
instance = new (EditorAssets);
};
return (instance);
}
}
}//package editor.model
Section 167
//EditorAssets_Assets (editor.model.EditorAssets_Assets)
package editor.model {
import mx.core.*;
public class EditorAssets_Assets extends ByteArrayAsset {
}
}//package editor.model
Section 168
//EditorProxy (editor.model.EditorProxy)
package editor.model {
import game.model.*;
import flash.display.*;
import core.shapes.*;
import editor.model.objects.*;
import flash.geom.*;
import editor.view.components.*;
import org.puremvc.as3.patterns.proxy.*;
import editor.controller.*;
import editor.view.*;
public class EditorProxy extends Proxy {
private var canvasScale:Number;
public var selectedTool:Tool;
private var objects:Array;
private var selectedObjs:Array;
private var tools:Array;
public var levelID:int;
private var notesProxy:NotesProxy;
public var levelName:String;
public var cuts:int;
public var shapes:Array;
public var levelDesc:String;
private var isPublishing:Boolean;
public static const OBJECT_ADD:String = "ObjectAdd";
public static const SHAPE_REMOVE:String = "ShapeRemove";
public static const TOOL_SELECT:String = "ToolSelect";
public static const OBJECT_REMOVE:String = "ObjectRemove";
public static const EDITOR_CLOSE:String = "EditorClose";
public static const OBJECT_UPDATE:String = "ObjectUpdate";
public static const SHAPE_ADD:String = "ShapeAdd";
public static const NAME:String = "EditorProxy";
public static const ELEVEL_ABORT:String = "ELevelAbort";
public static const ELEVEL_START:String = "ELevelStart";
public static const OBJECTS_SELECT:String = "ObjectsSelect";
public static const ELEVEL_COMPLETE:String = "EditorLevelComplete";
public static const SAVE_COMPLETE:String = "SaveComplete";
public function EditorProxy():void{
super(NAME);
init();
}
public function shapeAdd(_arg1:BaseShape, _arg2:int):void{
shapes[_arg2] = _arg1;
}
public function deleteObjects():void{
var _local2:BaseObjectDef;
var _local1:int = (objects.length - 1);
while (_local1 >= 0) {
_local2 = objects[_local1];
if ((_local2 is PlayerDef)){
_local2.x = 100;
_local2.y = 100;
notesProxy.push(OBJECT_UPDATE, _local2);
} else {
notesProxy.push(EditorProxy.OBJECT_REMOVE, _local2);
};
_local1--;
};
}
public function getObjsUnderRect(_arg1:Rectangle):Array{
var _local4:BaseObjectDef;
var _local2:Array = [];
var _local3:uint;
while (_local3 < objects.length) {
_local4 = objects[_local3];
if (_local4.isRectInside(_arg1)){
_local2.push(_local4);
};
_local3++;
};
return (_local2);
}
private function someLevels():void{
}
public function getLevelDef():String{
var _local1:int;
var _local5:BaseObjectDef;
var _local6:String;
var _local7:BaseShape;
var _local2 = "";
_local1 = 0;
while (_local1 < objects.length) {
_local5 = objects[_local1];
_local6 = _local5.getStringDef();
_local2 = (_local2 + (_local6 + "|"));
_local1++;
};
var _local3 = "";
_local1 = 0;
while (_local1 < shapes.length) {
_local7 = shapes[_local1];
if (_local7){
_local3 = (_local3 + (_local7.getStringDef() + "|"));
};
_local1++;
};
var _local4:String = ((_local2 + " ") + _local3);
return (_local4);
}
public function loadLevel(_arg1:String):void{
deleteObjects();
var _local2:Array = _arg1.split(" ");
var _local3:String = _local2[0];
var _local4:String = _local2[1];
var _local5:Array = _local3.split("|");
loadObjects(_local5);
var _local6:Array = _local4.split("|");
loadShapes(_local6);
}
public function objToShape(_arg1:BaseObjectDef):BaseShape{
var _local2:BaseShape;
if ((_arg1 is CircleDef)){
_local2 = new CircleShape((_arg1 as CircleDef).r);
} else {
if ((_arg1 is RectDef)){
_local2 = new RectShape((_arg1 as RectDef).width, (_arg1 as RectDef).height, (_arg1 as RectDef).rotation);
};
};
return (_local2);
}
public function shapeToObj(_arg1:BaseShape, _arg2:Number, _arg3:Number):BaseObjectDef{
var _local4:BaseObjectDef;
if ((_arg1 is CircleShape)){
_local4 = new CircleDef(_arg2, _arg3, (_arg1 as CircleShape).radius, BaseObjectDef.TYPE_WOOD);
} else {
if ((_arg1 is RectShape)){
_local4 = new RectDef(_arg2, _arg3, (_arg1 as RectShape).width, (_arg1 as RectShape).height, BaseObjectDef.TYPE_WOOD, (_arg1 as RectShape).rotation);
};
};
return (_local4);
}
private function checkRectRect(_arg1:Rectangle, _arg2:Rectangle):Boolean{
var _local3:Boolean;
var _local4:Boolean;
if ((((((_arg1.x < _arg2.x)) && (((_arg1.x + _arg1.width) > _arg2.x)))) || ((((_arg1.x > _arg2.x)) && ((_arg1.x < (_arg2.x + _arg2.width))))))){
_local3 = true;
};
if ((((((_arg1.y < _arg2.y)) && (((_arg1.y + _arg1.height) > _arg2.y)))) || ((((_arg1.y > _arg2.y)) && ((_arg1.y < (_arg2.y + _arg2.height))))))){
_local4 = true;
};
return ((((_local3) && (_local4))) ? true : false);
}
public function getSelectedObjects():Array{
return (selectedObjs);
}
public function getObjects():Array{
return (objects);
}
public function shapeRemove(_arg1:BaseShape, _arg2:int):void{
shapes[_arg2] = null;
}
private function initTools():void{
tools = [];
addTool(Tool.TYPE_SELECTION);
addTool(Tool.TYPE_CIRCLE);
addTool(Tool.TYPE_RECT);
addTool(Tool.TYPE_DIST_JOINT);
addTool(Tool.TYPE_REV_JOINT);
addTool(Tool.TYPE_MOTOR);
addTool(Tool.TYPE_POLY);
addTool(Tool.TYPE_CHAIN);
addTool(Tool.TYPE_HAND);
addTool(Tool.TYPE_BOTTLE);
addTool(Tool.TYPE_MONITOR);
}
private function loadObjects(_arg1:Array):void{
var _local3:String;
var _local4:Array;
var _local5:String;
var _local6:BaseObjectDef;
var _local7:PlayerDef;
var _local2:uint;
while (_local2 < _arg1.length) {
_local3 = _arg1[_local2];
_local4 = _local3.split("_");
_local5 = _local4[0];
_local6 = null;
switch (_local5){
case CircleDef.NAME:
_local6 = CircleDef.parseStringDef(_local3);
break;
case RectDef.NAME:
_local6 = RectDef.parseStringDef(_local3);
break;
case PlayerDef.NAME:
_local6 = PlayerDef.parseStringDef(_local3);
break;
case DistJointDef.NAME:
_local6 = DistJointDef.parseStringDef(_local3);
break;
case RevJointDef.NAME:
_local6 = RevJointDef.parseStringDef(_local3);
break;
case MotorDef.NAME:
_local6 = MotorDef.parseStringDef(_local3);
break;
case ChainDef.NAME:
_local6 = ChainDef.parseStringDef(_local3);
break;
case PolyDef.NAME:
_local6 = PolyDef.parseStringDef(_local3);
break;
};
if ((_local6 is PlayerDef)){
_local7 = objects[0];
_local7.x = _local6.x;
_local7.y = _local6.y;
notesProxy.push(OBJECT_UPDATE, _local7);
} else {
if (_local6 != null){
notesProxy.push(OBJECT_ADD, _local6);
};
};
_local2++;
};
}
private function init():void{
if (!facade.hasCommand(OBJECT_ADD)){
facade.registerCommand(OBJECT_ADD, ObjectAddCommand);
};
if (!facade.hasCommand(OBJECTS_SELECT)){
facade.registerCommand(OBJECTS_SELECT, ObjectsSelectCommand);
};
if (!facade.hasCommand(ELEVEL_START)){
facade.registerCommand(ELEVEL_START, ELevelStartCommand);
};
if (!facade.hasCommand(ELEVEL_ABORT)){
facade.registerCommand(ELEVEL_ABORT, ELevelAbortCommand);
};
if (!facade.hasCommand(ELEVEL_COMPLETE)){
facade.registerCommand(ELEVEL_COMPLETE, ELevelCompleteCommand);
};
if (!facade.hasCommand(OBJECT_REMOVE)){
facade.registerCommand(OBJECT_REMOVE, ObjectRemoveCommand);
};
if (!facade.hasCommand(EDITOR_CLOSE)){
facade.registerCommand(EDITOR_CLOSE, EditorCloseCommand);
};
if (!facade.hasCommand(TOOL_SELECT)){
facade.registerCommand(TOOL_SELECT, ToolSelectCommand);
};
if (!facade.hasCommand(SHAPE_ADD)){
facade.registerCommand(SHAPE_ADD, ShapeAddCommand);
};
if (!facade.hasCommand(SHAPE_REMOVE)){
facade.registerCommand(SHAPE_REMOVE, ShapeRemoveCommand);
};
notesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
initTools();
objects = [];
selectedObjs = [];
canvasScale = 1;
var _local1:PlayerDef = new PlayerDef(100, 100);
notesProxy.push(OBJECT_ADD, _local1);
var _local2:RectDef = new RectDef(100, 140, 40, 30, BaseObjectDef.TYPE_BRICK);
notesProxy.push(OBJECT_ADD, _local2);
levelID = 0;
levelDesc = "Description";
levelName = "name";
someLevels();
shapes = [];
}
public function deleteSelectedObjects():void{
var _local4:BaseObjectDef;
var _local5:BaseObjectDef;
var _local1:Array = getSelectedObjects();
var _local2:Array = [];
var _local3:uint;
while (_local3 < _local1.length) {
_local4 = _local1[_local3];
if ((_local4 is PlayerDef)){
} else {
_local2.push(_local4);
};
_local3++;
};
while (_local2.length > 0) {
_local5 = _local2.pop();
notesProxy.push(OBJECT_REMOVE, _local5);
};
}
public function canvasTranslate(_arg1:Number, _arg2:Number):void{
var _local3:EditorMediator = (facade.retrieveMediator(EditorMediator.NAME) as EditorMediator);
var _local4:EditorView = (_local3.getViewComponent() as EditorView);
var _local5:Sprite = _local4.canvas;
_local4.canvas.x = (_local5.x + _arg1);
_local5.y = (_local5.y + _arg2);
_local4.support.x = _local5.x;
_local4.support.y = _local5.y;
}
private function addTool(_arg1:String):void{
var _local2:int = tools.length;
var _local3:Tool = new Tool(_local2, _arg1);
tools.push(_local3);
}
public function destroy():void{
facade.retrieveProxy(NAME);
}
public function objectRemove(_arg1:BaseObjectDef):void{
var _local2:int = objects.indexOf(_arg1);
if (_local2 != -1){
objects.splice(_local2, 1);
};
var _local3:int = selectedObjs.indexOf(_arg1);
if (_local3 != -1){
selectedObjs.splice(_local3, 1);
};
}
public function getTools():Array{
return (tools);
}
public function objectAdd(_arg1:BaseObjectDef):void{
objects.push(_arg1);
}
public function objectsSelect(_arg1:Array):void{
selectedObjs = _arg1;
}
private function loadShapes(_arg1:Array):void{
var _local3:String;
var _local4:Array;
var _local5:String;
var _local6:BaseShape;
shapes = [];
var _local2:int;
while (_local2 < _arg1.length) {
_local3 = _arg1[_local2];
_local4 = _local3.split("_");
_local5 = _local4[0];
_local6 = null;
switch (_local5){
case CircleShape.NAME:
_local6 = CircleShape.parseStringDef(_local3);
break;
case RectShape.NAME:
_local6 = RectShape.parseStringDef(_local3);
break;
};
if (_local6){
notesProxy.push(SHAPE_ADD, [_local6, _local2]);
};
_local2++;
};
}
public function getObjUnderPoint(_arg1:Point):BaseObjectDef{
var _local2:int;
var _local3:BaseObjectDef;
var _local4:PlayerDef = objects[0];
if (_local4.isPointInside(_arg1)){
return (_local4);
};
_local2 = (objects.length - 1);
while (_local2 >= 0) {
_local3 = objects[_local2];
if ((((((_local3 is DistJointDef)) || ((_local3 is RevJointDef)))) || ((_local3 is ChainDef)))){
if (_local3.isPointInside(_arg1)){
return (_local3);
};
};
_local2--;
};
_local2 = (objects.length - 1);
while (_local2 >= 0) {
_local3 = objects[_local2];
if (_local3.isPointInside(_arg1)){
return (_local3);
};
_local2--;
};
return (null);
}
private function checkRectPoint(_arg1:Rectangle, _arg2:Point):Boolean{
if ((((((((_arg2.x > _arg1.x)) && ((_arg2.x < (_arg1.x + _arg1.width))))) && ((_arg2.y > _arg1.y)))) && ((_arg2.y < (_arg1.y + _arg1.height))))){
return (true);
};
return (false);
}
}
}//package editor.model
Section 169
//GridProxy (editor.model.GridProxy)
package editor.model {
import flash.geom.*;
import org.puremvc.as3.patterns.proxy.*;
import editor.controller.*;
public class GridProxy extends Proxy {
public var showGrid:Boolean;
public var cellWidth:Number;
public var cellHeight:Number;
public var snap:Boolean;
public static const GRID_OFF:String = "GridOff";
public static const GRID_ON:String = "GridOn";
public static const NAME:String = "GridProxy";
public function GridProxy():void{
super(NAME);
init();
}
public function gridOn():void{
showGrid = true;
snap = true;
}
private function init():void{
if (!facade.hasCommand(GRID_ON)){
facade.registerCommand(GRID_ON, GridOnCommand);
};
if (!facade.hasCommand(GRID_OFF)){
facade.registerCommand(GRID_OFF, GridOffCommand);
};
showGrid = false;
snap = false;
cellWidth = 5;
cellHeight = 5;
}
public function getSnapPoint(_arg1:Point):Point{
var _local2:Number;
var _local3:Number;
if (snap){
_local2 = (Math.round((_arg1.x / cellWidth)) * cellWidth);
_local3 = (Math.round((_arg1.y / cellHeight)) * cellHeight);
return (new Point(_local2, _local3));
};
return (_arg1);
}
public function gridOff():void{
showGrid = false;
snap = false;
}
public function destroy():void{
facade.removeProxy(NAME);
}
}
}//package editor.model
Section 170
//LevelProxy (editor.model.LevelProxy)
package editor.model {
import core.*;
import game.model.*;
import org.puremvc.as3.patterns.proxy.*;
import editor.view.*;
public class LevelProxy extends Proxy {
private var engine:CoreEngine;
private var notesProxy:NotesProxy;
public var publish:Boolean;
public static const SPLIT_NOT_AVAILABLE:String = "SplitNotAvailable";
public static const NAME:String = "LevelProxy";
public static const SPLIT_SUCCESS:String = "SplitSuccess";
public function LevelProxy():void{
super(NAME);
init();
}
private function init():void{
engine = CoreEngine.getInstance();
notesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
}
public function levelStart(_arg1:Boolean=false):void{
this.publish = _arg1;
var _local2:LevelTestMediator = (facade.retrieveMediator(LevelTestMediator.NAME) as LevelTestMediator);
var _local3:EditorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
var _local4:CoreLevel = new CoreLevel(-1);
engine.levelStart(_local4, _local2.getLevelContainer());
engine.addEventListener(CoreEngine.LEVEL_COMPLETE, levelCompleteHandler);
var _local5:String = _local3.getLevelDef();
LevelStringParser.getInstance().parse(_local5);
}
public function levelAbort():void{
engine.removeEventListener(CoreEngine.LEVEL_COMPLETE, levelCompleteHandler);
engine.levelAbort();
}
private function levelCompleteHandler(_arg1:CoreEvent):void{
notesProxy.push(EditorProxy.ELEVEL_COMPLETE);
}
}
}//package editor.model
Section 171
//LevelStringParser (editor.model.LevelStringParser)
package editor.model {
import core.*;
import core.objects.*;
import core.shapes.*;
import editor.model.objects.*;
import flash.geom.*;
import core.view.*;
import core.tools.*;
public class LevelStringParser {
private var engine:CoreEngine;
private static var instance:LevelStringParser;
public function LevelStringParser():void{
init();
}
private function createDistJoint(_arg1:DistJointDef):void{
var _local2:DistanceJoint = new DistanceJoint(_arg1.x1, _arg1.y1, _arg1.x2, _arg1.y2);
engine.objects.push(_local2);
trace("GG");
}
private function parseObjects(_arg1:String):void{
var _local3:int;
var _local4:String;
var _local5:BaseObjectDef;
var _local2:Array = _arg1.split("|");
engine.objects = [];
_local3 = 0;
while (_local3 < _local2.length) {
_local4 = _local2[_local3];
_local5 = parseObjectDef(_local4);
if ((_local5 is PlayerDef)){
createBox((_local5 as PlayerDef));
} else {
if ((_local5 is CircleDef)){
createCircle((_local5 as CircleDef));
} else {
if ((_local5 is PolyDef)){
createPoly((_local5 as PolyDef));
} else {
if ((_local5 is SimpleObjDef)){
createSimpleObj((_local5 as SimpleObjDef));
};
};
};
};
_local3++;
};
_local3 = 0;
while (_local3 < _local2.length) {
_local4 = _local2[_local3];
_local5 = parseObjectDef(_local4);
if ((_local5 is DistJointDef)){
createDistJoint((_local5 as DistJointDef));
} else {
if ((_local5 is MotorDef)){
createMotor((_local5 as MotorDef));
} else {
if ((_local5 is RevJointDef)){
createHinge((_local5 as RevJointDef));
} else {
if ((_local5 is ChainDef)){
createChain((_local5 as ChainDef));
};
};
};
};
_local3++;
};
}
private function parseShapes(_arg1:String):void{
var _local5:BaseShape;
engine.addShapeTool = new AddShapeTool();
var _local2:Array = _arg1.split("|");
var _local3:Array = [];
var _local4:int;
while (_local4 < _local2.length) {
_local5 = parseShapeDef(_local2[_local4]);
if (_local5){
_local3.push(_local5);
};
_local4++;
};
engine.addShapeTool.initShapes(_local3);
engine.shapesPreview = new ShapesPreview();
engine.addShapeTool.start();
}
private function createPoly(_arg1:PolyDef):void{
var _local2:BodyObject;
var _local3:PolyShape = new PolyShape(_arg1.vertices);
if (_arg1.type == BaseObjectDef.TYPE_BRICK){
_local2 = new BodyObject(_arg1.x, _arg1.y, new BodyMaterial(BodyMaterial.TYPE_BRICK));
} else {
if (_arg1.type == BaseObjectDef.TYPE_METAL){
_local2 = new BodyObject(_arg1.x, _arg1.y, new BodyMaterial(BodyMaterial.TYPE_METAL));
} else {
if (_arg1.type == BaseObjectDef.TYPE_KILLER){
_local2 = new BodyObject(_arg1.x, _arg1.y, new BodyMaterial(BodyMaterial.TYPE_KILLER));
} else {
if (_arg1.type == BaseObjectDef.TYPE_WOOD){
_local2 = new StickyBodyObject(_arg1.x, _arg1.y);
} else {
if (_arg1.type == BaseObjectDef.TYPE_RUBBER){
_local2 = new BodyObject(_arg1.x, _arg1.y, new BodyMaterial(BodyMaterial.TYPE_RUBBER));
};
};
};
};
};
_local2.addPolyShape(_local3, new Point(_arg1.x, _arg1.y));
engine.objects.push(_local2);
}
private function createSimpleObj(_arg1:SimpleObjDef):void{
var _local2:Bottle;
var _local3:Monitor;
switch (_arg1.type){
case SimpleObjDef.TYPE_BOTTLE:
_local2 = new Bottle(_arg1.x, _arg1.y);
engine.objects.push(_local2);
break;
case SimpleObjDef.TYPE_MONITOR:
_local3 = new Monitor(_arg1.x, _arg1.y);
engine.objects.push(_local3);
break;
};
}
private function createCircle(_arg1:CircleDef):void{
var _local2:BodyObject;
var _local3:CircleShape = new CircleShape(_arg1.r);
if (_arg1.type == BaseObjectDef.TYPE_BRICK){
_local2 = new BodyObject(_arg1.x, _arg1.y, new BodyMaterial(BodyMaterial.TYPE_BRICK));
} else {
if (_arg1.type == BaseObjectDef.TYPE_METAL){
_local2 = new BodyObject(_arg1.x, _arg1.y, new BodyMaterial(BodyMaterial.TYPE_METAL));
} else {
if (_arg1.type == BaseObjectDef.TYPE_KILLER){
_local2 = new BodyObject(_arg1.x, _arg1.y, new BodyMaterial(BodyMaterial.TYPE_KILLER));
} else {
if (_arg1.type == BaseObjectDef.TYPE_WOOD){
_local2 = new StickyBodyObject(_arg1.x, _arg1.y);
} else {
if (_arg1.type == BaseObjectDef.TYPE_RUBBER){
_local2 = new BodyObject(_arg1.x, _arg1.y, new BodyMaterial(BodyMaterial.TYPE_RUBBER));
};
};
};
};
};
_local2.addCircleShape(_local3, new Point(_arg1.x, _arg1.y));
engine.objects.push(_local2);
}
private function createBox(_arg1:PlayerDef):void{
var _local2:Box = new Box(_arg1.x, _arg1.y);
engine.objects.push(_local2);
engine.box = _local2;
}
private function init():void{
engine = CoreEngine.getInstance();
}
private function createChain(_arg1:ChainDef):void{
var _local2:Chain = new Chain(_arg1.x, _arg1.y, _arg1.x2, _arg1.y2);
engine.objects.push(_local2);
}
private function createHinge(_arg1:RevJointDef):void{
var _local2:Hinge = new Hinge(_arg1.x, _arg1.y);
engine.objects.push(_local2);
}
private function parseShapeDef(_arg1:String):BaseShape{
var _local2:Array = _arg1.split("_");
var _local3:String = _local2[0];
switch (_local3){
case CircleShape.NAME:
return (CircleShape.parseStringDef(_arg1));
case RectShape.NAME:
return (RectShape.parseStringDef(_arg1));
};
return (null);
}
private function createMotor(_arg1:MotorDef):void{
var _local2:Motor = new Motor(_arg1.x, _arg1.y, _arg1.torque);
engine.objects.push(_local2);
}
public function parse(_arg1:String):void{
trace(_arg1);
var _local2:Array = _arg1.split(" ");
var _local3:String = _local2[0];
var _local4:String = _local2[1];
parseObjects(_local3);
parseShapes(_local4);
}
public static function parseObjectDef(_arg1:String):BaseObjectDef{
var _local2:Array = _arg1.split("_");
var _local3:String = _local2[0];
switch (_local3){
case CircleDef.NAME:
return (CircleDef.parseStringDef(_arg1));
case PlayerDef.NAME:
return (PlayerDef.parseStringDef(_arg1));
case RectDef.NAME:
return (RectDef.parseStringDef(_arg1));
case DistJointDef.NAME:
return (DistJointDef.parseStringDef(_arg1));
case RevJointDef.NAME:
return (RevJointDef.parseStringDef(_arg1));
case MotorDef.NAME:
return (MotorDef.parseStringDef(_arg1));
case PolyDef.NAME:
return (PolyDef.parseStringDef(_arg1));
case ChainDef.NAME:
return (ChainDef.parseStringDef(_arg1));
case SimpleObjDef.NAME:
return (SimpleObjDef.parseStringDef(_arg1));
};
return (null);
}
public static function getInstance():LevelStringParser{
if (instance == null){
instance = new (LevelStringParser);
};
return (instance);
}
}
}//package editor.model
Section 172
//Tool (editor.model.Tool)
package editor.model {
public class Tool {
public var type:String;
public var id:uint;
public static const TYPE_MONITOR:String = "TypeMonitor";
public static const TYPE_PLAYER:String = "TypePlayer";
public static const TYPE_SELECTION:String = "TypeSelection";
public static const TYPE_REV_JOINT:String = "TypeRevJoint";
public static const TYPE_BOTTLE:String = "TypeBottle";
public static const TYPE_RECT:String = "TypeRect";
public static const TYPE_POLY:String = "TypePoly";
public static const TYPE_HAND:String = "TypeHand";
public static const TYPE_CIRCLE:String = "TypeCircle";
public static const TYPE_DIST_JOINT:String = "TypeDistJoint";
public static const TYPE_MOTOR:String = "TypeMotor";
public static const TYPE_CHAIN:String = "TypeChain";
public function Tool(_arg1:uint, _arg2:String):void{
this.id = _arg1;
this.type = _arg2;
}
}
}//package editor.model
Section 173
//ChainView (editor.view.components.obj.ChainView)
package editor.view.components.obj {
import editor.model.objects.*;
import flash.geom.*;
import editor.view.components.support.*;
public class ChainView extends ObjView {
private var anchor1:ChainTargetSup;
public var chainObj:ChainDef;
private var anchor2:ChainTargetSup;
public function ChainView(_arg1:ChainDef):void{
this.chainObj = _arg1;
super(_arg1);
}
override protected function createSupportStuff():void{
anchor1 = new ChainTargetSup(chainObj, ChainTargetSup.POS_FIRST);
anchor2 = new ChainTargetSup(chainObj, ChainTargetSup.POS_SECOND);
anchor1.visible = false;
anchor2.visible = false;
}
override protected function updateFrame():void{
frame.x = obj.x;
frame.y = obj.y;
var _local1:Rectangle = obj.getBoundingBox();
frame.graphics.clear();
frame.graphics.lineStyle(0, 6710937);
frame.graphics.drawRect(_local1.x, _local1.y, _local1.width, _local1.height);
}
override protected function updateSkin():void{
skin.graphics.clear();
skin.graphics.lineStyle(2, 0x6666);
skin.graphics.moveTo(chainObj.x, chainObj.y);
skin.graphics.lineTo(chainObj.x2, chainObj.y2);
super.updateSkin();
}
override public function update():void{
anchor1.update();
anchor2.update();
updateSkin();
updateFrame();
}
override public function deselect():void{
super.deselect();
anchor1.deselect();
anchor2.deselect();
}
override public function select():void{
super.select();
if (editorProxy.getSelectedObjects().length > 1){
return;
};
anchor1.select();
anchor2.select();
}
override protected function destroySupportStuff():void{
anchor1.destroy();
anchor2.destroy();
}
}
}//package editor.view.components.obj
Section 174
//CircleView (editor.view.components.obj.CircleView)
package editor.view.components.obj {
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
import editor.view.components.support.*;
public class CircleView extends ObjView {
private var circleObj:CircleDef;
private var scale:CircleScaleSup;
public function CircleView(_arg1:CircleDef):void{
circleObj = _arg1;
super(_arg1);
}
override protected function createSupportStuff():void{
scale = new CircleScaleSup(circleObj);
}
override protected function updateSkin():void{
var _local1:Class;
if (circleObj.type == BaseObjectDef.TYPE_BRICK){
_local1 = EditorAssets.getInstance().getAssetClass("StaticBMDAsset");
} else {
if (circleObj.type == BaseObjectDef.TYPE_METAL){
_local1 = EditorAssets.getInstance().getAssetClass("DynamicBMDAsset");
} else {
if (circleObj.type == BaseObjectDef.TYPE_WOOD){
_local1 = EditorAssets.getInstance().getAssetClass("StickyBMDAsset");
} else {
if (circleObj.type == BaseObjectDef.TYPE_KILLER){
_local1 = EditorAssets.getInstance().getAssetClass("KillerBMDAsset");
} else {
if (circleObj.type == BaseObjectDef.TYPE_RUBBER){
_local1 = EditorAssets.getInstance().getAssetClass("RubberBMDAsset");
};
};
};
};
};
var _local2:BitmapData = (new _local1(0, 0) as BitmapData);
skin.graphics.clear();
skin.graphics.beginBitmapFill(_local2, null, true, true);
skin.graphics.lineStyle(0, 0, 1);
skin.graphics.drawCircle(0, 0, circleObj.r);
skin.graphics.endFill();
}
override public function update():void{
super.update();
scale.update();
}
override public function select():void{
super.select();
if (editorProxy.getSelectedObjects().length > 1){
return;
};
scale.select();
}
override public function deselect():void{
super.deselect();
scale.deselect();
}
override protected function destroySupportStuff():void{
scale.destroy();
}
}
}//package editor.view.components.obj
Section 175
//DistJointView (editor.view.components.obj.DistJointView)
package editor.view.components.obj {
import editor.model.objects.*;
import flash.geom.*;
import editor.view.components.support.*;
public class DistJointView extends ObjView {
public var jointObj:DistJointDef;
private var anchor1:DistJointTargetSup;
private var anchor2:DistJointTargetSup;
public function DistJointView(_arg1:DistJointDef):void{
this.jointObj = _arg1;
super(_arg1);
}
override protected function createSupportStuff():void{
anchor1 = new DistJointTargetSup(jointObj, DistJointTargetSup.POS_FIRST);
anchor2 = new DistJointTargetSup(jointObj, DistJointTargetSup.POS_SECOND);
anchor1.visible = false;
anchor2.visible = false;
}
override public function select():void{
super.select();
if (editorProxy.getSelectedObjects().length > 1){
return;
};
anchor1.select();
anchor2.select();
}
override protected function updateFrame():void{
frame.x = obj.x;
frame.y = obj.y;
var _local1:Rectangle = obj.getBoundingBox();
frame.graphics.clear();
frame.graphics.lineStyle(0, 6710937);
frame.graphics.drawRect(_local1.x, _local1.y, _local1.width, _local1.height);
}
override protected function updateSkin():void{
skin.graphics.clear();
skin.graphics.lineStyle(2, 0x666600);
skin.graphics.moveTo(jointObj.x1, jointObj.y1);
skin.graphics.lineTo(jointObj.x2, jointObj.y2);
super.updateSkin();
}
override public function update():void{
anchor1.update();
anchor2.update();
updateSkin();
updateFrame();
}
override public function deselect():void{
super.deselect();
anchor1.deselect();
anchor2.deselect();
}
override protected function destroySupportStuff():void{
anchor1.destroy();
anchor2.destroy();
}
}
}//package editor.view.components.obj
Section 176
//MotorView (editor.view.components.obj.MotorView)
package editor.view.components.obj {
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
import editor.view.components.support.*;
public class MotorView extends ObjView {
private var motorObj:MotorDef;
private var torque:MotorTorqueSup;
private var skinCw:Sprite;
private var skinCcw:Sprite;
public function MotorView(_arg1:MotorDef):void{
motorObj = _arg1;
super(_arg1);
}
override protected function createSupportStuff():void{
torque = new MotorTorqueSup(motorObj, skinCw, skinCcw);
}
override public function update():void{
super.update();
torque.update();
}
override protected function createSkin():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("MotorAsset");
skin = new (_local1);
addChild(skin);
skinCw = (skin.getChildByName("cw") as Sprite);
skinCcw = (skin.getChildByName("ccw") as Sprite);
}
override public function select():void{
super.select();
if (editorProxy.getSelectedObjects().length > 1){
return;
};
torque.select();
}
override public function deselect():void{
super.deselect();
torque.deselect();
}
override protected function destroySupportStuff():void{
torque.destroy();
}
}
}//package editor.view.components.obj
Section 177
//ObjView (editor.view.components.obj.ObjView)
package editor.view.components.obj {
import flash.events.*;
import editor.model.*;
import game.model.*;
import flash.display.*;
import editor.model.objects.*;
import flash.geom.*;
import editor.view.components.*;
import editor.view.*;
public class ObjView extends Sprite {
protected var editorProxy:EditorProxy;
protected var skin:Sprite;
protected var support:Sprite;
protected var canvas:Sprite;
protected var frame:Sprite;
protected var notesProxy:NotesProxy;
public var obj:BaseObjectDef;
public function ObjView(_arg1:BaseObjectDef):void{
this.obj = _arg1;
init();
}
protected function createSupportStuff():void{
}
public function update():void{
x = obj.x;
y = obj.y;
updateSkin();
updateFrame();
}
protected function mouseUpHandler(_arg1:MouseEvent):void{
obj.x = parent.mouseX;
obj.y = parent.mouseY;
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
notesProxy.push(EditorProxy.OBJECT_UPDATE, obj);
}
protected function init():void{
var _local1:ApplicationFacade = ApplicationFacade.getInstance();
notesProxy = (_local1.retrieveProxy(NotesProxy.NAME) as NotesProxy);
var _local2:EditorMediator = (_local1.retrieveMediator(EditorMediator.NAME) as EditorMediator);
canvas = (_local2.getViewComponent() as EditorView).canvas;
support = (_local2.getViewComponent() as EditorView).support;
editorProxy = (_local1.retrieveProxy(EditorProxy.NAME) as EditorProxy);
createSkin();
frame = new Sprite();
addChild(frame);
createSupportStuff();
frame.visible = false;
update();
}
public function destroy():void{
parent.removeChild(this);
destroySupportStuff();
}
protected function mouseMoveHandler(_arg1:MouseEvent):void{
}
protected function createSkin():void{
skin = new Sprite();
addChild(skin);
}
protected function mouseDownHandler(_arg1:MouseEvent):void{
notesProxy.push(EditorProxy.OBJECTS_SELECT, [obj]);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
protected function updateFrame():void{
var _local1:Rectangle = obj.getBoundingBox();
var _local2:Point = frame.globalToLocal(new Point(_local1.x, _local1.y));
frame.graphics.clear();
frame.graphics.lineStyle(0, 6710937);
frame.graphics.drawRect(_local1.x, _local1.y, _local1.width, _local1.height);
frame.graphics.lineStyle(0, 0);
frame.graphics.moveTo(-3, 0);
frame.graphics.lineTo(3, 0);
frame.graphics.moveTo(0, -3);
frame.graphics.lineTo(0, 3);
}
protected function updateSkin():void{
}
public function select():void{
frame.visible = true;
}
public function deselect():void{
frame.visible = false;
}
protected function destroySupportStuff():void{
}
}
}//package editor.view.components.obj
Section 178
//PolyView (editor.view.components.obj.PolyView)
package editor.view.components.obj {
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
import flash.geom.*;
import editor.view.components.support.*;
public class PolyView extends ObjView {
private var polyObj:PolyDef;
private var pointSups:Array;
public function PolyView(_arg1:PolyDef):void{
polyObj = _arg1;
super(_arg1);
}
override protected function createSupportStuff():void{
createPoints();
}
private function destroyPoints():void{
var _local2:PolyPointSup;
var _local1:uint;
while (_local1 < pointSups.length) {
_local2 = pointSups[_local1];
_local2.destroy();
_local1++;
};
}
override protected function updateSkin():void{
var _local1:Class;
var _local5:Point;
if (polyObj.type == BaseObjectDef.TYPE_BRICK){
_local1 = EditorAssets.getInstance().getAssetClass("StaticBMDAsset");
} else {
if (polyObj.type == BaseObjectDef.TYPE_METAL){
_local1 = EditorAssets.getInstance().getAssetClass("DynamicBMDAsset");
} else {
if (polyObj.type == BaseObjectDef.TYPE_KILLER){
_local1 = EditorAssets.getInstance().getAssetClass("KillerBMDAsset");
} else {
if (polyObj.type == BaseObjectDef.TYPE_WOOD){
_local1 = EditorAssets.getInstance().getAssetClass("StickyBMDAsset");
} else {
if (polyObj.type == BaseObjectDef.TYPE_RUBBER){
_local1 = EditorAssets.getInstance().getAssetClass("RubberBMDAsset");
};
};
};
};
};
var _local2:BitmapData = (new _local1(0, 0) as BitmapData);
skin.graphics.clear();
skin.graphics.beginBitmapFill(_local2, null, true, true);
skin.graphics.lineStyle(0, 0, 1);
var _local3:Point = polyObj.vertices[0];
skin.graphics.moveTo(_local3.x, _local3.y);
var _local4:uint = 1;
while (_local4 < polyObj.vertices.length) {
_local5 = polyObj.vertices[_local4];
skin.graphics.lineTo(_local5.x, _local5.y);
_local4++;
};
skin.graphics.lineTo(_local3.x, _local3.y);
skin.graphics.endFill();
alpha = (polyObj.isSimple()) ? 1 : 0.5;
}
override public function update():void{
super.update();
if (polyObj.vertices.length == pointSups.length){
updatePoints();
} else {
destroyPoints();
createPoints();
updatePoints();
selectPoints();
};
}
private function updatePoints():void{
var _local2:PolyPointSup;
var _local1:uint;
while (_local1 < pointSups.length) {
_local2 = pointSups[_local1];
_local2.update();
_local1++;
};
}
private function createPoints():void{
var _local2:Point;
var _local3:PolyPointSup;
pointSups = [];
var _local1:uint;
while (_local1 < polyObj.vertices.length) {
_local2 = polyObj.vertices[_local1];
_local3 = new PolyPointSup(polyObj, _local2);
pointSups.push(_local3);
_local1++;
};
}
override protected function destroySupportStuff():void{
destroyPoints();
}
override public function select():void{
super.select();
if (editorProxy.getSelectedObjects().length > 1){
return;
};
selectPoints();
}
override public function deselect():void{
var _local2:PolyPointSup;
super.deselect();
var _local1:uint;
while (_local1 < pointSups.length) {
_local2 = pointSups[_local1];
_local2.deselect();
_local1++;
};
}
private function selectPoints():void{
var _local2:PolyPointSup;
var _local1:uint;
while (_local1 < pointSups.length) {
_local2 = pointSups[_local1];
_local2.select();
_local1++;
};
}
}
}//package editor.view.components.obj
Section 179
//RectView (editor.view.components.obj.RectView)
package editor.view.components.obj {
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
import flash.geom.*;
import editor.view.components.support.*;
public class RectView extends ObjView {
private var scale:RectScaleSup;
private var rectObj:RectDef;
private var rotate:RectRotateSup;
public function RectView(_arg1:RectDef):void{
rectObj = _arg1;
super(_arg1);
}
override protected function createSupportStuff():void{
scale = new RectScaleSup(rectObj);
rotate = new RectRotateSup(rectObj);
}
override protected function updateSkin():void{
var _local1:Class;
var _local5:Point;
if (rectObj.type == BaseObjectDef.TYPE_BRICK){
_local1 = EditorAssets.getInstance().getAssetClass("StaticBMDAsset");
} else {
if (rectObj.type == BaseObjectDef.TYPE_METAL){
_local1 = EditorAssets.getInstance().getAssetClass("DynamicBMDAsset");
} else {
if (rectObj.type == BaseObjectDef.TYPE_KILLER){
_local1 = EditorAssets.getInstance().getAssetClass("KillerBMDAsset");
} else {
if (rectObj.type == BaseObjectDef.TYPE_WOOD){
_local1 = EditorAssets.getInstance().getAssetClass("StickyBMDAsset");
} else {
if (rectObj.type == BaseObjectDef.TYPE_RUBBER){
_local1 = EditorAssets.getInstance().getAssetClass("RubberBMDAsset");
};
};
};
};
};
var _local2:BitmapData = (new _local1(0, 0) as BitmapData);
skin.graphics.clear();
skin.graphics.beginBitmapFill(_local2, null, true, true);
skin.graphics.lineStyle(0, 0, 1);
var _local3:Point = rectObj.vertices[0];
skin.graphics.moveTo(_local3.x, _local3.y);
var _local4:uint = 1;
while (_local4 < rectObj.vertices.length) {
_local5 = rectObj.vertices[_local4];
skin.graphics.lineTo(_local5.x, _local5.y);
_local4++;
};
skin.graphics.lineTo(_local3.x, _local3.y);
skin.graphics.endFill();
}
override public function update():void{
super.update();
scale.update();
rotate.update();
}
override protected function init():void{
super.init();
}
override public function select():void{
super.select();
if (editorProxy.getSelectedObjects().length > 1){
return;
};
scale.select();
rotate.select();
}
override public function deselect():void{
super.deselect();
scale.deselect();
rotate.deselect();
}
override protected function destroySupportStuff():void{
scale.destroy();
rotate.destroy();
}
}
}//package editor.view.components.obj
Section 180
//SimpleView (editor.view.components.obj.SimpleView)
package editor.view.components.obj {
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
public class SimpleView extends ObjView {
public function SimpleView(_arg1:BaseObjectDef):void{
super(_arg1);
}
private function getSimpleObjClass(_arg1:SimpleObjDef):Class{
var _local3:String;
var _local2:EditorAssets = EditorAssets.getInstance();
switch (_arg1.type){
case SimpleObjDef.TYPE_BOTTLE:
_local3 = "BottleAsset";
break;
case SimpleObjDef.TYPE_MONITOR:
_local3 = "MonitorAsset";
break;
default:
return (null);
};
return (_local2.getAssetClass(_local3));
}
override protected function createSkin():void{
var _local2:Class;
super.createSkin();
var _local1:EditorAssets = EditorAssets.getInstance();
if ((obj is PlayerDef)){
_local2 = _local1.getAssetClass("PlayerAsset");
} else {
if ((obj is RevJointDef)){
_local2 = _local1.getAssetClass("HingeAsset");
} else {
if ((obj is SimpleObjDef)){
_local2 = getSimpleObjClass((obj as SimpleObjDef));
} else {
return;
};
};
};
var _local3:Sprite = new (_local2);
skin.addChild(_local3);
}
}
}//package editor.view.components.obj
Section 181
//CirclePropsView (editor.view.components.props.CirclePropsView)
package editor.view.components.props {
import flash.display.*;
import editor.model.objects.*;
public class CirclePropsView extends ObjPropsView {
private var circleObj:CircleDef;
private var rubberMat:MaterialProp;
private var woodMat:MaterialProp;
private var killerMat:MaterialProp;
private var metallMat:MaterialProp;
private var brickMat:MaterialProp;
public function CirclePropsView(_arg1:CircleDef):void{
circleObj = _arg1;
super(_arg1);
}
override public function destroy():void{
super.destroy();
woodMat.destroy();
metallMat.destroy();
brickMat.destroy();
killerMat.destroy();
rubberMat.destroy();
}
override public function update():void{
woodMat.deselect();
metallMat.deselect();
brickMat.deselect();
killerMat.deselect();
rubberMat.deselect();
if (circleObj.type == BaseObjectDef.TYPE_WOOD){
woodMat.select();
} else {
if (circleObj.type == BaseObjectDef.TYPE_METAL){
metallMat.select();
} else {
if (circleObj.type == BaseObjectDef.TYPE_BRICK){
brickMat.select();
} else {
if (circleObj.type == BaseObjectDef.TYPE_KILLER){
killerMat.select();
} else {
if (circleObj.type == BaseObjectDef.TYPE_RUBBER){
rubberMat.select();
};
};
};
};
};
}
override protected function createSkin():void{
super.createSkin();
var _local1:Sprite = (window.getChildByName("woodMat") as Sprite);
var _local2:Sprite = (window.getChildByName("metallMat") as Sprite);
var _local3:Sprite = (window.getChildByName("brickMat") as Sprite);
var _local4:Sprite = (window.getChildByName("killerMat") as Sprite);
var _local5:Sprite = (window.getChildByName("rubberMat") as Sprite);
woodMat = new MaterialProp(_local1, circleObj, BaseObjectDef.TYPE_WOOD);
metallMat = new MaterialProp(_local2, circleObj, BaseObjectDef.TYPE_METAL);
brickMat = new MaterialProp(_local3, circleObj, BaseObjectDef.TYPE_BRICK);
killerMat = new MaterialProp(_local4, circleObj, BaseObjectDef.TYPE_KILLER);
rubberMat = new MaterialProp(_local5, circleObj, BaseObjectDef.TYPE_RUBBER);
}
override protected function getWindowClassName():String{
return ("CirclePropsWindow");
}
}
}//package editor.view.components.props
Section 182
//MaterialProp (editor.view.components.props.MaterialProp)
package editor.view.components.props {
import flash.events.*;
import editor.model.*;
import game.model.*;
import flash.display.*;
import editor.model.objects.*;
public class MaterialProp extends EventDispatcher {
private var type:String;
private var notesProxy:NotesProxy;
private var window:Sprite;
private var obj:BaseObjectDef;
private var frame:Sprite;
public function MaterialProp(_arg1:Sprite, _arg2:BaseObjectDef, _arg3:String):void{
this.window = _arg1;
this.obj = _arg2;
this.type = _arg3;
init();
}
public function select():void{
frame.visible = true;
}
public function destroy():void{
window.removeEventListener(MouseEvent.CLICK, windowClickHandler);
}
private function windowClickHandler(_arg1:MouseEvent):void{
if ((obj is CircleDef)){
(obj as CircleDef).type = type;
} else {
if ((obj is PolyDef)){
(obj as PolyDef).type = type;
};
};
notesProxy.push(EditorProxy.OBJECT_UPDATE, obj);
}
public function deselect():void{
frame.visible = false;
}
private function init():void{
var _local1:ApplicationFacade = ApplicationFacade.getInstance();
notesProxy = (_local1.retrieveProxy(NotesProxy.NAME) as NotesProxy);
frame = (window.getChildByName("frame") as Sprite);
frame.visible = false;
window.addEventListener(MouseEvent.CLICK, windowClickHandler);
}
}
}//package editor.view.components.props
Section 183
//ObjPropsView (editor.view.components.props.ObjPropsView)
package editor.view.components.props {
import flash.events.*;
import editor.model.*;
import game.model.*;
import flash.display.*;
import editor.model.objects.*;
public class ObjPropsView extends Sprite {
protected var facade:ApplicationFacade;
protected var delete_bt:SimpleButton;
protected var notesProxy:NotesProxy;
protected var window:Sprite;
public var obj:BaseObjectDef;
public function ObjPropsView(_arg1:BaseObjectDef):void{
this.obj = _arg1;
init();
}
public function update():void{
}
public function destroy():void{
delete_bt.removeEventListener(MouseEvent.CLICK, deleteClickHandler);
window.parent.removeChild(window);
}
protected function createSkin():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass(getWindowClassName());
window = new (_local1);
addChild(window);
delete_bt = (window.getChildByName("delete_bt") as SimpleButton);
delete_bt.addEventListener(MouseEvent.CLICK, deleteClickHandler);
}
protected function deleteClickHandler(_arg1:MouseEvent):void{
notesProxy.push(EditorProxy.OBJECT_REMOVE, obj);
}
protected function getWindowClassName():String{
return ("ObjPropsWindow");
}
protected function init():void{
facade = ApplicationFacade.getInstance();
notesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
createSkin();
update();
}
}
}//package editor.view.components.props
Section 184
//PolyPropsView (editor.view.components.props.PolyPropsView)
package editor.view.components.props {
import flash.display.*;
import editor.model.objects.*;
public class PolyPropsView extends ObjPropsView {
private var polyObj:PolyDef;
private var rubberMat:MaterialProp;
private var woodMat:MaterialProp;
private var killerMat:MaterialProp;
private var metallMat:MaterialProp;
private var brickMat:MaterialProp;
public function PolyPropsView(_arg1:PolyDef):void{
polyObj = _arg1;
super(_arg1);
}
override public function destroy():void{
super.destroy();
woodMat.destroy();
metallMat.destroy();
brickMat.destroy();
killerMat.destroy();
rubberMat.destroy();
}
override protected function getWindowClassName():String{
return ("RectPropsWindow");
}
override public function update():void{
woodMat.deselect();
metallMat.deselect();
brickMat.deselect();
killerMat.deselect();
rubberMat.deselect();
if (polyObj.type == BaseObjectDef.TYPE_WOOD){
woodMat.select();
} else {
if (polyObj.type == BaseObjectDef.TYPE_METAL){
metallMat.select();
} else {
if (polyObj.type == BaseObjectDef.TYPE_BRICK){
brickMat.select();
} else {
if (polyObj.type == BaseObjectDef.TYPE_KILLER){
killerMat.select();
} else {
if (polyObj.type == BaseObjectDef.TYPE_RUBBER){
rubberMat.select();
};
};
};
};
};
}
override protected function createSkin():void{
super.createSkin();
var _local1:Sprite = (window.getChildByName("woodMat") as Sprite);
var _local2:Sprite = (window.getChildByName("metallMat") as Sprite);
var _local3:Sprite = (window.getChildByName("brickMat") as Sprite);
var _local4:Sprite = (window.getChildByName("killerMat") as Sprite);
var _local5:Sprite = (window.getChildByName("rubberMat") as Sprite);
woodMat = new MaterialProp(_local1, polyObj, BaseObjectDef.TYPE_WOOD);
metallMat = new MaterialProp(_local2, polyObj, BaseObjectDef.TYPE_METAL);
brickMat = new MaterialProp(_local3, polyObj, BaseObjectDef.TYPE_BRICK);
killerMat = new MaterialProp(_local4, polyObj, BaseObjectDef.TYPE_KILLER);
rubberMat = new MaterialProp(_local5, polyObj, BaseObjectDef.TYPE_RUBBER);
}
}
}//package editor.view.components.props
Section 185
//SeveralObjsPropsView (editor.view.components.props.SeveralObjsPropsView)
package editor.view.components.props {
import flash.events.*;
import editor.model.*;
import editor.model.objects.*;
public class SeveralObjsPropsView extends ObjPropsView {
public function SeveralObjsPropsView(_arg1:BaseObjectDef):void{
super(_arg1);
}
override protected function deleteClickHandler(_arg1:MouseEvent):void{
var _local2:EditorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
_local2.deleteSelectedObjects();
}
override protected function getWindowClassName():String{
return ("SeveralObjsPropsWindow");
}
}
}//package editor.view.components.props
Section 186
//ShapeHolderItem (editor.view.components.shapes.ShapeHolderItem)
package editor.view.components.shapes {
import flash.events.*;
import editor.model.*;
import core.*;
import game.model.*;
import flash.display.*;
import core.shapes.*;
import editor.model.objects.*;
public class ShapeHolderItem extends Sprite {
private var shape:BaseShape;
private var skinShape:Sprite;
private var container:Sprite;
private var notesProxy:NotesProxy;
private var window:Sprite;
private var editorProxy:EditorProxy;
public var id:int;
public function ShapeHolderItem(_arg1:int):void{
this.id = _arg1;
init();
}
public function isObjectInside(_arg1:BaseObjectDef):Boolean{
if (window.hitTestPoint(_arg1.x, _arg1.y, true)){
return (true);
};
return (false);
}
public function addShape(_arg1:BaseShape):void{
this.shape = _arg1;
createShape(_arg1);
skinShape.addEventListener(MouseEvent.MOUSE_DOWN, shapeMouseDownHandler);
}
private function shapeMouseDownHandler(_arg1:MouseEvent):void{
notesProxy.push(EditorProxy.SHAPE_REMOVE, [shape, id]);
var _local2:BaseObjectDef = editorProxy.shapeToObj(shape, 320, 240);
if (_local2){
notesProxy.push(EditorProxy.OBJECT_ADD, _local2);
};
skinShape.graphics.clear();
skinShape.removeEventListener(MouseEvent.MOUSE_DOWN, shapeMouseDownHandler);
}
private function createShape(_arg1:BaseShape):void{
var _local3:Number;
var _local4:Number;
var _local2:Number = 50;
skinShape.graphics.clear();
skinShape.scaleX = (skinShape.scaleY = 1);
_arg1.draw(skinShape, new BodyMaterial(BodyMaterial.TYPE_WOOD));
if ((_arg1 is CircleShape)){
if (skinShape.width > _local2){
skinShape.width = (skinShape.height = _local2);
};
} else {
if ((_arg1 is RectShape)){
if ((((skinShape.width > _local2)) || ((skinShape.height > _local2)))){
_local3 = ((skinShape.width >= skinShape.height)) ? skinShape.width : skinShape.height;
_local4 = (_local2 / _local3);
skinShape.width = (skinShape.width * _local4);
skinShape.height = (skinShape.height * _local4);
};
};
};
}
private function init():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("ShapeHolderItemWindow");
window = new (_local1);
addChild(window);
container = (window.getChildByName("container") as Sprite);
skinShape = new Sprite();
skinShape.buttonMode = true;
container.addChild(skinShape);
var _local2:ApplicationFacade = ApplicationFacade.getInstance();
notesProxy = (_local2.retrieveProxy(NotesProxy.NAME) as NotesProxy);
editorProxy = (_local2.retrieveProxy(EditorProxy.NAME) as EditorProxy);
}
}
}//package editor.view.components.shapes
Section 187
//ChainTargetSup (editor.view.components.support.ChainTargetSup)
package editor.view.components.support {
import flash.events.*;
import editor.model.*;
import editor.model.objects.*;
import flash.geom.*;
public class ChainTargetSup extends ObjSup {
private var pos:String;
private var chainObj:ChainDef;
public static const POS_FIRST:String = "PosFirst";
public static const POS_SECOND:String = "PosSecond";
public function ChainTargetSup(_arg1:ChainDef, _arg2:String):void{
chainObj = _arg1;
this.pos = _arg2;
super(_arg1);
}
override public function update():void{
if (pos == POS_FIRST){
x = chainObj.x;
y = chainObj.y;
} else {
x = chainObj.x2;
y = chainObj.y2;
};
}
private function mouseUpHandler(_arg1:MouseEvent):void{
var _local2:Point = gridProxy.getSnapPoint(new Point(support.mouseX, support.mouseY));
if (pos == POS_FIRST){
chainObj.x = _local2.x;
chainObj.y = _local2.y;
} else {
chainObj.x2 = _local2.x;
chainObj.y2 = _local2.y;
};
notesProxy.push(EditorProxy.OBJECT_UPDATE, chainObj);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
override public function destroy():void{
super.destroy();
removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
override protected function createSkin():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("DistanceJointVertex");
skin = new (_local1);
addChild(skin);
support.addChild(this);
buttonMode = true;
}
private function mouseDownHandler(_arg1:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
private function mouseMoveHandler(_arg1:MouseEvent):void{
var _local2:Point;
_local2 = gridProxy.getSnapPoint(new Point(support.mouseX, support.mouseY));
x = _local2.x;
y = _local2.y;
}
override protected function initListeners():void{
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
}
}//package editor.view.components.support
Section 188
//CircleScaleSup (editor.view.components.support.CircleScaleSup)
package editor.view.components.support {
import flash.events.*;
import editor.model.*;
import editor.model.objects.*;
import flash.geom.*;
public class CircleScaleSup extends ObjSup {
private var radius:Number;
private var circleObj:CircleDef;
public function CircleScaleSup(_arg1:CircleDef):void{
circleObj = _arg1;
super(_arg1);
}
override public function update():void{
x = (circleObj.x + circleObj.r);
y = circleObj.y;
}
private function mouseUpHandler(_arg1:MouseEvent):void{
circleObj.r = radius;
notesProxy.push(EditorProxy.OBJECT_UPDATE, circleObj);
support.graphics.clear();
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
override protected function createSkin():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("ScaleAsset");
skin = new (_local1);
addChild(skin);
support.addChild(this);
}
private function mouseDownHandler(_arg1:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
private function mouseMoveHandler(_arg1:MouseEvent):void{
support.graphics.clear();
support.graphics.lineStyle(0, 1);
radius = gridProxy.getSnapPoint(new Point((support.mouseX - circleObj.x), 0)).x;
if (radius < 1){
radius = 1;
};
support.graphics.drawCircle(circleObj.x, circleObj.y, radius);
}
override public function destroy():void{
super.destroy();
removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
override protected function initListeners():void{
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
}
}//package editor.view.components.support
Section 189
//DistJointTargetSup (editor.view.components.support.DistJointTargetSup)
package editor.view.components.support {
import flash.events.*;
import editor.model.*;
import editor.model.objects.*;
import flash.geom.*;
public class DistJointTargetSup extends ObjSup {
private var pos:String;
private var jointObj:DistJointDef;
public static const POS_FIRST:String = "PosFirst";
public static const POS_SECOND:String = "PosSecond";
public function DistJointTargetSup(_arg1:DistJointDef, _arg2:String):void{
jointObj = _arg1;
this.pos = _arg2;
super(_arg1);
}
override public function update():void{
if (pos == POS_FIRST){
x = jointObj.x1;
y = jointObj.y1;
} else {
x = jointObj.x2;
y = jointObj.y2;
};
}
private function mouseUpHandler(_arg1:MouseEvent):void{
var _local2:Point = gridProxy.getSnapPoint(new Point(support.mouseX, support.mouseY));
if (pos == POS_FIRST){
jointObj.x1 = _local2.x;
jointObj.y1 = _local2.y;
} else {
jointObj.x2 = _local2.x;
jointObj.y2 = _local2.y;
};
jointObj.x = (jointObj.x1 + ((jointObj.x2 - jointObj.x1) / 2));
jointObj.y = (jointObj.y1 + ((jointObj.y2 - jointObj.y1) / 2));
notesProxy.push(EditorProxy.OBJECT_UPDATE, jointObj);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
private function mouseDownHandler(_arg1:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
override protected function createSkin():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("DistanceJointVertex");
skin = new (_local1);
addChild(skin);
support.addChild(this);
buttonMode = true;
}
private function mouseMoveHandler(_arg1:MouseEvent):void{
var _local2:Point;
_local2 = gridProxy.getSnapPoint(new Point(support.mouseX, support.mouseY));
x = _local2.x;
y = _local2.y;
}
override public function destroy():void{
super.destroy();
removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
override protected function initListeners():void{
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
}
}//package editor.view.components.support
Section 190
//MotorTorqueSup (editor.view.components.support.MotorTorqueSup)
package editor.view.components.support {
import flash.events.*;
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
public class MotorTorqueSup extends ObjSup {
private var motorObj:MotorDef;
private var skinCw:Sprite;
private var skinBar:Sprite;
private var skinCcw:Sprite;
public function MotorTorqueSup(_arg1:MotorDef, _arg2:Sprite, _arg3:Sprite):void{
motorObj = _arg1;
this.skinCw = _arg2;
this.skinCcw = _arg3;
super(_arg1);
}
override public function destroy():void{
super.destroy();
removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
private function mouseDownHandler(_arg1:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
private function mouseUpHandler(_arg1:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
motorObj.torque = skinBar.scaleX;
notesProxy.push(EditorProxy.OBJECT_UPDATE, motorObj);
}
override protected function initListeners():void{
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
override public function update():void{
x = motorObj.x;
y = (motorObj.y - 20);
skinBar.scaleX = motorObj.torque;
if (motorObj.torque == 0){
skinCw.visible = true;
skinCcw.visible = false;
} else {
if (motorObj.torque > 0){
skinCw.visible = true;
skinCcw.visible = false;
} else {
skinCw.visible = false;
skinCcw.visible = true;
};
};
}
override protected function createSkin():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("RevJointTorqueAsset");
skin = new (_local1);
addChild(skin);
support.addChild(this);
skinBar = (skin.getChildByName("bar") as Sprite);
buttonMode = true;
}
private function mouseMoveHandler(_arg1:MouseEvent):void{
var _local2:Number = skin.mouseX;
if (_local2 > 50){
_local2 = 50;
};
if (_local2 < -50){
_local2 = -50;
};
_local2 = (Math.round((_local2 / 5)) * 5);
skinBar.scaleX = (_local2 / 50);
}
}
}//package editor.view.components.support
Section 191
//ObjSup (editor.view.components.support.ObjSup)
package editor.view.components.support {
import editor.model.*;
import game.model.*;
import flash.display.*;
import editor.model.objects.*;
import editor.view.components.*;
import editor.view.*;
public class ObjSup extends Sprite {
protected var gridProxy:GridProxy;
protected var notesProxy:NotesProxy;
protected var support:Sprite;
protected var skin:Sprite;
public var obj:BaseObjectDef;
public function ObjSup(_arg1:BaseObjectDef):void{
this.obj = obj;
init();
}
public function deselect():void{
visible = false;
}
public function update():void{
}
public function destroy():void{
parent.removeChild(this);
}
protected function initListeners():void{
}
protected function init():void{
var _local1:ApplicationFacade = ApplicationFacade.getInstance();
var _local2:EditorMediator = (_local1.retrieveMediator(EditorMediator.NAME) as EditorMediator);
support = (_local2.getViewComponent() as EditorView).support;
notesProxy = (_local1.retrieveProxy(NotesProxy.NAME) as NotesProxy);
gridProxy = (_local1.retrieveProxy(GridProxy.NAME) as GridProxy);
createSkin();
initListeners();
deselect();
}
protected function createSkin():void{
}
public function select():void{
visible = true;
}
}
}//package editor.view.components.support
Section 192
//PolyPointSup (editor.view.components.support.PolyPointSup)
package editor.view.components.support {
import flash.events.*;
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
import flash.geom.*;
public class PolyPointSup extends ObjSup {
private var vertex:Point;
private var polyObj:PolyDef;
private var skinSquare:Sprite;
public function PolyPointSup(_arg1:PolyDef, _arg2:Point):void{
polyObj = _arg1;
this.vertex = _arg2;
super(_arg1);
}
private function squareMouseDownHandler(_arg1:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
override public function destroy():void{
super.destroy();
skinSquare.removeEventListener(MouseEvent.MOUSE_DOWN, squareMouseDownHandler);
}
override public function update():void{
x = (vertex.x + polyObj.x);
y = (vertex.y + polyObj.y);
}
private function mouseUpHandler(_arg1:MouseEvent):void{
vertex.x = (x - polyObj.x);
vertex.y = (y - polyObj.y);
notesProxy.push(EditorProxy.OBJECT_UPDATE, polyObj);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
override protected function initListeners():void{
skinSquare.addEventListener(MouseEvent.MOUSE_DOWN, squareMouseDownHandler);
}
override protected function createSkin():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("PolyPointAsset");
skin = new (_local1);
skinSquare = (skin.getChildByName("square") as Sprite);
addChild(skin);
support.addChild(this);
skinSquare.buttonMode = true;
}
private function mouseMoveHandler(_arg1:MouseEvent):void{
var _local2:Point;
_local2 = gridProxy.getSnapPoint(new Point(Math.round(support.mouseX), Math.round(support.mouseY)));
x = _local2.x;
y = _local2.y;
}
}
}//package editor.view.components.support
Section 193
//RectRotateSup (editor.view.components.support.RectRotateSup)
package editor.view.components.support {
import flash.events.*;
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
public class RectRotateSup extends ObjSup {
private var holst:Sprite;
private var rectObj:RectDef;
public function RectRotateSup(_arg1:RectDef):void{
rectObj = _arg1;
super(_arg1);
}
override public function update():void{
x = (rectObj.x + 10);
y = (rectObj.y + 0);
}
private function mouseUpHandler(_arg1:MouseEvent):void{
rectObj.setRotation(holst.rotation);
holst.parent.removeChild(holst);
notesProxy.push(EditorProxy.OBJECT_UPDATE, rectObj);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
private function mouseDownHandler(_arg1:MouseEvent):void{
holst = new Sprite();
holst.x = rectObj.x;
holst.y = rectObj.y;
support.addChild(holst);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
private function mouseMoveHandler(_arg1:MouseEvent):void{
var _local2:Number = Math.atan2((support.mouseY - rectObj.y), (support.mouseX - rectObj.x));
_local2 = (_local2 * (180 / Math.PI));
_local2 = (5 * Math.floor((_local2 / 5)));
holst.rotation = _local2;
holst.graphics.clear();
holst.graphics.lineStyle(0, 1);
holst.graphics.drawRect((-(rectObj.width) / 2), (-(rectObj.height) / 2), rectObj.width, rectObj.height);
}
override public function destroy():void{
super.destroy();
removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
override protected function createSkin():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("RotateAsset");
skin = new (_local1);
addChild(skin);
support.addChild(this);
}
override protected function initListeners():void{
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
}
}//package editor.view.components.support
Section 194
//RectScaleSup (editor.view.components.support.RectScaleSup)
package editor.view.components.support {
import flash.events.*;
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
import flash.geom.*;
import Box2D.Common.Math.*;
public class RectScaleSup extends ObjSup {
private var h:Number;
private var rectObj:RectDef;
private var veryTempSprite:Sprite;
private var w:Number;
public function RectScaleSup(_arg1:RectDef):void{
rectObj = _arg1;
super(_arg1);
}
override public function destroy():void{
super.destroy();
removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
private function mouseDownHandler(_arg1:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
veryTempSprite = new Sprite();
support.addChild(veryTempSprite);
veryTempSprite.x = rectObj.x;
veryTempSprite.y = rectObj.y;
}
override public function update():void{
var _local1:Point = rectObj.vertices[2];
x = (rectObj.x + _local1.x);
y = (rectObj.y + _local1.y);
}
private function mouseUpHandler(_arg1:MouseEvent):void{
rectObj.setDimensions((w * 2), (h * 2));
notesProxy.push(EditorProxy.OBJECT_UPDATE, rectObj);
veryTempSprite.parent.removeChild(veryTempSprite);
support.graphics.clear();
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
override protected function initListeners():void{
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
private function mouseMoveHandler(_arg1:MouseEvent):void{
var _local2:Point = gridProxy.getSnapPoint(new Point(support.mouseX, support.mouseY));
var _local3:Number = Math.abs(Math.round((_local2.x - rectObj.x)));
var _local4:Number = Math.abs(Math.round((_local2.y - rectObj.y)));
var _local5:b2Vec2 = new b2Vec2(1, 0);
var _local6:b2Mat22 = new b2Mat22();
_local6.Set(((rectObj.rotation * Math.PI) / 180));
_local5 = b2Math.MulMV(_local6, _local5);
var _local7:b2Vec2 = new b2Vec2((_local2.x - rectObj.x), (_local2.y - rectObj.y));
var _local8:Number = b2Math.Dot(_local7, _local5);
_local5.Multiply(_local8);
w = _local5.Length();
_local5 = new b2Vec2(1, 0);
_local6 = new b2Mat22();
_local6.Set((((rectObj.rotation + 90) * Math.PI) / 180));
_local5 = b2Math.MulMV(_local6, _local5);
_local8 = b2Math.Dot(_local7, _local5);
_local5.Multiply(_local8);
h = _local5.Length();
veryTempSprite.rotation = rectObj.rotation;
veryTempSprite.graphics.clear();
veryTempSprite.graphics.lineStyle(0, 1);
veryTempSprite.graphics.moveTo(-(w), -(h));
veryTempSprite.graphics.lineTo(w, -(h));
veryTempSprite.graphics.lineTo(w, h);
veryTempSprite.graphics.lineTo(-(w), h);
veryTempSprite.graphics.lineTo(-(w), -(h));
}
override protected function createSkin():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("ScaleAsset");
skin = new (_local1);
addChild(skin);
support.addChild(this);
}
}
}//package editor.view.components.support
Section 195
//ChainTool (editor.view.components.tools.ChainTool)
package editor.view.components.tools {
import flash.events.*;
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
import flash.geom.*;
public class ChainTool extends ToolView {
private var y1:Number;
private var x1:Number;
public function ChainTool(_arg1:Sprite, _arg2:Tool):void{
super(_arg1, _arg2);
}
override protected function mouseMoveHandler(_arg1:MouseEvent):void{
canvasTop.graphics.clear();
canvasTop.graphics.lineStyle(2, 0x6666);
canvasTop.graphics.moveTo(x1, y1);
var _local2:Point = gridProxy.getSnapPoint(new Point(canvas.mouseX, canvas.mouseY));
canvasTop.graphics.lineTo(_local2.x, _local2.y);
}
override protected function mouseUpHandler(_arg1:MouseEvent):void{
var _local3:Number;
var _local4:Number;
var _local5:ChainDef;
super.mouseUpHandler(_arg1);
canvasTop.graphics.clear();
var _local2:Point = gridProxy.getSnapPoint(new Point(canvas.mouseX, canvas.mouseY));
_local3 = _local2.x;
_local4 = _local2.y;
if (!(((x1 == _local3)) && ((y1 == _local4)))){
_local5 = new ChainDef(x1, y1, _local3, _local4);
notesProxy.push(EditorProxy.OBJECT_ADD, _local5);
};
}
override protected function canvasMouseDownHandler(_arg1:MouseEvent):void{
super.canvasMouseDownHandler(_arg1);
var _local2:Point = gridProxy.getSnapPoint(new Point(canvas.mouseX, canvas.mouseY));
x1 = _local2.x;
y1 = _local2.y;
}
}
}//package editor.view.components.tools
Section 196
//CircleTool (editor.view.components.tools.CircleTool)
package editor.view.components.tools {
import flash.events.*;
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
import flash.geom.*;
public class CircleTool extends ToolView {
private var circle:Sprite;
private var isDrawing:Boolean;
public function CircleTool(_arg1:Sprite, _arg2:Tool):void{
super(_arg1, _arg2);
}
override protected function mouseMoveHandler(_arg1:MouseEvent):void{
circle.graphics.clear();
circle.graphics.lineStyle(0, 0);
var _local2:Point = gridProxy.getSnapPoint(new Point(circle.mouseX, 0));
circle.graphics.drawCircle(0, 0, _local2.x);
}
override protected function init():void{
super.init();
isDrawing = false;
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
if (((isDrawing) && ((_arg1.keyCode == 27)))){
canvas.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
canvas.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
circle.parent.removeChild(circle);
notesProxy.push(EditorProxy.TOOL_SELECT, editorProxy.getTools()[0]);
};
}
override protected function mouseUpHandler(_arg1:MouseEvent):void{
var _local3:CircleDef;
super.mouseUpHandler(_arg1);
circle.parent.removeChild(circle);
isDrawing = false;
var _local2:Number = Math.round((circle.width / 2));
if (_local2 > 0){
_local3 = new CircleDef(circle.x, circle.y, _local2, BaseObjectDef.TYPE_WOOD);
notesProxy.push(EditorProxy.OBJECT_ADD, _local3);
};
}
override protected function canvasMouseDownHandler(_arg1:MouseEvent):void{
super.canvasMouseDownHandler(_arg1);
circle = new Sprite();
var _local2:Point = gridProxy.getSnapPoint(new Point(canvas.mouseX, canvas.mouseY));
circle.x = _local2.x;
circle.y = _local2.y;
bodies.addChild(circle);
isDrawing = true;
}
override public function select():void{
super.select();
window.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
}
override public function deselect():void{
super.deselect();
isDrawing = false;
window.stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
}
}
}//package editor.view.components.tools
Section 197
//DistJointTool (editor.view.components.tools.DistJointTool)
package editor.view.components.tools {
import flash.events.*;
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
import flash.geom.*;
public class DistJointTool extends ToolView {
private var y1:Number;
private var x1:Number;
public function DistJointTool(_arg1:Sprite, _arg2:Tool):void{
super(_arg1, _arg2);
}
override protected function mouseMoveHandler(_arg1:MouseEvent):void{
canvasTop.graphics.clear();
canvasTop.graphics.lineStyle(2, 0x666600);
canvasTop.graphics.moveTo(x1, y1);
var _local2:Point = gridProxy.getSnapPoint(new Point(canvas.mouseX, canvas.mouseY));
canvasTop.graphics.lineTo(_local2.x, _local2.y);
}
override protected function mouseUpHandler(_arg1:MouseEvent):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:DistJointDef;
super.mouseUpHandler(_arg1);
canvasTop.graphics.clear();
var _local2:Point = gridProxy.getSnapPoint(new Point(canvas.mouseX, canvas.mouseY));
_local3 = _local2.x;
_local4 = _local2.y;
if (!(((x1 == _local3)) && ((y1 == _local4)))){
_local5 = (x1 + ((_local3 - x1) / 2));
_local6 = (y1 + ((_local4 - y1) / 2));
_local7 = new DistJointDef(_local5, _local6, x1, y1, _local3, _local4);
notesProxy.push(EditorProxy.OBJECT_ADD, _local7);
};
}
override protected function canvasMouseDownHandler(_arg1:MouseEvent):void{
super.canvasMouseDownHandler(_arg1);
var _local2:Point = gridProxy.getSnapPoint(new Point(canvas.mouseX, canvas.mouseY));
x1 = _local2.x;
y1 = _local2.y;
}
}
}//package editor.view.components.tools
Section 198
//HandTool (editor.view.components.tools.HandTool)
package editor.view.components.tools {
import flash.events.*;
import editor.model.*;
import flash.display.*;
import flash.geom.*;
public class HandTool extends ToolView {
private var isDrawing:Boolean;
private var startPoint:Point;
public function HandTool(_arg1:Sprite, _arg2:Tool):void{
super(_arg1, _arg2);
}
override protected function init():void{
super.init();
isDrawing = false;
}
override protected function mouseMoveHandler(_arg1:MouseEvent):void{
var _local2:Point = new Point(canvas.parent.mouseX, canvas.parent.mouseY);
var _local3:Number = (_local2.x - startPoint.x);
var _local4:Number = (_local2.y - startPoint.y);
canvas.x = (canvas.x + _local3);
canvas.y = (canvas.y + _local4);
support.x = (support.x + _local3);
support.y = (support.y + _local4);
startPoint = _local2;
}
override protected function mouseUpHandler(_arg1:MouseEvent):void{
super.mouseUpHandler(_arg1);
}
override protected function canvasMouseDownHandler(_arg1:MouseEvent):void{
super.canvasMouseDownHandler(_arg1);
startPoint = new Point(canvas.parent.mouseX, canvas.parent.mouseY);
}
}
}//package editor.view.components.tools
Section 199
//PolyTool (editor.view.components.tools.PolyTool)
package editor.view.components.tools {
import flash.events.*;
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
import flash.geom.*;
public class PolyTool extends ToolView {
private var mx:Number;
private var my:Number;
private var vertices:Array;
private var poly:Sprite;
public function PolyTool(_arg1:Sprite, _arg2:Tool):void{
super(_arg1, _arg2);
}
private function closePoly():void{
var _local1:int;
var _local4:Point;
poly.parent.removeChild(poly);
canvas.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
canvas.removeEventListener(MouseEvent.MOUSE_DOWN, canvasMousDownHandler);
if (vertices.length < 3){
return;
};
var _local2:Point = vertices[0].clone();
_local1 = 0;
while (_local1 < vertices.length) {
_local4 = vertices[_local1];
vertices[_local1].x = (_local4.x - _local2.x);
_local4.y = (_local4.y - _local2.y);
_local1++;
};
var _local3:PolyDef = new PolyDef(_local2.x, _local2.y, vertices, BaseObjectDef.TYPE_WOOD);
notesProxy.push(EditorProxy.OBJECT_ADD, _local3);
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == 27){
notesProxy.push(EditorProxy.TOOL_SELECT, editorProxy.getTools()[0]);
};
}
override protected function init():void{
super.init();
}
override protected function mouseMoveHandler(_arg1:MouseEvent):void{
var _local3:Point;
var _local4:uint;
var _local5:Number;
var _local2:Point = gridProxy.getSnapPoint(new Point(Math.round(canvas.mouseX), Math.round(canvas.mouseY)));
mx = _local2.x;
my = _local2.y;
if (vertices.length > 0){
poly.graphics.clear();
poly.graphics.lineStyle(0, 0);
_local3 = vertices[0];
poly.graphics.moveTo(_local3.x, _local3.y);
_local4 = 1;
while (_local4 < vertices.length) {
_local3 = vertices[_local4];
poly.graphics.lineTo(_local3.x, _local3.y);
_local4++;
};
_local5 = Math.sqrt((((vertices[0].x - mx) * (vertices[0].x - mx)) + ((vertices[0].y - my) * (vertices[0].y - my))));
if (_local5 < 5){
mx = vertices[0].x;
my = vertices[0].y;
};
poly.graphics.lineTo(mx, my);
};
}
private function canvasMousDownHandler(_arg1:MouseEvent):void{
var _local2:Point = gridProxy.getSnapPoint(new Point(mx, my));
if (vertices.length > 0){
if ((((_local2.x == vertices[0].x)) && ((_local2.y == vertices[0].y)))){
closePoly();
select();
} else {
vertices.push(_local2);
};
} else {
vertices.push(_local2);
};
}
override public function select():void{
windowBack.gotoAndStop(2);
vertices = [];
poly = new Sprite();
bodies.addChild(poly);
canvas.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
canvas.addEventListener(MouseEvent.MOUSE_DOWN, canvasMousDownHandler);
window.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
}
override public function deselect():void{
windowBack.gotoAndStop(1);
poly.parent.removeChild(poly);
canvas.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
canvas.removeEventListener(MouseEvent.MOUSE_DOWN, canvasMousDownHandler);
window.stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
}
}
}//package editor.view.components.tools
Section 200
//RectTool (editor.view.components.tools.RectTool)
package editor.view.components.tools {
import flash.events.*;
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
import flash.geom.*;
public class RectTool extends ToolView {
private var isDrawing:Boolean;
private var rect:Sprite;
public function RectTool(_arg1:Sprite, _arg2:Tool):void{
super(_arg1, _arg2);
}
override protected function init():void{
super.init();
isDrawing = false;
}
override protected function canvasMouseDownHandler(_arg1:MouseEvent):void{
super.canvasMouseDownHandler(_arg1);
rect = new Sprite();
var _local2:Point = gridProxy.getSnapPoint(new Point(canvas.mouseX, canvas.mouseY));
rect.x = _local2.x;
rect.y = _local2.y;
bodies.addChild(rect);
isDrawing = true;
}
override protected function mouseMoveHandler(_arg1:MouseEvent):void{
rect.graphics.clear();
rect.graphics.lineStyle(0, 0);
var _local2:Point = gridProxy.getSnapPoint(new Point(rect.mouseX, rect.mouseY));
rect.graphics.drawRect(0, 0, _local2.x, _local2.y);
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
if (((isDrawing) && ((_arg1.keyCode == 27)))){
rect.parent.removeChild(rect);
canvas.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
canvas.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
notesProxy.push(EditorProxy.TOOL_SELECT, editorProxy.getTools()[0]);
};
}
override protected function mouseUpHandler(_arg1:MouseEvent):void{
var _local6:RectDef;
super.mouseUpHandler(_arg1);
rect.parent.removeChild(rect);
var _local2:Number = ((rect.x < canvas.mouseX)) ? rect.x : canvas.mouseX;
var _local3:Number = ((rect.y < canvas.mouseY)) ? rect.y : canvas.mouseY;
var _local4:Number = Math.round(rect.width);
var _local5:Number = Math.round(rect.height);
_local2 = (_local2 + Math.round((_local4 / 2)));
_local3 = (_local3 + Math.round((_local5 / 2)));
isDrawing = false;
if ((((_local4 > 0)) && ((_local5 > 0)))){
_local6 = new RectDef(_local2, _local3, _local4, _local5, BaseObjectDef.TYPE_WOOD);
notesProxy.push(EditorProxy.OBJECT_ADD, _local6);
};
}
override public function select():void{
super.select();
window.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
}
override public function deselect():void{
super.deselect();
isDrawing = false;
window.stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
}
}
}//package editor.view.components.tools
Section 201
//SelectionTool (editor.view.components.tools.SelectionTool)
package editor.view.components.tools {
import flash.events.*;
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
import flash.geom.*;
import flash.ui.*;
public class SelectionTool extends ToolView {
private var startPoint:Point;
public function SelectionTool(_arg1:Sprite, _arg2:Tool):void{
super(_arg1, _arg2);
}
private function translateMouseMoveHandler(_arg1:MouseEvent):void{
var _local7:BaseObjectDef;
var _local8:Rectangle;
var _local2:Array = editorProxy.getSelectedObjects();
canvasTop.graphics.clear();
canvasTop.graphics.lineStyle(0, 0, 0.5);
var _local3:Point = gridProxy.getSnapPoint(new Point(canvas.mouseX, canvas.mouseY));
var _local4:Number = (_local3.x - startPoint.x);
var _local5:Number = (_local3.y - startPoint.y);
var _local6:uint;
while (_local6 < _local2.length) {
_local7 = _local2[_local6];
_local8 = _local7.getBoundingBox();
canvasTop.graphics.drawRect(((_local7.x + _local8.x) + _local4), ((_local7.y + _local8.y) + _local5), _local8.width, _local8.height);
_local6++;
};
}
private function handMouseMoveHandler(_arg1:MouseEvent):void{
var _local2:Number = Math.round((canvas.mouseX - startPoint.x));
var _local3:Number = Math.round((canvas.mouseY - startPoint.y));
editorProxy.canvasTranslate(_local2, _local3);
}
private function selectMouseUpHandler(_arg1:MouseEvent):void{
canvas.stage.removeEventListener(MouseEvent.MOUSE_MOVE, selectMouseMoveHandler);
canvas.stage.removeEventListener(MouseEvent.MOUSE_UP, selectMouseUpHandler);
canvasTop.graphics.clear();
var _local2:Point = new Point(canvas.mouseX, canvas.mouseY);
var _local3:Number = ((_local2.x > startPoint.x)) ? startPoint.x : _local2.x;
var _local4:Number = ((_local2.y > startPoint.y)) ? startPoint.y : _local2.y;
var _local5:Number = Math.abs((_local2.x - startPoint.x));
var _local6:Number = Math.abs((_local2.y - startPoint.y));
var _local7:Rectangle = new Rectangle(_local3, _local4, _local5, _local6);
var _local8:Array = editorProxy.getObjsUnderRect(_local7);
notesProxy.push(EditorProxy.OBJECTS_SELECT, _local8);
}
private function removeObjects():void{
editorProxy.deleteSelectedObjects();
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
var _local2:Point = new Point(0, 0);
if (_arg1.keyCode == Keyboard.LEFT){
translateObjects(-1, 0);
} else {
if (_arg1.keyCode == Keyboard.RIGHT){
translateObjects(1, 0);
} else {
if (_arg1.keyCode == Keyboard.UP){
translateObjects(0, -1);
} else {
if (_arg1.keyCode == Keyboard.DOWN){
translateObjects(0, 1);
} else {
if (_arg1.keyCode == Keyboard.DELETE){
removeObjects();
};
};
};
};
};
}
private function translateObjects(_arg1:Number, _arg2:Number):void{
var _local4:uint;
var _local5:BaseObjectDef;
var _local3:Array = editorProxy.getSelectedObjects();
if (_local3.length != 0){
_local4 = 0;
while (_local4 < _local3.length) {
_local5 = _local3[_local4];
_local5.translate(_arg1, _arg2);
notesProxy.push(EditorProxy.OBJECT_UPDATE, _local5);
_local4++;
};
};
}
override protected function init():void{
super.init();
}
private function selectMouseMoveHandler(_arg1:MouseEvent):void{
var _local2:Number = (canvas.mouseX - startPoint.x);
var _local3:Number = (canvas.mouseY - startPoint.y);
canvasTop.graphics.clear();
canvasTop.graphics.lineStyle(0, 0);
canvasTop.graphics.beginFill(6710937, 0.3);
canvasTop.graphics.drawRect(startPoint.x, startPoint.y, _local2, _local3);
canvasTop.graphics.endFill();
}
private function translateMouseUpHandler(_arg1:MouseEvent):void{
var _local4:BaseObjectDef;
var _local5:uint;
var _local6:Array;
canvasTop.graphics.clear();
var _local2:Point = gridProxy.getSnapPoint(new Point(canvas.mouseX, canvas.mouseY));
var _local3:Array = editorProxy.getSelectedObjects();
if (_arg1.ctrlKey){
_local6 = [];
_local5 = 0;
while (_local5 < _local3.length) {
_local4 = _local3[_local5];
if ((_local4 is PlayerDef)){
} else {
_local4 = LevelStringParser.parseObjectDef(_local4.getStringDef());
_local4.translate((_local2.x - startPoint.x), (_local2.y - startPoint.y));
_local6.push(_local4);
notesProxy.push(EditorProxy.OBJECT_ADD, _local4);
};
_local5++;
};
notesProxy.push(EditorProxy.OBJECTS_SELECT, _local6);
} else {
_local5 = 0;
while (_local5 < _local3.length) {
_local4 = _local3[_local5];
_local4.translate((_local2.x - startPoint.x), (_local2.y - startPoint.y));
notesProxy.push(EditorProxy.OBJECT_UPDATE, _local4);
_local5++;
};
};
canvas.stage.removeEventListener(MouseEvent.MOUSE_UP, translateMouseUpHandler);
canvas.stage.removeEventListener(MouseEvent.MOUSE_MOVE, translateMouseMoveHandler);
}
private function handMouseUpHandler(_arg1:MouseEvent):void{
canvas.stage.removeEventListener(MouseEvent.MOUSE_MOVE, handMouseMoveHandler);
canvas.stage.removeEventListener(MouseEvent.MOUSE_UP, handMouseUpHandler);
}
override protected function canvasMouseDownHandler(_arg1:MouseEvent):void{
var _local3:Array;
startPoint = gridProxy.getSnapPoint(new Point(canvas.mouseX, canvas.mouseY));
var _local2:BaseObjectDef = editorProxy.getObjUnderPoint(new Point(canvas.mouseX, canvas.mouseY));
if (_local2){
_local3 = editorProxy.getSelectedObjects();
if (_local3.indexOf(_local2) == -1){
notesProxy.push(EditorProxy.OBJECTS_SELECT, [_local2]);
};
canvas.stage.addEventListener(MouseEvent.MOUSE_MOVE, translateMouseMoveHandler);
canvas.stage.addEventListener(MouseEvent.MOUSE_UP, translateMouseUpHandler);
} else {
notesProxy.push(EditorProxy.OBJECTS_SELECT, []);
canvas.stage.addEventListener(MouseEvent.MOUSE_MOVE, selectMouseMoveHandler);
canvas.stage.addEventListener(MouseEvent.MOUSE_UP, selectMouseUpHandler);
};
}
override public function select():void{
super.select();
window.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
}
override public function deselect():void{
super.deselect();
window.stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
}
private function keyUpHandler(_arg1:KeyboardEvent):void{
window.stage.removeEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
}
}
}//package editor.view.components.tools
Section 202
//SimpleTool (editor.view.components.tools.SimpleTool)
package editor.view.components.tools {
import flash.events.*;
import editor.model.*;
import flash.display.*;
import editor.model.objects.*;
import flash.geom.*;
public class SimpleTool extends ToolView {
public function SimpleTool(_arg1:Sprite, _arg2:Tool):void{
super(_arg1, _arg2);
}
override protected function mouseUpHandler(_arg1:MouseEvent):void{
var _local2:BaseObjectDef;
super.mouseUpHandler(_arg1);
var _local3:Point = gridProxy.getSnapPoint(new Point(canvas.mouseX, canvas.mouseY));
if (tool.type == Tool.TYPE_REV_JOINT){
_local2 = new RevJointDef(_local3.x, _local3.y);
} else {
if (tool.type == Tool.TYPE_MOTOR){
_local2 = new MotorDef(_local3.x, _local3.y, 0.5);
} else {
if (tool.type == Tool.TYPE_BOTTLE){
_local2 = new SimpleObjDef(_local3.x, _local3.y, SimpleObjDef.TYPE_BOTTLE);
} else {
if (tool.type == Tool.TYPE_MONITOR){
_local2 = new SimpleObjDef(_local3.x, _local3.y, SimpleObjDef.TYPE_MONITOR);
} else {
return;
};
};
};
};
notesProxy.push(EditorProxy.OBJECT_ADD, _local2);
}
}
}//package editor.view.components.tools
Section 203
//ToolView (editor.view.components.tools.ToolView)
package editor.view.components.tools {
import flash.events.*;
import editor.model.*;
import game.model.*;
import flash.display.*;
import editor.view.components.*;
import editor.view.*;
public class ToolView extends EventDispatcher {
protected var bodies:Sprite;
protected var editorProxy:EditorProxy;
protected var windowBack:MovieClip;
protected var gridProxy:GridProxy;
protected var support:Sprite;
public var tool:Tool;
protected var canvasTop:Sprite;
protected var canvasBack:Sprite;
protected var facade:ApplicationFacade;
protected var canvas:Sprite;
protected var notesProxy:NotesProxy;
protected var window:Sprite;
public static const SELECT:String = "Select";
public function ToolView(_arg1:Sprite, _arg2:Tool):void{
this.window = _arg1;
this.tool = _arg2;
init();
}
protected function mouseUpHandler(_arg1:MouseEvent):void{
canvas.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
canvas.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
protected function mouseMoveHandler(_arg1:MouseEvent):void{
}
protected function init():void{
windowBack = (window.getChildByName("back") as MovieClip);
windowBack.stop();
window.addEventListener(MouseEvent.CLICK, windowClickHandler);
facade = ApplicationFacade.getInstance();
var _local1:EditorMediator = (facade.retrieveMediator(EditorMediator.NAME) as EditorMediator);
var _local2:EditorView = (_local1.getViewComponent() as EditorView);
var _local3:ObjectsMediator = (facade.retrieveMediator(ObjectsMediator.NAME) as ObjectsMediator);
var _local4:ObjectsView = (_local3.getViewComponent() as ObjectsView);
canvas = _local2.canvas;
canvasBack = _local2.canvasBack;
canvasTop = _local2.canvasTop;
support = _local2.support;
bodies = _local4.bodies;
notesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
editorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
gridProxy = (facade.retrieveProxy(GridProxy.NAME) as GridProxy);
}
protected function canvasMouseDownHandler(_arg1:MouseEvent):void{
canvas.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
canvas.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
protected function windowClickHandler(_arg1:MouseEvent):void{
dispatchEvent(new Event(SELECT));
}
public function select():void{
windowBack.gotoAndStop(2);
canvas.addEventListener(MouseEvent.MOUSE_DOWN, canvasMouseDownHandler);
}
public function deselect():void{
windowBack.gotoAndStop(1);
canvas.removeEventListener(MouseEvent.MOUSE_DOWN, canvasMouseDownHandler);
}
}
}//package editor.view.components.tools
Section 204
//EditorView (editor.view.components.EditorView)
package editor.view.components {
import editor.model.*;
import flash.display.*;
public class EditorView extends Sprite {
public var exitConfirm:Sprite;
public var grid_bt:SimpleButton;
public var grid:Sprite;
public var load_bt:SimpleButton;
public var support:Sprite;
public var exitNo_bt:SimpleButton;
public var save_bt:SimpleButton;
public var canvas:Sprite;
public var tools:Sprite;
public var canvasTop:Sprite;
public var canvasBack:Sprite;
public var exitYes_bt:SimpleButton;
private var window:Sprite;
public var shapes:Sprite;
public var menu_bt:SimpleButton;
public var play_bt:SimpleButton;
public var props:Sprite;
public function EditorView():void{
init();
}
private function init():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("EditorWindow");
window = new (_local1);
addChild(window);
canvas = (window.getChildByName("canvas") as Sprite);
canvasBack = (canvas.getChildByName("back") as Sprite);
canvasTop = (canvas.getChildByName("canvasTop") as Sprite);
tools = (window.getChildByName("tools") as Sprite);
props = (window.getChildByName("props") as Sprite);
shapes = (window.getChildByName("shapes") as Sprite);
support = (window.getChildByName("support") as Sprite);
grid = (canvas.getChildByName("grid") as Sprite);
play_bt = (window.getChildByName("play_bt") as SimpleButton);
save_bt = (window.getChildByName("save_bt") as SimpleButton);
load_bt = (window.getChildByName("load_bt") as SimpleButton);
menu_bt = (window.getChildByName("menu_bt") as SimpleButton);
exitConfirm = (window.getChildByName("exitConfirm") as Sprite);
exitYes_bt = (exitConfirm.getChildByName("yes_bt") as SimpleButton);
exitNo_bt = (exitConfirm.getChildByName("no_bt") as SimpleButton);
grid_bt = (window.getChildByName("grid_bt") as SimpleButton);
}
}
}//package editor.view.components
Section 205
//ELevelCompleteView (editor.view.components.ELevelCompleteView)
package editor.view.components {
import editor.model.*;
import flash.display.*;
public class ELevelCompleteView extends Sprite {
private var window:Sprite;
public var restart_bt:SimpleButton;
public var inner:Sprite;
public var back:Sprite;
public var editor_bt:SimpleButton;
public function ELevelCompleteView():void{
init();
}
private function init():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("LevelCompleteWindow");
window = new (_local1);
addChild(window);
back = (window.getChildByName("back") as Sprite);
inner = (window.getChildByName("inner") as Sprite);
restart_bt = (inner.getChildByName("restart_bt") as SimpleButton);
editor_bt = (inner.getChildByName("editor_bt") as SimpleButton);
}
}
}//package editor.view.components
Section 206
//GridView (editor.view.components.GridView)
package editor.view.components {
import flash.display.*;
public class GridView {
public var window:Sprite;
public var container:Sprite;
public function GridView(_arg1:Sprite):void{
this.window = _arg1;
init();
}
private function init():void{
container = new Sprite();
window.addChild(container);
}
}
}//package editor.view.components
Section 207
//LevelLoadView (editor.view.components.LevelLoadView)
package editor.view.components {
import editor.model.*;
import flash.display.*;
import flash.text.*;
public class LevelLoadView extends Sprite {
private var window:Sprite;
public var inner:Sprite;
public var levelDef_tf:TextField;
public var load_bt:SimpleButton;
public var cancel_bt:SimpleButton;
public function LevelLoadView():void{
init();
}
private function init():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("LevelLoadWindow");
window = new (_local1);
addChild(window);
inner = (window.getChildByName("inner") as Sprite);
levelDef_tf = (inner.getChildByName("levelDef_tf") as TextField);
load_bt = (inner.getChildByName("load_bt") as SimpleButton);
cancel_bt = (inner.getChildByName("cancel_bt") as SimpleButton);
}
}
}//package editor.view.components
Section 208
//LevelSaveView (editor.view.components.LevelSaveView)
package editor.view.components {
import editor.model.*;
import flash.display.*;
import flash.text.*;
public class LevelSaveView extends Sprite {
private var window:Sprite;
public var ok_bt:SimpleButton;
public var inner:Sprite;
public var levelDef_tf:TextField;
public function LevelSaveView():void{
init();
}
private function init():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("LevelSaveWindow");
window = new (_local1);
addChild(window);
inner = (window.getChildByName("inner") as Sprite);
levelDef_tf = (inner.getChildByName("levelDef_tf") as TextField);
ok_bt = (inner.getChildByName("ok_bt") as SimpleButton);
}
}
}//package editor.view.components
Section 209
//LevelTestView (editor.view.components.LevelTestView)
package editor.view.components {
import editor.model.*;
import flash.display.*;
public class LevelTestView extends Sprite {
private var window:Sprite;
public var restart_bt:SimpleButton;
public var back_bt:SimpleButton;
public var levelContainer:Sprite;
public function LevelTestView():void{
init();
}
private function init():void{
var _local1:Class = EditorAssets.getInstance().getAssetClass("LevelTestWindow");
window = new (_local1);
addChild(window);
levelContainer = (window.getChildByName("levelContainer") as Sprite);
back_bt = (window.getChildByName("back_bt") as SimpleButton);
restart_bt = (window.getChildByName("restart_bt") as SimpleButton);
}
}
}//package editor.view.components
Section 210
//ObjectsView (editor.view.components.ObjectsView)
package editor.view.components {
import flash.display.*;
public class ObjectsView {
public var window:Sprite;
public var player:Sprite;
public var bodies:Sprite;
public var joints:Sprite;
public function ObjectsView(_arg1:Sprite):void{
this.window = _arg1;
init();
}
private function init():void{
bodies = (window.getChildByName("bodies") as Sprite);
player = (window.getChildByName("player") as Sprite);
joints = (window.getChildByName("joints") as Sprite);
}
}
}//package editor.view.components
Section 211
//PropsView (editor.view.components.PropsView)
package editor.view.components {
import flash.display.*;
public class PropsView {
public var window:Sprite;
public var container:Sprite;
public function PropsView(_arg1:Sprite):void{
this.window = _arg1;
init();
}
private function init():void{
container = (window.getChildByName("container") as Sprite);
}
}
}//package editor.view.components
Section 212
//ShapesView (editor.view.components.ShapesView)
package editor.view.components {
import flash.display.*;
public class ShapesView {
public var window:Sprite;
public var itemsContainer:Sprite;
public var show_bt:SimpleButton;
public var inner:Sprite;
public var hide_bt:SimpleButton;
public function ShapesView(_arg1:Sprite):void{
this.window = _arg1;
init();
}
private function init():void{
show_bt = (window.getChildByName("show_bt") as SimpleButton);
inner = (window.getChildByName("inner") as Sprite);
itemsContainer = (inner.getChildByName("itemsContainer") as Sprite);
hide_bt = (inner.getChildByName("hide_bt") as SimpleButton);
}
}
}//package editor.view.components
Section 213
//ToolsView (editor.view.components.ToolsView)
package editor.view.components {
import flash.display.*;
public class ToolsView {
public var distJointTool:Sprite;
public var selectionTool:Sprite;
public var polyTool:Sprite;
public var monitorTool:Sprite;
public var circleTool:Sprite;
public var playerTool:Sprite;
public var rectTool:Sprite;
public var revJointTool:Sprite;
public var handTool:Sprite;
public var motorTool:Sprite;
public var window:Sprite;
public var chainTool:Sprite;
public var bottleTool:Sprite;
public function ToolsView(_arg1:Sprite):void{
this.window = _arg1;
init();
}
private function init():void{
selectionTool = (window.getChildByName("selection") as Sprite);
circleTool = (window.getChildByName("circle") as Sprite);
rectTool = (window.getChildByName("rect") as Sprite);
distJointTool = (window.getChildByName("distJoint") as Sprite);
playerTool = (window.getChildByName("player") as Sprite);
revJointTool = (window.getChildByName("revJoint") as Sprite);
motorTool = (window.getChildByName("motor") as Sprite);
polyTool = (window.getChildByName("poly") as Sprite);
chainTool = (window.getChildByName("chain") as Sprite);
handTool = (window.getChildByName("move") as Sprite);
bottleTool = (window.getChildByName("bottle") as Sprite);
monitorTool = (window.getChildByName("monitor") as Sprite);
}
}
}//package editor.view.components
Section 214
//EditorMediator (editor.view.EditorMediator)
package editor.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import game.model.*;
import editor.view.components.*;
import org.puremvc.as3.patterns.mediator.*;
import game.view.*;
public class EditorMediator extends Mediator implements IMediator {
private var editorProxy:EditorProxy;
private var _view:EditorView;
private var notesProxy:NotesProxy;
public static const NAME:String = "EditorMediator";
public function EditorMediator(_arg1:EditorView):void{
super(NAME, _arg1);
init();
}
override public function listNotificationInterests():Array{
return ([]);
}
private function exitNoClickHandler(_arg1:MouseEvent):void{
_view.exitConfirm.visible = false;
}
override public function onRegister():void{
var _local1:ObjectsView = new ObjectsView(_view.canvas);
var _local2:ObjectsMediator = new ObjectsMediator(_local1);
facade.registerMediator(_local2);
var _local3:ToolsView = new ToolsView(_view.tools);
var _local4:ToolsMediator = new ToolsMediator(_local3);
facade.registerMediator(_local4);
var _local5:PropsView = new PropsView(_view.props);
var _local6:PropsMediator = new PropsMediator(_local5);
facade.registerMediator(_local6);
var _local7:ShapesView = new ShapesView(_view.shapes);
var _local8:ShapesMediator = new ShapesMediator(_local7);
facade.registerMediator(_local8);
var _local9:GridView = new GridView(_view.grid);
var _local10:GridMediator = new GridMediator(_local9);
facade.registerMediator(_local10);
notesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
editorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
_view.exitConfirm.visible = false;
_view.play_bt.addEventListener(MouseEvent.CLICK, playClickHandler);
_view.save_bt.addEventListener(MouseEvent.CLICK, saveClickHandler);
_view.load_bt.addEventListener(MouseEvent.CLICK, loadClickHandler);
_view.menu_bt.addEventListener(MouseEvent.CLICK, menuClickHandler);
_view.exitYes_bt.addEventListener(MouseEvent.CLICK, exitYesClickHandler);
_view.exitNo_bt.addEventListener(MouseEvent.CLICK, exitNoClickHandler);
_view.grid_bt.addEventListener(MouseEvent.CLICK, gridClickHandler);
}
private function exitYesClickHandler(_arg1:MouseEvent):void{
notesProxy.push(EditorProxy.EDITOR_CLOSE);
}
private function loadClickHandler(_arg1:MouseEvent):void{
notesProxy.push(EditorProxy.OBJECTS_SELECT, []);
var _local2:LevelLoadView = new LevelLoadView();
var _local3:AppMediator = (facade.retrieveMediator(AppMediator.NAME) as AppMediator);
_local3.getViewContainer().addChild(_local2);
var _local4:LevelLoadMediator = new LevelLoadMediator(_local2);
facade.registerMediator(_local4);
}
private function init():void{
_view = (getViewComponent() as EditorView);
}
public function destroy():void{
var _local1:ObjectsMediator = (facade.retrieveMediator(ObjectsMediator.NAME) as ObjectsMediator);
_local1.destroy();
var _local2:ToolsMediator = (facade.retrieveMediator(ToolsMediator.NAME) as ToolsMediator);
_local2.destroy();
var _local3:ShapesMediator = (facade.retrieveMediator(ShapesMediator.NAME) as ShapesMediator);
_local3.destroy();
_view.play_bt.removeEventListener(MouseEvent.CLICK, playClickHandler);
_view.save_bt.removeEventListener(MouseEvent.CLICK, saveClickHandler);
_view.menu_bt.removeEventListener(MouseEvent.CLICK, menuClickHandler);
_view.exitYes_bt.removeEventListener(MouseEvent.CLICK, exitYesClickHandler);
_view.exitNo_bt.removeEventListener(MouseEvent.CLICK, exitNoClickHandler);
_view.parent.removeChild(_view);
facade.removeMediator(NAME);
}
override public function handleNotification(_arg1:INotification):void{
}
private function playClickHandler(_arg1:MouseEvent):void{
notesProxy.push(EditorProxy.OBJECTS_SELECT, []);
notesProxy.push(EditorProxy.ELEVEL_START);
}
private function gridClickHandler(_arg1:MouseEvent):void{
var _local2:GridProxy = (facade.retrieveProxy(GridProxy.NAME) as GridProxy);
if (_local2.showGrid){
notesProxy.push(GridProxy.GRID_OFF);
} else {
notesProxy.push(GridProxy.GRID_ON);
};
}
private function menuClickHandler(_arg1:MouseEvent):void{
_view.exitConfirm.visible = true;
}
private function saveClickHandler(_arg1:MouseEvent):void{
trace("save");
notesProxy.push(EditorProxy.OBJECTS_SELECT, []);
var _local2:LevelSaveView = new LevelSaveView();
var _local3:AppMediator = (facade.retrieveMediator(AppMediator.NAME) as AppMediator);
_local3.getViewContainer().addChild(_local2);
var _local4:LevelSaveMediator = new LevelSaveMediator(_local2);
facade.registerMediator(_local4);
}
}
}//package editor.view
Section 215
//ELevelCompleteMediator (editor.view.ELevelCompleteMediator)
package editor.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import editor.model.*;
import game.model.*;
import editor.view.components.*;
import org.puremvc.as3.patterns.mediator.*;
import caurina.transitions.*;
public class ELevelCompleteMediator extends Mediator implements IMediator {
private var _view:ELevelCompleteView;
private var notesProxy:NotesProxy;
public static const NAME:String = "ELevelCompleteMediator";
public function ELevelCompleteMediator(_arg1:ELevelCompleteView):void{
super(NAME, _arg1);
init();
}
override public function listNotificationInterests():Array{
return ([]);
}
override public function handleNotification(_arg1:INotification):void{
}
private function editorClickHandler(_arg1:MouseEvent):void{
Fader.getInstance().fade(abortLevel);
}
private function init():void{
_view = (getViewComponent() as ELevelCompleteView);
notesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
_view.restart_bt.addEventListener(MouseEvent.CLICK, restartClickHandler);
_view.editor_bt.addEventListener(MouseEvent.CLICK, editorClickHandler);
_view.back.alpha = 0;
Tweener.addTween(_view.back, {alpha:1, time:1, transition:"linear"});
var _local1:Number = _view.inner.y;
_view.inner.y = -(_view.inner.height);
Tweener.addTween(_view.inner, {y:_local1, time:1, delay:0.5, transition:"easeoutback"});
}
private function restartClickHandler(_arg1:MouseEvent):void{
Fader.getInstance().fade(restartLevel);
}
private function abortLevel():void{
notesProxy.push(EditorProxy.ELEVEL_ABORT);
}
private function restartLevel():void{
notesProxy.push(EditorProxy.ELEVEL_ABORT);
notesProxy.push(EditorProxy.ELEVEL_START);
}
public function destroy():void{
_view.parent.removeChild(_view);
facade.removeMediator(NAME);
}
}
}//package editor.view
Section 216
//GridMediator (editor.view.GridMediator)
package editor.view {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import flash.display.*;
import editor.view.components.*;
import org.puremvc.as3.patterns.mediator.*;
public class GridMediator extends Mediator implements IMediator {
private var _view:GridView;
private var gridProxy:GridProxy;
public static const NAME:String = "GridMediator";
public function GridMediator(_arg1:GridView):void{
super(NAME, _arg1);
init();
}
override public function listNotificationInterests():Array{
return ([GridProxy.GRID_ON, GridProxy.GRID_OFF]);
}
override public function onRegister():void{
}
private function gridOn():void{
drawGrid();
}
private function gridOff():void{
_view.container.graphics.clear();
}
private function drawGrid():void{
var _local4:uint;
var _local1:uint = Math.round((640 / gridProxy.cellWidth));
var _local2:uint = Math.round((480 / gridProxy.cellHeight));
var _local3:Graphics = _view.container.graphics;
_local3.clear();
_local3.lineStyle(0, 0, 0.2);
_local4 = 0;
while (_local4 < _local1) {
_local3.moveTo((_local4 * gridProxy.cellWidth), 0);
_local3.lineTo((_local4 * gridProxy.cellWidth), 480);
_local4++;
};
_local4 = 0;
while (_local4 < _local2) {
_local3.moveTo(0, (_local4 * gridProxy.cellHeight));
_local3.lineTo(640, (_local4 * gridProxy.cellHeight));
_local4++;
};
}
override public function handleNotification(_arg1:INotification):void{
switch (_arg1.getName()){
case GridProxy.GRID_ON:
gridOn();
break;
case GridProxy.GRID_OFF:
gridOff();
};
}
private function init():void{
_view = (getViewComponent() as GridView);
gridProxy = (facade.retrieveProxy(GridProxy.NAME) as GridProxy);
}
public function destroy():void{
facade.removeMediator(NAME);
}
}
}//package editor.view
Section 217
//LevelLoadMediator (editor.view.LevelLoadMediator)
package editor.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import editor.view.components.*;
import org.puremvc.as3.patterns.mediator.*;
public class LevelLoadMediator extends Mediator implements IMediator {
private var _view:LevelLoadView;
public static const NAME:String = "LevelLoadMediator";
public function LevelLoadMediator(_arg1:LevelLoadView):void{
super(NAME, _arg1);
init();
}
private function init():void{
_view = (getViewComponent() as LevelLoadView);
_view.levelDef_tf.text = "";
_view.load_bt.addEventListener(MouseEvent.CLICK, loadClickHandler);
_view.cancel_bt.addEventListener(MouseEvent.CLICK, cancelClickHandler);
}
override public function listNotificationInterests():Array{
return ([]);
}
private function destroy():void{
_view.parent.removeChild(_view);
facade.removeMediator(NAME);
}
override public function handleNotification(_arg1:INotification):void{
}
private function cancelClickHandler(_arg1:MouseEvent):void{
destroy();
}
private function loadClickHandler(_arg1:MouseEvent):void{
var _local2:EditorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
var _local3:String = _view.levelDef_tf.text;
_local2.loadLevel(_local3);
destroy();
}
}
}//package editor.view
Section 218
//LevelSaveMediator (editor.view.LevelSaveMediator)
package editor.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import editor.view.components.*;
import org.puremvc.as3.patterns.mediator.*;
public class LevelSaveMediator extends Mediator implements IMediator {
private var _view:LevelSaveView;
public static const NAME:String = "LevelSaveMediator";
public function LevelSaveMediator(_arg1:LevelSaveView):void{
super(NAME, _arg1);
init();
}
private function init():void{
_view = (getViewComponent() as LevelSaveView);
var _local1:EditorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
_view.levelDef_tf.text = _local1.getLevelDef();
_view.ok_bt.addEventListener(MouseEvent.CLICK, okClickHandler);
}
override public function handleNotification(_arg1:INotification):void{
}
override public function listNotificationInterests():Array{
return ([]);
}
private function destroy():void{
_view.parent.removeChild(_view);
facade.removeMediator(NAME);
}
private function okClickHandler(_arg1:MouseEvent):void{
destroy();
}
}
}//package editor.view
Section 219
//LevelTestMediator (editor.view.LevelTestMediator)
package editor.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import game.model.*;
import flash.display.*;
import editor.view.components.*;
import org.puremvc.as3.patterns.mediator.*;
public class LevelTestMediator extends Mediator implements IMediator {
private var _view:LevelTestView;
private var levelProxy:LevelProxy;
private var cutIcons:Array;
public static const NAME:String = "LevelTestMediator";
public function LevelTestMediator(_arg1:LevelTestView):void{
super(NAME, _arg1);
init();
}
override public function listNotificationInterests():Array{
return ([EditorProxy.ELEVEL_COMPLETE]);
}
public function getLevelContainer():Sprite{
return (_view.levelContainer);
}
private function backClickHandler(_arg1:MouseEvent):void{
var _local2:NotesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
_local2.push(EditorProxy.ELEVEL_ABORT);
}
override public function handleNotification(_arg1:INotification):void{
switch (_arg1.getName()){
case EditorProxy.ELEVEL_COMPLETE:
levelComplete();
break;
};
}
private function restartClickHandler(_arg1:MouseEvent):void{
var _local2:NotesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
_local2.push(EditorProxy.ELEVEL_ABORT);
_local2.push(EditorProxy.ELEVEL_START);
}
private function init():void{
_view = (getViewComponent() as LevelTestView);
levelProxy = (facade.retrieveProxy(LevelProxy.NAME) as LevelProxy);
_view.back_bt.addEventListener(MouseEvent.CLICK, backClickHandler);
_view.restart_bt.addEventListener(MouseEvent.CLICK, restartClickHandler);
}
public function destroy():void{
_view.parent.removeChild(_view);
facade.removeMediator(NAME);
}
private function levelComplete():void{
}
}
}//package editor.view
Section 220
//ObjectsMediator (editor.view.ObjectsMediator)
package editor.view {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import editor.model.objects.*;
import editor.view.components.*;
import org.puremvc.as3.patterns.mediator.*;
import editor.view.components.obj.*;
public class ObjectsMediator extends Mediator implements IMediator {
private var _view:ObjectsView;
private var objViews:Array;
public static const NAME:String = "ObjectsMediator";
public function ObjectsMediator(_arg1:ObjectsView):void{
super(NAME, _arg1);
init();
}
override public function listNotificationInterests():Array{
return ([EditorProxy.OBJECT_ADD, EditorProxy.OBJECTS_SELECT, EditorProxy.OBJECT_UPDATE, EditorProxy.OBJECT_REMOVE]);
}
private function objectAdd(_arg1:BaseObjectDef):void{
var _local2:ObjView;
if ((_arg1 is PlayerDef)){
_local2 = new SimpleView(_arg1);
} else {
if ((_arg1 is CircleDef)){
_local2 = new CircleView((_arg1 as CircleDef));
} else {
if ((_arg1 is RectDef)){
_local2 = new RectView((_arg1 as RectDef));
} else {
if ((_arg1 is PolyDef)){
_local2 = new PolyView((_arg1 as PolyDef));
} else {
if ((_arg1 is DistJointDef)){
_local2 = new DistJointView((_arg1 as DistJointDef));
} else {
if ((_arg1 is MotorDef)){
_local2 = new MotorView((_arg1 as MotorDef));
} else {
if ((_arg1 is RevJointDef)){
_local2 = new SimpleView((_arg1 as RevJointDef));
} else {
if ((_arg1 is ChainDef)){
_local2 = new ChainView((_arg1 as ChainDef));
} else {
if ((_arg1 is SimpleObjDef)){
_local2 = new SimpleView((_arg1 as SimpleObjDef));
} else {
return;
};
};
};
};
};
};
};
};
};
if ((_arg1 is PlayerDef)){
_view.player.addChild(_local2);
} else {
if ((((((((_arg1 is CircleDef)) || ((_arg1 is RectDef)))) || ((_arg1 is PolyDef)))) || ((_arg1 is SimpleObjDef)))){
_view.bodies.addChild(_local2);
} else {
if ((((((_arg1 is DistJointDef)) || ((_arg1 is RevJointDef)))) || ((_arg1 is ChainDef)))){
_view.joints.addChild(_local2);
};
};
};
objViews.push(_local2);
}
private function objectRemove(_arg1:BaseObjectDef):void{
var _local3:ObjView;
var _local2:uint;
while (_local2 < objViews.length) {
_local3 = objViews[_local2];
if (_local3.obj == _arg1){
_local3.destroy();
};
_local2++;
};
}
override public function handleNotification(_arg1:INotification):void{
switch (_arg1.getName()){
case EditorProxy.OBJECT_ADD:
objectAdd((_arg1.getBody() as BaseObjectDef));
break;
case EditorProxy.OBJECTS_SELECT:
objectsSelect((_arg1.getBody() as Array));
break;
case EditorProxy.OBJECT_UPDATE:
objectUpdate((_arg1.getBody() as BaseObjectDef));
break;
case EditorProxy.OBJECT_REMOVE:
objectRemove((_arg1.getBody() as BaseObjectDef));
break;
};
}
private function objectUpdate(_arg1:BaseObjectDef):void{
var _local3:ObjView;
var _local2:uint;
while (_local2 < objViews.length) {
_local3 = objViews[_local2];
if (_local3.obj == _arg1){
_local3.update();
};
_local2++;
};
}
private function init():void{
_view = (getViewComponent() as ObjectsView);
objViews = [];
}
public function destroy():void{
facade.removeMediator(NAME);
}
private function objectsSelect(_arg1:Array):void{
var _local3:ObjView;
var _local4:uint;
var _local5:BaseObjectDef;
var _local2:uint;
while (_local2 < objViews.length) {
_local3 = objViews[_local2];
_local3.deselect();
_local4 = 0;
while (_local4 < _arg1.length) {
_local5 = _arg1[_local4];
if (_local3.obj == _local5){
_local3.select();
};
_local4++;
};
_local2++;
};
}
}
}//package editor.view
Section 221
//PropsMediator (editor.view.PropsMediator)
package editor.view {
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import editor.model.objects.*;
import editor.view.components.*;
import org.puremvc.as3.patterns.mediator.*;
import editor.view.components.props.*;
public class PropsMediator extends Mediator implements IMediator {
private var _view:PropsView;
private var objPropsView:ObjPropsView;
public static const NAME:String = "ObjPropsMediator";
public function PropsMediator(_arg1:PropsView):void{
super(mediatorName, _arg1);
init();
}
override public function listNotificationInterests():Array{
return ([EditorProxy.OBJECTS_SELECT, EditorProxy.OBJECT_UPDATE, EditorProxy.OBJECT_REMOVE]);
}
private function objectRemove():void{
var _local1:EditorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
var _local2:Array = _local1.getSelectedObjects();
objectsSelect(_local2);
}
private function objectUpdate(_arg1:BaseObjectDef):void{
if (objPropsView){
if (objPropsView.obj == _arg1){
objPropsView.update();
};
};
}
private function init():void{
_view = (getViewComponent() as PropsView);
}
private function objectsSelect(_arg1:Array):void{
var _local2:BaseObjectDef;
if (objPropsView){
objPropsView.destroy();
objPropsView = null;
};
if (_arg1.length > 0){
if (_arg1.length == 1){
_local2 = _arg1[0];
if ((_local2 is PlayerDef)){
return;
};
if ((_local2 is CircleDef)){
objPropsView = new CirclePropsView((_local2 as CircleDef));
} else {
if ((_local2 is PolyDef)){
objPropsView = new PolyPropsView((_local2 as PolyDef));
} else {
return;
};
};
} else {
objPropsView = new SeveralObjsPropsView(_arg1[0]);
};
_view.container.addChild(objPropsView);
};
}
override public function handleNotification(_arg1:INotification):void{
switch (_arg1.getName()){
case EditorProxy.OBJECTS_SELECT:
objectsSelect((_arg1.getBody() as Array));
break;
case EditorProxy.OBJECT_UPDATE:
objectUpdate((_arg1.getBody() as BaseObjectDef));
break;
case EditorProxy.OBJECT_REMOVE:
objectRemove();
break;
};
}
}
}//package editor.view
Section 222
//ShapesMediator (editor.view.ShapesMediator)
package editor.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import game.model.*;
import core.shapes.*;
import editor.model.objects.*;
import editor.view.components.*;
import org.puremvc.as3.patterns.mediator.*;
import editor.view.components.shapes.*;
public class ShapesMediator extends Mediator implements IMediator {
private var editorProxy:EditorProxy;
private var _view:ShapesView;
private var items:Array;
private var notesProxy:NotesProxy;
public static const NAME:String = "ShapesMediator";
public function ShapesMediator(_arg1:ShapesView):void{
super(NAME, _arg1);
init();
}
public function destroy():void{
facade.removeMediator(NAME);
}
private function createItems():void{
var _local2:ShapeHolderItem;
items = [];
var _local1:int;
while (_local1 < 7) {
_local2 = new ShapeHolderItem(_local1);
_view.itemsContainer.addChild(_local2);
_local2.x = (_local1 * 60);
items.push(_local2);
_local1++;
};
}
private function objectUpdate(_arg1:BaseObjectDef):void{
var _local2:int;
var _local3:ShapeHolderItem;
var _local4:BaseShape;
if (_view.inner.visible){
_local2 = 0;
while (_local2 < items.length) {
_local3 = items[_local2];
if (_local3.isObjectInside(_arg1)){
_local4 = editorProxy.objToShape(_arg1);
if (_local4){
notesProxy.push(EditorProxy.OBJECT_REMOVE, _arg1);
notesProxy.push(EditorProxy.SHAPE_ADD, [_local4, _local2]);
};
break;
};
_local2++;
};
};
}
private function init():void{
_view = (getViewComponent() as ShapesView);
notesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
editorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
_view.inner.visible = false;
createItems();
_view.show_bt.addEventListener(MouseEvent.CLICK, showClickHandler);
_view.hide_bt.addEventListener(MouseEvent.CLICK, hideClickHandler);
}
override public function handleNotification(_arg1:INotification):void{
switch (_arg1.getName()){
case EditorProxy.OBJECT_UPDATE:
objectUpdate((_arg1.getBody() as BaseObjectDef));
break;
case EditorProxy.SHAPE_ADD:
shapeAdd((_arg1.getBody() as Array));
break;
};
}
private function shapeAdd(_arg1:Array):void{
var _local2:BaseShape = _arg1[0];
var _local3:int = _arg1[1];
var _local4:ShapeHolderItem = items[_local3];
_local4.addShape(_local2);
}
override public function listNotificationInterests():Array{
return ([EditorProxy.OBJECT_UPDATE, EditorProxy.SHAPE_ADD]);
}
private function hideClickHandler(_arg1:MouseEvent):void{
_view.inner.visible = false;
_view.show_bt.visible = true;
}
private function showClickHandler(_arg1:MouseEvent):void{
_view.inner.visible = true;
_view.show_bt.visible = false;
}
}
}//package editor.view
Section 223
//ToolsMediator (editor.view.ToolsMediator)
package editor.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import editor.model.*;
import game.model.*;
import flash.display.*;
import editor.view.components.*;
import editor.view.components.tools.*;
import org.puremvc.as3.patterns.mediator.*;
public class ToolsMediator extends Mediator implements IMediator {
private var editorProxy:EditorProxy;
private var _view:ToolsView;
private var toolTypes:Array;
private var canvasScale:Number;
private var selectedTool:ToolView;
private var notesProxy:NotesProxy;
private var toolViews:Array;
public static const NAME:String = "ToolsMediator";
public function ToolsMediator(_arg1:ToolsView):void{
super(NAME, _arg1);
init();
}
override public function handleNotification(_arg1:INotification):void{
switch (_arg1.getName()){
case EditorProxy.TOOL_SELECT:
toolSelect((_arg1.getBody() as Tool));
break;
case EditorProxy.OBJECTS_SELECT:
objectsSelect((_arg1.getBody() as Array));
break;
case EditorProxy.OBJECT_REMOVE:
objectsRemove((_arg1.getBody() as Array));
break;
};
}
private function getToolView(_arg1:Tool):ToolView{
var _local3:ToolView;
var _local2:uint;
while (_local2 < toolViews.length) {
_local3 = toolViews[_local2];
if (_local3.tool == _arg1){
return (_local3);
};
_local2++;
};
return (null);
}
private function init():void{
_view = (getViewComponent() as ToolsView);
notesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
}
private function getToolByType(_arg1:String):Tool{
var _local4:Tool;
var _local2:Array = editorProxy.getTools();
var _local3:uint;
while (_local3 < _local2.length) {
_local4 = _local2[_local3];
if (_local4.type == _arg1){
return (_local4);
};
_local3++;
};
return (null);
}
override public function listNotificationInterests():Array{
return ([EditorProxy.TOOL_SELECT, EditorProxy.OBJECTS_SELECT, EditorProxy.OBJECT_REMOVE]);
}
override public function onRegister():void{
editorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
initTools();
canvasScale = 1;
_view.window.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
toolTypes = [Tool.TYPE_SELECTION, Tool.TYPE_CIRCLE, Tool.TYPE_RECT, Tool.TYPE_DIST_JOINT, Tool.TYPE_REV_JOINT, Tool.TYPE_MOTOR, Tool.TYPE_POLY];
notesProxy.push(EditorProxy.TOOL_SELECT, editorProxy.getTools()[0]);
}
private function initTools():void{
var _local3:Tool;
var _local4:ToolView;
var _local1:Array = editorProxy.getTools();
toolViews = [];
var _local2:uint;
for (;_local2 < _local1.length;_local2++) {
_local3 = _local1[_local2];
switch (_local3.type){
case Tool.TYPE_SELECTION:
_local4 = new SelectionTool(_view.selectionTool, _local3);
break;
case Tool.TYPE_CIRCLE:
_local4 = new CircleTool(_view.circleTool, _local3);
break;
case Tool.TYPE_RECT:
_local4 = new RectTool(_view.rectTool, _local3);
break;
case Tool.TYPE_DIST_JOINT:
_local4 = new DistJointTool(_view.distJointTool, _local3);
break;
case Tool.TYPE_REV_JOINT:
_local4 = new SimpleTool(_view.revJointTool, _local3);
break;
case Tool.TYPE_MOTOR:
_local4 = new SimpleTool(_view.motorTool, _local3);
break;
case Tool.TYPE_POLY:
_local4 = new PolyTool(_view.polyTool, _local3);
break;
case Tool.TYPE_CHAIN:
_local4 = new ChainTool(_view.chainTool, _local3);
break;
case Tool.TYPE_HAND:
_local4 = new HandTool(_view.handTool, _local3);
break;
case Tool.TYPE_BOTTLE:
_local4 = new SimpleTool(_view.bottleTool, _local3);
break;
case Tool.TYPE_MONITOR:
_local4 = new SimpleTool(_view.monitorTool, _local3);
break;
default:
continue;
};
toolViews.push(_local4);
_local4.addEventListener(ToolView.SELECT, toolSelectHandler);
};
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
var _local5:Tool;
var _local2:EditorMediator = (facade.retrieveMediator(EditorMediator.NAME) as EditorMediator);
var _local3:EditorView = (_local2.getViewComponent() as EditorView);
var _local4:Sprite = _local3.canvas;
if ((((_arg1.keyCode >= 49)) && ((_arg1.keyCode <= 55)))){
_local5 = getToolByType(toolTypes[(_arg1.keyCode - 49)]);
if (editorProxy.selectedTool != _local5){
notesProxy.push(EditorProxy.TOOL_SELECT, _local5);
};
};
}
private function toolSelect(_arg1:Tool):void{
if (selectedTool){
selectedTool.deselect();
};
selectedTool = getToolView(_arg1);
selectedTool.select();
editorProxy.selectedTool = selectedTool.tool;
}
private function objectsSelect(_arg1:Array):void{
if (_arg1.length == 0){
_view.window.visible = true;
} else {
_view.window.visible = false;
};
}
private function objectsRemove(_arg1:Array):void{
_view.window.visible = true;
}
public function destroy():void{
_view.window.stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
facade.removeMediator(NAME);
}
private function toolSelectHandler(_arg1:Event):void{
var _local2:ToolView = (_arg1.target as ToolView);
notesProxy.push(EditorProxy.TOOL_SELECT, _local2.tool);
}
}
}//package editor.view
Section 224
//GameAbortCommand (game.controller.GameAbortCommand)
package game.controller {
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import game.model.*;
import org.puremvc.as3.patterns.command.*;
import game.view.*;
public class GameAbortCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:GameProxy = (facade.retrieveProxy(GameProxy.NAME) as GameProxy);
_local2.gameAbort();
var _local3:LevelSelectMediator = (facade.retrieveMediator(LevelSelectMediator.NAME) as LevelSelectMediator);
if (_local3){
_local3.destroy();
};
var _local4:GameCompleteMediator = (facade.retrieveMediator(GameCompleteMediator.NAME) as GameCompleteMediator);
if (_local4){
_local4.destroy();
};
var _local5:AppMediator = (facade.retrieveMediator(AppMediator.NAME) as AppMediator);
var _local6:MainMenuView = new MainMenuView();
_local5.getViewContainer().addChild(_local6);
var _local7:MainMenuMediator = new MainMenuMediator(_local6);
facade.registerMediator(_local7);
}
}
}//package game.controller
Section 225
//GameCompleteCommand (game.controller.GameCompleteCommand)
package game.controller {
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import game.model.*;
import org.puremvc.as3.patterns.command.*;
import game.view.*;
public class GameCompleteCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:AppMediator = (facade.retrieveMediator(AppMediator.NAME) as AppMediator);
var _local3:GameCompleteView = new GameCompleteView();
_local2.getViewContainer().addChild(_local3);
var _local4:GameCompleteMediator = new GameCompleteMediator(_local3);
facade.registerMediator(_local4);
var _local5:GameProxy = (facade.retrieveProxy(GameProxy.NAME) as GameProxy);
_local5.gameComplete();
}
}
}//package game.controller
Section 226
//GameStartCommand (game.controller.GameStartCommand)
package game.controller {
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import game.model.*;
import org.puremvc.as3.patterns.command.*;
import game.view.*;
public class GameStartCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:MainMenuMediator = (facade.retrieveMediator(MainMenuMediator.NAME) as MainMenuMediator);
_local2.destroy();
var _local3:GameProxy = new GameProxy();
facade.registerProxy(_local3);
_local3.gameStart();
var _local4:AppMediator = (facade.retrieveMediator(AppMediator.NAME) as AppMediator);
var _local5:LevelSelectView = new LevelSelectView();
_local4.getViewContainer().addChild(_local5);
var _local6:LevelSelectMediator = new LevelSelectMediator(_local5);
facade.registerMediator(_local6);
}
}
}//package game.controller
Section 227
//InitializeCommand (game.controller.InitializeCommand)
package game.controller {
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import game.model.*;
import org.puremvc.as3.patterns.command.*;
import game.view.*;
public class InitializeCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:AppView = new AppView();
ApplicationFacade.getInstance().viewContainer.addChild(_local2);
var _local3:AppMediator = new AppMediator(_local2);
facade.registerMediator(_local3);
var _local4:MainMenuView = new MainMenuView();
_local3.getViewContainer().addChild(_local4);
var _local5:MainMenuMediator = new MainMenuMediator(_local4);
facade.registerMediator(_local5);
var _local6:AppProxy = (facade.retrieveProxy(AppProxy.NAME) as AppProxy);
_local6.initializeComplete();
var _local7:LogoView = new LogoView();
_local3.getSplashContainer().addChild(_local7);
}
}
}//package game.controller
Section 228
//LevelAbortCommand (game.controller.LevelAbortCommand)
package game.controller {
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import game.model.*;
import org.puremvc.as3.patterns.command.*;
import game.view.*;
public class LevelAbortCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:LevelMediator = (facade.retrieveMediator(LevelMediator.NAME) as LevelMediator);
_local2.destroy();
var _local3:LevelCompleteMediator = (facade.retrieveMediator(LevelCompleteMediator.NAME) as LevelCompleteMediator);
if (_local3){
_local3.destroy();
};
var _local4:GameProxy = (facade.retrieveProxy(GameProxy.NAME) as GameProxy);
_local4.levelAbort();
var _local5:AppMediator = (facade.retrieveMediator(AppMediator.NAME) as AppMediator);
var _local6:LevelSelectView = new LevelSelectView();
_local5.getViewContainer().addChild(_local6);
var _local7:LevelSelectMediator = new LevelSelectMediator(_local6);
facade.registerMediator(_local7);
}
}
}//package game.controller
Section 229
//LevelCompleteCommand (game.controller.LevelCompleteCommand)
package game.controller {
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import org.puremvc.as3.patterns.command.*;
import game.view.*;
public class LevelCompleteCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:AppMediator = (facade.retrieveMediator(AppMediator.NAME) as AppMediator);
var _local3:LevelCompleteView = new LevelCompleteView();
_local2.getViewContainer().addChild(_local3);
var _local4:LevelCompleteMediator = new LevelCompleteMediator(_local3);
facade.registerMediator(_local4);
}
}
}//package game.controller
Section 230
//LevelStartCommand (game.controller.LevelStartCommand)
package game.controller {
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import game.model.*;
import org.puremvc.as3.patterns.command.*;
import game.view.*;
public class LevelStartCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:LevelSelectMediator = (facade.retrieveMediator(LevelSelectMediator.NAME) as LevelSelectMediator);
_local2.destroy();
var _local3:AppMediator = (facade.retrieveMediator(AppMediator.NAME) as AppMediator);
var _local4:LevelView = new LevelView();
_local3.getViewContainer().addChild(_local4);
var _local5:LevelMediator = new LevelMediator(_local4);
facade.registerMediator(_local5);
var _local6:GameProxy = (facade.retrieveProxy(GameProxy.NAME) as GameProxy);
_local6.levelStart((_arg1.getBody() as int));
}
}
}//package game.controller
Section 231
//StartupCommand (game.controller.StartupCommand)
package game.controller {
import org.puremvc.as3.interfaces.*;
import game.model.*;
import flash.display.*;
import org.puremvc.as3.patterns.command.*;
public class StartupCommand extends SimpleCommand implements ICommand {
override public function execute(_arg1:INotification):void{
var _local2:Sprite = _arg1.getBody().container;
var _local3:AppProxy = new AppProxy();
facade.registerProxy(_local3);
_local3.startApp();
}
}
}//package game.controller
Section 232
//AppProxy (game.model.AppProxy)
package game.model {
import flash.events.*;
import game.view.components.*;
import editor.model.*;
import core.*;
import game.controller.*;
import org.puremvc.as3.patterns.proxy.*;
import editor.controller.*;
import caurina.transitions.properties.*;
public class AppProxy extends Proxy {
private var notesProxy:NotesProxy;
public static const GAME_URL:String = ("http://olologames.com/playgame.php?id=" + GAME_ID);
public static const GAME_ABORT:String = "GameAbort";
public static const MOCHI_LEVEL_COMPLETE_MORE_GAMES:String = "http://www.notdoppler.com/?ref=wakeupthebox2";
public static const GAME_ID:int = 92;
public static const NAME:String = "AppProxy";
public static const EDITOR_CLOSE:String = "EditorClose";
public static const MOCHI_MAIN_MENU_MORE_GAMES:String = "http://www.notdoppler.com/?ref=wakeupthebox2";
public static const MOCHI_GAME_COMPLETE_MORE_GAMES:String = "http://www.notdoppler.com/?ref=wakeupthebox2";
public static const INITIALIZE:String = "Initialize";
public static const HIGHSCORES_URL:String = "http://www.notdoppler.com/highscores.php?game=wakebox2";
public static const WALKTHROUGH_URL:String = "http://olologames.com/wuthw.php";
public static const WAKE_UP_THE_BOX_1_URL:String = "http://www.notdoppler.com/wakeupthebox.php?ref=wakeupthebox2";
public static const SITE_URL:String = "http://www.notdoppler.com/?ref=wakeupthebox2";
public static const MOCHI_CREDITS_SPONSOR:String = "http://www.notdoppler.com/?ref=wakeupthebox2";
public static const MOCHI_MAIN_MENU_HIGHSCORES:String = "http://www.notdoppler.com/highscores.php?game=wakebox2";
public static const GAME_COMPLETE:String = "GameComplete";
public static const INSERTSCORE_URL:String = "http://olologames.com/insertscore.php";
public static const EDITOR_START:String = "EditorStart";
public static const MOCHI_LEVEL_VIEW_SPONSOR_LOGO:String = "http://www.notdoppler.com/?ref=wakeupthebox2";
public static const GAME_START:String = "GameStart";
public static const MOCHI_MAIN_MENU_SPONSOR_LOGO:String = "http://www.notdoppler.com/?ref=wakeupthebox2";
public static const MOCHI_MAIN_MENU_ORIGINAL_GAME:String = "http://www.notdoppler.com/wakeupthebox.php?ref=wakeupthebox2";
public static const MOCHI_LEVEL_VIEW_WALKTHROUGH:String = "http://www.notdoppler.com/wakeupthebox2-walkthrough.php?ref=wakeupthebox2";
public static const MOCHI_SPLASH_SCREEN:String = "http://www.notdoppler.com/?ref=wakeupthebox2";
public static var GAME_VERSION:String = "0.97";
public function AppProxy():void{
super(NAME);
init();
}
private function init():void{
facade.registerCommand(INITIALIZE, InitializeCommand);
facade.registerCommand(GAME_START, GameStartCommand);
facade.registerCommand(GAME_ABORT, GameAbortCommand);
facade.registerCommand(GAME_COMPLETE, GameCompleteCommand);
facade.registerCommand(EDITOR_START, EditorStartCommand);
facade.registerCommand(EDITOR_CLOSE, EditorCloseCommand);
notesProxy = new NotesProxy();
facade.registerProxy(notesProxy);
}
private function editorAssetsInitHandler(_arg1:Event):void{
var _local2:GameAssets = GameAssets.getInstance();
_local2.addEventListener(Event.INIT, assetsInitHandler);
_local2.init();
}
private function assetsInitHandler(_arg1:Event=null):void{
if (Preloader.DOMAIN_KONG){
GAME_VERSION = (GAME_VERSION + " kong");
};
SaveData.getInstance().initialize();
SoundShortcuts.init();
notesProxy.push(INITIALIZE);
CoreEngine.getInstance().initialize();
}
private function coreAssetsInitHandler(_arg1:Event):void{
var _local2:EditorAssets = EditorAssets.getInstance();
_local2.addEventListener(Event.INIT, editorAssetsInitHandler);
_local2.init();
}
public function initializeComplete():void{
Fader.getInstance();
}
public function startApp():void{
var _local1:CoreAssets = CoreAssets.getInstance();
_local1.addEventListener(Event.INIT, coreAssetsInitHandler);
_local1.init();
}
}
}//package game.model
Section 233
//GameAssets (game.model.GameAssets)
package game.model {
import flash.events.*;
import flash.display.*;
import flash.system.*;
public class GameAssets extends EventDispatcher {
private var Assets:Class;
private var appDomain:ApplicationDomain;
private static var instance:GameAssets;
public function GameAssets():void{
Assets = GameAssets_Assets;
super();
}
public function init():void{
var _local1:Loader = new Loader();
_local1.contentLoaderInfo.addEventListener(Event.INIT, assetsInitHandler);
_local1.loadBytes(new Assets());
}
private function assetsInitHandler(_arg1:Event):void{
appDomain = _arg1.target.content.loaderInfo.applicationDomain;
dispatchEvent(new Event(Event.INIT));
}
public function getAssetClass(_arg1:String):Class{
if (!appDomain.hasDefinition(_arg1)){
trace((("*Error*: There is no definition of class '" + _arg1) + "'"));
return (null);
};
return ((appDomain.getDefinition(_arg1) as Class));
}
public static function getInstance():GameAssets{
if (!instance){
instance = new (GameAssets);
};
return (instance);
}
}
}//package game.model
Section 234
//GameAssets_Assets (game.model.GameAssets_Assets)
package game.model {
import mx.core.*;
public class GameAssets_Assets extends ByteArrayAsset {
}
}//package game.model
Section 235
//GameLevel (game.model.GameLevel)
package game.model {
import core.*;
public class GameLevel extends CoreLevel {
public var def:String;
public function GameLevel(_arg1:int, _arg2:String){
this.def = _arg2;
super(_arg1);
}
}
}//package game.model
Section 236
//GameProxy (game.model.GameProxy)
package game.model {
import game.view.components.*;
import editor.model.*;
import core.*;
import flash.display.*;
import core.gamecomplete.*;
import game.controller.*;
import org.puremvc.as3.patterns.proxy.*;
import game.view.*;
public class GameProxy extends Proxy {
private var engine:CoreEngine;
public var currentLevel:GameLevel;
public var playername:String;
private var notesProxy:NotesProxy;
public var levels:Array;
private var completeEngine:CompleteEngine;
public static const LEVEL_COMPLETE:String = "LevelComplete";
public static const LEVEL_ABORT:String = "LevelAbort";
public static const LEVEL_START:String = "LevelStart";
public static const NAME:String = "GameProxy";
public function GameProxy():void{
super(NAME);
init();
}
public function gameAbort():void{
if (completeEngine){
completeEngine.destroy();
};
engine.removeEventListener(CoreEngine.LEVEL_COMPLETE, levelCompleteHandler);
destroy();
}
public function destroy():void{
facade.removeProxy(NAME);
}
private function addLevel(_arg1:String):void{
var _local2:int = levels.length;
var _local3:GameLevel = new GameLevel(_local2, _arg1);
levels.push(_local3);
}
public function levelStart(_arg1:int):void{
var _local2:LevelMediator = (facade.retrieveMediator(LevelMediator.NAME) as LevelMediator);
var _local3:LevelView = (_local2.getViewComponent() as LevelView);
var _local4:GameLevel = levels[_arg1];
if (currentLevel){
engine.isLevelRestart = ((currentLevel.id == _local4.id)) ? true : false;
};
currentLevel = _local4;
engine.levelStart(currentLevel, _local3.coreContainer);
LevelStringParser.getInstance().parse(currentLevel.def);
_local2.setBackground();
}
public function levelAbort():void{
engine.levelAbort();
}
private function init():void{
if (!facade.hasCommand(LEVEL_START)){
facade.registerCommand(LEVEL_START, LevelStartCommand);
};
if (!facade.hasCommand(LEVEL_ABORT)){
facade.registerCommand(LEVEL_ABORT, LevelAbortCommand);
};
if (!facade.hasCommand(LEVEL_COMPLETE)){
facade.registerCommand(LEVEL_COMPLETE, LevelCompleteCommand);
};
notesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
engine = CoreEngine.getInstance();
playername = "Mr. Box";
}
public function gameComplete():void{
engine.removeEventListener(CoreEngine.LEVEL_COMPLETE, levelCompleteHandler);
var _local1:GameCompleteMediator = (facade.retrieveMediator(GameCompleteMediator.NAME) as GameCompleteMediator);
var _local2:Sprite = (_local1.getViewComponent() as GameCompleteView).back;
completeEngine = CompleteEngine.getInstance();
completeEngine.levelStart(_local2);
}
private function levelCompleteHandler(_arg1:CoreEvent):void{
currentLevel.complete(engine.elapsedTime);
SaveData.getInstance().levelComplete(currentLevel);
var _local2:CoreLevel = levels[(currentLevel.id + 1)];
if (_local2){
_local2.isOpen = true;
};
var _local3:CoreLevel = levels[(levels.length - 1)];
if (currentLevel.id == _local3.id){
Fader.getInstance().fade(gameCompleteCallback);
} else {
notesProxy.push(LEVEL_COMPLETE);
};
if (Preloader.DOMAIN_KONG){
Preloader.kongregate.scores.submit(getTotalScore());
};
}
public function gameStart():void{
var _local1:int;
var _local2:GameLevel;
var _local4:Object;
levels = [];
addLevel("PlayerDef_330_166|PolyDef_315_315_TypeWood_0,0_-35,-160_-25,-165_-15,-120_45,-120_60,-165_70,-160_25,0|RectDef_328_328_25_25_TypeBrick_0| CircleShape_40|");
addLevel("PlayerDef_365_101|RectDef_369_372_10_292_TypeMetal_0|RectDef_302_326_48_118_TypeBrick_0|CircleDef_433_229_38_TypeMetal|CircleDef_302_229_38_TypeMetal|RectDef_363_187_267_6_TypeMetal_0|CircleDef_473_161_23_TypeMetal|CircleDef_254_161_23_TypeMetal|RectDef_362_134_267_6_TypeMetal_0|RevJoint_369_374|DistJointDef_233_469_99_461_367_477|CircleDef_102_266_47_TypeWood|Motor_103_267_0.5|RectDef_435_326_48_118_TypeBrick_0|RectDef_99_401_12_132_TypeMetal_0|RevJoint_99_402| RectShape_60_10.000000000000004_0|");
addLevel("PlayerDef_339_137|PolyDef_248_167_TypeWood_0,0_177,0_178,8_85,21_-3,9|RevJoint_257_173|RevJoint_416_173|PolyDef_337_296_TypeKiller_-3,31_-7,-32_-3,-40_-5,-54_5,-63_15,-55_14,-41_21,-32_16,69_8,74_0,67|Motor_346_360_0.5| RectShape_13_69_0|");
addLevel("PlayerDef_50_270|RectDef_50_315_40_30_TypeBrick_0|RevJoint_376_344|RectDef_536_397_60_15_TypeBrick_0|ChainDef_370_70_280_205|CircleDef_260_220_35_TypeWood|ChainDef_240_205_125_75|PolyDef_300_336_TypeWood_-26,0_240,-1_240,9_-28,21|PolyDef_542_279_TypeKiller_4,3_34,2_34,14_29,18_26,24_27,32_30,38_35,45_37,56_35,74_25,88_11,103_-3,111_-3,107_8,97_20,78_13,69_2,66_1,54_9,47_14,39_16,31_12,20_4,13|DistJointDef_528_340_551_340_505_341|DistJointDef_541_315_559_289_523_341|DistJointDef_533_359_512_342_554_377| RectShape_50_50_0|RectShape_50_50_0|RectShape_50_50_0|");
addLevel("PlayerDef_544_401|RectDef_83_128_75_65_TypeWood_0|RectDef_83_125_24_50_TypeWood_0|Motor_85_110_0.6|PolyDef_22_160_TypeBrick_-44,0_121,-1_122,10_7,12_2,20_-2,38_-3,62_0,75_12,85_23,89_41,90_231,90_231,101_54,101_43,104_35,119_34,140_38,159_48,172_70,179_110,181_375,180_376,191_121,191_107,197_98,210_97,226_101,243_113,256_127,265_143,268_163,271_537,271_538,284_-44,283_-43,88| RectShape_10_81_0|");
addLevel("PlayerDef_347_323|PolyDef_302_362_TypeWood_-1,-1_1,-9_68,-9_69,-2_55,-1_72,47_63,47_49,-1_23,-1_6,47_-2,46_15,-1|RectDef_458_419_374_10.000000000000023_TypeBrick_0|RevJoint_493_288|PolyDef_447_278_TypeWood_2,-22_-8,136_-2,137_3,69_12,72_30,73_43,69_47,136_53,136_49,-22_24,-33|CircleDef_475_242_37_TypeWood|RevJoint_457_259|RevJoint_476_266|PolyDef_358_280_TypeWood_0,0_53,4_95,-5_101,4_53,15_11,8_8,11_-2,10|RevJoint_453_281|RevJoint_368_405|RevJoint_305_405|CircleDef_368_405_9_TypeWood|CircleDef_305_405_9_TypeWood|PolyDef_483_287_TypeWood_0,0_36,-34_52,-104_51,-113_72,-107_62,-100_43,-30_9,12|PolyDef_280_414_TypeBrick_0,0_-121,3_-177,12_-224,31_-269,58_-294,93_-279,98_-252,62_-209,40_-164,23_-79,13_-2,10|RevJoint_388_131|PolyDef_206_232_TypeBrick_0,0_81,-15_177,-19_183,-11_79,1_7,16|PolyDef_373_147_TypeWood_3,-1_5,-22_13,-30_25,-23_28,0_186,13_194,20_187,47_181,24_17,12_-135,30_-143,49_-150,27_-142,18| CircleShape_36|");
addLevel("PlayerDef_308_52|RectDef_558_278_20_354_TypeBrick_0|PolyDef_94_192_TypeBrick_0,0_-1,13_-10,25_-25,35_-39,40_-45,50_-47,65_-42,78_-32,87_-16,91_0,96_9,108_8,127_-5,139_-20,145_-31,152_-33,165_-28,173_-7,176_24,175_44,173_44,0|PolyDef_69_192_TypeBrick_0,0_-3,7_-15,16_-32,22_-43,33_-49,51_-48,75_-36,94_-21,106_0,110_4,116_0,124_-11,127_-25,132_-37,144_-40,162_-36,182_-24,194_-3,202_22,200_48,197_69,197_68,260_-67,258_-61,1|CircleDef_79_203_10_TypeWood|RectDef_302_92_533_19_TypeMetal_0|RectDef_73_147_131_89_TypeBrick_0|RevJoint_150_438|RevJoint_533_439|PolyDef_138_414_TypeRubber_0,0_54,7_122,2_177,8_244,15_280,-3_341,5_374,2_409,8_409,41_-1,38| CircleShape_51|");
addLevel("PlayerDef_402_262|PolyDef_71_462_TypeBrick_0,0_92,-2_77,-16_93,-15_82,-42_99,-22_114,-45_112,-15_130,-27_113,0_512,-4_517,110_4,101|PolyDef_293_358_TypeKiller_0,0_64,-65_96,-41_96,-66_118,-66_118,-26_149,-2_125,-2_128,102_103,102_102,54_58,47_59,102_30,102_27,-1|DistJointDef_313_144_313_137_313_151|PolyDef_204_142_TypeWood_0,0_-10,-8_-7,-19_9,-29_34,-32_59,-27_114,-20_152,-22_156,-15_149,-4_30,2|PolyDef_307_147_TypeKiller_-4,0_14,0_13,6_8,8_10,29_15,40_17,52_15,61_7,65_-2,62_-6,49_-4,38_0,30_3,8_-2,6|PolyDef_559_-19_TypeWood_3,1_6,27_-117,52_-116,57_8,34_14,43_23,48_-60,149_-54,153_29,51_49,54_62,54_43,164_49,165_69,53_98,48_104,1|PolyDef_24_91_TypeKiller_0,0_137,0_143,-6_148,-19_142,-31_125,-39_117,-36_108,-31_103,-26_100,-45_91,-62_68,-71_40,-67_29,-56_29,-31_24,-44_7,-50_-15,-45_-24,-31_-21,-6|PolyDef_252_135_TypeWood_0,0_0,-6_11,-10_74,-5_9,3|RevJoint_258_131|RevJoint_302_130|RevJoint_576_-11|RevJoint_648_21|RectDef_234_-93_978_8.00000000000006_TypeBrick_0|CircleDef_3_-161_64_TypeWood|Motor_4_-162_0.2|Motor_149_-162_0.2|DistJointDef_50.5_-48_69_-147_32_51|DistJointDef_95.5_-49_78_-147_113_49|CircleDef_146_-161_64_TypeWood|RectDef_77_-162_172_42.00000000000001_TypeWood_0|RevJoint_205_130|RevJoint_353_127| RectShape_15_49_15|");
addLevel("PlayerDef_360_370|RectDef_400_425_60_30.000000000000004_TypeBrick_0|DistJointDef_232.5_360_290_360_175_360|RectDef_163_360_54_30.000000000000004_TypeWood_0|RevJoint_145_355|RevJoint_145_365|PolyDef_239_181_TypeWood_0,0_60,1_58,32_58,74_59,109_-6,111_-10,76_-8,30|CircleDef_264_178_40_TypeWood|RevJoint_258_189|RevJoint_287_189|PolyDef_241_285_TypeWood_0,0_-2,76_2,82_15,80_29,82_37,77_35,62_21,62_5,66_6,-3|PolyDef_281_282_TypeWood_1,0_2,81_10,85_24,82_36,82_39,71_27,62_8,67_7,-1|RevJoint_244_287|Motor_285_286_7|RevJoint_240_220|RevJoint_290_220|DistJointDef_150_142.5_150_65_150_220|DistJointDef_520_142.5_520_65_520_220|PolyDef_520_210_TypeKiller_0,0_20,0_25,45_-25,45_-20,0|PolyDef_150_210_TypeKiller_0,0_20,0_25,45_-25,45_-20,0|RectDef_335_65_390_10_TypeWood_0|RevJoint_335_65|PolyDef_335_400_TypeWood_0,0_175,0_175,-130_185,-130_185,10_0,10| CircleShape_20|");
addLevel("PlayerDef_539_181|RevJoint_308_265|RectDef_70_313_327.82685902179844_27.812775911474542_TypeBrick_30|CircleDef_149_167_10_TypeKiller|PolyDef_312_202_TypeWood_0,0_17,-15_-28,-14_-10,0_-10,7_-39,-18_-40,-41_30,-42_27,-14_1,7|PolyDef_291_373_TypeMetal_0,0_0,-11_12,-15_12,-171_-4,-185_35,-185_20,-171_23,-16_35,-12_36,0_16,2|RectDef_121_188_139.4672577328444_12.20180398467214_TypeBrick_-5|RectDef_539_336_71_67_TypeWood_0|RectDef_539_290_72_24.000000000000004_TypeMetal_0|RectDef_539_245_71_67_TypeWood_0|PolyDef_209_378_TypeBrick_0,0_160,2_170,20_174,39_262,45_265,17_281,-8_369,-8_385,71_-4,69|PolyDef_371_380_TypeKiller_0,0_9,16_13,34_96,40_99,15_115,-6| CircleShape_23|RectShape_202_7_0|");
addLevel("PlayerDef_338_359|RectDef_170_393_300_14.000000000000018_TypeRubber_20|PolyDef_525_195_TypeWood_-3,0_7,0_8,12_35,13_52,63_-46,65_-34,14_-5,12|ChainDef_528_80_527_201|RevJoint_37_345|RevJoint_304_442|CircleDef_56_191_6_TypeKiller|PolyDef_510_95_TypeBrick_-8,-6_-23,-30_48,-34_44,-4|CircleDef_145_261_6_TypeKiller|CircleDef_259_297_6_TypeKiller|CircleDef_259_262_10_TypeWood|DistJointDef_259_279.5_259_262_259_297|RevJoint_259_262|CircleDef_145_226_10_TypeWood|DistJointDef_145_243_145_226_145_261|RevJoint_145_226|CircleDef_56_156_10_TypeWood|DistJointDef_56_173_56_156_56_191|RevJoint_56_156|RectDef_425_433_14_10_TypeBrick_0|RectDef_365_433_14_10_TypeBrick_0|PolyDef_348_421_TypeWood_0,0_220,-2_220,5_-10,8_-11,-33_3,-33| RectShape_50_7_0|");
addLevel("PlayerDef_498_310|RectDef_481_354_40_30_TypeBrick_0|CircleDef_342_65_53_TypeBrick|RectDef_204_285_319.0117951464495_18.206442745351097_TypeBrick_-20|RectDef_311_67_78_16.000000000000004_TypeWood_0|Motor_343_67_-0.6|RectDef_129_272_246.39290882492253_13.05888512827245_TypeWood_-20|DistJointDef_191_185_281_67_102_303|RevJoint_193_249|RevJoint_63_297|RectDef_359_182_177.36005736815702_15.60160409586326_TypeBrick_-20|RevJoint_493_106|PolyDef_418_69_TypeWood_51,32_75,46_152,12_145,0_74,33_56,23|RectDef_606_92_84_12_TypeBrick_0|CircleDef_532_72_10_TypeMetal|CircleDef_493_87_10_TypeMetal|CircleDef_512_82_10_TypeMetal|RectDef_142_287_117.2128274509814_17.12171372691585_TypeWood_160|RectDef_406_284_11.497362375955204_166.0837459187261_TypeBrick_-45| RectShape_98.28203230275508_10.22947341949746_30|RectShape_50.089442258789525_21.703635045848667_-105|");
addLevel("PlayerDef_148_105|CircleDef_320_322_22_TypeWood|Motor_260_392_-0.5|ChainDef_320_96_320_307|CircleDef_259_391_37_TypeWood|Motor_496_338_0.5|CircleDef_495_337_37_TypeWood|DistJointDef_148_132_148_187_148_77| RectShape_80_10_0|RectShape_80_10_0|RectShape_10_120_0|");
addLevel("PlayerDef_513_346|ChainDef_500_400_60_400|PolyDef_285_215_TypeWood_0,50_0,-110_-10,-110_-10,-135_20,-135_20,-110_10,-110_10,50|RectDef_290_68_60_15_TypeKiller_0|DistJointDef_275_80_270_70_280_90|DistJointDef_305_80_310_70_300_90|DistJointDef_285_80_270_70_300_90|DistJointDef_295_80_280_90_310_70|RevJoint_290_210|CircleDef_410_250_35_TypeWood|CircleDef_175_250_35_TypeKiller|DistJointDef_292.5_250_175_250_410_250|RectDef_513_438_14_34_TypeBrick_0|RectDef_513_393_44_34_TypeWood_0|RectDef_175_290_80_10.000000000000005_TypeBrick_0|RectDef_470_290_130_10.000000000000007_TypeBrick_0|RectDef_488_253_35_65_TypeRubber_0|RevJoint_490_230|RevJoint_490_280|RectDef_298_415_565_10_TypeWood_0|RectDef_93_438_14_34_TypeBrick_0|RectDef_325_280_20_30_TypeBrick_0|RectDef_370_290_70_10.000000000000004_TypeBrick_0| RectShape_130_10_0|");
addLevel("PlayerDef_542_372|RectDef_543_417_40_30_TypeBrick_0|ChainDef_49_269_532_415|CircleDef_121_135_40_TypeWood|RectDef_245_181_338_12.000000000000021_TypeWood_0|RectDef_449_145_172_18.00000000000001_TypeBrick_0|RevJoint_405_182|RevJoint_84_182|RevJoint_547_170|CircleDef_533_124_12_TypeKiller|RectDef_533_167_55_23_TypeBrick_0|RectDef_558_169_7.999999999999991_140_TypeMetal_90|RectDef_496_210_58_9_TypeWood_0|DistJointDef_508_189_495_169_521_209|DistJointDef_483_189_495_169_472_210|RectDef_271_166_148_18.00000000000001_TypeBrick_0| RectShape_45_42_0|RectShape_11_77_0|");
addLevel("PlayerDef_217_375|RectDef_144_430_40_30_TypeBrick_0|RectDef_269_410_244_10.000000000000014_TypeWood_0|RevJoint_376_410|CircleDef_128_233_3_TypeKiller|PolyDef_316_190_TypeBrick_-10,7_113,27_114,44_-5,40_-10,22|RectDef_441_359_28_136_TypeWood_0|RevJoint_440_419|RectDef_440_282_75_50_TypeMetal_0|RevJoint_443_304|RevJoint_443_294|ChainDef_450_90_454_270|RectDef_192_293_225_10_TypeBrick_0|PolyDef_282_220_TypeMetal_-8,-5_-164,45_-181,23_-179,21_-163,41_-7,-9|RevJoint_190_241|RectDef_396_245_12_37_TypeBrick_0|RectDef_154_57_86_11_TypeBrick_0|CircleDef_186_29_21_TypeWood|RectDef_311_256_11_85_TypeBrick_0|RectDef_189_259_34_59_TypeMetal_0| CircleShape_30|");
addLevel("PlayerDef_105_402|RectDef_105_470_326_20.00000000000002_TypeBrick_0|CircleDef_477_132_57_TypeWood|Motor_479_134_0.5|CircleDef_374_314_28_TypeWood|DistJointDef_443_205_375_316_511_94|DistJointDef_333.5_217.5_374_301_293_134|CircleDef_170_448_11_TypeWood|RectDef_103_434_173_4_TypeWood_0|CircleDef_43_448_11_TypeWood|CircleDef_106_448_11_TypeWood| RectShape_47_8_0|RectShape_47_8_0|RectShape_47_8_0|RectShape_47_8_0|");
addLevel("PlayerDef_521_258|RectDef_521_298_60_30.000000000000004_TypeBrick_0|RectDef_327_303_90_30.000000000000007_TypeWood_0|RectDef_430_303_86_30.000000000000004_TypeWood_0|PolyDef_363_318_TypeMetal_0,0_30,0_30,-20_111,-20_111,-35_-81,-35_-81,-21_0,-20|RevJoint_358_293|RevJoint_288_292|RevJoint_468_292|RevJoint_403_293|Motor_378_303_0.4|PolyDef_265_283_TypeBrick_0,0_-40,0_-75,-5_-125,-15_-160,-30_-210,-60_-245,-105_-260,-140_-265,-140_-265,30_0,30|RectDef_513_38_95_20_TypeMetal_0|CircleDef_540_38_20_TypeKiller|CircleDef_485_38_20_TypeKiller|RevJoint_485_38|RevJoint_540_38|RectDef_350_86_500.3633983573119_17.676809223443684_TypeBrick_-5| RectShape_10_50_0|");
addLevel("PlayerDef_324_44|PolyDef_385_445_TypeWood_-5,0_0,-40_40,-45_40,-55_0,-60_-5,-100_-15,-100_-20,-60_-60,-55_-60,-45_-20,-40_-15,0|PolyDef_270_445_TypeWood_-5,0_0,-40_40,-45_40,-55_0,-60_-5,-100_-15,-100_-20,-60_-60,-55_-60,-45_-20,-40_-15,0|RectDef_318_393_135_45_TypeWood_0|Motor_375_395_0.4|Motor_260_395_-0.4|RectDef_315_458_230_25_TypeBrick_0|RectDef_420_416_20_20_TypeBrick_0|RectDef_220_375_40_20.000000000000004_TypeBrick_0|RectDef_440_245_20_450_TypeWood_0|RectDef_420_350_20_20_TypeBrick_0|RectDef_220_320_40_20.000000000000004_TypeBrick_0|RectDef_420_295_20_20_TypeBrick_0|RectDef_220_260_40_20.000000000000004_TypeBrick_0|RectDef_420_235_20_20_TypeBrick_0|RectDef_220_200_40_20.000000000000004_TypeBrick_0|RectDef_190_245_20_450_TypeWood_0|RevJoint_440_455|RevJoint_440_30|RevJoint_190_30|RevJoint_190_455|RectDef_293_80_28_12.000000000000002_TypeBrick_0|RectDef_358_79_28_12.000000000000002_TypeBrick_0| RectShape_75_20_0|RectShape_75_20_0|RectShape_14_62_0|");
addLevel("PlayerDef_590_375|RectDef_258_253_5_145_TypeWood_0|RevJoint_258_324|RectDef_283_253_5_145_TypeWood_0|RevJoint_283_324|RectDef_308_253_5_145_TypeWood_0|RevJoint_308_324|RectDef_333_253_5_145_TypeWood_0|RevJoint_333_324|RectDef_358_253_5_145_TypeWood_0|RevJoint_358_324|RectDef_383_253_5_145_TypeWood_0|RevJoint_383_324|CircleDef_620_315_20_TypeRubber|RevJoint_620_315|RectDef_408_253_5_145_TypeWood_0|RevJoint_408_324|RectDef_433_253_5_145_TypeWood_0|RevJoint_433_324|RectDef_458_253_5_145_TypeWood_0|RevJoint_458_324|RectDef_483_253_5_145_TypeWood_0|RevJoint_483_324|RectDef_508_253_5_145_TypeWood_0|RevJoint_508_324|CircleDef_40_100_15_TypeWood|PolyDef_45_115_TypeBrick_0,0_10,15_65,50_170,70_170,90_70,80_0,40_-15,0|CircleDef_590_430_25_TypeBrick| CircleShape_10|CircleShape_5|");
addLevel("PlayerDef_573_162|CircleDef_275_265_60_TypeWood|Motor_275_265_-0.3|RectDef_500_210_226_10.000000000000014_TypeBrick_0|PolyDef_339_197_TypeWood_0,0_160,-5_160,6_1,8|PolyDef_341_246_TypeWood_0,0_-2,-50_10,-50_6,3|RevJoint_345_201|RectDef_297_129_252_14.000000000000016_TypeKiller_0|RevJoint_182_130|RevJoint_413_129|PolyDef_529_132_TypeWood_-4,26_-1,61_74,60_83,-4_89,-4_82,73_-11,72_-10,26| RectShape_8_64_0|RectShape_51_10_0|RectShape_8_64_0|RectShape_5_90_0|");
addLevel("PlayerDef_520_416|RectDef_438_319_236_10.000000000000014_TypeBrick_0|RectDef_368_76_69_65_TypeWood_0|RectDef_368_141_69_65_TypeWood_0|RectDef_368_206_69_65_TypeWood_0|RectDef_433_245_103_14_TypeBrick_0|RectDef_341_276_10_76_TypeWood_0|PolyDef_128_218_TypeBrick_-28,3_9,31_47,53_85,71_164,89_205,96_204,107_59,71_-30,14_-34,5|CircleDef_154_57_12_TypeKiller|PolyDef_412_239_TypeBrick_0,0_68,-7_112,-26_142,-58_164,-113_192,-131_220,-136_186,13_20,15|CircleDef_611_76_30_TypeWood|DistJointDef_469_152_342_248_597_56|DistJointDef_479_201_342_307_616_96|RectDef_156_76_29.014283515275785_12.5766192633472_TypeBrick_-5|PolyDef_20_205_TypeBrick_0,0_5,35_22,83_63,129_131,166_244,182_365,185_452,182_453,195_275,195_118,179_36,133_1,75_-13,-4|RectDef_505_449_92_8.000000000000005_TypeWood_0|RectDef_432_481_186_56.000000000000014_TypeBrick_0| RectShape_10_72_-30|RectShape_10_93_0|");
addLevel("PlayerDef_617_225|RectDef_83_323_408_18.000000000000025_TypeBrick_0|RevJoint_52_288|Motor_-47_269_-0.6|PolyDef_61_314_TypeBrick_0,0_70,-8_113,-30_153,-5_215,-42_284,-70_286,18_25,37|PolyDef_-79_201_TypeWood_0,0_7,-4_13,0_23,34_105,32_105,-15_101,-20_102,-28_116,-28_117,-20_112,-15_113,32_134,33_143,41_138,97_116,83_3,81|CircleDef_52_289_25_TypeWood|CircleDef_-48_270_45_TypeWood|ChainDef_345_246_541_247|PolyDef_538_338_TypeBrick_0,0_2,-93_51,-83_109,-84_111,0|PolyDef_398_353_TypeKiller_17,36_-9,-72_30,-19_49,-72_65,-13_103,-74_81,22_50,186|RevJoint_425_367|RevJoint_448_503|PolyDef_22_431_TypeKiller_-37,-6_50,-21_108,12_161,-53_205,-5_285,-40_349,-10_448,-46_568,-23_631,-62_635,-29_631,-12_628,74_367,95_-37,60|RevJoint_-9_434|RevJoint_650_386|RevJoint_464_367|RevJoint_345_263|RevJoint_91_350|PolyDef_550_278_TypeKiller_0,0_12,-43_25,2|RevJoint_562_256|RevJoint_345_328|PolyDef_83_346_TypeWood_0,0_259,-20_257,-90_269,-94_278,-87_276,0_8,16|PolyDef_524_256_TypeWood_0,0_20,-3_18,77_112,77_115,93_3,92|RevJoint_541_271|RevJoint_631_337| CircleShape_34|RectShape_142_8.000000000000009_0|");
addLevel("PlayerDef_139_108|RectDef_470_38_100_5_TypeWood_0|RectDef_533_183_44_14.000000000000004_TypeRubber_0|RectDef_435_390_380_10.000000000000025_TypeBrick_0|RevJoint_137_475|RevJoint_550_185|RectDef_90_422_110_74_TypeBrick_0|RectDef_208_426_108_54.00000000000001_TypeBrick_0|RectDef_150_473_44_14.000000000000004_TypeRubber_0|RevJoint_162_475|RevJoint_520_185|RectDef_135_142_8_10_TypeBrick_0| CircleShape_35|");
addLevel("PlayerDef_322_69|RectDef_319_111_148_22.00000000000001_TypeBrick_0|CircleDef_327_282_103_TypeWood|Motor_328_285_0.2| RectShape_144_12.000000000000009_0|RectShape_144_12.000000000000009_90|");
addLevel("PlayerDef_565_140|RectDef_565_180_40_30_TypeBrick_0|RectDef_195_79_504_18.000000000000032_TypeBrick_0|RectDef_232_359_423_16_TypeBrick_0|RectDef_232_330_392_40.00000000000002_TypeWood_0|RectDef_436_343_14_32_TypeBrick_0|RectDef_27_338_14_32_TypeBrick_0|RectDef_66_96_80_10.000000000000005_TypeWood_0|RectDef_66_61_80_10.000000000000005_TypeWood_0|DistJointDef_101_79_100_97_102_61|DistJointDef_31_79_31_95_32_64|DistJointDef_66_78.5_30_95_102_62|DistJointDef_63_80_95_97_32_63|RectDef_67_161_116_22.000000000000007_TypeWood_0|ChainDef_98_96_121_156|ChainDef_36_97_15_155|PolyDef_20_156_TypeWood_11,0_41,5_48,-25_58,-23_52,7_79,14_80,25_51,20_45,48_34,47_39,17_10,11|Motor_65_168_-0.5|CircleDef_122_169_9_TypeWood|CircleDef_14_168_9_TypeWood|RevJoint_122_169|RevJoint_14_168|CircleDef_103_61_9_TypeWood|RevJoint_103_61|CircleDef_31_62_9_TypeWood|RevJoint_31_62|CircleDef_199_124_15_TypeWood|DistJointDef_157_143_202_133_113_154|DistJointDef_148_110_197_124_99_97|DistJointDef_157_140_116_156_198_125|DistJointDef_117_109_36_95_199_123| RectShape_7_146_0|RectShape_7_146_0|RectShape_7_146_0|RectShape_7_146_0|RectShape_7_146_0|RectShape_7_146_0|");
addLevel("PlayerDef_457_351|CircleDef_352_186_60_TypeWood|Motor_352_186_-0.4|RectDef_249_389_312_14.00000000000002_TypeWood_0|CircleDef_354_230_23_TypeWood|RevJoint_355_214|DistJointDef_377_320_354_252_400_388|RectDef_214_406_340_16.00000000000002_TypeBrick_0|RectDef_418_188_36_19_TypeWood_0|RevJoint_405_192|RevJoint_405_182|RectDef_485_165_144_24.000000000000007_TypeWood_0|RevJoint_492_172|RectDef_292_71_265_12_TypeBrick_5|RevJoint_524_172|RevJoint_421_171|CircleDef_168_42_10_TypeKiller|CircleDef_99_262_43_TypeWood|DistJointDef_227_325_393_387_62_263|RevJoint_101_264|RectDef_447_387_80_14.000000000000005_TypeBrick_0|CircleDef_99_389_9_TypeWood|RevJoint_99_389| CircleShape_33|");
addLevel("PlayerDef_335_110|RectDef_335_155_10_30_TypeBrick_0|RevJoint_335_290|CircleDef_335_290_10_TypeWood|RectDef_338_330_225_10_TypeWood_0|RevJoint_230_330|RevJoint_445_330|PolyDef_-100_615_TypeKiller_0,0_-3,-145_9,-240_38,-259_76,-256_78,-243_39,-242_20,-228_11,-142_17,-2_89,11_98,43_-56,48_-47,10|CircleDef_-130_655_28_TypeKiller|CircleDef_-29_655_28_TypeKiller|Motor_-29_654_-0.8|Motor_-131_655_-0.8|RectDef_361_700_1114_32.00000000000007_TypeBrick_0| CircleShape_50|RectShape_216_10.000000000000012_0|RectShape_12_96_0|");
addLevel("PlayerDef_235_375|DistJointDef_180_162.5_180_125_180_200|DistJointDef_245_162.5_245_125_245_200|CircleDef_450_70_15_TypeWood|RectDef_360_275_110_10_TypeBrick_0|DistJointDef_440_297_440_260_440_335|DistJointDef_520_297_520_260_520_335|CircleDef_215_415_10_TypeMetal|CircleDef_260_415_10_TypeMetal|RectDef_235_435_60_20_TypeBrick_0|RectDef_213_125_105_10_TypeWood_0|RectDef_483_260_105_10_TypeWood_0|PolyDef_345_270_TypeKiller_0,0_-10,-25_0,-15_10,-35_15,-15_30,-30_20,0|CircleDef_530_70_15_TypeWood|DistJointDef_490_70_450_70_530_70|CircleDef_490_70_15_TypeKiller|PolyDef_270_120_TypeBrick_0,0_45,0_165,-35_390,-35_390,-25_170,-25_90,0_390,0_390,10_0,10| RectShape_10_50_0|RectShape_10_50_0|RectShape_10_50_0|");
addLevel("PlayerDef_405_395|RectDef_224_215_230.6210149407715_10.674617917680187_TypeBrick_15|RectDef_315_228_105_10_TypeWood_15|RectDef_160_186_214_10.000000000000012_TypeBrick_15|RectDef_353_314_9.723629485606562_56.43980004949205_TypeBrick_-15|RectDef_405_340_100_10_TypeBrick_0|CircleDef_405_440_15_TypeBrick|RectDef_355_130_230_10_TypeBrick_-5|CircleDef_350_70_55_TypeWood|CircleDef_335_40_15_TypeWood|CircleDef_310_65_15_TypeWood|CircleDef_385_70_15_TypeWood|CircleDef_355_90_15_TypeWood|RevJoint_355_90|RevJoint_385_70|RevJoint_310_65|RevJoint_335_40|RevJoint_380_45|RevJoint_315_100|CircleDef_105_110_15_TypeKiller|CircleDef_105_80_10_TypeWood|DistJointDef_105_95_105_80_105_110|CircleDef_425_80_15_TypeKiller|CircleDef_425_50_10_TypeWood|DistJointDef_425_65_425_50_425_80|RevJoint_105_80|RevJoint_425_50|CircleDef_465_195_15_TypeKiller|CircleDef_465_165_10_TypeWood|DistJointDef_465_180_465_165_465_195|RevJoint_465_165|CircleDef_85_310_15_TypeKiller|CircleDef_85_280_10_TypeWood|DistJointDef_85_295_85_280_85_310|RevJoint_85_280|CircleDef_200_400_15_TypeKiller|CircleDef_200_370_10_TypeWood|DistJointDef_200_385_200_370_200_400|RevJoint_200_370| RectShape_130_10_0|RectShape_130_10_0|RectShape_10_85_30|");
var _local3:Array = SaveData.getInstance().completedLevels;
_local1 = 0;
while (_local1 < _local3.length) {
_local4 = _local3[_local1];
_local2 = levels[_local1];
if (((_local2) && (_local4))){
_local2.isOpen = _local4.isOpen;
_local2.isCompleted = _local4.isCompleted;
_local2.score = _local4.score;
};
_local1++;
};
engine.addEventListener(CoreEngine.LEVEL_COMPLETE, levelCompleteHandler);
}
public function getTotalScore():int{
var _local3:CoreLevel;
var _local1:int;
var _local2:int;
while (_local2 < levels.length) {
_local3 = levels[_local2];
_local1 = (_local1 + _local3.score);
_local2++;
};
return (_local1);
}
private function gameCompleteCallback():void{
var _local1:LevelMediator = (facade.retrieveMediator(LevelMediator.NAME) as LevelMediator);
_local1.destroy();
levelAbort();
notesProxy.push(AppProxy.GAME_COMPLETE);
}
}
}//package game.model
Section 237
//NotDopplerScores (game.model.NotDopplerScores)
package game.model {
import flash.display.*;
import flash.system.*;
import flash.net.*;
public class NotDopplerScores {
private var container:Sprite;
private var readytoSend:Boolean;// = false
private var widgetHeight:Number;// = 61
private var viewURL:String;// = ""
private var score:Number;
private var connected:Boolean;// = false
private var widgetWidth:Number;// = 522
private var view:Number;
private var game:String;// = "wakebox2"
private var AS3_lc:LocalConnection;
private var connectionID:Number;// = 1
public function NotDopplerScores(_arg1:Sprite, _arg2:Number=1):void{
this.container = _arg1;
this.view = _arg2;
init();
}
public function as2Ready():void{
trace("AS2 Ready");
readytoSend = true;
AS3_lc.send(("_AS3toAS2_" + connectionID), "communicateData", game, score, view, viewURL, ((("fl3m_uP_Ebri8zi8#" + game) + score) + "2I2RI3tH6ahl?"));
}
private function resendData():void{
if (readytoSend){
as2Ready();
};
}
public function hide():void{
container.visible = false;
}
public function init():void{
container.visible = false;
}
private function secondFrame():void{
Security.allowInsecureDomain("*");
Security.allowDomain("*");
var loader:Loader = new Loader();
loader.load(new URLRequest("http://www.notdoppler.com/highscores/highscores.swf"));
container.addChild(loader);
AS3_lc = new LocalConnection();
AS3_lc.allowDomain("*");
AS3_lc.allowInsecureDomain("*");
while (((!(connected)) && ((connectionID < 5)))) {
try {
AS3_lc.connect(("_AS2toAS3_" + connectionID));
connected = true;
} catch(error:ArgumentError) {
trace((("AS3: Connection No:" + connectionID) + " is already in use!"));
connectionID = (connectionID + 1);
};
};
AS3_lc.client = this;
}
public function loadHighscores(_arg1:Number):void{
score = _arg1;
container.visible = true;
secondFrame();
resendData();
}
}
}//package game.model
Section 238
//NotesProxy (game.model.NotesProxy)
package game.model {
import org.puremvc.as3.interfaces.*;
import org.puremvc.as3.patterns.proxy.*;
public class NotesProxy extends Proxy implements IProxy {
private var notes:Array;
public static const NAME:String = "NotesProxy";
public function NotesProxy():void{
super(NAME);
init();
}
private function init():void{
notes = [];
}
private function sendNote():void{
var _local1:Object = notes[0];
trace("note!", _local1.name);
sendNotification(_local1.name, _local1.body);
sendNoteComplete();
}
public function push(_arg1:String, _arg2:Object=null):void{
var _local3:Object = {name:_arg1, body:_arg2};
notes.push(_local3);
if (notes.length == 1){
sendNote();
};
}
private function sendNoteComplete():void{
notes.splice(0, 1);
if (notes.length > 0){
sendNote();
};
}
}
}//package game.model
Section 239
//SaveData (game.model.SaveData)
package game.model {
import core.*;
import flash.net.*;
public class SaveData {
private var sharedObject:SharedObject;
public var isNewGame:Boolean;
public var soundEnabled:Boolean;
public var completedLevels:Array;
public var musicEnabled:Boolean;
private var levelsNum:int;
private var version:String;// = "1.03"
private static var instance:SaveData;
public function clearProgress():void{
completedLevels = null;
sharedObject.data.completedLevels = null;
isNewGame = true;
sharedObject.data.isNewGame = isNewGame;
initProgress();
}
private function loadProgress():void{
var _local1:int;
var _local2:Object;
completedLevels = new Array(levelsNum);
_local1 = 0;
while (_local1 < sharedObject.data.completedLevels.length) {
_local2 = sharedObject.data.completedLevels[_local1];
if (_local2){
completedLevels[_local1] = {isCompleted:_local2.isCompleted, isOpen:_local2.isOpen, score:_local2.score};
};
_local1++;
};
if (sharedObject.data.isNewGame != null){
isNewGame = sharedObject.data.isNewGame;
};
}
private function initProgress():void{
var _local1:int;
var _local2:Object;
completedLevels = new Array(levelsNum);
_local1 = 0;
while (_local1 < levelsNum) {
_local2 = {isCompleted:false, isOpen:false, score:0};
if (_local1 == 0){
_local2.isOpen = true;
};
completedLevels[_local1] = _local2;
sharedObject.data.completedLevels = completedLevels;
_local1++;
};
sharedObject.flush();
}
public function levelComplete(_arg1:CoreLevel):void{
var _local2:Object = {isCompleted:true, isOpen:true, score:_arg1.score};
completedLevels[_arg1.id] = _local2;
sharedObject.data.completedLevels[_arg1.id] = completedLevels[_arg1.id];
if (_arg1.id < (levelsNum - 1)){
completedLevels[(_arg1.id + 1)].isOpen = true;
sharedObject.data.completedLevels[(_arg1.id + 1)].isOpen = true;
};
isNewGame = false;
sharedObject.data.isNewGame = isNewGame;
sharedObject.flush();
}
public function initialize():void{
levelsNum = 30;
sharedObject = SharedObject.getLocal("gameData");
isNewGame = true;
musicEnabled = true;
soundEnabled = true;
if (sharedObject.data.version == version){
loadProgress();
} else {
sharedObject.data.version = version;
initProgress();
};
}
public static function getInstance():SaveData{
if (instance == null){
instance = new (SaveData);
};
return (instance);
}
}
}//package game.model
Section 240
//LevelItem (game.view.components.levelSelect.LevelItem)
package game.view.components.levelSelect {
import flash.events.*;
import game.view.components.*;
import game.model.*;
import flash.display.*;
import flash.text.*;
public class LevelItem extends Sprite {
public var level:GameLevel;
private var back:Sprite;
private var num_tf:TextField;
private var underline:Sprite;
private var backInner:MovieClip;
private var window:Sprite;
private var activeArea:Sprite;
private var complete:Sprite;
private var score_tf:TextField;
public static const ROLL_OVER:String = "RollOver";
public static const MOUSE_MOVE:String = "MouseMove";
public static const ROLL_OUT:String = "RollOut";
public function LevelItem(_arg1:GameLevel):void{
this.level = _arg1;
init();
}
private function clickHandler(_arg1:MouseEvent):void{
Fader.getInstance().fade(startLevel);
}
private function startLevel():void{
var _local1:ApplicationFacade = ApplicationFacade.getInstance();
var _local2:NotesProxy = (_local1.retrieveProxy(NotesProxy.NAME) as NotesProxy);
_local2.push(GameProxy.LEVEL_START, level.id);
}
private function rollOverHandler(_arg1:MouseEvent):void{
underline.visible = true;
dispatchEvent(new Event(ROLL_OVER));
}
private function mouseMoveHandler(_arg1:MouseEvent):void{
dispatchEvent(new Event(MOUSE_MOVE));
}
private function init():void{
var _local1:Class = GameAssets.getInstance().getAssetClass("LevelItemAsset");
window = new (_local1);
addChild(window);
back = (window.getChildByName("back") as Sprite);
score_tf = (window.getChildByName("score_tf") as TextField);
num_tf = (window.getChildByName("num_tf") as TextField);
activeArea = (back.getChildByName("activeArea") as Sprite);
underline = (back.getChildByName("underline") as Sprite);
complete = (back.getChildByName("complete") as Sprite);
backInner = (back.getChildByName("backInner") as MovieClip);
num_tf.mouseEnabled = false;
score_tf.mouseEnabled = false;
num_tf.text = (level.id + 1).toString();
underline.visible = false;
complete.visible = false;
var _local2:Number = (1 + Math.floor((Math.random() * backInner.totalFrames)));
backInner.gotoAndStop(_local2);
if (level.isOpen){
if (level.isCompleted){
complete.visible = true;
score_tf.text = level.score.toString();
} else {
score_tf.visible = false;
};
activeArea.buttonMode = true;
activeArea.addEventListener(MouseEvent.ROLL_OVER, rollOverHandler);
activeArea.addEventListener(MouseEvent.ROLL_OUT, rollOutHandler);
activeArea.addEventListener(MouseEvent.CLICK, clickHandler);
activeArea.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
} else {
score_tf.visible = false;
num_tf.alpha = 0.3;
};
}
private function rollOutHandler(_arg1:MouseEvent):void{
underline.visible = false;
dispatchEvent(new Event(ROLL_OUT));
}
}
}//package game.view.components.levelSelect
Section 241
//LevelPreview (game.view.components.levelSelect.LevelPreview)
package game.view.components.levelSelect {
import flash.events.*;
import editor.model.*;
import core.*;
import game.model.*;
import flash.display.*;
import core.objects.*;
import core.shapes.*;
import editor.model.objects.*;
import flash.text.*;
import caurina.transitions.*;
public class LevelPreview extends EventDispatcher {
public var container:Sprite;
private var assets:EditorAssets;
private var levelName_tf:TextField;
private var objectsContainer:Sprite;
private var levelCuts_tf:TextField;
private var scoreHolder:Sprite;
private var levelScore_tf:TextField;
private var playerContainer:Sprite;
private var holder:Sprite;
private var window:Sprite;
private var closed:Sprite;
private var holderMask:Sprite;
private var jointsContainer:Sprite;
public function LevelPreview(_arg1:Sprite):void{
this.window = _arg1;
init();
}
private function createDistJoint(_arg1:DistJointDef):void{
var _local2:Class = CoreAssets.getInstance().getAssetClass(DistanceJoint.SKIN_CLASS_NAME);
var _local3:Sprite = new (_local2);
var _local4:Sprite = (_local3.getChildByName("vertex1") as Sprite);
var _local5:Sprite = (_local3.getChildByName("vertex2") as Sprite);
var _local6:Sprite = (_local3.getChildByName("container") as Sprite);
var _local7:Class = CoreAssets.getInstance().getAssetClass("DistJointLineAsset");
var _local8:BitmapData = new _local7(0, 0);
var _local9:Number = Math.sqrt((((_arg1.x2 - _arg1.x1) * (_arg1.x2 - _arg1.x1)) + ((_arg1.y2 - _arg1.y1) * (_arg1.y2 - _arg1.y1))));
_local6.graphics.clear();
_local6.graphics.beginBitmapFill(_local8, null, true, true);
_local6.graphics.drawRect(0, -2, _local9, 2);
_local6.graphics.endFill();
var _local10:Number = Math.atan2((_arg1.y2 - _arg1.y1), (_arg1.x2 - _arg1.x1));
_local6.x = _arg1.x1;
_local6.y = _arg1.y1;
_local6.rotation = ((_local10 * 180) / Math.PI);
_local4.x = _arg1.x1;
_local4.y = _arg1.y1;
_local5.x = _arg1.x2;
_local5.y = _arg1.y2;
jointsContainer.addChild(_local3);
}
private function createPlayer(_arg1:PlayerDef):void{
var _local2:Class = EditorAssets.getInstance().getAssetClass("PlayerAsset");
var _local3:Sprite = new (_local2);
_local3.x = _arg1.x;
_local3.y = _arg1.y;
playerContainer.addChild(_local3);
}
private function createHinge(_arg1:RevJointDef):void{
var _local2:Class = CoreAssets.getInstance().getAssetClass(Hinge.SKIN_CLASS_NAME);
if ((_arg1 is MotorDef)){
_local2 = CoreAssets.getInstance().getAssetClass(Motor.SKIN_CLASS_NAME);
};
var _local3:Sprite = new (_local2);
_local3.x = _arg1.x;
_local3.y = _arg1.y;
jointsContainer.addChild(_local3);
}
private function init():void{
assets = EditorAssets.getInstance();
closed = (window.getChildByName("closed") as Sprite);
holder = (window.getChildByName("holder") as Sprite);
holderMask = (window.getChildByName("holderMask") as Sprite);
holder.mask = holderMask;
container = new Sprite();
holder.addChild(container);
window.mouseEnabled = false;
window.mouseChildren = false;
window.alpha = 0;
}
public function hide():void{
Tweener.addTween(window, {alpha:0, time:0.2, transition:"linear"});
}
public function updatePos(_arg1:Number, _arg2:Number):void{
if ((_arg2 + 240) < 480){
window.y = _arg2;
} else {
window.y = (_arg2 - 240);
};
if ((_arg1 + 320) < 640){
window.x = _arg1;
} else {
window.x = (_arg1 - 320);
};
}
public function update(_arg1:GameLevel, _arg2:Number, _arg3:Number):void{
var _local4:uint;
var _local5:BaseObjectDef;
show();
updatePos(_arg2, _arg3);
container.parent.removeChild(container);
container = new Sprite();
container.scaleX = (container.scaleY = 0.5);
holder.addChild(container);
objectsContainer = new Sprite();
container.addChild(objectsContainer);
playerContainer = new Sprite();
container.addChild(playerContainer);
jointsContainer = new Sprite();
container.addChild(jointsContainer);
var _local6:Array = _arg1.def.split(" ");
var _local7:String = _local6[0];
parseObjects(_local7);
}
private function createChain(_arg1:ChainDef):void{
var _local2:Sprite = new Sprite();
_local2.graphics.clear();
_local2.graphics.lineStyle(4, 0x999999);
_local2.graphics.moveTo(_arg1.x, _arg1.y);
_local2.graphics.lineTo(_arg1.x2, _arg1.y2);
jointsContainer.addChild(_local2);
}
private function parseObjects(_arg1:String):void{
var _local3:int;
var _local4:BaseObjectDef;
var _local2:Array = _arg1.split("|");
_local3 = 0;
while (_local3 < _local2.length) {
_local4 = LevelStringParser.parseObjectDef(_local2[_local3]);
if ((_local4 is PlayerDef)){
createPlayer((_local4 as PlayerDef));
} else {
if ((_local4 is CircleDef)){
createCircle((_local4 as CircleDef));
} else {
if ((_local4 is PolyDef)){
createPoly((_local4 as PolyDef));
} else {
if ((_local4 is RevJointDef)){
createHinge((_local4 as RevJointDef));
} else {
if ((_local4 is DistJointDef)){
createDistJoint((_local4 as DistJointDef));
} else {
if ((_local4 is ChainDef)){
createChain((_local4 as ChainDef));
};
};
};
};
};
};
_local3++;
};
}
private function createPoly(_arg1:PolyDef):void{
var _local2:Sprite = new Sprite();
var _local3:PolyShape = new PolyShape(_arg1.vertices);
var _local4:BodyMaterial = new BodyMaterial(_arg1.type);
_local3.draw(_local2, _local4);
_local2.x = _arg1.x;
_local2.y = _arg1.y;
objectsContainer.addChild(_local2);
}
private function createCircle(_arg1:CircleDef):void{
var _local2:Sprite = new Sprite();
var _local3:CircleShape = new CircleShape(_arg1.r);
var _local4:BodyMaterial = new BodyMaterial(_arg1.type);
_local3.draw(_local2, _local4);
_local2.x = _arg1.x;
_local2.y = _arg1.y;
objectsContainer.addChild(_local2);
}
private function show():void{
Tweener.addTween(window, {alpha:1, time:0.2, transition:"linear"});
}
}
}//package game.view.components.levelSelect
Section 242
//AppView (game.view.components.AppView)
package game.view.components {
import game.model.*;
import flash.display.*;
public class AppView extends Sprite {
public var container:Sprite;
public var music:MovieClip;
public var logo_bt:Sprite;
public var sound:MovieClip;
private var window:Sprite;
public var popupContainer:Sprite;
public var splashContainer:Sprite;
public function AppView(){
init();
}
private function init():void{
var _local1:Class = GameAssets.getInstance().getAssetClass("AppWindow");
window = new (_local1);
addChild(window);
container = (window.getChildByName("container") as Sprite);
popupContainer = (window.getChildByName("popupContainer") as Sprite);
splashContainer = (window.getChildByName("splashContainer") as Sprite);
sound = (window.getChildByName("sound") as MovieClip);
music = (window.getChildByName("music") as MovieClip);
logo_bt = (window.getChildByName("logo_bt") as Sprite);
}
}
}//package game.view.components
Section 243
//CreditsView (game.view.components.CreditsView)
package game.view.components {
import game.model.*;
import flash.display.*;
public class CreditsView extends Sprite {
public var nayhan_bt:SimpleButton;
public var egoshin_bt:SimpleButton;
private var window:Sprite;
public var ok_bt:SimpleButton;
public var inner:Sprite;
public var sponsor_bt:SimpleButton;
public var box2d_bt:SimpleButton;
public var karataev_bt:SimpleButton;
public function CreditsView():void{
init();
}
private function init():void{
var _local1:Class = GameAssets.getInstance().getAssetClass("CreditsWindow");
window = new (_local1);
addChild(window);
inner = (window.getChildByName("inner") as Sprite);
ok_bt = (inner.getChildByName("ok_bt") as SimpleButton);
karataev_bt = (inner.getChildByName("karataev_bt") as SimpleButton);
egoshin_bt = (inner.getChildByName("egoshin_bt") as SimpleButton);
sponsor_bt = (inner.getChildByName("sponsor_bt") as SimpleButton);
box2d_bt = (inner.getChildByName("box2d_bt") as SimpleButton);
nayhan_bt = (inner.getChildByName("nayhan_bt") as SimpleButton);
}
}
}//package game.view.components
Section 244
//Fader (game.view.components.Fader)
package game.view.components {
import game.model.*;
import flash.display.*;
import game.view.*;
import caurina.transitions.*;
public class Fader {
private var window:Sprite;
private var callbackFunc:Function;
private static var instance:Fader;
public function Fader():void{
init();
}
private function init():void{
var _local1:Class = GameAssets.getInstance().getAssetClass("FaderWindow");
window = new (_local1);
var _local2:ApplicationFacade = ApplicationFacade.getInstance();
var _local3:AppMediator = (_local2.retrieveMediator(AppMediator.NAME) as AppMediator);
_local3.getPopupContainer().addChild(window);
window.visible = false;
}
private function fadeInComplete():void{
Tweener.addTween(window, {alpha:0, time:0.3, transition:"linear", onComplete:fadeOutComplete});
callbackFunc();
}
private function fadeOutComplete():void{
window.visible = false;
}
public function fade(_arg1:Function):void{
this.callbackFunc = _arg1;
window.visible = true;
window.alpha = 0;
Tweener.addTween(window, {alpha:1, time:0.3, transition:"linear", onComplete:fadeInComplete});
}
public static function getInstance():Fader{
if (instance == null){
instance = new (Fader);
};
return (instance);
}
}
}//package game.view.components
Section 245
//GameCompleteView (game.view.components.GameCompleteView)
package game.view.components {
import game.model.*;
import flash.display.*;
import flash.text.*;
public class GameCompleteView extends Sprite {
public var ndHolder:Sprite;
public var totalScore_tf:TextField;
public var back:Sprite;
public var ican_bt:SimpleButton;
private var window:Sprite;
public var exit_bt:SimpleButton;
public var inner:Sprite;
public var sure_bt:SimpleButton;
public function GameCompleteView():void{
init();
}
private function init():void{
var _local1:Class = GameAssets.getInstance().getAssetClass("GameCompleteWindow");
window = new (_local1);
addChild(window);
back = (window.getChildByName("back") as Sprite);
inner = (window.getChildByName("inner") as Sprite);
totalScore_tf = (inner.getChildByName("totalScore_tf") as TextField);
exit_bt = (inner.getChildByName("exit_bt") as SimpleButton);
ndHolder = (inner.getChildByName("ndHolder") as Sprite);
ican_bt = (inner.getChildByName("ican_bt") as SimpleButton);
sure_bt = (inner.getChildByName("sure_bt") as SimpleButton);
}
}
}//package game.view.components
Section 246
//LevelCompleteView (game.view.components.LevelCompleteView)
package game.view.components {
import game.model.*;
import flash.display.*;
public class LevelCompleteView extends Sprite {
public var nextLevel_bt:SimpleButton;
public var restart_bt:SimpleButton;
public var moreGames_bt:SimpleButton;
public var back:Sprite;
public var levels_bt:SimpleButton;
private var window:Sprite;
public var inner:Sprite;
public function LevelCompleteView():void{
init();
}
private function init():void{
var _local1:Class = GameAssets.getInstance().getAssetClass("LevelCompleteWindow");
window = new (_local1);
addChild(window);
back = (window.getChildByName("back") as Sprite);
inner = (window.getChildByName("inner") as Sprite);
restart_bt = (inner.getChildByName("restart_bt") as SimpleButton);
levels_bt = (inner.getChildByName("levels_bt") as SimpleButton);
nextLevel_bt = (inner.getChildByName("nextLevel_bt") as SimpleButton);
moreGames_bt = (inner.getChildByName("moreGames_bt") as SimpleButton);
}
}
}//package game.view.components
Section 247
//LevelSelectView (game.view.components.LevelSelectView)
package game.view.components {
import game.model.*;
import flash.display.*;
import flash.text.*;
public class LevelSelectView extends Sprite {
public var itemsContainer:Sprite;
public var totalScore_tf:TextField;
public var preview:Sprite;
public var back_bt:SimpleButton;
public var scoresHolder:Sprite;
public var ndClose_bt:SimpleButton;
private var window:Sprite;
public var ndScoresContainer:Sprite;
public var submit_bt:SimpleButton;
public var ndScoresHolder:Sprite;
public function LevelSelectView():void{
init();
}
private function init():void{
var _local1:Class = GameAssets.getInstance().getAssetClass("LevelSelectWindow");
window = new (_local1);
addChild(window);
scoresHolder = (window.getChildByName("scoresHolder") as Sprite);
totalScore_tf = (scoresHolder.getChildByName("totalScore_tf") as TextField);
back_bt = (window.getChildByName("back_bt") as SimpleButton);
preview = (window.getChildByName("preview") as Sprite);
itemsContainer = (window.getChildByName("itemsContainer") as Sprite);
submit_bt = (window.getChildByName("submit_bt") as SimpleButton);
ndScoresHolder = (window.getChildByName("ndScoresHolder") as Sprite);
ndScoresContainer = (ndScoresHolder.getChildByName("container") as Sprite);
ndClose_bt = (ndScoresHolder.getChildByName("close_bt") as SimpleButton);
ndClose_bt.x = ((((640 - 522) / 2) + 522) - ndClose_bt.width);
ndClose_bt.y = ((((480 - 61) / 2) - ndClose_bt.height) - 5);
itemsContainer.x = 14;
itemsContainer.y = 100;
}
}
}//package game.view.components
Section 248
//LevelView (game.view.components.LevelView)
package game.view.components {
import game.model.*;
import flash.display.*;
public class LevelView extends Sprite {
public var levels_bt:SimpleButton;
public var coreBack:MovieClip;
public var coreContainer:Sprite;
private var window:Sprite;
public var restart_bt:SimpleButton;
public var exit_bt:SimpleButton;
public var walkthrough_bt:SimpleButton;
public var toEditor_bt:SimpleButton;
public var sponsor:Sprite;
public function LevelView():void{
init();
}
private function init():void{
var _local1:Class = GameAssets.getInstance().getAssetClass("LevelWindow");
window = new (_local1);
addChild(window);
coreContainer = (window.getChildByName("coreContainer") as Sprite);
coreBack = (coreContainer.getChildByName("back") as MovieClip);
exit_bt = (window.getChildByName("exit_bt") as SimpleButton);
restart_bt = (window.getChildByName("restart_bt") as SimpleButton);
levels_bt = (window.getChildByName("levels_bt") as SimpleButton);
walkthrough_bt = (window.getChildByName("walkthrough_bt") as SimpleButton);
toEditor_bt = (window.getChildByName("toEditor_bt") as SimpleButton);
sponsor = (window.getChildByName("sponsor") as Sprite);
}
}
}//package game.view.components
Section 249
//LogoView (game.view.components.LogoView)
package game.view.components {
import flash.events.*;
import game.model.*;
import flash.display.*;
import flash.net.*;
import game.view.*;
import caurina.transitions.*;
public class LogoView extends Sprite {
private var overEffect:Sprite;
private var showLogo:Boolean;
private var window:MovieClip;
public function LogoView():void{
init();
}
private function clickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(AppProxy.MOCHI_SPLASH_SCREEN));
}
private function efHandler(_arg1:Event):void{
if (window.currentFrame == window.totalFrames){
hideComplete();
};
}
private function addedHandler(_arg1:Event):void{
var _local2:Class = GameAssets.getInstance().getAssetClass("NotDopplerIntro");
window = new (_local2);
addChild(window);
overEffect = (window.getChildByName("overEffect") as Sprite);
showLogo = (Preloader.DEBUG) ? false : true;
addEventListener(Event.ENTER_FRAME, efHandler);
addEventListener(MouseEvent.ROLL_OVER, overEffectRollOverHandler);
addEventListener(MouseEvent.ROLL_OUT, overEffectRollOutHandler);
overEffect.alpha = 0;
buttonMode = true;
addEventListener(MouseEvent.CLICK, clickHandler);
if (!showLogo){
hideComplete();
};
}
private function overEffectRollOverHandler(_arg1:MouseEvent):void{
overEffect.alpha = 0.4;
Tweener.addTween(overEffect, {alpha:0.15, time:0.3, transition:"linear"});
}
private function init():void{
addEventListener(Event.ADDED_TO_STAGE, addedHandler);
}
private function destroy():void{
parent.removeChild(this);
}
private function hideComplete():void{
window.stop();
removeEventListener(Event.ENTER_FRAME, efHandler);
removeEventListener(MouseEvent.CLICK, clickHandler);
var _local1:ApplicationFacade = ApplicationFacade.getInstance();
var _local2:AppMediator = (_local1.retrieveMediator(AppMediator.NAME) as AppMediator);
_local2.logoViewComplete();
destroy();
}
private function overEffectRollOutHandler(_arg1:MouseEvent):void{
Tweener.removeTweens(overEffect);
overEffect.alpha = 0;
}
}
}//package game.view.components
Section 250
//MainMenuView (game.view.components.MainMenuView)
package game.view.components {
import game.model.*;
import flash.display.*;
import flash.text.*;
public class MainMenuView extends Sprite {
public var newGameConfirmNo_bt:SimpleButton;
public var startGame_bt:SimpleButton;
public var moreGames_bt:SimpleButton;
public var moreGamesHolder:Sprite;
public var newGameConfirmInner:Sprite;
public var highscores_bt:SimpleButton;
public var highscoresHolder:Sprite;
public var debug:MovieClip;
public var walkthrough_bt:SimpleButton;
public var clearProgress_bt:SimpleButton;
public var continueGame_bt:SimpleButton;
public var sponsor:Sprite;
public var editor_bt:SimpleButton;
public var wutb_bt:SimpleButton;
public var credits_bt:SimpleButton;
public var newGameConfirm:Sprite;
private var window:Sprite;
public var newGameConfirmYes_bt:SimpleButton;
public var version_tf:TextField;
public function MainMenuView():void{
init();
}
private function init():void{
var _local1:Class = GameAssets.getInstance().getAssetClass("MainMenuWindow");
window = new (_local1);
addChild(window);
startGame_bt = (window.getChildByName("startGame_bt") as SimpleButton);
clearProgress_bt = (window.getChildByName("clearProgress_bt") as SimpleButton);
continueGame_bt = (window.getChildByName("continue_bt") as SimpleButton);
credits_bt = (window.getChildByName("credits_bt") as SimpleButton);
highscoresHolder = (window.getChildByName("highscoresHolder") as Sprite);
highscores_bt = (highscoresHolder.getChildByName("highscores_bt") as SimpleButton);
moreGamesHolder = (window.getChildByName("moreGamesHolder") as Sprite);
moreGames_bt = (moreGamesHolder.getChildByName("moreGames_bt") as SimpleButton);
walkthrough_bt = (window.getChildByName("walkthrough_bt") as SimpleButton);
version_tf = (window.getChildByName("version_tf") as TextField);
sponsor = (window.getChildByName("sponsor_bt") as Sprite);
debug = (window.getChildByName("debug_mc") as MovieClip);
wutb_bt = (window.getChildByName("wutb_bt") as SimpleButton);
newGameConfirm = (window.getChildByName("newGameConfirm") as Sprite);
newGameConfirmInner = (newGameConfirm.getChildByName("inner") as Sprite);
newGameConfirmYes_bt = (newGameConfirmInner.getChildByName("yes_bt") as SimpleButton);
newGameConfirmNo_bt = (newGameConfirmInner.getChildByName("no_bt") as SimpleButton);
editor_bt = (window.getChildByName("editor_bt") as SimpleButton);
}
}
}//package game.view.components
Section 251
//AppMediator (game.view.AppMediator)
package game.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import game.model.*;
import flash.display.*;
import flash.media.*;
import flash.net.*;
import org.puremvc.as3.patterns.mediator.*;
import caurina.transitions.*;
import preloader.*;
public class AppMediator extends Mediator implements IMediator {
private var sndMainMusic:Sound;
private var _view:AppView;
private var saveData:SaveData;
private var musicChannel:SoundChannel;
private var musicVolume:Number;
private var levelCompleteChannel:SoundChannel;
private var sndLevelComplete:Sound;
public static const NAME:String = "AppMediator";
public function AppMediator(_arg1:AppView):void{
super(NAME, _arg1);
init();
}
public function logoViewComplete():void{
if (saveData.musicEnabled){
musicChannel = sndMainMusic.play(0, 10000, new SoundTransform(musicVolume));
};
}
private function init():void{
_view = (getViewComponent() as AppView);
_view.tabChildren = false;
saveData = SaveData.getInstance();
var _local1:Class = GameAssets.getInstance().getAssetClass("SndMusic");
sndMainMusic = new (_local1);
var _local2:Class = GameAssets.getInstance().getAssetClass("SndLevelComplete");
sndLevelComplete = new (_local2);
musicVolume = 0.7;
_view.sound.addEventListener(MouseEvent.CLICK, soundClickHandler);
_view.music.addEventListener(MouseEvent.CLICK, musicClickHandler);
_view.logo_bt.addEventListener(MouseEvent.CLICK, logoClickHandler);
_view.sound.buttonMode = true;
_view.music.buttonMode = true;
_view.sound.gotoAndStop(1);
_view.music.gotoAndStop(1);
var _local3:NotDopplerButton = new NotDopplerButton(_view.logo_bt, AppProxy.MOCHI_MAIN_MENU_SPONSOR_LOGO);
}
private function soundClickHandler(_arg1:MouseEvent):void{
if (saveData.soundEnabled){
saveData.soundEnabled = false;
_view.sound.gotoAndStop(2);
} else {
saveData.soundEnabled = true;
_view.sound.gotoAndStop(1);
};
}
private function levelAbort():void{
if (levelCompleteChannel){
Tweener.addTween(levelCompleteChannel, {_sound_volume:0, time:0.5});
};
Tweener.addTween(musicChannel, {_sound_volume:musicVolume, time:0.5});
}
private function levelComplete():void{
levelCompleteChannel = sndLevelComplete.play(0, 1, new SoundTransform(musicVolume));
Tweener.addTween(musicChannel, {_sound_volume:0, time:0.5});
}
override public function listNotificationInterests():Array{
return ([GameProxy.LEVEL_COMPLETE, GameProxy.LEVEL_START, GameProxy.LEVEL_ABORT]);
}
public function getSplashContainer():Sprite{
return (_view.splashContainer);
}
private function musicClickHandler(_arg1:MouseEvent):void{
if (saveData.musicEnabled){
saveData.musicEnabled = false;
_view.music.gotoAndStop(2);
musicVolume = 0;
Tweener.addTween(musicChannel, {_sound_volume:0, time:0.5});
} else {
saveData.musicEnabled = true;
_view.music.gotoAndStop(1);
musicVolume = 0.7;
Tweener.addTween(musicChannel, {_sound_volume:musicVolume, time:0.5});
};
}
public function getPopupContainer():Sprite{
return (_view.popupContainer);
}
public function getViewContainer():Sprite{
return (_view.container);
}
override public function handleNotification(_arg1:INotification):void{
switch (_arg1.getName()){
case GameProxy.LEVEL_COMPLETE:
levelComplete();
break;
case GameProxy.LEVEL_START:
levelStart();
break;
case GameProxy.LEVEL_ABORT:
levelAbort();
break;
};
}
private function logoClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(AppProxy.MOCHI_LEVEL_VIEW_SPONSOR_LOGO));
}
private function levelStart():void{
if (levelCompleteChannel){
Tweener.addTween(levelCompleteChannel, {_sound_volume:0, time:0.5});
};
Tweener.addTween(musicChannel, {_sound_volume:musicVolume, time:0.5});
}
}
}//package game.view
Section 252
//CreditsMediator (game.view.CreditsMediator)
package game.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import game.model.*;
import flash.net.*;
import org.puremvc.as3.patterns.mediator.*;
public class CreditsMediator extends Mediator implements IMediator {
private var _view:CreditsView;
public static const NAME:String = "CreditsMediator";
public function CreditsMediator(_arg1:CreditsView):void{
super(NAME, _arg1);
init();
}
override public function listNotificationInterests():Array{
return ([]);
}
override public function handleNotification(_arg1:INotification):void{
}
private function karataevClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("mailto:eugene.karataev@gmail.com"), "_blank");
}
private function egoshinClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("mailto:egoshin83@rambler.ru"), "_blank");
}
private function init():void{
_view = (getViewComponent() as CreditsView);
_view.karataev_bt.addEventListener(MouseEvent.CLICK, karataevClickHandler);
_view.egoshin_bt.addEventListener(MouseEvent.CLICK, egoshinClickHandler);
_view.sponsor_bt.addEventListener(MouseEvent.CLICK, sponsorClickHandler);
_view.box2d_bt.addEventListener(MouseEvent.CLICK, box2dClickHandler);
_view.ok_bt.addEventListener(MouseEvent.CLICK, okClickHandler);
_view.nayhan_bt.addEventListener(MouseEvent.CLICK, nayhanClickHandler);
}
private function nayhanClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://nayhan.newgrounds.com/"), "_blank");
}
private function destroy():void{
_view.parent.removeChild(_view);
facade.removeMediator(NAME);
}
private function sponsorClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(AppProxy.MOCHI_CREDITS_SPONSOR), "_blank");
}
private function okClickHandler(_arg1:MouseEvent):void{
destroy();
}
private function box2dClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://box2d.org"), "_blank");
}
}
}//package game.view
Section 253
//GameCompleteMediator (game.view.GameCompleteMediator)
package game.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import game.model.*;
import flash.net.*;
import org.puremvc.as3.patterns.mediator.*;
import caurina.transitions.*;
public class GameCompleteMediator extends Mediator implements IMediator {
private var _view:GameCompleteView;
private var notesProxy:NotesProxy;
private var gameProxy:GameProxy;
private var ndScores:NotDopplerScores;
public static const NAME:String = "GameCompleteMediator";
public function GameCompleteMediator(_arg1:GameCompleteView):void{
super(NAME, _arg1);
init();
}
private function exitClickHandler(_arg1:MouseEvent):void{
Fader.getInstance().fade(gameAbort);
}
public function destroy():void{
_view.parent.removeChild(_view);
facade.removeMediator(NAME);
}
override public function handleNotification(_arg1:INotification):void{
}
private function gameAbort():void{
notesProxy.push(AppProxy.GAME_ABORT);
}
override public function listNotificationInterests():Array{
return ([]);
}
private function icanClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("mailto:eugene.karataev@gmail.com"), "_blank");
}
private function init():void{
_view = (getViewComponent() as GameCompleteView);
notesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
gameProxy = (facade.retrieveProxy(GameProxy.NAME) as GameProxy);
_view.exit_bt.addEventListener(MouseEvent.CLICK, exitClickHandler);
_view.ican_bt.addEventListener(MouseEvent.CLICK, icanClickHandler);
_view.sure_bt.addEventListener(MouseEvent.CLICK, sureClickHandler);
_view.totalScore_tf.text = gameProxy.getTotalScore().toString();
ndScores = new NotDopplerScores(_view.ndHolder, 3);
ndScores.loadHighscores(gameProxy.getTotalScore());
var _local1:Number = _view.inner.y;
_view.inner.y = 480;
Tweener.addTween(_view.inner, {y:_local1, time:1, delay:0.5, transition:"easeoutback"});
}
private function sureClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(AppProxy.MOCHI_GAME_COMPLETE_MORE_GAMES), "_blank");
}
}
}//package game.view
Section 254
//LevelCompleteMediator (game.view.LevelCompleteMediator)
package game.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import core.*;
import game.model.*;
import flash.net.*;
import org.puremvc.as3.patterns.mediator.*;
import caurina.transitions.*;
public class LevelCompleteMediator extends Mediator implements IMediator {
private var _view:LevelCompleteView;
private var notesProxy:NotesProxy;
private var gameProxy:GameProxy;
public static const NAME:String = "LevelCompleteMediator";
public function LevelCompleteMediator(_arg1:LevelCompleteView):void{
super(NAME, _arg1);
init();
}
private function nextLevel():void{
notesProxy.push(GameProxy.LEVEL_ABORT);
var _local1:CoreLevel = gameProxy.levels[(gameProxy.currentLevel.id + 1)];
if (_local1){
notesProxy.push(GameProxy.LEVEL_START, _local1.id);
} else {
trace("GAME COMPLETE!");
};
}
public function destroy():void{
_view.parent.removeChild(_view);
facade.removeMediator(NAME);
}
private function nextLevelClickHandler(_arg1:MouseEvent):void{
SaveData.getInstance().levelComplete(gameProxy.currentLevel);
Fader.getInstance().fade(nextLevel);
}
override public function listNotificationInterests():Array{
return ([]);
}
override public function handleNotification(_arg1:INotification):void{
}
private function moreGamesClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(AppProxy.MOCHI_LEVEL_COMPLETE_MORE_GAMES));
}
private function init():void{
_view = (getViewComponent() as LevelCompleteView);
notesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
gameProxy = (facade.retrieveProxy(GameProxy.NAME) as GameProxy);
_view.restart_bt.addEventListener(MouseEvent.CLICK, restartClickHandler);
_view.levels_bt.addEventListener(MouseEvent.CLICK, levelsClickHandler);
_view.nextLevel_bt.addEventListener(MouseEvent.CLICK, nextLevelClickHandler);
_view.moreGames_bt.addEventListener(MouseEvent.CLICK, moreGamesClickHandler);
_view.back.alpha = 0;
Tweener.addTween(_view.back, {alpha:1, time:1, transition:"linear"});
var _local1:Number = _view.inner.y;
_view.inner.y = -(_view.inner.height);
Tweener.addTween(_view.inner, {y:_local1, time:1, delay:0.5, transition:"easeoutback"});
}
private function restartClickHandler(_arg1:MouseEvent):void{
Fader.getInstance().fade(restartLevel);
}
private function abortLevel():void{
notesProxy.push(GameProxy.LEVEL_ABORT);
}
private function restartLevel():void{
notesProxy.push(GameProxy.LEVEL_ABORT);
notesProxy.push(GameProxy.LEVEL_START, gameProxy.currentLevel.id);
}
private function levelsClickHandler(_arg1:MouseEvent):void{
Fader.getInstance().fade(abortLevel);
}
}
}//package game.view
Section 255
//LevelMediator (game.view.LevelMediator)
package game.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import editor.model.*;
import game.model.*;
import flash.net.*;
import org.puremvc.as3.patterns.mediator.*;
import caurina.transitions.*;
import flash.ui.*;
public class LevelMediator extends Mediator implements IMediator {
private var _view:LevelView;
private var notesProxy:NotesProxy;
public static const NAME:String = "LevelMediator";
public function LevelMediator(_arg1:LevelView):void{
super(NAME, _arg1);
init();
}
private function exitClickHandler(_arg1:MouseEvent):void{
Fader.getInstance().fade(abortGame);
}
public function destroy():void{
_view.exit_bt.removeEventListener(MouseEvent.CLICK, exitClickHandler);
_view.stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
_view.parent.removeChild(_view);
facade.retrieveMediator(NAME);
}
private function abortGame():void{
notesProxy.push(GameProxy.LEVEL_ABORT);
notesProxy.push(AppProxy.GAME_ABORT);
}
override public function listNotificationInterests():Array{
return ([GameProxy.LEVEL_COMPLETE]);
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
var _local2:GameProxy;
if ((((_arg1.keyCode == Keyboard.SPACE)) || ((_arg1.keyCode == 82)))){
_local2 = (facade.retrieveProxy(GameProxy.NAME) as GameProxy);
_view.stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
Fader.getInstance().fade(restartLevel);
};
}
private function toEditorClickHandler(_arg1:MouseEvent):void{
var _local2:GameProxy = (facade.retrieveProxy(GameProxy.NAME) as GameProxy);
var _local3:String = _local2.currentLevel.def;
notesProxy.push(GameProxy.LEVEL_ABORT);
notesProxy.push(AppProxy.GAME_ABORT);
notesProxy.push(AppProxy.EDITOR_START);
var _local4:EditorProxy = (facade.retrieveProxy(EditorProxy.NAME) as EditorProxy);
_local4.loadLevel(_local3);
}
override public function handleNotification(_arg1:INotification):void{
switch (_arg1.getName()){
case GameProxy.LEVEL_COMPLETE:
levelComplete();
break;
};
}
private function init():void{
_view = (getViewComponent() as LevelView);
notesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
_view.exit_bt.addEventListener(MouseEvent.CLICK, exitClickHandler);
_view.restart_bt.addEventListener(MouseEvent.CLICK, restartClickHandler);
_view.levels_bt.addEventListener(MouseEvent.CLICK, levelsClickHandler);
_view.walkthrough_bt.addEventListener(MouseEvent.CLICK, walkthroughClickHandler);
_view.toEditor_bt.addEventListener(MouseEvent.CLICK, toEditorClickHandler);
_view.exit_bt.visible = false;
_view.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
_view.toEditor_bt.visible = false;
_view.sponsor.visible = false;
}
private function restartClickHandler(_arg1:MouseEvent):void{
Fader.getInstance().fade(restartLevel);
}
private function abortLevel():void{
notesProxy.push(GameProxy.LEVEL_ABORT);
}
private function restartLevel():void{
var _local1:GameProxy = (facade.retrieveProxy(GameProxy.NAME) as GameProxy);
notesProxy.push(GameProxy.LEVEL_ABORT);
notesProxy.push(GameProxy.LEVEL_START, _local1.currentLevel.id);
}
public function setBackground():void{
var _local1:int;
var _local2:GameProxy = (facade.retrieveProxy(GameProxy.NAME) as GameProxy);
trace(_local2.currentLevel);
if (_local2.currentLevel.id < 10){
_local1 = 1;
} else {
if (_local2.currentLevel.id < 20){
_local1 = 2;
} else {
_local1 = 3;
};
};
_view.coreBack.gotoAndStop(_local1);
}
private function levelsClickHandler(_arg1:MouseEvent):void{
Fader.getInstance().fade(abortLevel);
}
private function levelComplete():void{
Tweener.addTween(_view.levels_bt, {alpha:0, time:0.5, transition:"linear"});
Tweener.addTween(_view.restart_bt, {alpha:0, time:0.5, transition:"linear"});
Tweener.addTween(_view.walkthrough_bt, {alpha:0, time:0.5, transition:"linear"});
}
private function walkthroughClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(AppProxy.MOCHI_LEVEL_VIEW_WALKTHROUGH));
}
}
}//package game.view
Section 256
//LevelSelectMediator (game.view.LevelSelectMediator)
package game.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import game.model.*;
import org.puremvc.as3.patterns.mediator.*;
import game.view.components.levelSelect.*;
public class LevelSelectMediator extends Mediator implements IMediator {
private var gameProxy:GameProxy;
private var _view:LevelSelectView;
private var preview:LevelPreview;
private var ndScores:NotDopplerScores;
public static const NAME:String = "LevelSelectMediator";
public function LevelSelectMediator(_arg1:LevelSelectView):void{
super(NAME, _arg1);
init();
}
override public function listNotificationInterests():Array{
return ([]);
}
public function destroy():void{
_view.parent.removeChild(_view);
facade.removeMediator(NAME);
}
private function abortGame():void{
var _local1:NotesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
_local1.push(AppProxy.GAME_ABORT);
}
private function itemRollOverHandler(_arg1:Event):void{
var _local2:LevelItem = (_arg1.target as LevelItem);
preview.update(_local2.level, _view.mouseX, _view.mouseY);
}
private function backClickHandler(_arg1:MouseEvent):void{
Fader.getInstance().fade(abortGame);
}
private function createItems():void{
var _local1:int;
var _local2:GameLevel;
var _local3:LevelItem;
_local1 = 0;
while (_local1 < gameProxy.levels.length) {
_local2 = gameProxy.levels[_local1];
_local3 = new LevelItem(_local2);
_local3.addEventListener(LevelItem.ROLL_OVER, itemRollOverHandler);
_local3.addEventListener(LevelItem.ROLL_OUT, itemRollOutHandler);
_local3.x = ((_local1 % 10) * 62);
_local3.y = (Math.floor((_local1 / 10)) * 80);
_view.itemsContainer.addChild(_local3);
_local1++;
};
}
private function itemRollOutHandler(_arg1:Event):void{
var _local2:LevelItem = (_arg1.target as LevelItem);
preview.hide();
}
private function mouseMoveHandler(_arg1:Event):void{
preview.updatePos(_view.mouseX, _view.mouseY);
}
override public function handleNotification(_arg1:INotification):void{
}
private function init():void{
_view = (getViewComponent() as LevelSelectView);
gameProxy = (facade.retrieveProxy(GameProxy.NAME) as GameProxy);
createItems();
_view.totalScore_tf.text = gameProxy.getTotalScore().toString();
_view.back_bt.addEventListener(MouseEvent.CLICK, backClickHandler);
_view.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
preview = new LevelPreview(_view.preview);
_view.ndScoresHolder.visible = false;
ndScores = new NotDopplerScores(_view.ndScoresContainer);
_view.ndClose_bt.addEventListener(MouseEvent.CLICK, ndCloseClickHandler);
_view.submit_bt.addEventListener(MouseEvent.CLICK, submitClickHandler);
}
private function submitClickHandler(_arg1:MouseEvent):void{
_view.ndScoresHolder.visible = true;
ndScores.loadHighscores(gameProxy.getTotalScore());
}
private function ndCloseClickHandler(_arg1:MouseEvent):void{
_view.ndScoresHolder.visible = false;
}
}
}//package game.view
Section 257
//MainMenuMediator (game.view.MainMenuMediator)
package game.view {
import flash.events.*;
import org.puremvc.as3.interfaces.*;
import game.view.components.*;
import game.model.*;
import flash.net.*;
import org.puremvc.as3.patterns.mediator.*;
public class MainMenuMediator extends Mediator implements IMediator {
private var _view:MainMenuView;
private var notesProxy:NotesProxy;
public static const NAME:String = "MainMenuMediator";
public function MainMenuMediator(_arg1:MainMenuView):void{
super(NAME, _arg1);
init();
}
override public function listNotificationInterests():Array{
return ([]);
}
public function destroy():void{
_view.parent.removeChild(_view);
facade.removeMediator(NAME);
}
private function newGameNoClickHandler(_arg1:MouseEvent):void{
_view.newGameConfirm.visible = false;
}
private function creditsClickHandler(_arg1:MouseEvent):void{
var _local2:AppMediator = (facade.retrieveMediator(AppMediator.NAME) as AppMediator);
var _local3:CreditsView = new CreditsView();
_local2.getViewContainer().addChild(_local3);
var _local4:CreditsMediator = new CreditsMediator(_local3);
facade.registerMediator(_local4);
}
private function highscoresClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(AppProxy.MOCHI_MAIN_MENU_HIGHSCORES), "_blank");
}
private function newGameYesClickHandler(_arg1:MouseEvent):void{
SaveData.getInstance().clearProgress();
Fader.getInstance().fade(startNewGame);
}
private function clearProgressClickHandler(_arg1:MouseEvent):void{
SaveData.getInstance().clearProgress();
}
override public function handleNotification(_arg1:INotification):void{
}
private function moreGamesClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(AppProxy.MOCHI_MAIN_MENU_MORE_GAMES));
}
private function editorClickHandler(_arg1:MouseEvent):void{
notesProxy.push(AppProxy.EDITOR_START);
}
private function init():void{
_view = (getViewComponent() as MainMenuView);
notesProxy = (facade.retrieveProxy(NotesProxy.NAME) as NotesProxy);
_view.startGame_bt.addEventListener(MouseEvent.CLICK, startGameClickHandler);
_view.clearProgress_bt.addEventListener(MouseEvent.CLICK, clearProgressClickHandler);
_view.credits_bt.addEventListener(MouseEvent.CLICK, creditsClickHandler);
_view.walkthrough_bt.addEventListener(MouseEvent.CLICK, walkthroughClickHandler);
_view.editor_bt.addEventListener(MouseEvent.CLICK, editorClickHandler);
_view.highscores_bt.addEventListener(MouseEvent.CLICK, highscoresClickHandler);
_view.moreGames_bt.addEventListener(MouseEvent.CLICK, moreGamesClickHandler);
_view.sponsor.visible = false;
var _local1:SaveData = SaveData.getInstance();
if (_local1.isNewGame){
_view.continueGame_bt.alpha = 0.5;
_view.continueGame_bt.mouseEnabled = false;
} else {
_view.continueGame_bt.addEventListener(MouseEvent.CLICK, continueGameClickHandler);
};
if (!Preloader.DEBUG){
_view.debug.visible = false;
};
_view.clearProgress_bt.visible = false;
_view.newGameConfirm.visible = false;
_view.newGameConfirmYes_bt.addEventListener(MouseEvent.CLICK, newGameYesClickHandler);
_view.newGameConfirmNo_bt.addEventListener(MouseEvent.CLICK, newGameNoClickHandler);
_view.version_tf.text = AppProxy.GAME_VERSION;
_view.wutb_bt.addEventListener(MouseEvent.CLICK, wutbClickHandler);
_view.walkthrough_bt.visible = false;
_view.editor_bt.visible = (Preloader.DEBUG) ? true : false;
}
private function wutbClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(AppProxy.MOCHI_MAIN_MENU_ORIGINAL_GAME), "_blank");
}
private function startGameClickHandler(_arg1:MouseEvent):void{
var _local2:SaveData = SaveData.getInstance();
if (!_local2.isNewGame){
_view.newGameConfirm.visible = true;
} else {
Fader.getInstance().fade(startNewGame);
};
}
private function startNewGame():void{
notesProxy.push(AppProxy.GAME_START);
}
private function continueGame():void{
notesProxy.push(AppProxy.GAME_START);
}
private function continueGameClickHandler(_arg1:MouseEvent):void{
Fader.getInstance().fade(continueGame);
}
private function sponsorClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(AppProxy.SITE_URL));
}
private function walkthroughClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(AppProxy.WALKTHROUGH_URL));
}
}
}//package game.view
Section 258
//GeomLine (geom.GeomLine)
package geom {
import flash.geom.*;
public class GeomLine extends GeomObj {
public var p1:Vector;
public var p2:Vector;
public function GeomLine(_arg1:Vector, _arg2:Vector):void{
this.p1 = _arg1;
this.p2 = _arg2;
}
override public function getBoundingBox():Rectangle{
var _local1:Number = (p1.x + ((p2.x - p1.x) / 2));
var _local2:Number = (p1.y + ((p2.y - p1.y) / 2));
return (new Rectangle((_local1 - 10), (_local2 - 10), 20, 20));
}
override public function translate(_arg1:Number, _arg2:Number):void{
p1.x = (p1.x + _arg1);
p2.x = (p2.x + _arg1);
p1.y = (p1.y + _arg2);
p2.y = (p2.y + _arg2);
}
}
}//package geom
Section 259
//GeomObj (geom.GeomObj)
package geom {
import flash.geom.*;
public class GeomObj {
public function GeomObj():void{
}
public function getBoundingBox():Rectangle{
return (null);
}
public function isPointInside(_arg1:Point):Boolean{
return (false);
}
public function isRectInside(_arg1:Rectangle):Boolean{
return (false);
}
public function translate(_arg1:Number, _arg2:Number):void{
}
public static function lineLineInts(_arg1:GeomLine, _arg2:GeomLine):Vector{
var _local14:Vector;
var _local3:Number = _arg1.p1.x;
var _local4:Number = _arg1.p2.x;
var _local5:Number = _arg2.p1.x;
var _local6:Number = _arg2.p2.x;
var _local7:Number = _arg1.p1.y;
var _local8:Number = _arg1.p2.y;
var _local9:Number = _arg2.p1.y;
var _local10:Number = _arg2.p2.y;
if ((((Math.max(_local3, _local4) < Math.min(_local5, _local6))) || ((Math.max(_local5, _local6) < Math.min(_local3, _local4))))){
return (null);
};
if ((((Math.max(_local7, _local8) < Math.min(_local9, _local10))) || ((Math.max(_local9, _local10) < Math.min(_local7, _local8))))){
return (null);
};
var _local11:Number = (((_local6 - _local5) * (_local7 - _local9)) - ((_local10 - _local9) * (_local3 - _local5)));
var _local12:Number = (((_local4 - _local3) * (_local7 - _local9)) - ((_local8 - _local7) * (_local3 - _local5)));
var _local13:Number = (((_local10 - _local9) * (_local4 - _local3)) - ((_local6 - _local5) * (_local8 - _local7)));
if (Math.abs(_local13) < 0.001){
return (null);
};
_local11 = (_local11 / _local13);
_local12 = (_local12 / _local13);
if ((((((((0 < _local11)) && ((_local11 < 1)))) && ((0 < _local12)))) && ((_local12 < 1)))){
_local14 = new Vector((_local3 + (_local11 * (_local4 - _local3))), (_local7 + (_local11 * (_local8 - _local7))));
return (_local14);
};
return (null);
}
}
}//package geom
Section 260
//GeomPoly (geom.GeomPoly)
package geom {
import flash.geom.*;
public class GeomPoly extends GeomObj {
public var isReversed:Boolean;
public var vertices:Array;
public function GeomPoly(_arg1:Array):void{
this.vertices = _arg1;
isReversed = false;
if (isCW()){
_arg1.reverse();
isReversed = true;
};
}
public function add(_arg1:GeomTriangle):GeomPoly{
var _local6:int;
var _local16:Vector;
var _local2 = -1;
var _local3 = -1;
var _local4 = -1;
var _local5 = -1;
var _local7:int = vertices.length;
var _local8:Array = [];
var _local9:Array = [];
_local6 = 0;
while (_local6 < _local7) {
_local8[_local6] = vertices[_local6].x;
_local9[_local6] = vertices[_local6].y;
_local6++;
};
_local6 = 0;
while (_local6 < _local7) {
if ((((_arg1.x[0] == _local8[_local6])) && ((_arg1.y[0] == _local9[_local6])))){
if (_local2 == -1){
_local2 = _local6;
_local3 = 0;
} else {
_local4 = _local6;
_local5 = 0;
};
} else {
if ((((_arg1.x[1] == _local8[_local6])) && ((_arg1.y[1] == _local9[_local6])))){
if (_local2 == -1){
_local2 = _local6;
_local3 = 1;
} else {
_local4 = _local6;
_local5 = 1;
};
} else {
if ((((_arg1.x[2] == _local8[_local6])) && ((_arg1.y[2] == _local9[_local6])))){
if (_local2 == -1){
_local2 = _local6;
_local3 = 2;
} else {
_local4 = _local6;
_local5 = 2;
};
};
};
};
_local6++;
};
if ((((_local2 == 0)) && ((_local4 == (_local7 - 1))))){
_local2 = (_local7 - 1);
_local4 = 0;
};
if (_local4 == -1){
return (null);
};
var _local10:int;
if ((((_local10 == _local3)) || ((_local10 == _local5)))){
_local10 = 1;
};
if ((((_local10 == _local3)) || ((_local10 == _local5)))){
_local10 = 2;
};
var _local11:Array = [];
var _local12:Array = [];
var _local13:int;
_local6 = 0;
while (_local6 < _local7) {
_local11[_local13] = _local8[_local6];
_local12[_local13] = _local9[_local6];
if (_local6 == _local2){
_local13++;
_local11[_local13] = _arg1.x[_local10];
_local12[_local13] = _arg1.y[_local10];
};
_local13++;
_local6++;
};
var _local14:int = _local11.length;
var _local15:Array = [];
_local6 = 0;
while (_local6 < _local14) {
_local16 = new Vector(_local11[_local6], _local12[_local6]);
_local15.push(_local16);
_local6++;
};
return (new GeomPoly(_local15));
}
override public function isPointInside(_arg1:Point):Boolean{
var _local6:GeomLine;
var _local7:Vector;
var _local2:GeomLine = new GeomLine(new Vector(_arg1.x, _arg1.y), new Vector((_arg1.x + 1000), _arg1.y));
var _local3:uint;
var _local4:uint;
var _local5:uint = 1;
while (_local5 <= vertices.length) {
_local4 = _local5;
if (_local4 == vertices.length){
_local4 = 0;
};
_local6 = new GeomLine(vertices[_local4], vertices[(_local5 - 1)]);
_local7 = GeomObj.lineLineInts(_local2, _local6);
if (_local7){
_local3 = (_local3 + 1);
};
_local5++;
};
return ((((_local3 > 0)) && (!(((_local3 % 2) == 0)))));
}
public function getArea():Number{
var _local4:Vector;
var _local5:Vector;
var _local1:Number = 0;
var _local2:Vector = vertices[0];
var _local3:uint = 2;
while (_local3 < vertices.length) {
_local4 = vertices[(_local3 - 1)].subtract(_local2);
_local5 = vertices[_local3].subtract(_local2);
_local1 = (_local1 + _local4.cross(_local5));
_local3++;
};
return (_local1);
}
override public function isRectInside(_arg1:Rectangle):Boolean{
var _local4:GeomLine;
var _local5:uint;
var _local2:Array = [new GeomLine(new Vector(_arg1.x, _arg1.y), new Vector((_arg1.x + _arg1.width), _arg1.y)), new GeomLine(new Vector((_arg1.x + _arg1.width), _arg1.y), new Vector((_arg1.x + _arg1.width), (_arg1.y + _arg1.height))), new GeomLine(new Vector((_arg1.x + _arg1.width), (_arg1.y + _arg1.height)), new Vector(_arg1.x, (_arg1.y + _arg1.height))), new GeomLine(new Vector(_arg1.x, (_arg1.y + _arg1.height)), new Vector(_arg1.x, _arg1.y))];
var _local3:uint = 1;
while (_local3 < vertices.length) {
_local4 = new GeomLine(vertices[_local3], vertices[(_local3 - 1)]);
_local5 = 0;
while (_local5 < _local2.length) {
if (GeomObj.lineLineInts(_local4, _local2[_local5])){
return (true);
};
_local5++;
};
_local3++;
};
return (false);
}
public function isConvex():Boolean{
var _local4:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Boolean;
var _local1:int = vertices.length;
var _local2:Array = [];
var _local3:Array = [];
_local4 = 0;
while (_local4 < _local1) {
_local2.push(vertices[_local4].x);
_local3.push(vertices[_local4].y);
_local4++;
};
var _local5:Boolean;
_local4 = 0;
while (_local4 < _local1) {
_local6 = ((_local4 == 0)) ? (_local1 - 1) : (_local4 - 1);
_local7 = _local4;
_local8 = ((_local4 == (_local1 - 1))) ? 0 : (_local4 + 1);
_local9 = (_local2[_local7] - _local2[_local6]);
_local10 = (_local3[_local7] - _local3[_local6]);
_local11 = (_local2[_local8] - _local2[_local7]);
_local12 = (_local3[_local8] - _local3[_local7]);
_local13 = ((_local9 * _local12) - (_local11 * _local10));
_local14 = ((_local13 > 0)) ? true : false;
if (_local4 == 0){
_local5 = _local14;
} else {
if (_local5 != _local14){
return (false);
};
};
_local4++;
};
return (true);
}
override public function getBoundingBox():Rectangle{
var _local6:Vector;
var _local1:Number = 1000;
var _local2:Number = 1000;
var _local3:Number = -1000;
var _local4:Number = -1000;
var _local5:uint;
while (_local5 < vertices.length) {
_local6 = vertices[_local5];
if (_local6.x < _local1){
_local1 = _local6.x;
};
if (_local6.x > _local3){
_local3 = _local6.x;
};
if (_local6.y < _local2){
_local2 = _local6.y;
};
if (_local6.y > _local4){
_local4 = _local6.y;
};
_local5++;
};
return (new Rectangle(_local1, _local2, (_local3 - _local1), (_local4 - _local2)));
}
public function isSimple():Boolean{
var _local2:uint;
var _local3:GeomLine;
var _local4:uint;
var _local5:uint;
var _local6:GeomLine;
var _local7:Vector;
var _local1:uint = 1;
while (_local1 <= vertices.length) {
_local2 = _local1;
if (_local2 == vertices.length){
_local2 = 0;
};
_local3 = new GeomLine(vertices[_local2], vertices[(_local1 - 1)]);
_local4 = (_local1 + 1);
while (_local4 <= vertices.length) {
_local5 = _local4;
if (_local5 == vertices.length){
_local5 = 0;
};
_local6 = new GeomLine(vertices[_local5], vertices[(_local4 - 1)]);
_local7 = GeomObj.lineLineInts(_local3, _local6);
if (_local7){
return (false);
};
_local4++;
};
_local1++;
};
return (true);
}
public function isCW():Boolean{
return ((getArea() > 0));
}
public static function pseudoPolygonize(_arg1:Array):Array{
var _local4:GeomTriangle;
var _local5:Vector;
var _local6:Vector;
var _local7:Vector;
var _local2:Array = [];
var _local3:uint;
while (_local3 < _arg1.length) {
_local4 = _arg1[_local3];
_local5 = new Vector(_local4.x[0], _local4.y[0]);
_local6 = new Vector(_local4.x[1], _local4.y[1]);
_local7 = new Vector(_local4.x[2], _local4.y[2]);
_local2.push(new GeomPoly([_local5, _local6, _local7]));
_local3++;
};
return (_local2);
}
public static function polygonizeTriangles(_arg1:Array):Array{
var _local2:Array;
var _local4:uint;
var _local6:Array;
var _local7:Boolean;
var _local8:int;
var _local9:GeomTriangle;
var _local10:Vector;
var _local11:Vector;
var _local12:Vector;
var _local13:GeomPoly;
var _local14:GeomPoly;
var _local3:int;
if (_arg1 == null){
return (null);
};
_local2 = [];
_local6 = [];
_local4 = 0;
while (_local4 < _arg1.length) {
_local6[_local4] = false;
_local4++;
};
_local7 = true;
while (_local7) {
_local8 = -1;
_local4 = 0;
while (_local4 < _arg1.length) {
if (_local6[_local4]){
} else {
_local8 = _local4;
break;
};
_local4++;
};
if (_local8 == -1){
_local7 = false;
} else {
_local9 = _arg1[_local8];
_local10 = new Vector(_local9.x[0], _local9.y[0]);
_local11 = new Vector(_local9.x[1], _local9.y[1]);
_local12 = new Vector(_local9.x[2], _local9.y[2]);
_local13 = new GeomPoly([_local10, _local11, _local12]);
_local6[_local8] = true;
_local4 = 0;
while (_local4 < _arg1.length) {
if (_local6[_local4]){
} else {
_local14 = _local13.add(_arg1[_local4]);
if (_local14 == null){
} else {
if (_local14.isConvex()){
_local13 = _local14;
_local6[_local4] = true;
};
};
};
_local4++;
};
_local2[_local3] = _local13;
_local3++;
};
};
var _local5:Array = [];
_local4 = 0;
while (_local4 < _local3) {
_local5[_local4] = _local2[_local4];
_local4++;
};
return (_local5);
}
private static function isEar(_arg1:int, _arg2:Array, _arg3:Array):Boolean{
var _local4:Number = 0;
var _local5:Number = 0;
var _local6:Number = 0;
var _local7:Number = 0;
if ((((((_arg1 >= _arg2.length)) || ((_arg1 < 0)))) || ((_arg2.length < 3)))){
return (false);
};
var _local8:int = (_arg1 + 1);
var _local9:int = (_arg1 - 1);
if (_arg1 == 0){
_local4 = (_arg2[0] - _arg2[(_arg2.length - 1)]);
_local5 = (_arg3[0] - _arg3[(_arg3.length - 1)]);
_local6 = (_arg2[1] - _arg2[0]);
_local7 = (_arg3[1] - _arg3[0]);
_local9 = (_arg2.length - 1);
} else {
if (_arg1 == (_arg2.length - 1)){
_local4 = (_arg2[_arg1] - _arg2[(_arg1 - 1)]);
_local5 = (_arg3[_arg1] - _arg3[(_arg1 - 1)]);
_local6 = (_arg2[0] - _arg2[_arg1]);
_local7 = (_arg3[0] - _arg3[_arg1]);
} else {
_local4 = (_arg2[_arg1] - _arg2[(_arg1 - 1)]);
_local5 = (_arg3[_arg1] - _arg3[(_arg1 - 1)]);
_local6 = (_arg2[(_arg1 + 1)] - _arg2[_arg1]);
_local7 = (_arg3[(_arg1 + 1)] - _arg3[_arg1]);
};
};
var _local10:Number = ((_local4 * _local7) - (_local6 * _local5));
if (_local10 > 0){
return (false);
};
var _local11:GeomTriangle = new GeomTriangle(_arg2[_arg1], _arg3[_arg1], _arg2[_local8], _arg3[_local8], _arg2[_local9], _arg3[_local9]);
var _local12:uint;
while (_local12 < _arg2.length) {
if (!(((((_local12 == _arg1)) || ((_local12 == _local9)))) || ((_local12 == _local8)))){
if (_local11.isInside2(_arg2[_local12], _arg3[_local12])){
return (false);
};
};
_local12++;
};
return (true);
}
public static function triangulate(_arg1:GeomPoly):Array{
var _local3:int;
var _local10:GeomTriangle;
var _local12:int;
var _local13:Number;
var _local14:Array;
var _local15:Array;
var _local16:int;
var _local17:int;
var _local18:int;
var _local19:GeomTriangle;
var _local2:int = _arg1.vertices.length;
if (_local2 < 3){
return (null);
};
var _local4:Array = [];
var _local5:Array = [];
_local3 = 0;
while (_local3 < _arg1.vertices.length) {
_local4[_local3] = _arg1.vertices[_local3].x;
_local5[_local3] = _arg1.vertices[_local3].y;
_local3++;
};
var _local6:Array = [];
var _local7:uint;
var _local8:Array = [];
var _local9:Array = [];
_local3 = 0;
while (_local3 < _local2) {
_local8[_local3] = _local4[_local3];
_local9[_local3] = _local5[_local3];
_local3++;
};
while (_local2 > 3) {
_local12 = -1;
_local13 = -10;
_local3 = 0;
while (_local3 < _local2) {
if (isEar(_local3, _local8, _local9)){
_local12 = _local3;
break;
};
_local3++;
};
if (_local12 == -1){
trace("NO EAR FOUND");
return (null);
};
_local2--;
_local14 = [];
_local15 = [];
_local16 = 0;
_local3 = 0;
while (_local3 < _local2) {
if (_local16 == _local12){
_local16++;
};
_local14[_local3] = _local8[_local16];
_local15[_local3] = _local9[_local16];
_local16++;
_local3++;
};
_local17 = ((_local12 == 0)) ? (_local8.length - 1) : (_local12 - 1);
_local18 = ((_local12 == (_local8.length - 1))) ? 0 : (_local12 + 1);
_local10 = new GeomTriangle(_local8[_local12], _local9[_local12], _local8[_local18], _local9[_local18], _local8[_local17], _local9[_local17]);
_local6[_local7] = _local10;
_local7++;
_local8 = _local14;
_local9 = _local15;
};
_local10 = new GeomTriangle(_local8[1], _local9[1], _local8[2], _local9[2], _local8[0], _local9[0]);
_local6[_local7] = _local10;
_local7++;
var _local11:Array = [];
_local3 = 0;
while (_local3 < _local7) {
_local19 = _local6[_local3];
if (_local19.getMinAngle() > 0.1){
_local11.push(_local6[_local3]);
};
_local3++;
};
return (_local11);
}
public static function getGeomPoly(_arg1:Number, _arg2:Number, _arg3:Array):GeomPoly{
var _local6:Vector;
var _local4:Array = [];
var _local5:uint;
while (_local5 < _arg3.length) {
_local6 = new Vector((_arg1 + _arg3[_local5].x), (_arg2 + _arg3[_local5].y));
_local4.push(_local6);
_local5++;
};
return (new GeomPoly(_local4));
}
}
}//package geom
Section 261
//GeomTriangle (geom.GeomTriangle)
package geom {
import flash.geom.*;
public class GeomTriangle {
public var x:Array;
public var y:Array;
public function GeomTriangle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):void{
x = [];
y = [];
var _local7:Number = (_arg3 - _arg1);
var _local8:Number = (_arg5 - _arg1);
var _local9:Number = (_arg4 - _arg2);
var _local10:Number = (_arg6 - _arg2);
var _local11:Number = ((_local7 * _local10) - (_local8 * _local9));
var _local12 = (_local11 > 0);
if (_local12){
x[0] = _arg1;
x[1] = _arg3;
x[2] = _arg5;
y[0] = _arg2;
y[1] = _arg4;
y[2] = _arg6;
} else {
x[0] = _arg1;
x[1] = _arg5;
x[2] = _arg3;
y[0] = _arg2;
y[1] = _arg6;
y[2] = _arg4;
};
}
public function isInside(_arg1:Number, _arg2:Number):Boolean{
if ((((((_arg1 < x[0])) && ((_arg1 < x[1])))) && ((_arg1 < x[2])))){
return (false);
};
if ((((((_arg1 > x[0])) && ((_arg1 > x[1])))) && ((_arg1 > x[2])))){
return (false);
};
if ((((((_arg2 < y[0])) && ((_arg2 < y[1])))) && ((_arg2 < y[2])))){
return (false);
};
if ((((((_arg2 > y[0])) && ((_arg2 > y[1])))) && ((_arg2 > y[2])))){
return (false);
};
var _local3:Number = (_arg1 - x[0]);
var _local4:Number = (_arg2 - y[0]);
var _local5:Number = (x[1] - x[0]);
var _local6:Number = (y[1] - y[0]);
var _local7:Number = (x[2] - x[0]);
var _local8:Number = (y[2] - y[0]);
var _local9:Number = ((_local7 * _local7) + (_local8 * _local8));
var _local10:Number = ((_local7 * _local5) + (_local8 * _local6));
var _local11:Number = ((_local7 * _local3) + (_local8 * _local4));
var _local12:Number = ((_local5 * _local5) + (_local6 * _local6));
var _local13:Number = ((_local5 * _local3) + (_local6 * _local4));
var _local14:Number = (1 / ((_local9 * _local12) - (_local10 * _local10)));
var _local15:Number = (((_local12 * _local11) - (_local10 * _local13)) * _local14);
var _local16:Number = (((_local9 * _local13) - (_local10 * _local11)) * _local14);
return ((((((_local15 > 0)) && ((_local16 > 0)))) && (((_local15 + _local16) < 1))));
}
public function getMinAngle():Number{
var _local1:Vector = new Vector((x[1] - x[0]), (y[1] - y[0]));
var _local2:Vector = new Vector((x[0] - x[2]), (y[0] - y[2]));
var _local3:Vector = new Vector((x[2] - x[1]), (y[2] - y[1]));
_local1.normalize();
_local2.normalize();
_local3.normalize();
var _local4:Number = Math.abs(_local1.cross(_local2));
var _local5:Number = Math.abs(_local2.cross(_local3));
var _local6:Number = Math.abs(_local3.cross(_local1));
var _local7:Number = Math.min(_local4, _local5, _local6);
return (((Math.asin(_local7) * 180) / Math.PI));
}
private function getArea(_arg1:Point, _arg2:Point, _arg3:Point):Number{
return ((0.5 * ((((((_arg1.x * _arg2.y) + (_arg1.y * _arg3.x)) + (_arg3.y * _arg2.x)) - (_arg3.x * _arg2.y)) - (_arg3.y * _arg1.x)) - (_arg2.x * _arg1.y))));
}
public function isInside2(_arg1:Number, _arg2:Number):Boolean{
var _local3:Point = new Point(_arg1, _arg2);
var _local4:Point = new Point(x[0], y[0]);
var _local5:Point = new Point(x[1], y[1]);
var _local6:Point = new Point(x[2], y[2]);
var _local7:Number = getArea(_local4, _local5, _local6);
var _local8:Number = ((Math.abs(getArea(_local3, _local4, _local5)) + Math.abs(getArea(_local3, _local4, _local6))) + Math.abs(getArea(_local3, _local5, _local6)));
return (((Math.abs((_local7 - _local8)) < 1E-5)) ? true : false);
}
}
}//package geom
Section 262
//Vector (geom.Vector)
package geom {
public class Vector {
public var x:Number;
public var y:Number;
public function Vector(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
public function dot(_arg1:Vector):Number{
return (((x * _arg1.x) + (y * _arg1.y)));
}
public function subtract(_arg1:Vector):Vector{
return (new Vector((x - _arg1.x), (y - _arg1.y)));
}
public function copy():Vector{
return (new Vector(x, y));
}
public function toString():String{
return (((x + " ") + y));
}
public function normalize():Number{
var _local1:Number = Math.sqrt(((x * x) + (y * y)));
if (_local1 < Number.MIN_VALUE){
return (0);
};
var _local2:Number = (1 / _local1);
x = (x * _local2);
y = (y * _local2);
return (_local1);
}
public function cross(_arg1:Vector):Number{
return (((x * _arg1.y) - (y * _arg1.x)));
}
}
}//package geom
Section 263
//ByteArrayAsset (mx.core.ByteArrayAsset)
package mx.core {
import flash.utils.*;
public class ByteArrayAsset extends ByteArray implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
}
}//package mx.core
Section 264
//EdgeMetrics (mx.core.EdgeMetrics)
package mx.core {
public class EdgeMetrics {
public var top:Number;
public var left:Number;
public var bottom:Number;
public var right:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public static const EMPTY:EdgeMetrics = new EdgeMetrics(0, 0, 0, 0);
;
public function EdgeMetrics(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0){
this.left = _arg1;
this.top = _arg2;
this.right = _arg3;
this.bottom = _arg4;
}
public function clone():EdgeMetrics{
return (new EdgeMetrics(left, top, right, bottom));
}
}
}//package mx.core
Section 265
//FlexSprite (mx.core.FlexSprite)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexSprite extends Sprite {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexSprite(){
super();
try {
name = NameUtil.createUniqueName(this);
} catch(e:Error) {
};
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 266
//IBorder (mx.core.IBorder)
package mx.core {
public interface IBorder {
function get borderMetrics():EdgeMetrics;
}
}//package mx.core
Section 267
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 268
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.accessibility.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get visible():Boolean;
function get rotation():Number;
function localToGlobal(_arg1:Point):Point;
function get name():String;
function set width(_arg1:Number):void;
function get measuredHeight():Number;
function get blendMode():String;
function get scale9Grid():Rectangle;
function set name(_arg1:String):void;
function set scaleX(_arg1:Number):void;
function set scaleY(_arg1:Number):void;
function get measuredWidth():Number;
function get accessibilityProperties():AccessibilityProperties;
function set scrollRect(_arg1:Rectangle):void;
function get cacheAsBitmap():Boolean;
function globalToLocal(_arg1:Point):Point;
function get height():Number;
function set blendMode(_arg1:String):void;
function get parent():DisplayObjectContainer;
function getBounds(_arg1:DisplayObject):Rectangle;
function get opaqueBackground():Object;
function set scale9Grid(_arg1:Rectangle):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set alpha(_arg1:Number):void;
function set accessibilityProperties(_arg1:AccessibilityProperties):void;
function get width():Number;
function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean;
function set cacheAsBitmap(_arg1:Boolean):void;
function get scaleX():Number;
function get scaleY():Number;
function get scrollRect():Rectangle;
function get mouseX():Number;
function get mouseY():Number;
function set height(_arg1:Number):void;
function set mask(_arg1:DisplayObject):void;
function getRect(_arg1:DisplayObject):Rectangle;
function get alpha():Number;
function set transform(_arg1:Transform):void;
function move(_arg1:Number, _arg2:Number):void;
function get loaderInfo():LoaderInfo;
function get root():DisplayObject;
function hitTestObject(_arg1:DisplayObject):Boolean;
function set opaqueBackground(_arg1:Object):void;
function set visible(_arg1:Boolean):void;
function get mask():DisplayObject;
function set x(_arg1:Number):void;
function set y(_arg1:Number):void;
function get transform():Transform;
function set filters(_arg1:Array):void;
function get x():Number;
function get y():Number;
function get filters():Array;
function set rotation(_arg1:Number):void;
function get stage():Stage;
}
}//package mx.core
Section 269
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(_arg1:Array):void;
function get isDocument():Boolean;
function set repeaters(_arg1:Array):void;
function initializeRepeaterArrays(_arg1:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(_arg1:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 270
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 271
//SpriteAsset (mx.core.SpriteAsset)
package mx.core {
public class SpriteAsset extends FlexSprite implements IFlexAsset, IFlexDisplayObject, IBorder {
private var _measuredHeight:Number;
private var _measuredWidth:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public function SpriteAsset(){
_measuredWidth = width;
_measuredHeight = height;
}
public function get measuredWidth():Number{
return (_measuredWidth);
}
public function get measuredHeight():Number{
return (_measuredHeight);
}
public function setActualSize(_arg1:Number, _arg2:Number):void{
width = _arg1;
height = _arg2;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
public function get borderMetrics():EdgeMetrics{
if (scale9Grid == null){
return (EdgeMetrics.EMPTY);
};
return (new EdgeMetrics(scale9Grid.left, scale9Grid.top, Math.ceil((measuredWidth - scale9Grid.right)), Math.ceil((measuredHeight - scale9Grid.bottom))));
}
}
}//package mx.core
Section 272
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import flash.display.*;
import mx.core.*;
import flash.utils.*;
public class NameUtil {
mx_internal static const VERSION:String = "3.0.0.0";
private static var counter:int = 0;
public static function displayObjectToString(_arg1:DisplayObject):String{
var _local2:String;
var _local4:String;
var _local5:Array;
var _local3:DisplayObject = _arg1;
while (_local3 != null) {
if (((((_local3.parent) && (_local3.stage))) && ((_local3.parent == _local3.stage)))){
break;
};
_local4 = _local3.name;
if ((_local3 is IRepeaterClient)){
_local5 = IRepeaterClient(_local3).instanceIndices;
if (_local5){
_local4 = (_local4 + (("[" + _local5.join("][")) + "]"));
};
};
_local2 = ((_local2 == null)) ? _local4 : ((_local4 + ".") + _local2);
_local3 = _local3.parent;
};
return (_local2);
}
public static function createUniqueName(_arg1:Object):String{
if (!_arg1){
return (null);
};
var _local2:String = getQualifiedClassName(_arg1);
var _local3:int = _local2.indexOf("::");
if (_local3 != -1){
_local2 = _local2.substr((_local3 + 2));
};
var _local4:int = _local2.charCodeAt((_local2.length - 1));
if ((((_local4 >= 48)) && ((_local4 <= 57)))){
_local2 = (_local2 + "_");
};
return ((_local2 + counter++));
}
}
}//package mx.utils
Section 273
//Controller (org.puremvc.as3.core.controller.Controller)
package org.puremvc.as3.core.controller {
import org.puremvc.as3.interfaces.*;
import org.puremvc.as3.core.view.*;
import org.puremvc.as3.patterns.observer.*;
public class Controller implements IController {
protected const SINGLETON_MSG:String = "Controller Singleton already constructed!";
protected var commandMap:Array;
protected var view:IView;
protected static var instance:IController;
public function Controller(){
if (instance != null){
throw (Error(SINGLETON_MSG));
};
instance = this;
commandMap = new Array();
initializeController();
}
public function removeCommand(_arg1:String):void{
commandMap[_arg1] = null;
}
public function registerCommand(_arg1:String, _arg2:Class):void{
if (commandMap[_arg1] == null){
view.registerObserver(_arg1, new Observer(executeCommand, this));
};
commandMap[_arg1] = _arg2;
}
protected function initializeController():void{
view = View.getInstance();
}
public function hasCommand(_arg1:String):Boolean{
return (!((commandMap[_arg1] == null)));
}
public function executeCommand(_arg1:INotification):void{
var _local2:Class = commandMap[_arg1.getName()];
if (_local2 == null){
return;
};
var _local3:ICommand = new (_local2);
_local3.execute(_arg1);
}
public static function getInstance():IController{
if (instance == null){
instance = new (Controller);
};
return (instance);
}
}
}//package org.puremvc.as3.core.controller
Section 274
//Model (org.puremvc.as3.core.model.Model)
package org.puremvc.as3.core.model {
import org.puremvc.as3.interfaces.*;
public class Model implements IModel {
protected const SINGLETON_MSG:String = "Model Singleton already constructed!";
protected var proxyMap:Array;
protected static var instance:IModel;
public function Model(){
if (instance != null){
throw (Error(SINGLETON_MSG));
};
instance = this;
proxyMap = new Array();
initializeModel();
}
protected function initializeModel():void{
}
public function removeProxy(_arg1:String):IProxy{
var _local2:IProxy = (proxyMap[_arg1] as IProxy);
proxyMap[_arg1] = null;
return (_local2);
}
public function hasProxy(_arg1:String):Boolean{
return (!((proxyMap[_arg1] == null)));
}
public function retrieveProxy(_arg1:String):IProxy{
return (proxyMap[_arg1]);
}
public function registerProxy(_arg1:IProxy):void{
proxyMap[_arg1.getProxyName()] = _arg1;
}
public static function getInstance():IModel{
if (instance == null){
instance = new (Model);
};
return (instance);
}
}
}//package org.puremvc.as3.core.model
Section 275
//View (org.puremvc.as3.core.view.View)
package org.puremvc.as3.core.view {
import org.puremvc.as3.interfaces.*;
import org.puremvc.as3.patterns.observer.*;
public class View implements IView {
protected const SINGLETON_MSG:String = "View Singleton already constructed!";
protected var observerMap:Array;
protected var mediatorMap:Array;
protected static var instance:IView;
public function View(){
if (instance != null){
throw (Error(SINGLETON_MSG));
};
instance = this;
mediatorMap = new Array();
observerMap = new Array();
initializeView();
}
public function retrieveMediator(_arg1:String):IMediator{
return (mediatorMap[_arg1]);
}
public function hasMediator(_arg1:String):Boolean{
return (!((mediatorMap[_arg1] == null)));
}
public function notifyObservers(_arg1:INotification):void{
var _local2:Array;
var _local3:Number;
var _local4:IObserver;
if (observerMap[_arg1.getName()] != null){
_local2 = (observerMap[_arg1.getName()] as Array);
_local3 = 0;
while (_local3 < _local2.length) {
_local4 = (_local2[_local3] as IObserver);
_local4.notifyObserver(_arg1);
_local3++;
};
};
}
protected function initializeView():void{
}
public function registerMediator(_arg1:IMediator):void{
var _local3:Observer;
var _local4:Number;
mediatorMap[_arg1.getMediatorName()] = _arg1;
var _local2:Array = _arg1.listNotificationInterests();
if (_local2.length > 0){
_local3 = new Observer(_arg1.handleNotification, _arg1);
_local4 = 0;
while (_local4 < _local2.length) {
registerObserver(_local2[_local4], _local3);
_local4++;
};
};
_arg1.onRegister();
}
public function removeMediator(_arg1:String):IMediator{
var _local2:String;
var _local3:IMediator;
var _local4:Array;
var _local5:Array;
var _local6:int;
var _local7:int;
for (_local2 in observerMap) {
_local4 = observerMap[_local2];
_local5 = new Array();
_local6 = 0;
while (_local6 < _local4.length) {
if (Observer(_local4[_local6]).compareNotifyContext(retrieveMediator(_arg1)) == true){
_local5.push(_local6);
};
_local6++;
};
while (_local5.length > 0) {
_local7 = _local5.pop();
_local4.splice(_local7, 1);
};
if (_local4.length == 0){
delete observerMap[_local2];
};
};
_local3 = (mediatorMap[_arg1] as IMediator);
delete mediatorMap[_arg1];
if (_local3){
_local3.onRemove();
};
return (_local3);
}
public function registerObserver(_arg1:String, _arg2:IObserver):void{
if (observerMap[_arg1] != null){
observerMap[_arg1].push(_arg2);
} else {
observerMap[_arg1] = [_arg2];
};
}
public static function getInstance():IView{
if (instance == null){
instance = new (View);
};
return (instance);
}
}
}//package org.puremvc.as3.core.view
Section 276
//ICommand (org.puremvc.as3.interfaces.ICommand)
package org.puremvc.as3.interfaces {
public interface ICommand {
function execute(_arg1:INotification):void;
}
}//package org.puremvc.as3.interfaces
Section 277
//IController (org.puremvc.as3.interfaces.IController)
package org.puremvc.as3.interfaces {
public interface IController {
function registerCommand(_arg1:String, _arg2:Class):void;
function hasCommand(_arg1:String):Boolean;
function executeCommand(_arg1:INotification):void;
function removeCommand(_arg1:String):void;
}
}//package org.puremvc.as3.interfaces
Section 278
//IFacade (org.puremvc.as3.interfaces.IFacade)
package org.puremvc.as3.interfaces {
public interface IFacade extends INotifier {
function removeCommand(_arg1:String):void;
function registerCommand(_arg1:String, _arg2:Class):void;
function removeProxy(_arg1:String):IProxy;
function registerProxy(_arg1:IProxy):void;
function hasMediator(_arg1:String):Boolean;
function retrieveMediator(_arg1:String):IMediator;
function hasCommand(_arg1:String):Boolean;
function retrieveProxy(_arg1:String):IProxy;
function hasProxy(_arg1:String):Boolean;
function registerMediator(_arg1:IMediator):void;
function removeMediator(_arg1:String):IMediator;
}
}//package org.puremvc.as3.interfaces
Section 279
//IMediator (org.puremvc.as3.interfaces.IMediator)
package org.puremvc.as3.interfaces {
public interface IMediator {
function listNotificationInterests():Array;
function onRegister():void;
function handleNotification(_arg1:INotification):void;
function getMediatorName():String;
function setViewComponent(_arg1:Object):void;
function getViewComponent():Object;
function onRemove():void;
}
}//package org.puremvc.as3.interfaces
Section 280
//IModel (org.puremvc.as3.interfaces.IModel)
package org.puremvc.as3.interfaces {
public interface IModel {
function removeProxy(_arg1:String):IProxy;
function retrieveProxy(_arg1:String):IProxy;
function registerProxy(_arg1:IProxy):void;
function hasProxy(_arg1:String):Boolean;
}
}//package org.puremvc.as3.interfaces
Section 281
//INotification (org.puremvc.as3.interfaces.INotification)
package org.puremvc.as3.interfaces {
public interface INotification {
function getType():String;
function getName():String;
function toString():String;
function setBody(_arg1:Object):void;
function getBody():Object;
function setType(_arg1:String):void;
}
}//package org.puremvc.as3.interfaces
Section 282
//INotifier (org.puremvc.as3.interfaces.INotifier)
package org.puremvc.as3.interfaces {
public interface INotifier {
function sendNotification(_arg1:String, _arg2:Object=null, _arg3:String=null):void;
}
}//package org.puremvc.as3.interfaces
Section 283
//IObserver (org.puremvc.as3.interfaces.IObserver)
package org.puremvc.as3.interfaces {
public interface IObserver {
function compareNotifyContext(_arg1:Object):Boolean;
function setNotifyContext(_arg1:Object):void;
function setNotifyMethod(_arg1:Function):void;
function notifyObserver(_arg1:INotification):void;
}
}//package org.puremvc.as3.interfaces
Section 284
//IProxy (org.puremvc.as3.interfaces.IProxy)
package org.puremvc.as3.interfaces {
public interface IProxy {
function getData():Object;
function getProxyName():String;
function setData(_arg1:Object):void;
}
}//package org.puremvc.as3.interfaces
Section 285
//IView (org.puremvc.as3.interfaces.IView)
package org.puremvc.as3.interfaces {
public interface IView {
function notifyObservers(_arg1:INotification):void;
function registerMediator(_arg1:IMediator):void;
function removeMediator(_arg1:String):IMediator;
function registerObserver(_arg1:String, _arg2:IObserver):void;
function hasMediator(_arg1:String):Boolean;
function retrieveMediator(_arg1:String):IMediator;
}
}//package org.puremvc.as3.interfaces
Section 286
//SimpleCommand (org.puremvc.as3.patterns.command.SimpleCommand)
package org.puremvc.as3.patterns.command {
import org.puremvc.as3.interfaces.*;
import org.puremvc.as3.patterns.observer.*;
public class SimpleCommand extends Notifier implements ICommand, INotifier {
public function execute(_arg1:INotification):void{
}
}
}//package org.puremvc.as3.patterns.command
Section 287
//Facade (org.puremvc.as3.patterns.facade.Facade)
package org.puremvc.as3.patterns.facade {
import org.puremvc.as3.interfaces.*;
import org.puremvc.as3.core.view.*;
import org.puremvc.as3.core.controller.*;
import org.puremvc.as3.core.model.*;
import org.puremvc.as3.patterns.observer.*;
public class Facade implements IFacade {
protected const SINGLETON_MSG:String = "Facade Singleton already constructed!";
protected var controller:IController;
protected var view:IView;
protected var model:IModel;
protected static var instance:IFacade;
public function Facade(){
if (instance != null){
throw (Error(SINGLETON_MSG));
};
instance = this;
initializeFacade();
}
public function removeProxy(_arg1:String):IProxy{
var _local2:IProxy;
if (model != null){
_local2 = model.removeProxy(_arg1);
};
return (_local2);
}
public function registerProxy(_arg1:IProxy):void{
model.registerProxy(_arg1);
}
protected function initializeController():void{
if (controller != null){
return;
};
controller = Controller.getInstance();
}
protected function initializeFacade():void{
initializeModel();
initializeController();
initializeView();
}
public function retrieveProxy(_arg1:String):IProxy{
return (model.retrieveProxy(_arg1));
}
public function sendNotification(_arg1:String, _arg2:Object=null, _arg3:String=null):void{
notifyObservers(new Notification(_arg1, _arg2, _arg3));
}
public function notifyObservers(_arg1:INotification):void{
if (view != null){
view.notifyObservers(_arg1);
};
}
protected function initializeView():void{
if (view != null){
return;
};
view = View.getInstance();
}
public function retrieveMediator(_arg1:String):IMediator{
return ((view.retrieveMediator(_arg1) as IMediator));
}
public function removeMediator(_arg1:String):IMediator{
var _local2:IMediator;
if (view != null){
_local2 = view.removeMediator(_arg1);
};
return (_local2);
}
public function hasCommand(_arg1:String):Boolean{
return (controller.hasCommand(_arg1));
}
public function removeCommand(_arg1:String):void{
controller.removeCommand(_arg1);
}
public function registerCommand(_arg1:String, _arg2:Class):void{
controller.registerCommand(_arg1, _arg2);
}
public function hasMediator(_arg1:String):Boolean{
return (view.hasMediator(_arg1));
}
public function registerMediator(_arg1:IMediator):void{
if (view != null){
view.registerMediator(_arg1);
};
}
protected function initializeModel():void{
if (model != null){
return;
};
model = Model.getInstance();
}
public function hasProxy(_arg1:String):Boolean{
return (model.hasProxy(_arg1));
}
public static function getInstance():IFacade{
if (instance == null){
instance = new (Facade);
};
return (instance);
}
}
}//package org.puremvc.as3.patterns.facade
Section 288
//Mediator (org.puremvc.as3.patterns.mediator.Mediator)
package org.puremvc.as3.patterns.mediator {
import org.puremvc.as3.interfaces.*;
import org.puremvc.as3.patterns.observer.*;
public class Mediator extends Notifier implements IMediator, INotifier {
protected var viewComponent:Object;
protected var mediatorName:String;
public static const NAME:String = "Mediator";
public function Mediator(_arg1:String=null, _arg2:Object=null){
this.mediatorName = ((_arg1)!=null) ? _arg1 : NAME;
this.viewComponent = _arg2;
}
public function listNotificationInterests():Array{
return ([]);
}
public function onRegister():void{
}
public function onRemove():void{
}
public function getViewComponent():Object{
return (viewComponent);
}
public function handleNotification(_arg1:INotification):void{
}
public function getMediatorName():String{
return (mediatorName);
}
public function setViewComponent(_arg1:Object):void{
this.viewComponent = _arg1;
}
}
}//package org.puremvc.as3.patterns.mediator
Section 289
//Notification (org.puremvc.as3.patterns.observer.Notification)
package org.puremvc.as3.patterns.observer {
import org.puremvc.as3.interfaces.*;
public class Notification implements INotification {
private var body:Object;
private var name:String;
private var type:String;
public function Notification(_arg1:String, _arg2:Object=null, _arg3:String=null){
this.name = _arg1;
this.body = _arg2;
this.type = _arg3;
}
public function setBody(_arg1:Object):void{
this.body = _arg1;
}
public function getName():String{
return (name);
}
public function toString():String{
var _local1:String = ("Notification Name: " + getName());
_local1 = (_local1 + ("\nBody:" + ((body)==null) ? "null" : body.toString()));
_local1 = (_local1 + ("\nType:" + ((type)==null) ? "null" : type));
return (_local1);
}
public function getType():String{
return (type);
}
public function setType(_arg1:String):void{
this.type = _arg1;
}
public function getBody():Object{
return (body);
}
}
}//package org.puremvc.as3.patterns.observer
Section 290
//Notifier (org.puremvc.as3.patterns.observer.Notifier)
package org.puremvc.as3.patterns.observer {
import org.puremvc.as3.interfaces.*;
import org.puremvc.as3.patterns.facade.*;
public class Notifier implements INotifier {
protected var facade:IFacade;
public function Notifier(){
facade = Facade.getInstance();
super();
}
public function sendNotification(_arg1:String, _arg2:Object=null, _arg3:String=null):void{
facade.sendNotification(_arg1, _arg2, _arg3);
}
}
}//package org.puremvc.as3.patterns.observer
Section 291
//Observer (org.puremvc.as3.patterns.observer.Observer)
package org.puremvc.as3.patterns.observer {
import org.puremvc.as3.interfaces.*;
public class Observer implements IObserver {
private var notify:Function;
private var context:Object;
public function Observer(_arg1:Function, _arg2:Object){
setNotifyMethod(_arg1);
setNotifyContext(_arg2);
}
private function getNotifyMethod():Function{
return (notify);
}
public function compareNotifyContext(_arg1:Object):Boolean{
return ((_arg1 === this.context));
}
public function setNotifyContext(_arg1:Object):void{
context = _arg1;
}
private function getNotifyContext():Object{
return (context);
}
public function setNotifyMethod(_arg1:Function):void{
notify = _arg1;
}
public function notifyObserver(_arg1:INotification):void{
this.getNotifyMethod().apply(this.getNotifyContext(), [_arg1]);
}
}
}//package org.puremvc.as3.patterns.observer
Section 292
//Proxy (org.puremvc.as3.patterns.proxy.Proxy)
package org.puremvc.as3.patterns.proxy {
import org.puremvc.as3.interfaces.*;
import org.puremvc.as3.patterns.observer.*;
public class Proxy extends Notifier implements IProxy, INotifier {
protected var proxyName:String;
protected var data:Object;
public static var NAME:String = "Proxy";
public function Proxy(_arg1:String=null, _arg2:Object=null){
this.proxyName = ((_arg1)!=null) ? _arg1 : NAME;
if (_arg2 != null){
setData(_arg2);
};
}
public function getData():Object{
return (data);
}
public function getProxyName():String{
return (proxyName);
}
public function setData(_arg1:Object):void{
this.data = _arg1;
}
}
}//package org.puremvc.as3.patterns.proxy
Section 293
//NotDopplerButton (preloader.NotDopplerButton)
package preloader {
import flash.events.*;
import flash.display.*;
import caurina.transitions.*;
import flash.net.*;
public class NotDopplerButton {
private var transitionTime:Number;
private var url:String;
private var window:Sprite;
private var transitionDistance:Number;
private var innerNot2:Sprite;
private var innerDoppler:Sprite;
private var innerDoppler2:Sprite;
private var innerNot:Sprite;
public function NotDopplerButton(_arg1:Sprite, _arg2:String):void{
this.window = _arg1;
this.url = _arg2;
init();
}
private function rollOutHandler(_arg1:MouseEvent):void{
var _local2:Number = ((innerNot.y / transitionDistance) * transitionTime);
Tweener.addTween(innerNot, {y:0, time:_local2, transition:"linear"});
Tweener.addTween(innerDoppler, {y:0, time:_local2, transition:"linear"});
Tweener.addTween(innerNot2, {y:-(transitionDistance), time:_local2, transition:"linear"});
Tweener.addTween(innerDoppler2, {y:transitionDistance, time:_local2, transition:"linear"});
}
private function clickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(url), "_blank");
}
private function rollOverHandler(_arg1:MouseEvent):void{
var _local2:Number = (((transitionDistance - innerNot.y) / transitionDistance) * transitionTime);
Tweener.addTween(innerNot, {y:transitionDistance, time:_local2, transition:"linear"});
Tweener.addTween(innerDoppler, {y:-(transitionDistance), time:_local2, transition:"linear"});
Tweener.addTween(innerNot2, {y:0, time:_local2, transition:"linear"});
Tweener.addTween(innerDoppler2, {y:0, time:_local2, transition:"linear"});
}
private function init():void{
innerNot = (window.getChildByName("innerNot") as Sprite);
innerDoppler = (window.getChildByName("innerDoppler") as Sprite);
innerNot2 = (window.getChildByName("innerNot2") as Sprite);
innerDoppler2 = (window.getChildByName("innerDoppler2") as Sprite);
transitionTime = 0.2;
transitionDistance = 22;
window.buttonMode = true;
window.addEventListener(MouseEvent.CLICK, clickHandler);
window.addEventListener(MouseEvent.ROLL_OVER, rollOverHandler);
window.addEventListener(MouseEvent.ROLL_OUT, rollOutHandler);
}
}
}//package preloader
Section 294
//ApplicationFacade (ApplicationFacade)
package {
import org.puremvc.as3.interfaces.*;
import flash.display.*;
import org.puremvc.as3.patterns.facade.*;
import org.puremvc.as3.patterns.observer.*;
import game.controller.*;
public class ApplicationFacade extends Facade implements IFacade {
public var viewContainer:Sprite;
public static const STARTUP:String = "Startup";
override protected function initializeController():void{
super.initializeController();
registerCommand(STARTUP, StartupCommand);
}
public function startup(_arg1:Object):void{
var _local2:Sprite = _arg1.container;
viewContainer = new Sprite();
_local2.addChild(viewContainer);
notifyObservers(new Notification(STARTUP, _arg1));
}
public static function getInstance():ApplicationFacade{
if (instance == null){
instance = new (ApplicationFacade);
};
return ((instance as ApplicationFacade));
}
}
}//package
Section 295
//MochiBot (MochiBot)
package {
import flash.display.*;
import flash.net.*;
import flash.system.*;
public dynamic class MochiBot extends Sprite {
public static function track(_arg1:Sprite, _arg2:String):MochiBot{
if (Security.sandboxType == "localWithFile"){
return (null);
};
var _local3:MochiBot = new (MochiBot);
_arg1.addChild(_local3);
Security.allowDomain("*");
Security.allowInsecureDomain("*");
var _local4 = "http://core.mochibot.com/my/core.swf";
var _local5:URLVariables = new URLVariables();
_local5["sb"] = Security.sandboxType;
_local5["v"] = Capabilities.version;
_local5["swfid"] = _arg2;
_local5["mv"] = "8";
_local5["fv"] = "9";
var _local6:String = _local3.root.loaderInfo.loaderURL;
if (_local6.indexOf("http") == 0){
_local5["url"] = _local6;
} else {
_local5["url"] = "local";
};
var _local7:URLRequest = new URLRequest(_local4);
_local7.contentType = "application/x-www-form-urlencoded";
_local7.method = URLRequestMethod.POST;
_local7.data = _local5;
var _local8:Loader = new Loader();
_local3.addChild(_local8);
_local8.load(_local7);
return (_local3);
}
}
}//package
Section 296
//Preloader (Preloader)
package {
import flash.events.*;
import flash.display.*;
import caurina.transitions.*;
import preloader.*;
import flash.text.*;
import CPMStar.*;
import flash.ui.*;
import flash.net.*;
import flash.utils.*;
public class Preloader extends MovieClip {
private var prevProgress:Number;
private var PreloaderClass:Class;
private var arrow:Sprite;
private var box:MovieClip;
private var sponsor_bt:NotDopplerButton;
private var downloadHere_bt:SimpleButton;
private var timeMult:Number;
private var _containerSprite:Sprite;
private var _percentLoaded:Number;
private var percent_tf:TextField;
private var _infoField:TextField;
private var adsContainer:Sprite;
private var progressBarHolder:Sprite;
private var CPMStarContentSpotID:String;// = "2616Q897DCA86"
private var playHere_bt:SimpleButton;
private var back:Sprite;
private var siteLocked:Sprite;
private var play_bt:SimpleButton;
public static const MOCHI_PRELOADER_SPONSOR_LOGO:String = "http://www.notdoppler.com/?ref=wakeupthebox2";
public static const DEBUG:Boolean = false;
public static const SITE_URL:String = "http://www.notdoppler.com/?ref=wakeupthebox2";
public static var DOMAIN_OLOLOGAMES:Boolean = false;
public static var kongregate;
public static var DOMAIN_LOCAL:Boolean = false;
public static var DOMAIN_NOTDOPPLER:Boolean = false;
public static var DOMAIN_KONG:Boolean = false;
public static var DOMAIN_ARMORGAMES:Boolean = false;
public function Preloader(){
var _local4:DisplayObject;
PreloaderClass = Preloader_PreloaderClass;
super();
_containerSprite = (new PreloaderClass() as Sprite);
addChild(_containerSprite);
progressBarHolder = (_containerSprite.getChildByName("progressBarHolder") as Sprite);
percent_tf = (progressBarHolder.getChildByName("percent_tf") as TextField);
arrow = (progressBarHolder.getChildByName("arrow") as Sprite);
adsContainer = (_containerSprite.getChildByName("adsContainer") as MovieClip);
box = (progressBarHolder.getChildByName("box") as MovieClip);
back = (_containerSprite.getChildByName("back") as Sprite);
siteLocked = (_containerSprite.getChildByName("siteLocked") as Sprite);
playHere_bt = (siteLocked.getChildByName("playHere_bt") as SimpleButton);
downloadHere_bt = (siteLocked.getChildByName("downloadHere_bt") as SimpleButton);
progressBarHolder.visible = false;
play_bt = (_containerSprite.getChildByName("play_bt") as SimpleButton);
var _local1:Sprite = (_containerSprite.getChildByName("sponsor") as Sprite);
sponsor_bt = new NotDopplerButton(_local1, MOCHI_PRELOADER_SPONSOR_LOGO);
var _local2:ContextMenu = new ContextMenu();
_local2.hideBuiltInItems();
contextMenu = _local2;
checkDomain();
prevProgress = 0;
adsContainer.visible = false;
play_bt.addEventListener(MouseEvent.CLICK, playClickHandler);
MochiBot.track(this, "5d3b9b7e");
box.stop();
play_bt.visible = false;
timeMult = (DEBUG) ? 0.1 : 1;
addEventListener(Event.ENTER_FRAME, efHandler);
var _local3:Boolean;
if (((DOMAIN_OLOLOGAMES) || (DOMAIN_NOTDOPPLER))){
_local3 = true;
};
if (DEBUG){
if (DOMAIN_LOCAL){
_local3 = true;
};
};
siteLocked.visible = false;
progressBarHolder.visible = true;
loaderInfo.addEventListener(ProgressEvent.PROGRESS, onRootLoaderProgress);
loaderInfo.addEventListener(Event.COMPLETE, onRootLoaderComplete);
if (DOMAIN_NOTDOPPLER){
adsContainer.visible = false;
} else {
adsContainer.visible = true;
_local4 = new AdLoader(CPMStarContentSpotID);
adsContainer.addChild(_local4);
};
if (DOMAIN_KONG){
initKongAPI();
};
}
private function updateProgress(_arg1:Number):void{
prevProgress = _arg1;
var _local2:Number = arrow.x;
var _local3:Number = (20 + ((400 - 20) * _percentLoaded));
var _local4:Number = (((_local3 - _local2) / 100) * timeMult);
Tweener.addTween(arrow, {x:_local3, time:_local4, transition:"easeoutquad"});
}
private function onRootLoaderComplete(_arg1:Event):void{
updateProgress(1);
}
private function playHereClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.notdoppler.com/wakeupthebox2.php"), "_blank");
}
private function initKongAPI():void{
var _local1:Object = LoaderInfo(root.loaderInfo).parameters;
var _local2:String = ((_local1.api_path) || ("http://www.kongregate.com/flash/API_AS3_Local.swf"));
trace(("API path: " + _local2));
var _local3:URLRequest = new URLRequest(_local2);
var _local4:Loader = new Loader();
_local4.contentLoaderInfo.addEventListener(Event.COMPLETE, kongAPILoadComplete);
_local4.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, kongAPIErrorHandler);
_local4.load(_local3);
this.addChild(_local4);
}
private function adsCompleteHandler():void{
trace("ADS COMPLETE");
onRootLoaderComplete(null);
}
private function kongAPILoadComplete(_arg1:Event):void{
kongregate = _arg1.target.content;
kongregate.services.connect();
trace(("\n" + kongregate.services));
trace(("\n" + kongregate.user));
trace(("\n" + kongregate.scores));
trace(("\n" + kongregate.stats));
}
private function playClickHandler(_arg1:MouseEvent):void{
var _local3:Object;
removeChild(_containerSprite);
loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onRootLoaderProgress);
loaderInfo.removeEventListener(Event.COMPLETE, onRootLoaderComplete);
nextFrame();
var _local2:Class = Class(getDefinitionByName("WakeUpTheBox2"));
if (_local2){
_local3 = new (_local2);
addChild((_local3 as DisplayObject));
};
}
private function onRootLoaderProgress(_arg1:ProgressEvent):void{
var _local2:Number = _arg1.target.bytesLoaded;
var _local3:Number = _arg1.target.bytesTotal;
_percentLoaded = (_local2 / _local3);
updateProgress(_percentLoaded);
}
private function efHandler(_arg1:Event):void{
var _local2:Number = (arrow.x / 380);
percent_tf.text = (Math.floor((_local2 * 100)).toString() + "%");
if (arrow.x > 310){
if (arrow.x < 380){
box.gotoAndStop(2);
box.x = (arrow.x + 40);
} else {
play_bt.visible = true;
box.gotoAndStop(3);
removeEventListener(Event.ENTER_FRAME, efHandler);
Tweener.addTween(box, {y:(box.y + 150), x:(box.x + 50), time:1, rotation:179, transition:"easeinquad"});
};
};
}
private function backClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(SITE_URL));
}
private function checkDomain():void{
var _local1:String = stage.loaderInfo.url;
var _local2:Number = (_local1.indexOf("://") + 3);
var _local3:Number = _local1.indexOf("/", _local2);
var _local4:String = _local1.substring(_local2, _local3);
var _local5:Number = (_local4.lastIndexOf(".") - 1);
var _local6:Number = (_local4.lastIndexOf(".", _local5) + 1);
_local4 = _local4.substring(_local6, _local4.length);
if ((((_local4 == "")) || ((_local4 == "localhost")))){
DOMAIN_LOCAL = true;
};
if ((((_local4 == "isfland.com")) || ((_local4 == "olologames.com")))){
DOMAIN_OLOLOGAMES = true;
};
if (_local4 == "armorgames.com"){
DOMAIN_ARMORGAMES = true;
};
if (_local4 == "notdoppler.com"){
DOMAIN_NOTDOPPLER = true;
};
DOMAIN_KONG = ((_local4 == "kongregate.com")) ? true : false;
}
private function downloadHereClickHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.notdoppler.com/webmasters.php"), "_blank");
}
private function kongAPIErrorHandler(_arg1:IOErrorEvent):void{
trace("ZZ", _arg1.text);
}
}
}//package
Section 297
//Preloader_PreloaderClass (Preloader_PreloaderClass)
package {
import flash.display.*;
import mx.core.*;
public class Preloader_PreloaderClass extends SpriteAsset {
public var arrow:DisplayObject;
public var box:DisplayObject;
public var downloadHere_bt:DisplayObject;
public var sponsor:DisplayObject;
public var innerDoppler2:DisplayObject;
public var innerNot:DisplayObject;
public var back:DisplayObject;
public var percent_tf:DisplayObject;
public var playHere_bt:DisplayObject;
public var siteLocked:DisplayObject;
public var progressBarHolder:DisplayObject;
public var innerNot2:DisplayObject;
public var adsContainer:DisplayObject;
public var play_bt:DisplayObject;
public var innerDoppler:DisplayObject;
}
}//package
Section 298
//WakeUpTheBox2 (WakeUpTheBox2)
package {
import flash.events.*;
import flash.display.*;
public class WakeUpTheBox2 extends Sprite {
public function WakeUpTheBox2():void{
addEventListener(Event.ADDED_TO_STAGE, addedHandler);
}
private function addedHandler(_arg1:Event):void{
ApplicationFacade.getInstance().startup({container:this});
}
}
}//package