Section 1
//MultiCloud_98 (ArtAssets_fla.MultiCloud_98)
package ArtAssets_fla {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class MultiCloud_98 extends MovieClip {
public var randomStartingFrame:int;
public function MultiCloud_98(){
addFrameScript(0, frame1);
}
function frame1(){
randomStartingFrame = (Math.round((Math.random() * (4 - 1))) + 1);
gotoAndStop(randomStartingFrame);
}
}
}//package ArtAssets_fla
Section 2
//b2BoxDef (Box2D.Collision.Shapes.b2BoxDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
public class b2BoxDef extends b2ShapeDef {
public var extents:b2Vec2;
public function b2BoxDef(){
super();
type = b2Shape.e_boxShape;
extents = new b2Vec2(1, 1);
}
}
}//package Box2D.Collision.Shapes
Section 3
//b2CircleDef (Box2D.Collision.Shapes.b2CircleDef)
package Box2D.Collision.Shapes {
public class b2CircleDef extends b2ShapeDef {
public var radius:Number;
public function b2CircleDef(){
super();
type = b2Shape.e_circleShape;
radius = 1;
}
}
}//package Box2D.Collision.Shapes
Section 4
//b2CircleShape (Box2D.Collision.Shapes.b2CircleShape)
package Box2D.Collision.Shapes {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.Math.*;
public class b2CircleShape extends b2Shape {
public var m_localPosition:b2Vec2;
public var m_radius:Number;
public function b2CircleShape(def:b2ShapeDef, body:b2Body, localCenter:b2Vec2){
var rX:Number;
var rY:Number;
m_localPosition = new b2Vec2();
super(def, body);
var circle:b2CircleDef = (def as b2CircleDef);
m_localPosition.Set((def.localPosition.x - localCenter.x), (def.localPosition.y - localCenter.y));
m_type = b2Shape.e_circleShape;
m_radius = circle.radius;
m_R.SetM(m_body.m_R);
rX = ((m_R.col1.x * m_localPosition.x) + (m_R.col2.x * m_localPosition.y));
rY = ((m_R.col1.y * m_localPosition.x) + (m_R.col2.y * m_localPosition.y));
m_position.x = (m_body.m_position.x + rX);
m_position.y = (m_body.m_position.y + rY);
m_maxRadius = (Math.sqrt(((rX * rX) + (rY * rY))) + m_radius);
var aabb:b2AABB = new b2AABB();
aabb.minVertex.Set((m_position.x - m_radius), (m_position.y - m_radius));
aabb.maxVertex.Set((m_position.x + m_radius), (m_position.y + m_radius));
var broadPhase:b2BroadPhase = m_body.m_world.m_broadPhase;
if (broadPhase.InRange(aabb)){
m_proxyId = broadPhase.CreateProxy(aabb, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
if (m_proxyId == b2Pair.b2_nullProxy){
m_body.Freeze();
};
}
override public function Synchronize(position1:b2Vec2, R1:b2Mat22, position2:b2Vec2, R2:b2Mat22):void{
m_R.SetM(R2);
m_position.x = (((R2.col1.x * m_localPosition.x) + (R2.col2.x * m_localPosition.y)) + position2.x);
m_position.y = (((R2.col1.y * m_localPosition.x) + (R2.col2.y * m_localPosition.y)) + position2.y);
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
var p1X:Number = (position1.x + ((R1.col1.x * m_localPosition.x) + (R1.col2.x * m_localPosition.y)));
var p1Y:Number = (position1.y + ((R1.col1.y * m_localPosition.x) + (R1.col2.y * m_localPosition.y)));
var lowerX:Number = Math.min(p1X, m_position.x);
var lowerY:Number = Math.min(p1Y, m_position.y);
var upperX:Number = Math.max(p1X, m_position.x);
var upperY:Number = Math.max(p1Y, m_position.y);
var aabb:b2AABB = new b2AABB();
aabb.minVertex.Set((lowerX - m_radius), (lowerY - m_radius));
aabb.maxVertex.Set((upperX + m_radius), (upperY + m_radius));
var broadPhase:b2BroadPhase = m_body.m_world.m_broadPhase;
if (broadPhase.InRange(aabb)){
broadPhase.MoveProxy(m_proxyId, aabb);
} else {
m_body.Freeze();
};
}
override public function Support(dX:Number, dY:Number, out:b2Vec2):void{
var len:Number = Math.sqrt(((dX * dX) + (dY * dY)));
dX = (dX / len);
dY = (dY / len);
out.Set((m_position.x + (m_radius * dX)), (m_position.y + (m_radius * dY)));
}
override public function QuickSync(position:b2Vec2, R:b2Mat22):void{
m_R.SetM(R);
m_position.x = (((R.col1.x * m_localPosition.x) + (R.col2.x * m_localPosition.y)) + position.x);
m_position.y = (((R.col1.y * m_localPosition.x) + (R.col2.y * m_localPosition.y)) + position.y);
}
override public function TestPoint(p:b2Vec2):Boolean{
var d:b2Vec2 = new b2Vec2();
d.SetV(p);
d.Subtract(m_position);
return ((b2Math.b2Dot(d, d) <= (m_radius * m_radius)));
}
override public function ResetProxy(broadPhase:b2BroadPhase):void{
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
var proxy:b2Proxy = broadPhase.GetProxy(m_proxyId);
broadPhase.DestroyProxy(m_proxyId);
proxy = null;
var aabb:b2AABB = new b2AABB();
aabb.minVertex.Set((m_position.x - m_radius), (m_position.y - m_radius));
aabb.maxVertex.Set((m_position.x + m_radius), (m_position.y + m_radius));
if (broadPhase.InRange(aabb)){
m_proxyId = broadPhase.CreateProxy(aabb, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
if (m_proxyId == b2Pair.b2_nullProxy){
m_body.Freeze();
};
}
}
}//package Box2D.Collision.Shapes
Section 5
//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 6
//b2PolyDef (Box2D.Collision.Shapes.b2PolyDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PolyDef extends b2ShapeDef {
public var vertices:Array;
public var vertexCount:int;
public function b2PolyDef(){
vertices = new Array(b2Settings.b2_maxPolyVertices);
super();
type = b2Shape.e_polyShape;
vertexCount = 0;
var i:int;
while (i < b2Settings.b2_maxPolyVertices) {
vertices[i] = new b2Vec2();
i++;
};
}
}
}//package Box2D.Collision.Shapes
Section 7
//b2PolyShape (Box2D.Collision.Shapes.b2PolyShape)
package Box2D.Collision.Shapes {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PolyShape extends b2Shape {
public var m_vertexCount:int;
private var syncMat:b2Mat22;
public var m_vertices:Array;
public var m_coreVertices:Array;
public var m_localCentroid:b2Vec2;
public var m_normals:Array;
private var syncAABB:b2AABB;
public var m_localOBB:b2OBB;
private static var tempVec:b2Vec2 = new b2Vec2();
private static var tAbsR:b2Mat22 = new b2Mat22();
public function b2PolyShape(def:b2ShapeDef, body:b2Body, newOrigin:b2Vec2){
var i:int;
var hX:Number;
var hY:Number;
var tVec:b2Vec2;
var aabb:b2AABB;
var localR:b2Mat22;
var i1:int;
var i2:int;
var box:b2BoxDef;
var hcX:Number;
var hcY:Number;
var poly:b2PolyDef;
var centroidX:Number;
var centroidY:Number;
var uX:Number;
var uY:Number;
var length:Number;
var v:b2Vec2;
syncAABB = new b2AABB();
syncMat = new b2Mat22();
m_localCentroid = new b2Vec2();
m_localOBB = new b2OBB();
super(def, body);
aabb = new b2AABB();
m_vertices = new Array(b2Settings.b2_maxPolyVertices);
m_coreVertices = new Array(b2Settings.b2_maxPolyVertices);
m_normals = new Array(b2Settings.b2_maxPolyVertices);
m_type = b2Shape.e_polyShape;
localR = new b2Mat22(def.localRotation);
if (def.type == b2Shape.e_boxShape){
m_localCentroid.x = (def.localPosition.x - newOrigin.x);
m_localCentroid.y = (def.localPosition.y - newOrigin.y);
box = (def as b2BoxDef);
m_vertexCount = 4;
hX = box.extents.x;
hY = box.extents.y;
hcX = Math.max(0, (hX - (2 * b2Settings.b2_linearSlop)));
hcY = Math.max(0, (hY - (2 * b2Settings.b2_linearSlop)));
tVec = (m_vertices[0] = new b2Vec2());
tVec.x = ((localR.col1.x * hX) + (localR.col2.x * hY));
tVec.y = ((localR.col1.y * hX) + (localR.col2.y * hY));
tVec = (m_vertices[1] = new b2Vec2());
tVec.x = ((localR.col1.x * -(hX)) + (localR.col2.x * hY));
tVec.y = ((localR.col1.y * -(hX)) + (localR.col2.y * hY));
tVec = (m_vertices[2] = new b2Vec2());
tVec.x = ((localR.col1.x * -(hX)) + (localR.col2.x * -(hY)));
tVec.y = ((localR.col1.y * -(hX)) + (localR.col2.y * -(hY)));
tVec = (m_vertices[3] = new b2Vec2());
tVec.x = ((localR.col1.x * hX) + (localR.col2.x * -(hY)));
tVec.y = ((localR.col1.y * hX) + (localR.col2.y * -(hY)));
tVec = (m_coreVertices[0] = new b2Vec2());
tVec.x = ((localR.col1.x * hcX) + (localR.col2.x * hcY));
tVec.y = ((localR.col1.y * hcX) + (localR.col2.y * hcY));
tVec = (m_coreVertices[1] = new b2Vec2());
tVec.x = ((localR.col1.x * -(hcX)) + (localR.col2.x * hcY));
tVec.y = ((localR.col1.y * -(hcX)) + (localR.col2.y * hcY));
tVec = (m_coreVertices[2] = new b2Vec2());
tVec.x = ((localR.col1.x * -(hcX)) + (localR.col2.x * -(hcY)));
tVec.y = ((localR.col1.y * -(hcX)) + (localR.col2.y * -(hcY)));
tVec = (m_coreVertices[3] = new b2Vec2());
tVec.x = ((localR.col1.x * hcX) + (localR.col2.x * -(hcY)));
tVec.y = ((localR.col1.y * hcX) + (localR.col2.y * -(hcY)));
} else {
poly = (def as b2PolyDef);
m_vertexCount = poly.vertexCount;
PolyCentroid(poly.vertices, poly.vertexCount, tempVec);
centroidX = tempVec.x;
centroidY = tempVec.y;
m_localCentroid.x = ((def.localPosition.x + ((localR.col1.x * centroidX) + (localR.col2.x * centroidY))) - newOrigin.x);
m_localCentroid.y = ((def.localPosition.y + ((localR.col1.y * centroidX) + (localR.col2.y * centroidY))) - newOrigin.y);
i = 0;
while (i < m_vertexCount) {
m_vertices[i] = new b2Vec2();
m_coreVertices[i] = new b2Vec2();
hX = (poly.vertices[i].x - centroidX);
hY = (poly.vertices[i].y - centroidY);
m_vertices[i].x = ((localR.col1.x * hX) + (localR.col2.x * hY));
m_vertices[i].y = ((localR.col1.y * hX) + (localR.col2.y * hY));
uX = m_vertices[i].x;
uY = m_vertices[i].y;
length = Math.sqrt(((uX * uX) + (uY * uY)));
if (length > Number.MIN_VALUE){
uX = (uX * (1 / length));
uY = (uY * (1 / length));
};
m_coreVertices[i].x = (m_vertices[i].x - ((2 * b2Settings.b2_linearSlop) * uX));
m_coreVertices[i].y = (m_vertices[i].y - ((2 * b2Settings.b2_linearSlop) * uY));
i++;
};
};
var minVertexX:Number = Number.MAX_VALUE;
var minVertexY:Number = Number.MAX_VALUE;
var maxVertexX:Number = -(Number.MAX_VALUE);
var maxVertexY:Number = -(Number.MAX_VALUE);
m_maxRadius = 0;
i = 0;
while (i < m_vertexCount) {
v = m_vertices[i];
minVertexX = Math.min(minVertexX, v.x);
minVertexY = Math.min(minVertexY, v.y);
maxVertexX = Math.max(maxVertexX, v.x);
maxVertexY = Math.max(maxVertexY, v.y);
m_maxRadius = Math.max(m_maxRadius, v.Length());
i++;
};
m_localOBB.R.SetIdentity();
m_localOBB.center.Set(((minVertexX + maxVertexX) * 0.5), ((minVertexY + maxVertexY) * 0.5));
m_localOBB.extents.Set(((maxVertexX - minVertexX) * 0.5), ((maxVertexY - minVertexY) * 0.5));
i = 0;
while (i < m_vertexCount) {
m_normals[i] = new b2Vec2();
i1 = i;
i2 = (((i + 1) < m_vertexCount)) ? (i + 1) : 0;
m_normals[i].x = (m_vertices[i2].y - m_vertices[i1].y);
m_normals[i].y = -((m_vertices[i2].x - m_vertices[i1].x));
m_normals[i].Normalize();
i++;
};
i = 0;
while (i < m_vertexCount) {
i1 = i;
i2 = (((i + 1) < m_vertexCount)) ? (i + 1) : 0;
i++;
};
m_R.SetM(m_body.m_R);
m_position.x = (m_body.m_position.x + ((m_R.col1.x * m_localCentroid.x) + (m_R.col2.x * m_localCentroid.y)));
m_position.y = (m_body.m_position.y + ((m_R.col1.y * m_localCentroid.x) + (m_R.col2.y * m_localCentroid.y)));
tAbsR.col1.x = ((m_R.col1.x * m_localOBB.R.col1.x) + (m_R.col2.x * m_localOBB.R.col1.y));
tAbsR.col1.y = ((m_R.col1.y * m_localOBB.R.col1.x) + (m_R.col2.y * m_localOBB.R.col1.y));
tAbsR.col2.x = ((m_R.col1.x * m_localOBB.R.col2.x) + (m_R.col2.x * m_localOBB.R.col2.y));
tAbsR.col2.y = ((m_R.col1.y * m_localOBB.R.col2.x) + (m_R.col2.y * m_localOBB.R.col2.y));
tAbsR.Abs();
hX = ((tAbsR.col1.x * m_localOBB.extents.x) + (tAbsR.col2.x * m_localOBB.extents.y));
hY = ((tAbsR.col1.y * m_localOBB.extents.x) + (tAbsR.col2.y * m_localOBB.extents.y));
var positionX:Number = (m_position.x + ((m_R.col1.x * m_localOBB.center.x) + (m_R.col2.x * m_localOBB.center.y)));
var positionY:Number = (m_position.y + ((m_R.col1.y * m_localOBB.center.x) + (m_R.col2.y * m_localOBB.center.y)));
aabb.minVertex.x = (positionX - hX);
aabb.minVertex.y = (positionY - hY);
aabb.maxVertex.x = (positionX + hX);
aabb.maxVertex.y = (positionY + hY);
var broadPhase:b2BroadPhase = m_body.m_world.m_broadPhase;
if (broadPhase.InRange(aabb)){
m_proxyId = broadPhase.CreateProxy(aabb, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
if (m_proxyId == b2Pair.b2_nullProxy){
m_body.Freeze();
};
}
override public function QuickSync(position:b2Vec2, R:b2Mat22):void{
m_R.SetM(R);
m_position.x = (position.x + ((R.col1.x * m_localCentroid.x) + (R.col2.x * m_localCentroid.y)));
m_position.y = (position.y + ((R.col1.y * m_localCentroid.x) + (R.col2.y * m_localCentroid.y)));
}
override public function Support(dX:Number, dY:Number, out:b2Vec2):void{
var value:Number;
var dLocalX:Number = ((dX * m_R.col1.x) + (dY * m_R.col1.y));
var dLocalY:Number = ((dX * m_R.col2.x) + (dY * m_R.col2.y));
var bestIndex:int;
var bestValue:Number = ((m_coreVertices[0].x * dLocalX) + (m_coreVertices[0].y * dLocalY));
var i = 1;
while (i < m_vertexCount) {
value = ((m_coreVertices[i].x * dLocalX) + (m_coreVertices[i].y * dLocalY));
if (value > bestValue){
bestIndex = i;
bestValue = value;
};
i++;
};
out.Set((m_position.x + ((m_R.col1.x * m_coreVertices[bestIndex].x) + (m_R.col2.x * m_coreVertices[bestIndex].y))), (m_position.y + ((m_R.col1.y * m_coreVertices[bestIndex].x) + (m_R.col2.y * m_coreVertices[bestIndex].y))));
}
override public function Synchronize(position1:b2Vec2, R1:b2Mat22, position2:b2Vec2, R2:b2Mat22):void{
var hX:Number;
var hY:Number;
m_R.SetM(R2);
m_position.x = (m_body.m_position.x + ((R2.col1.x * m_localCentroid.x) + (R2.col2.x * m_localCentroid.y)));
m_position.y = (m_body.m_position.y + ((R2.col1.y * m_localCentroid.x) + (R2.col2.y * m_localCentroid.y)));
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
var v1:b2Vec2 = R1.col1;
var v2:b2Vec2 = R1.col2;
var v3:b2Vec2 = m_localOBB.R.col1;
var v4:b2Vec2 = m_localOBB.R.col2;
syncMat.col1.x = ((v1.x * v3.x) + (v2.x * v3.y));
syncMat.col1.y = ((v1.y * v3.x) + (v2.y * v3.y));
syncMat.col2.x = ((v1.x * v4.x) + (v2.x * v4.y));
syncMat.col2.y = ((v1.y * v4.x) + (v2.y * v4.y));
syncMat.Abs();
hX = (m_localCentroid.x + m_localOBB.center.x);
hY = (m_localCentroid.y + m_localOBB.center.y);
var centerX:Number = (position1.x + ((R1.col1.x * hX) + (R1.col2.x * hY)));
var centerY:Number = (position1.y + ((R1.col1.y * hX) + (R1.col2.y * hY)));
hX = ((syncMat.col1.x * m_localOBB.extents.x) + (syncMat.col2.x * m_localOBB.extents.y));
hY = ((syncMat.col1.y * m_localOBB.extents.x) + (syncMat.col2.y * m_localOBB.extents.y));
syncAABB.minVertex.x = (centerX - hX);
syncAABB.minVertex.y = (centerY - hY);
syncAABB.maxVertex.x = (centerX + hX);
syncAABB.maxVertex.y = (centerY + hY);
v1 = R2.col1;
v2 = R2.col2;
v3 = m_localOBB.R.col1;
v4 = m_localOBB.R.col2;
syncMat.col1.x = ((v1.x * v3.x) + (v2.x * v3.y));
syncMat.col1.y = ((v1.y * v3.x) + (v2.y * v3.y));
syncMat.col2.x = ((v1.x * v4.x) + (v2.x * v4.y));
syncMat.col2.y = ((v1.y * v4.x) + (v2.y * v4.y));
syncMat.Abs();
hX = (m_localCentroid.x + m_localOBB.center.x);
hY = (m_localCentroid.y + m_localOBB.center.y);
centerX = (position2.x + ((R2.col1.x * hX) + (R2.col2.x * hY)));
centerY = (position2.y + ((R2.col1.y * hX) + (R2.col2.y * hY)));
hX = ((syncMat.col1.x * m_localOBB.extents.x) + (syncMat.col2.x * m_localOBB.extents.y));
hY = ((syncMat.col1.y * m_localOBB.extents.x) + (syncMat.col2.y * m_localOBB.extents.y));
syncAABB.minVertex.x = Math.min(syncAABB.minVertex.x, (centerX - hX));
syncAABB.minVertex.y = Math.min(syncAABB.minVertex.y, (centerY - hY));
syncAABB.maxVertex.x = Math.max(syncAABB.maxVertex.x, (centerX + hX));
syncAABB.maxVertex.y = Math.max(syncAABB.maxVertex.y, (centerY + hY));
var broadPhase:b2BroadPhase = m_body.m_world.m_broadPhase;
if (broadPhase.InRange(syncAABB)){
broadPhase.MoveProxy(m_proxyId, syncAABB);
} else {
m_body.Freeze();
};
}
override public function TestPoint(p:b2Vec2):Boolean{
var tVec:b2Vec2;
var dot:Number;
var pLocal:b2Vec2 = new b2Vec2();
pLocal.SetV(p);
pLocal.Subtract(m_position);
pLocal.MulTM(m_R);
var i:int;
while (i < m_vertexCount) {
tVec = new b2Vec2();
tVec.SetV(pLocal);
tVec.Subtract(m_vertices[i]);
dot = b2Math.b2Dot(m_normals[i], tVec);
if (dot > 0){
return (false);
};
i++;
};
return (true);
}
override public function ResetProxy(broadPhase:b2BroadPhase):void{
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
var proxy:b2Proxy = broadPhase.GetProxy(m_proxyId);
broadPhase.DestroyProxy(m_proxyId);
proxy = null;
var R:b2Mat22 = b2Math.b2MulMM(m_R, m_localOBB.R);
var absR:b2Mat22 = b2Math.b2AbsM(R);
var h:b2Vec2 = b2Math.b2MulMV(absR, m_localOBB.extents);
var position:b2Vec2 = b2Math.b2MulMV(m_R, m_localOBB.center);
position.Add(m_position);
var aabb:b2AABB = new b2AABB();
aabb.minVertex.SetV(position);
aabb.minVertex.Subtract(h);
aabb.maxVertex.SetV(position);
aabb.maxVertex.Add(h);
if (broadPhase.InRange(aabb)){
m_proxyId = broadPhase.CreateProxy(aabb, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
if (m_proxyId == b2Pair.b2_nullProxy){
m_body.Freeze();
};
}
}
}//package Box2D.Collision.Shapes
Section 8
//b2Shape (Box2D.Collision.Shapes.b2Shape)
package Box2D.Collision.Shapes {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Shape {
public var m_position:b2Vec2;
public var m_maxRadius:Number;
public var m_next:b2Shape;
public var m_type:int;
public var m_R:b2Mat22;
public var m_friction:Number;
public var m_proxyId:uint;
public var m_maskBits:uint;
public var m_groupIndex:int;
public var m_userData;// = null
public var m_body:b2Body;
public var m_restitution:Number;
public var m_categoryBits:uint;
public static const e_boxShape:int = 1;
public static const e_unknownShape:int = -1;
public static const e_shapeTypeCount:int = 4;
public static const e_circleShape:int = 0;
public static const e_meshShape:int = 3;
public static const e_polyShape:int = 2;
public function b2Shape(def:b2ShapeDef, body:b2Body){
m_R = new b2Mat22();
m_position = new b2Vec2();
super();
m_userData = def.userData;
m_friction = def.friction;
m_restitution = def.restitution;
m_body = body;
m_proxyId = b2Pair.b2_nullProxy;
m_maxRadius = 0;
m_categoryBits = def.categoryBits;
m_maskBits = def.maskBits;
m_groupIndex = def.groupIndex;
}
public function GetMaxRadius():Number{
return (m_maxRadius);
}
public function ResetProxy(broadPhase:b2BroadPhase):void{
}
public function QuickSync(position:b2Vec2, R:b2Mat22):void{
}
public function GetNext():b2Shape{
return (m_next);
}
public function GetType():int{
return (m_type);
}
public function GetUserData(){
return (m_userData);
}
public function Support(dX:Number, dY:Number, out:b2Vec2):void{
}
public function Synchronize(position1:b2Vec2, R1:b2Mat22, position2:b2Vec2, R2:b2Mat22):void{
}
public function GetRotationMatrix():b2Mat22{
return (m_R);
}
public function GetBody():b2Body{
return (m_body);
}
public function DestroyProxy():void{
if (m_proxyId != b2Pair.b2_nullProxy){
m_body.m_world.m_broadPhase.DestroyProxy(m_proxyId);
m_proxyId = b2Pair.b2_nullProxy;
};
}
public function TestPoint(p:b2Vec2):Boolean{
return (false);
}
public function GetPosition():b2Vec2{
return (m_position);
}
public static function Destroy(shape:b2Shape):void{
if (shape.m_proxyId != b2Pair.b2_nullProxy){
shape.m_body.m_world.m_broadPhase.DestroyProxy(shape.m_proxyId);
};
}
public static function PolyMass(massData:b2MassData, vs:Array, count:int, rho:Number):void{
var p1:b2Vec2;
var p2:b2Vec2;
var p3:b2Vec2;
var e1:b2Vec2;
var e2:b2Vec2;
var D:Number;
var triangleArea:Number;
var tVec:b2Vec2;
var px:Number;
var py:Number;
var ex1:Number;
var ey1:Number;
var ex2:Number;
var ey2:Number;
var intx2:Number;
var inty2:Number;
var center:b2Vec2 = new b2Vec2();
center.SetZero();
var area:Number = 0;
var I:Number = 0;
var pRef:b2Vec2 = new b2Vec2(0, 0);
var inv3:Number = (1 / 3);
var i:int;
while (i < count) {
p1 = pRef;
p2 = vs[i];
p3 = (((i + 1) < count)) ? vs[(i + 1)] : vs[0];
e1 = b2Math.SubtractVV(p2, p1);
e2 = b2Math.SubtractVV(p3, p1);
D = b2Math.b2CrossVV(e1, e2);
triangleArea = (0.5 * D);
area = (area + triangleArea);
tVec = new b2Vec2();
tVec.SetV(p1);
tVec.Add(p2);
tVec.Add(p3);
tVec.Multiply((inv3 * triangleArea));
center.Add(tVec);
px = p1.x;
py = p1.y;
ex1 = e1.x;
ey1 = e1.y;
ex2 = e2.x;
ey2 = e2.y;
intx2 = ((inv3 * ((0.25 * (((ex1 * ex1) + (ex2 * ex1)) + (ex2 * ex2))) + ((px * ex1) + (px * ex2)))) + ((0.5 * px) * px));
inty2 = ((inv3 * ((0.25 * (((ey1 * ey1) + (ey2 * ey1)) + (ey2 * ey2))) + ((py * ey1) + (py * ey2)))) + ((0.5 * py) * py));
I = (I + (D * (intx2 + inty2)));
i++;
};
massData.mass = (rho * area);
center.Multiply((1 / area));
massData.center = center;
I = (rho * (I - (area * b2Math.b2Dot(center, center))));
massData.I = I;
}
public static function PolyCentroid(vs:Array, count:int, out:b2Vec2):void{
var p1X:Number;
var p1Y:Number;
var p2X:Number;
var p2Y:Number;
var p3X:Number;
var p3Y:Number;
var e1X:Number;
var e1Y:Number;
var e2X:Number;
var e2Y:Number;
var D:Number;
var triangleArea:Number;
var cX:Number = 0;
var cY:Number = 0;
var area:Number = 0;
var pRefX:Number = 0;
var pRefY:Number = 0;
var inv3:Number = (1 / 3);
var i:int;
while (i < count) {
p1X = pRefX;
p1Y = pRefY;
p2X = vs[i].x;
p2Y = vs[i].y;
p3X = (((i + 1) < count)) ? vs[(i + 1)].x : vs[0].x;
p3Y = (((i + 1) < count)) ? vs[(i + 1)].y : vs[0].y;
e1X = (p2X - p1X);
e1Y = (p2Y - p1Y);
e2X = (p3X - p1X);
e2Y = (p3Y - p1Y);
D = ((e1X * e2Y) - (e1Y * e2X));
triangleArea = (0.5 * D);
area = (area + triangleArea);
cX = (cX + ((triangleArea * inv3) * ((p1X + p2X) + p3X)));
cY = (cY + ((triangleArea * inv3) * ((p1Y + p2Y) + p3Y)));
i++;
};
cX = (cX * (1 / area));
cY = (cY * (1 / area));
out.Set(cX, cY);
}
public static function Create(def:b2ShapeDef, body:b2Body, center:b2Vec2):b2Shape{
switch (def.type){
case e_circleShape:
return (new b2CircleShape(def, body, center));
case e_boxShape:
case e_polyShape:
return (new b2PolyShape(def, body, center));
};
return (null);
}
}
}//package Box2D.Collision.Shapes
Section 9
//b2ShapeDef (Box2D.Collision.Shapes.b2ShapeDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2ShapeDef {
public var type:int;
public var groupIndex:int;
public var localPosition:b2Vec2;
public var categoryBits:int;
public var localRotation:Number;
public var density:Number;
public var restitution:Number;
public var userData;// = null
public var maskBits:int;
public var friction:Number;
public function b2ShapeDef(){
super();
type = b2Shape.e_unknownShape;
userData = null;
localPosition = new b2Vec2(0, 0);
localRotation = 0;
friction = 0.2;
restitution = 0;
density = 0;
categoryBits = 1;
maskBits = 0xFFFF;
groupIndex = 0;
}
public function ComputeMass(massData:b2MassData):void{
var circle:b2CircleDef;
var box:b2BoxDef;
var poly:b2PolyDef;
massData.center = new b2Vec2(0, 0);
if (density == 0){
massData.mass = 0;
massData.center.Set(0, 0);
massData.I = 0;
};
switch (type){
case b2Shape.e_circleShape:
circle = (this as b2CircleDef);
massData.mass = (((density * b2Settings.b2_pi) * circle.radius) * circle.radius);
massData.center.Set(0, 0);
massData.I = (((0.5 * massData.mass) * circle.radius) * circle.radius);
break;
case b2Shape.e_boxShape:
box = (this as b2BoxDef);
massData.mass = (((4 * density) * box.extents.x) * box.extents.y);
massData.center.Set(0, 0);
massData.I = ((massData.mass / 3) * b2Math.b2Dot(box.extents, box.extents));
break;
case b2Shape.e_polyShape:
poly = (this as b2PolyDef);
b2Shape.PolyMass(massData, poly.vertices, poly.vertexCount, density);
break;
default:
massData.mass = 0;
massData.center.Set(0, 0);
massData.I = 0;
break;
};
}
}
}//package Box2D.Collision.Shapes
Section 10
//b2AABB (Box2D.Collision.b2AABB)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2AABB {
public var minVertex:b2Vec2;
public var maxVertex:b2Vec2;
public function b2AABB(){
minVertex = new b2Vec2();
maxVertex = new b2Vec2();
super();
}
public function IsValid():Boolean{
var dX:Number = maxVertex.x;
var dY:Number = maxVertex.y;
dX = maxVertex.x;
dY = maxVertex.y;
dX = (dX - minVertex.x);
dY = (dY - minVertex.y);
var valid:Boolean = (((dX >= 0)) && ((dY >= 0)));
valid = ((((valid) && (minVertex.IsValid()))) && (maxVertex.IsValid()));
return (valid);
}
}
}//package Box2D.Collision
Section 11
//b2Bound (Box2D.Collision.b2Bound)
package Box2D.Collision {
public class b2Bound {
public var value:uint;
public var proxyId:uint;
public var stabbingCount:uint;
public function b2Bound(){
super();
}
public function Swap(b:b2Bound):void{
var tempValue:uint = value;
var tempProxyId:uint = proxyId;
var tempStabbingCount:uint = stabbingCount;
value = b.value;
proxyId = b.proxyId;
stabbingCount = b.stabbingCount;
b.value = tempValue;
b.proxyId = tempProxyId;
b.stabbingCount = tempStabbingCount;
}
public function IsLower():Boolean{
return (((value & 1) == 0));
}
public function IsUpper():Boolean{
return (((value & 1) == 1));
}
}
}//package Box2D.Collision
Section 12
//b2BoundValues (Box2D.Collision.b2BoundValues)
package Box2D.Collision {
public class b2BoundValues {
public var lowerValues:Array;
public var upperValues:Array;
public function b2BoundValues(){
lowerValues = [0, 0];
upperValues = [0, 0];
super();
}
}
}//package Box2D.Collision
Section 13
//b2BroadPhase (Box2D.Collision.b2BroadPhase)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2BroadPhase {
public var m_bounds:Array;
public var m_quantizationFactor:b2Vec2;
public var m_worldAABB:b2AABB;
public var m_freeProxy:uint;
public var m_proxyCount:int;
public var m_proxyPool:Array;
public var m_queryResultCount:int;
public var m_pairManager:b2PairManager;
public var m_timeStamp:uint;
public var m_queryResults:Array;
public static const b2_nullEdge:uint = 0xFFFF;
public static const b2_invalid:uint = 0xFFFF;
public static var s_validate:Boolean = false;
public function b2BroadPhase(worldAABB:b2AABB, callback:b2PairCallback){
var i:int;
var tProxy:b2Proxy;
var j:int;
m_pairManager = new b2PairManager();
m_proxyPool = new Array(b2Settings.b2_maxPairs);
m_bounds = new Array((2 * b2Settings.b2_maxProxies));
m_queryResults = new Array(b2Settings.b2_maxProxies);
m_quantizationFactor = new b2Vec2();
super();
m_pairManager.Initialize(this, callback);
m_worldAABB = worldAABB;
m_proxyCount = 0;
i = 0;
while (i < b2Settings.b2_maxProxies) {
m_queryResults[i] = 0;
i++;
};
m_bounds = new Array(2);
i = 0;
while (i < 2) {
m_bounds[i] = new Array((2 * b2Settings.b2_maxProxies));
j = 0;
while (j < (2 * b2Settings.b2_maxProxies)) {
m_bounds[i][j] = new b2Bound();
j++;
};
i++;
};
var dX:Number = worldAABB.maxVertex.x;
var dY:Number = worldAABB.maxVertex.y;
dX = (dX - worldAABB.minVertex.x);
dY = (dY - worldAABB.minVertex.y);
m_quantizationFactor.x = (b2Settings.USHRT_MAX / dX);
m_quantizationFactor.y = (b2Settings.USHRT_MAX / dY);
i = 0;
while (i < (b2Settings.b2_maxProxies - 1)) {
tProxy = new b2Proxy();
m_proxyPool[i] = tProxy;
tProxy.SetNext((i + 1));
tProxy.timeStamp = 0;
tProxy.overlapCount = b2_invalid;
tProxy.userData = null;
i++;
};
tProxy = new b2Proxy();
m_proxyPool[(b2Settings.b2_maxProxies - 1)] = tProxy;
tProxy.SetNext(b2Pair.b2_nullProxy);
tProxy.timeStamp = 0;
tProxy.overlapCount = b2_invalid;
tProxy.userData = null;
m_freeProxy = 0;
m_timeStamp = 1;
m_queryResultCount = 0;
}
public function QueryAABB(aabb:b2AABB, userData, maxCount:int):int{
var lowerIndex:uint;
var upperIndex:uint;
var proxy:b2Proxy;
var lowerValues:Array = new Array();
var upperValues:Array = new Array();
ComputeBounds(lowerValues, upperValues, aabb);
var lowerIndexOut:Array = [lowerIndex];
var upperIndexOut:Array = [upperIndex];
Query(lowerIndexOut, upperIndexOut, lowerValues[0], upperValues[0], m_bounds[0], (2 * m_proxyCount), 0);
Query(lowerIndexOut, upperIndexOut, lowerValues[1], upperValues[1], m_bounds[1], (2 * m_proxyCount), 1);
var count:int;
var i:int;
while ((((i < m_queryResultCount)) && ((count < maxCount)))) {
proxy = m_proxyPool[m_queryResults[i]];
userData[i] = proxy.userData;
i++;
count++;
};
m_queryResultCount = 0;
IncrementTimeStamp();
return (count);
}
public function Commit():void{
m_pairManager.Commit();
}
public function GetProxy(proxyId:int):b2Proxy{
if ((((proxyId == b2Pair.b2_nullProxy)) || ((m_proxyPool[proxyId].IsValid() == false)))){
return (null);
};
return (m_proxyPool[proxyId]);
}
private function IncrementTimeStamp():void{
var i:uint;
if (m_timeStamp == b2Settings.USHRT_MAX){
i = 0;
while (i < b2Settings.b2_maxProxies) {
m_proxyPool[i].timeStamp = 0;
i++;
};
m_timeStamp = 1;
} else {
m_timeStamp++;
};
}
private function Query(lowerQueryOut:Array, upperQueryOut:Array, lowerValue:uint, upperValue:uint, bounds:Array, boundCount:uint, axis:int):void{
var i:int;
var s:int;
var proxy:b2Proxy;
var lowerQuery:uint = BinarySearch(bounds, boundCount, lowerValue);
var upperQuery:uint = BinarySearch(bounds, boundCount, upperValue);
var j:uint = lowerQuery;
while (j < upperQuery) {
if (bounds[j].IsLower()){
IncrementOverlapCount(bounds[j].proxyId);
};
j++;
};
if (lowerQuery > 0){
i = (lowerQuery - 1);
s = bounds[i].stabbingCount;
while (s) {
if (bounds[i].IsLower()){
proxy = m_proxyPool[bounds[i].proxyId];
if (lowerQuery <= proxy.upperBounds[axis]){
IncrementOverlapCount(bounds[i].proxyId);
s--;
};
};
i--;
};
};
lowerQueryOut[0] = lowerQuery;
upperQueryOut[0] = upperQuery;
}
private function TestOverlapValidate(p1:b2Proxy, p2:b2Proxy):Boolean{
var bounds:Array;
var axis:int;
while (axis < 2) {
bounds = m_bounds[axis];
if (bounds[p1.lowerBounds[axis]].value > bounds[p2.upperBounds[axis]].value){
return (false);
};
if (bounds[p1.upperBounds[axis]].value < bounds[p2.lowerBounds[axis]].value){
return (false);
};
axis++;
};
return (true);
}
private function ComputeBounds(lowerValues:Array, upperValues:Array, aabb:b2AABB):void{
var minVertexX:Number = aabb.minVertex.x;
var minVertexY:Number = aabb.minVertex.y;
minVertexX = b2Math.b2Min(minVertexX, m_worldAABB.maxVertex.x);
minVertexY = b2Math.b2Min(minVertexY, m_worldAABB.maxVertex.y);
minVertexX = b2Math.b2Max(minVertexX, m_worldAABB.minVertex.x);
minVertexY = b2Math.b2Max(minVertexY, m_worldAABB.minVertex.y);
var maxVertexX:Number = aabb.maxVertex.x;
var maxVertexY:Number = aabb.maxVertex.y;
maxVertexX = b2Math.b2Min(maxVertexX, m_worldAABB.maxVertex.x);
maxVertexY = b2Math.b2Min(maxVertexY, m_worldAABB.maxVertex.y);
maxVertexX = b2Math.b2Max(maxVertexX, m_worldAABB.minVertex.x);
maxVertexY = b2Math.b2Max(maxVertexY, m_worldAABB.minVertex.y);
lowerValues[0] = (uint((m_quantizationFactor.x * (minVertexX - m_worldAABB.minVertex.x))) & (b2Settings.USHRT_MAX - 1));
upperValues[0] = ((uint((m_quantizationFactor.x * (maxVertexX - m_worldAABB.minVertex.x))) & 0xFFFF) | 1);
lowerValues[1] = (uint((m_quantizationFactor.y * (minVertexY - m_worldAABB.minVertex.y))) & (b2Settings.USHRT_MAX - 1));
upperValues[1] = ((uint((m_quantizationFactor.y * (maxVertexY - m_worldAABB.minVertex.y))) & 0xFFFF) | 1);
}
public function CreateProxy(aabb:b2AABB, userData):uint{
var index:uint;
var proxy:b2Proxy;
var bounds:Array;
var lowerIndex:uint;
var upperIndex:uint;
var lowerIndexOut:Array;
var upperIndexOut:Array;
var tArr:Array;
var j:int;
var tEnd:int;
var tBound1:b2Bound;
var tBound2:b2Bound;
var tIndex:int;
var proxy2:b2Proxy;
var proxyId:uint = m_freeProxy;
proxy = m_proxyPool[proxyId];
m_freeProxy = proxy.GetNext();
proxy.overlapCount = 0;
proxy.userData = userData;
var boundCount:uint = (2 * m_proxyCount);
var lowerValues:Array = new Array();
var upperValues:Array = new Array();
ComputeBounds(lowerValues, upperValues, aabb);
var axis:int;
while (axis < 2) {
bounds = m_bounds[axis];
lowerIndexOut = [lowerIndex];
upperIndexOut = [upperIndex];
Query(lowerIndexOut, upperIndexOut, lowerValues[axis], upperValues[axis], bounds, boundCount, axis);
lowerIndex = lowerIndexOut[0];
upperIndex = upperIndexOut[0];
tArr = new Array();
tEnd = (boundCount - upperIndex);
j = 0;
while (j < tEnd) {
tArr[j] = new b2Bound();
tBound1 = tArr[j];
tBound2 = bounds[(upperIndex + j)];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tEnd = tArr.length;
tIndex = (upperIndex + 2);
j = 0;
while (j < tEnd) {
tBound2 = tArr[j];
tBound1 = bounds[(tIndex + j)];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tArr = new Array();
tEnd = (upperIndex - lowerIndex);
j = 0;
while (j < tEnd) {
tArr[j] = new b2Bound();
tBound1 = tArr[j];
tBound2 = bounds[(lowerIndex + j)];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tEnd = tArr.length;
tIndex = (lowerIndex + 1);
j = 0;
while (j < tEnd) {
tBound2 = tArr[j];
tBound1 = bounds[(tIndex + j)];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
upperIndex++;
bounds[lowerIndex].value = lowerValues[axis];
bounds[lowerIndex].proxyId = proxyId;
bounds[upperIndex].value = upperValues[axis];
bounds[upperIndex].proxyId = proxyId;
bounds[lowerIndex].stabbingCount = ((lowerIndex == 0)) ? 0 : bounds[(lowerIndex - 1)].stabbingCount;
bounds[upperIndex].stabbingCount = bounds[(upperIndex - 1)].stabbingCount;
index = lowerIndex;
while (index < upperIndex) {
bounds[index].stabbingCount++;
index++;
};
index = lowerIndex;
while (index < (boundCount + 2)) {
proxy2 = m_proxyPool[bounds[index].proxyId];
if (bounds[index].IsLower()){
proxy2.lowerBounds[axis] = index;
} else {
proxy2.upperBounds[axis] = index;
};
index++;
};
axis++;
};
m_proxyCount++;
var i:int;
while (i < m_queryResultCount) {
m_pairManager.AddBufferedPair(proxyId, m_queryResults[i]);
i++;
};
m_pairManager.Commit();
m_queryResultCount = 0;
IncrementTimeStamp();
return (proxyId);
}
public function DestroyProxy(proxyId:uint):void{
var bounds:Array;
var lowerIndex:uint;
var upperIndex:uint;
var lowerValue:uint;
var upperValue:uint;
var tArr:Array;
var j:int;
var tEnd:int;
var tBound1:b2Bound;
var tBound2:b2Bound;
var tIndex:int;
var index:uint;
var index2:int;
var proxy2:b2Proxy;
var proxy:b2Proxy = m_proxyPool[proxyId];
var boundCount:int = (2 * m_proxyCount);
var axis:int;
while (axis < 2) {
bounds = m_bounds[axis];
lowerIndex = proxy.lowerBounds[axis];
upperIndex = proxy.upperBounds[axis];
lowerValue = bounds[lowerIndex].value;
upperValue = bounds[upperIndex].value;
tArr = new Array();
tEnd = ((upperIndex - lowerIndex) - 1);
j = 0;
while (j < tEnd) {
tArr[j] = new b2Bound();
tBound1 = tArr[j];
tBound2 = bounds[((lowerIndex + 1) + j)];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tEnd = tArr.length;
tIndex = lowerIndex;
j = 0;
while (j < tEnd) {
tBound2 = tArr[j];
tBound1 = bounds[(tIndex + j)];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tArr = new Array();
tEnd = ((boundCount - upperIndex) - 1);
j = 0;
while (j < tEnd) {
tArr[j] = new b2Bound();
tBound1 = tArr[j];
tBound2 = bounds[((upperIndex + 1) + j)];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tEnd = tArr.length;
tIndex = (upperIndex - 1);
j = 0;
while (j < tEnd) {
tBound2 = tArr[j];
tBound1 = bounds[(tIndex + j)];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tEnd = (boundCount - 2);
index = lowerIndex;
while (index < tEnd) {
proxy2 = m_proxyPool[bounds[index].proxyId];
if (bounds[index].IsLower()){
proxy2.lowerBounds[axis] = index;
} else {
proxy2.upperBounds[axis] = index;
};
index++;
};
tEnd = (upperIndex - 1);
index2 = lowerIndex;
while (index2 < tEnd) {
bounds[index2].stabbingCount--;
index2++;
};
Query([0], [0], lowerValue, upperValue, bounds, (boundCount - 2), axis);
axis++;
};
var i:int;
while (i < m_queryResultCount) {
m_pairManager.RemoveBufferedPair(proxyId, m_queryResults[i]);
i++;
};
m_pairManager.Commit();
m_queryResultCount = 0;
IncrementTimeStamp();
proxy.userData = null;
proxy.overlapCount = b2_invalid;
proxy.lowerBounds[0] = b2_invalid;
proxy.lowerBounds[1] = b2_invalid;
proxy.upperBounds[0] = b2_invalid;
proxy.upperBounds[1] = b2_invalid;
proxy.SetNext(m_freeProxy);
m_freeProxy = proxyId;
m_proxyCount--;
}
public function TestOverlap(b:b2BoundValues, p:b2Proxy):Boolean{
var bounds:Array;
var axis:int;
while (axis < 2) {
bounds = m_bounds[axis];
if (b.lowerValues[axis] > bounds[p.upperBounds[axis]].value){
return (false);
};
if (b.upperValues[axis] < bounds[p.lowerBounds[axis]].value){
return (false);
};
axis++;
};
return (true);
}
public function Validate():void{
var pair:b2Pair;
var proxy1:b2Proxy;
var proxy2:b2Proxy;
var overlap:Boolean;
var bounds:b2Bound;
var boundCount:uint;
var stabbingCount:uint;
var i:uint;
var bound:b2Bound;
var axis:int;
while (axis < 2) {
bounds = m_bounds[axis];
boundCount = (2 * m_proxyCount);
stabbingCount = 0;
i = 0;
while (i < boundCount) {
bound = bounds[i];
if (bound.IsLower() == true){
stabbingCount++;
} else {
stabbingCount--;
};
i++;
};
axis++;
};
}
private function IncrementOverlapCount(proxyId:uint):void{
var proxy:b2Proxy = m_proxyPool[proxyId];
if (proxy.timeStamp < m_timeStamp){
proxy.timeStamp = m_timeStamp;
proxy.overlapCount = 1;
} else {
proxy.overlapCount = 2;
m_queryResults[m_queryResultCount] = proxyId;
m_queryResultCount++;
};
}
public function InRange(aabb:b2AABB):Boolean{
var dX:Number;
var dY:Number;
var d2X:Number;
var d2Y:Number;
dX = aabb.minVertex.x;
dY = aabb.minVertex.y;
dX = (dX - m_worldAABB.maxVertex.x);
dY = (dY - m_worldAABB.maxVertex.y);
d2X = m_worldAABB.minVertex.x;
d2Y = m_worldAABB.minVertex.y;
d2X = (d2X - aabb.maxVertex.x);
d2Y = (d2Y - aabb.maxVertex.y);
dX = b2Math.b2Max(dX, d2X);
dY = b2Math.b2Max(dY, d2Y);
return ((b2Math.b2Max(dX, dY) < 0));
}
public function MoveProxy(proxyId:uint, aabb:b2AABB):void{
var axis:uint;
var index:uint;
var bound:b2Bound;
var prevBound:b2Bound;
var nextBound:b2Bound;
var nextProxyId:uint;
var nextProxy:b2Proxy;
var bounds:Array;
var lowerIndex:uint;
var upperIndex:uint;
var lowerValue:uint;
var upperValue:uint;
var deltaLower:int;
var deltaUpper:int;
var prevProxyId:uint;
var prevProxy:b2Proxy;
if ((((proxyId == b2Pair.b2_nullProxy)) || ((b2Settings.b2_maxProxies <= proxyId)))){
return;
};
if (aabb.IsValid() == false){
return;
};
var boundCount:uint = (2 * m_proxyCount);
var proxy:b2Proxy = m_proxyPool[proxyId];
var newValues:b2BoundValues = new b2BoundValues();
ComputeBounds(newValues.lowerValues, newValues.upperValues, aabb);
var oldValues:b2BoundValues = new b2BoundValues();
axis = 0;
while (axis < 2) {
oldValues.lowerValues[axis] = m_bounds[axis][proxy.lowerBounds[axis]].value;
oldValues.upperValues[axis] = m_bounds[axis][proxy.upperBounds[axis]].value;
axis++;
};
axis = 0;
while (axis < 2) {
bounds = m_bounds[axis];
lowerIndex = proxy.lowerBounds[axis];
upperIndex = proxy.upperBounds[axis];
lowerValue = newValues.lowerValues[axis];
upperValue = newValues.upperValues[axis];
deltaLower = (lowerValue - bounds[lowerIndex].value);
deltaUpper = (upperValue - bounds[upperIndex].value);
bounds[lowerIndex].value = lowerValue;
bounds[upperIndex].value = upperValue;
if (deltaLower < 0){
index = lowerIndex;
while ((((index > 0)) && ((lowerValue < bounds[(index - 1)].value)))) {
bound = bounds[index];
prevBound = bounds[(index - 1)];
prevProxyId = prevBound.proxyId;
prevProxy = m_proxyPool[prevBound.proxyId];
prevBound.stabbingCount++;
if (prevBound.IsUpper() == true){
if (TestOverlap(newValues, prevProxy)){
m_pairManager.AddBufferedPair(proxyId, prevProxyId);
};
var _local23 = prevProxy.upperBounds;
var _local24 = axis;
var _local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
bound.stabbingCount++;
} else {
_local23 = prevProxy.lowerBounds;
_local24 = axis;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
bound.stabbingCount--;
};
_local23 = proxy.lowerBounds;
_local24 = axis;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
bound.Swap(prevBound);
index--;
};
};
if (deltaUpper > 0){
index = upperIndex;
while ((((index < (boundCount - 1))) && ((bounds[(index + 1)].value <= upperValue)))) {
bound = bounds[index];
nextBound = bounds[(index + 1)];
nextProxyId = nextBound.proxyId;
nextProxy = m_proxyPool[nextProxyId];
nextBound.stabbingCount++;
if (nextBound.IsLower() == true){
if (TestOverlap(newValues, nextProxy)){
m_pairManager.AddBufferedPair(proxyId, nextProxyId);
};
_local23 = nextProxy.lowerBounds;
_local24 = axis;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
bound.stabbingCount++;
} else {
_local23 = nextProxy.upperBounds;
_local24 = axis;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
bound.stabbingCount--;
};
_local23 = proxy.upperBounds;
_local24 = axis;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
bound.Swap(nextBound);
index++;
};
};
if (deltaLower > 0){
index = lowerIndex;
while ((((index < (boundCount - 1))) && ((bounds[(index + 1)].value <= lowerValue)))) {
bound = bounds[index];
nextBound = bounds[(index + 1)];
nextProxyId = nextBound.proxyId;
nextProxy = m_proxyPool[nextProxyId];
nextBound.stabbingCount--;
if (nextBound.IsUpper()){
if (TestOverlap(oldValues, nextProxy)){
m_pairManager.RemoveBufferedPair(proxyId, nextProxyId);
};
_local23 = nextProxy.upperBounds;
_local24 = axis;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
bound.stabbingCount--;
} else {
_local23 = nextProxy.lowerBounds;
_local24 = axis;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
bound.stabbingCount++;
};
_local23 = proxy.lowerBounds;
_local24 = axis;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
bound.Swap(nextBound);
index++;
};
};
if (deltaUpper < 0){
index = upperIndex;
while ((((index > 0)) && ((upperValue < bounds[(index - 1)].value)))) {
bound = bounds[index];
prevBound = bounds[(index - 1)];
prevProxyId = prevBound.proxyId;
prevProxy = m_proxyPool[prevProxyId];
prevBound.stabbingCount--;
if (prevBound.IsLower() == true){
if (TestOverlap(oldValues, prevProxy)){
m_pairManager.RemoveBufferedPair(proxyId, prevProxyId);
};
_local23 = prevProxy.lowerBounds;
_local24 = axis;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
bound.stabbingCount--;
} else {
_local23 = prevProxy.upperBounds;
_local24 = axis;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
bound.stabbingCount++;
};
_local23 = proxy.upperBounds;
_local24 = axis;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
bound.Swap(prevBound);
index--;
};
};
axis++;
};
}
public static function BinarySearch(bounds:Array, count:int, value:uint):uint{
var mid:int;
var low:int;
var high:int = (count - 1);
while (low <= high) {
mid = ((low + high) / 2);
if (bounds[mid].value > value){
high = (mid - 1);
} else {
if (bounds[mid].value < value){
low = (mid + 1);
} else {
return (uint(mid));
};
};
};
return (uint(low));
}
}
}//package Box2D.Collision
Section 14
//b2BufferedPair (Box2D.Collision.b2BufferedPair)
package Box2D.Collision {
public class b2BufferedPair {
public var proxyId1:uint;
public var proxyId2:uint;
public function b2BufferedPair(){
super();
}
}
}//package Box2D.Collision
Section 15
//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();
public function b2Collision(){
super();
}
public static function EdgeSeparation(poly1:b2PolyShape, edge1:int, poly2:b2PolyShape):Number{
var tVec:b2Vec2;
var dot:Number;
var vert1s:Array = poly1.m_vertices;
var count2:int = poly2.m_vertexCount;
var vert2s:Array = poly2.m_vertices;
var normalX:Number = poly1.m_normals[edge1].x;
var normalY:Number = poly1.m_normals[edge1].y;
var tX:Number = normalX;
var tMat:b2Mat22 = poly1.m_R;
normalX = ((tMat.col1.x * tX) + (tMat.col2.x * normalY));
normalY = ((tMat.col1.y * tX) + (tMat.col2.y * normalY));
var normalLocal2X:Number = normalX;
var normalLocal2Y:Number = normalY;
tMat = poly2.m_R;
tX = ((normalLocal2X * tMat.col1.x) + (normalLocal2Y * tMat.col1.y));
normalLocal2Y = ((normalLocal2X * tMat.col2.x) + (normalLocal2Y * tMat.col2.y));
normalLocal2X = tX;
var vertexIndex2:int;
var minDot:Number = Number.MAX_VALUE;
var i:int;
while (i < count2) {
tVec = vert2s[i];
dot = ((tVec.x * normalLocal2X) + (tVec.y * normalLocal2Y));
if (dot < minDot){
minDot = dot;
vertexIndex2 = i;
};
i++;
};
tMat = poly1.m_R;
var v1X:Number = (poly1.m_position.x + ((tMat.col1.x * vert1s[edge1].x) + (tMat.col2.x * vert1s[edge1].y)));
var v1Y:Number = (poly1.m_position.y + ((tMat.col1.y * vert1s[edge1].x) + (tMat.col2.y * vert1s[edge1].y)));
tMat = poly2.m_R;
var v2X:Number = (poly2.m_position.x + ((tMat.col1.x * vert2s[vertexIndex2].x) + (tMat.col2.x * vert2s[vertexIndex2].y)));
var v2Y:Number = (poly2.m_position.y + ((tMat.col1.y * vert2s[vertexIndex2].x) + (tMat.col2.y * vert2s[vertexIndex2].y)));
v2X = (v2X - v1X);
v2Y = (v2Y - v1Y);
var separation:Number = ((v2X * normalX) + (v2Y * normalY));
return (separation);
}
public static function b2TestOverlap(a:b2AABB, b:b2AABB):Boolean{
var t1:b2Vec2 = b.minVertex;
var t2:b2Vec2 = a.maxVertex;
var d1X:Number = (t1.x - t2.x);
var d1Y:Number = (t1.y - t2.y);
t1 = a.minVertex;
t2 = b.maxVertex;
var d2X:Number = (t1.x - t2.x);
var d2Y:Number = (t1.y - t2.y);
if ((((d1X > 0)) || ((d1Y > 0)))){
return (false);
};
if ((((d2X > 0)) || ((d2Y > 0)))){
return (false);
};
return (true);
}
public static function FindIncidentEdge(c:Array, poly1:b2PolyShape, edge1:int, poly2:b2PolyShape):void{
var vertex21:int;
var vertex22:int;
var tClip:ClipVertex;
var i1:int;
var i2:int;
var normal2Local2X:Number;
var normal2Local2Y:Number;
var dot:Number;
var count1:int = poly1.m_vertexCount;
var vert1s:Array = poly1.m_vertices;
var count2:int = poly2.m_vertexCount;
var vert2s:Array = poly2.m_vertices;
var vertex11:int = edge1;
var vertex12:int = (((edge1 + 1) == count1)) ? 0 : (edge1 + 1);
var tVec:b2Vec2 = vert1s[vertex12];
var normal1Local1X:Number = tVec.x;
var normal1Local1Y:Number = tVec.y;
tVec = vert1s[vertex11];
normal1Local1X = (normal1Local1X - tVec.x);
normal1Local1Y = (normal1Local1Y - tVec.y);
var tX:Number = normal1Local1X;
normal1Local1X = normal1Local1Y;
normal1Local1Y = -(tX);
var invLength:Number = (1 / Math.sqrt(((normal1Local1X * normal1Local1X) + (normal1Local1Y * normal1Local1Y))));
normal1Local1X = (normal1Local1X * invLength);
normal1Local1Y = (normal1Local1Y * invLength);
var normal1X:Number = normal1Local1X;
var normal1Y:Number = normal1Local1Y;
tX = normal1X;
var tMat:b2Mat22 = poly1.m_R;
normal1X = ((tMat.col1.x * tX) + (tMat.col2.x * normal1Y));
normal1Y = ((tMat.col1.y * tX) + (tMat.col2.y * normal1Y));
var normal1Local2X:Number = normal1X;
var normal1Local2Y:Number = normal1Y;
tMat = poly2.m_R;
tX = ((normal1Local2X * tMat.col1.x) + (normal1Local2Y * tMat.col1.y));
normal1Local2Y = ((normal1Local2X * tMat.col2.x) + (normal1Local2Y * tMat.col2.y));
normal1Local2X = tX;
var minDot:Number = Number.MAX_VALUE;
var i:int;
while (i < count2) {
i1 = i;
i2 = (((i + 1) < count2)) ? (i + 1) : 0;
tVec = vert2s[i2];
normal2Local2X = tVec.x;
normal2Local2Y = tVec.y;
tVec = vert2s[i1];
normal2Local2X = (normal2Local2X - tVec.x);
normal2Local2Y = (normal2Local2Y - tVec.y);
tX = normal2Local2X;
normal2Local2X = normal2Local2Y;
normal2Local2Y = -(tX);
invLength = (1 / Math.sqrt(((normal2Local2X * normal2Local2X) + (normal2Local2Y * normal2Local2Y))));
normal2Local2X = (normal2Local2X * invLength);
normal2Local2Y = (normal2Local2Y * invLength);
dot = ((normal2Local2X * normal1Local2X) + (normal2Local2Y * normal1Local2Y));
if (dot < minDot){
minDot = dot;
vertex21 = i1;
vertex22 = i2;
};
i++;
};
tClip = c[0];
tVec = tClip.v;
tVec.SetV(vert2s[vertex21]);
tVec.MulM(poly2.m_R);
tVec.Add(poly2.m_position);
tClip.id.features.referenceFace = edge1;
tClip.id.features.incidentEdge = vertex21;
tClip.id.features.incidentVertex = vertex21;
tClip = c[1];
tVec = tClip.v;
tVec.SetV(vert2s[vertex22]);
tVec.MulM(poly2.m_R);
tVec.Add(poly2.m_position);
tClip.id.features.referenceFace = edge1;
tClip.id.features.incidentEdge = vertex21;
tClip.id.features.incidentVertex = vertex22;
}
public static function b2CollidePolyAndCircle(manifold:b2Manifold, poly:b2PolyShape, circle:b2CircleShape, conservative:Boolean):void{
var tPoint:b2ContactPoint;
var dX:Number;
var dY:Number;
var dist:Number;
var pX:Number;
var pY:Number;
var s:Number;
var tVec:b2Vec2;
manifold.pointCount = 0;
var xLocalX:Number = (circle.m_position.x - poly.m_position.x);
var xLocalY:Number = (circle.m_position.y - poly.m_position.y);
var tMat:b2Mat22 = poly.m_R;
var tX:Number = ((xLocalX * tMat.col1.x) + (xLocalY * tMat.col1.y));
xLocalY = ((xLocalX * tMat.col2.x) + (xLocalY * tMat.col2.y));
xLocalX = tX;
var normalIndex:int;
var separation:Number = -(Number.MAX_VALUE);
var radius:Number = circle.m_radius;
var i:int;
while (i < poly.m_vertexCount) {
s = ((poly.m_normals[i].x * (xLocalX - poly.m_vertices[i].x)) + (poly.m_normals[i].y * (xLocalY - poly.m_vertices[i].y)));
if (s > radius){
return;
};
if (s > separation){
separation = s;
normalIndex = i;
};
i++;
};
if (separation < Number.MIN_VALUE){
manifold.pointCount = 1;
tVec = poly.m_normals[normalIndex];
manifold.normal.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
manifold.normal.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tPoint = manifold.points[0];
tPoint.id.features.incidentEdge = normalIndex;
tPoint.id.features.incidentVertex = b2_nullFeature;
tPoint.id.features.referenceFace = b2_nullFeature;
tPoint.id.features.flip = 0;
tPoint.position.x = (circle.m_position.x - (radius * manifold.normal.x));
tPoint.position.y = (circle.m_position.y - (radius * manifold.normal.y));
tPoint.separation = (separation - radius);
return;
};
var vertIndex1:int = normalIndex;
var vertIndex2:int = (((vertIndex1 + 1) < poly.m_vertexCount)) ? (vertIndex1 + 1) : 0;
var eX:Number = (poly.m_vertices[vertIndex2].x - poly.m_vertices[vertIndex1].x);
var eY:Number = (poly.m_vertices[vertIndex2].y - poly.m_vertices[vertIndex1].y);
var length:Number = Math.sqrt(((eX * eX) + (eY * eY)));
eX = (eX / length);
eY = (eY / length);
if (length < Number.MIN_VALUE){
dX = (xLocalX - poly.m_vertices[vertIndex1].x);
dY = (xLocalY - poly.m_vertices[vertIndex1].y);
dist = Math.sqrt(((dX * dX) + (dY * dY)));
dX = (dX / dist);
dY = (dY / dist);
if (dist > radius){
return;
};
manifold.pointCount = 1;
manifold.normal.Set(((tMat.col1.x * dX) + (tMat.col2.x * dY)), ((tMat.col1.y * dX) + (tMat.col2.y * dY)));
tPoint = manifold.points[0];
tPoint.id.features.incidentEdge = b2_nullFeature;
tPoint.id.features.incidentVertex = vertIndex1;
tPoint.id.features.referenceFace = b2_nullFeature;
tPoint.id.features.flip = 0;
tPoint.position.x = (circle.m_position.x - (radius * manifold.normal.x));
tPoint.position.y = (circle.m_position.y - (radius * manifold.normal.y));
tPoint.separation = (dist - radius);
return;
};
var u:Number = (((xLocalX - poly.m_vertices[vertIndex1].x) * eX) + ((xLocalY - poly.m_vertices[vertIndex1].y) * eY));
tPoint = manifold.points[0];
tPoint.id.features.incidentEdge = b2_nullFeature;
tPoint.id.features.incidentVertex = b2_nullFeature;
tPoint.id.features.referenceFace = b2_nullFeature;
tPoint.id.features.flip = 0;
if (u <= 0){
pX = poly.m_vertices[vertIndex1].x;
pY = poly.m_vertices[vertIndex1].y;
tPoint.id.features.incidentVertex = vertIndex1;
} else {
if (u >= length){
pX = poly.m_vertices[vertIndex2].x;
pY = poly.m_vertices[vertIndex2].y;
tPoint.id.features.incidentVertex = vertIndex2;
} else {
pX = ((eX * u) + poly.m_vertices[vertIndex1].x);
pY = ((eY * u) + poly.m_vertices[vertIndex1].y);
tPoint.id.features.incidentEdge = vertIndex1;
};
};
dX = (xLocalX - pX);
dY = (xLocalY - pY);
dist = Math.sqrt(((dX * dX) + (dY * dY)));
dX = (dX / dist);
dY = (dY / dist);
if (dist > radius){
return;
};
manifold.pointCount = 1;
manifold.normal.Set(((tMat.col1.x * dX) + (tMat.col2.x * dY)), ((tMat.col1.y * dX) + (tMat.col2.y * dY)));
tPoint.position.x = (circle.m_position.x - (radius * manifold.normal.x));
tPoint.position.y = (circle.m_position.y - (radius * manifold.normal.y));
tPoint.separation = (dist - radius);
}
public static function FindMaxSeparation(edgeIndex:Array, poly1:b2PolyShape, poly2:b2PolyShape, conservative:Boolean):Number{
var bestEdge:int;
var bestSeparation:Number;
var increment:int;
var dot:Number;
var count1:int = poly1.m_vertexCount;
var dX:Number = (poly2.m_position.x - poly1.m_position.x);
var dY:Number = (poly2.m_position.y - poly1.m_position.y);
var dLocal1X:Number = ((dX * poly1.m_R.col1.x) + (dY * poly1.m_R.col1.y));
var dLocal1Y:Number = ((dX * poly1.m_R.col2.x) + (dY * poly1.m_R.col2.y));
var edge:int;
var maxDot:Number = -(Number.MAX_VALUE);
var i:int;
while (i < count1) {
dot = ((poly1.m_normals[i].x * dLocal1X) + (poly1.m_normals[i].y * dLocal1Y));
if (dot > maxDot){
maxDot = dot;
edge = i;
};
i++;
};
var s:Number = EdgeSeparation(poly1, edge, poly2);
if ((((s > 0)) && ((conservative == false)))){
return (s);
};
var prevEdge:int = (((edge - 1) >= 0)) ? (edge - 1) : (count1 - 1);
var sPrev:Number = EdgeSeparation(poly1, prevEdge, poly2);
if ((((sPrev > 0)) && ((conservative == false)))){
return (sPrev);
};
var nextEdge:int = (((edge + 1) < count1)) ? (edge + 1) : 0;
var sNext:Number = EdgeSeparation(poly1, nextEdge, poly2);
if ((((sNext > 0)) && ((conservative == false)))){
return (sNext);
};
if ((((sPrev > s)) && ((sPrev > sNext)))){
increment = -1;
bestEdge = prevEdge;
bestSeparation = sPrev;
} else {
if (sNext > s){
increment = 1;
bestEdge = nextEdge;
bestSeparation = sNext;
} else {
edgeIndex[0] = edge;
return (s);
};
};
while (true) {
if (increment == -1){
edge = (((bestEdge - 1) >= 0)) ? (bestEdge - 1) : (count1 - 1);
} else {
edge = (((bestEdge + 1) < count1)) ? (bestEdge + 1) : 0;
};
s = EdgeSeparation(poly1, edge, poly2);
if ((((s > 0)) && ((conservative == false)))){
return (s);
};
if (s > bestSeparation){
bestEdge = edge;
bestSeparation = s;
} else {
break;
};
};
edgeIndex[0] = bestEdge;
return (bestSeparation);
}
public static function ClipSegmentToLine(vOut:Array, vIn:Array, normal:b2Vec2, offset:Number):int{
var vIn1:b2Vec2;
var distance0:Number;
var interp:Number;
var tVec:b2Vec2;
var numOut:int;
var vIn0:b2Vec2 = vIn[0].v;
vIn1 = vIn[1].v;
distance0 = (b2Math.b2Dot(normal, vIn[0].v) - offset);
var distance1:Number = (b2Math.b2Dot(normal, vIn[1].v) - offset);
if (distance0 <= 0){
var _temp1 = numOut;
numOut = (numOut + 1);
var _local12 = _temp1;
vOut[_local12] = vIn[0];
};
if (distance1 <= 0){
var _temp2 = numOut;
numOut = (numOut + 1);
_local12 = _temp2;
vOut[_local12] = vIn[1];
};
if ((distance0 * distance1) < 0){
interp = (distance0 / (distance0 - distance1));
tVec = vOut[numOut].v;
tVec.x = (vIn0.x + (interp * (vIn1.x - vIn0.x)));
tVec.y = (vIn0.y + (interp * (vIn1.y - vIn0.y)));
if (distance0 > 0){
vOut[numOut].id = vIn[0].id;
} else {
vOut[numOut].id = vIn[1].id;
};
numOut++;
};
return (numOut);
}
public static function b2CollidePoly(manifold:b2Manifold, polyA:b2PolyShape, polyB:b2PolyShape, conservative:Boolean):void{
var poly1:b2PolyShape;
var poly2:b2PolyShape;
var edge1:int;
var flip:int;
var np:int;
var tVec:b2Vec2;
var separation:Number;
var cp:b2ContactPoint;
manifold.pointCount = 0;
var edgeA:int;
var edgeAOut:Array = [edgeA];
var separationA:Number = FindMaxSeparation(edgeAOut, polyA, polyB, conservative);
edgeA = edgeAOut[0];
if ((((separationA > 0)) && ((conservative == false)))){
return;
};
var edgeB:int;
var edgeBOut:Array = [edgeB];
var separationB:Number = FindMaxSeparation(edgeBOut, polyB, polyA, conservative);
edgeB = edgeBOut[0];
if ((((separationB > 0)) && ((conservative == false)))){
return;
};
var k_relativeTol:Number = 0.98;
var k_absoluteTol:Number = 0.001;
if (separationB > ((k_relativeTol * separationA) + k_absoluteTol)){
poly1 = polyB;
poly2 = polyA;
edge1 = edgeB;
flip = 1;
} else {
poly1 = polyA;
poly2 = polyB;
edge1 = edgeA;
flip = 0;
};
var incidentEdge:Array = [new ClipVertex(), new ClipVertex()];
FindIncidentEdge(incidentEdge, poly1, edge1, poly2);
var count1:int = poly1.m_vertexCount;
var vert1s:Array = poly1.m_vertices;
var v11:b2Vec2 = vert1s[edge1];
var v12:b2Vec2 = (((edge1 + 1) < count1)) ? vert1s[(edge1 + 1)] : vert1s[0];
var dvX:Number = (v12.x - v11.x);
var dvY:Number = (v12.y - v11.y);
var sideNormalX:Number = (v12.x - v11.x);
var sideNormalY:Number = (v12.y - v11.y);
var tX:Number = sideNormalX;
var tMat:b2Mat22 = poly1.m_R;
sideNormalX = ((tMat.col1.x * tX) + (tMat.col2.x * sideNormalY));
sideNormalY = ((tMat.col1.y * tX) + (tMat.col2.y * sideNormalY));
var invLength:Number = (1 / Math.sqrt(((sideNormalX * sideNormalX) + (sideNormalY * sideNormalY))));
sideNormalX = (sideNormalX * invLength);
sideNormalY = (sideNormalY * invLength);
var frontNormalX:Number = sideNormalX;
var frontNormalY:Number = sideNormalY;
tX = frontNormalX;
frontNormalX = frontNormalY;
frontNormalY = -(tX);
var v11X:Number = v11.x;
var v11Y:Number = v11.y;
tX = v11X;
tMat = poly1.m_R;
v11X = ((tMat.col1.x * tX) + (tMat.col2.x * v11Y));
v11Y = ((tMat.col1.y * tX) + (tMat.col2.y * v11Y));
v11X = (v11X + poly1.m_position.x);
v11Y = (v11Y + poly1.m_position.y);
var v12X:Number = v12.x;
var v12Y:Number = v12.y;
tX = v12X;
tMat = poly1.m_R;
v12X = ((tMat.col1.x * tX) + (tMat.col2.x * v12Y));
v12Y = ((tMat.col1.y * tX) + (tMat.col2.y * v12Y));
v12X = (v12X + poly1.m_position.x);
v12Y = (v12Y + poly1.m_position.y);
var frontOffset:Number = ((frontNormalX * v11X) + (frontNormalY * v11Y));
var sideOffset1:Number = -(((sideNormalX * v11X) + (sideNormalY * v11Y)));
var sideOffset2:Number = ((sideNormalX * v12X) + (sideNormalY * v12Y));
var clipPoints1:Array = [new ClipVertex(), new ClipVertex()];
var clipPoints2:Array = [new ClipVertex(), new ClipVertex()];
b2CollidePolyTempVec.Set(-(sideNormalX), -(sideNormalY));
np = ClipSegmentToLine(clipPoints1, incidentEdge, b2CollidePolyTempVec, sideOffset1);
if (np < 2){
return;
};
b2CollidePolyTempVec.Set(sideNormalX, sideNormalY);
np = ClipSegmentToLine(clipPoints2, clipPoints1, b2CollidePolyTempVec, sideOffset2);
if (np < 2){
return;
};
if (flip){
manifold.normal.Set(-(frontNormalX), -(frontNormalY));
} else {
manifold.normal.Set(frontNormalX, frontNormalY);
};
var pointCount:int;
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
tVec = clipPoints2[i].v;
separation = (((frontNormalX * tVec.x) + (frontNormalY * tVec.y)) - frontOffset);
if ((((separation <= 0)) || ((conservative == true)))){
cp = manifold.points[pointCount];
cp.separation = separation;
cp.position.SetV(clipPoints2[i].v);
cp.id.Set(clipPoints2[i].id);
cp.id.features.flip = flip;
pointCount++;
};
i++;
};
manifold.pointCount = pointCount;
}
public static function b2CollideCircle(manifold:b2Manifold, circle1:b2CircleShape, circle2:b2CircleShape, conservative:Boolean):void{
var separation:Number;
var dist:Number;
var a:Number;
manifold.pointCount = 0;
var dX:Number = (circle2.m_position.x - circle1.m_position.x);
var dY:Number = (circle2.m_position.y - circle1.m_position.y);
var distSqr:Number = ((dX * dX) + (dY * dY));
var radiusSum:Number = (circle1.m_radius + circle2.m_radius);
if ((((distSqr > (radiusSum * radiusSum))) && ((conservative == false)))){
return;
};
if (distSqr < Number.MIN_VALUE){
separation = -(radiusSum);
manifold.normal.Set(0, 1);
} else {
dist = Math.sqrt(distSqr);
separation = (dist - radiusSum);
a = (1 / dist);
manifold.normal.x = (a * dX);
manifold.normal.y = (a * dY);
};
manifold.pointCount = 1;
var tPoint:b2ContactPoint = manifold.points[0];
tPoint.id.key = 0;
tPoint.separation = separation;
tPoint.position.x = (circle2.m_position.x - (circle2.m_radius * manifold.normal.x));
tPoint.position.y = (circle2.m_position.y - (circle2.m_radius * manifold.normal.y));
}
}
}//package Box2D.Collision
Section 16
//b2ContactID (Box2D.Collision.b2ContactID)
package Box2D.Collision {
public class b2ContactID {
public var _key:uint;
public var features:Features;
public function b2ContactID(){
features = new Features();
super();
features._m_id = this;
}
public function Set(id:b2ContactID):void{
key = id._key;
}
public function Copy():b2ContactID{
var id:b2ContactID = new b2ContactID();
id.key = key;
return (id);
}
public function set key(value:uint):void{
_key = value;
features._referenceFace = (_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 17
//b2ContactPoint (Box2D.Collision.b2ContactPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2ContactPoint {
public var tangentImpulse:Number;
public var separation:Number;
public var position:b2Vec2;
public var id:b2ContactID;
public var normalImpulse:Number;
public function b2ContactPoint(){
position = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Collision
Section 18
//b2Manifold (Box2D.Collision.b2Manifold)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Manifold {
public var points:Array;
public var normal:b2Vec2;
public var pointCount:int;
public function b2Manifold(){
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
points[i] = new b2ContactPoint();
i++;
};
normal = new b2Vec2();
}
}
}//package Box2D.Collision
Section 19
//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 20
//b2Pair (Box2D.Collision.b2Pair)
package Box2D.Collision {
public class b2Pair {
public var proxyId1:uint;
public var userData;// = null
public var proxyId2:uint;
public var status:uint;
public var next:uint;
public static var e_pairFinal:uint = 4;
public static var b2_tableMask:int = (b2_tableCapacity - 1);
public static var e_pairRemoved:uint = 2;
public static var b2_nullPair:uint = 0xFFFF;
public static var e_pairBuffered:uint = 1;
public static var b2_nullProxy:uint = 0xFFFF;
public static var b2_tableCapacity:int = 8192;
public function b2Pair(){
super();
}
public function SetBuffered():void{
status = (status | e_pairBuffered);
}
public function IsBuffered():Boolean{
return (((status & e_pairBuffered) == e_pairBuffered));
}
public function IsFinal():Boolean{
return (((status & e_pairFinal) == e_pairFinal));
}
public function ClearRemoved():void{
status = (status & ~(e_pairRemoved));
}
public function SetFinal():void{
status = (status | e_pairFinal);
}
public function IsRemoved():Boolean{
return (((status & e_pairRemoved) == e_pairRemoved));
}
public function ClearBuffered():void{
status = (status & ~(e_pairBuffered));
}
public function SetRemoved():void{
status = (status | e_pairRemoved);
}
}
}//package Box2D.Collision
Section 21
//b2PairCallback (Box2D.Collision.b2PairCallback)
package Box2D.Collision {
public class b2PairCallback {
public function b2PairCallback(){
super();
}
public function PairRemoved(proxyUserData1, proxyUserData2, pairUserData):void{
}
public function PairAdded(proxyUserData1, proxyUserData2){
return (null);
}
}
}//package Box2D.Collision
Section 22
//b2PairManager (Box2D.Collision.b2PairManager)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PairManager {
public var m_pairCount:int;
public var m_pairBuffer:Array;
public var m_hashTable:Array;
public var m_callback:b2PairCallback;
public var m_pairs:Array;
public var m_pairBufferCount:int;
public var m_broadPhase:b2BroadPhase;
public var m_freePair:uint;
public function b2PairManager(){
var i:uint;
super();
m_hashTable = new Array(b2Pair.b2_tableCapacity);
i = 0;
while (i < b2Pair.b2_tableCapacity) {
m_hashTable[i] = b2Pair.b2_nullPair;
i++;
};
m_pairs = new Array(b2Settings.b2_maxPairs);
i = 0;
while (i < b2Settings.b2_maxPairs) {
m_pairs[i] = new b2Pair();
i++;
};
m_pairBuffer = new Array(b2Settings.b2_maxPairs);
i = 0;
while (i < b2Settings.b2_maxPairs) {
m_pairBuffer[i] = new b2BufferedPair();
i++;
};
i = 0;
while (i < b2Settings.b2_maxPairs) {
m_pairs[i].proxyId1 = b2Pair.b2_nullProxy;
m_pairs[i].proxyId2 = b2Pair.b2_nullProxy;
m_pairs[i].userData = null;
m_pairs[i].status = 0;
m_pairs[i].next = (i + 1);
i++;
};
m_pairs[(b2Settings.b2_maxPairs - 1)].next = b2Pair.b2_nullPair;
m_pairCount = 0;
}
private function FindHash(proxyId1:uint, proxyId2:uint, hash:uint):b2Pair{
var index:uint = m_hashTable[hash];
while (((!((index == b2Pair.b2_nullPair))) && ((Equals(m_pairs[index], proxyId1, proxyId2) == false)))) {
index = m_pairs[index].next;
};
if (index == b2Pair.b2_nullPair){
return (null);
};
return (m_pairs[index]);
}
private function Find(proxyId1:uint, proxyId2:uint):b2Pair{
var temp:uint;
if (proxyId1 > proxyId2){
temp = proxyId1;
proxyId1 = proxyId2;
proxyId2 = temp;
};
var hash:uint = (Hash(proxyId1, proxyId2) & b2Pair.b2_tableMask);
return (FindHash(proxyId1, proxyId2, hash));
}
private function ValidateBuffer():void{
}
public function Commit():void{
var i:int;
var pair:b2Pair;
var proxy1:b2Proxy;
var proxy2:b2Proxy;
var removeCount:int;
var proxies:Array = m_broadPhase.m_proxyPool;
i = 0;
while (i < m_pairBufferCount) {
pair = Find(m_pairBuffer[i].proxyId1, m_pairBuffer[i].proxyId2);
pair.ClearBuffered();
proxy1 = proxies[pair.proxyId1];
proxy2 = proxies[pair.proxyId2];
if (pair.IsRemoved()){
if (pair.IsFinal() == true){
m_callback.PairRemoved(proxy1.userData, proxy2.userData, pair.userData);
};
m_pairBuffer[removeCount].proxyId1 = pair.proxyId1;
m_pairBuffer[removeCount].proxyId2 = pair.proxyId2;
removeCount++;
} else {
if (pair.IsFinal() == false){
pair.userData = m_callback.PairAdded(proxy1.userData, proxy2.userData);
pair.SetFinal();
};
};
i++;
};
i = 0;
while (i < removeCount) {
RemovePair(m_pairBuffer[i].proxyId1, m_pairBuffer[i].proxyId2);
i++;
};
m_pairBufferCount = 0;
if (b2BroadPhase.s_validate){
ValidateTable();
};
}
public function RemoveBufferedPair(proxyId1:int, proxyId2:int):void{
var pair:b2Pair = Find(proxyId1, proxyId2);
if (pair == null){
return;
};
if (pair.IsBuffered() == false){
pair.SetBuffered();
m_pairBuffer[m_pairBufferCount].proxyId1 = pair.proxyId1;
m_pairBuffer[m_pairBufferCount].proxyId2 = pair.proxyId2;
m_pairBufferCount++;
};
pair.SetRemoved();
if (b2BroadPhase.s_validate){
ValidateBuffer();
};
}
private function RemovePair(proxyId1:uint, proxyId2:uint){
var temp:uint;
var index:uint;
var pair:b2Pair;
var userData:*;
if (proxyId1 > proxyId2){
temp = proxyId1;
proxyId1 = proxyId2;
proxyId2 = temp;
};
var hash:uint = (Hash(proxyId1, proxyId2) & b2Pair.b2_tableMask);
var node:uint = m_hashTable[hash];
var pNode:b2Pair;
while (node != b2Pair.b2_nullPair) {
if (Equals(m_pairs[node], proxyId1, proxyId2)){
index = node;
if (pNode){
pNode.next = m_pairs[node].next;
} else {
m_hashTable[hash] = m_pairs[node].next;
};
pair = m_pairs[index];
userData = pair.userData;
pair.next = m_freePair;
pair.proxyId1 = b2Pair.b2_nullProxy;
pair.proxyId2 = b2Pair.b2_nullProxy;
pair.userData = null;
pair.status = 0;
m_freePair = index;
m_pairCount--;
return (userData);
} else {
pNode = m_pairs[node];
node = pNode.next;
};
};
return (null);
}
public function Initialize(broadPhase:b2BroadPhase, callback:b2PairCallback):void{
m_broadPhase = broadPhase;
m_callback = callback;
}
public function AddBufferedPair(proxyId1:int, proxyId2:int):void{
var pair:b2Pair = AddPair(proxyId1, proxyId2);
if (pair.IsBuffered() == false){
pair.SetBuffered();
m_pairBuffer[m_pairBufferCount].proxyId1 = pair.proxyId1;
m_pairBuffer[m_pairBufferCount].proxyId2 = pair.proxyId2;
m_pairBufferCount++;
};
pair.ClearRemoved();
if (b2BroadPhase.s_validate){
ValidateBuffer();
};
}
private function AddPair(proxyId1:uint, proxyId2:uint):b2Pair{
var temp:uint;
if (proxyId1 > proxyId2){
temp = proxyId1;
proxyId1 = proxyId2;
proxyId2 = temp;
};
var hash:uint = (Hash(proxyId1, proxyId2) & b2Pair.b2_tableMask);
var pair = FindHash(proxyId1, proxyId2, hash);
if (pair != null){
return (pair);
};
var pIndex:uint = m_freePair;
pair = m_pairs[pIndex];
m_freePair = pair.next;
pair.proxyId1 = proxyId1;
pair.proxyId2 = proxyId2;
pair.status = 0;
pair.userData = null;
pair.next = m_hashTable[hash];
m_hashTable[hash] = pIndex;
m_pairCount++;
return (pair);
}
private function ValidateTable():void{
}
public static function EqualsPair(pair1:b2BufferedPair, pair2:b2BufferedPair):Boolean{
return ((((pair1.proxyId1 == pair2.proxyId1)) && ((pair1.proxyId2 == pair2.proxyId2))));
}
public static function Hash(proxyId1:uint, proxyId2:uint):uint{
var key:uint = (((proxyId2 << 16) & 4294901760) | proxyId1);
key = (~(key) + ((key << 15) & 4294934528));
key = (key ^ ((key >> 12) & 1048575));
key = (key + ((key << 2) & 4294967292));
key = (key ^ ((key >> 4) & 268435455));
key = (key * 2057);
key = (key ^ ((key >> 16) & 0xFFFF));
return (key);
}
public static function Equals(pair:b2Pair, proxyId1:uint, proxyId2:uint):Boolean{
return ((((pair.proxyId1 == proxyId1)) && ((pair.proxyId2 == proxyId2))));
}
}
}//package Box2D.Collision
Section 23
//b2Proxy (Box2D.Collision.b2Proxy)
package Box2D.Collision {
public class b2Proxy {
public var overlapCount:uint;
public var userData;// = null
public var lowerBounds:Array;
public var upperBounds:Array;
public var timeStamp:uint;
public function b2Proxy(){
lowerBounds = [uint(0), uint(0)];
upperBounds = [uint(0), uint(0)];
super();
}
public function GetNext():uint{
return (lowerBounds[0]);
}
public function IsValid():Boolean{
return (!((overlapCount == b2BroadPhase.b2_invalid)));
}
public function SetNext(next:uint):void{
lowerBounds[0] = (next & 0xFFFF);
}
}
}//package Box2D.Collision
Section 24
//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();
}
}
}//package Box2D.Collision
Section 25
//Features (Box2D.Collision.Features)
package Box2D.Collision {
public class Features {
public var _referenceFace:int;
public var _incidentEdge:int;
public var _flip:int;
public var _incidentVertex:int;
public var _m_id:b2ContactID;
public function Features(){
super();
}
public function get referenceFace():int{
return (_referenceFace);
}
public function set incidentVertex(value:int):void{
_incidentVertex = value;
_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 referenceFace(value:int):void{
_referenceFace = value;
_m_id._key = ((_m_id._key & 4294967040) | (_referenceFace & 0xFF));
}
public function get incidentVertex():int{
return (_incidentVertex);
}
public function set flip(value:int):void{
_flip = value;
_m_id._key = ((_m_id._key & 0xFFFFFF) | ((_flip << 24) & 4278190080));
}
public function set incidentEdge(value:int):void{
_incidentEdge = value;
_m_id._key = ((_m_id._key & 4294902015) | ((_incidentEdge << 8) & 0xFF00));
}
}
}//package Box2D.Collision
Section 26
//b2Mat22 (Box2D.Common.Math.b2Mat22)
package Box2D.Common.Math {
public class b2Mat22 {
public var col1:b2Vec2;
public var col2:b2Vec2;
public function b2Mat22(angle:Number=0, c1:b2Vec2=null, c2:b2Vec2=null){
var c:Number;
var s:Number;
col1 = new b2Vec2();
col2 = new b2Vec2();
super();
if (((!((c1 == null))) && (!((c2 == null))))){
col1.SetV(c1);
col2.SetV(c2);
} else {
c = Math.cos(angle);
s = Math.sin(angle);
col1.x = c;
col2.x = -(s);
col1.y = s;
col2.y = c;
};
}
public function SetIdentity():void{
col1.x = 1;
col2.x = 0;
col1.y = 0;
col2.y = 1;
}
public function SetVV(c1:b2Vec2, c2:b2Vec2):void{
col1.SetV(c1);
col2.SetV(c2);
}
public function Set(angle:Number):void{
var c:Number;
c = Math.cos(angle);
var s:Number = Math.sin(angle);
col1.x = c;
col2.x = -(s);
col1.y = s;
col2.y = c;
}
public function SetZero():void{
col1.x = 0;
col2.x = 0;
col1.y = 0;
col2.y = 0;
}
public function SetM(m:b2Mat22):void{
col1.SetV(m.col1);
col2.SetV(m.col2);
}
public function AddM(m:b2Mat22):void{
col1.x = (col1.x + m.col1.x);
col1.y = (col1.y + m.col1.y);
col2.x = (col2.x + m.col2.x);
col2.y = (col2.y + m.col2.y);
}
public function Abs():void{
col1.Abs();
col2.Abs();
}
public function Copy():b2Mat22{
return (new b2Mat22(0, col1, col2));
}
public function Invert(out:b2Mat22):b2Mat22{
var a:Number;
var c:Number;
var det:Number;
a = col1.x;
var b:Number = col2.x;
c = col1.y;
var d:Number = col2.y;
det = ((a * d) - (b * c));
det = (1 / det);
out.col1.x = (det * d);
out.col2.x = (-(det) * b);
out.col1.y = (-(det) * c);
out.col2.y = (det * a);
return (out);
}
public function Solve(out:b2Vec2, bX:Number, bY:Number):b2Vec2{
var a11:Number = col1.x;
var a12:Number = col2.x;
var a21:Number = col1.y;
var a22:Number = col2.y;
var det:Number = ((a11 * a22) - (a12 * a21));
det = (1 / det);
out.x = (det * ((a22 * bX) - (a12 * bY)));
out.y = (det * ((a11 * bY) - (a21 * bX)));
return (out);
}
}
}//package Box2D.Common.Math
Section 27
//b2Math (Box2D.Common.Math.b2Math)
package Box2D.Common.Math {
public class b2Math {
public function b2Math(){
super();
}
public static function b2CrossVF(a:b2Vec2, s:Number):b2Vec2{
var v:b2Vec2 = new b2Vec2((s * a.y), (-(s) * a.x));
return (v);
}
public static function AddVV(a:b2Vec2, b:b2Vec2):b2Vec2{
var v:b2Vec2 = new b2Vec2((a.x + b.x), (a.y + b.y));
return (v);
}
public static function b2IsValid(x:Number):Boolean{
return (isFinite(x));
}
public static function b2Swap(a:Array, b:Array):void{
var tmp:* = a[0];
a[0] = b[0];
b[0] = tmp;
}
public static function b2Abs(a:Number):Number{
return (((a > 0)) ? a : -(a));
}
public static function b2AbsM(A:b2Mat22):b2Mat22{
var B:b2Mat22 = new b2Mat22(0, b2AbsV(A.col1), b2AbsV(A.col2));
return (B);
}
public static function SubtractVV(a:b2Vec2, b:b2Vec2):b2Vec2{
var v:b2Vec2 = new b2Vec2((a.x - b.x), (a.y - b.y));
return (v);
}
public static function b2CrossVV(a:b2Vec2, b:b2Vec2):Number{
return (((a.x * b.y) - (a.y * b.x)));
}
public static function b2Clamp(a:Number, low:Number, high:Number):Number{
return (b2Max(low, b2Min(a, high)));
}
public static function b2AbsV(a:b2Vec2):b2Vec2{
var b:b2Vec2 = new b2Vec2(b2Abs(a.x), b2Abs(a.y));
return (b);
}
public static function b2MinV(a:b2Vec2, b:b2Vec2):b2Vec2{
var c:b2Vec2 = new b2Vec2(b2Min(a.x, b.x), b2Min(a.y, b.y));
return (c);
}
public static function b2Dot(a:b2Vec2, b:b2Vec2):Number{
return (((a.x * b.x) + (a.y * b.y)));
}
public static function b2CrossFV(s:Number, a:b2Vec2):b2Vec2{
var v:b2Vec2 = new b2Vec2((-(s) * a.y), (s * a.x));
return (v);
}
public static function AddMM(A:b2Mat22, B:b2Mat22):b2Mat22{
var C:b2Mat22 = new b2Mat22(0, AddVV(A.col1, B.col1), AddVV(A.col2, B.col2));
return (C);
}
public static function b2MulTMM(A:b2Mat22, B:b2Mat22):b2Mat22{
var c1:b2Vec2 = new b2Vec2(b2Dot(A.col1, B.col1), b2Dot(A.col2, B.col1));
var c2:b2Vec2 = new b2Vec2(b2Dot(A.col1, B.col2), b2Dot(A.col2, B.col2));
var C:b2Mat22 = new b2Mat22(0, c1, c2);
return (C);
}
public static function b2MaxV(a:b2Vec2, b:b2Vec2):b2Vec2{
var c:b2Vec2 = new b2Vec2(b2Max(a.x, b.x), b2Max(a.y, b.y));
return (c);
}
public static function b2IsPowerOfTwo(x:uint):Boolean{
var result:Boolean = (((x > 0)) && (((x & (x - 1)) == 0)));
return (result);
}
public static function b2ClampV(a:b2Vec2, low:b2Vec2, high:b2Vec2):b2Vec2{
return (b2MaxV(low, b2MinV(a, high)));
}
public static function MulFV(s:Number, a:b2Vec2):b2Vec2{
var v:b2Vec2 = new b2Vec2((s * a.x), (s * a.y));
return (v);
}
public static function b2MulTMV(A:b2Mat22, v:b2Vec2):b2Vec2{
var u:b2Vec2 = new b2Vec2(b2Dot(v, A.col1), b2Dot(v, A.col2));
return (u);
}
public static function b2Min(a:Number, b:Number):Number{
return (((a < b)) ? a : b);
}
public static function b2Random():Number{
return (((Math.random() * 2) - 1));
}
public static function b2MulMM(A:b2Mat22, B:b2Mat22):b2Mat22{
var C:b2Mat22 = new b2Mat22(0, b2MulMV(A, B.col1), b2MulMV(A, B.col2));
return (C);
}
public static function b2NextPowerOfTwo(x:uint):uint{
x = (x | ((x >> 1) & 2147483647));
x = (x | ((x >> 2) & 1073741823));
x = (x | ((x >> 4) & 268435455));
x = (x | ((x >> 8) & 0xFFFFFF));
x = (x | ((x >> 16) & 0xFFFF));
return ((x + 1));
}
public static function b2Max(a:Number, b:Number):Number{
return (((a > b)) ? a : b);
}
public static function b2MulMV(A:b2Mat22, v:b2Vec2):b2Vec2{
var u:b2Vec2 = new b2Vec2(((A.col1.x * v.x) + (A.col2.x * v.y)), ((A.col1.y * v.x) + (A.col2.y * v.y)));
return (u);
}
}
}//package Box2D.Common.Math
Section 28
//b2Vec2 (Box2D.Common.Math.b2Vec2)
package Box2D.Common.Math {
public class b2Vec2 {
public var y:Number;
public var x:Number;
public function b2Vec2(x_:Number=0, y_:Number=0):void{
super();
x = x_;
y = y_;
}
public function Add(v:b2Vec2):void{
x = (x + v.x);
y = (y + v.y);
}
public function Set(x_:Number=0, y_:Number=0):void{
x = x_;
y = y_;
}
public function Multiply(a:Number):void{
x = (x * a);
y = (y * a);
}
public function Length():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function MulM(A:b2Mat22):void{
var tX:Number = x;
x = ((A.col1.x * tX) + (A.col2.x * y));
y = ((A.col1.y * tX) + (A.col2.y * y));
}
public function SetZero():void{
x = 0;
y = 0;
}
public function MinV(b:b2Vec2):void{
x = ((x < b.x)) ? x : b.x;
y = ((y < b.y)) ? y : b.y;
}
public function Normalize():Number{
var length:Number = Length();
if (length < Number.MIN_VALUE){
return (0);
};
var invLength:Number = (1 / length);
x = (x * invLength);
y = (y * invLength);
return (length);
}
public function CrossVF(s:Number):void{
var tX:Number = x;
x = (s * y);
y = (-(s) * tX);
}
public function MaxV(b:b2Vec2):void{
x = ((x > b.x)) ? x : b.x;
y = ((y > b.y)) ? y : b.y;
}
public function SetV(v:b2Vec2):void{
x = v.x;
y = v.y;
}
public function Negative():b2Vec2{
return (new b2Vec2(-(x), -(y)));
}
public function CrossFV(s:Number):void{
var tX:Number = x;
x = (-(s) * y);
y = (s * tX);
}
public function Abs():void{
x = Math.abs(x);
y = Math.abs(y);
}
public function Subtract(v:b2Vec2):void{
x = (x - v.x);
y = (y - v.y);
}
public function Copy():b2Vec2{
return (new b2Vec2(x, y));
}
public function MulTM(A:b2Mat22):void{
var tX:Number = b2Math.b2Dot(this, A.col1);
y = b2Math.b2Dot(this, A.col2);
x = tX;
}
public function IsValid():Boolean{
return (((b2Math.b2IsValid(x)) && (b2Math.b2IsValid(y))));
}
public static function Make(x_:Number, y_:Number):b2Vec2{
return (new b2Vec2(x_, y_));
}
}
}//package Box2D.Common.Math
Section 29
//b2Settings (Box2D.Common.b2Settings)
package Box2D.Common {
import Box2D.Common.Math.*;
public class b2Settings {
public static const b2_lengthUnitsPerMeter:Number = 30;
public static const b2_angularSleepTolerance:Number = 0.0111111111111111;
public static const b2_linearSleepTolerance:Number = 0.3;
public static const b2_angularSlop:Number = 0.0349065850398866;
public static const b2_linearSlop:Number = 0.15;
public static const b2_pi:Number = 3.14159265358979;
public static const b2_maxShapesPerBody:int = 64;
public static const b2_maxProxies:int = 0x0400;
public static const b2_velocityThreshold:Number = 30;
public static const b2_timeToSleep:Number = 0.5;
public static const b2_contactBaumgarte:Number = 0.2;
public static const b2_maxPairs:int = 8192;
public static const b2_maxManifoldPoints:int = 2;
public static const b2_massUnitsPerKilogram:Number = 1;
public static const b2_maxAngularCorrection:Number = 0.139626340159546;
public static const USHRT_MAX:int = 0xFFFF;
public static const b2_maxLinearCorrection:Number = 6;
public static const b2_maxPolyVertices:int = 8;
public static const b2_timeUnitsPerSecond:Number = 1;
public function b2Settings(){
super();
}
public static function b2Assert(a:Boolean):void{
var nullVec:b2Vec2;
if (!a){
nullVec.x++;
};
}
}
}//package Box2D.Common
Section 30
//b2CircleContact (Box2D.Dynamics.Contacts.b2CircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2CircleContact extends b2Contact {
public var m_manifold:Array;
public function b2CircleContact(shape1:b2Shape, shape2:b2Shape){
m_manifold = [new b2Manifold()];
super(shape1, shape2);
m_manifold[0].pointCount = 0;
m_manifold[0].points[0].normalImpulse = 0;
m_manifold[0].points[0].tangentImpulse = 0;
}
override public function Evaluate():void{
b2Collision.b2CollideCircle(m_manifold[0], (m_shape1 as b2CircleShape), (m_shape2 as b2CircleShape), false);
if (m_manifold[0].pointCount > 0){
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
}
override public function GetManifolds():Array{
return (m_manifold);
}
public static function Destroy(contact:b2Contact, allocator):void{
}
public static function Create(shape1:b2Shape, shape2:b2Shape, allocator):b2Contact{
return (new b2CircleContact(shape1, shape2));
}
}
}//package Box2D.Dynamics.Contacts
Section 31
//b2Contact (Box2D.Dynamics.Contacts.b2Contact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Contact {
public var m_shape1:b2Shape;
public var m_shape2:b2Shape;
public var m_next:b2Contact;
public var m_prev:b2Contact;
public var m_friction:Number;
public var m_manifoldCount:int;
public var m_node1:b2ContactNode;
public var m_node2:b2ContactNode;
public var m_restitution:Number;
public var m_flags:uint;
public static var s_registers:Array;
public static var s_initialized:Boolean = false;
public static var e_islandFlag:uint = 1;
public static var e_destroyFlag:uint = 2;
public function b2Contact(s1:b2Shape=null, s2:b2Shape=null){
m_node1 = new b2ContactNode();
m_node2 = new b2ContactNode();
super();
m_flags = 0;
if (((!(s1)) || (!(s2)))){
m_shape1 = null;
m_shape2 = null;
return;
};
m_shape1 = s1;
m_shape2 = s2;
m_manifoldCount = 0;
m_friction = Math.sqrt((m_shape1.m_friction * m_shape2.m_friction));
m_restitution = b2Math.b2Max(m_shape1.m_restitution, m_shape2.m_restitution);
m_prev = null;
m_next = null;
m_node1.contact = null;
m_node1.prev = null;
m_node1.next = null;
m_node1.other = null;
m_node2.contact = null;
m_node2.prev = null;
m_node2.next = null;
m_node2.other = null;
}
public function GetShape1():b2Shape{
return (m_shape1);
}
public function GetShape2():b2Shape{
return (m_shape2);
}
public function GetManifoldCount():int{
return (m_manifoldCount);
}
public function GetNext():b2Contact{
return (m_next);
}
public function GetManifolds():Array{
return (null);
}
public function Evaluate():void{
}
public static function InitializeRegisters():void{
var j:int;
s_registers = new Array(b2Shape.e_shapeTypeCount);
var i:int;
while (i < b2Shape.e_shapeTypeCount) {
s_registers[i] = new Array(b2Shape.e_shapeTypeCount);
j = 0;
while (j < b2Shape.e_shapeTypeCount) {
s_registers[i][j] = new b2ContactRegister();
j++;
};
i++;
};
AddType(b2CircleContact.Create, b2CircleContact.Destroy, b2Shape.e_circleShape, b2Shape.e_circleShape);
AddType(b2PolyAndCircleContact.Create, b2PolyAndCircleContact.Destroy, b2Shape.e_polyShape, b2Shape.e_circleShape);
AddType(b2PolyContact.Create, b2PolyContact.Destroy, b2Shape.e_polyShape, b2Shape.e_polyShape);
}
public static function Destroy(contact:b2Contact, allocator):void{
if (contact.GetManifoldCount() > 0){
contact.m_shape1.m_body.WakeUp();
contact.m_shape2.m_body.WakeUp();
};
var type1:int = contact.m_shape1.m_type;
var type2:int = contact.m_shape2.m_type;
var destroyFcn:* = s_registers[type1][type2].destroyFcn;
destroyFcn(contact, allocator);
}
public static function AddType(createFcn, destroyFcn, type1:int, type2:int):void{
s_registers[type1][type2].createFcn = createFcn;
s_registers[type1][type2].destroyFcn = destroyFcn;
s_registers[type1][type2].primary = true;
if (type1 != type2){
s_registers[type2][type1].createFcn = createFcn;
s_registers[type2][type1].destroyFcn = destroyFcn;
s_registers[type2][type1].primary = false;
};
}
public static function Create(shape1:b2Shape, shape2:b2Shape, allocator):b2Contact{
var c:b2Contact;
var i:int;
var m:b2Manifold;
if (s_initialized == false){
InitializeRegisters();
s_initialized = true;
};
var type1:int = shape1.m_type;
var type2:int = shape2.m_type;
var createFcn:* = s_registers[type1][type2].createFcn;
if (createFcn){
if (s_registers[type1][type2].primary){
return (createFcn(shape1, shape2, allocator));
};
c = createFcn(shape2, shape1, allocator);
i = 0;
while (i < c.GetManifoldCount()) {
m = c.GetManifolds()[i];
m.normal = m.normal.Negative();
i++;
};
return (c);
//unresolved jump
};
return (null);
}
}
}//package Box2D.Dynamics.Contacts
Section 32
//b2ContactConstraint (Box2D.Dynamics.Contacts.b2ContactConstraint)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2ContactConstraint {
public var points:Array;
public var normal:b2Vec2;
public var restitution:Number;
public var body1:b2Body;
public var manifold:b2Manifold;
public var body2:b2Body;
public var friction:Number;
public var pointCount:int;
public function b2ContactConstraint(){
normal = new b2Vec2();
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
points[i] = new b2ContactConstraintPoint();
i++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 33
//b2ContactConstraintPoint (Box2D.Dynamics.Contacts.b2ContactConstraintPoint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
public class b2ContactConstraintPoint {
public var separation:Number;
public var positionImpulse:Number;
public var normalImpulse:Number;
public var tangentImpulse:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var tangentMass:Number;
public var normalMass:Number;
public var velocityBias:Number;
public function b2ContactConstraintPoint(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 34
//b2ContactNode (Box2D.Dynamics.Contacts.b2ContactNode)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
public class b2ContactNode {
public var other:b2Body;
public var prev:b2ContactNode;
public var contact:b2Contact;
public var next:b2ContactNode;
public function b2ContactNode(){
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 35
//b2ContactRegister (Box2D.Dynamics.Contacts.b2ContactRegister)
package Box2D.Dynamics.Contacts {
public class b2ContactRegister {
public var primary:Boolean;
public var createFcn;
public var destroyFcn;
public function b2ContactRegister(){
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 36
//b2ContactSolver (Box2D.Dynamics.Contacts.b2ContactSolver)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2ContactSolver {
public var m_constraintCount:int;
public var m_constraints:Array;
public var m_allocator;
public function b2ContactSolver(contacts:Array, contactCount:int, allocator){
var i:int;
var tVec:b2Vec2;
var tMat:b2Mat22;
var contact:b2Contact;
var b1:b2Body;
var b2:b2Body;
var manifoldCount:int;
var manifolds:Array;
var friction:Number;
var restitution:Number;
var v1X:Number;
var v1Y:Number;
var v2X:Number;
var v2Y:Number;
var w1:Number;
var w2:Number;
var j:int;
var manifold:b2Manifold;
var normalX:Number;
var normalY:Number;
var c:b2ContactConstraint;
var k:uint;
var cp:b2ContactPoint;
var ccp:b2ContactConstraintPoint;
var r1X:Number;
var r1Y:Number;
var r2X:Number;
var r2Y:Number;
var r1Sqr:Number;
var r2Sqr:Number;
var rn1:Number;
var rn2:Number;
var kNormal:Number;
var tangentX:Number;
var tangentY:Number;
var rt1:Number;
var rt2:Number;
var kTangent:Number;
var tX:Number;
var tY:Number;
var vRel:Number;
m_constraints = new Array();
super();
m_allocator = allocator;
m_constraintCount = 0;
i = 0;
while (i < contactCount) {
m_constraintCount = (m_constraintCount + contacts[i].GetManifoldCount());
i++;
};
i = 0;
while (i < m_constraintCount) {
m_constraints[i] = new b2ContactConstraint();
i++;
};
var count:int;
i = 0;
while (i < contactCount) {
contact = contacts[i];
b1 = contact.m_shape1.m_body;
b2 = contact.m_shape2.m_body;
manifoldCount = contact.GetManifoldCount();
manifolds = contact.GetManifolds();
friction = contact.m_friction;
restitution = contact.m_restitution;
v1X = b1.m_linearVelocity.x;
v1Y = b1.m_linearVelocity.y;
v2X = b2.m_linearVelocity.x;
v2Y = b2.m_linearVelocity.y;
w1 = b1.m_angularVelocity;
w2 = b2.m_angularVelocity;
j = 0;
while (j < manifoldCount) {
manifold = manifolds[j];
normalX = manifold.normal.x;
normalY = manifold.normal.y;
c = m_constraints[count];
c.body1 = b1;
c.body2 = b2;
c.manifold = manifold;
c.normal.x = normalX;
c.normal.y = normalY;
c.pointCount = manifold.pointCount;
c.friction = friction;
c.restitution = restitution;
k = 0;
while (k < c.pointCount) {
cp = manifold.points[k];
ccp = c.points[k];
ccp.normalImpulse = cp.normalImpulse;
ccp.tangentImpulse = cp.tangentImpulse;
ccp.separation = cp.separation;
r1X = (cp.position.x - b1.m_position.x);
r1Y = (cp.position.y - b1.m_position.y);
r2X = (cp.position.x - b2.m_position.x);
r2Y = (cp.position.y - b2.m_position.y);
tVec = ccp.localAnchor1;
tMat = b1.m_R;
tVec.x = ((r1X * tMat.col1.x) + (r1Y * tMat.col1.y));
tVec.y = ((r1X * tMat.col2.x) + (r1Y * tMat.col2.y));
tVec = ccp.localAnchor2;
tMat = b2.m_R;
tVec.x = ((r2X * tMat.col1.x) + (r2Y * tMat.col1.y));
tVec.y = ((r2X * tMat.col2.x) + (r2Y * tMat.col2.y));
r1Sqr = ((r1X * r1X) + (r1Y * r1Y));
r2Sqr = ((r2X * r2X) + (r2Y * r2Y));
rn1 = ((r1X * normalX) + (r1Y * normalY));
rn2 = ((r2X * normalX) + (r2Y * normalY));
kNormal = (b1.m_invMass + b2.m_invMass);
kNormal = (kNormal + ((b1.m_invI * (r1Sqr - (rn1 * rn1))) + (b2.m_invI * (r2Sqr - (rn2 * rn2)))));
ccp.normalMass = (1 / kNormal);
tangentX = normalY;
tangentY = -(normalX);
rt1 = ((r1X * tangentX) + (r1Y * tangentY));
rt2 = ((r2X * tangentX) + (r2Y * tangentY));
kTangent = (b1.m_invMass + b2.m_invMass);
kTangent = (kTangent + ((b1.m_invI * (r1Sqr - (rt1 * rt1))) + (b2.m_invI * (r2Sqr - (rt2 * rt2)))));
ccp.tangentMass = (1 / kTangent);
ccp.velocityBias = 0;
if (ccp.separation > 0){
ccp.velocityBias = (-60 * ccp.separation);
};
tX = (((v2X + (-(w2) * r2Y)) - v1X) - (-(w1) * r1Y));
tY = (((v2Y + (w2 * r2X)) - v1Y) - (w1 * r1X));
vRel = ((c.normal.x * tX) + (c.normal.y * tY));
if (vRel < -(b2Settings.b2_velocityThreshold)){
ccp.velocityBias = (ccp.velocityBias + (-(c.restitution) * vRel));
};
k++;
};
count++;
j++;
};
i++;
};
}
public function SolveVelocityConstraints():void{
var j:int;
var ccp:b2ContactConstraintPoint;
var r1X:Number;
var r1Y:Number;
var r2X:Number;
var r2Y:Number;
var dvX:Number;
var dvY:Number;
var lambda:Number;
var newImpulse:Number;
var PX:Number;
var PY:Number;
var tMat:b2Mat22;
var tVec:b2Vec2;
var c:b2ContactConstraint;
var b1:b2Body;
var b2:b2Body;
var b1_angularVelocity:Number;
var b1_linearVelocity:b2Vec2;
var b2_angularVelocity:Number;
var b2_linearVelocity:b2Vec2;
var invMass1:Number;
var invI1:Number;
var invMass2:Number;
var invI2:Number;
var normalX:Number;
var normalY:Number;
var tangentX:Number;
var tangentY:Number;
var tCount:int;
var vn:Number;
var vt:Number;
var maxFriction:Number;
var i:int;
while (i < m_constraintCount) {
c = m_constraints[i];
b1 = c.body1;
b2 = c.body2;
b1_angularVelocity = b1.m_angularVelocity;
b1_linearVelocity = b1.m_linearVelocity;
b2_angularVelocity = b2.m_angularVelocity;
b2_linearVelocity = b2.m_linearVelocity;
invMass1 = b1.m_invMass;
invI1 = b1.m_invI;
invMass2 = b2.m_invMass;
invI2 = b2.m_invI;
normalX = c.normal.x;
normalY = c.normal.y;
tangentX = normalY;
tangentY = -(normalX);
tCount = c.pointCount;
j = 0;
while (j < tCount) {
ccp = c.points[j];
tMat = b1.m_R;
tVec = ccp.localAnchor1;
r1X = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
r1Y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = b2.m_R;
tVec = ccp.localAnchor2;
r2X = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
r2Y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
dvX = (((b2_linearVelocity.x + (-(b2_angularVelocity) * r2Y)) - b1_linearVelocity.x) - (-(b1_angularVelocity) * r1Y));
dvY = (((b2_linearVelocity.y + (b2_angularVelocity * r2X)) - b1_linearVelocity.y) - (b1_angularVelocity * r1X));
vn = ((dvX * normalX) + (dvY * normalY));
lambda = (-(ccp.normalMass) * (vn - ccp.velocityBias));
newImpulse = b2Math.b2Max((ccp.normalImpulse + lambda), 0);
lambda = (newImpulse - ccp.normalImpulse);
PX = (lambda * normalX);
PY = (lambda * normalY);
b1_linearVelocity.x = (b1_linearVelocity.x - (invMass1 * PX));
b1_linearVelocity.y = (b1_linearVelocity.y - (invMass1 * PY));
b1_angularVelocity = (b1_angularVelocity - (invI1 * ((r1X * PY) - (r1Y * PX))));
b2_linearVelocity.x = (b2_linearVelocity.x + (invMass2 * PX));
b2_linearVelocity.y = (b2_linearVelocity.y + (invMass2 * PY));
b2_angularVelocity = (b2_angularVelocity + (invI2 * ((r2X * PY) - (r2Y * PX))));
ccp.normalImpulse = newImpulse;
dvX = (((b2_linearVelocity.x + (-(b2_angularVelocity) * r2Y)) - b1_linearVelocity.x) - (-(b1_angularVelocity) * r1Y));
dvY = (((b2_linearVelocity.y + (b2_angularVelocity * r2X)) - b1_linearVelocity.y) - (b1_angularVelocity * r1X));
vt = ((dvX * tangentX) + (dvY * tangentY));
lambda = (ccp.tangentMass * -(vt));
maxFriction = (c.friction * ccp.normalImpulse);
newImpulse = b2Math.b2Clamp((ccp.tangentImpulse + lambda), -(maxFriction), maxFriction);
lambda = (newImpulse - ccp.tangentImpulse);
PX = (lambda * tangentX);
PY = (lambda * tangentY);
b1_linearVelocity.x = (b1_linearVelocity.x - (invMass1 * PX));
b1_linearVelocity.y = (b1_linearVelocity.y - (invMass1 * PY));
b1_angularVelocity = (b1_angularVelocity - (invI1 * ((r1X * PY) - (r1Y * PX))));
b2_linearVelocity.x = (b2_linearVelocity.x + (invMass2 * PX));
b2_linearVelocity.y = (b2_linearVelocity.y + (invMass2 * PY));
b2_angularVelocity = (b2_angularVelocity + (invI2 * ((r2X * PY) - (r2Y * PX))));
ccp.tangentImpulse = newImpulse;
j++;
};
b1.m_angularVelocity = b1_angularVelocity;
b2.m_angularVelocity = b2_angularVelocity;
i++;
};
}
public function PreSolve():void{
var tVec:b2Vec2;
var tVec2:b2Vec2;
var tMat:b2Mat22;
var c:b2ContactConstraint;
var b1:b2Body;
var b2:b2Body;
var invMass1:Number;
var invI1:Number;
var invMass2:Number;
var invI2:Number;
var normalX:Number;
var normalY:Number;
var tangentX:Number;
var tangentY:Number;
var j:int;
var tCount:int;
var ccp:b2ContactConstraintPoint;
var PX:Number;
var PY:Number;
var r1X:Number;
var r1Y:Number;
var r2X:Number;
var r2Y:Number;
var ccp2:b2ContactConstraintPoint;
var i:int;
while (i < m_constraintCount) {
c = m_constraints[i];
b1 = c.body1;
b2 = c.body2;
invMass1 = b1.m_invMass;
invI1 = b1.m_invI;
invMass2 = b2.m_invMass;
invI2 = b2.m_invI;
normalX = c.normal.x;
normalY = c.normal.y;
tangentX = normalY;
tangentY = -(normalX);
if (b2World.s_enableWarmStarting){
tCount = c.pointCount;
j = 0;
while (j < tCount) {
ccp = c.points[j];
PX = ((ccp.normalImpulse * normalX) + (ccp.tangentImpulse * tangentX));
PY = ((ccp.normalImpulse * normalY) + (ccp.tangentImpulse * tangentY));
tMat = b1.m_R;
tVec = ccp.localAnchor1;
r1X = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
r1Y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = b2.m_R;
tVec = ccp.localAnchor2;
r2X = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
r2Y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
b1.m_angularVelocity = (b1.m_angularVelocity - (invI1 * ((r1X * PY) - (r1Y * PX))));
b1.m_linearVelocity.x = (b1.m_linearVelocity.x - (invMass1 * PX));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y - (invMass1 * PY));
b2.m_angularVelocity = (b2.m_angularVelocity + (invI2 * ((r2X * PY) - (r2Y * PX))));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (invMass2 * PX));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (invMass2 * PY));
ccp.positionImpulse = 0;
j++;
};
} else {
tCount = c.pointCount;
j = 0;
while (j < tCount) {
ccp2 = c.points[j];
ccp2.normalImpulse = 0;
ccp2.tangentImpulse = 0;
ccp2.positionImpulse = 0;
j++;
};
};
i++;
};
}
public function SolvePositionConstraints(beta:Number):Boolean{
var tMat:b2Mat22;
var tVec:b2Vec2;
var c:b2ContactConstraint;
var b1:b2Body;
var b2:b2Body;
var b1_position:b2Vec2;
var b1_rotation:Number;
var b2_position:b2Vec2;
var b2_rotation:Number;
var invMass1:Number;
var invI1:Number;
var invMass2:Number;
var invI2:Number;
var normalX:Number;
var normalY:Number;
var tangentX:Number;
var tangentY:Number;
var tCount:int;
var j:int;
var ccp:b2ContactConstraintPoint;
var r1X:Number;
var r1Y:Number;
var r2X:Number;
var r2Y:Number;
var p1X:Number;
var p1Y:Number;
var p2X:Number;
var p2Y:Number;
var dpX:Number;
var dpY:Number;
var separation:Number;
var C:Number;
var dImpulse:Number;
var impulse0:Number;
var impulseX:Number;
var impulseY:Number;
var minSeparation:Number = 0;
var i:int;
while (i < m_constraintCount) {
c = m_constraints[i];
b1 = c.body1;
b2 = c.body2;
b1_position = b1.m_position;
b1_rotation = b1.m_rotation;
b2_position = b2.m_position;
b2_rotation = b2.m_rotation;
invMass1 = b1.m_invMass;
invI1 = b1.m_invI;
invMass2 = b2.m_invMass;
invI2 = b2.m_invI;
normalX = c.normal.x;
normalY = c.normal.y;
tangentX = normalY;
tangentY = -(normalX);
tCount = c.pointCount;
j = 0;
while (j < tCount) {
ccp = c.points[j];
tMat = b1.m_R;
tVec = ccp.localAnchor1;
r1X = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
r1Y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = b2.m_R;
tVec = ccp.localAnchor2;
r2X = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
r2Y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
p1X = (b1_position.x + r1X);
p1Y = (b1_position.y + r1Y);
p2X = (b2_position.x + r2X);
p2Y = (b2_position.y + r2Y);
dpX = (p2X - p1X);
dpY = (p2Y - p1Y);
separation = (((dpX * normalX) + (dpY * normalY)) + ccp.separation);
minSeparation = b2Math.b2Min(minSeparation, separation);
C = (beta * b2Math.b2Clamp((separation + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0));
dImpulse = (-(ccp.normalMass) * C);
impulse0 = ccp.positionImpulse;
ccp.positionImpulse = b2Math.b2Max((impulse0 + dImpulse), 0);
dImpulse = (ccp.positionImpulse - impulse0);
impulseX = (dImpulse * normalX);
impulseY = (dImpulse * normalY);
b1_position.x = (b1_position.x - (invMass1 * impulseX));
b1_position.y = (b1_position.y - (invMass1 * impulseY));
b1_rotation = (b1_rotation - (invI1 * ((r1X * impulseY) - (r1Y * impulseX))));
b1.m_R.Set(b1_rotation);
b2_position.x = (b2_position.x + (invMass2 * impulseX));
b2_position.y = (b2_position.y + (invMass2 * impulseY));
b2_rotation = (b2_rotation + (invI2 * ((r2X * impulseY) - (r2Y * impulseX))));
b2.m_R.Set(b2_rotation);
j++;
};
b1.m_rotation = b1_rotation;
b2.m_rotation = b2_rotation;
i++;
};
return ((minSeparation >= -(b2Settings.b2_linearSlop)));
}
public function PostSolve():void{
var c:b2ContactConstraint;
var m:b2Manifold;
var j:int;
var mPoint:b2ContactPoint;
var cPoint:b2ContactConstraintPoint;
var i:int;
while (i < m_constraintCount) {
c = m_constraints[i];
m = c.manifold;
j = 0;
while (j < c.pointCount) {
mPoint = m.points[j];
cPoint = c.points[j];
mPoint.normalImpulse = cPoint.normalImpulse;
mPoint.tangentImpulse = cPoint.tangentImpulse;
j++;
};
i++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 37
//b2NullContact (Box2D.Dynamics.Contacts.b2NullContact)
package Box2D.Dynamics.Contacts {
public class b2NullContact extends b2Contact {
public function b2NullContact():void{
super();
}
override public function Evaluate():void{
}
override public function GetManifolds():Array{
return (null);
}
}
}//package Box2D.Dynamics.Contacts
Section 38
//b2PolyAndCircleContact (Box2D.Dynamics.Contacts.b2PolyAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolyAndCircleContact extends b2Contact {
public var m_manifold:Array;
public function b2PolyAndCircleContact(shape1:b2Shape, shape2:b2Shape){
m_manifold = [new b2Manifold()];
super(shape1, shape2);
b2Settings.b2Assert((m_shape1.m_type == b2Shape.e_polyShape));
b2Settings.b2Assert((m_shape2.m_type == b2Shape.e_circleShape));
m_manifold[0].pointCount = 0;
m_manifold[0].points[0].normalImpulse = 0;
m_manifold[0].points[0].tangentImpulse = 0;
}
override public function Evaluate():void{
b2Collision.b2CollidePolyAndCircle(m_manifold[0], (m_shape1 as b2PolyShape), (m_shape2 as b2CircleShape), false);
if (m_manifold[0].pointCount > 0){
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
}
override public function GetManifolds():Array{
return (m_manifold);
}
public static function Destroy(contact:b2Contact, allocator):void{
}
public static function Create(shape1:b2Shape, shape2:b2Shape, allocator):b2Contact{
return (new b2PolyAndCircleContact(shape1, shape2));
}
}
}//package Box2D.Dynamics.Contacts
Section 39
//b2PolyContact (Box2D.Dynamics.Contacts.b2PolyContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolyContact extends b2Contact {
public var m_manifold:Array;
private var m0:b2Manifold;
public function b2PolyContact(shape1:b2Shape, shape2:b2Shape):void{
m0 = new b2Manifold();
m_manifold = [new b2Manifold()];
super(shape1, shape2);
m_manifold[0].pointCount = 0;
}
override public function Evaluate():void{
var tPoint:b2ContactPoint;
var tPoint0:b2ContactPoint;
var match:Array;
var i:int;
var cp:b2ContactPoint;
var idKey:uint;
var j:int;
var cp0:b2ContactPoint;
var id0:b2ContactID;
var tMani:b2Manifold = m_manifold[0];
var tPoints:Array = m0.points;
var k:int;
while (k < tMani.pointCount) {
tPoint = tPoints[k];
tPoint0 = tMani.points[k];
tPoint.normalImpulse = tPoint0.normalImpulse;
tPoint.tangentImpulse = tPoint0.tangentImpulse;
tPoint.id = tPoint0.id.Copy();
k++;
};
m0.pointCount = tMani.pointCount;
b2Collision.b2CollidePoly(tMani, (m_shape1 as b2PolyShape), (m_shape2 as b2PolyShape), false);
if (tMani.pointCount > 0){
match = [false, false];
i = 0;
while (i < tMani.pointCount) {
cp = tMani.points[i];
cp.normalImpulse = 0;
cp.tangentImpulse = 0;
idKey = cp.id.key;
j = 0;
while (j < m0.pointCount) {
if (match[j] == true){
} else {
cp0 = m0.points[j];
id0 = cp0.id;
if (id0.key == idKey){
match[j] = true;
cp.normalImpulse = cp0.normalImpulse;
cp.tangentImpulse = cp0.tangentImpulse;
break;
};
};
j++;
};
i++;
};
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
}
override public function GetManifolds():Array{
return (m_manifold);
}
public static function Destroy(contact:b2Contact, allocator):void{
}
public static function Create(shape1:b2Shape, shape2:b2Shape, allocator):b2Contact{
return (new b2PolyContact(shape1, shape2));
}
}
}//package Box2D.Dynamics.Contacts
Section 40
//b2DistanceJoint (Box2D.Dynamics.Joints.b2DistanceJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2DistanceJoint extends b2Joint {
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_u:b2Vec2;
public var m_impulse:Number;
public var m_length:Number;
public var m_mass:Number;
public function b2DistanceJoint(def:b2DistanceJointDef){
var tMat:b2Mat22;
var tX:Number;
var tY:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_u = new b2Vec2();
super(def);
tMat = m_body1.m_R;
tX = (def.anchorPoint1.x - m_body1.m_position.x);
tY = (def.anchorPoint1.y - m_body1.m_position.y);
m_localAnchor1.x = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
m_localAnchor1.y = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
tMat = m_body2.m_R;
tX = (def.anchorPoint2.x - m_body2.m_position.x);
tY = (def.anchorPoint2.y - m_body2.m_position.y);
m_localAnchor2.x = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
m_localAnchor2.y = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
tX = (def.anchorPoint2.x - def.anchorPoint1.x);
tY = (def.anchorPoint2.y - def.anchorPoint1.y);
m_length = Math.sqrt(((tX * tX) + (tY * tY)));
m_impulse = 0;
}
override public function GetAnchor1():b2Vec2{
return (b2Math.AddVV(m_body1.m_position, b2Math.b2MulMV(m_body1.m_R, m_localAnchor1)));
}
override public function GetAnchor2():b2Vec2{
return (b2Math.AddVV(m_body2.m_position, b2Math.b2MulMV(m_body2.m_R, m_localAnchor2)));
}
override public function GetReactionTorque(invTimeStep:Number):Number{
return (0);
}
override public function GetReactionForce(invTimeStep:Number):b2Vec2{
var F:b2Vec2 = new b2Vec2();
F.SetV(m_u);
F.Multiply((m_impulse * invTimeStep));
return (F);
}
override public function SolvePositionConstraints():Boolean{
var tMat:b2Mat22;
tMat = m_body1.m_R;
var r1X:Number = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
var r1Y:Number = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = m_body2.m_R;
var r2X:Number = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
var r2Y:Number = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
var dX:Number = (((m_body2.m_position.x + r2X) - m_body1.m_position.x) - r1X);
var dY:Number = (((m_body2.m_position.y + r2Y) - m_body1.m_position.y) - r1Y);
var length:Number = Math.sqrt(((dX * dX) + (dY * dY)));
dX = (dX / length);
dY = (dY / length);
var C:Number = (length - m_length);
C = b2Math.b2Clamp(C, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
var impulse:Number = (-(m_mass) * C);
m_u.Set(dX, dY);
var PX:Number = (impulse * m_u.x);
var PY:Number = (impulse * m_u.y);
m_body1.m_position.x = (m_body1.m_position.x - (m_body1.m_invMass * PX));
m_body1.m_position.y = (m_body1.m_position.y - (m_body1.m_invMass * PY));
m_body1.m_rotation = (m_body1.m_rotation - (m_body1.m_invI * ((r1X * PY) - (r1Y * PX))));
m_body2.m_position.x = (m_body2.m_position.x + (m_body2.m_invMass * PX));
m_body2.m_position.y = (m_body2.m_position.y + (m_body2.m_invMass * PY));
m_body2.m_rotation = (m_body2.m_rotation + (m_body2.m_invI * ((r2X * PY) - (r2Y * PX))));
m_body1.m_R.Set(m_body1.m_rotation);
m_body2.m_R.Set(m_body2.m_rotation);
return ((b2Math.b2Abs(C) < b2Settings.b2_linearSlop));
}
override public function PrepareVelocitySolver():void{
var tMat:b2Mat22;
var r1X:Number;
var r1Y:Number;
var r2X:Number;
var r2Y:Number;
var PX:Number;
var PY:Number;
tMat = m_body1.m_R;
r1X = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
r1Y = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = m_body2.m_R;
r2X = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
r2Y = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
m_u.x = (((m_body2.m_position.x + r2X) - m_body1.m_position.x) - r1X);
m_u.y = (((m_body2.m_position.y + r2Y) - m_body1.m_position.y) - r1Y);
var length:Number = Math.sqrt(((m_u.x * m_u.x) + (m_u.y * m_u.y)));
if (length > b2Settings.b2_linearSlop){
m_u.Multiply((1 / length));
} else {
m_u.SetZero();
};
var cr1u:Number = ((r1X * m_u.y) - (r1Y * m_u.x));
var cr2u:Number = ((r2X * m_u.y) - (r2Y * m_u.x));
m_mass = (((m_body1.m_invMass + ((m_body1.m_invI * cr1u) * cr1u)) + m_body2.m_invMass) + ((m_body2.m_invI * cr2u) * cr2u));
m_mass = (1 / m_mass);
if (b2World.s_enableWarmStarting){
PX = (m_impulse * m_u.x);
PY = (m_impulse * m_u.y);
m_body1.m_linearVelocity.x = (m_body1.m_linearVelocity.x - (m_body1.m_invMass * PX));
m_body1.m_linearVelocity.y = (m_body1.m_linearVelocity.y - (m_body1.m_invMass * PY));
m_body1.m_angularVelocity = (m_body1.m_angularVelocity - (m_body1.m_invI * ((r1X * PY) - (r1Y * PX))));
m_body2.m_linearVelocity.x = (m_body2.m_linearVelocity.x + (m_body2.m_invMass * PX));
m_body2.m_linearVelocity.y = (m_body2.m_linearVelocity.y + (m_body2.m_invMass * PY));
m_body2.m_angularVelocity = (m_body2.m_angularVelocity + (m_body2.m_invI * ((r2X * PY) - (r2Y * PX))));
} else {
m_impulse = 0;
};
}
override public function SolveVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
tMat = m_body1.m_R;
var r1X:Number = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
var r1Y:Number = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = m_body2.m_R;
var r2X:Number = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
var r2Y:Number = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
var v1X:Number = (m_body1.m_linearVelocity.x + (-(m_body1.m_angularVelocity) * r1Y));
var v1Y:Number = (m_body1.m_linearVelocity.y + (m_body1.m_angularVelocity * r1X));
var v2X:Number = (m_body2.m_linearVelocity.x + (-(m_body2.m_angularVelocity) * r2Y));
var v2Y:Number = (m_body2.m_linearVelocity.y + (m_body2.m_angularVelocity * r2X));
var Cdot:Number = ((m_u.x * (v2X - v1X)) + (m_u.y * (v2Y - v1Y)));
var impulse:Number = (-(m_mass) * Cdot);
m_impulse = (m_impulse + impulse);
var PX:Number = (impulse * m_u.x);
var PY:Number = (impulse * m_u.y);
m_body1.m_linearVelocity.x = (m_body1.m_linearVelocity.x - (m_body1.m_invMass * PX));
m_body1.m_linearVelocity.y = (m_body1.m_linearVelocity.y - (m_body1.m_invMass * PY));
m_body1.m_angularVelocity = (m_body1.m_angularVelocity - (m_body1.m_invI * ((r1X * PY) - (r1Y * PX))));
m_body2.m_linearVelocity.x = (m_body2.m_linearVelocity.x + (m_body2.m_invMass * PX));
m_body2.m_linearVelocity.y = (m_body2.m_linearVelocity.y + (m_body2.m_invMass * PY));
m_body2.m_angularVelocity = (m_body2.m_angularVelocity + (m_body2.m_invI * ((r2X * PY) - (r2Y * PX))));
}
}
}//package Box2D.Dynamics.Joints
Section 41
//b2DistanceJointDef (Box2D.Dynamics.Joints.b2DistanceJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2DistanceJointDef extends b2JointDef {
public var anchorPoint1:b2Vec2;
public var anchorPoint2:b2Vec2;
public function b2DistanceJointDef(){
anchorPoint1 = new b2Vec2();
anchorPoint2 = new b2Vec2();
super();
type = b2Joint.e_distanceJoint;
}
}
}//package Box2D.Dynamics.Joints
Section 42
//b2GearJoint (Box2D.Dynamics.Joints.b2GearJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2GearJoint extends b2Joint {
public var m_ground2:b2Body;
public var m_groundAnchor1:b2Vec2;
public var m_groundAnchor2:b2Vec2;
public var m_revolute2:b2RevoluteJoint;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_ratio:Number;
public var m_mass:Number;
public var m_impulse:Number;
public var m_prismatic2:b2PrismaticJoint;
public var m_ground1:b2Body;
public var m_revolute1:b2RevoluteJoint;
public var m_prismatic1:b2PrismaticJoint;
public var m_constant:Number;
public var m_J:b2Jacobian;
public function b2GearJoint(def:b2GearJointDef){
var coordinate1:Number;
var coordinate2:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_J = new b2Jacobian();
super(def);
m_revolute1 = null;
m_prismatic1 = null;
m_revolute2 = null;
m_prismatic2 = null;
m_ground1 = def.joint1.m_body1;
m_body1 = def.joint1.m_body2;
if (def.joint1.m_type == b2Joint.e_revoluteJoint){
m_revolute1 = (def.joint1 as b2RevoluteJoint);
m_groundAnchor1.SetV(m_revolute1.m_localAnchor1);
m_localAnchor1.SetV(m_revolute1.m_localAnchor2);
coordinate1 = m_revolute1.GetJointAngle();
} else {
m_prismatic1 = (def.joint1 as b2PrismaticJoint);
m_groundAnchor1.SetV(m_prismatic1.m_localAnchor1);
m_localAnchor1.SetV(m_prismatic1.m_localAnchor2);
coordinate1 = m_prismatic1.GetJointTranslation();
};
m_ground2 = def.joint2.m_body1;
m_body2 = def.joint2.m_body2;
if (def.joint2.m_type == b2Joint.e_revoluteJoint){
m_revolute2 = (def.joint2 as b2RevoluteJoint);
m_groundAnchor2.SetV(m_revolute2.m_localAnchor1);
m_localAnchor2.SetV(m_revolute2.m_localAnchor2);
coordinate2 = m_revolute2.GetJointAngle();
} else {
m_prismatic2 = (def.joint2 as b2PrismaticJoint);
m_groundAnchor2.SetV(m_prismatic2.m_localAnchor1);
m_localAnchor2.SetV(m_prismatic2.m_localAnchor2);
coordinate2 = m_prismatic2.GetJointTranslation();
};
m_ratio = def.ratio;
m_constant = (coordinate1 + (m_ratio * coordinate2));
m_impulse = 0;
}
override public function GetAnchor1():b2Vec2{
var tMat:b2Mat22 = m_body1.m_R;
return (new b2Vec2((m_body1.m_position.x + ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y))), (m_body1.m_position.y + ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y)))));
}
override public function GetAnchor2():b2Vec2{
var tMat:b2Mat22 = m_body2.m_R;
return (new b2Vec2((m_body2.m_position.x + ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y))), (m_body2.m_position.y + ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y)))));
}
override public function PrepareVelocitySolver():void{
var b1:b2Body;
var b2:b2Body;
var ugX:Number;
var ugY:Number;
var rX:Number;
var rY:Number;
var tMat:b2Mat22;
var tVec:b2Vec2;
var crug:Number;
var g1:b2Body = m_ground1;
var g2:b2Body = m_ground2;
b1 = m_body1;
b2 = m_body2;
var K:Number = 0;
m_J.SetZero();
if (m_revolute1){
m_J.angular1 = -1;
K = (K + b1.m_invI);
} else {
tMat = g1.m_R;
tVec = m_prismatic1.m_localXAxis1;
ugX = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
ugY = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = b1.m_R;
rX = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
rY = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
crug = ((rX * ugY) - (rY * ugX));
m_J.linear1.Set(-(ugX), -(ugY));
m_J.angular1 = -(crug);
K = (K + (b1.m_invMass + ((b1.m_invI * crug) * crug)));
};
if (m_revolute2){
m_J.angular2 = -(m_ratio);
K = (K + ((m_ratio * m_ratio) * b2.m_invI));
} else {
tMat = g2.m_R;
tVec = m_prismatic2.m_localXAxis1;
ugX = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
ugY = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = b2.m_R;
rX = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
rY = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
crug = ((rX * ugY) - (rY * ugX));
m_J.linear2.Set((-(m_ratio) * ugX), (-(m_ratio) * ugY));
m_J.angular2 = (-(m_ratio) * crug);
K = (K + ((m_ratio * m_ratio) * (b2.m_invMass + ((b2.m_invI * crug) * crug))));
};
m_mass = (1 / K);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + ((b1.m_invMass * m_impulse) * m_J.linear1.x));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + ((b1.m_invMass * m_impulse) * m_J.linear1.y));
b1.m_angularVelocity = (b1.m_angularVelocity + ((b1.m_invI * m_impulse) * m_J.angular1));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + ((b2.m_invMass * m_impulse) * m_J.linear2.x));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + ((b2.m_invMass * m_impulse) * m_J.linear2.y));
b2.m_angularVelocity = (b2.m_angularVelocity + ((b2.m_invI * m_impulse) * m_J.angular2));
}
override public function GetReactionTorque(invTimeStep:Number):Number{
return (0);
}
override public function GetReactionForce(invTimeStep:Number):b2Vec2{
return (new b2Vec2());
}
override public function SolvePositionConstraints():Boolean{
var coordinate1:Number;
var coordinate2:Number;
var linearError:Number = 0;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
if (m_revolute1){
coordinate1 = m_revolute1.GetJointAngle();
} else {
coordinate1 = m_prismatic1.GetJointTranslation();
};
if (m_revolute2){
coordinate2 = m_revolute2.GetJointAngle();
} else {
coordinate2 = m_prismatic2.GetJointTranslation();
};
var C:Number = (m_constant - (coordinate1 + (m_ratio * coordinate2)));
var impulse:Number = (-(m_mass) * C);
b1.m_position.x = (b1.m_position.x + ((b1.m_invMass * impulse) * m_J.linear1.x));
b1.m_position.y = (b1.m_position.y + ((b1.m_invMass * impulse) * m_J.linear1.y));
b1.m_rotation = (b1.m_rotation + ((b1.m_invI * impulse) * m_J.angular1));
b2.m_position.x = (b2.m_position.x + ((b2.m_invMass * impulse) * m_J.linear2.x));
b2.m_position.y = (b2.m_position.y + ((b2.m_invMass * impulse) * m_J.linear2.y));
b2.m_rotation = (b2.m_rotation + ((b2.m_invI * impulse) * m_J.angular2));
b1.m_R.Set(b1.m_rotation);
b2.m_R.Set(b2.m_rotation);
return ((linearError < b2Settings.b2_linearSlop));
}
public function GetRatio():Number{
return (m_ratio);
}
override public function SolveVelocityConstraints(step:b2TimeStep):void{
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
var Cdot:Number = m_J.Compute(b1.m_linearVelocity, b1.m_angularVelocity, b2.m_linearVelocity, b2.m_angularVelocity);
var impulse:Number = (-(m_mass) * Cdot);
m_impulse = (m_impulse + impulse);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + ((b1.m_invMass * impulse) * m_J.linear1.x));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + ((b1.m_invMass * impulse) * m_J.linear1.y));
b1.m_angularVelocity = (b1.m_angularVelocity + ((b1.m_invI * impulse) * m_J.angular1));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + ((b2.m_invMass * impulse) * m_J.linear2.x));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + ((b2.m_invMass * impulse) * m_J.linear2.y));
b2.m_angularVelocity = (b2.m_angularVelocity + ((b2.m_invI * impulse) * m_J.angular2));
}
}
}//package Box2D.Dynamics.Joints
Section 43
//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(){
super();
type = b2Joint.e_gearJoint;
joint1 = null;
joint2 = null;
ratio = 1;
}
}
}//package Box2D.Dynamics.Joints
Section 44
//b2Jacobian (Box2D.Dynamics.Joints.b2Jacobian)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2Jacobian {
public var linear1:b2Vec2;
public var linear2:b2Vec2;
public var angular1:Number;
public var angular2:Number;
public function b2Jacobian(){
linear1 = new b2Vec2();
linear2 = new b2Vec2();
super();
}
public function Set(x1:b2Vec2, a1:Number, x2:b2Vec2, a2:Number):void{
linear1.SetV(x1);
angular1 = a1;
linear2.SetV(x2);
angular2 = a2;
}
public function SetZero():void{
linear1.SetZero();
angular1 = 0;
linear2.SetZero();
angular2 = 0;
}
public function Compute(x1:b2Vec2, a1:Number, x2:b2Vec2, a2:Number):Number{
return ((((((linear1.x * x1.x) + (linear1.y * x1.y)) + (angular1 * a1)) + ((linear2.x * x2.x) + (linear2.y * x2.y))) + (angular2 * a2)));
}
}
}//package Box2D.Dynamics.Joints
Section 45
//b2Joint (Box2D.Dynamics.Joints.b2Joint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class b2Joint {
public var m_islandFlag:Boolean;
public var m_collideConnected:Boolean;
public var m_prev:b2Joint;
public var m_next:b2Joint;
public var m_type:int;
public var m_node1:b2JointNode;
public var m_node2:b2JointNode;
public var m_userData;
public var m_body1:b2Body;
public var m_body2:b2Body;
public static const e_unknownJoint:int = 0;
public static const e_inactiveLimit:int = 0;
public static const e_atUpperLimit:int = 2;
public static const e_atLowerLimit:int = 1;
public static const e_gearJoint:int = 6;
public static const e_revoluteJoint:int = 1;
public static const e_equalLimits:int = 3;
public static const e_distanceJoint:int = 3;
public static const e_pulleyJoint:int = 4;
public static const e_prismaticJoint:int = 2;
public static const e_mouseJoint:int = 5;
public function b2Joint(def:b2JointDef){
m_node1 = new b2JointNode();
m_node2 = new b2JointNode();
super();
m_type = def.type;
m_prev = null;
m_next = null;
m_body1 = def.body1;
m_body2 = def.body2;
m_collideConnected = def.collideConnected;
m_islandFlag = false;
m_userData = def.userData;
}
public function GetAnchor1():b2Vec2{
return (null);
}
public function GetAnchor2():b2Vec2{
return (null);
}
public function GetNext():b2Joint{
return (m_next);
}
public function GetType():int{
return (m_type);
}
public function SolveVelocityConstraints(step:b2TimeStep):void{
}
public function PrepareVelocitySolver():void{
}
public function PreparePositionSolver():void{
}
public function GetReactionTorque(invTimeStep:Number):Number{
return (0);
}
public function GetUserData(){
return (m_userData);
}
public function GetReactionForce(invTimeStep:Number):b2Vec2{
return (null);
}
public function SolvePositionConstraints():Boolean{
return (false);
}
public function GetBody1():b2Body{
return (m_body1);
}
public function GetBody2():b2Body{
return (m_body2);
}
public static function Destroy(joint:b2Joint, allocator):void{
}
public static function Create(def:b2JointDef, allocator):b2Joint{
var joint:b2Joint;
switch (def.type){
case e_distanceJoint:
joint = new b2DistanceJoint((def as b2DistanceJointDef));
break;
case e_mouseJoint:
joint = new b2MouseJoint((def as b2MouseJointDef));
break;
case e_prismaticJoint:
joint = new b2PrismaticJoint((def as b2PrismaticJointDef));
break;
case e_revoluteJoint:
joint = new b2RevoluteJoint((def as b2RevoluteJointDef));
break;
case e_pulleyJoint:
joint = new b2PulleyJoint((def as b2PulleyJointDef));
break;
case e_gearJoint:
joint = new b2GearJoint((def as b2GearJointDef));
break;
default:
break;
};
return (joint);
}
}
}//package Box2D.Dynamics.Joints
Section 46
//b2JointDef (Box2D.Dynamics.Joints.b2JointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointDef {
public var body2:b2Body;
public var type:int;
public var userData;
public var collideConnected:Boolean;
public var body1:b2Body;
public function b2JointDef(){
super();
type = b2Joint.e_unknownJoint;
userData = null;
body1 = null;
body2 = null;
collideConnected = false;
}
}
}//package Box2D.Dynamics.Joints
Section 47
//b2JointNode (Box2D.Dynamics.Joints.b2JointNode)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointNode {
public var other:b2Body;
public var next:b2JointNode;
public var prev:b2JointNode;
public var joint:b2Joint;
public function b2JointNode(){
super();
}
}
}//package Box2D.Dynamics.Joints
Section 48
//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 K1:b2Mat22;
public var m_beta:Number;
private var K:b2Mat22;
private var K2:b2Mat22;
public var m_target:b2Vec2;
public var m_gamma:Number;
public var m_impulse:b2Vec2;
public var m_ptpMass:b2Mat22;
public var m_C:b2Vec2;
public var m_maxForce:Number;
public var m_localAnchor:b2Vec2;
public function b2MouseJoint(def:b2MouseJointDef){
var tY:Number;
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
m_localAnchor = new b2Vec2();
m_target = new b2Vec2();
m_impulse = new b2Vec2();
m_ptpMass = new b2Mat22();
m_C = new b2Vec2();
super(def);
m_target.SetV(def.target);
var tX:Number = (m_target.x - m_body2.m_position.x);
tY = (m_target.y - m_body2.m_position.y);
m_localAnchor.x = ((tX * m_body2.m_R.col1.x) + (tY * m_body2.m_R.col1.y));
m_localAnchor.y = ((tX * m_body2.m_R.col2.x) + (tY * m_body2.m_R.col2.y));
m_maxForce = def.maxForce;
m_impulse.SetZero();
var mass:Number = m_body2.m_mass;
var omega:Number = ((2 * b2Settings.b2_pi) * def.frequencyHz);
var d:Number = (((2 * mass) * def.dampingRatio) * omega);
var k:Number = ((mass * omega) * omega);
m_gamma = (1 / (d + (def.timeStep * k)));
m_beta = ((def.timeStep * k) / (d + (def.timeStep * k)));
}
public function SetTarget(target:b2Vec2):void{
m_body2.WakeUp();
m_target = target;
}
override public function GetAnchor2():b2Vec2{
var tVec:b2Vec2 = b2Math.b2MulMV(m_body2.m_R, m_localAnchor);
tVec.Add(m_body2.m_position);
return (tVec);
}
override public function GetAnchor1():b2Vec2{
return (m_target);
}
override public function PrepareVelocitySolver():void{
var b:b2Body;
var tMat:b2Mat22;
var rX:Number;
var rY:Number;
var invMass:Number;
var invI:Number;
b = m_body2;
tMat = b.m_R;
rX = ((tMat.col1.x * m_localAnchor.x) + (tMat.col2.x * m_localAnchor.y));
rY = ((tMat.col1.y * m_localAnchor.x) + (tMat.col2.y * m_localAnchor.y));
invMass = b.m_invMass;
invI = b.m_invI;
K1.col1.x = invMass;
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = invMass;
K2.col1.x = ((invI * rY) * rY);
K2.col2.x = ((-(invI) * rX) * rY);
K2.col1.y = ((-(invI) * rX) * rY);
K2.col2.y = ((invI * rX) * rX);
K.SetM(K1);
K.AddM(K2);
K.col1.x = (K.col1.x + m_gamma);
K.col2.y = (K.col2.y + m_gamma);
K.Invert(m_ptpMass);
m_C.x = ((b.m_position.x + rX) - m_target.x);
m_C.y = ((b.m_position.y + rY) - m_target.y);
b.m_angularVelocity = (b.m_angularVelocity * 0.98);
var PX:Number = m_impulse.x;
var PY:Number = m_impulse.y;
b.m_linearVelocity.x = (b.m_linearVelocity.x + (invMass * PX));
b.m_linearVelocity.y = (b.m_linearVelocity.y + (invMass * PY));
b.m_angularVelocity = (b.m_angularVelocity + (invI * ((rX * PY) - (rY * PX))));
}
override public function GetReactionTorque(invTimeStep:Number):Number{
return (0);
}
override public function GetReactionForce(invTimeStep:Number):b2Vec2{
var F:b2Vec2 = new b2Vec2();
F.SetV(m_impulse);
F.Multiply(invTimeStep);
return (F);
}
override public function SolvePositionConstraints():Boolean{
return (true);
}
override public function SolveVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var body:b2Body = m_body2;
tMat = body.m_R;
var rX:Number = ((tMat.col1.x * m_localAnchor.x) + (tMat.col2.x * m_localAnchor.y));
var rY:Number = ((tMat.col1.y * m_localAnchor.x) + (tMat.col2.y * m_localAnchor.y));
var CdotX:Number = (body.m_linearVelocity.x + (-(body.m_angularVelocity) * rY));
var CdotY:Number = (body.m_linearVelocity.y + (body.m_angularVelocity * rX));
tMat = m_ptpMass;
var tX:Number = ((CdotX + ((m_beta * step.inv_dt) * m_C.x)) + (m_gamma * m_impulse.x));
var tY:Number = ((CdotY + ((m_beta * step.inv_dt) * m_C.y)) + (m_gamma * m_impulse.y));
var impulseX:Number = -(((tMat.col1.x * tX) + (tMat.col2.x * tY)));
var impulseY:Number = -(((tMat.col1.y * tX) + (tMat.col2.y * tY)));
var oldImpulseX:Number = m_impulse.x;
var oldImpulseY:Number = m_impulse.y;
m_impulse.x = (m_impulse.x + impulseX);
m_impulse.y = (m_impulse.y + impulseY);
var length:Number = m_impulse.Length();
if (length > (step.dt * m_maxForce)){
m_impulse.Multiply(((step.dt * m_maxForce) / length));
};
impulseX = (m_impulse.x - oldImpulseX);
impulseY = (m_impulse.y - oldImpulseY);
body.m_linearVelocity.x = (body.m_linearVelocity.x + (body.m_invMass * impulseX));
body.m_linearVelocity.y = (body.m_linearVelocity.y + (body.m_invMass * impulseY));
body.m_angularVelocity = (body.m_angularVelocity + (body.m_invI * ((rX * impulseY) - (rY * impulseX))));
}
}
}//package Box2D.Dynamics.Joints
Section 49
//b2MouseJointDef (Box2D.Dynamics.Joints.b2MouseJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2MouseJointDef extends b2JointDef {
public var timeStep:Number;
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;
timeStep = (1 / 60);
}
}
}//package Box2D.Dynamics.Joints
Section 50
//b2PrismaticJoint (Box2D.Dynamics.Joints.b2PrismaticJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PrismaticJoint extends b2Joint {
public var m_initialAngle:Number;
public var m_localXAxis1:b2Vec2;
public var m_lowerTranslation:Number;
public var m_angularMass:Number;
public var m_enableLimit:Boolean;
public var m_maxMotorForce:Number;
public var m_limitState:int;
public var m_localYAxis1:b2Vec2;
public var m_motorMass:Number;
public var m_linearImpulse:Number;
public var m_upperTranslation:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_angularImpulse:Number;
public var m_linearMass:Number;
public var m_motorImpulse:Number;
public var m_limitImpulse:Number;
public var m_motorJacobian:b2Jacobian;
public var m_limitPositionImpulse:Number;
public var m_motorSpeed:Number;
public var m_enableMotor:Boolean;
public var m_linearJacobian:b2Jacobian;
public function b2PrismaticJoint(def:b2PrismaticJointDef){
var tMat:b2Mat22;
var tX:Number;
var tY:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_localXAxis1 = new b2Vec2();
m_localYAxis1 = new b2Vec2();
m_linearJacobian = new b2Jacobian();
m_motorJacobian = new b2Jacobian();
super(def);
tMat = m_body1.m_R;
tX = (def.anchorPoint.x - m_body1.m_position.x);
tY = (def.anchorPoint.y - m_body1.m_position.y);
m_localAnchor1.Set(((tX * tMat.col1.x) + (tY * tMat.col1.y)), ((tX * tMat.col2.x) + (tY * tMat.col2.y)));
tMat = m_body2.m_R;
tX = (def.anchorPoint.x - m_body2.m_position.x);
tY = (def.anchorPoint.y - m_body2.m_position.y);
m_localAnchor2.Set(((tX * tMat.col1.x) + (tY * tMat.col1.y)), ((tX * tMat.col2.x) + (tY * tMat.col2.y)));
tMat = m_body1.m_R;
tX = def.axis.x;
tY = def.axis.y;
m_localXAxis1.Set(((tX * tMat.col1.x) + (tY * tMat.col1.y)), ((tX * tMat.col2.x) + (tY * tMat.col2.y)));
m_localYAxis1.x = -(m_localXAxis1.y);
m_localYAxis1.y = m_localXAxis1.x;
m_initialAngle = (m_body2.m_rotation - m_body1.m_rotation);
m_linearJacobian.SetZero();
m_linearMass = 0;
m_linearImpulse = 0;
m_angularMass = 0;
m_angularImpulse = 0;
m_motorJacobian.SetZero();
m_motorMass = 0;
m_motorImpulse = 0;
m_limitImpulse = 0;
m_limitPositionImpulse = 0;
m_lowerTranslation = def.lowerTranslation;
m_upperTranslation = def.upperTranslation;
m_maxMotorForce = def.motorForce;
m_motorSpeed = def.motorSpeed;
m_enableLimit = def.enableLimit;
m_enableMotor = def.enableMotor;
}
override public function GetAnchor1():b2Vec2{
var b1:b2Body = m_body1;
var tVec:b2Vec2 = new b2Vec2();
tVec.SetV(m_localAnchor1);
tVec.MulM(b1.m_R);
tVec.Add(b1.m_position);
return (tVec);
}
override public function GetAnchor2():b2Vec2{
var b2:b2Body = m_body2;
var tVec:b2Vec2 = new b2Vec2();
tVec.SetV(m_localAnchor2);
tVec.MulM(b2.m_R);
tVec.Add(b2.m_position);
return (tVec);
}
override public function PrepareVelocitySolver():void{
var tMat:b2Mat22;
var ax1X:Number;
var ax1Y:Number;
var dX:Number;
var dY:Number;
var jointTranslation:Number;
var P1X:Number;
var P1Y:Number;
var P2X:Number;
var P2Y:Number;
var L1:Number;
var L2:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
tMat = b1.m_R;
var r1X:Number = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
var r1Y:Number = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = b2.m_R;
var r2X:Number = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
var r2Y:Number = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
var invMass1:Number = b1.m_invMass;
var invMass2:Number = b2.m_invMass;
var invI1:Number = b1.m_invI;
var invI2:Number = b2.m_invI;
tMat = b1.m_R;
var ay1X:Number = ((tMat.col1.x * m_localYAxis1.x) + (tMat.col2.x * m_localYAxis1.y));
var ay1Y:Number = ((tMat.col1.y * m_localYAxis1.x) + (tMat.col2.y * m_localYAxis1.y));
var eX:Number = ((b2.m_position.x + r2X) - b1.m_position.x);
var eY:Number = ((b2.m_position.y + r2Y) - b1.m_position.y);
m_linearJacobian.linear1.x = -(ay1X);
m_linearJacobian.linear1.y = -(ay1Y);
m_linearJacobian.linear2.x = ay1X;
m_linearJacobian.linear2.y = ay1Y;
m_linearJacobian.angular1 = -(((eX * ay1Y) - (eY * ay1X)));
m_linearJacobian.angular2 = ((r2X * ay1Y) - (r2Y * ay1X));
m_linearMass = (((invMass1 + ((invI1 * m_linearJacobian.angular1) * m_linearJacobian.angular1)) + invMass2) + ((invI2 * m_linearJacobian.angular2) * m_linearJacobian.angular2));
m_linearMass = (1 / m_linearMass);
m_angularMass = (1 / (invI1 + invI2));
if (((m_enableLimit) || (m_enableMotor))){
tMat = b1.m_R;
ax1X = ((tMat.col1.x * m_localXAxis1.x) + (tMat.col2.x * m_localXAxis1.y));
ax1Y = ((tMat.col1.y * m_localXAxis1.x) + (tMat.col2.y * m_localXAxis1.y));
m_motorJacobian.linear1.x = -(ax1X);
m_motorJacobian.linear1.y = -(ax1Y);
m_motorJacobian.linear2.x = ax1X;
m_motorJacobian.linear2.y = ax1Y;
m_motorJacobian.angular1 = -(((eX * ax1Y) - (eY * ax1X)));
m_motorJacobian.angular2 = ((r2X * ax1Y) - (r2Y * ax1X));
m_motorMass = (((invMass1 + ((invI1 * m_motorJacobian.angular1) * m_motorJacobian.angular1)) + invMass2) + ((invI2 * m_motorJacobian.angular2) * m_motorJacobian.angular2));
m_motorMass = (1 / m_motorMass);
if (m_enableLimit){
dX = (eX - r1X);
dY = (eY - r1Y);
jointTranslation = ((ax1X * dX) + (ax1Y * dY));
if (b2Math.b2Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
m_limitState = e_equalLimits;
} else {
if (jointTranslation <= m_lowerTranslation){
if (m_limitState != e_atLowerLimit){
m_limitImpulse = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (jointTranslation >= m_upperTranslation){
if (m_limitState != e_atUpperLimit){
m_limitImpulse = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_limitImpulse = 0;
};
};
};
};
};
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (m_enableLimit == false){
m_limitImpulse = 0;
};
if (b2World.s_enableWarmStarting){
P1X = ((m_linearImpulse * m_linearJacobian.linear1.x) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.linear1.x));
P1Y = ((m_linearImpulse * m_linearJacobian.linear1.y) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.linear1.y));
P2X = ((m_linearImpulse * m_linearJacobian.linear2.x) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.linear2.x));
P2Y = ((m_linearImpulse * m_linearJacobian.linear2.y) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.linear2.y));
L1 = (((m_linearImpulse * m_linearJacobian.angular1) - m_angularImpulse) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.angular1));
L2 = (((m_linearImpulse * m_linearJacobian.angular2) + m_angularImpulse) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.angular2));
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + (invMass1 * P1X));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + (invMass1 * P1Y));
b1.m_angularVelocity = (b1.m_angularVelocity + (invI1 * L1));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (invMass2 * P2X));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (invMass2 * P2Y));
b2.m_angularVelocity = (b2.m_angularVelocity + (invI2 * L2));
} else {
m_linearImpulse = 0;
m_angularImpulse = 0;
m_limitImpulse = 0;
m_motorImpulse = 0;
};
m_limitPositionImpulse = 0;
}
public function GetJointTranslation():Number{
var tMat:b2Mat22;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
tMat = b1.m_R;
var r1X:Number = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
var r1Y:Number = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = b2.m_R;
var r2X:Number = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
var r2Y:Number = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
var p1X:Number = (b1.m_position.x + r1X);
var p1Y:Number = (b1.m_position.y + r1Y);
var p2X:Number = (b2.m_position.x + r2X);
var p2Y:Number = (b2.m_position.y + r2Y);
var dX:Number = (p2X - p1X);
var dY:Number = (p2Y - p1Y);
tMat = b1.m_R;
var ax1X:Number = ((tMat.col1.x * m_localXAxis1.x) + (tMat.col2.x * m_localXAxis1.y));
var ax1Y:Number = ((tMat.col1.y * m_localXAxis1.x) + (tMat.col2.y * m_localXAxis1.y));
var translation:Number = ((ax1X * dX) + (ax1Y * dY));
return (translation);
}
override public function GetReactionForce(invTimeStep:Number):b2Vec2{
var tMat:b2Mat22;
var tImp:Number = (invTimeStep * m_limitImpulse);
tMat = m_body1.m_R;
var ax1X:Number = (tImp * ((tMat.col1.x * m_localXAxis1.x) + (tMat.col2.x * m_localXAxis1.y)));
var ax1Y:Number = (tImp * ((tMat.col1.y * m_localXAxis1.x) + (tMat.col2.y * m_localXAxis1.y)));
var ay1X:Number = (tImp * ((tMat.col1.x * m_localYAxis1.x) + (tMat.col2.x * m_localYAxis1.y)));
var ay1Y:Number = (tImp * ((tMat.col1.y * m_localYAxis1.x) + (tMat.col2.y * m_localYAxis1.y)));
return (new b2Vec2((ax1X + ay1X), (ax1Y + ay1Y)));
}
override public function SolvePositionConstraints():Boolean{
var limitC:Number;
var oldLimitImpulse:Number;
var tMat:b2Mat22;
var ax1X:Number;
var ax1Y:Number;
var translation:Number;
var limitImpulse:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
var invMass1:Number = b1.m_invMass;
var invMass2:Number = b2.m_invMass;
var invI1:Number = b1.m_invI;
var invI2:Number = b2.m_invI;
tMat = b1.m_R;
var r1X:Number = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
var r1Y:Number = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = b2.m_R;
var r2X:Number = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
var r2Y:Number = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
var p1X:Number = (b1.m_position.x + r1X);
var p1Y:Number = (b1.m_position.y + r1Y);
var p2X:Number = (b2.m_position.x + r2X);
var p2Y:Number = (b2.m_position.y + r2Y);
var dX:Number = (p2X - p1X);
var dY:Number = (p2Y - p1Y);
tMat = b1.m_R;
var ay1X:Number = ((tMat.col1.x * m_localYAxis1.x) + (tMat.col2.x * m_localYAxis1.y));
var ay1Y:Number = ((tMat.col1.y * m_localYAxis1.x) + (tMat.col2.y * m_localYAxis1.y));
var linearC:Number = ((ay1X * dX) + (ay1Y * dY));
linearC = b2Math.b2Clamp(linearC, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
var linearImpulse:Number = (-(m_linearMass) * linearC);
b1.m_position.x = (b1.m_position.x + ((invMass1 * linearImpulse) * m_linearJacobian.linear1.x));
b1.m_position.y = (b1.m_position.y + ((invMass1 * linearImpulse) * m_linearJacobian.linear1.y));
b1.m_rotation = (b1.m_rotation + ((invI1 * linearImpulse) * m_linearJacobian.angular1));
b2.m_position.x = (b2.m_position.x + ((invMass2 * linearImpulse) * m_linearJacobian.linear2.x));
b2.m_position.y = (b2.m_position.y + ((invMass2 * linearImpulse) * m_linearJacobian.linear2.y));
b2.m_rotation = (b2.m_rotation + ((invI2 * linearImpulse) * m_linearJacobian.angular2));
var positionError:Number = b2Math.b2Abs(linearC);
var angularC:Number = ((b2.m_rotation - b1.m_rotation) - m_initialAngle);
angularC = b2Math.b2Clamp(angularC, -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
var angularImpulse:Number = (-(m_angularMass) * angularC);
b1.m_rotation = (b1.m_rotation - (b1.m_invI * angularImpulse));
b1.m_R.Set(b1.m_rotation);
b2.m_rotation = (b2.m_rotation + (b2.m_invI * angularImpulse));
b2.m_R.Set(b2.m_rotation);
var angularError:Number = b2Math.b2Abs(angularC);
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
tMat = b1.m_R;
r1X = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
r1Y = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = b2.m_R;
r2X = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
r2Y = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
p1X = (b1.m_position.x + r1X);
p1Y = (b1.m_position.y + r1Y);
p2X = (b2.m_position.x + r2X);
p2Y = (b2.m_position.y + r2Y);
dX = (p2X - p1X);
dY = (p2Y - p1Y);
tMat = b1.m_R;
ax1X = ((tMat.col1.x * m_localXAxis1.x) + (tMat.col2.x * m_localXAxis1.y));
ax1Y = ((tMat.col1.y * m_localXAxis1.x) + (tMat.col2.y * m_localXAxis1.y));
translation = ((ax1X * dX) + (ax1Y * dY));
limitImpulse = 0;
if (m_limitState == e_equalLimits){
limitC = b2Math.b2Clamp(translation, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
limitImpulse = (-(m_motorMass) * limitC);
positionError = b2Math.b2Max(positionError, b2Math.b2Abs(angularC));
} else {
if (m_limitState == e_atLowerLimit){
limitC = (translation - m_lowerTranslation);
positionError = b2Math.b2Max(positionError, -(limitC));
limitC = b2Math.b2Clamp((limitC + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
limitImpulse = (-(m_motorMass) * limitC);
oldLimitImpulse = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Max((m_limitPositionImpulse + limitImpulse), 0);
limitImpulse = (m_limitPositionImpulse - oldLimitImpulse);
} else {
if (m_limitState == e_atUpperLimit){
limitC = (translation - m_upperTranslation);
positionError = b2Math.b2Max(positionError, limitC);
limitC = b2Math.b2Clamp((limitC - b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
limitImpulse = (-(m_motorMass) * limitC);
oldLimitImpulse = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Min((m_limitPositionImpulse + limitImpulse), 0);
limitImpulse = (m_limitPositionImpulse - oldLimitImpulse);
};
};
};
b1.m_position.x = (b1.m_position.x + ((invMass1 * limitImpulse) * m_motorJacobian.linear1.x));
b1.m_position.y = (b1.m_position.y + ((invMass1 * limitImpulse) * m_motorJacobian.linear1.y));
b1.m_rotation = (b1.m_rotation + ((invI1 * limitImpulse) * m_motorJacobian.angular1));
b1.m_R.Set(b1.m_rotation);
b2.m_position.x = (b2.m_position.x + ((invMass2 * limitImpulse) * m_motorJacobian.linear2.x));
b2.m_position.y = (b2.m_position.y + ((invMass2 * limitImpulse) * m_motorJacobian.linear2.y));
b2.m_rotation = (b2.m_rotation + ((invI2 * limitImpulse) * m_motorJacobian.angular2));
b2.m_R.Set(b2.m_rotation);
};
return ((((positionError <= b2Settings.b2_linearSlop)) && ((angularError <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(speed:Number):void{
m_motorSpeed = speed;
}
public function GetJointSpeed():Number{
var tMat:b2Mat22;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
tMat = b1.m_R;
var r1X:Number = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
var r1Y:Number = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = b2.m_R;
var r2X:Number = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
var r2Y:Number = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
var p1X:Number = (b1.m_position.x + r1X);
var p1Y:Number = (b1.m_position.y + r1Y);
var p2X:Number = (b2.m_position.x + r2X);
var p2Y:Number = (b2.m_position.y + r2Y);
var dX:Number = (p2X - p1X);
var dY:Number = (p2Y - p1Y);
tMat = b1.m_R;
var ax1X:Number = ((tMat.col1.x * m_localXAxis1.x) + (tMat.col2.x * m_localXAxis1.y));
var ax1Y:Number = ((tMat.col1.y * m_localXAxis1.x) + (tMat.col2.y * m_localXAxis1.y));
var v1:b2Vec2 = b1.m_linearVelocity;
var v2:b2Vec2 = b2.m_linearVelocity;
var w1:Number = b1.m_angularVelocity;
var w2:Number = b2.m_angularVelocity;
var speed:Number = (((dX * (-(w1) * ax1Y)) + (dY * (w1 * ax1X))) + ((ax1X * (((v2.x + (-(w2) * r2Y)) - v1.x) - (-(w1) * r1Y))) + (ax1Y * (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X)))));
return (speed);
}
public function GetMotorForce(invTimeStep:Number):Number{
return ((invTimeStep * m_motorImpulse));
}
public function SetMotorForce(force:Number):void{
m_maxMotorForce = force;
}
override public function GetReactionTorque(invTimeStep:Number):Number{
return ((invTimeStep * m_angularImpulse));
}
override public function SolveVelocityConstraints(step:b2TimeStep):void{
var oldLimitImpulse:Number;
var motorCdot:Number;
var motorImpulse:Number;
var oldMotorImpulse:Number;
var limitCdot:Number;
var limitImpulse:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
var invMass1:Number = b1.m_invMass;
var invMass2:Number = b2.m_invMass;
var invI1:Number = b1.m_invI;
var invI2:Number = b2.m_invI;
var linearCdot:Number = m_linearJacobian.Compute(b1.m_linearVelocity, b1.m_angularVelocity, b2.m_linearVelocity, b2.m_angularVelocity);
var linearImpulse:Number = (-(m_linearMass) * linearCdot);
m_linearImpulse = (m_linearImpulse + linearImpulse);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + ((invMass1 * linearImpulse) * m_linearJacobian.linear1.x));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + ((invMass1 * linearImpulse) * m_linearJacobian.linear1.y));
b1.m_angularVelocity = (b1.m_angularVelocity + ((invI1 * linearImpulse) * m_linearJacobian.angular1));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + ((invMass2 * linearImpulse) * m_linearJacobian.linear2.x));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + ((invMass2 * linearImpulse) * m_linearJacobian.linear2.y));
b2.m_angularVelocity = (b2.m_angularVelocity + ((invI2 * linearImpulse) * m_linearJacobian.angular2));
var angularCdot:Number = (b2.m_angularVelocity - b1.m_angularVelocity);
var angularImpulse:Number = (-(m_angularMass) * angularCdot);
m_angularImpulse = (m_angularImpulse + angularImpulse);
b1.m_angularVelocity = (b1.m_angularVelocity - (invI1 * angularImpulse));
b2.m_angularVelocity = (b2.m_angularVelocity + (invI2 * angularImpulse));
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
motorCdot = (m_motorJacobian.Compute(b1.m_linearVelocity, b1.m_angularVelocity, b2.m_linearVelocity, b2.m_angularVelocity) - m_motorSpeed);
motorImpulse = (-(m_motorMass) * motorCdot);
oldMotorImpulse = m_motorImpulse;
m_motorImpulse = b2Math.b2Clamp((m_motorImpulse + motorImpulse), (-(step.dt) * m_maxMotorForce), (step.dt * m_maxMotorForce));
motorImpulse = (m_motorImpulse - oldMotorImpulse);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + ((invMass1 * motorImpulse) * m_motorJacobian.linear1.x));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + ((invMass1 * motorImpulse) * m_motorJacobian.linear1.y));
b1.m_angularVelocity = (b1.m_angularVelocity + ((invI1 * motorImpulse) * m_motorJacobian.angular1));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + ((invMass2 * motorImpulse) * m_motorJacobian.linear2.x));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + ((invMass2 * motorImpulse) * m_motorJacobian.linear2.y));
b2.m_angularVelocity = (b2.m_angularVelocity + ((invI2 * motorImpulse) * m_motorJacobian.angular2));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
limitCdot = m_motorJacobian.Compute(b1.m_linearVelocity, b1.m_angularVelocity, b2.m_linearVelocity, b2.m_angularVelocity);
limitImpulse = (-(m_motorMass) * limitCdot);
if (m_limitState == e_equalLimits){
m_limitImpulse = (m_limitImpulse + limitImpulse);
} else {
if (m_limitState == e_atLowerLimit){
oldLimitImpulse = m_limitImpulse;
m_limitImpulse = b2Math.b2Max((m_limitImpulse + limitImpulse), 0);
limitImpulse = (m_limitImpulse - oldLimitImpulse);
} else {
if (m_limitState == e_atUpperLimit){
oldLimitImpulse = m_limitImpulse;
m_limitImpulse = b2Math.b2Min((m_limitImpulse + limitImpulse), 0);
limitImpulse = (m_limitImpulse - oldLimitImpulse);
};
};
};
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + ((invMass1 * limitImpulse) * m_motorJacobian.linear1.x));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + ((invMass1 * limitImpulse) * m_motorJacobian.linear1.y));
b1.m_angularVelocity = (b1.m_angularVelocity + ((invI1 * limitImpulse) * m_motorJacobian.angular1));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + ((invMass2 * limitImpulse) * m_motorJacobian.linear2.x));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + ((invMass2 * limitImpulse) * m_motorJacobian.linear2.y));
b2.m_angularVelocity = (b2.m_angularVelocity + ((invI2 * limitImpulse) * m_motorJacobian.angular2));
};
}
}
}//package Box2D.Dynamics.Joints
Section 51
//b2PrismaticJointDef (Box2D.Dynamics.Joints.b2PrismaticJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2PrismaticJointDef extends b2JointDef {
public var axis:b2Vec2;
public var upperTranslation:Number;
public var lowerTranslation:Number;
public var motorSpeed:Number;
public var enableLimit:Boolean;
public var enableMotor:Boolean;
public var anchorPoint:b2Vec2;
public var motorForce:Number;
public function b2PrismaticJointDef(){
super();
type = b2Joint.e_prismaticJoint;
anchorPoint = new b2Vec2(0, 0);
axis = new b2Vec2(0, 0);
lowerTranslation = 0;
upperTranslation = 0;
motorForce = 0;
motorSpeed = 0;
enableLimit = false;
enableMotor = false;
}
}
}//package Box2D.Dynamics.Joints
Section 52
//b2PulleyJoint (Box2D.Dynamics.Joints.b2PulleyJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PulleyJoint extends b2Joint {
public var m_limitState1:int;
public var m_limitState2:int;
public var m_ground:b2Body;
public var m_maxLength2:Number;
public var m_maxLength1:Number;
public var m_limitPositionImpulse1:Number;
public var m_limitPositionImpulse2:Number;
public var m_pulleyImpulse:Number;
public var m_constant:Number;
public var m_ratio:Number;
public var m_groundAnchor1:b2Vec2;
public var m_groundAnchor2:b2Vec2;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_limitMass1:Number;
public var m_limitMass2:Number;
public var m_limitImpulse1:Number;
public var m_pulleyMass:Number;
public var m_u1:b2Vec2;
public var m_u2:b2Vec2;
public var m_limitImpulse2:Number;
public static var b2_minPulleyLength:Number = 30;
public function b2PulleyJoint(def:b2PulleyJointDef){
var tMat:b2Mat22;
var tX:Number;
var tY: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(def);
m_ground = m_body1.m_world.m_groundBody;
m_groundAnchor1.x = (def.groundPoint1.x - m_ground.m_position.x);
m_groundAnchor1.y = (def.groundPoint1.y - m_ground.m_position.y);
m_groundAnchor2.x = (def.groundPoint2.x - m_ground.m_position.x);
m_groundAnchor2.y = (def.groundPoint2.y - m_ground.m_position.y);
tMat = m_body1.m_R;
tX = (def.anchorPoint1.x - m_body1.m_position.x);
tY = (def.anchorPoint1.y - m_body1.m_position.y);
m_localAnchor1.x = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
m_localAnchor1.y = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
tMat = m_body2.m_R;
tX = (def.anchorPoint2.x - m_body2.m_position.x);
tY = (def.anchorPoint2.y - m_body2.m_position.y);
m_localAnchor2.x = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
m_localAnchor2.y = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
m_ratio = def.ratio;
tX = (def.groundPoint1.x - def.anchorPoint1.x);
tY = (def.groundPoint1.y - def.anchorPoint1.y);
var d1Len:Number = Math.sqrt(((tX * tX) + (tY * tY)));
tX = (def.groundPoint2.x - def.anchorPoint2.x);
tY = (def.groundPoint2.y - def.anchorPoint2.y);
var d2Len:Number = Math.sqrt(((tX * tX) + (tY * tY)));
var length1:Number = b2Math.b2Max((0.5 * b2_minPulleyLength), d1Len);
var length2:Number = b2Math.b2Max((0.5 * b2_minPulleyLength), d2Len);
m_constant = (length1 + (m_ratio * length2));
m_maxLength1 = b2Math.b2Clamp(def.maxLength1, length1, (m_constant - (m_ratio * b2_minPulleyLength)));
m_maxLength2 = b2Math.b2Clamp(def.maxLength2, length2, ((m_constant - b2_minPulleyLength) / m_ratio));
m_pulleyImpulse = 0;
m_limitImpulse1 = 0;
m_limitImpulse2 = 0;
}
public function GetLength1():Number{
var tMat:b2Mat22;
tMat = m_body1.m_R;
var pX:Number = (m_body1.m_position.x + ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y)));
var pY:Number = (m_body1.m_position.y + ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y)));
var dX:Number = (pX - (m_ground.m_position.x + m_groundAnchor1.x));
var dY:Number = (pY - (m_ground.m_position.y + m_groundAnchor1.y));
return (Math.sqrt(((dX * dX) + (dY * dY))));
}
override public function GetAnchor1():b2Vec2{
var tMat:b2Mat22 = m_body1.m_R;
return (new b2Vec2((m_body1.m_position.x + ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y))), (m_body1.m_position.y + ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y)))));
}
override public function GetAnchor2():b2Vec2{
var tMat:b2Mat22 = m_body2.m_R;
return (new b2Vec2((m_body2.m_position.x + ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y))), (m_body2.m_position.y + ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y)))));
}
override public function PrepareVelocitySolver():void{
var tMat:b2Mat22;
var P2Y:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
tMat = b1.m_R;
var r1X:Number = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
var r1Y:Number = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = b2.m_R;
var r2X:Number = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
var r2Y:Number = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
var p1X:Number = (b1.m_position.x + r1X);
var p1Y:Number = (b1.m_position.y + r1Y);
var p2X:Number = (b2.m_position.x + r2X);
var p2Y:Number = (b2.m_position.y + r2Y);
var s1X:Number = (m_ground.m_position.x + m_groundAnchor1.x);
var s1Y:Number = (m_ground.m_position.y + m_groundAnchor1.y);
var s2X:Number = (m_ground.m_position.x + m_groundAnchor2.x);
var s2Y:Number = (m_ground.m_position.y + m_groundAnchor2.y);
m_u1.Set((p1X - s1X), (p1Y - s1Y));
m_u2.Set((p2X - s2X), (p2Y - s2Y));
var length1:Number = m_u1.Length();
var length2:Number = m_u2.Length();
if (length1 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / length1));
} else {
m_u1.SetZero();
};
if (length2 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / length2));
} else {
m_u2.SetZero();
};
if (length1 < m_maxLength1){
m_limitState1 = e_inactiveLimit;
m_limitImpulse1 = 0;
} else {
m_limitState1 = e_atUpperLimit;
m_limitPositionImpulse1 = 0;
};
if (length2 < m_maxLength2){
m_limitState2 = e_inactiveLimit;
m_limitImpulse2 = 0;
} else {
m_limitState2 = e_atUpperLimit;
m_limitPositionImpulse2 = 0;
};
var cr1u1:Number = ((r1X * m_u1.y) - (r1Y * m_u1.x));
var cr2u2:Number = ((r2X * m_u2.y) - (r2Y * m_u2.x));
m_limitMass1 = (b1.m_invMass + ((b1.m_invI * cr1u1) * cr1u1));
m_limitMass2 = (b2.m_invMass + ((b2.m_invI * cr2u2) * cr2u2));
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);
var P1X:Number = ((-(m_pulleyImpulse) - m_limitImpulse1) * m_u1.x);
var P1Y:Number = ((-(m_pulleyImpulse) - m_limitImpulse1) * m_u1.y);
var P2X:Number = (((-(m_ratio) * m_pulleyImpulse) - m_limitImpulse2) * m_u2.x);
P2Y = (((-(m_ratio) * m_pulleyImpulse) - m_limitImpulse2) * m_u2.y);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + (b1.m_invMass * P1X));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + (b1.m_invMass * P1Y));
b1.m_angularVelocity = (b1.m_angularVelocity + (b1.m_invI * ((r1X * P1Y) - (r1Y * P1X))));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (b2.m_invMass * P2X));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (b2.m_invMass * P2Y));
b2.m_angularVelocity = (b2.m_angularVelocity + (b2.m_invI * ((r2X * P2Y) - (r2Y * P2X))));
}
override public function GetReactionForce(invTimeStep:Number):b2Vec2{
return (new b2Vec2());
}
override public function SolvePositionConstraints():Boolean{
var tMat:b2Mat22;
var r1X:Number;
var r1Y:Number;
var r2X:Number;
var r2Y:Number;
var p1X:Number;
var p1Y:Number;
var p2X:Number;
var p2Y:Number;
var length1:Number;
var length2:Number;
var C:Number;
var impulse:Number;
var oldLimitPositionImpulse:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
var s1X:Number = (m_ground.m_position.x + m_groundAnchor1.x);
var s1Y:Number = (m_ground.m_position.y + m_groundAnchor1.y);
var s2X:Number = (m_ground.m_position.x + m_groundAnchor2.x);
var s2Y:Number = (m_ground.m_position.y + m_groundAnchor2.y);
var linearError:Number = 0;
tMat = b1.m_R;
r1X = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
r1Y = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = b2.m_R;
r2X = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
r2Y = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
p1X = (b1.m_position.x + r1X);
p1Y = (b1.m_position.y + r1Y);
p2X = (b2.m_position.x + r2X);
p2Y = (b2.m_position.y + r2Y);
m_u1.Set((p1X - s1X), (p1Y - s1Y));
m_u2.Set((p2X - s2X), (p2Y - s2Y));
length1 = m_u1.Length();
length2 = m_u2.Length();
if (length1 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / length1));
} else {
m_u1.SetZero();
};
if (length2 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / length2));
} else {
m_u2.SetZero();
};
C = ((m_constant - length1) - (m_ratio * length2));
linearError = b2Math.b2Max(linearError, Math.abs(C));
C = b2Math.b2Clamp(C, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
impulse = (-(m_pulleyMass) * C);
p1X = (-(impulse) * m_u1.x);
p1Y = (-(impulse) * m_u1.y);
p2X = ((-(m_ratio) * impulse) * m_u2.x);
p2Y = ((-(m_ratio) * impulse) * m_u2.y);
b1.m_position.x = (b1.m_position.x + (b1.m_invMass * p1X));
b1.m_position.y = (b1.m_position.y + (b1.m_invMass * p1Y));
b1.m_rotation = (b1.m_rotation + (b1.m_invI * ((r1X * p1Y) - (r1Y * p1X))));
b2.m_position.x = (b2.m_position.x + (b2.m_invMass * p2X));
b2.m_position.y = (b2.m_position.y + (b2.m_invMass * p2Y));
b2.m_rotation = (b2.m_rotation + (b2.m_invI * ((r2X * p2Y) - (r2Y * p2X))));
b1.m_R.Set(b1.m_rotation);
b2.m_R.Set(b2.m_rotation);
if (m_limitState1 == e_atUpperLimit){
tMat = b1.m_R;
r1X = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
r1Y = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
p1X = (b1.m_position.x + r1X);
p1Y = (b1.m_position.y + r1Y);
m_u1.Set((p1X - s1X), (p1Y - s1Y));
length1 = m_u1.Length();
if (length1 > b2Settings.b2_linearSlop){
m_u1.x = (m_u1.x * (1 / length1));
m_u1.y = (m_u1.y * (1 / length1));
} else {
m_u1.SetZero();
};
C = (m_maxLength1 - length1);
linearError = b2Math.b2Max(linearError, -(C));
C = b2Math.b2Clamp((C + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
impulse = (-(m_limitMass1) * C);
oldLimitPositionImpulse = m_limitPositionImpulse1;
m_limitPositionImpulse1 = b2Math.b2Max(0, (m_limitPositionImpulse1 + impulse));
impulse = (m_limitPositionImpulse1 - oldLimitPositionImpulse);
p1X = (-(impulse) * m_u1.x);
p1Y = (-(impulse) * m_u1.y);
b1.m_position.x = (b1.m_position.x + (b1.m_invMass * p1X));
b1.m_position.y = (b1.m_position.y + (b1.m_invMass * p1Y));
b1.m_rotation = (b1.m_rotation + (b1.m_invI * ((r1X * p1Y) - (r1Y * p1X))));
b1.m_R.Set(b1.m_rotation);
};
if (m_limitState2 == e_atUpperLimit){
tMat = b2.m_R;
r2X = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
r2Y = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
p2X = (b2.m_position.x + r2X);
p2Y = (b2.m_position.y + r2Y);
m_u2.Set((p2X - s2X), (p2Y - s2Y));
length2 = m_u2.Length();
if (length2 > b2Settings.b2_linearSlop){
m_u2.x = (m_u2.x * (1 / length2));
m_u2.y = (m_u2.y * (1 / length2));
} else {
m_u2.SetZero();
};
C = (m_maxLength2 - length2);
linearError = b2Math.b2Max(linearError, -(C));
C = b2Math.b2Clamp((C + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
impulse = (-(m_limitMass2) * C);
oldLimitPositionImpulse = m_limitPositionImpulse2;
m_limitPositionImpulse2 = b2Math.b2Max(0, (m_limitPositionImpulse2 + impulse));
impulse = (m_limitPositionImpulse2 - oldLimitPositionImpulse);
p2X = (-(impulse) * m_u2.x);
p2Y = (-(impulse) * m_u2.y);
b2.m_position.x = (b2.m_position.x + (b2.m_invMass * p2X));
b2.m_position.y = (b2.m_position.y + (b2.m_invMass * p2Y));
b2.m_rotation = (b2.m_rotation + (b2.m_invI * ((r2X * p2Y) - (r2Y * p2X))));
b2.m_R.Set(b2.m_rotation);
};
return ((linearError < b2Settings.b2_linearSlop));
}
public function GetGroundPoint2():b2Vec2{
return (new b2Vec2((m_ground.m_position.x + m_groundAnchor2.x), (m_ground.m_position.y + m_groundAnchor2.y)));
}
override public function GetReactionTorque(invTimeStep:Number):Number{
return (0);
}
public function GetGroundPoint1():b2Vec2{
return (new b2Vec2((m_ground.m_position.x + m_groundAnchor1.x), (m_ground.m_position.y + m_groundAnchor1.y)));
}
override public function SolveVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var v1X:Number;
var v1Y:Number;
var v2X:Number;
var v2Y:Number;
var P1X:Number;
var P1Y:Number;
var P2X:Number;
var P2Y:Number;
var Cdot:Number;
var impulse:Number;
var oldLimitImpulse:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
tMat = b1.m_R;
var r1X:Number = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
var r1Y:Number = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = b2.m_R;
var r2X:Number = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
var r2Y:Number = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
v1X = (b1.m_linearVelocity.x + (-(b1.m_angularVelocity) * r1Y));
v1Y = (b1.m_linearVelocity.y + (b1.m_angularVelocity * r1X));
v2X = (b2.m_linearVelocity.x + (-(b2.m_angularVelocity) * r2Y));
v2Y = (b2.m_linearVelocity.y + (b2.m_angularVelocity * r2X));
Cdot = (-(((m_u1.x * v1X) + (m_u1.y * v1Y))) - (m_ratio * ((m_u2.x * v2X) + (m_u2.y * v2Y))));
impulse = (-(m_pulleyMass) * Cdot);
m_pulleyImpulse = (m_pulleyImpulse + impulse);
P1X = (-(impulse) * m_u1.x);
P1Y = (-(impulse) * m_u1.y);
P2X = ((-(m_ratio) * impulse) * m_u2.x);
P2Y = ((-(m_ratio) * impulse) * m_u2.y);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + (b1.m_invMass * P1X));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + (b1.m_invMass * P1Y));
b1.m_angularVelocity = (b1.m_angularVelocity + (b1.m_invI * ((r1X * P1Y) - (r1Y * P1X))));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (b2.m_invMass * P2X));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (b2.m_invMass * P2Y));
b2.m_angularVelocity = (b2.m_angularVelocity + (b2.m_invI * ((r2X * P2Y) - (r2Y * P2X))));
if (m_limitState1 == e_atUpperLimit){
v1X = (b1.m_linearVelocity.x + (-(b1.m_angularVelocity) * r1Y));
v1Y = (b1.m_linearVelocity.y + (b1.m_angularVelocity * r1X));
Cdot = -(((m_u1.x * v1X) + (m_u1.y * v1Y)));
impulse = (-(m_limitMass1) * Cdot);
oldLimitImpulse = m_limitImpulse1;
m_limitImpulse1 = b2Math.b2Max(0, (m_limitImpulse1 + impulse));
impulse = (m_limitImpulse1 - oldLimitImpulse);
P1X = (-(impulse) * m_u1.x);
P1Y = (-(impulse) * m_u1.y);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + (b1.m_invMass * P1X));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + (b1.m_invMass * P1Y));
b1.m_angularVelocity = (b1.m_angularVelocity + (b1.m_invI * ((r1X * P1Y) - (r1Y * P1X))));
};
if (m_limitState2 == e_atUpperLimit){
v2X = (b2.m_linearVelocity.x + (-(b2.m_angularVelocity) * r2Y));
v2Y = (b2.m_linearVelocity.y + (b2.m_angularVelocity * r2X));
Cdot = -(((m_u2.x * v2X) + (m_u2.y * v2Y)));
impulse = (-(m_limitMass2) * Cdot);
oldLimitImpulse = m_limitImpulse2;
m_limitImpulse2 = b2Math.b2Max(0, (m_limitImpulse2 + impulse));
impulse = (m_limitImpulse2 - oldLimitImpulse);
P2X = (-(impulse) * m_u2.x);
P2Y = (-(impulse) * m_u2.y);
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (b2.m_invMass * P2X));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (b2.m_invMass * P2Y));
b2.m_angularVelocity = (b2.m_angularVelocity + (b2.m_invI * ((r2X * P2Y) - (r2Y * P2X))));
};
}
public function GetRatio():Number{
return (m_ratio);
}
public function GetLength2():Number{
var tMat:b2Mat22;
tMat = m_body2.m_R;
var pX:Number = (m_body2.m_position.x + ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y)));
var pY:Number = (m_body2.m_position.y + ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y)));
var dX:Number = (pX - (m_ground.m_position.x + m_groundAnchor2.x));
var dY:Number = (pY - (m_ground.m_position.y + m_groundAnchor2.y));
return (Math.sqrt(((dX * dX) + (dY * dY))));
}
}
}//package Box2D.Dynamics.Joints
Section 53
//b2PulleyJointDef (Box2D.Dynamics.Joints.b2PulleyJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2PulleyJointDef extends b2JointDef {
public var maxLength1:Number;
public var groundPoint1:b2Vec2;
public var groundPoint2:b2Vec2;
public var ratio:Number;
public var maxLength2:Number;
public var anchorPoint1:b2Vec2;
public var anchorPoint2:b2Vec2;
public function b2PulleyJointDef(){
groundPoint1 = new b2Vec2();
groundPoint2 = new b2Vec2();
anchorPoint1 = new b2Vec2();
anchorPoint2 = new b2Vec2();
super();
type = b2Joint.e_pulleyJoint;
groundPoint1.Set(-1, 1);
groundPoint2.Set(1, 1);
anchorPoint1.Set(-1, 0);
anchorPoint2.Set(1, 0);
maxLength1 = (0.5 * b2PulleyJoint.b2_minPulleyLength);
maxLength2 = (0.5 * b2PulleyJoint.b2_minPulleyLength);
ratio = 1;
collideConnected = true;
}
}
}//package Box2D.Dynamics.Joints
Section 54
//b2RevoluteJoint (Box2D.Dynamics.Joints.b2RevoluteJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2RevoluteJoint extends b2Joint {
public var m_enableLimit:Boolean;
public var m_limitState:int;
public var m_ptpMass:b2Mat22;
public var m_motorMass:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
private var K1:b2Mat22;
private var K2:b2Mat22;
private var K:b2Mat22;
public var m_limitImpulse:Number;
private var K3:b2Mat22;
public var m_motorImpulse:Number;
public var m_enableMotor:Boolean;
public var m_limitPositionImpulse:Number;
public var m_motorSpeed:Number;
public var m_upperAngle:Number;
public var m_lowerAngle:Number;
public var m_maxMotorTorque:Number;
public var m_ptpImpulse:b2Vec2;
public var m_intialAngle:Number;
public static var tImpulse:b2Vec2 = new b2Vec2();
public function b2RevoluteJoint(def:b2RevoluteJointDef){
var tMat:b2Mat22;
var tX:Number;
var tY:Number;
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
K3 = new b2Mat22();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_ptpImpulse = new b2Vec2();
m_ptpMass = new b2Mat22();
super(def);
tMat = m_body1.m_R;
tX = (def.anchorPoint.x - m_body1.m_position.x);
tY = (def.anchorPoint.y - m_body1.m_position.y);
m_localAnchor1.x = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
m_localAnchor1.y = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
tMat = m_body2.m_R;
tX = (def.anchorPoint.x - m_body2.m_position.x);
tY = (def.anchorPoint.y - m_body2.m_position.y);
m_localAnchor2.x = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
m_localAnchor2.y = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
m_intialAngle = (m_body2.m_rotation - m_body1.m_rotation);
m_ptpImpulse.Set(0, 0);
m_motorImpulse = 0;
m_limitImpulse = 0;
m_limitPositionImpulse = 0;
m_lowerAngle = def.lowerAngle;
m_upperAngle = def.upperAngle;
m_maxMotorTorque = def.motorTorque;
m_motorSpeed = def.motorSpeed;
m_enableLimit = def.enableLimit;
m_enableMotor = def.enableMotor;
}
override public function GetAnchor1():b2Vec2{
var tMat:b2Mat22 = m_body1.m_R;
return (new b2Vec2((m_body1.m_position.x + ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y))), (m_body1.m_position.y + ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y)))));
}
override public function GetAnchor2():b2Vec2{
var tMat:b2Mat22 = m_body2.m_R;
return (new b2Vec2((m_body2.m_position.x + ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y))), (m_body2.m_position.y + ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y)))));
}
override public function PrepareVelocitySolver():void{
var b1:b2Body;
var b2:b2Body;
var tMat:b2Mat22;
var jointAngle:Number;
b1 = m_body1;
b2 = m_body2;
tMat = b1.m_R;
var r1X:Number = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
var r1Y:Number = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = b2.m_R;
var r2X:Number = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
var r2Y:Number = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
var invMass1:Number = b1.m_invMass;
var invMass2:Number = b2.m_invMass;
var invI1:Number = b1.m_invI;
var invI2:Number = b2.m_invI;
K1.col1.x = (invMass1 + invMass2);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (invMass1 + invMass2);
K2.col1.x = ((invI1 * r1Y) * r1Y);
K2.col2.x = ((-(invI1) * r1X) * r1Y);
K2.col1.y = ((-(invI1) * r1X) * r1Y);
K2.col2.y = ((invI1 * r1X) * r1X);
K3.col1.x = ((invI2 * r2Y) * r2Y);
K3.col2.x = ((-(invI2) * r2X) * r2Y);
K3.col1.y = ((-(invI2) * r2X) * r2Y);
K3.col2.y = ((invI2 * r2X) * r2X);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Invert(m_ptpMass);
m_motorMass = (1 / (invI1 + invI2));
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (m_enableLimit){
jointAngle = ((b2.m_rotation - b1.m_rotation) - m_intialAngle);
if (b2Math.b2Abs((m_upperAngle - m_lowerAngle)) < (2 * b2Settings.b2_angularSlop)){
m_limitState = e_equalLimits;
} else {
if (jointAngle <= m_lowerAngle){
if (m_limitState != e_atLowerLimit){
m_limitImpulse = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (jointAngle >= m_upperAngle){
if (m_limitState != e_atUpperLimit){
m_limitImpulse = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_limitImpulse = 0;
};
};
};
} else {
m_limitImpulse = 0;
};
if (b2World.s_enableWarmStarting){
b1.m_linearVelocity.x = (b1.m_linearVelocity.x - (invMass1 * m_ptpImpulse.x));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y - (invMass1 * m_ptpImpulse.y));
b1.m_angularVelocity = (b1.m_angularVelocity - (invI1 * ((((r1X * m_ptpImpulse.y) - (r1Y * m_ptpImpulse.x)) + m_motorImpulse) + m_limitImpulse)));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (invMass2 * m_ptpImpulse.x));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (invMass2 * m_ptpImpulse.y));
b2.m_angularVelocity = (b2.m_angularVelocity + (invI2 * ((((r2X * m_ptpImpulse.y) - (r2Y * m_ptpImpulse.x)) + m_motorImpulse) + m_limitImpulse)));
} else {
m_ptpImpulse.SetZero();
m_motorImpulse = 0;
m_limitImpulse = 0;
};
m_limitPositionImpulse = 0;
}
override public function GetReactionForce(invTimeStep:Number):b2Vec2{
var tVec:b2Vec2 = m_ptpImpulse.Copy();
tVec.Multiply(invTimeStep);
return (tVec);
}
override public function SolvePositionConstraints():Boolean{
var oldLimitImpulse:Number;
var limitC:Number;
var tMat:b2Mat22;
var angle:Number;
var limitImpulse:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
var positionError:Number = 0;
tMat = b1.m_R;
var r1X:Number = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
var r1Y:Number = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = b2.m_R;
var r2X:Number = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
var r2Y:Number = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
var p1X:Number = (b1.m_position.x + r1X);
var p1Y:Number = (b1.m_position.y + r1Y);
var p2X:Number = (b2.m_position.x + r2X);
var p2Y:Number = (b2.m_position.y + r2Y);
var ptpCX:Number = (p2X - p1X);
var ptpCY:Number = (p2Y - p1Y);
positionError = Math.sqrt(((ptpCX * ptpCX) + (ptpCY * ptpCY)));
var invMass1:Number = b1.m_invMass;
var invMass2:Number = b2.m_invMass;
var invI1:Number = b1.m_invI;
var invI2:Number = b2.m_invI;
K1.col1.x = (invMass1 + invMass2);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (invMass1 + invMass2);
K2.col1.x = ((invI1 * r1Y) * r1Y);
K2.col2.x = ((-(invI1) * r1X) * r1Y);
K2.col1.y = ((-(invI1) * r1X) * r1Y);
K2.col2.y = ((invI1 * r1X) * r1X);
K3.col1.x = ((invI2 * r2Y) * r2Y);
K3.col2.x = ((-(invI2) * r2X) * r2Y);
K3.col1.y = ((-(invI2) * r2X) * r2Y);
K3.col2.y = ((invI2 * r2X) * r2X);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Solve(tImpulse, -(ptpCX), -(ptpCY));
var impulseX:Number = tImpulse.x;
var impulseY:Number = tImpulse.y;
b1.m_position.x = (b1.m_position.x - (b1.m_invMass * impulseX));
b1.m_position.y = (b1.m_position.y - (b1.m_invMass * impulseY));
b1.m_rotation = (b1.m_rotation - (b1.m_invI * ((r1X * impulseY) - (r1Y * impulseX))));
b1.m_R.Set(b1.m_rotation);
b2.m_position.x = (b2.m_position.x + (b2.m_invMass * impulseX));
b2.m_position.y = (b2.m_position.y + (b2.m_invMass * impulseY));
b2.m_rotation = (b2.m_rotation + (b2.m_invI * ((r2X * impulseY) - (r2Y * impulseX))));
b2.m_R.Set(b2.m_rotation);
var angularError:Number = 0;
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
angle = ((b2.m_rotation - b1.m_rotation) - m_intialAngle);
limitImpulse = 0;
if (m_limitState == e_equalLimits){
limitC = b2Math.b2Clamp(angle, -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
limitImpulse = (-(m_motorMass) * limitC);
angularError = b2Math.b2Abs(limitC);
} else {
if (m_limitState == e_atLowerLimit){
limitC = (angle - m_lowerAngle);
angularError = b2Math.b2Max(0, -(limitC));
limitC = b2Math.b2Clamp((limitC + b2Settings.b2_angularSlop), -(b2Settings.b2_maxAngularCorrection), 0);
limitImpulse = (-(m_motorMass) * limitC);
oldLimitImpulse = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Max((m_limitPositionImpulse + limitImpulse), 0);
limitImpulse = (m_limitPositionImpulse - oldLimitImpulse);
} else {
if (m_limitState == e_atUpperLimit){
limitC = (angle - m_upperAngle);
angularError = b2Math.b2Max(0, limitC);
limitC = b2Math.b2Clamp((limitC - b2Settings.b2_angularSlop), 0, b2Settings.b2_maxAngularCorrection);
limitImpulse = (-(m_motorMass) * limitC);
oldLimitImpulse = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Min((m_limitPositionImpulse + limitImpulse), 0);
limitImpulse = (m_limitPositionImpulse - oldLimitImpulse);
};
};
};
b1.m_rotation = (b1.m_rotation - (b1.m_invI * limitImpulse));
b1.m_R.Set(b1.m_rotation);
b2.m_rotation = (b2.m_rotation + (b2.m_invI * limitImpulse));
b2.m_R.Set(b2.m_rotation);
};
return ((((positionError <= b2Settings.b2_linearSlop)) && ((angularError <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(speed:Number):void{
m_motorSpeed = speed;
}
public function GetJointSpeed():Number{
return ((m_body2.m_angularVelocity - m_body1.m_angularVelocity));
}
public function SetMotorTorque(torque:Number):void{
m_maxMotorTorque = torque;
}
public function GetJointAngle():Number{
return ((m_body2.m_rotation - m_body1.m_rotation));
}
public function GetMotorTorque(invTimeStep:Number):Number{
return ((invTimeStep * m_motorImpulse));
}
override public function GetReactionTorque(invTimeStep:Number):Number{
return ((invTimeStep * m_limitImpulse));
}
override public function SolveVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var oldLimitImpulse:Number;
var motorCdot:Number;
var motorImpulse:Number;
var oldMotorImpulse:Number;
var limitCdot:Number;
var limitImpulse:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
tMat = b1.m_R;
var r1X:Number = ((tMat.col1.x * m_localAnchor1.x) + (tMat.col2.x * m_localAnchor1.y));
var r1Y:Number = ((tMat.col1.y * m_localAnchor1.x) + (tMat.col2.y * m_localAnchor1.y));
tMat = b2.m_R;
var r2X:Number = ((tMat.col1.x * m_localAnchor2.x) + (tMat.col2.x * m_localAnchor2.y));
var r2Y:Number = ((tMat.col1.y * m_localAnchor2.x) + (tMat.col2.y * m_localAnchor2.y));
var ptpCdotX:Number = (((b2.m_linearVelocity.x + (-(b2.m_angularVelocity) * r2Y)) - b1.m_linearVelocity.x) - (-(b1.m_angularVelocity) * r1Y));
var ptpCdotY:Number = (((b2.m_linearVelocity.y + (b2.m_angularVelocity * r2X)) - b1.m_linearVelocity.y) - (b1.m_angularVelocity * r1X));
var ptpImpulseX:Number = -(((m_ptpMass.col1.x * ptpCdotX) + (m_ptpMass.col2.x * ptpCdotY)));
var ptpImpulseY:Number = -(((m_ptpMass.col1.y * ptpCdotX) + (m_ptpMass.col2.y * ptpCdotY)));
m_ptpImpulse.x = (m_ptpImpulse.x + ptpImpulseX);
m_ptpImpulse.y = (m_ptpImpulse.y + ptpImpulseY);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x - (b1.m_invMass * ptpImpulseX));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y - (b1.m_invMass * ptpImpulseY));
b1.m_angularVelocity = (b1.m_angularVelocity - (b1.m_invI * ((r1X * ptpImpulseY) - (r1Y * ptpImpulseX))));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (b2.m_invMass * ptpImpulseX));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (b2.m_invMass * ptpImpulseY));
b2.m_angularVelocity = (b2.m_angularVelocity + (b2.m_invI * ((r2X * ptpImpulseY) - (r2Y * ptpImpulseX))));
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
motorCdot = ((b2.m_angularVelocity - b1.m_angularVelocity) - m_motorSpeed);
motorImpulse = (-(m_motorMass) * motorCdot);
oldMotorImpulse = m_motorImpulse;
m_motorImpulse = b2Math.b2Clamp((m_motorImpulse + motorImpulse), (-(step.dt) * m_maxMotorTorque), (step.dt * m_maxMotorTorque));
motorImpulse = (m_motorImpulse - oldMotorImpulse);
b1.m_angularVelocity = (b1.m_angularVelocity - (b1.m_invI * motorImpulse));
b2.m_angularVelocity = (b2.m_angularVelocity + (b2.m_invI * motorImpulse));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
limitCdot = (b2.m_angularVelocity - b1.m_angularVelocity);
limitImpulse = (-(m_motorMass) * limitCdot);
if (m_limitState == e_equalLimits){
m_limitImpulse = (m_limitImpulse + limitImpulse);
} else {
if (m_limitState == e_atLowerLimit){
oldLimitImpulse = m_limitImpulse;
m_limitImpulse = b2Math.b2Max((m_limitImpulse + limitImpulse), 0);
limitImpulse = (m_limitImpulse - oldLimitImpulse);
} else {
if (m_limitState == e_atUpperLimit){
oldLimitImpulse = m_limitImpulse;
m_limitImpulse = b2Math.b2Min((m_limitImpulse + limitImpulse), 0);
limitImpulse = (m_limitImpulse - oldLimitImpulse);
};
};
};
b1.m_angularVelocity = (b1.m_angularVelocity - (b1.m_invI * limitImpulse));
b2.m_angularVelocity = (b2.m_angularVelocity + (b2.m_invI * limitImpulse));
};
}
}
}//package Box2D.Dynamics.Joints
Section 55
//b2RevoluteJointDef (Box2D.Dynamics.Joints.b2RevoluteJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2RevoluteJointDef extends b2JointDef {
public var enableMotor:Boolean;
public var upperAngle:Number;
public var lowerAngle:Number;
public var enableLimit:Boolean;
public var motorSpeed:Number;
public var anchorPoint:b2Vec2;
public var motorTorque:Number;
public function b2RevoluteJointDef(){
super();
type = b2Joint.e_revoluteJoint;
anchorPoint = new b2Vec2(0, 0);
lowerAngle = 0;
upperAngle = 0;
motorTorque = 0;
motorSpeed = 0;
enableLimit = false;
enableMotor = false;
}
}
}//package Box2D.Dynamics.Joints
Section 56
//b2Body (Box2D.Dynamics.b2Body)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Body {
public var m_next:b2Body;
public var m_R:b2Mat22;
public var m_contactList:b2ContactNode;
public var m_angularVelocity:Number;
public var m_rotation:Number;
public var m_shapeList:b2Shape;
public var m_force:b2Vec2;
public var m_torque:Number;
public var m_mass:Number;
public var m_rotation0:Number;
public var m_invI:Number;
public var m_shapeCount:int;
public var m_userData;
public var m_linearVelocity:b2Vec2;
public var m_flags:uint;
public var m_invMass:Number;
public var m_position:b2Vec2;
public var m_linearDamping:Number;
public var m_prev:b2Body;
public var m_world:b2World;
public var m_angularDamping:Number;
public var m_position0:b2Vec2;
private var sMat0:b2Mat22;
public var m_center:b2Vec2;
public var m_sleepTime:Number;
public var m_I:Number;
public var m_jointList:b2JointNode;
public static var e_frozenFlag:uint = 2;
public static var e_sleepFlag:uint = 8;
public static var e_islandFlag:uint = 4;
public static var e_destroyFlag:uint = 32;
public static var e_allowSleepFlag:uint = 16;
public static var e_staticFlag:uint = 1;
public function b2Body(bd:b2BodyDef, world:b2World){
var i:int;
var sd:b2ShapeDef;
var massData:b2MassData;
var r:b2Vec2;
var shape:b2Shape;
sMat0 = new b2Mat22();
m_position = new b2Vec2();
m_R = new b2Mat22(0);
m_position0 = new b2Vec2();
super();
m_flags = 0;
m_position.SetV(bd.position);
m_rotation = bd.rotation;
m_R.Set(m_rotation);
m_position0.SetV(m_position);
m_rotation0 = m_rotation;
m_world = world;
m_linearDamping = b2Math.b2Clamp((1 - bd.linearDamping), 0, 1);
m_angularDamping = b2Math.b2Clamp((1 - bd.angularDamping), 0, 1);
m_force = new b2Vec2(0, 0);
m_torque = 0;
m_mass = 0;
var massDatas:Array = new Array(b2Settings.b2_maxShapesPerBody);
i = 0;
while (i < b2Settings.b2_maxShapesPerBody) {
massDatas[i] = new b2MassData();
i++;
};
m_shapeCount = 0;
m_center = new b2Vec2(0, 0);
i = 0;
while (i < b2Settings.b2_maxShapesPerBody) {
sd = bd.shapes[i];
if (sd == null){
break;
};
massData = massDatas[i];
sd.ComputeMass(massData);
m_mass = (m_mass + massData.mass);
m_center.x = (m_center.x + (massData.mass * (sd.localPosition.x + massData.center.x)));
m_center.y = (m_center.y + (massData.mass * (sd.localPosition.y + massData.center.y)));
m_shapeCount++;
i++;
};
if (m_mass > 0){
m_center.Multiply((1 / m_mass));
m_position.Add(b2Math.b2MulMV(m_R, m_center));
} else {
m_flags = (m_flags | e_staticFlag);
};
m_I = 0;
i = 0;
while (i < m_shapeCount) {
sd = bd.shapes[i];
massData = massDatas[i];
m_I = (m_I + massData.I);
r = b2Math.SubtractVV(b2Math.AddVV(sd.localPosition, massData.center), m_center);
m_I = (m_I + (massData.mass * b2Math.b2Dot(r, r)));
i++;
};
if (m_mass > 0){
m_invMass = (1 / m_mass);
} else {
m_invMass = 0;
};
if ((((m_I > 0)) && ((bd.preventRotation == false)))){
m_invI = (1 / m_I);
} else {
m_I = 0;
m_invI = 0;
};
m_linearVelocity = b2Math.AddVV(bd.linearVelocity, b2Math.b2CrossFV(bd.angularVelocity, m_center));
m_angularVelocity = bd.angularVelocity;
m_jointList = null;
m_contactList = null;
m_prev = null;
m_next = null;
m_shapeList = null;
i = 0;
while (i < m_shapeCount) {
sd = bd.shapes[i];
shape = b2Shape.Create(sd, this, m_center);
shape.m_next = m_shapeList;
m_shapeList = shape;
i++;
};
m_sleepTime = 0;
if (bd.allowSleep){
m_flags = (m_flags | e_allowSleepFlag);
};
if (bd.isSleeping){
m_flags = (m_flags | e_sleepFlag);
};
if ((((m_flags & e_sleepFlag)) || ((m_invMass == 0)))){
m_linearVelocity.Set(0, 0);
m_angularVelocity = 0;
};
m_userData = bd.userData;
}
public function SetCenterPosition(position:b2Vec2, rotation:Number):void{
if (IsFrozen()){
return;
};
m_rotation = rotation;
m_R.Set(m_rotation);
m_position.SetV(position);
m_position0.SetV(m_position);
m_rotation0 = m_rotation;
var s:b2Shape = m_shapeList;
while (s != null) {
s.Synchronize(m_position, m_R, m_position, m_R);
s = s.m_next;
};
m_world.m_broadPhase.Commit();
}
public function GetWorldPoint(localPoint:b2Vec2):b2Vec2{
return (b2Math.AddVV(m_position, b2Math.b2MulMV(m_R, localPoint)));
}
public function SetLinearVelocity(v:b2Vec2):void{
m_linearVelocity.SetV(v);
}
public function WakeUp():void{
m_flags = (m_flags & ~(e_sleepFlag));
m_sleepTime = 0;
}
public function IsFrozen():Boolean{
return (((m_flags & e_frozenFlag) == e_frozenFlag));
}
public function IsSleeping():Boolean{
return (((m_flags & e_sleepFlag) == e_sleepFlag));
}
public function GetLocalVector(worldVector:b2Vec2):b2Vec2{
return (b2Math.b2MulTMV(m_R, worldVector));
}
public function QuickSyncShapes():void{
var s:b2Shape = m_shapeList;
while (s != null) {
s.QuickSync(m_position, m_R);
s = s.m_next;
};
}
public function GetInertia():Number{
return (m_I);
}
public function GetJointList():b2JointNode{
return (m_jointList);
}
public function Freeze():void{
m_flags = (m_flags | e_frozenFlag);
m_linearVelocity.SetZero();
m_angularVelocity = 0;
var s:b2Shape = m_shapeList;
while (s != null) {
s.DestroyProxy();
s = s.m_next;
};
}
public function GetRotationMatrix():b2Mat22{
return (m_R);
}
public function SetAngularVelocity(w:Number):void{
m_angularVelocity = w;
}
public function SynchronizeShapes():void{
sMat0.Set(m_rotation0);
var s:b2Shape = m_shapeList;
while (s != null) {
s.Synchronize(m_position0, sMat0, m_position, m_R);
s = s.m_next;
};
}
public function ApplyForce(force:b2Vec2, point:b2Vec2):void{
if (IsSleeping() == false){
m_force.Add(force);
m_torque = (m_torque + b2Math.b2CrossVV(b2Math.SubtractVV(point, m_position), force));
};
}
public function GetOriginPosition():b2Vec2{
return (b2Math.SubtractVV(m_position, b2Math.b2MulMV(m_R, m_center)));
}
public function ApplyImpulse(impulse:b2Vec2, point:b2Vec2):void{
if (IsSleeping() == false){
m_linearVelocity.Add(b2Math.MulFV(m_invMass, impulse));
m_angularVelocity = (m_angularVelocity + (m_invI * b2Math.b2CrossVV(b2Math.SubtractVV(point, m_position), impulse)));
};
}
public function GetContactList():b2ContactNode{
return (m_contactList);
}
public function GetShapeList():b2Shape{
return (m_shapeList);
}
public function GetMass():Number{
return (m_mass);
}
public function GetAngularVelocity():Number{
return (m_angularVelocity);
}
public function SetOriginPosition(position:b2Vec2, rotation:Number):void{
if (IsFrozen()){
return;
};
m_rotation = rotation;
m_R.Set(m_rotation);
m_position = b2Math.AddVV(position, b2Math.b2MulMV(m_R, m_center));
m_position0.SetV(m_position);
m_rotation0 = m_rotation;
var s:b2Shape = m_shapeList;
while (s != null) {
s.Synchronize(m_position, m_R, m_position, m_R);
s = s.m_next;
};
m_world.m_broadPhase.Commit();
}
public function GetLocalPoint(worldPoint:b2Vec2):b2Vec2{
return (b2Math.b2MulTMV(m_R, b2Math.SubtractVV(worldPoint, m_position)));
}
public function GetRotation():Number{
return (m_rotation);
}
public function IsStatic():Boolean{
return (((m_flags & e_staticFlag) == e_staticFlag));
}
public function Destroy():void{
var s0:b2Shape;
var s:b2Shape = m_shapeList;
while (s) {
s0 = s;
s = s.m_next;
b2Shape.Destroy(s0);
};
}
public function GetWorldVector(localVector:b2Vec2):b2Vec2{
return (b2Math.b2MulMV(m_R, localVector));
}
public function GetNext():b2Body{
return (m_next);
}
public function IsConnected(other:b2Body):Boolean{
var jn:b2JointNode = m_jointList;
while (jn != null) {
if (jn.other == other){
return ((jn.joint.m_collideConnected == false));
};
jn = jn.next;
};
return (false);
}
public function GetUserData(){
return (m_userData);
}
public function AllowSleeping(flag:Boolean):void{
if (flag){
m_flags = (m_flags | e_allowSleepFlag);
} else {
m_flags = (m_flags & ~(e_allowSleepFlag));
WakeUp();
};
}
public function ApplyTorque(torque:Number):void{
if (IsSleeping() == false){
m_torque = (m_torque + torque);
};
}
public function GetCenterPosition():b2Vec2{
return (m_position);
}
public function GetLinearVelocity():b2Vec2{
return (m_linearVelocity);
}
}
}//package Box2D.Dynamics
Section 57
//b2BodyDef (Box2D.Dynamics.b2BodyDef)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2BodyDef {
public var angularDamping:Number;
public var linearVelocity:b2Vec2;
public var position:b2Vec2;
public var isSleeping:Boolean;
public var allowSleep:Boolean;
public var userData;
public var preventRotation:Boolean;
public var shapes:Array;
public var linearDamping:Number;
public var rotation:Number;
public var angularVelocity:Number;
public function b2BodyDef(){
shapes = new Array();
super();
userData = null;
var i:int;
while (i < b2Settings.b2_maxShapesPerBody) {
shapes[i] = null;
i++;
};
position = new b2Vec2(0, 0);
rotation = 0;
linearVelocity = new b2Vec2(0, 0);
angularVelocity = 0;
linearDamping = 0;
angularDamping = 0;
allowSleep = true;
isSleeping = false;
preventRotation = false;
}
public function AddShape(shape:b2ShapeDef):void{
var i:int;
while (i < b2Settings.b2_maxShapesPerBody) {
if (shapes[i] == null){
shapes[i] = shape;
break;
};
i++;
};
}
}
}//package Box2D.Dynamics
Section 58
//b2CollisionFilter (Box2D.Dynamics.b2CollisionFilter)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
public class b2CollisionFilter {
public static var b2_defaultFilter:b2CollisionFilter = new (b2CollisionFilter);
;
public function b2CollisionFilter(){
super();
}
public function ShouldCollide(shape1:b2Shape, shape2:b2Shape):Boolean{
if ((((shape1.m_groupIndex == shape2.m_groupIndex)) && (!((shape1.m_groupIndex == 0))))){
return ((shape1.m_groupIndex > 0));
};
var collide:Boolean = ((!(((shape1.m_maskBits & shape2.m_categoryBits) == 0))) && (!(((shape1.m_categoryBits & shape2.m_maskBits) == 0))));
return (collide);
}
}
}//package Box2D.Dynamics
Section 59
//b2ContactManager (Box2D.Dynamics.b2ContactManager)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Collision.Shapes.*;
public class b2ContactManager extends b2PairCallback {
public var m_world:b2World;
public var m_destroyImmediate:Boolean;
public var m_nullContact:b2NullContact;
public function b2ContactManager(){
m_nullContact = new b2NullContact();
super();
m_world = null;
m_destroyImmediate = false;
}
public function Collide(checkOnly:b2Body=null):void{
var body1:b2Body;
var body2:b2Body;
var node1:b2ContactNode;
var node2:b2ContactNode;
var oldCount:int;
var newCount:int;
var c:b2Contact = m_world.m_contactList;
while (c != null) {
if (((((!((checkOnly == null))) && (!((c.m_shape1.m_body == checkOnly))))) && (!((c.m_shape2.m_body == checkOnly))))){
} else {
if (((c.m_shape1.m_body.IsSleeping()) && (c.m_shape2.m_body.IsSleeping()))){
} else {
oldCount = c.GetManifoldCount();
c.Evaluate();
newCount = c.GetManifoldCount();
if ((((oldCount == 0)) && ((newCount > 0)))){
body1 = c.m_shape1.m_body;
body2 = c.m_shape2.m_body;
node1 = c.m_node1;
node2 = c.m_node2;
node1.contact = c;
node1.other = body2;
node1.prev = null;
node1.next = body1.m_contactList;
if (node1.next != null){
node1.next.prev = c.m_node1;
};
body1.m_contactList = c.m_node1;
node2.contact = c;
node2.other = body1;
node2.prev = null;
node2.next = body2.m_contactList;
if (node2.next != null){
node2.next.prev = node2;
};
body2.m_contactList = node2;
} else {
if ((((oldCount > 0)) && ((newCount == 0)))){
body1 = c.m_shape1.m_body;
body2 = c.m_shape2.m_body;
node1 = c.m_node1;
node2 = c.m_node2;
if (node1.prev){
node1.prev.next = node1.next;
};
if (node1.next){
node1.next.prev = node1.prev;
};
if (node1 == body1.m_contactList){
body1.m_contactList = node1.next;
};
node1.prev = null;
node1.next = null;
if (node2.prev){
node2.prev.next = node2.next;
};
if (node2.next){
node2.next.prev = node2.prev;
};
if (node2 == body2.m_contactList){
body2.m_contactList = node2.next;
};
node2.prev = null;
node2.next = null;
};
};
};
};
c = c.m_next;
};
}
public function CleanContactList():void{
var c0:b2Contact;
var c:b2Contact = m_world.m_contactList;
while (c != null) {
c0 = c;
c = c.m_next;
if ((c0.m_flags & b2Contact.e_destroyFlag)){
DestroyContact(c0);
c0 = null;
};
};
}
public function DestroyContact(c:b2Contact):void{
var body1:b2Body;
var body2:b2Body;
var node1:b2ContactNode;
var node2:b2ContactNode;
if (c.m_prev){
c.m_prev.m_next = c.m_next;
};
if (c.m_next){
c.m_next.m_prev = c.m_prev;
};
if (c == m_world.m_contactList){
m_world.m_contactList = c.m_next;
};
if (c.GetManifoldCount() > 0){
body1 = c.m_shape1.m_body;
body2 = c.m_shape2.m_body;
node1 = c.m_node1;
node2 = c.m_node2;
body1.WakeUp();
body2.WakeUp();
if (node1.prev){
node1.prev.next = node1.next;
};
if (node1.next){
node1.next.prev = node1.prev;
};
if (node1 == body1.m_contactList){
body1.m_contactList = node1.next;
};
node1.prev = null;
node1.next = null;
if (node2.prev){
node2.prev.next = node2.next;
};
if (node2.next){
node2.next.prev = node2.prev;
};
if (node2 == body2.m_contactList){
body2.m_contactList = node2.next;
};
node2.prev = null;
node2.next = null;
};
b2Contact.Destroy(c, m_world.m_blockAllocator);
m_world.m_contactCount--;
}
override public function PairRemoved(proxyUserData1, proxyUserData2, pairUserData):void{
if (pairUserData == null){
return;
};
var c:b2Contact = (pairUserData as b2Contact);
if (c != m_nullContact){
if (m_destroyImmediate == true){
DestroyContact(c);
c = null;
} else {
c.m_flags = (c.m_flags | b2Contact.e_destroyFlag);
};
};
}
override public function PairAdded(proxyUserData1, proxyUserData2){
var tempShape:b2Shape;
var tempBody:b2Body;
var shape1:b2Shape = (proxyUserData1 as b2Shape);
var shape2:b2Shape = (proxyUserData2 as b2Shape);
var body1:b2Body = shape1.m_body;
var body2:b2Body = shape2.m_body;
if (((body1.IsStatic()) && (body2.IsStatic()))){
return (m_nullContact);
};
if (shape1.m_body == shape2.m_body){
return (m_nullContact);
};
if (body2.IsConnected(body1)){
return (m_nullContact);
};
if (((!((m_world.m_filter == null))) && ((m_world.m_filter.ShouldCollide(shape1, shape2) == false)))){
return (m_nullContact);
};
if (body2.m_invMass == 0){
tempShape = shape1;
shape1 = shape2;
shape2 = tempShape;
tempBody = body1;
body1 = body2;
body2 = tempBody;
};
var contact:b2Contact = b2Contact.Create(shape1, shape2, m_world.m_blockAllocator);
if (contact == null){
return (m_nullContact);
};
contact.m_prev = null;
contact.m_next = m_world.m_contactList;
if (m_world.m_contactList != null){
m_world.m_contactList.m_prev = contact;
};
m_world.m_contactList = contact;
m_world.m_contactCount++;
return (contact);
}
}
}//package Box2D.Dynamics
Section 60
//b2Island (Box2D.Dynamics.b2Island)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2Island {
public var m_positionError:Number;
public var m_bodyCapacity:int;
public var m_bodies:Array;
public var m_joints:Array;
public var m_jointCapacity:int;
public var m_contactCount:int;
public var m_contacts:Array;
public var m_contactCapacity:int;
public var m_jointCount:int;
public var m_allocator;
public var m_bodyCount:int;
public static var m_positionIterationCount:uint;
public function b2Island(bodyCapacity:int, contactCapacity:int, jointCapacity:int, allocator):void{
var i:int;
super();
m_bodyCapacity = bodyCapacity;
m_contactCapacity = contactCapacity;
m_jointCapacity = jointCapacity;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_bodies = new Array(bodyCapacity);
i = 0;
while (i < bodyCapacity) {
m_bodies[i] = null;
i++;
};
m_contacts = new Array(contactCapacity);
i = 0;
while (i < contactCapacity) {
m_contacts[i] = null;
i++;
};
m_joints = new Array(jointCapacity);
i = 0;
while (i < jointCapacity) {
m_joints[i] = null;
i++;
};
m_allocator = allocator;
}
public function AddBody(body:b2Body):void{
var _local2 = m_bodyCount++;
m_bodies[_local2] = body;
}
public function AddJoint(joint:b2Joint):void{
var _local2 = m_jointCount++;
m_joints[_local2] = joint;
}
public function AddContact(contact:b2Contact):void{
var _local2 = m_contactCount++;
m_contacts[_local2] = contact;
}
public function Solve(step:b2TimeStep, gravity:b2Vec2):void{
var i:int;
var b:b2Body;
var j:int;
var contactsOkay:Boolean;
var jointsOkay:Boolean;
var jointOkay:Boolean;
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
if (b.m_invMass == 0){
} else {
b.m_linearVelocity.Add(b2Math.MulFV(step.dt, b2Math.AddVV(gravity, b2Math.MulFV(b.m_invMass, b.m_force))));
b.m_angularVelocity = (b.m_angularVelocity + ((step.dt * b.m_invI) * b.m_torque));
b.m_linearVelocity.Multiply(b.m_linearDamping);
b.m_angularVelocity = (b.m_angularVelocity * b.m_angularDamping);
b.m_position0.SetV(b.m_position);
b.m_rotation0 = b.m_rotation;
};
i++;
};
var contactSolver:b2ContactSolver = new b2ContactSolver(m_contacts, m_contactCount, m_allocator);
contactSolver.PreSolve();
i = 0;
while (i < m_jointCount) {
m_joints[i].PrepareVelocitySolver();
i++;
};
i = 0;
while (i < step.iterations) {
contactSolver.SolveVelocityConstraints();
j = 0;
while (j < m_jointCount) {
m_joints[j].SolveVelocityConstraints(step);
j++;
};
i++;
};
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
if (b.m_invMass == 0){
} else {
b.m_position.x = (b.m_position.x + (step.dt * b.m_linearVelocity.x));
b.m_position.y = (b.m_position.y + (step.dt * b.m_linearVelocity.y));
b.m_rotation = (b.m_rotation + (step.dt * b.m_angularVelocity));
b.m_R.Set(b.m_rotation);
};
i++;
};
i = 0;
while (i < m_jointCount) {
m_joints[i].PreparePositionSolver();
i++;
};
if (b2World.s_enablePositionCorrection){
m_positionIterationCount = 0;
while (m_positionIterationCount < step.iterations) {
contactsOkay = contactSolver.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
jointsOkay = true;
i = 0;
while (i < m_jointCount) {
jointOkay = m_joints[i].SolvePositionConstraints();
jointsOkay = ((jointsOkay) && (jointOkay));
i++;
};
if (((contactsOkay) && (jointsOkay))){
break;
};
m_positionIterationCount++;
};
};
contactSolver.PostSolve();
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
if (b.m_invMass == 0){
} else {
b.m_R.Set(b.m_rotation);
b.SynchronizeShapes();
b.m_force.Set(0, 0);
b.m_torque = 0;
};
i++;
};
}
public function Clear():void{
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
}
public function UpdateSleep(dt:Number):void{
var i:int;
var b:b2Body;
var minSleepTime:Number = Number.MAX_VALUE;
var linTolSqr:Number = (b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance);
var angTolSqr:Number = (b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance);
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
if (b.m_invMass == 0){
} else {
if ((b.m_flags & b2Body.e_allowSleepFlag) == 0){
b.m_sleepTime = 0;
minSleepTime = 0;
};
if (((((((b.m_flags & b2Body.e_allowSleepFlag) == 0)) || (((b.m_angularVelocity * b.m_angularVelocity) > angTolSqr)))) || ((b2Math.b2Dot(b.m_linearVelocity, b.m_linearVelocity) > linTolSqr)))){
b.m_sleepTime = 0;
minSleepTime = 0;
} else {
b.m_sleepTime = (b.m_sleepTime + dt);
minSleepTime = b2Math.b2Min(minSleepTime, b.m_sleepTime);
};
};
i++;
};
if (minSleepTime >= b2Settings.b2_timeToSleep){
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
b.m_flags = (b.m_flags | b2Body.e_sleepFlag);
i++;
};
};
}
}
}//package Box2D.Dynamics
Section 61
//b2TimeStep (Box2D.Dynamics.b2TimeStep)
package Box2D.Dynamics {
public class b2TimeStep {
public var dt:Number;
public var iterations:int;
public var inv_dt:Number;
public function b2TimeStep(){
super();
}
}
}//package Box2D.Dynamics
Section 62
//b2World (Box2D.Dynamics.b2World)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Collision.Shapes.*;
public class b2World {
public var m_bodyCount:int;
public var m_gravity:b2Vec2;
public var m_listener:b2WorldListener;
public var m_filter:b2CollisionFilter;
private var step:b2TimeStep;
public var m_positionIterationCount:int;
public var m_contactList:b2Contact;
public var m_blockAllocator;
public var m_groundBody:b2Body;
public var m_contactCount:int;
public var m_broadPhase:b2BroadPhase;
public var m_allowSleep:Boolean;
public var m_stackAllocator;
public var m_jointCount:int;
public var m_bodyList:b2Body;
public var m_bodyDestroyList:b2Body;
public var m_jointList:b2Joint;
public var m_contactManager:b2ContactManager;
public static var s_enableWarmStarting:int = 1;
public static var s_enablePositionCorrection:int = 1;
public function b2World(worldAABB:b2AABB, gravity:b2Vec2, doSleep:Boolean){
step = new b2TimeStep();
m_contactManager = new b2ContactManager();
super();
m_listener = null;
m_filter = b2CollisionFilter.b2_defaultFilter;
m_bodyList = null;
m_contactList = null;
m_jointList = null;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_bodyDestroyList = null;
m_allowSleep = doSleep;
m_gravity = gravity;
m_contactManager.m_world = this;
m_broadPhase = new b2BroadPhase(worldAABB, m_contactManager);
var bd:b2BodyDef = new b2BodyDef();
m_groundBody = CreateBody(bd);
}
public function GetContactList():b2Contact{
return (m_contactList);
}
public function CreateJoint(def:b2JointDef):b2Joint{
var b:b2Body;
var s:b2Shape;
var j:b2Joint = b2Joint.Create(def, m_blockAllocator);
j.m_prev = null;
j.m_next = m_jointList;
if (m_jointList){
m_jointList.m_prev = j;
};
m_jointList = j;
m_jointCount++;
j.m_node1.joint = j;
j.m_node1.other = j.m_body2;
j.m_node1.prev = null;
j.m_node1.next = j.m_body1.m_jointList;
if (j.m_body1.m_jointList){
j.m_body1.m_jointList.prev = j.m_node1;
};
j.m_body1.m_jointList = j.m_node1;
j.m_node2.joint = j;
j.m_node2.other = j.m_body1;
j.m_node2.prev = null;
j.m_node2.next = j.m_body2.m_jointList;
if (j.m_body2.m_jointList){
j.m_body2.m_jointList.prev = j.m_node2;
};
j.m_body2.m_jointList = j.m_node2;
if (def.collideConnected == false){
b = ((def.body1.m_shapeCount < def.body2.m_shapeCount)) ? def.body1 : def.body2;
s = b.m_shapeList;
while (s) {
s.ResetProxy(m_broadPhase);
s = s.m_next;
};
};
return (j);
}
public function DestroyJoint(j:b2Joint):void{
var b:b2Body;
var s:b2Shape;
var collideConnected:Boolean = j.m_collideConnected;
if (j.m_prev){
j.m_prev.m_next = j.m_next;
};
if (j.m_next){
j.m_next.m_prev = j.m_prev;
};
if (j == m_jointList){
m_jointList = j.m_next;
};
var body1:b2Body = j.m_body1;
var body2:b2Body = j.m_body2;
body1.WakeUp();
body2.WakeUp();
if (j.m_node1.prev){
j.m_node1.prev.next = j.m_node1.next;
};
if (j.m_node1.next){
j.m_node1.next.prev = j.m_node1.prev;
};
if (j.m_node1 == body1.m_jointList){
body1.m_jointList = j.m_node1.next;
};
j.m_node1.prev = null;
j.m_node1.next = null;
if (j.m_node2.prev){
j.m_node2.prev.next = j.m_node2.next;
};
if (j.m_node2.next){
j.m_node2.next.prev = j.m_node2.prev;
};
if (j.m_node2 == body2.m_jointList){
body2.m_jointList = j.m_node2.next;
};
j.m_node2.prev = null;
j.m_node2.next = null;
b2Joint.Destroy(j, m_blockAllocator);
m_jointCount--;
if (collideConnected == false){
b = ((body1.m_shapeCount < body2.m_shapeCount)) ? body1 : body2;
s = b.m_shapeList;
while (s) {
s.ResetProxy(m_broadPhase);
s = s.m_next;
};
};
}
public function SetFilter(filter:b2CollisionFilter):void{
m_filter = filter;
}
public function DestroyBody(b:b2Body):void{
if ((b.m_flags & b2Body.e_destroyFlag)){
return;
};
if (b.m_prev){
b.m_prev.m_next = b.m_next;
};
if (b.m_next){
b.m_next.m_prev = b.m_prev;
};
if (b == m_bodyList){
m_bodyList = b.m_next;
};
b.m_flags = (b.m_flags | b2Body.e_destroyFlag);
m_bodyCount--;
b.m_prev = null;
b.m_next = m_bodyDestroyList;
m_bodyDestroyList = b;
}
public function SetListener(listener:b2WorldListener):void{
m_listener = listener;
}
public function CreateBody(def:b2BodyDef):b2Body{
var b:b2Body = new b2Body(def, this);
b.m_prev = null;
b.m_next = m_bodyList;
if (m_bodyList){
m_bodyList.m_prev = b;
};
m_bodyList = b;
m_bodyCount++;
return (b);
}
public function GetGroundBody():b2Body{
return (m_groundBody);
}
public function Query(aabb:b2AABB, shapes:Array, maxCount:int):int{
var results:Array = new Array();
var count:int = m_broadPhase.QueryAABB(aabb, results, maxCount);
var i:int;
while (i < count) {
shapes[i] = (results[i] as b2Shape);
i++;
};
return (count);
}
public function CleanBodyList():void{
var b0:b2Body;
var jn:b2JointNode;
var jn0:b2JointNode;
m_contactManager.m_destroyImmediate = true;
var b:b2Body = m_bodyDestroyList;
while (b) {
b0 = b;
b = b.m_next;
jn = b0.m_jointList;
while (jn) {
jn0 = jn;
jn = jn.next;
if (m_listener){
m_listener.NotifyJointDestroyed(jn0.joint);
};
DestroyJoint(jn0.joint);
};
b0.Destroy();
};
m_bodyDestroyList = null;
m_contactManager.m_destroyImmediate = false;
}
public function Step(dt:Number, iterations:int):void{
var b:b2Body;
var other:b2Body;
var stackCount:int;
var i:int;
var cn:b2ContactNode;
var jn:b2JointNode;
var response:uint;
step.dt = dt;
step.iterations = iterations;
if (dt > 0){
step.inv_dt = (1 / dt);
} else {
step.inv_dt = 0;
};
m_positionIterationCount = 0;
m_contactManager.CleanContactList();
CleanBodyList();
m_contactManager.Collide();
var island:b2Island = new b2Island(m_bodyCount, m_contactCount, m_jointCount, m_stackAllocator);
b = m_bodyList;
while (b != null) {
b.m_flags = (b.m_flags & ~(b2Body.e_islandFlag));
b = b.m_next;
};
var c:b2Contact = m_contactList;
while (c != null) {
c.m_flags = (c.m_flags & ~(b2Contact.e_islandFlag));
c = c.m_next;
};
var j:b2Joint = m_jointList;
while (j != null) {
j.m_islandFlag = false;
j = j.m_next;
};
var stackSize:int = m_bodyCount;
var stack:Array = new Array(m_bodyCount);
var k:int;
while (k < m_bodyCount) {
stack[k] = null;
k++;
};
var seed:b2Body = m_bodyList;
while (seed != null) {
if ((seed.m_flags & (((b2Body.e_staticFlag | b2Body.e_islandFlag) | b2Body.e_sleepFlag) | b2Body.e_frozenFlag))){
} else {
island.Clear();
stackCount = 0;
var _temp1 = stackCount;
stackCount = (stackCount + 1);
var _local17 = _temp1;
stack[_local17] = seed;
seed.m_flags = (seed.m_flags | b2Body.e_islandFlag);
while (stackCount > 0) {
--stackCount;
b = stack[stackCount];
island.AddBody(b);
b.m_flags = (b.m_flags & ~(b2Body.e_sleepFlag));
if ((b.m_flags & b2Body.e_staticFlag)){
} else {
cn = b.m_contactList;
while (cn != null) {
if ((cn.contact.m_flags & b2Contact.e_islandFlag)){
} else {
island.AddContact(cn.contact);
cn.contact.m_flags = (cn.contact.m_flags | b2Contact.e_islandFlag);
other = cn.other;
if ((other.m_flags & b2Body.e_islandFlag)){
} else {
var _temp2 = stackCount;
stackCount = (stackCount + 1);
var _local18 = _temp2;
stack[_local18] = other;
other.m_flags = (other.m_flags | b2Body.e_islandFlag);
};
};
cn = cn.next;
};
jn = b.m_jointList;
while (jn != null) {
if (jn.joint.m_islandFlag == true){
} else {
island.AddJoint(jn.joint);
jn.joint.m_islandFlag = true;
other = jn.other;
if ((other.m_flags & b2Body.e_islandFlag)){
} else {
var _temp3 = stackCount;
stackCount = (stackCount + 1);
_local18 = _temp3;
stack[_local18] = other;
other.m_flags = (other.m_flags | b2Body.e_islandFlag);
};
};
jn = jn.next;
};
};
};
island.Solve(step, m_gravity);
m_positionIterationCount = b2Math.b2Max(m_positionIterationCount, b2Island.m_positionIterationCount);
if (m_allowSleep){
island.UpdateSleep(dt);
};
i = 0;
while (i < island.m_bodyCount) {
b = island.m_bodies[i];
if ((b.m_flags & b2Body.e_staticFlag)){
b.m_flags = (b.m_flags & ~(b2Body.e_islandFlag));
};
if (((b.IsFrozen()) && (m_listener))){
response = m_listener.NotifyBoundaryViolated(b);
if (response == b2WorldListener.b2_destroyBody){
DestroyBody(b);
b = null;
island.m_bodies[i] = null;
};
};
i++;
};
};
seed = seed.m_next;
};
m_broadPhase.Commit();
}
public function GetJointList():b2Joint{
return (m_jointList);
}
public function GetBodyList():b2Body{
return (m_bodyList);
}
}
}//package Box2D.Dynamics
Section 63
//b2WorldListener (Box2D.Dynamics.b2WorldListener)
package Box2D.Dynamics {
import Box2D.Dynamics.Joints.*;
public class b2WorldListener {
public static var b2_freezeBody:uint = 0;
public static var b2_destroyBody:uint = 1;
public function b2WorldListener(){
super();
}
public function NotifyJointDestroyed(joint:b2Joint):void{
}
public function NotifyBoundaryViolated(body:b2Body):uint{
return (b2_freezeBody);
}
}
}//package Box2D.Dynamics
Section 64
//BagsSubControl (com.whirled.game.BagsSubControl)
package com.whirled.game {
import com.whirled.*;
public class BagsSubControl extends AbstractSubControl {
public static const SHOW_TO_ALL:int = 0;
public function BagsSubControl(_arg1:AbstractControl){
super(_arg1);
}
public function create(_arg1:String, _arg2:Array):void{
populate(_arg1, _arg2, true);
}
public function deal(_arg1:String, _arg2:int, _arg3:String, _arg4:Function=null, _arg5:int=0):void{
getFrom(_arg1, _arg2, _arg3, _arg5, true, _arg4);
}
public function addTo(_arg1:String, _arg2:Array):void{
populate(_arg1, _arg2, false);
}
protected function getFrom(_arg1:String, _arg2:int, _arg3:String, _arg4:int, _arg5:Boolean, _arg6:Function):void{
callHostCode("getFromCollection_v2", _arg1, _arg2, _arg3, _arg4, _arg5, _arg6);
}
public function pick(_arg1:String, _arg2:int, _arg3:String, _arg4:int=0):void{
getFrom(_arg1, _arg2, _arg3, _arg4, false, null);
}
protected function populate(_arg1:String, _arg2:Array, _arg3:Boolean):void{
callHostCode("populateCollection_v1", _arg1, _arg2, _arg3);
}
public function merge(_arg1:String, _arg2:String):void{
callHostCode("mergeCollection_v1", _arg1, _arg2);
}
}
}//package com.whirled.game
Section 65
//CoinsAwardedEvent (com.whirled.game.CoinsAwardedEvent)
package com.whirled.game {
import flash.events.*;
public class CoinsAwardedEvent extends Event {
protected var _amount:int;
protected var _percentile:int;
public static const COINS_AWARDED:String = "CoinsAwarded";
public function CoinsAwardedEvent(_arg1:int, _arg2:int){
super(COINS_AWARDED, false, true);
_amount = _arg1;
_percentile = _arg2;
}
override public function toString():String{
return ((((((("CoinsAwardedEvent [type=" + type) + ", amount=") + _amount) + ", percentile=") + _percentile) + "]"));
}
public function get percentile():int{
return (_percentile);
}
public function get amount():int{
return (_amount);
}
override public function clone():Event{
return (new CoinsAwardedEvent(_amount, _percentile));
}
}
}//package com.whirled.game
Section 66
//ElementChangedEvent (com.whirled.game.ElementChangedEvent)
package com.whirled.game {
import flash.events.*;
public class ElementChangedEvent extends PropertyChangedEvent {
protected var _key:int;
public static const ELEMENT_CHANGED:String = "ElemChanged";
public function ElementChangedEvent(_arg1:String, _arg2:String, _arg3:Object, _arg4:Object, _arg5:int){
super(_arg1, _arg2, _arg3, _arg4);
_key = _arg5;
}
public function get index():int{
return (_key);
}
override public function clone():Event{
return (new ElementChangedEvent(type, _name, _newValue, _oldValue, _key));
}
public function get key():int{
return (_key);
}
override public function toString():String{
return ((((((("[ElementChangedEvent name=" + _name) + ", value=") + _newValue) + ", key=") + _key) + "]"));
}
}
}//package com.whirled.game
Section 67
//GameControl (com.whirled.game.GameControl)
package com.whirled.game {
import flash.events.*;
import flash.display.*;
import com.whirled.*;
public class GameControl extends AbstractControl {
protected var _servicesCtrl:ServicesSubControl;
protected var _playerCtrl:PlayerSubControl;
protected var _connected:Boolean;
protected var _gameCtrl:GameSubControl;
protected var _localCtrl:LocalSubControl;
protected var _netCtrl:NetSubControl;
public function GameControl(_arg1:DisplayObject, _arg2:Boolean=true){
super(_arg1, {autoReady_v1:_arg2});
_arg1.root.addEventListener(MouseEvent.CLICK, handleRootClick);
}
public function get net():NetSubControl{
return (_netCtrl);
}
public function get player():PlayerSubControl{
return (_playerCtrl);
}
override protected function setUserProps(_arg1:Object):void{
super.setUserProps(_arg1);
_arg1["connectionClosed_v1"] = connectionClosed_v1;
}
public function get services():ServicesSubControl{
return (_servicesCtrl);
}
public function get local():LocalSubControl{
return (_localCtrl);
}
public function get game():GameSubControl{
return (_gameCtrl);
}
private function connectionClosed_v1():void{
_connected = false;
}
override protected function createSubControls():Array{
return ([(_localCtrl = new LocalSubControl(this)), (_netCtrl = new NetSubControl(this)), (_playerCtrl = new PlayerSubControl(this)), (_gameCtrl = new GameSubControl(this)), (_servicesCtrl = new ServicesSubControl(this))]);
}
override protected function gotHostProps(_arg1:Object):void{
super.gotHostProps(_arg1);
_connected = !((_arg1.gameData == null));
}
protected function handleRootClick(_arg1:MouseEvent):void{
var evt = _arg1;
if (!isConnected()){
return;
};
try {
if ((((evt.target.stage == null)) || (!((evt.target.stage.focus == null))))){
return;
};
} catch(err:SecurityError) {
};
callHostCode("focusContainer_v1");
}
override public function isConnected():Boolean{
return (_connected);
}
}
}//package com.whirled.game
Section 68
//GameSubControl (com.whirled.game.GameSubControl)
package com.whirled.game {
import com.whirled.*;
public class GameSubControl extends AbstractSubControl {
protected var _gameConfig:Object;
protected var _seatingCtrl:SeatingSubControl;
public static const PROPORTIONAL:int = 3;
public static const TO_EACH_THEIR_OWN:int = 2;
public static const CURRENT_USER:int = 0;
public static const WINNERS_TAKE_ALL:int = 1;
public static const SERVER_AGENT_ID:int = -2147483648;
public static const CASCADING_PAYOUT:int = 0;
public function GameSubControl(_arg1:GameControl){
_gameConfig = {};
super(_arg1);
}
private function occupantChanged_v1(_arg1:int, _arg2:Boolean, _arg3:Boolean):void{
dispatch(new OccupantChangedEvent((_arg3) ? OccupantChangedEvent.OCCUPANT_ENTERED : OccupantChangedEvent.OCCUPANT_LEFT, _arg1, _arg2));
}
public function getOccupantIds():Array{
return ((callHostCode("getOccupants_v1") as Array));
}
public function getTurnHolderId():int{
return (int(callHostCode("getTurnHolder_v1")));
}
private function gameStateChanged_v1(_arg1:Boolean):void{
dispatch(new StateChangedEvent((_arg1) ? StateChangedEvent.GAME_STARTED : StateChangedEvent.GAME_ENDED));
}
public function endGameWithScore(_arg1:int):void{
endGameWithScores([getMyId()], [_arg1], TO_EACH_THEIR_OWN);
}
public function isMyTurn():Boolean{
return (Boolean(callHostCode("isMyTurn_v1")));
}
public function startNextTurn(_arg1:int=0):void{
callHostCode("startNextTurn_v1", _arg1);
}
override protected function setUserProps(_arg1:Object):void{
super.setUserProps(_arg1);
_arg1["controlDidChange_v1"] = controlDidChange_v1;
_arg1["turnDidChange_v1"] = turnDidChange_v1;
_arg1["gameStateChanged_v1"] = gameStateChanged_v1;
_arg1["roundStateChanged_v1"] = roundStateChanged_v1;
_arg1["occupantChanged_v1"] = occupantChanged_v1;
_arg1["userChat_v1"] = userChat_v1;
}
public function restartGameIn(_arg1:int):void{
if (_seatingCtrl != null){
throw (new Error("restartGameIn() is only applicable to party games."));
};
callHostCode("restartGameIn_v1", _arg1);
}
private function controlDidChange_v1():void{
dispatch(new StateChangedEvent(StateChangedEvent.CONTROL_CHANGED));
}
public function amInControl():Boolean{
return ((getControllerId() == getMyId()));
}
public function amServerAgent():Boolean{
return ((getMyId() == SERVER_AGENT_ID));
}
public function getConfig():Object{
return (_gameConfig);
}
public function get seating():SeatingSubControl{
return (_seatingCtrl);
}
public function endGameWithWinners(_arg1:Array, _arg2:Array, _arg3:int):void{
callHostCode("endGameWithWinners_v1", _arg1, _arg2, _arg3);
}
public function playerReady():void{
if (_seatingCtrl == null){
throw (new Error("playerReady() is only applicable to seated games."));
};
callHostCode("playerReady_v1");
}
public function isInPlay():Boolean{
return (Boolean(callHostCode("isInPlay_v1")));
}
private function turnDidChange_v1():void{
dispatch(new StateChangedEvent(StateChangedEvent.TURN_CHANGED));
}
public function getLevelPacks(_arg1:int=0):Array{
return ((callHostCode("getLevelPacks_v1", _arg1) as Array));
}
public function getRound():int{
return (int(callHostCode("getRound_v1")));
}
public function endGameWithScores(_arg1:Array, _arg2:Array, _arg3:int):void{
callHostCode("endGameWithScores_v1", _arg1, _arg2, _arg3);
}
public function getControllerId():int{
return (int(callHostCode("getControllerId_v1")));
}
public function getMyId():int{
return (int(callHostCode("getMyId_v1")));
}
public function systemMessage(_arg1:String):void{
callHostCode("sendChat_v1", _arg1);
}
public function getOccupantName(_arg1:int):String{
return (String(callHostCode("getOccupantName_v1", _arg1)));
}
private function roundStateChanged_v1(_arg1:Boolean):void{
dispatch(new StateChangedEvent((_arg1) ? StateChangedEvent.ROUND_STARTED : StateChangedEvent.ROUND_ENDED));
}
public function getItemPacks():Array{
return ((callHostCode("getItemPacks_v1") as Array));
}
public function endRound(_arg1:int=0):void{
callHostCode("endRound_v1", _arg1);
}
private function userChat_v1(_arg1:int, _arg2:String):void{
dispatch(new UserChatEvent(_arg1, _arg2));
}
override protected function createSubControls():Array{
return ([(_seatingCtrl = new SeatingSubControl(_parent, this))]);
}
override protected function gotHostProps(_arg1:Object):void{
var o = _arg1;
super.gotHostProps(o);
_gameConfig = o.gameConfig;
try {
if (o["gameInfo"]["type"] == "party"){
_seatingCtrl = null;
_subControls = null;
};
} catch(er:Error) {
};
}
}
}//package com.whirled.game
Section 69
//LocalSubControl (com.whirled.game.LocalSubControl)
package com.whirled.game {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import com.whirled.*;
public class LocalSubControl extends AbstractSubControl {
public function LocalSubControl(_arg1:GameControl){
super(_arg1);
}
public function feedback(_arg1:String):void{
callHostCode("localChat_v1", _arg1);
}
public function getHeadShot(_arg1:int):DisplayObject{
return ((callHostCode("getHeadShot_v2", _arg1) as DisplayObject));
}
override public function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{
super.removeEventListener(_arg1, _arg2, _arg3);
switch (_arg1){
case KeyboardEvent.KEY_UP:
case KeyboardEvent.KEY_DOWN:
if (!hasEventListener(_arg1)){
callHostCode("alterKeyEvents_v1", _arg1, false);
};
break;
};
}
override public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
super.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5);
switch (_arg1){
case KeyboardEvent.KEY_UP:
case KeyboardEvent.KEY_DOWN:
if (hasEventListener(_arg1)){
callHostCode("alterKeyEvents_v1", _arg1, true);
};
break;
};
}
private function sizeChanged_v1(_arg1:Point):void{
dispatch(new SizeChangedEvent(_arg1));
}
public function setShowButtons(_arg1:Boolean=true, _arg2:Boolean=true):void{
callHostCode("setShowButtons_v1", _arg1, _arg2);
}
public function clearScores(_arg1:Object=null, _arg2:Boolean=false):void{
callHostCode("clearScores_v1", _arg1, _arg2);
}
public function setOccupantsLabel(_arg1:String):void{
callHostCode("setOccupantsLabel_v1", _arg1);
}
override protected function setUserProps(_arg1:Object):void{
super.setUserProps(_arg1);
_arg1["dispatchEvent_v1"] = dispatch;
_arg1["sizeChanged_v1"] = sizeChanged_v1;
}
public function setPlayerScores(_arg1:Array, _arg2:Array=null):void{
callHostCode("setPlayerScores_v1", _arg1, _arg2);
}
public function setStageQuality(_arg1:String="medium"):void{
callHostCode("setStageQuality_v1", _arg1);
}
public function setFrameRate(_arg1:Number=30):void{
callHostCode("setFrameRate_v1", _arg1);
}
public function setMappedScores(_arg1:Object):void{
callHostCode("setMappedScores_v1", _arg1);
}
public function getSize():Point{
return ((callHostCode("getSize_v1") as Point));
}
public function filter(_arg1:String):String{
return ((callHostCode("filter_v1", _arg1) as String));
}
public function backToWhirled(_arg1:Boolean=false):void{
callHostCode("backToWhirled_v1", _arg1);
}
}
}//package com.whirled.game
Section 70
//MessageReceivedEvent (com.whirled.game.MessageReceivedEvent)
package com.whirled.game {
import flash.events.*;
public class MessageReceivedEvent extends Event {
protected var _senderId:int;
protected var _name:String;
protected var _value:Object;
protected static const SERVER_AGENT_ID:int = -2147483648;
protected static const SERVER_ID:int = 0;
public static const MESSAGE_RECEIVED:String = "MsgReceived";
public function MessageReceivedEvent(_arg1:String, _arg2:Object, _arg3:int){
super(MESSAGE_RECEIVED);
_name = _arg1;
_value = _arg2;
_senderId = _arg3;
}
public function get name():String{
return (_name);
}
public function isFromServer():Boolean{
return ((((_senderId == SERVER_ID)) || ((_senderId == SERVER_AGENT_ID))));
}
override public function clone():Event{
return (new MessageReceivedEvent(_name, _value, _senderId));
}
override public function toString():String{
return ((((((("[MessageReceivedEvent name=" + _name) + ", value=") + _value) + ", sender=") + _senderId) + "]"));
}
public function get senderId():int{
return (_senderId);
}
public function get value():Object{
return (_value);
}
}
}//package com.whirled.game
Section 71
//NetSubControl (com.whirled.game.NetSubControl)
package com.whirled.game {
import com.whirled.*;
public class NetSubControl extends AbstractSubControl {
protected var _gameData:Object;
public static const TO_SERVER_AGENT:int = -2147483648;
public static const TO_ALL:int = 0;
public function NetSubControl(_arg1:GameControl){
super(_arg1);
}
public function getPropertyNames(_arg1:String=""):Array{
var _local2:Array;
var _local3:String;
_local2 = [];
for (_local3 in _gameData) {
if (_local3.lastIndexOf(_arg1, 0) == 0){
_local2.push(_local3);
};
};
return (_local2);
}
private function messageReceived_v2(_arg1:String, _arg2:Object, _arg3:int):void{
dispatch(new MessageReceivedEvent(_arg1, _arg2, _arg3));
}
public function get(_arg1:String):Object{
checkIsConnected();
return (_gameData[_arg1]);
}
public function sendMessage(_arg1:String, _arg2:Object, _arg3:int=0):void{
callHostCode("sendMessage_v2", _arg1, _arg2, _arg3);
}
public function set(_arg1:String, _arg2:Object, _arg3:Boolean=false):void{
callHostCode("setProperty_v2", _arg1, _arg2, null, false, _arg3);
}
override protected function setUserProps(_arg1:Object):void{
super.setUserProps(_arg1);
_arg1["propertyWasSet_v2"] = propertyWasSet_v2;
_arg1["messageReceived_v2"] = messageReceived_v2;
}
public function sendMessageToAgent(_arg1:String, _arg2:Object):void{
sendMessage(_arg1, _arg2, TO_SERVER_AGENT);
}
private function propertyWasSet_v2(_arg1:String, _arg2:Object, _arg3:Object, _arg4:Object):void{
if (_arg4 == null){
dispatch(new PropertyChangedEvent(PropertyChangedEvent.PROPERTY_CHANGED, _arg1, _arg2, _arg3));
} else {
dispatch(new ElementChangedEvent(ElementChangedEvent.ELEMENT_CHANGED, _arg1, _arg2, _arg3, int(_arg4)));
};
}
public function setAt(_arg1:String, _arg2:int, _arg3:Object, _arg4:Boolean=false):void{
callHostCode("setProperty_v2", _arg1, _arg3, _arg2, true, _arg4);
}
public function setIn(_arg1:String, _arg2:int, _arg3:Object, _arg4:Boolean=false):void{
callHostCode("setProperty_v2", _arg1, _arg3, _arg2, false, _arg4);
}
override protected function gotHostProps(_arg1:Object):void{
super.gotHostProps(_arg1);
_gameData = _arg1.gameData;
}
public function testAndSet(_arg1:String, _arg2:Object, _arg3:Object):void{
callHostCode("testAndSetProperty_v1", _arg1, _arg2, _arg3);
}
}
}//package com.whirled.game
Section 72
//OccupantChangedEvent (com.whirled.game.OccupantChangedEvent)
package com.whirled.game {
import flash.events.*;
public class OccupantChangedEvent extends Event {
protected var _player:Boolean;
protected var _occupantId:int;
public static const OCCUPANT_LEFT:String = "OccupantLeft";
public static const OCCUPANT_ENTERED:String = "OccupantEntered";
public function OccupantChangedEvent(_arg1:String, _arg2:int, _arg3:Boolean){
super(_arg1);
_occupantId = _arg2;
_player = _arg3;
}
override public function toString():String{
return ((((((("[OccupantChangedEvent type=" + type) + ", occupantId=") + _occupantId) + ", player=") + _player) + "]"));
}
public function get player():Boolean{
return (_player);
}
public function get occupantId():int{
return (_occupantId);
}
override public function clone():Event{
return (new OccupantChangedEvent(type, _occupantId, _player));
}
}
}//package com.whirled.game
Section 73
//PlayerSubControl (com.whirled.game.PlayerSubControl)
package com.whirled.game {
import com.whirled.*;
public class PlayerSubControl extends AbstractSubControl {
public static const CURRENT_USER:int = 0;
public function PlayerSubControl(_arg1:GameControl){
super(_arg1);
}
private function flowAwarded_v1(_arg1:int, _arg2:int):Boolean{
var _local3:CoinsAwardedEvent;
_local3 = new CoinsAwardedEvent(_arg1, _arg2);
dispatch(_local3);
return (_local3.isDefaultPrevented());
}
public function getPlayerItemPacks(_arg1:int=0):Array{
return ((callHostCode("getPlayerItemPacks_v1", _arg1) as Array));
}
public function getCookie(_arg1:Function, _arg2:int=0):void{
callHostCode("getCookie_v1", _arg1, _arg2);
}
override protected function setUserProps(_arg1:Object):void{
super.setUserProps(_arg1);
_arg1["flowAwarded_v1"] = flowAwarded_v1;
}
public function holdsTrophy(_arg1:String, _arg2:int=0):Boolean{
return ((callHostCode("holdsTrophy_v1", _arg1, _arg2) as Boolean));
}
public function setCookie(_arg1:Object, _arg2:int=0):Boolean{
return (Boolean(callHostCode("setCookie_v1", _arg1, _arg2)));
}
public function awardTrophy(_arg1:String, _arg2:int=0):Boolean{
return ((callHostCode("awardTrophy_v1", _arg1, _arg2) as Boolean));
}
public function awardPrize(_arg1:String, _arg2:int=0):void{
callHostCode("awardPrize_v1", _arg1, _arg2);
}
}
}//package com.whirled.game
Section 74
//PropertyChangedEvent (com.whirled.game.PropertyChangedEvent)
package com.whirled.game {
import flash.events.*;
public class PropertyChangedEvent extends Event {
protected var _newValue:Object;
protected var _oldValue:Object;
protected var _name:String;
public static const PROPERTY_CHANGED:String = "PropChanged";
public function PropertyChangedEvent(_arg1:String, _arg2:String, _arg3:Object, _arg4:Object){
super(_arg1);
_name = _arg2;
_newValue = _arg3;
_oldValue = _arg4;
}
public function get oldValue():Object{
return (_oldValue);
}
public function get name():String{
return (_name);
}
override public function clone():Event{
return (new PropertyChangedEvent(type, _name, _newValue, _oldValue));
}
override public function toString():String{
return ((((("[PropertyChangedEvent name=" + _name) + ", value=") + _newValue) + "]"));
}
public function get newValue():Object{
return (_newValue);
}
}
}//package com.whirled.game
Section 75
//SeatingSubControl (com.whirled.game.SeatingSubControl)
package com.whirled.game {
import com.whirled.*;
public class SeatingSubControl extends AbstractSubControl {
protected var _game:GameSubControl;
public function SeatingSubControl(_arg1:AbstractControl, _arg2:GameSubControl){
super(_arg1);
_game = _arg2;
}
public function getPlayerNames():Array{
return (getPlayerIds().map(function (_arg1:int, _arg2, _arg3):String{
return (((_arg1)==0) ? null : _game.getOccupantName(_arg1));
}));
}
public function getPlayerIds():Array{
return ((callHostCode("getPlayers_v1") as Array));
}
public function getMyPosition():int{
return (int(callHostCode("getMyPosition_v1")));
}
public function getPlayerPosition(_arg1:int):int{
return (int(callHostCode("getPlayerPosition_v1", _arg1)));
}
}
}//package com.whirled.game
Section 76
//ServicesSubControl (com.whirled.game.ServicesSubControl)
package com.whirled.game {
import com.whirled.*;
public class ServicesSubControl extends AbstractSubControl {
protected var _bagsCtrl:BagsSubControl;
public function ServicesSubControl(_arg1:GameControl){
super(_arg1);
}
public function stopTicker(_arg1:String):void{
startTicker(_arg1, 0);
}
public function startTicker(_arg1:String, _arg2:int):void{
callHostCode("setTicker_v1", _arg1, _arg2);
}
override protected function createSubControls():Array{
return ([(_bagsCtrl = new BagsSubControl(_parent))]);
}
public function checkDictionaryWord(_arg1:String, _arg2:String, _arg3:String, _arg4:Function):void{
callHostCode("checkDictionaryWord_v2", _arg1, _arg2, _arg3, _arg4);
}
public function get bags():BagsSubControl{
return (_bagsCtrl);
}
public function getDictionaryLetterSet(_arg1:String, _arg2:String, _arg3:int, _arg4:Function):void{
callHostCode("getDictionaryLetterSet_v2", _arg1, _arg2, _arg3, _arg4);
}
public function getDictionaryWords(_arg1:String, _arg2:String, _arg3:int, _arg4:Function):void{
callHostCode("getDictionaryWords_v1", _arg1, _arg2, _arg3, _arg4);
}
}
}//package com.whirled.game
Section 77
//SizeChangedEvent (com.whirled.game.SizeChangedEvent)
package com.whirled.game {
import flash.events.*;
import flash.geom.*;
public class SizeChangedEvent extends Event {
protected var _size:Point;
public static const SIZE_CHANGED:String = "SizeChanged";
public function SizeChangedEvent(_arg1:Point){
super(SIZE_CHANGED);
_size = _arg1;
}
override public function toString():String{
return ((("[SizeChangedEvent size=" + _size) + "]"));
}
public function get size():Point{
return (_size);
}
override public function clone():Event{
return (new SizeChangedEvent(_size.clone()));
}
}
}//package com.whirled.game
Section 78
//StateChangedEvent (com.whirled.game.StateChangedEvent)
package com.whirled.game {
import flash.events.*;
public class StateChangedEvent extends Event {
public static const CONTROL_CHANGED:String = "ControlChanged";
public static const ROUND_ENDED:String = "RoundEnded";
public static const GAME_ENDED:String = "GameEnded";
public static const ROUND_STARTED:String = "RoundStarted";
public static const GAME_STARTED:String = "GameStarted";
public static const TURN_CHANGED:String = "TurnChanged";
public function StateChangedEvent(_arg1:String){
super(_arg1);
}
override public function toString():String{
return ((("[StateChangedEvent type=" + type) + "]"));
}
override public function clone():Event{
return (new StateChangedEvent(type));
}
}
}//package com.whirled.game
Section 79
//UserChatEvent (com.whirled.game.UserChatEvent)
package com.whirled.game {
import flash.events.*;
public class UserChatEvent extends Event {
protected var _message:String;
protected var _speaker:int;
public static const USER_CHAT:String = "UserChat";
public function UserChatEvent(_arg1:int, _arg2:String){
super(USER_CHAT);
_speaker = _arg1;
_message = _arg2;
}
override public function toString():String{
return ((((("[UserChatEvent speaker=" + _speaker) + ", message=") + _message) + "]"));
}
public function get message():String{
return (_message);
}
override public function clone():Event{
return (new UserChatEvent(_speaker, _message));
}
public function get speaker():int{
return (_speaker);
}
}
}//package com.whirled.game
Section 80
//AbstractControl (com.whirled.AbstractControl)
package com.whirled {
import flash.events.*;
import flash.display.*;
import flash.errors.*;
public class AbstractControl extends EventDispatcher {
protected var _subControls:Array;
protected var _funcs:Object;
public function AbstractControl(_arg1:DisplayObject, _arg2:Object=null){
var _local3:Object;
var _local4:ConnectEvent;
var _local5:Object;
super();
_subControls = createSubControls();
if ((this is AbstractSubControl)){
return;
};
if (_arg1.root == null){
throw (new Error("Display object used to instantiate a control must be on the stage"));
};
_arg1.root.loaderInfo.addEventListener(Event.UNLOAD, handleUnload, false, 0, true);
_local3 = ((_arg2)!=null) ? _arg2 : new Object();
setUserProps(_local3);
_local4 = new ConnectEvent();
_local4.props.userProps = _local3;
_arg1.root.loaderInfo.sharedEvents.dispatchEvent(_local4);
if (Boolean(_local4.props.alreadyConnected)){
throw (new Error("You've already set up a Control instance. There should only be one."));
};
_local5 = _local4.props.hostProps;
if (_local5 != null){
gotHostProps(_local5);
};
}
override public function dispatchEvent(_arg1:Event):Boolean{
throw (new IllegalOperationError());
}
protected function dispatch(_arg1:Event):void{
var event = _arg1;
try {
super.dispatchEvent(event);
} catch(err:Error) {
trace("Error dispatching event to user code.");
trace(err.getStackTrace());
};
}
protected function handleUnload(_arg1:Event):void{
dispatch(_arg1);
}
override public function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{
super.removeEventListener(_arg1, _arg2, _arg3);
}
override public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
super.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5);
}
protected function checkIsConnected():void{
if (!isConnected()){
throw (new IllegalOperationError(("The control is not connected to the host framework, please check isConnected(). " + "If false, your SWF is being viewed standalone and should adjust.")));
};
}
protected function setUserProps(_arg1:Object):void{
var _local2:AbstractSubControl;
for each (_local2 in _subControls) {
_local2.setUserPropsFriend(_arg1);
};
}
public function doBatch(_arg1:Function):void{
var fn = _arg1;
callHostCode("startTransaction");
try {
fn();
} finally {
callHostCode("commitTransaction");
};
}
function callHostCodeFriend(_arg1:String, _arg2:Array){
_arg2.unshift(_arg1);
return (callHostCode.apply(this, _arg2));
}
protected function callHostCode(_arg1:String, ... _args){
var func:Function;
var name = _arg1;
var args = _args;
if (_funcs != null){
try {
func = (_funcs[name] as Function);
if (func != null){
return (func.apply(null, args));
};
} catch(err:Error) {
trace(err.getStackTrace());
throw (new Error(("Unable to call host code: " + err.message)));
};
} else {
checkIsConnected();
};
return (undefined);
}
protected function createSubControls():Array{
return (null);
}
protected function gotHostProps(_arg1:Object):void{
var _local2:AbstractSubControl;
_funcs = _arg1;
for each (_local2 in _subControls) {
_local2.gotHostPropsFriend(_arg1);
};
}
public function isConnected():Boolean{
return (!((_funcs == null)));
}
}
}//package com.whirled
import flash.events.*;
class ConnectEvent extends Event {
public var props:Object;
private function ConnectEvent(_arg1:Object=null){
super("controlConnect", true, false);
props = ((_arg1) || ({}));
}
override public function clone():Event{
return (new ConnectEvent(props));
}
}
Section 81
//AbstractSubControl (com.whirled.AbstractSubControl)
package com.whirled {
import flash.events.*;
public class AbstractSubControl extends AbstractControl {
protected var _parent:AbstractControl;
public function AbstractSubControl(_arg1:AbstractControl){
_parent = _arg1;
_parent.addEventListener(Event.UNLOAD, handleUnload, false, 0, true);
super(null);
}
function gotHostPropsFriend(_arg1:Object):void{
gotHostProps(_arg1);
}
function setUserPropsFriend(_arg1:Object):void{
setUserProps(_arg1);
}
override public function doBatch(_arg1:Function):void{
return (_parent.doBatch(_arg1));
}
override protected function callHostCode(_arg1:String, ... _args){
return (_parent.callHostCodeFriend(_arg1, _args));
}
override public function isConnected():Boolean{
return (_parent.isConnected());
}
}
}//package com.whirled
Section 82
//BeginEditingEvent (contraption.blocks.BeginEditingEvent)
package contraption.blocks {
import flash.events.*;
public class BeginEditingEvent extends Event {
public var block:EditableBlock;
public static const BEGIN_EDITING:String = "beginEditing";
public function BeginEditingEvent(block:EditableBlock){
super(BEGIN_EDITING);
this.block = block;
}
override public function clone():Event{
return (new BeginEditingEvent(block));
}
}
}//package contraption.blocks
Section 83
//Block (contraption.blocks.Block)
package contraption.blocks {
import contraption.*;
import flash.display.*;
import flash.geom.*;
import de.polygonal.ds.*;
import Box2D.Dynamics.*;
import flash.utils.*;
import flash.errors.*;
public class Block extends ActionContainerImpl {
protected var physicsBody:b2Body;
public var jointedBlocks:Dictionary;
protected var blockHeight:Number;// = 50
protected var blockBackground:Sprite;
protected var blockForegroundCanvas:ActionContainerImpl;
protected var blockRotation:Number;// = 0
protected var blockForeground:Sprite;
protected var joints:SLinkedList;
protected var blockWidth:Number;// = 50
public var isGoalBlock:Boolean;
protected var physicsBodyDef:b2BodyDef;
public var saveIndex:Number;
protected var blockPosition:Point;
protected var blockBackgroundCanvas:ActionContainerImpl;
public static const CLOCKWISE:int = 0;
public static const COUNTER_CLOCKWISE:int = -1;
public function Block(isGoalBlock:Boolean=false){
blockPosition = new Point(100, 100);
blockForeground = new Sprite();
addChild(blockForeground);
blockBackground = new Sprite();
this.isGoalBlock = isGoalBlock;
joints = new SLinkedList();
super();
}
public function setRotation(value:Number):void{
blockRotation = value;
rotation = (value * (180 / Math.PI));
if (blockBackground != null){
blockBackground.rotation = rotation;
};
updatePhysicsBody();
}
public function isJointedTo(block:Block):Boolean{
var jointIter:Iterator;
var jointCollection:JointCollection;
var jointCollectionIter:SListIterator = joints.getListIterator();
while (jointCollectionIter.hasNext()) {
jointCollection = (jointCollectionIter.next() as JointCollection);
if (jointCollection.isJointedTo(block)){
return (true);
};
};
return (false);
}
protected function setBlockCanvas():void{
reDrawBlock();
x = getPosition().x;
y = getPosition().y;
rotation = (getRotation() * (180 / Math.PI));
blockBackground.x = getPosition().x;
blockBackground.y = getPosition().y;
blockBackground.rotation = (getRotation() * (180 / Math.PI));
}
public function setWidth(value:Number):void{
blockWidth = value;
}
public function updatePhysicsBody():void{
var world:b2World;
if (physicsBody != null){
world = physicsBody.m_world;
world.DestroyBody(physicsBody);
world.CleanBodyList();
generatePhysicsBody(world);
};
}
override protected function initAllowableActions():void{
allowableActions = new Actions();
allowableActions.move = true;
allowableActions.delete_ = true;
allowableActions.build = true;
}
public function collidesWithJointedBlocks():Boolean{
return (true);
}
public function getWidth():Number{
return (blockWidth);
}
protected function generatePhysicsBodyDef():b2BodyDef{
throw (new IllegalOperationError("You must extend Block and implement \"generatePhysicsBodyDef\""));
}
public function moveWithJoint(joint:JointCollection, movementVector:Point):void{
setPosition(getPosition().add(movementVector));
setBlockCanvas();
}
public function drawAnchor(position:Point, canvas:Sprite=null):void{
drawTypedAnchor(position, JointType.PIN, canvas);
}
public function getHeight():Number{
return (blockHeight);
}
public function getPosition():Point{
return (blockPosition);
}
public function setCollisionMaskBits(bits:int):void{
physicsBodyDef.shapes[0].maskBits = bits;
}
protected function getJointXml():XML{
var jointCollection:JointCollection;
var block:Block;
var xml:XML = <joints/>
;
var jointCollectionIter:Iterator = joints.getIterator();
while (jointCollectionIter.hasNext()) {
jointCollection = (jointCollectionIter.next() as JointCollection);
block = jointCollection.getBlockJointedBeneath(this);
if (block != null){
xml.appendChild((("<jointedTo>" + block.saveIndex) + "</jointedTo>"));
};
};
return (xml);
}
public function getClosestJointCollection(point:Point):JointCollection{
var jointIter:Iterator;
var jointCollection:JointCollection;
var distance:Number;
var jointCollectionIter:Iterator = joints.getIterator();
var closestJoint:JointCollection;
var closestDistance:Number = 1000000;
while (jointCollectionIter.hasNext()) {
jointCollection = (jointCollectionIter.next() as JointCollection);
distance = Point.distance(jointCollection.getPosition(), point);
if (distance < closestDistance){
closestDistance = distance;
closestJoint = jointCollection;
};
};
return (closestJoint);
}
public function setHeight(value:Number):void{
blockHeight = value;
}
public function setPosition(value:Point):void{
blockPosition = value;
x = value.x;
y = value.y;
if (blockBackground != null){
blockBackground.x = value.x;
blockBackground.y = value.y;
};
updatePhysicsBody();
}
public function drawMotorAnchor(position:Point, canvas:Sprite=null):void{
drawTypedAnchor(position, JointType.MOTOR_CLOCKWISE, canvas);
}
public function getCollisionMaskBits():int{
return (physicsBodyDef.shapes[0].maskBits);
}
protected function drawBlock(canvas:Sprite, backgroundCanvas:Sprite):void{
throw (new IllegalOperationError("You must extend Block and implement \"drawBlock\""));
}
public function addJoints(jointDictionary:Dictionary):void{
var jointIter:Iterator;
var jointCollection:JointCollection;
var jointCollectionIter:SListIterator = joints.getListIterator();
while (jointCollectionIter.hasNext()) {
jointCollection = (jointCollectionIter.next() as JointCollection);
jointDictionary[jointCollection] = jointCollection;
};
}
public function setCollisionCategoryBits(bits:int):void{
physicsBodyDef.shapes[0].categoryBits = bits;
}
public function getJointType():JointType{
return (JointType.PIN);
}
public function reDrawBlock():void{
if (blockForegroundCanvas != null){
blockForeground.removeChild(blockForegroundCanvas);
};
if (blockBackgroundCanvas != null){
blockBackground.removeChild(blockBackgroundCanvas);
};
blockForegroundCanvas = new ActionContainerImpl();
blockForegroundCanvas.setAllowableActions(getAllowableActions());
blockForeground.addChild(blockForegroundCanvas);
blockBackgroundCanvas = new ActionContainerImpl();
blockBackgroundCanvas.setAllowableActions(getAllowableActions());
blockBackground.addChild(blockBackgroundCanvas);
drawBlock(blockForegroundCanvas, blockBackgroundCanvas);
}
public function startJoints(physicsWorld:b2World):void{
var jointCollection:JointCollection;
var jointCollectionIter:Iterator = joints.getIterator();
while (jointCollectionIter.hasNext()) {
jointCollection = (jointCollectionIter.next() as JointCollection);
jointCollection.startJoints(physicsWorld);
};
}
public function getClosestJointDistance(point:Point):Number{
var jointIter:Iterator;
var jointCollection:JointCollection;
var distance:Number;
var jointCollectionIter:Iterator = joints.getIterator();
var closestDistance:Number = NaN;
while (jointCollectionIter.hasNext()) {
jointCollection = (jointCollectionIter.next() as JointCollection);
distance = Point.distance(jointCollection.getPosition(), point);
if ((((distance < closestDistance)) || (isNaN(closestDistance)))){
closestDistance = distance;
};
};
return (closestDistance);
}
public function getCollisionCategoryBits():int{
return (physicsBodyDef.shapes[0].categoryBits);
}
public function destroyBlock(physicsWorld:b2World):void{
unjointBlock();
if (physicsBody != null){
physicsWorld.DestroyBody(physicsBody);
};
physicsBody = null;
}
public function stopJoints(physicsWorld:b2World):void{
var jointIter:Iterator;
var jointCollection:JointCollection;
var jointCollectionIter:Iterator = joints.getIterator();
while (jointCollectionIter.hasNext()) {
jointCollection = (jointCollectionIter.next() as JointCollection);
jointIter = jointCollection.getIterator();
while (jointIter.hasNext()) {
(jointIter.next() as Joint).destroyPhysicsJoint(physicsWorld);
};
};
}
public function setJointedBlocks():void{
jointedBlocks = new Dictionary();
addJointedBlocks(jointedBlocks);
}
public function getPhysicsBody():b2Body{
return (physicsBody);
}
public function generatePhysicsBody(physicsWorld:b2World):b2Body{
var bodyDef:b2BodyDef = generatePhysicsBodyDef();
physicsBody = physicsWorld.CreateBody(bodyDef);
return (physicsBody);
}
public function drawTypedAnchor(position:Point, type:JointType, canvas:Sprite=null):void{
if (canvas == null){
canvas = blockForegroundCanvas;
};
var outerColour = 12381585;
var innerColour = 0x838383;
if (type != JointType.PIN){
outerColour = 16724787;
innerColour = 0xFFFFFF;
};
canvas.graphics.endFill();
canvas.graphics.lineStyle(2, innerColour);
canvas.graphics.drawCircle(position.x, position.y, 3);
canvas.graphics.lineStyle(0, 0, 0);
}
public function getXml():XML{
var xml:XML = new XML(getXmlRoot());
if (!isNaN(saveIndex)){
xml.@id = saveIndex;
};
xml.appendChild((("<rotation>" + getRotation()) + "</rotation>"));
var position:XML = new XML(<position></position>
);
position.appendChild((("<x>" + getPosition().x) + "</x>"));
position.appendChild((("<y>" + getPosition().y) + "</y>"));
xml.appendChild(position);
xml.appendChild((("<width>" + getWidth()) + "</width>"));
xml.appendChild((("<height>" + getHeight()) + "</height>"));
xml.appendChild((("<goalBlock>" + isGoalBlock) + "</goalBlock>"));
xml.appendChild(getJointXml());
return (xml);
}
protected function getXmlRoot():XML{
throw (new IllegalOperationError("You must extend EditableBlock and implement \"getXmlRoot\""));
}
public function getBlockBackground():Sprite{
return (blockBackground);
}
protected function addJoint(jointCollection:JointCollection):void{
joints.append(jointCollection);
}
public function getDistance(point:Point):Number{
throw (new IllegalOperationError("You must extend Block and implement \"getDistance\""));
}
public function setFromXML(xml:XML):void{
setRotation(new Number(xml.rotation));
setWidth(new Number(xml.width));
setHeight(new Number(xml.height));
var position:Point = new Point();
position.x = new Number(xml.position.x);
position.y = new Number(xml.position.y);
setPosition(position);
setBlockCanvas();
}
public function addJointedBlocks(jointedBlocks:Dictionary):void{
var jointCollection:JointCollection;
var jointCollectionIter:SListIterator = joints.getListIterator();
while (jointCollectionIter.hasNext()) {
jointCollection = (jointCollectionIter.next() as JointCollection);
jointCollection.addJointedBlocks(jointedBlocks);
};
}
public function getRotation():Number{
return (blockRotation);
}
public function updateFromPhysicsBody():void{
x = physicsBody.m_position.x;
y = physicsBody.m_position.y;
rotation = (physicsBody.m_rotation * (180 / Math.PI));
blockBackground.x = physicsBody.m_position.x;
blockBackground.y = physicsBody.m_position.y;
blockBackground.rotation = rotation;
}
public function getBlockForeground():MovieClip{
return (this);
}
public function replaceJointCollection(existing:JointCollection, newJoints:JointCollection):void{
var jointIter:Iterator;
var jointCollection:JointCollection;
var jointCollectionIter:SListIterator = joints.getListIterator();
while (jointCollectionIter.hasNext()) {
jointCollection = (jointCollectionIter.next() as JointCollection);
if (jointCollection == existing){
joints.insertAfter(jointCollectionIter, newJoints);
joints.remove(joints.nodeOf(jointCollection));
return;
};
};
}
protected function unjointBlock():void{
var jointCollection:JointCollection;
var jointCollectionIter:Iterator = joints.getIterator();
while (jointCollectionIter.hasNext()) {
jointCollection = (jointCollectionIter.next() as JointCollection);
jointCollection.unjointBlock(this);
};
}
public function resetBlock(physicsWorld:b2World):void{
physicsWorld.DestroyBody(physicsBody);
physicsBody = null;
setBlockCanvas();
}
}
}//package contraption.blocks
Section 84
//BlockCollection (contraption.blocks.BlockCollection)
package contraption.blocks {
import flash.geom.*;
import de.polygonal.ds.*;
import Box2D.Dynamics.*;
public class BlockCollection extends SLinkedList {
public function BlockCollection(){
super();
}
public function deleteBlock(physicsWorld:b2World, block:Block):void{
block.destroyBlock(physicsWorld);
remove(nodeOf(block));
}
protected function joinToJointCollection(jointCollection:JointCollection, block:Block):Joint{
var newJoint:Joint;
var jointType:JointType = block.getJointType();
if ((((((((jointCollection.getTopBlock() as Wheel)) && ((jointCollection.getTopBlock() == jointCollection.getBottomBlock())))) && ((jointCollection.getTopBlock().getPosition().x == jointCollection.position.x)))) && ((jointCollection.getTopBlock().getPosition().y == jointCollection.position.y)))){
jointType = jointCollection.getTopBlock().getJointType();
};
if ((((block as Wheel)) && (((!((block.getPosition().x == jointCollection.position.x))) || (!((block.getPosition().y == jointCollection.position.y))))))){
jointType = JointType.PIN;
};
if (((!((jointType == JointType.PIN))) && ((block as Wheel)))){
if (jointType == JointType.MOTOR_CLOCKWISE){
jointType = JointType.MOTOR_COUNTER_CLOCKWISE;
} else {
if (jointType == JointType.MOTOR_COUNTER_CLOCKWISE){
jointType = JointType.MOTOR_CLOCKWISE;
};
};
newJoint = new Joint(jointCollection.getTopBlock(), block, jointCollection.position, jointType);
jointCollection.append(newJoint);
} else {
newJoint = new Joint(jointCollection.getTopBlock(), block, jointCollection.position, jointType);
jointCollection.append(newJoint);
};
block.replaceJointCollection(block.getClosestJointCollection(jointCollection.position), jointCollection);
return (newJoint);
}
public function getClosestJointCollection(point:Point, joints:XML=null):JointCollection{
var block:Block;
var jointedToThis:Boolean;
var jointDistance:Number;
var i:int;
var closestJoint:JointCollection;
var closestJointDistance:Number = 10000000;
var blockIter:Iterator = getIterator();
while (blockIter.hasNext()) {
block = (blockIter.next() as Block);
jointDistance = block.getClosestJointDistance(point);
if (jointDistance < closestJointDistance){
if (joints != null){
jointedToThis = false;
i = 0;
while (i < joints.jointedTo.length()) {
if (joints.jointedTo[i] == block.saveIndex){
jointedToThis = true;
break;
};
i++;
};
} else {
jointedToThis = true;
};
if (jointedToThis){
closestJointDistance = jointDistance;
closestJoint = block.getClosestJointCollection(point);
};
};
};
return (closestJoint);
}
public function createWheel(point:Point, scale:Number, spinDirection:int, rotation:Number=0, radius:Number=NaN, editing:Boolean=false, isGoalBlock:Boolean=false, joints:XML=null):Wheel{
var closestJointDistance:Number;
var attach:Boolean;
var closestJoint:JointCollection;
closestJoint = getClosestJointCollection(point, joints);
if (closestJoint != null){
closestJointDistance = Point.distance(point, closestJoint.position);
};
if (((((!((closestJoint == null))) && (((closestJointDistance * scale) < 10)))) && (!(closestJoint.containsWheel())))){
attach = true;
};
if (attach){
point.x = closestJoint.position.x;
point.y = closestJoint.position.y;
};
var newWheel:Wheel = new Wheel(point, spinDirection, rotation, radius, editing, isGoalBlock);
if (attach){
joinToJointCollection(closestJoint, newWheel);
};
append(newWheel);
return (newWheel);
}
public function getClosestBlock(point:Point, includeGoalBlocks:Boolean=true):Block{
var block:Block;
var distance:Number;
var closestDistance:Number = 1000000;
var closestBlock:Block;
var blockIter:Iterator = getIterator();
while (blockIter.hasNext()) {
block = (blockIter.next() as Block);
distance = block.getDistance(point);
if ((((distance < closestDistance)) && (((includeGoalBlocks) || (!(block.isGoalBlock)))))){
closestDistance = distance;
closestBlock = block;
};
};
return (closestBlock);
}
public function createRod(point1:Point, point2:Point, scale:Number, newRod:Function, joints:XML=null, enforceMinWidth:Boolean=false):Rod{
var closestJointDistance1:Number;
var closestJointDistance2:Number;
var attach1:Boolean;
var attach2:Boolean;
var closestJoint1:JointCollection;
var closestJoint2:JointCollection;
var rotation:Number = Math.atan2((point2.y - point1.y), (point2.x - point1.x));
var width:Number = Point.distance(point1, point2);
if ((((width < 20)) && (enforceMinWidth))){
width = 20;
point2.x = (point1.x + (Math.cos(rotation) * width));
point2.y = (point1.y + (Math.sin(rotation) * width));
};
closestJoint1 = getClosestJointCollection(point1, joints);
closestJoint2 = getClosestJointCollection(point2, joints);
if (closestJoint1 != null){
closestJointDistance1 = Point.distance(point1, closestJoint1.position);
};
if (closestJoint2 != null){
closestJointDistance2 = Point.distance(point2, closestJoint2.position);
};
if (((!((closestJoint1 == null))) && (((closestJointDistance1 * scale) < 10)))){
attach1 = true;
};
if (((((!((closestJoint2 == null))) && (((closestJointDistance2 * scale) < 10)))) && (((!(attach1)) || (!((closestJoint2 == closestJoint1))))))){
attach2 = true;
};
if (((((attach1) && (attach2))) && (closestJoint2.sharesBlockWith(closestJoint1)))){
attach2 = false;
};
if (attach1){
point1.x = closestJoint1.position.x;
point1.y = closestJoint1.position.y;
};
if (attach2){
point2.x = closestJoint2.position.x;
point2.y = closestJoint2.position.y;
};
var rod:Rod = newRod(point1, point2);
if (attach1){
joinToJointCollection(closestJoint1, rod);
};
if (attach2){
joinToJointCollection(closestJoint2, rod);
};
append(rod);
return (rod);
}
protected function newSolidRod(point1:Point, point2:Point):Rod{
return (new SolidRod(point1, point2));
}
protected function newHollowRod(point1:Point, point2:Point):Rod{
return (new Rod(point1, point2));
}
public function createHollowRod(point1:Point, point2:Point, scale:Number, joints:XML=null, enforceMinWidth:Boolean=false):Rod{
return (createRod(point1, point2, scale, newHollowRod, joints, enforceMinWidth));
}
public function createPlayerBlockFromXml(blockXmlNode:XML, editing:Boolean):Block{
var block:Block;
var width:Number;
var rotation:Number;
var endPoint1:Point = new Point();
var endPoint2:Point = new Point();
var centerPoint:Point = new Point();
var isGoalBlock:Boolean;
centerPoint.x = new Number(blockXmlNode.position.x);
centerPoint.y = new Number(blockXmlNode.position.y);
rotation = new Number(blockXmlNode.rotation);
width = new Number(blockXmlNode.width);
isGoalBlock = false;
if (((!((blockXmlNode.goalBlock == null))) && ((blockXmlNode.goalBlock == "true")))){
isGoalBlock = true;
};
endPoint1.x = (centerPoint.x - ((Math.cos(rotation) * width) / 2));
endPoint1.y = (centerPoint.y - ((Math.sin(rotation) * width) / 2));
endPoint2.x = (centerPoint.x + ((Math.cos(rotation) * width) / 2));
endPoint2.y = (centerPoint.y + ((Math.sin(rotation) * width) / 2));
switch (blockXmlNode.localName()){
case "HollowRod":
block = createHollowRod(endPoint1, endPoint2, 1, blockXmlNode.joints[0]);
break;
case "SolidRod":
block = createSolidRod(endPoint1, endPoint2, 1, blockXmlNode.joints[0]);
break;
case "ClockwiseWheel":
block = createWheel(centerPoint, 1, Wheel.CLOCKWISE, rotation, (width / 2), editing, isGoalBlock, blockXmlNode.joints[0]);
break;
case "CounterClockwiseWheel":
block = createWheel(centerPoint, 1, Wheel.COUNTER_CLOCKWISE, rotation, (width / 2), editing, isGoalBlock, blockXmlNode.joints[0]);
break;
case "NoSpinWheel":
block = createWheel(centerPoint, 1, Wheel.NO_SPIN, rotation, (width / 2), editing, isGoalBlock, blockXmlNode.joints[0]);
break;
case "JointedDynamicRectangle":
block = new JointedDynamicRectangle(editing, isGoalBlock);
block.setFromXML(blockXmlNode);
append(block);
break;
default:
throw (new ArgumentError("xml contains an unrecognized player block type"));
};
block.saveIndex = blockXmlNode.@id;
return (block);
}
public function createSolidRod(point1:Point, point2:Point, scale:Number, joints:XML=null, enforceMinWidth:Boolean=false):Rod{
return (createRod(point1, point2, scale, newSolidRod, joints, enforceMinWidth));
}
public static function createLevelBlockFromXml(blockXmlNode:XML, physicsWorld:b2World, editing:Boolean):EditableBlock{
var block:EditableBlock;
switch (blockXmlNode.localName()){
case "DynamicRectangle":
block = new DynamicRectangle(editing);
break;
case "DynamicCircle":
block = new DynamicCircle(editing);
break;
case "StaticRectangle":
block = new StaticRectangle(editing);
break;
case "StaticCircle":
block = new StaticCircle(editing);
break;
default:
throw (new ArgumentError("xml contains an unrecognized level block type"));
};
block.setFromXML(blockXmlNode);
return (block);
}
}
}//package contraption.blocks
Section 85
//BlockType (contraption.blocks.BlockType)
package contraption.blocks {
public class BlockType {
public static const STATIC_CIRCLE:BlockType = new (BlockType);
;
public static const WHEEL_NO_SPIN:BlockType = new (BlockType);
;
public static const ROD_HOLLOW:BlockType = new (BlockType);
;
public static const WHEEL_COUNTER_CLOCKWISE:BlockType = new (BlockType);
;
public static const WHEEL_CLOCKWISE:BlockType = new (BlockType);
;
public static const DYNAMIC_RECTANGLE:BlockType = new (BlockType);
;
public static const DYNAMIC_CIRCLE:BlockType = new (BlockType);
;
public static const ROD_SOLID:BlockType = new (BlockType);
;
public static const STATIC_RECTANGLE:BlockType = new (BlockType);
;
public function BlockType(){
super();
}
}
}//package contraption.blocks
Section 86
//DeleteBlockEvent (contraption.blocks.DeleteBlockEvent)
package contraption.blocks {
import flash.events.*;
public class DeleteBlockEvent extends Event {
public var block:EditableBlock;
public static const DELETE_BLOCK:String = "deleteBlock";
public function DeleteBlockEvent(block:EditableBlock){
super(DELETE_BLOCK);
this.block = block;
}
override public function clone():Event{
return (new DeleteBlockEvent(block));
}
}
}//package contraption.blocks
Section 87
//DynamicCircle (contraption.blocks.DynamicCircle)
package contraption.blocks {
import flash.display.*;
import flash.geom.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class DynamicCircle extends EditableBlock {
public function DynamicCircle(editing:Boolean, position:Point=null){
super(editing, false, position);
generatePhysicsBodyDef();
}
override protected function generatePhysicsBodyDef():b2BodyDef{
var bodyDef:b2BodyDef;
var circleDef:b2CircleDef;
var body:b2Body;
bodyDef = new b2BodyDef();
circleDef = new b2CircleDef();
circleDef.radius = getWidth();
circleDef.density = 1;
circleDef.friction = 0.7;
circleDef.restitution = 0.2;
circleDef.categoryBits = ~(0);
circleDef.maskBits = ~(0);
bodyDef.AddShape(circleDef);
bodyDef.position.x = getPosition().x;
bodyDef.position.y = getPosition().y;
bodyDef.userData = this;
return (bodyDef);
}
override protected function drawBlock(canvas:Sprite, backgroundCanvas:Sprite):void{
canvas.graphics.beginFill(16353583);
canvas.graphics.drawCircle(0, 0, (getWidth() - 4));
canvas.graphics.endFill();
backgroundCanvas.graphics.lineStyle(6, 12998156, 100);
backgroundCanvas.graphics.drawCircle(0, 0, (getWidth() - 3));
}
override protected function getXmlRoot():XML{
return (<DynamicCircle/>
);
}
override public function getHeight():Number{
return (getWidth());
}
}
}//package contraption.blocks
Section 88
//DynamicRectangle (contraption.blocks.DynamicRectangle)
package contraption.blocks {
import flash.display.*;
import flash.geom.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class DynamicRectangle extends UnstretchableBlock {
public function DynamicRectangle(editing:Boolean, isGoalBlock:Boolean=false, position:Point=null){
super(editing, isGoalBlock, position);
generatePhysicsBodyDef();
}
override protected function generatePhysicsBodyDef():b2BodyDef{
var boxDef:b2BoxDef;
var bodyDef:b2BodyDef;
var body:b2Body;
boxDef = new b2BoxDef();
bodyDef = new b2BodyDef();
boxDef.extents.Set((getWidth() / 2), (getHeight() / 2));
boxDef.density = 1;
boxDef.friction = 0.7;
boxDef.restitution = 0.2;
boxDef.categoryBits = getCategoryBits();
boxDef.maskBits = getMaskBits();
boxDef.userData = this;
bodyDef.AddShape(boxDef);
bodyDef.userData = this;
bodyDef.position.x = getPosition().x;
bodyDef.position.y = getPosition().y;
bodyDef.rotation = getRotation();
return (bodyDef);
}
protected function getCategoryBits():int{
return (~(0));
}
override protected function getXmlRoot():XML{
return (<DynamicRectangle/>
);
}
protected function getMaskBits():int{
return (~(0));
}
override protected function drawBlock(canvas:Sprite, backgroundCanvas:Sprite):void{
canvas.graphics.beginFill(16374319);
if (isGoalBlock){
canvas.graphics.beginFill(16737894);
};
canvas.graphics.drawRect(((-(getWidth()) / 2) + 4), ((-(getHeight()) / 2) + 4), (getWidth() - 8), (getHeight() - 8));
canvas.graphics.endFill();
backgroundCanvas.graphics.lineStyle(6, 12998156, 100);
backgroundCanvas.graphics.drawRect(((-(getWidth()) / 2) + 3), ((-(getHeight()) / 2) + 3), (getWidth() - 6), (getHeight() - 6));
}
override public function getDistance(point:Point):Number{
return (Point.distance(getPosition(), point));
}
}
}//package contraption.blocks
Section 89
//EditableBlock (contraption.blocks.EditableBlock)
package contraption.blocks {
import flash.events.*;
import contraption.*;
import flash.display.*;
import flash.geom.*;
public class EditableBlock extends Block {
protected var my0:Number;
protected var moving:Boolean;// = false
protected var rotateCorner:MovieClip;
protected var rotating:Boolean;// = false
protected var editing:Boolean;
protected var deleteCorner:MovieClip;
protected var mx0:Number;
protected var resizing:Boolean;// = false
protected var resizeCorner:MovieClip;
public static var MIN_BLOCK_WIDTH:Number = 12;
public function EditableBlock(editing:Boolean, isGoalBlock:Boolean=false, position:Point=null){
super(isGoalBlock);
if (position != null){
setPosition(position);
};
this.editing = editing;
if (editing){
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownM);
};
setBlockCanvas();
}
override protected function setBlockCanvas():void{
super.setBlockCanvas();
if (editing){
resizeCorner = newResizeCorner();
blockForegroundCanvas.addChild(resizeCorner);
resizeCorner.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownR);
resizeCorner.x = (getWidth() / 2);
resizeCorner.y = (getHeight() / 2);
rotateCorner = newRotateCorner();
blockForegroundCanvas.addChild(rotateCorner);
rotateCorner.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownO);
rotateCorner.x = (getWidth() / 2);
rotateCorner.y = (-(getHeight()) / 2);
deleteCorner = newDeleteCorner();
blockForegroundCanvas.addChild(deleteCorner);
deleteCorner.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownD);
deleteCorner.x = (-(getWidth()) / 2);
deleteCorner.y = (getHeight() / 2);
};
}
protected function mouseDownM(event:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveM, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpM, false, 0, true);
event.stopPropagation();
mx0 = (parent.mouseX - getPosition().x);
my0 = (parent.mouseY - getPosition().y);
moving = true;
this.dispatchEvent(new BeginEditingEvent(this));
}
protected function mouseDownO(event:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveO, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpO, false, 0, true);
event.stopPropagation();
rotating = true;
this.dispatchEvent(new BeginEditingEvent(this));
var modeEvent:ModeEvent = new ModeEvent(ModeEvent.START_ACTION, true, true);
modeEvent.actionType = ModeEvent.ACTION_BUTTON;
dispatchEvent(modeEvent);
}
protected function mouseDownR(event:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveR, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpR, false, 0, true);
event.stopPropagation();
resizing = true;
this.dispatchEvent(new BeginEditingEvent(this));
var modeEvent:ModeEvent = new ModeEvent(ModeEvent.START_ACTION, true, true);
modeEvent.actionType = ModeEvent.ACTION_BUTTON;
dispatchEvent(modeEvent);
}
override protected function initAllowableActions():void{
allowableActions = new Actions();
if (editing){
allowableActions.move = true;
} else {
allowableActions.alwaysDrag = true;
};
}
protected function newRotateCorner():MovieClip{
var rotateCorner:MovieClip = newCornerButton();
rotateCorner.graphics.lineStyle(2, 0xFFFF);
rotateCorner.graphics.beginFill(0xFFFF, 0.5);
rotateCorner.graphics.drawRect(-6, -6, 12, 12);
return (rotateCorner);
}
protected function newDeleteCorner():MovieClip{
var deleteCorner:MovieClip = newCornerButton();
deleteCorner.graphics.lineStyle(2, 16733525);
deleteCorner.graphics.beginFill(0xFFFF, 0.5);
deleteCorner.graphics.drawRect(-6, -6, 12, 12);
return (deleteCorner);
}
protected function newResizeCorner():MovieClip{
var resizeCorner:MovieClip = newCornerButton();
resizeCorner.graphics.lineStyle(2, 0xFFFF00);
resizeCorner.graphics.beginFill(0xFFFF, 0.5);
resizeCorner.graphics.drawRect(-6, -6, 12, 12);
return (resizeCorner);
}
protected function mouseUpM(event:MouseEvent):void{
moving = false;
}
protected function newCornerButton():ActionContainerImpl{
var cornerButton:ActionContainerImpl = new ActionContainerImpl();
var actions:Actions = new Actions();
actions.button = true;
cornerButton.setAllowableActions(actions);
return (cornerButton);
}
protected function mouseUpR(event:MouseEvent):void{
resizing = false;
}
protected function mouseUpO(event:MouseEvent):void{
rotating = false;
}
protected function mouseMoveO(event:MouseEvent):void{
if (!rotating){
return;
};
var cornerAngle:Number = Math.atan2((-1 * getHeight()), getWidth());
setRotation((Math.atan2((parent.mouseY - this.y), (parent.mouseX - this.x)) - cornerAngle));
}
protected function mouseMoveR(event:MouseEvent):void{
if (!resizing){
return;
};
var newWidth:Number = (blockForeground.mouseX * 2);
var newHeight:Number = (blockForeground.mouseY * 2);
if (newWidth < MIN_BLOCK_WIDTH){
newWidth = MIN_BLOCK_WIDTH;
};
if (newHeight < MIN_BLOCK_WIDTH){
newHeight = MIN_BLOCK_WIDTH;
};
setWidth(newWidth);
setHeight(newHeight);
setBlockCanvas();
}
protected function mouseDownD(event:MouseEvent):void{
event.stopPropagation();
this.dispatchEvent(new DeleteBlockEvent(this));
}
protected function mouseMoveM(event:MouseEvent):void{
if (!moving){
return;
};
setPosition(new Point((parent.mouseX - mx0), (parent.mouseY - my0)));
}
}
}//package contraption.blocks
Section 90
//Joint (contraption.blocks.Joint)
package contraption.blocks {
import flash.geom.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
public class Joint {
protected var physicsJoint:b2Joint;// = null
public var jointType:JointType;
public var block2:Block;
public var position:Point;
public var block1:Block;
public function Joint(block1:Block, block2:Block, position:Point, jointType:JointType){
super();
this.block1 = block1;
this.block2 = block2;
this.position = position;
this.jointType = jointType;
}
public function connectsWheelMiddle():Boolean{
if ((((((block1 as Wheel)) && ((block1.getPosition().x == position.x)))) && ((block1.getPosition().y == position.y)))){
return (true);
};
if ((((((block2 as Wheel)) && ((block2.getPosition().x == position.x)))) && ((block2.getPosition().y == position.y)))){
return (true);
};
return (false);
}
protected function generatePhysicsJointDef():b2JointDef{
var jointDef:b2RevoluteJointDef = new b2RevoluteJointDef();
jointDef.body1 = block1.getPhysicsBody();
jointDef.body2 = block2.getPhysicsBody();
jointDef.anchorPoint.Set(position.x, position.y);
jointDef.collideConnected = true;
if (jointType == JointType.MOTOR_CLOCKWISE){
jointDef.motorTorque = 50000000;
jointDef.motorSpeed = -5;
jointDef.enableMotor = true;
};
if (jointType == JointType.MOTOR_COUNTER_CLOCKWISE){
jointDef.motorTorque = 50000000;
jointDef.motorSpeed = 5;
jointDef.enableMotor = true;
};
if (jointType == JointType.WELD){
jointDef.motorTorque = 50000000;
jointDef.motorSpeed = 0;
jointDef.enableMotor = true;
};
return (jointDef);
}
public function generatePhysicsJoint(physicsWorld:b2World):b2Joint{
if (physicsJoint == null){
physicsJoint = physicsWorld.CreateJoint(generatePhysicsJointDef());
};
return (physicsJoint);
}
public function setPosition(value:Point):void{
position = value;
}
public function destroyPhysicsJoint(physicsWorld:b2World):void{
if (physicsJoint != null){
physicsWorld.DestroyJoint(physicsJoint);
physicsJoint = null;
};
}
public function getPosition():Point{
return (position);
}
}
}//package contraption.blocks
Section 91
//JointCollection (contraption.blocks.JointCollection)
package contraption.blocks {
import flash.geom.*;
import de.polygonal.ds.*;
import Box2D.Dynamics.*;
import flash.utils.*;
public class JointCollection extends SLinkedList {
protected var collisionMaskBitIndex:int;// = 0
public var position:Point;
protected var collisionMaskBit:int;// = 1
protected var hasMoved:Boolean;// = false
protected var firstBlock:Block;
public function JointCollection(firstBlock:Block, position:Point){
super();
this.firstBlock = firstBlock;
this.position = position;
}
public function moveJoint(movementVector:Point):void{
var joint:Joint;
if (hasMoved){
return;
};
hasMoved = true;
getTopBlock().moveWithJoint(this, movementVector);
var jointIter:Iterator = getIterator();
while (jointIter.hasNext()) {
joint = (jointIter.next() as Joint);
joint.block1.moveWithJoint(this, movementVector);
};
setPosition(getPosition().add(movementVector));
hasMoved = false;
}
public function isJointedTo(block:Block):Boolean{
var joint:Joint;
if (block == getTopBlock()){
return (true);
};
var jointIter:Iterator = getIterator();
while (jointIter.hasNext()) {
joint = (jointIter.next() as Joint);
if (joint.block1 == block){
return (true);
};
if (joint.block2 == block){
return (true);
};
};
return (false);
}
public function setPosition(value:Point):void{
position = value;
var jointIter:Iterator = getIterator();
while (jointIter.hasNext()) {
(jointIter.next() as Joint).setPosition(position);
};
}
public function getBottomBlock():Block{
if (isEmpty()){
return (firstBlock);
};
return ((head.data.block1 as Block));
}
public function startJoints(physicsWorld:b2World):void{
var joint:Joint;
var hasWheel:Boolean;
var jointIter:Iterator = getIterator();
while (jointIter.hasNext()) {
joint = (jointIter.next() as Joint);
if ((((joint.block2 as Wheel)) && (!((joint.jointType == JointType.PIN))))){
hasWheel = true;
};
};
jointIter = getIterator();
while (jointIter.hasNext()) {
joint = (jointIter.next() as Joint);
joint.generatePhysicsJoint(physicsWorld);
};
}
public function getTopBlock():Block{
if (isEmpty()){
return (firstBlock);
};
return ((tail.data.block2 as Block));
}
public function getBlockJointedBeneath(block:Block):Block{
var joint:Joint;
var jointIter:Iterator = getIterator();
while (jointIter.hasNext()) {
joint = (jointIter.next() as Joint);
if (joint.block2 == block){
return (joint.block1);
};
};
return (null);
}
public function containsWheel():Boolean{
var joint:Joint;
var jointIter:Iterator = getIterator();
if ((getTopBlock() as Wheel)){
return (true);
};
while (jointIter.hasNext()) {
joint = (jointIter.next() as Joint);
if ((joint.block1 as Wheel)){
return (true);
};
};
return (false);
}
public function addJointedBlocks(jointedBlocks:Dictionary):void{
var joint:Joint;
var jointIter:Iterator = getIterator();
while (jointIter.hasNext()) {
joint = (jointIter.next() as Joint);
jointedBlocks[joint.block1] = joint.block1;
jointedBlocks[joint.block2] = joint.block2;
};
}
public function sharesBlockWith(otherJoints:JointCollection):Boolean{
var joint:Joint;
if (otherJoints.isJointedTo(getTopBlock())){
return (true);
};
var jointIter:Iterator = getIterator();
while (jointIter.hasNext()) {
joint = (jointIter.next() as Joint);
if (otherJoints.isJointedTo(joint.block1)){
return (true);
};
if (otherJoints.isJointedTo(joint.block2)){
return (true);
};
};
return (false);
}
public function unjointBlock(block:Block):void{
var joint:Joint;
var usedJoint1:Joint;
var usedJoint2:Joint;
var jointIter:Iterator = getIterator();
while (jointIter.hasNext()) {
joint = (jointIter.next() as Joint);
if (joint.block1 == block){
usedJoint1 = joint;
};
if (joint.block2 == block){
usedJoint2 = joint;
};
};
if ((((usedJoint1 == null)) && ((usedJoint2 == null)))){
return;
};
if (((!((usedJoint1 == null))) && ((usedJoint2 == null)))){
firstBlock = usedJoint1.block2;
remove(nodeOf(usedJoint1));
if ((((((usedJoint1.jointType == JointType.MOTOR_CLOCKWISE)) && ((usedJoint1.block2 as Wheel)))) && (!((tail == null))))){
(tail.data as Joint).jointType = JointType.MOTOR_COUNTER_CLOCKWISE;
} else {
if ((((((usedJoint1.jointType == JointType.MOTOR_COUNTER_CLOCKWISE)) && ((usedJoint1.block2 as Wheel)))) && (!((tail == null))))){
(tail.data as Joint).jointType = JointType.MOTOR_CLOCKWISE;
};
};
return;
};
if (((!((usedJoint2 == null))) && ((usedJoint1 == null)))){
firstBlock = usedJoint2.block1;
remove(nodeOf(usedJoint2));
return;
};
usedJoint2.block2 = usedJoint1.block2;
remove(nodeOf(usedJoint1));
if ((block as Wheel)){
usedJoint2.jointType = JointType.PIN;
} else {
if (usedJoint1.jointType != JointType.PIN){
usedJoint2.jointType = usedJoint1.jointType;
};
};
}
public function getPosition():Point{
return (position);
}
}
}//package contraption.blocks
Section 92
//JointedDynamicRectangle (contraption.blocks.JointedDynamicRectangle)
package contraption.blocks {
import contraption.*;
import flash.display.*;
import flash.geom.*;
public class JointedDynamicRectangle extends DynamicRectangle {
public function JointedDynamicRectangle(editing:Boolean, isGoalBlock:Boolean=false, position:Point=null){
super(editing, isGoalBlock, position);
}
override protected function initAllowableActions():void{
if (editing){
return (super.initAllowableActions());
};
allowableActions = new Actions();
allowableActions.move = true;
allowableActions.build = true;
}
override public function getDistance(pointy:Point):Number{
var position:Point = getPosition();
var width:Number = getWidth();
var height:Number = getHeight();
var point:Point = parent.localToGlobal(pointy);
point = globalToLocal(point);
var centreDistance:Number = Point.distance(position, point);
if ((((((((point.x > (-(width) / 2))) && ((point.x < (width / 2))))) && ((point.y > (-(height) / 2))))) && ((point.y < (height / 2))))){
if (centreDistance > 7){
return (7);
};
};
return (centreDistance);
}
override public function collidesWithJointedBlocks():Boolean{
return (false);
}
override protected function getXmlRoot():XML{
return (<JointedDynamicRectangle/>
);
}
override protected function getMaskBits():int{
return (~(16));
}
override protected function drawBlock(canvas:Sprite, backgroundCanvas:Sprite):void{
var anchorPoint:Point;
super.drawBlock(canvas, backgroundCanvas);
drawAnchor(new Point(0, 0));
drawAnchor(new Point((getWidth() / 2), (getHeight() / 2)));
drawAnchor(new Point((-(getWidth()) / 2), (getHeight() / 2)));
drawAnchor(new Point((getWidth() / 2), (-(getHeight()) / 2)));
drawAnchor(new Point((-(getWidth()) / 2), (-(getHeight()) / 2)));
}
override protected function getCategoryBits():int{
return (1);
}
override public function setFromXML(xml:XML):void{
var anchorPoint:Point;
super.setFromXML(xml);
var position:Point = getPosition();
var width:Number = getWidth();
var height:Number = getHeight();
var rotation:Number = getRotation();
var widthJointOffset:Point = new Point();
var heightJointOffset:Point = new Point();
widthJointOffset.x = ((Math.cos(rotation) * width) / 2);
widthJointOffset.y = ((Math.sin(rotation) * width) / 2);
heightJointOffset.x = ((Math.sin(rotation) * height) / 2);
heightJointOffset.y = ((-(Math.cos(rotation)) * height) / 2);
anchorPoint = new Point(position.x, position.y);
addJoint(new JointCollection(this, anchorPoint));
anchorPoint = position.add(widthJointOffset).add(heightJointOffset);
addJoint(new JointCollection(this, anchorPoint));
anchorPoint = position.subtract(widthJointOffset).add(heightJointOffset);
addJoint(new JointCollection(this, anchorPoint));
anchorPoint = position.add(widthJointOffset).subtract(heightJointOffset);
addJoint(new JointCollection(this, anchorPoint));
anchorPoint = position.subtract(widthJointOffset).subtract(heightJointOffset);
addJoint(new JointCollection(this, anchorPoint));
}
}
}//package contraption.blocks
Section 93
//JointType (contraption.blocks.JointType)
package contraption.blocks {
public class JointType {
public static const MOTOR_COUNTER_CLOCKWISE:JointType = new (JointType);
;
public static const PIN:JointType = new (JointType);
;
public static const WELD:JointType = new (JointType);
;
public static const MOTOR_CLOCKWISE:JointType = new (JointType);
;
public function JointType(){
super();
}
}
}//package contraption.blocks
Section 94
//Rod (contraption.blocks.Rod)
package contraption.blocks {
import contraption.*;
import flash.display.*;
import flash.geom.*;
import de.polygonal.ds.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class Rod extends Block {
protected var rodCanvas:Sprite;
public var point1:Point;
public var point2:Point;
public function Rod(point1:Point, point2:Point){
super();
this.point1 = point1;
this.point2 = point2;
setPositionFromPoints();
this.point1 = new Point();
this.point2 = new Point();
var rotation:Number = getRotation();
var centerPoint:Point = getPosition();
var width:Number = getWidth();
this.point1.x = (centerPoint.x - ((Math.cos(rotation) * width) / 2));
this.point1.y = (centerPoint.y - ((Math.sin(rotation) * width) / 2));
this.point2.x = (centerPoint.x + ((Math.cos(rotation) * width) / 2));
this.point2.y = (centerPoint.y + ((Math.sin(rotation) * width) / 2));
addJoint(new JointCollection(this, point1));
addJoint(new JointCollection(this, point2));
setBlockCanvas();
}
override public function setRotation(value:Number):void{
super.setRotation(value);
setPointsFromPosition();
}
protected function setPositionFromPointsy():void{
super.setRotation(Math.atan2((point2.y - point1.y), (point2.x - point1.x)));
super.setWidth(Point.distance(point1, point2));
super.setHeight(getHeight());
super.setPosition(new Point((point1.x + ((point2.x - point1.x) / 2)), (point1.y + ((point2.y - point1.y) / 2))));
}
public function getMaskBits():int{
return (~(17));
}
override public function setWidth(value:Number):void{
super.setWidth(value);
setPointsFromPosition();
}
public function doesJoinWheelMiddles():Boolean{
var jointIter:Iterator;
var jointCollection:JointCollection;
var containsWheelMiddle:Boolean;
var joint:Joint;
var jointCollectionIter:Iterator = joints.getIterator();
while (jointCollectionIter.hasNext()) {
jointCollection = (jointCollectionIter.next() as JointCollection);
jointIter = jointCollection.getIterator();
containsWheelMiddle = false;
while (jointIter.hasNext()) {
joint = (jointIter.next() as Joint);
if (joint.connectsWheelMiddle()){
containsWheelMiddle = true;
};
};
if (!containsWheelMiddle){
return (false);
};
};
return (true);
}
override protected function generatePhysicsBodyDef():b2BodyDef{
var body:b2Body;
var boxDef:b2BoxDef = new b2BoxDef();
var bodyDef:b2BodyDef = new b2BodyDef();
boxDef.extents.Set((getWidth() / 2), (getHeight() / 2));
boxDef.density = 1;
boxDef.friction = 0.7;
boxDef.restitution = 0.2;
boxDef.categoryBits = getCategoryBits();
boxDef.maskBits = getMaskBits();
boxDef.userData = this;
bodyDef.AddShape(boxDef);
bodyDef.userData = this;
bodyDef.position.x = getPosition().x;
bodyDef.position.y = getPosition().y;
bodyDef.rotation = getRotation();
bodyDef.linearDamping = 0.009;
bodyDef.angularDamping = 0.2;
return (bodyDef);
}
override public function moveWithJoint(joint:JointCollection, movementVector:Point):void{
if (Point.distance(joint.getPosition(), point1) < Point.distance(joint.getPosition(), point2)){
point1 = point1.add(movementVector);
} else {
point2 = point2.add(movementVector);
};
setPositionFromPointsy();
setBlockCanvas();
}
protected function getSimpleColour():int{
return (0xFF);
}
protected function drawSimpleBlock(canvas:Sprite, backgroundCanvas:Sprite):void{
var width:Number = (getWidth() - 4);
var height:Number = 8;
canvas.graphics.beginFill(getSimpleColour());
canvas.graphics.drawRect((((-1 * width) / 2) + 2), ((-(height) / 2) + 2), (width - 4), (height - 4));
canvas.graphics.endFill();
backgroundCanvas.graphics.lineStyle(4, getSimpleBackgroundColour());
backgroundCanvas.graphics.drawRect((((-1 * width) / 2) + 1), ((-(height) / 2) + 1), (width - 2), (height - 2));
drawAnchor(new Point(((-1 * getWidth()) / 2), 0));
drawAnchor(new Point((getWidth() / 2), 0));
}
public function getCategoryBits():int{
return (16);
}
override public function getHeight():Number{
return (4);
}
override protected function getXmlRoot():XML{
return (<HollowRod/>
);
}
protected function getTile():Sprite{
return (new HollowRodGraphic());
}
protected function drawFancyBlock(canvas:Sprite, backgroundCanvas:Sprite):void{
var width:Number;
var rodTile:Sprite;
width = (getWidth() - 4);
var height:Number = getHeight();
canvas.graphics.beginFill(0xFFFFFF, 0);
canvas.graphics.drawRect(((-(width) / 2) - 7), (-10 / 2), (width + 14), 10);
var rodTileWidth = 100;
var numTiles:int = Math.ceil((width / rodTileWidth));
rodCanvas = new Sprite();
canvas.addChild(rodCanvas);
var i:int;
while (i < numTiles) {
rodTile = getTile();
rodTile.x = ((-(width) / 2) + (i * rodTileWidth));
rodCanvas.addChild(rodTile);
rodTile = getTileBackground();
rodTile.x = ((-(width) / 2) + (i * rodTileWidth));
backgroundCanvas.addChild(rodTile);
i++;
};
var mask:Sprite = new Sprite();
mask.graphics.beginFill(0xFF0000);
mask.graphics.drawRect(((-1 * width) / 2), -25, width, 50);
rodCanvas.addChild(mask);
rodCanvas.mask = mask;
mask = new Sprite();
mask.graphics.beginFill(0xFF0000);
mask.graphics.drawRect(((-1 * width) / 2), -25, width, 50);
backgroundCanvas.addChild(mask);
backgroundCanvas.mask = mask;
var jointCanvas:Sprite = new Sprite();
canvas.addChild(jointCanvas);
drawAnchor(new Point(((-1 * getWidth()) / 2), 0), jointCanvas);
drawAnchor(new Point((getWidth() / 2), 0), jointCanvas);
}
protected function getSimpleBackgroundColour():int{
return (0xFFFFFF);
}
override public function setPosition(value:Point):void{
super.setPosition(value);
setPointsFromPosition();
}
override protected function drawBlock(canvas:Sprite, backgroundCanvas:Sprite):void{
if (Configuration.getInstance().isInSimpleGraphicsMode()){
drawSimpleBlock(canvas, backgroundCanvas);
} else {
drawFancyBlock(canvas, backgroundCanvas);
};
}
protected function getTileBackground():Sprite{
return (new HollowRodGraphicBG());
}
override public function collidesWithJointedBlocks():Boolean{
return (false);
}
protected function setPointsFromPosition():void{
if (getPosition() == null){
return;
};
if (point1 == null){
point1 = new Point();
};
if (point2 == null){
point2 = new Point();
};
var width:Number = getWidth();
point1.x = (getPosition().x - ((Math.cos(getRotation()) * width) / 2));
point1.y = (getPosition().y - ((Math.sin(getRotation()) * width) / 2));
point2.x = (getPosition().x + ((Math.cos(getRotation()) * width) / 2));
point2.y = (getPosition().y + ((Math.sin(getRotation()) * width) / 2));
}
override public function getDistance(fromPoint:Point):Number{
var distanceSegment:Number;
var dist1:Number;
var dist2:Number;
var r_numerator:Number = (((fromPoint.x - point1.x) * (point2.x - point1.x)) + ((fromPoint.y - point1.y) * (point2.y - point1.y)));
var r_denomenator:Number = (((point2.x - point1.x) * (point2.x - point1.x)) + ((point2.y - point1.y) * (point2.y - point1.y)));
var r:Number = (r_numerator / r_denomenator);
var px:Number = (point1.x + (r * (point2.x - point1.x)));
var py:Number = (point1.y + (r * (point2.y - point1.y)));
var s:Number = ((((point1.y - fromPoint.y) * (point2.x - point1.x)) - ((point1.x - fromPoint.x) * (point2.y - point1.y))) / r_denomenator);
var distanceLine:Number = (Math.abs(s) * Math.sqrt(r_denomenator));
var xx:Number = px;
var yy:Number = py;
if ((((r >= 0)) && ((r <= 1)))){
distanceSegment = distanceLine;
} else {
dist1 = (((fromPoint.x - point1.x) * (fromPoint.x - point1.x)) + ((fromPoint.y - point1.y) * (fromPoint.y - point1.y)));
dist2 = (((fromPoint.x - point2.x) * (fromPoint.x - point2.x)) + ((fromPoint.y - point2.y) * (fromPoint.y - point2.y)));
if (dist1 < dist2){
xx = point1.x;
yy = point1.y;
distanceSegment = Math.sqrt(dist1);
} else {
xx = point2.x;
yy = point2.y;
distanceSegment = Math.sqrt(dist2);
};
};
return (distanceSegment);
}
protected function setPositionFromPoints():void{
super.setRotation(Math.atan2((point2.y - point1.y), (point2.x - point1.x)));
super.setWidth(Point.distance(point1, point2));
super.setHeight(getHeight());
super.setPosition(new Point((point1.x + ((point2.x - point1.x) / 2)), (point1.y + ((point2.y - point1.y) / 2))));
}
}
}//package contraption.blocks
Section 95
//SolidRod (contraption.blocks.SolidRod)
package contraption.blocks {
import flash.display.*;
import flash.geom.*;
public class SolidRod extends Rod {
public function SolidRod(point1:Point, point2:Point){
super(point1, point2);
}
override protected function getSimpleBackgroundColour():int{
return (0xB55900);
}
override protected function getTile():Sprite{
return (new SolidRodGraphic());
}
override protected function getXmlRoot():XML{
return (<SolidRod/>
);
}
override public function getMaskBits():int{
return (~(16));
}
override protected function getTileBackground():Sprite{
return (new SolidRodGraphicBG());
}
override public function getCategoryBits():int{
return (0x0100);
}
override protected function getSimpleColour():int{
return (0x6B3400);
}
override public function getHeight():Number{
return (8);
}
}
}//package contraption.blocks
Section 96
//StaticCircle (contraption.blocks.StaticCircle)
package contraption.blocks {
import flash.display.*;
import flash.geom.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class StaticCircle extends EditableBlock {
public function StaticCircle(editing:Boolean, position:Point=null){
super(editing, false, position);
generatePhysicsBodyDef();
}
override protected function generatePhysicsBodyDef():b2BodyDef{
var bodyDef:b2BodyDef;
var circleDef:b2CircleDef;
var body:b2Body;
bodyDef = new b2BodyDef();
circleDef = new b2CircleDef();
circleDef.radius = getWidth();
circleDef.friction = 0.7;
circleDef.categoryBits = ~(0);
circleDef.maskBits = ~(0);
bodyDef.AddShape(circleDef);
bodyDef.position.x = getPosition().x;
bodyDef.position.y = getPosition().y;
bodyDef.userData = this;
return (bodyDef);
}
override protected function drawBlock(canvas:Sprite, backgroundCanvas:Sprite):void{
canvas.graphics.beginFill(48641);
canvas.graphics.drawCircle(0, 0, (getWidth() - 4));
canvas.graphics.endFill();
backgroundCanvas.graphics.lineStyle(6, 32777, 100);
backgroundCanvas.graphics.drawCircle(0, 0, (getWidth() - 3));
}
override protected function getXmlRoot():XML{
return (<StaticCircle/>
);
}
override public function getHeight():Number{
return (getWidth());
}
}
}//package contraption.blocks
Section 97
//StaticRectangle (contraption.blocks.StaticRectangle)
package contraption.blocks {
import flash.display.*;
import flash.geom.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class StaticRectangle extends EditableBlock {
public function StaticRectangle(editing:Boolean, position:Point=null){
super(editing, false, position);
generatePhysicsBodyDef();
}
override protected function generatePhysicsBodyDef():b2BodyDef{
var bodyDef:b2BodyDef;
var body:b2Body;
var boxDef:b2BoxDef = new b2BoxDef();
bodyDef = new b2BodyDef();
boxDef.extents.Set((getWidth() / 2), (getHeight() / 2));
boxDef.friction = 0.7;
boxDef.categoryBits = ~(0);
boxDef.maskBits = ~(0);
bodyDef.AddShape(boxDef);
bodyDef.userData = this;
bodyDef.position.x = getPosition().x;
bodyDef.position.y = getPosition().y;
bodyDef.rotation = getRotation();
return (bodyDef);
}
override protected function drawBlock(canvas:Sprite, backgroundCanvas:Sprite):void{
canvas.graphics.beginFill(48641);
canvas.graphics.drawRect(((-(getWidth()) / 2) + 4), ((-(getHeight()) / 2) + 4), (getWidth() - 8), (getHeight() - 8));
canvas.graphics.endFill();
backgroundCanvas.graphics.lineStyle(6, 32777, 100);
backgroundCanvas.graphics.drawRect(((-(getWidth()) / 2) + 3), ((-(getHeight()) / 2) + 3), (getWidth() - 5), (getHeight() - 5));
}
override protected function getXmlRoot():XML{
return (<StaticRectangle/>
);
}
}
}//package contraption.blocks
Section 98
//UnstretchableBlock (contraption.blocks.UnstretchableBlock)
package contraption.blocks {
import flash.geom.*;
import de.polygonal.ds.*;
public class UnstretchableBlock extends EditableBlock {
protected var hasMoved:Boolean;// = false
public function UnstretchableBlock(editing:Boolean, isGoalBlock:Boolean=false, position:Point=null){
super(editing, isGoalBlock, position);
}
override public function moveWithJoint(joint:JointCollection, movementVector:Point):void{
var jointCollection:JointCollection;
if (hasMoved){
return;
};
hasMoved = true;
super.moveWithJoint(joint, movementVector);
var jointCollectionIter:SListIterator = joints.getListIterator();
while (jointCollectionIter.hasNext()) {
jointCollection = (jointCollectionIter.next() as JointCollection);
jointCollection.moveJoint(movementVector);
};
hasMoved = false;
}
}
}//package contraption.blocks
Section 99
//Wheel (contraption.blocks.Wheel)
package contraption.blocks {
import contraption.*;
import flash.display.*;
import flash.geom.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class Wheel extends UnstretchableBlock {
public var spinDirection:int;
public var radius:Number;// = 20
public static const DEFAULT_RADIUS:int = 20;
public static const CLOCKWISE:int = 0;
public static const NO_SPIN:int = 1;
public static const COUNTER_CLOCKWISE:int = -1;
public function Wheel(position:Point, spinDirection:int, rotation:Number=0, radius:Number=NaN, editing:Boolean=false, isGoalBlock:Boolean=false){
super(editing, isGoalBlock);
if (!isNaN(radius)){
setRadius(radius);
} else {
radius = getRadius();
};
setRotation(rotation);
setPosition(position);
this.spinDirection = spinDirection;
addJoint(new JointCollection(this, new Point(position.x, position.y)));
addJoint(new JointCollection(this, getAnchorPoint(0)));
addJoint(new JointCollection(this, getAnchorPoint((Math.PI / 2))));
addJoint(new JointCollection(this, getAnchorPoint(Math.PI)));
addJoint(new JointCollection(this, getAnchorPoint(((Math.PI / 2) * 3))));
setBlockCanvas();
}
override public function getDistance(point:Point):Number{
var distance:Number = Point.distance(getPosition(), point);
if (distance < getRadius()){
if (distance > 7){
distance = 7;
} else {
distance = (distance - getRadius());
};
};
return (distance);
}
override public function setWidth(value:Number):void{
radius = (value / 2);
}
protected function getAnchorPoint(anchorAngle:Number):Point{
return (getPosition().add(new Point((Math.cos((getRotation() + anchorAngle)) * getRadius()), (Math.sin((getRotation() + anchorAngle)) * getRadius()))));
}
public function getRadius():Number{
return (radius);
}
override public function setHeight(value:Number):void{
radius = (value / 2);
}
override protected function getXmlRoot():XML{
if (spinDirection == CLOCKWISE){
return (<ClockwiseWheel/>
);
};
if (spinDirection == COUNTER_CLOCKWISE){
return (<CounterClockwiseWheel/>
);
};
return (<NoSpinWheel/>
);
}
override public function getJointType():JointType{
if (spinDirection == CLOCKWISE){
return (JointType.MOTOR_CLOCKWISE);
};
if (spinDirection == COUNTER_CLOCKWISE){
return (JointType.MOTOR_COUNTER_CLOCKWISE);
};
return (JointType.PIN);
}
override public function getWidth():Number{
return ((radius * 2));
}
override protected function generatePhysicsBodyDef():b2BodyDef{
var body:b2Body;
var bodyDef:b2BodyDef = new b2BodyDef();
var circleDef:b2CircleDef = new b2CircleDef();
circleDef.radius = getRadius();
circleDef.density = 1;
circleDef.friction = 0.7;
circleDef.restitution = 0.2;
circleDef.categoryBits = 1;
circleDef.maskBits = ~(16);
circleDef.userData = this;
bodyDef.AddShape(circleDef);
bodyDef.rotation = getRotation();
bodyDef.position.x = getPosition().x;
bodyDef.position.y = getPosition().y;
bodyDef.userData = this;
return (bodyDef);
}
public function setRadius(value:Number):void{
radius = value;
}
override protected function drawBlock(canvas:Sprite, backgroundCanvas:Sprite):void{
var backgroundColour:int;
var anchorPoint:Point;
var wheelGraphic:Sprite;
var x:Number = getPosition().x;
var y:Number = getPosition().y;
if (isGoalBlock){
canvas.graphics.beginFill(16737894);
canvas.graphics.drawCircle(0, 0, (getRadius() - 4));
backgroundColour = 12281446;
} else {
if (spinDirection == CLOCKWISE){
wheelGraphic = new ClockwiseWheelGraphic();
backgroundColour = 16547843;
} else {
if (spinDirection == COUNTER_CLOCKWISE){
wheelGraphic = new CounterClockwiseWheelGraphic();
backgroundColour = 13715365;
} else {
wheelGraphic = new NonPoweredWheelGraphic();
backgroundColour = 682493;
};
};
canvas.addChild(wheelGraphic);
canvas.graphics.beginFill(0xFFFFFF, 0);
canvas.graphics.drawCircle(0, 0, getRadius());
};
backgroundCanvas.graphics.lineStyle(6, backgroundColour, 100);
backgroundCanvas.graphics.drawCircle(0, 0, (getRadius() - 3));
var jointCanvas:Sprite = new Sprite();
canvas.addChild(jointCanvas);
drawAnchor(new Point(getRadius(), 0), jointCanvas);
drawAnchor(new Point(0, getRadius()), jointCanvas);
drawAnchor(new Point((-1 * getRadius()), 0), jointCanvas);
drawAnchor(new Point(0, (-1 * getRadius())), jointCanvas);
drawMotorAnchor(new Point(0, 0), jointCanvas);
}
override protected function initAllowableActions():void{
if (editing){
return (super.initAllowableActions());
};
allowableActions = new Actions();
allowableActions.move = true;
allowableActions.build = true;
if (!isGoalBlock){
allowableActions.delete_ = true;
};
}
override public function collidesWithJointedBlocks():Boolean{
return (false);
}
override public function getHeight():Number{
return ((radius * 2));
}
}
}//package contraption.blocks
Section 100
//OfficialLevels (contraption.data.OfficialLevels)
package contraption.data {
public class OfficialLevels {
public function OfficialLevels(){
super();
}
public static function getOfficialLevels():XML{
return (<officialLevels>
<level1>
<retrieveLevel>
<levelId>91</levelId>
<levelNumber>1</levelNumber>
<name>Rolling Away</name>
<level>
<levelBlocks>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-155</x>
<y>190</y>
</position>
<width>162</width>
<height>162</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>85</x>
<y>135</y>
</position>
<width>348</width>
<height>80</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>123</x>
<y>296</y>
</position>
<width>192</width>
<height>192</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-463.49999999999994</x>
<y>-333.34999999999997</y>
</position>
<width>136</width>
<height>136</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-254.64999999999998</x>
<y>-432</y>
</position>
<width>173</width>
<height>173</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-284.25</x>
<y>-287.24999999999994</y>
</position>
<width>287.1</width>
<height>94.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>402.1</x>
<y>-64.99999999999999</y>
</position>
<width>141.6</width>
<height>141.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>288.05000000000007</x>
<y>-301.05</y>
</position>
<width>188.8</width>
<height>188.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0.38529804259629785</rotation>
<position>
<x>242.75</x>
<y>-118.10000000000001</y>
</position>
<width>277.6</width>
<height>87.30000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-229</x>
<y>-31</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-154</x>
<y>15</y>
</position>
<width>256</width>
<height>188</height>
</start>
<end>
<position>
<x>153</x>
<y>25</y>
</position>
<width>200</width>
<height>200</height>
</end>
</level>
</retrieveLevel>
</level1>
<level2>
<retrieveLevel>
<levelId>55</levelId>
<levelNumber>2</levelNumber>
<name>Reach Up</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>317</x>
<y>277</y>
</position>
<width>622</width>
<height>62</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>180</x>
<y>-37.20000000000001</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-67.15</x>
<y>27.15</y>
</position>
<width>122.8</width>
<height>120</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>555.75</x>
<y>408.6</y>
</position>
<width>137.20000000000002</width>
<height>125.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-27.149999999999984</x>
<y>350</y>
</position>
<width>134.3</width>
<height>122.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>758.5500000000001</x>
<y>-21.4</y>
</position>
<width>128.6</width>
<height>111.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>884.3000000000001</x>
<y>257.1</y>
</position>
<width>205.7</width>
<height>168.60000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>629.45</x>
<y>277.2</y>
</position>
<width>32</width>
<height>32</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<JointedDynamicRectangle id="0">
<rotation>0</rotation>
<position>
<x>268.25</x>
<y>100.5</y>
</position>
<width>28</width>
<height>30</height>
<goalBlock>true</goalBlock>
<joints/>
</JointedDynamicRectangle>
<NoSpinWheel id="1">
<rotation>0</rotation>
<position>
<x>38.900000000000006</x>
<y>225.10000000000002</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>false</goalBlock>
<joints/>
</NoSpinWheel>
<NoSpinWheel id="2">
<rotation>0</rotation>
<position>
<x>134.05</x>
<y>225.10000000000002</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>false</goalBlock>
<joints/>
</NoSpinWheel>
<SolidRod id="3">
<rotation>0</rotation>
<position>
<x>86.47500000000001</x>
<y>225.10000000000002</y>
</position>
<width>95.15</width>
<height>8</height>
<goalBlock>false</goalBlock>
<joints>
<jointedTo>1</jointedTo>
<jointedTo>2</jointedTo>
</joints>
</SolidRod>
<SolidRod id="4">
<rotation>-2.2225965468532523</rotation>
<position>
<x>111.025</x>
<y>194.925</y>
</position>
<width>75.91261423505321</width>
<height>8</height>
<goalBlock>false</goalBlock>
<joints>
<jointedTo>3</jointedTo>
</joints>
</SolidRod>
<SolidRod id="5">
<rotation>2.2537675358563143</rotation>
<position>
<x>63.45</x>
<y>194.925</y>
</position>
<width>77.80059447073656</width>
<height>8</height>
<goalBlock>false</goalBlock>
<joints>
<jointedTo>4</jointedTo>
<jointedTo>3</jointedTo>
</joints>
</SolidRod>
</playerBlocks>
<start>
<position>
<x>201.75</x>
<y>160.9</y>
</position>
<width>379.5</width>
<height>197.1</height>
</start>
<end>
<position>
<x>554.25</x>
<y>73.5</y>
</position>
<width>148</width>
<height>142</height>
</end>
</level>
</retrieveLevel>
</level2>
<level3>
<retrieveLevel>
<levelId>16</levelId>
<levelNumber>3</levelNumber>
<name>Mind The Gap</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>94.75</x>
<y>228.35</y>
</position>
<width>412</width>
<height>92</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>528.8</x>
<y>229.4</y>
</position>
<width>254</width>
<height>90</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-101.3</x>
<y>231.75</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>662.1</x>
<y>279.1</y>
</position>
<width>93.4</width>
<height>93.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>27.75</x>
<y>27.749999999999996</y>
</position>
<width>61.3</width>
<height>61.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>2.050224006112992</rotation>
<position>
<x>640.1500000000001</x>
<y>35.8</y>
</position>
<width>42.3</width>
<height>68.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>444.1</x>
<y>268.8</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>158.4</x>
<y>316.8</y>
</position>
<width>96.4</width>
<height>96.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>521.45</x>
<y>305.5500000000001</y>
</position>
<width>71.5</width>
<height>71.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>171</x>
<y>106</y>
</position>
<width>26</width>
<height>26</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>90</x>
<y>109</y>
</position>
<width>404</width>
<height>166</height>
</start>
<end>
<position>
<x>562.8000000000001</x>
<y>123.4</y>
</position>
<width>159.10000000000002</width>
<height>135.70000000000002</height>
</end>
</level>
</retrieveLevel>
</level3>
<level4>
<retrieveLevel>
<levelId>102</levelId>
<levelNumber>4</levelNumber>
<name>Junkyard</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>243</x>
<y>280</y>
</position>
<width>778</width>
<height>68</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>254.99999999999997</x>
<y>117.24999999999999</y>
</position>
<width>25</width>
<height>58.400000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0.032246882435253865</rotation>
<position>
<x>284.54999999999995</x>
<y>216</y>
</position>
<width>39.3</width>
<height>40.8</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>321.15</x>
<y>178.65</y>
</position>
<width>18</width>
<height>18</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>364</x>
<y>217</y>
</position>
<width>48</width>
<height>46</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>202.25</x>
<y>178.45</y>
</position>
<width>21.700000000000003</width>
<height>36.7</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>431.25</x>
<y>208.75</y>
</position>
<width>29.700000000000003</width>
<height>42</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>404</x>
<y>110</y>
</position>
<width>23.400000000000002</width>
<height>56.7</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>339.45000000000005</x>
<y>110.25</y>
</position>
<width>20</width>
<height>20.1</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>240.35000000000002</x>
<y>168.35000000000002</y>
</position>
<width>39.6</width>
<height>29.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>367.1</x>
<y>158.70000000000002</y>
</position>
<width>26.700000000000003</width>
<height>41.800000000000004</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>404.35</x>
<y>164.00000000000003</y>
</position>
<width>17.3</width>
<height>17.3</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>161.10000000000002</x>
<y>220.45000000000002</y>
</position>
<width>51.800000000000004</width>
<height>18.400000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>466.65000000000003</x>
<y>162.3</y>
</position>
<width>52</width>
<height>29.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>492.65000000000003</x>
<y>213</y>
</position>
<width>59.300000000000004</width>
<height>37.1</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>472.35</x>
<y>102.65</y>
</position>
<width>58.400000000000006</width>
<height>25.1</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>240.35</x>
<y>219.45000000000002</y>
</position>
<width>41.7</width>
<height>28.3</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-203.85000000000005</x>
<y>280.49999999999994</y>
</position>
<width>240.20000000000002</width>
<height>67.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>-180.75000000000003</x>
<y>222.05</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>-235.35000000000002</x>
<y>207.5</y>
</position>
<width>29.1</width>
<height>78.30000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-190.75000000000003</x>
<y>166.50000000000003</y>
</position>
<width>31</width>
<height>31</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>-289.95</x>
<y>230.25000000000003</y>
</position>
<width>61.900000000000006</width>
<height>32.800000000000004</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-291.8</x>
<y>195.70000000000002</y>
</position>
<width>18.2</width>
<height>18.2</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicRectangle>
<rotation>-0.20477186860842284</rotation>
<position>
<x>-276.35</x>
<y>157.45000000000005</y>
</position>
<width>85.5</width>
<height>32.7</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0.017512709110314773</rotation>
<position>
<x>-212.55</x>
<y>109.14999999999999</y>
</position>
<width>69.2</width>
<height>51</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-14.200000000000045</x>
<y>420.4000000000001</y>
</position>
<width>660.7</width>
<height>60</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>-189.9</x>
<y>365.84999999999997</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>-36.99999999999999</x>
<y>374.95</y>
</position>
<width>29.1</width>
<height>30.900000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>-37.90000000000002</x>
<y>344.05</y>
</position>
<width>60.1</width>
<height>30.900000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>-110.70000000000005</x>
<y>356.75000000000006</y>
</position>
<width>54.6</width>
<height>67.3</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>32.199999999999996</x>
<y>378.55</y>
</position>
<width>60</width>
<height>23.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0.39204627244228374</rotation>
<position>
<x>91.25000000000001</x>
<y>358.6</y>
</position>
<width>74.7</width>
<height>38.2</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>25.800000000000004</x>
<y>353.05000000000007</y>
</position>
<width>25.5</width>
<height>27.3</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>-0.5044164118269181</rotation>
<position>
<x>145.94999999999996</x>
<y>362.20000000000005</y>
</position>
<width>18.2</width>
<height>56.400000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>240.55</x>
<y>356.7</y>
</position>
<width>76.4</width>
<height>67.4</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>-150.75</x>
<y>378.55</y>
</position>
<width>18.2</width>
<height>23.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>184.15</x>
<y>372.1500000000001</y>
</position>
<width>18.2</width>
<height>18.2</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-153.45000000000002</x>
<y>356.70000000000005</y>
</position>
<width>10.9</width>
<height>10.9</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>7</x>
<y>173</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-4</x>
<y>160</y>
</position>
<width>280</width>
<height>190</height>
</start>
<end>
<position>
<x>572</x>
<y>152</y>
</position>
<width>100</width>
<height>208</height>
</end>
</level>
</retrieveLevel>
</level4>
<level5>
<retrieveLevel>
<levelId>31</levelId>
<levelNumber>5</levelNumber>
<name>The Wall</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>110.2</x>
<y>287.6</y>
</position>
<width>467.1</width>
<height>87.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>740.8</x>
<y>273.70000000000005</y>
</position>
<width>480.3</width>
<height>61.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>490.25</x>
<y>337.9000000000001</y>
</position>
<width>1129.9</width>
<height>90.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>291.25</x>
<y>159.1</y>
</position>
<width>29.200000000000003</width>
<height>32.1</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>252.54999999999995</x>
<y>162.8</y>
</position>
<width>35.1</width>
<height>40.900000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>289.05</x>
<y>193.4</y>
</position>
<width>27.8</width>
<height>35</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>251.75</x>
<y>202.2</y>
</position>
<width>24.8</width>
<height>38</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>290.55</x>
<y>227</y>
</position>
<width>30.6</width>
<height>32.1</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>253.30000000000004</x>
<y>232.9</y>
</position>
<width>32.1</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>294.20000000000005</x>
<y>100</y>
</position>
<width>33.6</width>
<height>30.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>255.44999999999993</x>
<y>101.45</y>
</position>
<width>26.200000000000003</width>
<height>27.8</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>273.74999999999994</x>
<y>129.95</y>
</position>
<width>71.5</width>
<height>23.3</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>328.50000000000006</x>
<y>111.7</y>
</position>
<width>32.1</width>
<height>30.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>325.55</x>
<y>148.15</y>
</position>
<width>30.700000000000003</width>
<height>36.5</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>325.55000000000007</x>
<y>183.95</y>
</position>
<width>30.6</width>
<height>33.6</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>324.75000000000006</x>
<y>223.35</y>
</position>
<width>23.3</width>
<height>40.900000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-72.25000000000001</x>
<y>330.65</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>989.05</x>
<y>310.2</y>
</position>
<width>67.10000000000001</width>
<height>67.10000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-111.70000000000002</x>
<y>12.399999999999991</y>
</position>
<width>77.9</width>
<height>77.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>135.25</x>
<y>-28.95000000000001</y>
</position>
<width>31.6</width>
<height>31.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>93.9</x>
<y>-49.650000000000006</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-13.149999999999997</x>
<y>-71.55</y>
</position>
<width>70.60000000000001</width>
<height>70.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-101.95000000000002</x>
<y>-97.05</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>61.09999999999998</x>
<y>-110.45000000000002</y>
</position>
<width>36.5</width>
<height>36.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.5742878193317579</rotation>
<position>
<x>795.9000000000002</x>
<y>-7.100000000000001</y>
</position>
<width>80.30000000000001</width>
<height>82.80000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.4531278240870904</rotation>
<position>
<x>548.9</x>
<y>-20.450000000000006</y>
</position>
<width>70.4</width>
<height>55.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.005127687802247816</rotation>
<position>
<x>603.65</x>
<y>-42.349999999999994</y>
</position>
<width>77.80000000000001</width>
<height>70.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.38987614128793013</rotation>
<position>
<x>663.25</x>
<y>-35.099999999999994</y>
</position>
<width>82.80000000000001</width>
<height>75.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.42419355299901373</rotation>
<position>
<x>726.5</x>
<y>-38.7</y>
</position>
<width>92.5</width>
<height>75.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<JointedDynamicRectangle id="0">
<rotation>0</rotation>
<position>
<x>29</x>
<y>158</y>
</position>
<width>28</width>
<height>30</height>
<goalBlock>true</goalBlock>
<joints/>
</JointedDynamicRectangle>
</playerBlocks>
<start>
<position>
<x>14</x>
<y>153</y>
</position>
<width>274</width>
<height>194</height>
</start>
<end>
<position>
<x>611.7</x>
<y>151.85</y>
</position>
<width>200</width>
<height>200</height>
</end>
</level>
</retrieveLevel>
</level5>
<level6>
<retrieveLevel>
<levelId>89</levelId>
<levelNumber>6</levelNumber>
<name>On a Roll</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-290</x>
<y>230</y>
</position>
<width>816</width>
<height>58</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-338</x>
<y>119</y>
</position>
<width>82</width>
<height>82</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticRectangle>
<rotation>-0.4911863378316689</rotation>
<position>
<x>-586.1499999999997</x>
<y>68.69999999999997</y>
</position>
<width>64.9</width>
<height>31</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.790117623877445</rotation>
<position>
<x>-618.65</x>
<y>40.45</y>
</position>
<width>87.5</width>
<height>33.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-661.0500000000002</x>
<y>37.650000000000006</y>
</position>
<width>84.7</width>
<height>25.400000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.8298537316689694</rotation>
<position>
<x>-685.0500000000001</x>
<y>60.300000000000004</y>
</position>
<width>60.800000000000004</width>
<height>27.200000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-394.2</x>
<y>-137.45000000000005</y>
</position>
<width>22.6</width>
<height>56.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.40323852203169236</rotation>
<position>
<x>-418.2</x>
<y>-151.60000000000002</y>
</position>
<width>59.300000000000004</width>
<height>28.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.31018911492659573</rotation>
<position>
<x>-416.75000000000006</x>
<y>-172.70000000000002</y>
</position>
<width>22.6</width>
<height>56.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.16229887623745093</rotation>
<position>
<x>-439.29999999999995</x>
<y>-184.04999999999998</y>
</position>
<width>62.2</width>
<height>19.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.45018601367763234</rotation>
<position>
<x>-18.550000000000015</x>
<y>-110.64999999999999</y>
</position>
<width>84.80000000000001</width>
<height>28.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.5698629937964668</rotation>
<position>
<x>-62.35</x>
<y>-121.94999999999999</y>
</position>
<width>84.7</width>
<height>22.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.1560780599440067</rotation>
<position>
<x>-107.60000000000002</x>
<y>-117.75000000000004</y>
</position>
<width>87.5</width>
<height>22.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.45234394718667875</rotation>
<position>
<x>22.349999999999966</x>
<y>-100.75</y>
</position>
<width>70.60000000000001</width>
<height>22.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.41422262451345127</rotation>
<position>
<x>118.40000000000002</x>
<y>248.00000000000003</y>
</position>
<width>25.400000000000002</width>
<height>73.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.8628470922264423</rotation>
<position>
<x>149.45</x>
<y>232.50000000000003</y>
</position>
<width>74.5</width>
<height>25.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.10371808350983186</rotation>
<position>
<x>180.25000000000003</x>
<y>237.90000000000006</y>
</position>
<width>69.9</width>
<height>16.900000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.5447021293342041</rotation>
<position>
<x>-260</x>
<y>262.15000000000003</y>
</position>
<width>84.5</width>
<height>25</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.7553069146140182</rotation>
<position>
<x>-276.95000000000005</x>
<y>280.49999999999994</y>
</position>
<width>24.1</width>
<height>66.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.7440872017124346</rotation>
<position>
<x>-268.45</x>
<y>311</y>
</position>
<width>58.6</width>
<height>18.400000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-271.2</x>
<y>333.95000000000005</y>
</position>
<width>12.9</width>
<height>56.800000000000004</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>1.8495910970201173</rotation>
<position>
<x>-701</x>
<y>231.3</y>
</position>
<width>93.5</width>
<height>42.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.5620757484096769</rotation>
<position>
<x>-703.75</x>
<y>284.5</y>
</position>
<width>94.30000000000001</width>
<height>36.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.6863295277912818</rotation>
<position>
<x>-701.0500000000001</x>
<y>319.35</y>
</position>
<width>23.8</width>
<height>55</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>1.8317160080084676</rotation>
<position>
<x>-685.5000000000001</x>
<y>331.30000000000007</y>
</position>
<width>16</width>
<height>59</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-248.70000000000002</x>
<y>-20.25</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-385.5</x>
<y>19.75</y>
</position>
<width>386.90000000000003</width>
<height>189.3</height>
</start>
<end>
<position>
<x>10.100000000000001</x>
<y>22.900000000000002</y>
</position>
<width>155.8</width>
<height>194.3</height>
</end>
</level>
</retrieveLevel>
</level6>
<level7>
<retrieveLevel>
<levelId>88</levelId>
<levelNumber>7</levelNumber>
<name>Full-up</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-268</x>
<y>202</y>
</position>
<width>636</width>
<height>116</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>380</x>
<y>195</y>
</position>
<width>310</width>
<height>94</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-116</x>
<y>-110</y>
</position>
<width>86</width>
<height>86</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-118</x>
<y>-4</y>
</position>
<width>28</width>
<height>40</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>245.29999999999998</x>
<y>306.6</y>
</position>
<width>56</width>
<height>56</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>140</x>
<y>626</y>
</position>
<width>520</width>
<height>134</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-335.65</x>
<y>435.05000000000007</y>
</position>
<width>500</width>
<height>515.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>416.6500000000001</x>
<y>438.75</y>
</position>
<width>236.20000000000002</width>
<height>507.90000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>125.20000000000003</x>
<y>394.05000000000007</y>
</position>
<width>94.9</width>
<height>94.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>153.3</x>
<y>540.3500000000001</y>
</position>
<width>18.1</width>
<height>18.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>239.15</x>
<y>499.9</y>
</position>
<width>64.60000000000001</width>
<height>64.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-14.200000000000001</x>
<y>485.8000000000001</y>
</position>
<width>72.7</width>
<height>72.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>89.75</x>
<y>521.1500000000001</y>
</position>
<width>38.400000000000006</width>
<height>38.400000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>3.9499999999999957</x>
<y>387.90000000000003</y>
</position>
<width>26.200000000000003</width>
<height>26.200000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>259.34999999999997</x>
<y>399.00000000000006</y>
</position>
<width>40.400000000000006</width>
<height>40.400000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<JointedDynamicRectangle id="0">
<rotation>0</rotation>
<position>
<x>-469</x>
<y>98</y>
</position>
<width>82</width>
<height>20</height>
<goalBlock>true</goalBlock>
<joints/>
</JointedDynamicRectangle>
</playerBlocks>
<start>
<position>
<x>-319</x>
<y>53</y>
</position>
<width>490</width>
<height>216</height>
</start>
<end>
<position>
<x>375</x>
<y>70</y>
</position>
<width>200</width>
<height>200</height>
</end>
</level>
</retrieveLevel>
</level7>
<level8>
<retrieveLevel>
<levelId>86</levelId>
<levelNumber>8</levelNumber>
<name>Higher</name>
<level>
<levelBlocks>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-266</x>
<y>316</y>
</position>
<width>102</width>
<height>102</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-126</x>
<y>353</y>
</position>
<width>120</width>
<height>120</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-35</x>
<y>293</y>
</position>
<width>64</width>
<height>64</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>136</x>
<y>305</y>
</position>
<width>140</width>
<height>140</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>348</x>
<y>218</y>
</position>
<width>164</width>
<height>164</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>547</x>
<y>194</y>
</position>
<width>96</width>
<height>96</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>633</x>
<y>248</y>
</position>
<width>46</width>
<height>46</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-358</x>
<y>384</y>
</position>
<width>66</width>
<height>66</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-435</x>
<y>388</y>
</position>
<width>36</width>
<height>36</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-290</x>
<y>-181</y>
</position>
<width>62</width>
<height>62</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>215</x>
<y>-170</y>
</position>
<width>24</width>
<height>24</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-401</x>
<y>-163</y>
</position>
<width>16</width>
<height>16</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-358</x>
<y>-190</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>174</x>
<y>-194</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-81</x>
<y>-238</y>
</position>
<width>114</width>
<height>114</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-199</x>
<y>-225</y>
</position>
<width>74</width>
<height>74</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>84</x>
<y>-263</y>
</position>
<width>104</width>
<height>104</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>17</x>
<y>-180</y>
</position>
<width>18</width>
<height>18</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<JointedDynamicRectangle id="0">
<rotation>0</rotation>
<position>
<x>-217</x>
<y>68</y>
</position>
<width>34</width>
<height>36</height>
<goalBlock>true</goalBlock>
<joints/>
</JointedDynamicRectangle>
</playerBlocks>
<start>
<position>
<x>-39</x>
<y>141</y>
</position>
<width>454</width>
<height>222</height>
</start>
<end>
<position>
<x>-39</x>
<y>-23</y>
</position>
<width>454</width>
<height>100</height>
</end>
</level>
</retrieveLevel>
</level8>
<level9>
<retrieveLevel>
<levelId>100</levelId>
<levelNumber>9</levelNumber>
<name>Around the Bend</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-191.90000000000003</x>
<y>33.85</y>
</position>
<width>482.5</width>
<height>101.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-184.85000000000002</x>
<y>299.1500000000001</y>
</position>
<width>869.1</width>
<height>84.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>290.6</x>
<y>176.35000000000002</y>
</position>
<width>101.5</width>
<height>330.20000000000005</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-647.6000000000001</x>
<y>413.3499999999999</y>
</position>
<width>110</width>
<height>313.20000000000005</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-384.05000000000007</x>
<y>74.65</y>
</position>
<width>98.2</width>
<height>141.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>328.3999999999999</x>
<y>60.84999999999999</y>
</position>
<width>160.9</width>
<height>98.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-696.15</x>
<y>518.25</y>
</position>
<width>164.9</width>
<height>102.10000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-344.45000000000005</x>
<y>-279.90000000000003</y>
</position>
<width>969.6</width>
<height>137.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>59.94999999999996</x>
<y>-442.35</y>
</position>
<width>161</width>
<height>255.10000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-746.8</x>
<y>-93.00000000000003</y>
</position>
<width>164.8</width>
<height>365.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>307.3</x>
<y>-16.85</y>
</position>
<width>27.5</width>
<height>27.5</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-744.7500000000001</x>
<y>436.5</y>
</position>
<width>31.400000000000002</width>
<height>31.400000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-365.95</x>
<y>-44.4</y>
</position>
<width>27.5</width>
<height>27.5</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-65.6000000000001</x>
<y>-376.15000000000003</y>
</position>
<width>27.5</width>
<height>27.5</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>99.30000000000008</x>
<y>-601.3000000000001</y>
</position>
<width>31.400000000000002</width>
<height>31.400000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-638.8000000000001</x>
<y>-379.55</y>
</position>
<width>31.400000000000002</width>
<height>31.400000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-436.7</x>
<y>228.95000000000002</y>
</position>
<width>27.5</width>
<height>27.5</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-174.65000000000003</x>
<y>-64.10000000000002</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-191.9</x>
<y>-126.95</y>
</position>
<width>434.6</width>
<height>279.40000000000003</height>
</start>
<end>
<position>
<x>-187.65</x>
<y>180.60000000000002</y>
</position>
<width>460</width>
<height>220.10000000000002</height>
</end>
</level>
</retrieveLevel>
</level9>
<level10>
<retrieveLevel>
<levelId>17</levelId>
<levelNumber>10</levelNumber>
<name>Up The Hump</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>318.45</x>
<y>278.6</y>
</position>
<width>873.8000000000001</width>
<height>133.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>351.55000000000007</x>
<y>213.95</y>
</position>
<width>102.2</width>
<height>102.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0.364926276337564</rotation>
<position>
<x>-11.900000000000007</x>
<y>347.40000000000003</y>
</position>
<width>139.5</width>
<height>61.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.16829401120136167</rotation>
<position>
<x>185.15</x>
<y>353.90000000000003</y>
</position>
<width>113.6</width>
<height>73</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.4720399232666762</rotation>
<position>
<x>718.0500000000001</x>
<y>349</y>
</position>
<width>112.4</width>
<height>63</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.056705940703367985</rotation>
<position>
<x>546</x>
<y>359.50000000000006</y>
</position>
<width>123.3</width>
<height>56.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.4676269911188695</rotation>
<position>
<x>362.75</x>
<y>362</y>
</position>
<width>66.5</width>
<height>95.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.24992450923689735</rotation>
<position>
<x>-126.95000000000002</x>
<y>270.65</y>
</position>
<width>45</width>
<height>60.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>664.45</x>
<y>22.94999999999999</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>81.2</x>
<y>14.300000000000011</y>
</position>
<width>37.4</width>
<height>37.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<JointedDynamicRectangle id="0">
<rotation>0</rotation>
<position>
<x>-7</x>
<y>92</y>
</position>
<width>84</width>
<height>70</height>
<goalBlock>true</goalBlock>
<joints/>
</JointedDynamicRectangle>
</playerBlocks>
<start>
<position>
<x>11</x>
<y>129</y>
</position>
<width>258</width>
<height>176</height>
</start>
<end>
<position>
<x>619</x>
<y>132</y>
</position>
<width>244</width>
<height>184</height>
</end>
</level>
</retrieveLevel>
</level10>
<level11>
<retrieveLevel>
<levelId>62</levelId>
<levelNumber>11</levelNumber>
<name>Mission to Mars</name>
<level>
<levelBlocks>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>152.15</x>
<y>155.5</y>
</position>
<width>33.5</width>
<height>33.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>454.55000000000007</x>
<y>152.15</y>
</position>
<width>34.800000000000004</width>
<height>34.800000000000004</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>152.85</x>
<y>97.3</y>
</position>
<width>17.400000000000002</width>
<height>17.400000000000002</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>150</x>
<y>150</y>
</position>
<width>200</width>
<height>200</height>
</start>
<end>
<position>
<x>450</x>
<y>150</y>
</position>
<width>200</width>
<height>200</height>
</end>
</level>
</retrieveLevel>
</level11>
<level12>
<retrieveLevel>
<levelId>19</levelId>
<levelNumber>12</levelNumber>
<name>Up The Stairs</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>80.35</x>
<y>320.4</y>
</position>
<width>322.6</width>
<height>68.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>281</x>
<y>302.25000000000006</y>
</position>
<width>113.9</width>
<height>80.30000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>351.75</x>
<y>281.80000000000007</y>
</position>
<width>131.4</width>
<height>87.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>403.65</x>
<y>248.2</y>
</position>
<width>111</width>
<height>70.10000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>462.1</x>
<y>217.50000000000003</y>
</position>
<width>106.6</width>
<height>65.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>543.1000000000001</x>
<y>189.1</y>
</position>
<width>140.20000000000002</width>
<height>68.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>593.35</x>
<y>156.2</y>
</position>
<width>112.4</width>
<height>61.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>647.1999999999999</x>
<y>180.85</y>
</position>
<width>56.400000000000006</width>
<height>56.400000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>525</x>
<y>312.65000000000003</y>
</position>
<width>134.3</width>
<height>134.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>270.8</x>
<y>377.35</y>
</position>
<width>67.2</width>
<height>67.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>364.50000000000006</x>
<y>352.00000000000006</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-84.55000000000001</x>
<y>387.85</y>
</position>
<width>102.2</width>
<height>102.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>98.95</x>
<y>382.55</y>
</position>
<width>62.6</width>
<height>62.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>184.50000000000003</x>
<y>359.35</y>
</position>
<width>41.400000000000006</width>
<height>41.400000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>36.4</x>
<y>351.3</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0.13210546652388205</rotation>
<position>
<x>85.79999999999997</x>
<y>62.25</y>
</position>
<width>96.3</width>
<height>56.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>89.35</x>
<y>38.64999999999999</y>
</position>
<width>48.400000000000006</width>
<height>48.400000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.4308491039314226</rotation>
<position>
<x>266.90000000000003</x>
<y>24.9</y>
</position>
<width>44.8</width>
<height>22.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>261.6</x>
<y>14.500000000000004</y>
</position>
<width>22.9</width>
<height>22.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>546</x>
<y>100</y>
</position>
<width>20</width>
<height>20</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>480</x>
<y>-117</y>
</position>
<width>8</width>
<height>8</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>241</x>
<y>-29</y>
</position>
<width>18</width>
<height>18</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>513</x>
<y>-48</y>
</position>
<width>30</width>
<height>30</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>533</x>
<y>-8</y>
</position>
<width>10</width>
<height>10</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>451</x>
<y>-179</y>
</position>
<width>10</width>
<height>10</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>306</x>
<y>-8</y>
</position>
<width>8</width>
<height>8</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>-0.714090698612158</rotation>
<position>
<x>295</x>
<y>-43</y>
</position>
<width>10</width>
<height>10</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticRectangle>
<rotation>-2.066529346548105</rotation>
<position>
<x>527.3000000000001</x>
<y>-56.15</y>
</position>
<width>58.900000000000006</width>
<height>28</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>63</x>
<y>221</y>
</position>
<width>24</width>
<height>24</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>56.95</x>
<y>192.75</y>
</position>
<width>275.90000000000003</width>
<height>191.2</height>
</start>
<end>
<position>
<x>605.1</x>
<y>62.800000000000004</y>
</position>
<width>131.4</width>
<height>146</height>
</end>
</level>
</retrieveLevel>
</level12>
<level13>
<retrieveLevel>
<levelId>23</levelId>
<levelNumber>13</levelNumber>
<name>Big Ball</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0.08609323420781712</rotation>
<position>
<x>636.2999999999998</x>
<y>281.25000000000006</y>
</position>
<width>194.5</width>
<height>45.900000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>744.5500000000001</x>
<y>192.54999999999998</y>
</position>
<width>48</width>
<height>240</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>412.3000000000002</x>
<y>-43.09999999999998</y>
</position>
<width>70.10000000000001</width>
<height>70.10000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticRectangle>
<rotation>0.39331112360490583</rotation>
<position>
<x>413.8500000000001</x>
<y>52.44999999999999</y>
</position>
<width>159.5</width>
<height>33.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.00000806919550522256</rotation>
<position>
<x>224.0999999999999</x>
<y>273.75000000000006</y>
</position>
<width>658.4000000000001</width>
<height>45.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-25</x>
<y>19</y>
</position>
<width>232</width>
<height>28</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-88</x>
<y>-61</y>
</position>
<width>66</width>
<height>66</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>745</x>
<y>0</y>
</position>
<width>70</width>
<height>70</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>393</x>
<y>379</y>
</position>
<width>70</width>
<height>70</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>316</x>
<y>468</y>
</position>
<width>236</width>
<height>38</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<JointedDynamicRectangle id="0">
<rotation>0</rotation>
<position>
<x>207</x>
<y>170</y>
</position>
<width>58</width>
<height>12</height>
<goalBlock>true</goalBlock>
<joints/>
</JointedDynamicRectangle>
</playerBlocks>
<start>
<position>
<x>86.2</x>
<y>157.65</y>
</position>
<width>346</width>
<height>204.4</height>
</start>
<end>
<position>
<x>682.5</x>
<y>229.9</y>
</position>
<width>100.7</width>
<height>115.3</height>
</end>
</level>
</retrieveLevel>
</level13>
<level14>
<retrieveLevel>
<levelId>20</levelId>
<levelNumber>14</levelNumber>
<name>Four Balls</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>212.45</x>
<y>266.40000000000003</y>
</position>
<width>401.4</width>
<height>62.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.2374387084494178</rotation>
<position>
<x>-21.85</x>
<y>154.00000000000003</y>
</position>
<width>184.5</width>
<height>17.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>389.05</x>
<y>234.3</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>405.85</x>
<y>175.15</y>
</position>
<width>54</width>
<height>54</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>602.2</x>
<y>188.75000000000003</y>
</position>
<width>68.4</width>
<height>68.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>492.3</x>
<y>243.05</y>
</position>
<width>68.60000000000001</width>
<height>68.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-117</x>
<y>174</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-274</x>
<y>45</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-196</x>
<y>76</y>
</position>
<width>30</width>
<height>30</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-137</x>
<y>97</y>
</position>
<width>20</width>
<height>20</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-53</x>
<y>215</y>
</position>
<width>72</width>
<height>72</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-4</x>
<y>189</y>
</position>
<width>34</width>
<height>34</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0.507098504392337</rotation>
<position>
<x>2.0999999999999996</x>
<y>255.19999999999993</y>
</position>
<width>70</width>
<height>62.300000000000004</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.36397895650964407</rotation>
<position>
<x>423</x>
<y>266</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>565.95</x>
<y>249.5</y>
</position>
<width>35.300000000000004</width>
<height>35.300000000000004</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0.3085500010704924</rotation>
<position>
<x>-80.85000000000001</x>
<y>163.4</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>45</x>
<y>144</y>
</position>
<width>26</width>
<height>26</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
<NoSpinWheel id="1">
<rotation>0</rotation>
<position>
<x>1</x>
<y>132</y>
</position>
<width>26</width>
<height>26</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
<NoSpinWheel id="2">
<rotation>0</rotation>
<position>
<x>-39</x>
<y>121</y>
</position>
<width>24</width>
<height>24</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
<NoSpinWheel id="3">
<rotation>0</rotation>
<position>
<x>-85</x>
<y>110</y>
</position>
<width>24</width>
<height>24</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>196.10000000000002</x>
<y>144.55</y>
</position>
<width>358.70000000000005</width>
<height>183.3</height>
</start>
<end>
<position>
<x>508</x>
<y>167.85000000000002</y>
</position>
<width>159.20000000000002</width>
<height>83.30000000000001</height>
</end>
</level>
</retrieveLevel>
</level14>
<level15>
<retrieveLevel>
<levelId>24</levelId>
<levelNumber>15</levelNumber>
<name>Down Under</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>339.45000000000005</x>
<y>86.15</y>
</position>
<width>324.1</width>
<height>84.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>348.2</x>
<y>313.90000000000003</y>
</position>
<width>159.10000000000002</width>
<height>59.900000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>349</x>
<y>373</y>
</position>
<width>86</width>
<height>86</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>347</x>
<y>464</y>
</position>
<width>10</width>
<height>140</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>345</x>
<y>539</y>
</position>
<width>24</width>
<height>24</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>284</x>
<y>404</y>
</position>
<width>26</width>
<height>26</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>418</x>
<y>342</y>
</position>
<width>28</width>
<height>28</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>275</x>
<y>95</y>
</position>
<width>46</width>
<height>46</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>330</x>
<y>114</y>
</position>
<width>36</width>
<height>36</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>492</x>
<y>100</y>
</position>
<width>14</width>
<height>14</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>342</x>
<y>-55</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>341.6</x>
<y>-24.85</y>
</position>
<width>251.1</width>
<height>172.3</height>
</start>
<end>
<position>
<x>348.15000000000003</x>
<y>244.55</y>
</position>
<width>129.9</width>
<height>115.3</height>
</end>
</level>
</retrieveLevel>
</level15>
<level16>
<retrieveLevel>
<levelId>28</levelId>
<levelNumber>16</levelNumber>
<name>Awash</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>-0.34706526203385135</rotation>
<position>
<x>392.00000000000006</x>
<y>278.80000000000007</y>
</position>
<width>417.7000000000001</width>
<height>65</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>548.85</x>
<y>124.79999999999998</y>
</position>
<width>19</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>494.8500000000001</x>
<y>84.69999999999999</y>
</position>
<width>21.9</width>
<height>21.9</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>490.5</x>
<y>148.9</y>
</position>
<width>19</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>402.2000000000001</x>
<y>67.85000000000001</y>
</position>
<width>19</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>548.9000000000001</x>
<y>67.9</y>
</position>
<width>17.5</width>
<height>17.5</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>529.9499999999999</x>
<y>170.8</y>
</position>
<width>17.5</width>
<height>17.5</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>473.00000000000006</x>
<y>189.05</y>
</position>
<width>17.5</width>
<height>17.5</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>327</x>
<y>219</y>
</position>
<width>23.4</width>
<height>23.4</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>359.85</x>
<y>56.249999999999986</y>
</position>
<width>10.2</width>
<height>10.2</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>366.4</x>
<y>105.1</y>
</position>
<width>24.8</width>
<height>24.8</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>365.7</x>
<y>168.60000000000002</y>
</position>
<width>17.5</width>
<height>17.5</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>375.2000000000001</x>
<y>224.8</y>
</position>
<width>16.1</width>
<height>16.1</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>59.849999999999994</x>
<y>344.55000000000007</y>
</position>
<width>296.40000000000003</width>
<height>54</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>713.1500000000001</x>
<y>204.4</y>
</position>
<width>285.6</width>
<height>49.800000000000004</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>274.6</x>
<y>189.75</y>
</position>
<width>22</width>
<height>22</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>311.15</x>
<y>91.65</y>
</position>
<width>24</width>
<height>24</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>312.40000000000003</x>
<y>146.7</y>
</position>
<width>27.8</width>
<height>27.8</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>489.05000000000007</x>
<y>24.09999999999999</y>
</position>
<width>24.8</width>
<height>24.8</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>430.65</x>
<y>133.5</y>
</position>
<width>35.1</width>
<height>35.1</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>443.05</x>
<y>66.4</y>
</position>
<width>14.6</width>
<height>14.6</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>270.90000000000003</x>
<y>150.65</y>
</position>
<width>13.2</width>
<height>13.2</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>310.95</x>
<y>34.3</y>
</position>
<width>29.200000000000003</width>
<height>29.200000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>427.75</x>
<y>10.949999999999998</y>
</position>
<width>33.6</width>
<height>33.6</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>418.2</x>
<y>194.95</y>
</position>
<width>24.9</width>
<height>24.9</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticRectangle>
<rotation>0.26313751420353326</rotation>
<position>
<x>594.1</x>
<y>241.5</y>
</position>
<width>121.2</width>
<height>78.30000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>2.2640688357474295</rotation>
<position>
<x>194.00000000000003</x>
<y>376.4500000000001</y>
</position>
<width>87.60000000000001</width>
<height>56.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.3192953406522806</rotation>
<position>
<x>-106.14999999999999</x>
<y>353.75</y>
</position>
<width>72.3</width>
<height>54.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.4360672976842675</rotation>
<position>
<x>877.5000000000001</x>
<y>220.75000000000003</y>
</position>
<width>87.60000000000001</width>
<height>53.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.36918610597890567</rotation>
<position>
<x>-40.5</x>
<y>19.69999999999999</y>
</position>
<width>131.3</width>
<height>50.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.4487233440107211</rotation>
<position>
<x>23.899999999999988</x>
<y>7.499999999999999</y>
</position>
<width>59.7</width>
<height>48.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>434.85</x>
<y>286.15</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>380.15</x>
<y>326.2</y>
</position>
<width>62.1</width>
<height>62.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>315.35</x>
<y>333.55</y>
</position>
<width>32.800000000000004</width>
<height>32.800000000000004</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>582.6500000000001</x>
<y>267.8500000000001</y>
</position>
<width>63.900000000000006</width>
<height>63.900000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>508.75</x>
<y>278.90000000000003</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>544.35</x>
<y>316.25</y>
</position>
<width>18.2</width>
<height>18.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>225</x>
<y>269</y>
</position>
<width>32</width>
<height>32</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>179</x>
<y>107</y>
</position>
<width>46</width>
<height>46</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>201</x>
<y>165</y>
</position>
<width>14</width>
<height>14</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>219</x>
<y>207</y>
</position>
<width>30</width>
<height>30</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>304</x>
<y>255</y>
</position>
<width>14</width>
<height>14</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>273</x>
<y>236</y>
</position>
<width>18</width>
<height>18</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>241</x>
<y>137</y>
</position>
<width>18</width>
<height>18</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>250</x>
<y>74</y>
</position>
<width>26</width>
<height>26</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>35</x>
<y>293</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>41</x>
<y>249</y>
</position>
<width>298</width>
<height>154</height>
</start>
<end>
<position>
<x>704.75</x>
<y>99.4</y>
</position>
<width>253</width>
<height>198.9</height>
</end>
</level>
</retrieveLevel>
</level16>
<level17>
<retrieveLevel>
<levelId>69</levelId>
<levelNumber>17</levelNumber>
<name>Handling</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>122</x>
<y>176.99999999999997</y>
</position>
<width>1166.1000000000001</width>
<height>46.800000000000004</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>265</x>
<y>-187.4</y>
</position>
<width>96.30000000000001</width>
<height>489.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.1782558204336252</rotation>
<position>
<x>226.89999999999998</x>
<y>-439.8</y>
</position>
<width>954.6</width>
<height>53.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.41144162737828727</rotation>
<position>
<x>-343.3</x>
<y>-43.00000000000001</y>
</position>
<width>39.300000000000004</width>
<height>185.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-314.75</x>
<y>-112.75</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>228.7</x>
<y>-400.55</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>309.1</x>
<y>-382.65</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-280.70000000000005</x>
<y>-531.05</y>
</position>
<width>21.400000000000002</width>
<height>21.400000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-384.45</x>
<y>46.349999999999994</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-307.54999999999995</x>
<y>-205.7</y>
</position>
<width>32.2</width>
<height>32.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-327.20000000000005</x>
<y>-282.6</y>
</position>
<width>21.5</width>
<height>21.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-362.95</x>
<y>-329</y>
</position>
<width>14.3</width>
<height>14.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.5364578174643075</rotation>
<position>
<x>-334.40000000000015</x>
<y>-541.7499999999999</y>
</position>
<width>25.3</width>
<height>27.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<JointedDynamicRectangle id="0">
<rotation>-1.578258831084456</rotation>
<position>
<x>1.0999999999999432</x>
<y>67.50000000000001</y>
</position>
<width>114.4</width>
<height>20</height>
<goalBlock>true</goalBlock>
<joints/>
</JointedDynamicRectangle>
</playerBlocks>
<start>
<position>
<x>1.3</x>
<y>-11</y>
</position>
<width>517</width>
<height>338.3</height>
</start>
<end>
<position>
<x>400.40000000000003</x>
<y>93.65</y>
</position>
<width>37.2</width>
<height>124.4</height>
</end>
</level>
</retrieveLevel>
</level17>
<level18>
<retrieveLevel>
<levelId>76</levelId>
<levelNumber>18</levelNumber>
<name>Tube</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>25.449999999999932</x>
<y>156.20000000000007</y>
</position>
<width>50.2</width>
<height>859.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>192.40000000000003</x>
<y>164.95000000000005</y>
</position>
<width>50.3</width>
<height>875.9000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>231.65000000000006</x>
<y>-93.90000000000003</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-17.749999999999936</x>
<y>219.45000000000005</y>
</position>
<width>27.200000000000003</width>
<height>27.200000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>212.05000000000013</x>
<y>584.3999999999999</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>1.0000000000000906</x>
<y>586.0999999999999</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>0.29999999999999716</x>
<y>-181.85000000000005</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>219.15000000000006</x>
<y>-145.3</y>
</position>
<width>22.200000000000003</width>
<height>22.200000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>109.80000000000003</x>
<y>404.3</y>
</position>
<width>17</width>
<height>17</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>108.85000000000001</x>
<y>413.40000000000003</y>
</position>
<width>180.8</width>
<height>306.2</height>
</start>
<end>
<position>
<x>111.95</x>
<y>-192.55</y>
</position>
<width>167.3</width>
<height>156.20000000000002</height>
</end>
</level>
</retrieveLevel>
</level18>
<level19>
<retrieveLevel>
<levelId>60</levelId>
<levelNumber>19</levelNumber>
<name>Back and Forth</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>94.40000000000003</x>
<y>268.75</y>
</position>
<width>504.1</width>
<height>52.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>281.95</x>
<y>317.40000000000003</y>
</position>
<width>105.5</width>
<height>105.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.15533789293086786</rotation>
<position>
<x>637.4499999999999</x>
<y>341.75</y>
</position>
<width>332.70000000000005</width>
<height>95.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-157.95</x>
<y>333.79999999999995</y>
</position>
<width>92</width>
<height>92</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0.09327589932936298</rotation>
<position>
<x>57.79999999999998</x>
<y>369.8500000000001</y>
</position>
<width>448.3</width>
<height>65.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>52.099999999999994</x>
<y>316.54999999999995</y>
</position>
<width>454.6</width>
<height>100.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>493.75</x>
<y>453.3</y>
</position>
<width>28.700000000000003</width>
<height>149.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>630.35</x>
<y>494.9</y>
</position>
<width>31.6</width>
<height>241.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>666.3500000000003</x>
<y>404.3500000000001</y>
</position>
<width>10</width>
<height>60.400000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>565.6500000000001</x>
<y>417.25</y>
</position>
<width>31.700000000000003</width>
<height>74.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>738.25</x>
<y>410.1</y>
</position>
<width>25.9</width>
<height>164</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>790.05</x>
<y>473.4</y>
</position>
<width>34.6</width>
<height>241.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-330.6</x>
<y>46.05</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-254.35</x>
<y>-76.25</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.6264402302885688</rotation>
<position>
<x>-287.45000000000005</x>
<y>-21.6</y>
</position>
<width>152.5</width>
<height>28.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>886.45</x>
<y>-66.15</y>
</position>
<width>31.700000000000003</width>
<height>31.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>841.8</x>
<y>5.749999999999997</y>
</position>
<width>31.700000000000003</width>
<height>31.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.6105716305576829</rotation>
<position>
<x>869.1500000000001</x>
<y>-34.45</y>
</position>
<width>87.4</width>
<height>25.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-118.05</x>
<y>213.2</y>
</position>
<width>56.900000000000006</width>
<height>56.900000000000006</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>150</x>
<y>155.55</y>
</position>
<width>309.70000000000005</width>
<height>195.9</height>
</start>
<end>
<position>
<x>688.9000000000001</x>
<y>241.70000000000002</y>
</position>
<width>200</width>
<height>200</height>
</end>
</level>
</retrieveLevel>
</level19>
<level20>
<retrieveLevel>
<levelId>54</levelId>
<levelNumber>20</levelNumber>
<name>Unpossible</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>327</x>
<y>145</y>
</position>
<width>86</width>
<height>232</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>219</x>
<y>271</y>
</position>
<width>702</width>
<height>54</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>432.9</x>
<y>40</y>
</position>
<width>300</width>
<height>42</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>547.2</x>
<y>393.70000000000005</y>
</position>
<width>46.5</width>
<height>272.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.42337293418504707</rotation>
<position>
<x>428.7</x>
<y>327.05</y>
</position>
<width>263.6</width>
<height>43.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>130.65</x>
<y>367.29999999999995</y>
</position>
<width>42.2</width>
<height>194.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.2837730021668529</rotation>
<position>
<x>223.7</x>
<y>395.80000000000007</y>
</position>
<width>209.4</width>
<height>31.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>263.8</x>
<y>337.70000000000005</y>
</position>
<width>38</width>
<height>101.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.341047829634894</rotation>
<position>
<x>-100.74999999999999</x>
<y>337.74999999999994</y>
</position>
<width>27.5</width>
<height>114.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-78.64999999999998</x>
<y>362.00000000000006</y>
</position>
<width>35.9</width>
<height>160.70000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.6387545653136661</rotation>
<position>
<x>19.650000000000006</x>
<y>399.04999999999995</y>
</position>
<width>27.5</width>
<height>152.20000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>58.80000000000001</x>
<y>304.95000000000005</y>
</position>
<width>29.6</width>
<height>95.10000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-22.6</x>
<y>383.15</y>
</position>
<width>27.5</width>
<height>219.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-186.45000000000002</x>
<y>25.900000000000013</y>
</position>
<width>139.6</width>
<height>38.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.4679534168639694</rotation>
<position>
<x>-196.99999999999997</x>
<y>86.15000000000003</y>
</position>
<width>33.800000000000004</width>
<height>158.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.4865762139617804</rotation>
<position>
<x>-245.60000000000002</x>
<y>-14.299999999999983</y>
</position>
<width>23.200000000000003</width>
<height>112.10000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-220.25000000000003</x>
<y>81.95000000000002</y>
</position>
<width>21.1</width>
<height>95.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-235.05000000000004</x>
<y>-59.749999999999986</y>
</position>
<width>61.300000000000004</width>
<height>10.600000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>100</x>
<y>100</y>
</position>
<width>20.4</width>
<height>20.4</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>75</x>
<y>162</y>
</position>
<width>330</width>
<height>176</height>
</start>
<end>
<position>
<x>450</x>
<y>150</y>
</position>
<width>200</width>
<height>200</height>
</end>
</level>
</retrieveLevel>
</level20>
<level21>
<retrieveLevel>
<levelId>4575</levelId>
<levelNumber>21</levelNumber>
<name>U-Turn</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-60.900000000000006</x>
<y>-91.30000000000001</y>
</position>
<width>869.2</width>
<height>74.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-61.10000000000002</x>
<y>167.60000000000002</y>
</position>
<width>869.2</width>
<height>74.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-61.35000000000002</x>
<y>424.8</y>
</position>
<width>869.2</width>
<height>74.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>365.90000000000003</x>
<y>167.65000000000003</y>
</position>
<width>37.5</width>
<height>37.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-498.45</x>
<y>-91.25</y>
</position>
<width>38</width>
<height>38</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-498.35000000000014</x>
<y>167.50000000000003</y>
</position>
<width>38</width>
<height>38</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-492.65000000000003</x>
<y>424.8</y>
</position>
<width>38</width>
<height>38</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.057433946420220594</rotation>
<position>
<x>377.75000000000006</x>
<y>413.29999999999995</y>
</position>
<width>50.1</width>
<height>54.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.2188890647345736</rotation>
<position>
<x>412.3</x>
<y>407.6000000000001</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.3727196492481757</rotation>
<position>
<x>443.84999999999997</x>
<y>396.4</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.5501214374048453</rotation>
<position>
<x>476.85</x>
<y>379.59999999999997</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.6900361164950406</rotation>
<position>
<x>507.0000000000001</x>
<y>357.6</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.8042638494191203</rotation>
<position>
<x>530.3499999999999</x>
<y>336.8</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.9492195254248363</rotation>
<position>
<x>552.6999999999999</x>
<y>310.4</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.4676001575875561</rotation>
<position>
<x>569.9</x>
<y>281.4500000000001</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.3585090955969665</rotation>
<position>
<x>582.0500000000001</x>
<y>255.85</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.22619580274782458</rotation>
<position>
<x>592.5</x>
<y>220.1</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.12264364424939811</rotation>
<position>
<x>597.1000000000001</x>
<y>193.70000000000002</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>598.2</x>
<y>162.3</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.05887294616330241</rotation>
<position>
<x>596.5000000000001</x>
<y>132</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.14586641283292168</rotation>
<position>
<x>593.5</x>
<y>119.25</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.27362909316359363</rotation>
<position>
<x>586.2500000000002</x>
<y>90.05</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.35917800222360374</rotation>
<position>
<x>578.4</x>
<y>68.19999999999999</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.487147555620417</rotation>
<position>
<x>567.1500000000001</x>
<y>47.4</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.6550203157012948</rotation>
<position>
<x>546.9500000000002</x>
<y>17.100000000000005</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.795643706526244</rotation>
<position>
<x>522.75</x>
<y>-11.5</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.644438315641658</rotation>
<position>
<x>497.00000000000006</x>
<y>-33.400000000000006</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-1.0681021101544852</rotation>
<position>
<x>466.70000000000005</x>
<y>-51.949999999999996</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.3781423153226016</rotation>
<position>
<x>441.9500000000001</x>
<y>-65.35000000000001</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.2381962321567037</rotation>
<position>
<x>417.80000000000007</x>
<y>-73.25</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.20163119104657812</rotation>
<position>
<x>395.95000000000005</x>
<y>-77.80000000000001</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>375.70000000000005</x>
<y>-80.00000000000001</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>372.2</x>
<y>447.2</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>374.80000000000007</x>
<y>-110.10000000000001</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>431.1000000000001</x>
<y>-91.95</y>
</position>
<width>40.7</width>
<height>40.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>423.40000000000003</x>
<y>-137.65</y>
</position>
<width>16.900000000000002</width>
<height>16.900000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>466.70000000000016</x>
<y>-74.6</y>
</position>
<width>28.900000000000002</width>
<height>28.900000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>414.4000000000001</x>
<y>445.65000000000003</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>474.5000000000001</x>
<y>420.1</y>
</position>
<width>35.6</width>
<height>35.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>546.7500000000001</x>
<y>354.55</y>
</position>
<width>15.5</width>
<height>15.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>595.6499999999999</x>
<y>66.60000000000001</y>
</position>
<width>28.900000000000002</width>
<height>28.900000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.8079149353758508</rotation>
<position>
<x>575.2</x>
<y>384.50000000000006</y>
</position>
<width>12</width>
<height>80.80000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>604.3000000000001</x>
<y>413.19999999999993</y>
</position>
<width>12</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.29077191014988335</rotation>
<position>
<x>385.3500000000001</x>
<y>-177.10000000000002</y>
</position>
<width>12</width>
<height>104.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>371.40000000000003</x>
<y>-223.9</y>
</position>
<width>23.400000000000002</width>
<height>23.400000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-753.0500000000001</x>
<y>-28.400000000000002</y>
</position>
<width>82.9</width>
<height>82.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-800.6500000000001</x>
<y>-87.39999999999999</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-687.45</x>
<y>7.599999999999994</y>
</position>
<width>23.900000000000002</width>
<height>23.900000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-751.3500000000001</x>
<y>-99.25000000000004</y>
</position>
<width>34</width>
<height>34</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-680.4000000000002</x>
<y>-58.20000000000002</y>
</position>
<width>12</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.5874199932276543</rotation>
<position>
<x>-862.2</x>
<y>-122.25000000000003</y>
</position>
<width>12</width>
<height>111.80000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-900.15</x>
<y>-179.10000000000002</y>
</position>
<width>38</width>
<height>38</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0.7114652320242791</rotation>
<position>
<x>-832.95</x>
<y>-160.65</y>
</position>
<width>12</width>
<height>96.80000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-802.8500000000001</x>
<y>-193.5</y>
</position>
<width>12</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-743.8000000000001</x>
<y>367.15000000000003</y>
</position>
<width>27.6</width>
<height>27.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-762.9500000000002</x>
<y>355.4</y>
</position>
<width>12</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.23395050645486792</rotation>
<position>
<x>-736.35</x>
<y>391.55</y>
</position>
<width>12</width>
<height>42.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-728.85</x>
<y>417</y>
</position>
<width>17</width>
<height>17</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>10.850000000000044</x>
<y>535.0999999999999</y>
</position>
<width>33.5</width>
<height>33.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-19.549999999999997</x>
<y>529</y>
</position>
<width>16</width>
<height>16</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-231.65000000000003</x>
<y>-240.44999999999996</y>
</position>
<width>50.1</width>
<height>50.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0.008042722022367443</rotation>
<position>
<x>-170.35000000000002</x>
<y>-252.90000000000003</y>
</position>
<width>25</width>
<height>25</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-185.95</x>
<y>-265.35</y>
</position>
<width>18.8</width>
<height>18.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.06856778645581586</rotation>
<position>
<x>-107.89999999999999</x>
<y>-259.6</y>
</position>
<width>107.30000000000001</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-61.099999999999994</x>
<y>-252.20000000000005</y>
</position>
<width>20.3</width>
<height>20.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-47.55000000000002</x>
<y>-245.45000000000005</y>
</position>
<width>12</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-274.5</x>
<y>293.1</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-285.35</x>
<y>303.05</y>
</position>
<width>417.70000000000005</width>
<height>233.9</height>
</start>
<end>
<position>
<x>-285.85</x>
<y>34.95</y>
</position>
<width>415.8</width>
<height>211.9</height>
</end>
</level>
</retrieveLevel>
</level21>
</officialLevels>
);
}
public static function getLeveListXML():XML{
return (<levelList>
<levelCount>21</levelCount>
<level>
<levelName>Rolling Away</levelName>
<description>level 3!</description>
<levelId>91</levelId>
<levelNumber>1</levelNumber>
</level>
<level>
<levelName>Reach Up</levelName>
<description></description>
<levelId>55</levelId>
<levelNumber>2</levelNumber>
</level>
<level>
<levelName>Mind The Gap</levelName>
<description></description>
<levelId>16</levelId>
<levelNumber>3</levelNumber>
</level>
<level>
<levelName>Junkyard</levelName>
<description>j2</description>
<levelId>102</levelId>
<levelNumber>4</levelNumber>
</level>
<level>
<levelName>The Wall</levelName>
<description></description>
<levelId>31</levelId>
<levelNumber>5</levelNumber>
</level>
<level>
<levelName>On a Roll</levelName>
<description>medium</description>
<levelId>89</levelId>
<levelNumber>6</levelNumber>
</level>
<level>
<levelName>Full-up</levelName>
<description>easyish</description>
<levelId>88</levelId>
<levelNumber>7</levelNumber>
</level>
<level>
<levelName>Higher</levelName>
<description>6ish</description>
<levelId>86</levelId>
<levelNumber>8</levelNumber>
</level>
<level>
<levelName>Around the Bend</levelName>
<description></description>
<levelId>100</levelId>
<levelNumber>9</levelNumber>
</level>
<level>
<levelName>Up The Hump</levelName>
<description></description>
<levelId>17</levelId>
<levelNumber>10</levelNumber>
</level>
<level>
<levelName>Mission to Mars</levelName>
<description></description>
<levelId>62</levelId>
<levelNumber>11</levelNumber>
</level>
<level>
<levelName>Up The Stairs</levelName>
<description></description>
<levelId>19</levelId>
<levelNumber>12</levelNumber>
</level>
<level>
<levelName>Big Ball</levelName>
<description></description>
<levelId>23</levelId>
<levelNumber>13</levelNumber>
</level>
<level>
<levelName>Four Balls</levelName>
<description></description>
<levelId>20</levelId>
<levelNumber>14</levelNumber>
</level>
<level>
<levelName>Down Under</levelName>
<description></description>
<levelId>24</levelId>
<levelNumber>15</levelNumber>
</level>
<level>
<levelName>Awash</levelName>
<description></description>
<levelId>28</levelId>
<levelNumber>16</levelNumber>
</level>
<level>
<levelName>Handling</levelName>
<description></description>
<levelId>69</levelId>
<levelNumber>17</levelNumber>
</level>
<level>
<levelName>Tube</levelName>
<description></description>
<levelId>76</levelId>
<levelNumber>18</levelNumber>
</level>
<level>
<levelName>Back and Forth</levelName>
<description></description>
<levelId>60</levelId>
<levelNumber>19</levelNumber>
</level>
<level>
<levelName>Unpossible</levelName>
<description></description>
<levelId>54</levelId>
<levelNumber>20</levelNumber>
</level>
<level>
<levelName>U-Turn</levelName>
<description></description>
<levelId>4575</levelId>
<levelNumber>21</levelNumber>
</level>
</levelList>
);
}
}
}//package contraption.data
Section 101
//TutorialLevels (contraption.data.TutorialLevels)
package contraption.data {
public class TutorialLevels {
public function TutorialLevels(){
super();
}
public static function getTutorialLevels():XML{
return (<tutorialLevels>
<level1>
<retrieveLevel>
<levelId>264</levelId>
<tutorialNumber>1</tutorialNumber>
<name>How to Create</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-98</x>
<y>237</y>
</position>
<width>1128</width>
<height>180</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-101</x>
<y>106</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-151</x>
<y>51</y>
</position>
<width>258</width>
<height>208</height>
</start>
<end>
<position>
<x>217</x>
<y>66</y>
</position>
<width>170</width>
<height>198</height>
</end>
</level>
</retrieveLevel>
</level1>
<level2>
<retrieveLevel>
<levelId>266</levelId>
<tutorialNumber>2</tutorialNumber>
<name>How to Edit</name>
<level>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>176.89999999999998</x>
<y>360.2999999999999</y>
</position>
<width>1279.8000000000002</width>
<height>392.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-44.35000000000002</x>
<y>-81.35</y>
</position>
<width>240.8</width>
<height>277.40000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>271.84999999999997</x>
<y>112.05</y>
</position>
<width>159</width>
<height>238.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-566</x>
<y>-4.250000000000014</y>
</position>
<width>270.1</width>
<height>673.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-239.64999999999992</x>
<y>-251.45</y>
</position>
<width>630.8000000000001</width>
<height>437.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-209.35000000000008</x>
<y>120.30000000000004</y>
</position>
<width>41.900000000000006</width>
<height>41.900000000000006</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
<ClockwiseWheel id="1">
<rotation>0</rotation>
<position>
<x>-346.45000000000005</x>
<y>127.15000000000002</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>false</goalBlock>
<joints/>
</ClockwiseWheel>
<ClockwiseWheel id="2">
<rotation>0</rotation>
<position>
<x>-371.65</x>
<y>38.349999999999994</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>false</goalBlock>
<joints/>
</ClockwiseWheel>
<HollowRod id="3">
<rotation>0.4675831439645074</rotation>
<position>
<x>-290.5</x>
<y>79.32500000000002</y>
</position>
<width>181.81609527211825</width>
<height>4</height>
<goalBlock>false</goalBlock>
<joints>
<jointedTo>2</jointedTo>
<jointedTo>0</jointedTo>
</joints>
</HollowRod>
<HollowRod id="4">
<rotation>-2.0474725145327923</rotation>
<position>
<x>-359.05</x>
<y>82.75</y>
</position>
<width>54.92249083936378</width>
<height>4</height>
<goalBlock>false</goalBlock>
<joints>
<jointedTo>1</jointedTo>
<jointedTo>2</jointedTo>
</joints>
</HollowRod>
<HollowRod id="5">
<rotation>-0.07112268338379367</rotation>
<position>
<x>-278.37500000000006</x>
<y>123.72500000000002</y>
</position>
<width>96.39369792678355</width>
<height>4</height>
<goalBlock>false</goalBlock>
<joints>
<jointedTo>1</jointedTo>
<jointedTo>0</jointedTo>
</joints>
</HollowRod>
</playerBlocks>
<start>
<position>
<x>-301</x>
<y>41.85</y>
</position>
<width>274.8</width>
<height>280.1</height>
</start>
<end>
<position>
<x>146.55</x>
<y>-52.300000000000004</y>
</position>
<width>164.9</width>
<height>183.2</height>
</end>
</level>
</retrieveLevel>
</level2>
<level3>
<retrieveLevel>
<levelId>14</levelId>
<tutorialNumber>3</tutorialNumber>
<name>Easy As Pie</name>
<level>
<levelBlocks>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>83.94999999999997</x>
<y>278.80000000000007</y>
</position>
<width>108.1</width>
<height>108.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>395.65</x>
<y>180.3</y>
</position>
<width>630.7</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.3069971628664862</rotation>
<position>
<x>402.2000000000001</x>
<y>282.5</y>
</position>
<width>644.5</width>
<height>16.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.30900981675940253</rotation>
<position>
<x>259.8499999999999</x>
<y>277.4</y>
</position>
<width>362</width>
<height>100.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>314.3</x>
<y>214.6</y>
</position>
<width>438.3</width>
<height>68.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.30957547603700286</rotation>
<position>
<x>459.85</x>
<y>248.85000000000005</y>
</position>
<width>453.2000000000001</width>
<height>16.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.13568348287377818</rotation>
<position>
<x>661.6999999999998</x>
<y>190.3</y>
</position>
<width>75.2</width>
<height>23</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>544.2</x>
<y>202.2</y>
</position>
<width>133.6</width>
<height>45.900000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.2940495524427015</rotation>
<position>
<x>506.3</x>
<y>230.60000000000008</y>
</position>
<width>298.5</width>
<height>37.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>193.15000000000003</x>
<y>250.45</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>663.8000000000001</x>
<y>296.3</y>
</position>
<width>62.6</width>
<height>62.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.4269466595720473</rotation>
<position>
<x>548.9499999999999</x>
<y>296.90000000000003</y>
</position>
<width>243.5</width>
<height>29.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>557.9999999999998</x>
<y>343.65000000000003</y>
</position>
<width>235.8</width>
<height>31.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.3742209110809005</rotation>
<position>
<x>605.35</x>
<y>303.95000000000005</y>
</position>
<width>89.2</width>
<height>81.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>547.25</x>
<y>323.1000000000001</y>
</position>
<width>33.4</width>
<height>33.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>510.4500000000001</x>
<y>326.55000000000007</y>
</position>
<width>16.7</width>
<height>16.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>442.45</x>
<y>344.45</y>
</position>
<width>15.2</width>
<height>15.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>706.5500000000001</x>
<y>182.35</y>
</position>
<width>12.4</width>
<height>12.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.0015385844126063195</rotation>
<position>
<x>342.45000000000016</x>
<y>-39.8</y>
</position>
<width>473.8</width>
<height>27.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>200</x>
<y>144</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
<ClockwiseWheel id="1">
<rotation>0</rotation>
<position>
<x>115</x>
<y>145</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>false</goalBlock>
<joints/>
</ClockwiseWheel>
<ClockwiseWheel id="2">
<rotation>0</rotation>
<position>
<x>145.04999999999998</x>
<y>-79.55</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>false</goalBlock>
<joints/>
</ClockwiseWheel>
<NoSpinWheel id="3">
<rotation>0</rotation>
<position>
<x>227.55</x>
<y>-80.55</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>false</goalBlock>
<joints/>
</NoSpinWheel>
<SolidRod id="4">
<rotation>3.129472035047703</rotation>
<position>
<x>186.3</x>
<y>-80.05</y>
</position>
<width>82.5060603834652</width>
<height>8</height>
<goalBlock>false</goalBlock>
<joints>
<jointedTo>3</jointedTo>
<jointedTo>2</jointedTo>
</joints>
</SolidRod>
</playerBlocks>
<start>
<position>
<x>151.3</x>
<y>52.2</y>
</position>
<width>248.4</width>
<height>321.5</height>
</start>
<end>
<position>
<x>597.8000000000001</x>
<y>118.25</y>
</position>
<width>119.7</width>
<height>115.3</height>
</end>
</level>
</retrieveLevel>
</level3>
</tutorialLevels>
);
}
public static function getTutorialListXML():XML{
return (<tutorialLevelList>
<levelCount>3</levelCount>
<level>
<levelName>How to Create</levelName>
<description></description>
<levelId>264</levelId>
<tutorialNumber>1</tutorialNumber>
</level>
<level>
<levelName>How to Edit</levelName>
<description></description>
<levelId>266</levelId>
<tutorialNumber>2</tutorialNumber>
</level>
<level>
<levelName>Easy As Pie</levelName>
<description></description>
<levelId>14</levelId>
<tutorialNumber>3</tutorialNumber>
</level>
</tutorialLevelList>
);
}
}
}//package contraption.data
Section 102
//Button (contraption.menu.Button)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.display.*;
import flash.geom.*;
import flash.text.*;
public class Button extends MovieClip implements ActionContainer {
protected var buttonHeight:int;
public var userId:int;// = 0
public var tutorialNumber:int;// = 0
protected var isInitialized:Boolean;// = false
protected var downEvent:String;
protected var toolTip:String;
protected var overrideDownEvent:String;
public var levelNumber:int;// = 0
protected var buttonWidth:int;
public var userName:String;
protected var isEnabled:Boolean;// = true
public var designId:int;// = 0
protected var text:TextField;
public var levelId:int;// = 0
public function Button(text:String=""){
super();
gotoAndPlay(1);
addEventListener(MouseEvent.MOUSE_DOWN, buttonPress);
addEventListener(MouseEvent.ROLL_OVER, mouseOver);
addEventListener(MouseEvent.ROLL_OUT, mouseOut);
if (buttonWidth != 0){
initialize();
};
}
public function setToolTip(toolTip:String):void{
this.toolTip = toolTip;
}
protected function initialize():void{
if (isInitialized){
return;
};
graphics.beginFill(0, 0);
graphics.drawRect(0, 0, buttonWidth, buttonHeight);
isInitialized = true;
}
public function enable():void{
isEnabled = true;
transform.colorTransform = new ColorTransform(1, 1, 1, 1, 0, 0, 0, 0);
}
public function setDownEvent(event:String):void{
overrideDownEvent = event;
}
public function getAllowableActions():Actions{
var allowableActions:Actions = new Actions();
if (isEnabled){
allowableActions.button = true;
};
return (allowableActions);
}
protected function mouseOver(event:MouseEvent):void{
var tooltipEvent:TooltipEvent;
initialize();
if (toolTip){
tooltipEvent = new TooltipEvent(TooltipEvent.ADD_TOOLTIP, true, true);
tooltipEvent.toolTip = toolTip;
dispatchEvent(tooltipEvent);
};
}
public function setAllowableActions(actions:Actions):void{
}
protected function mouseOut(event:MouseEvent):void{
if (toolTip){
dispatchEvent(new TooltipEvent(TooltipEvent.REMOVE_TOOLTIP, true, true));
};
}
public function disable():void{
isEnabled = false;
var colourTransform:ColorTransform = new ColorTransform(0.8, 0.8, 0.8, 1, 0, 0, 0, 0);
transform.colorTransform = colourTransform;
}
protected function buttonPress(event:MouseEvent):void{
var menuEvent:MenuEvent;
if (!isEnabled){
return;
};
if (overrideDownEvent != null){
downEvent = overrideDownEvent;
};
if (downEvent != null){
menuEvent = new MenuEvent(downEvent, true, true);
menuEvent.levelId = levelId;
menuEvent.levelNumber = levelNumber;
menuEvent.tutorialNumber = tutorialNumber;
menuEvent.designId = designId;
menuEvent.userId = userId;
menuEvent.userName = userName;
dispatchEvent(menuEvent);
};
}
}
}//package contraption.menu
Section 103
//BuyGameMenu (contraption.menu.BuyGameMenu)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.display.*;
import flash.net.*;
import flash.external.*;
public class BuyGameMenu extends ModalMenu {
protected var canvas:Sprite;
public function BuyGameMenu():void{
super("", false);
var bg:MovieClip = new BuyMenuBackground();
bg.x = 100;
bg.y = 50;
addChild(bg);
canvas = new Sprite();
addChild(canvas);
setMenu();
}
protected function setMenu():void{
var user:User;
var text:TextArea;
var nameField:TextArea;
var emailField:TextArea;
var buyButton:Button;
var updateButton:Button;
var cancelButton:Button;
var loginButton:Button;
var newUserButton:Button;
removeChild(canvas);
canvas = new Sprite();
addChild(canvas);
user = User.getInstance();
text = new TextArea("", 14);
text.bold();
text.setHtmlText((((((("Thank you for playing Fantastic Contraption!\n" + "When you buy the full version for only $10 you:\n\n") + "<ul><li>Make your own levels</li>\n") + "<li>Share your levels with other people</li>\n") + "<li>Play levels other people have made</li>\n") + "<li>Support independent game deveopment</li>\n") + "<li>Get the really excelent full music</li></ul>"));
text.x = 160;
text.y = 125;
canvas.addChild(text);
if (user.isLoggedIn()){
text = new TextArea("Now Registering:", 14);
text.bold();
text.x = 160;
text.y = 250;
canvas.addChild(text);
text = new TextArea("User Name:", 14);
text.bold();
text.x = 170;
text.y = 270;
canvas.addChild(text);
text = new TextArea("Email:", 14);
text.bold();
text.x = 170;
text.y = 290;
canvas.addChild(text);
nameField = new TextArea(user.getUserName(), 14);
nameField.bold();
nameField.x = 260;
nameField.y = 270;
canvas.addChild(nameField);
emailField = new TextArea(user.getEmail(), 14);
emailField.bold();
emailField.x = 260;
emailField.y = 290;
canvas.addChild(emailField);
buyButton = new BuyGameButton();
buyButton.x = 280;
buyButton.y = 310;
canvas.addChild(buyButton);
buyButton.addEventListener(MenuEvent.BUY_GAME, buyGame);
updateButton = new UpdateUserInfoButton();
updateButton.x = 215;
updateButton.y = 375;
canvas.addChild(updateButton);
cancelButton = new SmallCancelButton();
cancelButton.x = 355;
cancelButton.y = 375;
canvas.addChild(cancelButton);
} else {
text = new TextArea("First you have to sign in or register (only takes a second)", 14);
text.bold();
text.x = 160;
text.y = 270;
canvas.addChild(text);
loginButton = new LogInButton();
loginButton.x = 215;
loginButton.y = 310;
canvas.addChild(loginButton);
newUserButton = new NewUserButton();
newUserButton.x = 355;
newUserButton.y = 310;
canvas.addChild(newUserButton);
cancelButton = new SmallCancelButton();
cancelButton.x = 355;
cancelButton.y = 375;
canvas.addChild(cancelButton);
};
}
override public function refresh():void{
setMenu();
}
protected function buyGame(event:Event):void{
event.stopPropagation();
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("http://FantasticContraption.com/buy.php");
var variables:URLVariables = new URLVariables();
variables.versionName = Contraption.VERSION_NAME;
variables.versionNumber = Contraption.VERSION_NUMBER;
request.data = variables;
request.method = URLRequestMethod.GET;
loader.load(request);
var user:User = User.getInstance();
request = new URLRequest("https://www.paypal.com/cgi-bin/webscr");
variables = new URLVariables();
variables.cmd = "_xclick";
variables.business = "sales@fantasticcontraption.com";
variables.item_name = "Fantastic Contraption";
variables.amount = "10.00";
variables.shipping = "0.00";
variables.no_shipping = "1";
variables.no_note = "1";
variables.currency_code = "USD";
variables.tax = "0.00";
variables.lc = "US";
variables.bn = "PP-BuyNowBF";
variables.on0 = "userID";
variables.os0 = user.getUserId();
request.data = variables;
request.method = URLRequestMethod.POST;
navigateToURL(request);
if (Contraption.VERSION_NAME == "fantasticcontraption.com"){
ExternalInterface.call("pageTracker._trackPageview", "/purchase");
};
}
}
}//package contraption.menu
Section 104
//CompletedLevelMenu (contraption.menu.CompletedLevelMenu)
package contraption.menu {
import flash.events.*;
public class CompletedLevelMenu extends ModalMenu {
protected var levelNumber:int;
protected var levelId:int;
public function CompletedLevelMenu(levelNumber:int, levelId:int):void{
var cancelButton:Button;
var menuButton:Button;
var saveButton:Button;
var nextLevel:Button;
super("Victory!");
this.levelNumber = levelNumber;
this.levelId = levelId;
if (levelId != 0){
if (levelNumber != 0){
nextLevel = new NextLevelButton();
nextLevel.x = 230;
nextLevel.y = 210;
addChild(nextLevel);
nextLevel.addEventListener(MenuEvent.LOAD_LEVEL, loadLevel);
};
menuButton = new BackToMenuButton();
menuButton.x = 370;
menuButton.y = 270;
addChild(menuButton);
menuButton.addEventListener(MenuEvent.MENU_BACK, backToMenu);
saveButton = new SmallSaveButton();
saveButton.x = 370;
saveButton.y = 210;
addChild(saveButton);
saveButton.addEventListener(MouseEvent.MOUSE_DOWN, save);
};
cancelButton = new SmallBackButton();
cancelButton.x = 230;
cancelButton.y = 270;
addChild(cancelButton);
}
protected function backToMenu(event:Event):void{
event.stopPropagation();
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK, true, true));
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK, true, true));
}
protected function save(event:Event):void{
dispatchEvent(new SaveEvent(MenuEvent.SAVE_CONTRAPTION, true, true));
}
protected function loadLevel(event:Event):void{
event.stopPropagation();
var levelEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_OFFICIAL_LEVEL, true, true);
levelEvent.levelNumber = (levelNumber + 1);
dispatchEvent(levelEvent);
}
}
}//package contraption.menu
Section 105
//CompletedTutorialLevelMenu (contraption.menu.CompletedTutorialLevelMenu)
package contraption.menu {
import flash.events.*;
public class CompletedTutorialLevelMenu extends ModalMenu {
protected var tutorialNumber:int;
public function CompletedTutorialLevelMenu(tutorialNumber:int):void{
var menuButton:Button;
var text:TextArea;
super("Victory!");
this.tutorialNumber = tutorialNumber;
var nextLevel:Button = new ContinueTutorialButton();
nextLevel.x = 220;
nextLevel.y = 300;
addChild(nextLevel);
if (tutorialNumber < 3){
nextLevel.addEventListener(MouseEvent.MOUSE_DOWN, loadTutorial);
text = new TextArea();
text.setText(("You have finished this tutorial level.\n" + "Let's move on to the next one."));
text.x = 0xFF;
text.y = 200;
addChild(text);
} else {
nextLevel.addEventListener(MouseEvent.MOUSE_DOWN, startLevels);
text = new TextArea();
text.setText((("Congratulations!\nYou've finished the tutorials.\n" + "From here on you're on your own.\n") + "Good luck and have fun!"));
text.x = 0xFF;
text.y = 190;
addChild(text);
};
menuButton = new BackToMenuButton();
menuButton.x = 370;
menuButton.y = 300;
addChild(menuButton);
menuButton.addEventListener(MenuEvent.MENU_BACK, backToMenu);
}
protected function startLevels(event:Event):void{
event.stopPropagation();
var levelEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_OFFICIAL_LEVEL, true, true);
levelEvent.levelNumber = 1;
dispatchEvent(levelEvent);
}
protected function backToMenu(event:Event):void{
event.stopPropagation();
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK, true, true));
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK, true, true));
}
protected function loadTutorial(event:Event):void{
event.stopPropagation();
var levelEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_TUTORIAL_LEVEL, true, true);
levelEvent.tutorialNumber = (tutorialNumber + 1);
dispatchEvent(levelEvent);
}
}
}//package contraption.menu
Section 106
//Dashboard (contraption.menu.Dashboard)
package contraption.menu {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class Dashboard extends MovieClip {
public var dynamicCircleButton:DashboardButton;
public var tooltip:TextField;
public var zoomOutButton:DashboardButton;
public var dynamicSquareButton:DashboardButton;
public var saveButton:DashboardButton;
protected var mode:String;
public var staticCircleButton:DashboardButton;
public var zoomInButton:DashboardButton;
public var hollowRodButton:DashboardButton;
public var goButton:DashboardButton;
public var staticSquareButton:DashboardButton;
protected var fatInitFunction:Function;
public var npWheelButton:DashboardButton;
public var stopButton:DashboardButton;
public var goalCircleButton:DashboardButton;
public var ccwWheelButton:DashboardButton;
public var cwWheelButton:DashboardButton;
public var deleteButton:DashboardButton;
public var goalSquareButton:DashboardButton;
public var testLevelButton:DashboardButton;
public var stopButtonPing:MovieClip;
public var moveButton:DashboardButton;
protected var hilightedButton:DashboardButton;
public var solidRodButton:DashboardButton;
public var backButton:DashboardButton;
public static const MODE_TEST_LEVEL:String = "testLevel";
public static const MODE_EDIT_LEVEL:String = "editLevel";
public static const MODE_EDIT_CONTRPATION:String = "editContraption";
public function Dashboard(mode:String="editContraption"){
super();
this.mode = mode;
addEventListener(MouseEvent.MOUSE_DOWN, buttonPress);
}
protected function init():void{
zoomInButton.init(DashboardEvent.ZOOM_IN, "Zoom In", this);
zoomOutButton.init(DashboardEvent.ZOOM_OUT, "Zoom Out", this);
if (mode == MODE_EDIT_LEVEL){
testLevelButton.init(DashboardEvent.TEST_LEVEL, "Make a test contraption to test your level", this);
goalCircleButton.init(DashboardEvent.GOAL_CIRCLE, "Goal Circle: these must be moved to the end area to win the level", this);
goalSquareButton.init(DashboardEvent.GOAL_SQUARE, "Goal Square: these must be moved to the end area to win the level", this);
staticCircleButton.init(DashboardEvent.STATIC_CIRCLE, "Static Circle: these form unmovable terrain", this);
staticSquareButton.init(DashboardEvent.STATIC_SQUARE, "Static Square: these form unmovable terrain", this);
dynamicCircleButton.init(DashboardEvent.DYNAMIC_CIRCLE, "Dynamic Circle: these form movable objects affected by gravity", this);
dynamicSquareButton.init(DashboardEvent.DYNAMIC_SQUARE, "Dynamic Square: these form movable objects affected by gravity", this);
} else {
goButton.init(DashboardEvent.GO, "Start contraption (Space)", this);
stopButton.init(DashboardEvent.STOP, "Stop and build contraption (Space)", this);
cwWheelButton.init(DashboardEvent.CW_WHEEL, "Clockwise wheels (W): will turn if a rod is connected to the center joint", this);
ccwWheelButton.init(DashboardEvent.CCW_WHEEL, "Counter-Clockwise wheels (C): will turn if a rod is connected to the center joint", this);
npWheelButton.init(DashboardEvent.NP_WHEEL, "Un-Powered wheels (U): will roll if pushed, but not on their own", this);
hollowRodButton.init(DashboardEvent.HOLLOW_ROD, "Water rod (R): can pass through other rods but not through the environment", this);
solidRodButton.init(DashboardEvent.SOLID_ROD, "Solid wood rods (S): will collide with other solid wood rods", this);
moveButton.init(DashboardEvent.MOVE, "Move stuff (Shift-click): click and drag to move", this);
deleteButton.init(DashboardEvent.DELETE, "Delete stuff (Ctrl-click): click near items to remove", this);
hilightButton(solidRodButton);
};
if (mode != MODE_TEST_LEVEL){
saveButton.init(DashboardEvent.SAVE, "Save your contraption online", this);
backButton.init(DashboardEvent.BACK, "Return to main menu: unsaved contraption will be lost!", this);
} else {
backButton.init(DashboardEvent.BACK, "Go back to editing level: this contraption can't be saved", this);
};
backButton.addEventListener(MouseEvent.MOUSE_DOWN, backButtonPress);
}
public function setMode(mode:String):void{
this.mode = mode;
}
protected function buttonPress(event:MouseEvent):void{
event.stopPropagation();
}
public function hilightButton(button:DashboardButton):void{
if (hilightedButton == button){
return;
};
if (hilightedButton != null){
hilightedButton.state = DashboardButton.UP;
};
button.state = DashboardButton.DOWN;
hilightedButton = button;
setTooltip(hilightedButton.tooltip);
}
public function setTooltip(text:String):void{
if (text == null){
if (hilightedButton != null){
tooltip.text = hilightedButton.tooltip;
} else {
tooltip.text = "";
};
} else {
tooltip.text = text;
};
}
protected function backButtonPress(event:MouseEvent):void{
var menuEvent:MenuEvent = new MenuEvent(MenuEvent.MENU_BACK, true, true);
dispatchEvent(menuEvent);
}
public function initFat():void{
fatInitFunction(mode);
}
public function pingStopButton():void{
stopButtonPing.gotoAndPlay(1);
}
}
}//package contraption.menu
Section 107
//DashboardButton (contraption.menu.DashboardButton)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.display.*;
public class DashboardButton extends SimpleButton implements ActionContainer {
protected var currentState:String;// = "up"
protected var dashboard:Dashboard;
public var eventType:String;// = null
protected var origUpState:DisplayObject;
public var tooltip:String;
public static const DOWN:String = "down";
public static const OVER:String = "over";
public static const UP:String = "up";
public function DashboardButton(){
super();
tabEnabled = false;
addEventListener(MouseEvent.MOUSE_DOWN, buttonPress);
}
public function set state(newState:String):void{
if (currentState == newState){
return;
};
currentState = newState;
if (origUpState == null){
origUpState = upState;
};
if (newState == "up"){
upState = origUpState;
} else {
if (newState == "over"){
upState = overState;
} else {
if (newState == "down"){
upState = downState;
};
};
};
}
protected function removeTooltip(event:Event):void{
dashboard.setTooltip(null);
}
protected function addTooltip(event:Event):void{
dashboard.setTooltip(tooltip);
}
public function init(eventType:String, tooltip:String, dashboard:Dashboard):void{
this.eventType = eventType;
this.tooltip = tooltip;
this.dashboard = dashboard;
overState.addEventListener(Event.ADDED_TO_STAGE, addTooltip);
downState.addEventListener(Event.ADDED_TO_STAGE, addTooltip);
upState.addEventListener(Event.ADDED_TO_STAGE, removeTooltip);
}
public function get state():String{
return (currentState);
}
public function getAllowableActions():Actions{
throw ("sad");
}
protected function buttonPress(event:MouseEvent):void{
var dashEvent:DashboardEvent = new DashboardEvent(eventType, true, true);
dispatchEvent(dashEvent);
}
public function setAllowableActions(actions:Actions):void{
}
}
}//package contraption.menu
Section 108
//DashboardEvent (contraption.menu.DashboardEvent)
package contraption.menu {
import flash.events.*;
public class DashboardEvent extends Event {
public static const STATIC_CIRCLE:String = "staticCircle";
public static const STOP:String = "stop";
public static const GOAL_CIRCLE:String = "goalCircle";
public static const ZOOM_OUT:String = "zoomOut";
public static const SAVE:String = "save";
public static const STATIC_SQUARE:String = "staticSquare";
public static const ZOOM_IN:String = "zoomIn";
public static const HOLLOW_ROD:String = "hollowRod";
public static const MOVE:String = "move";
public static const GOAL_SQUARE:String = "goalSquare";
public static const GO:String = "go";
public static const DELETE:String = "delete";
public static const CW_WHEEL:String = "cwWheel";
public static const SOLID_ROD:String = "solidRod";
public static const BACK:String = "back";
public static const TEST_LEVEL:String = "testLevel";
public static const CCW_WHEEL:String = "ccwWheel";
public static const DYNAMIC_SQUARE:String = "dynamicSquare";
public static const NP_WHEEL:String = "npWheel";
public static const DYNAMIC_CIRCLE:String = "dynamicCircle";
public function DashboardEvent(eventType:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(eventType, bubbles, cancelable);
}
override public function clone():Event{
return (new DashboardEvent(type));
}
}
}//package contraption.menu
Section 109
//DesignLinkMenu (contraption.menu.DesignLinkMenu)
package contraption.menu {
public class DesignLinkMenu extends ModalMenu {
public function DesignLinkMenu(designId:int):void{
super("Link");
var text:TextArea = new TextArea();
text.setText(((("Anyone who uses this link will \n" + "get to see your Fantastic Contraption.\n\n") + "You can copy and paste it to your friends,\n") + "post it on your blog, a forum, or whatever!"));
text.x = 230;
text.y = 190;
addChild(text);
text = new TextArea(("http://FantasticContraption.com/?designId=" + designId), 12);
text.mouseEnabled = true;
text.bold();
text.x = 230;
text.y = 290;
addChild(text);
var backButton:Button = new SmallBackButton();
backButton.x = 0xFF;
backButton.y = 320;
addChild(backButton);
}
}
}//package contraption.menu
Section 110
//LevelLinkMenu (contraption.menu.LevelLinkMenu)
package contraption.menu {
public class LevelLinkMenu extends ModalMenu {
public function LevelLinkMenu(levelId:int):void{
super("Link");
var text:TextArea = new TextArea();
text.setText(((("Anyone who uses this link will be \n" + "transported to this saved level.\n\n") + "You can copy and paste it to your friends,\n") + "post it on your blog, a forum, or whatever!"));
text.x = 230;
text.y = 190;
addChild(text);
text = new TextArea(("http://FantasticContraption.com/?levelId=" + levelId), 12);
text.mouseEnabled = true;
text.bold();
text.x = 230;
text.y = 290;
addChild(text);
var backButton:Button = new SmallBackButton();
backButton.x = 0xFF;
backButton.y = 320;
addChild(backButton);
}
}
}//package contraption.menu
Section 111
//LinkButton (contraption.menu.LinkButton)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.text.*;
public class LinkButton extends TextField implements ActionContainer {
protected var enabled:Boolean;// = true
protected var format:TextFormat;
protected var downEvent:String;
public var levelId:int;
public function LinkButton(text:String, textSize:int=13, font:String="arial", neverUnderline:Boolean=false):void{
super();
this.text = text;
textColor = 0xFF;
format = new TextFormat();
format.font = font;
format.bold = true;
format.size = textSize;
setTextFormat(format);
autoSize = "left";
selectable = false;
if (!neverUnderline){
addEventListener(MouseEvent.ROLL_OVER, mouseOver);
addEventListener(MouseEvent.ROLL_OUT, mouseOut);
};
addEventListener(MouseEvent.MOUSE_DOWN, buttonPress);
}
public function enable():void{
textColor = 0xFF;
enabled = true;
}
public function disable():void{
textColor = 0xDDDDDD;
enabled = false;
}
protected function mouseOut(event:MouseEvent):void{
removeUnderline();
}
public function addUnderline():void{
format.underline = true;
setTextFormat(format);
}
public function removeUnderline():void{
format.underline = false;
setTextFormat(format);
}
protected function buttonPress(event:MouseEvent):void{
var menuEvent:MenuEvent;
if (downEvent != null){
menuEvent = new MenuEvent(downEvent, true, true);
menuEvent.levelId = levelId;
dispatchEvent(menuEvent);
};
}
public function getAllowableActions():Actions{
var allowableActions:Actions = new Actions();
if (enabled){
allowableActions.button = true;
};
return (allowableActions);
}
public function setDownEvent(event:String):void{
downEvent = event;
}
protected function mouseOver(event:MouseEvent):void{
addUnderline();
}
public function setAllowableActions(actions:Actions):void{
}
}
}//package contraption.menu
Section 112
//LinkedIntoBadLevelMenu (contraption.menu.LinkedIntoBadLevelMenu)
package contraption.menu {
import flash.display.*;
public class LinkedIntoBadLevelMenu extends ModalMenu {
protected var canvas:Sprite;
public function LinkedIntoBadLevelMenu():void{
var buyButton:Button;
super("Restricted");
var text:TextArea = new TextArea();
text.setText(((("Sorry! You need to buy the full version of the \n" + "game to see solutions to this player-made level.\n\n") + "But you can still play the game!\n") + "Or you can register for $10 and have\nfull access to The Fantastic Contraption."));
text.x = 230;
text.y = 190;
addChild(text);
var playGameButton:Button = new PlayGameButton();
playGameButton.x = 230;
playGameButton.y = 310;
addChild(playGameButton);
buyButton = new BuyGameButton();
buyButton.x = 360;
buyButton.y = 310;
addChild(buyButton);
}
}
}//package contraption.menu
Section 113
//LinkInMenu (contraption.menu.LinkInMenu)
package contraption.menu {
import flash.events.*;
import flash.display.*;
public class LinkInMenu extends ModalMenu {
protected var canvas:Sprite;
public function LinkInMenu():void{
var backButton:Button;
super("Welcome");
addChild(new LinkedInOverlay());
var text:TextArea = new TextArea((((("Welcome to Fantastic Contraption!\n\n" + "Someone built this machine and thought you'd \nlike it. ") + "Press continue and then the start button \nto watch it go. ") + "To play the game and make your \nown contraptions, ") + "press the red back arrow."));
text.x = 230;
text.y = 190;
text.width = 430;
text.height = 400;
addChild(text);
backButton = new ContinueButton();
backButton.x = 270;
backButton.y = 310;
addChild(backButton);
backButton.addEventListener(MenuEvent.MENU_BACK, closeMenu);
}
public function closeMenu(event:Event):void{
event.stopPropagation();
parent.removeChild(this);
}
}
}//package contraption.menu
Section 114
//LogInMenu (contraption.menu.LogInMenu)
package contraption.menu {
import flash.events.*;
import contraption.*;
public class LogInMenu extends ModalMenu {
protected var passwordField:TextBox;
protected var validationError:TextArea;
protected var nameField:TextBox;
public function LogInMenu():void{
var text:TextArea;
var resetButton:LinkButton;
super("Sign In");
validationError = new TextArea("");
validationError.x = 250;
validationError.y = 0xFF;
validationError.textColor = 16720418;
validationError.width = 250;
addChild(validationError);
text = new TextArea("User Name:");
text.x = 250;
text.y = 190;
addChild(text);
text = new TextArea("Password:");
text.x = 250;
text.y = 220;
addChild(text);
nameField = new TextBox(100, 20, 15);
nameField.x = 330;
nameField.y = 190;
addChild(nameField);
passwordField = new TextBox(100, 20, 15, true);
passwordField.x = 330;
passwordField.y = 220;
addChild(passwordField);
var loginButton:Button = new LogInButton();
loginButton.x = 230;
loginButton.y = 280;
addChild(loginButton);
loginButton.addEventListener(MenuEvent.LOG_IN, login);
var cancelButton:Button = new SmallCancelButton();
cancelButton.x = 360;
cancelButton.y = 280;
addChild(cancelButton);
resetButton = new LinkButton("forgot your password?");
resetButton.width = 200;
resetButton.x = 295;
resetButton.y = 335;
addChild(resetButton);
resetButton.addEventListener(MouseEvent.MOUSE_DOWN, resetPassword);
}
override public function disposeMenu():void{
var user:User = User.getInstance();
user.removeEventListener(MenuEvent.LOGGED_IN, loginComplete);
user.removeEventListener(MenuEvent.LOG_IN_FAILED, loginFailed);
user.removeEventListener(MenuEvent.ADD_SPINNER, addSpinner);
user.removeEventListener(MenuEvent.REMOVE_SPINNER, removeSpinner);
}
protected function loginComplete(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK, true, true));
dispatchEvent(new MenuEvent(MenuEvent.LOGGED_IN, true, true));
}
protected function loginFailed(event:Event):void{
validationError.text = "Oops, Wrong user name or password";
}
protected function login(event:MenuEvent):void{
event.stopPropagation();
validationError.text = "";
var user:User = User.getInstance();
user.addEventListener(MenuEvent.LOGGED_IN, loginComplete, false, 0, true);
user.addEventListener(MenuEvent.LOG_IN_FAILED, loginFailed, false, 0, true);
user.addEventListener(MenuEvent.ADD_SPINNER, addSpinner, false, 0, true);
user.addEventListener(MenuEvent.REMOVE_SPINNER, removeSpinner, false, 0, true);
user.logIn(nameField.getText(), passwordField.getText());
}
protected function resetPassword(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.RESET_PASSWORD));
}
}
}//package contraption.menu
Section 115
//LoginPanel (contraption.menu.LoginPanel)
package contraption.menu {
import contraption.*;
import flash.display.*;
public class LoginPanel extends Sprite {
protected var userNameField:TextArea;
protected var loggedOutPanel:Sprite;
protected var loggedInPanel:Sprite;
public function LoginPanel(){
var button:Button;
super();
loggedInPanel = new Sprite();
addChild(loggedInPanel);
loggedOutPanel = new Sprite();
addChild(loggedOutPanel);
button = new LogInButton();
button.x = 10;
button.y = 100;
loggedOutPanel.addChild(button);
button = new NewUserButton();
button.x = 10;
button.y = 160;
loggedOutPanel.addChild(button);
userNameField = new TextArea("", 12);
userNameField.x = 15;
userNameField.y = 10;
userNameField.textColor = 0x663300;
userNameField.bold();
loggedInPanel.addChild(userNameField);
button = new LogOutButton();
button.x = 10;
button.y = 100;
loggedInPanel.addChild(button);
button = new UpdateUserInfoButton();
button.x = 10;
button.y = 160;
loggedInPanel.addChild(button);
setPanel();
}
protected function setPanel():void{
var user:User = User.getInstance();
loggedInPanel.visible = false;
loggedOutPanel.visible = false;
if (user.isLoggedIn()){
loggedInPanel.visible = true;
userNameField.setText(user.getUserName());
} else {
loggedOutPanel.visible = true;
};
}
public function refresh():void{
setPanel();
}
}
}//package contraption.menu
Section 116
//LostPasswordMenu (contraption.menu.LostPasswordMenu)
package contraption.menu {
import flash.events.*;
import contraption.*;
public class LostPasswordMenu extends ModalMenu {
protected var validationError:TextArea;
protected var emailField:TextBox;
protected var nameField:TextBox;
public function LostPasswordMenu():void{
var text:TextArea;
super("Lost Pass");
validationError = new TextArea("");
validationError.x = 230;
validationError.y = 190;
validationError.textColor = 16720418;
validationError.width = 250;
addChild(validationError);
text = new TextArea("User Name:");
text.x = 270;
text.y = 220;
addChild(text);
text = new TextArea("Email Address:");
text.x = 250;
text.y = 250;
addChild(text);
nameField = new TextBox(100, 20, 15);
nameField.x = 350;
nameField.y = 220;
addChild(nameField);
emailField = new TextBox(150, 20, 100);
emailField.x = 350;
emailField.y = 250;
addChild(emailField);
var resetPasswordButton:Button = new ResetPasswordButton();
resetPasswordButton.x = 230;
resetPasswordButton.y = 300;
addChild(resetPasswordButton);
resetPasswordButton.addEventListener(MenuEvent.RESET_PASSWORD, resetPassword);
var cancelButton:Button = new SmallCancelButton();
cancelButton.x = 360;
cancelButton.y = 300;
addChild(cancelButton);
}
protected function resetComplete(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK, true, true));
}
protected function resetPassword(event:MenuEvent):void{
event.stopPropagation();
validationError.text = "";
var user:User = User.getInstance();
user.addEventListener(MenuEvent.RESET_PASSWORD, resetComplete, false, 0, true);
user.addEventListener(MenuEvent.RESET_PASSWORD_FAILED, resetFailed, false, 0, true);
user.resetPassword(nameField.getText(), emailField.getText());
}
protected function resetFailed(event:Event):void{
validationError.text = "The User Name and Email Address do not match";
}
}
}//package contraption.menu
Section 117
//MainMenu (contraption.menu.MainMenu)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.display.*;
import flash.net.*;
import contraption.data.*;
public class MainMenu extends MenuWindow {
protected var savedDesignsButton:Button;
protected var learnToPlayButton:Button;
protected var pagingData:PagingData;
protected var pageCount:TextArea;
protected var loginPanel:LoginPanel;
protected var regButton:SimpleButton;
protected var levelsCanvas:Sprite;
protected var savedLevelsButton:Button;
protected var viewingSolutions:Boolean;// = false
public function MainMenu():void{
var button:Button;
loginPanel = new LoginPanel();
super(false);
addChild(new MenuBackground());
addChild(new MainMenuButtons());
loginPanel = new LoginPanel();
addChild(loginPanel);
learnToPlayButton = new LearnToPlayButton();
learnToPlayButton.x = 427;
learnToPlayButton.y = 165;
addChild(learnToPlayButton);
learnToPlayButton.addEventListener(MouseEvent.MOUSE_DOWN, previousPage, false, 0, true);
pageCount = new TextArea();
pageCount.x = 390;
pageCount.y = 155;
pageCount.bold();
pageCount.textColor = 0x663300;
addChild(pageCount);
button = new PreviousPageButton();
button.x = 340;
button.y = 150;
addChild(button);
button.addEventListener(MouseEvent.MOUSE_DOWN, previousPage, false, 0, true);
button = new NextPageButton();
button.x = 480;
button.y = 150;
addChild(button);
button.addEventListener(MouseEvent.MOUSE_DOWN, nextPage, false, 0, true);
addEventListener(MenuEvent.LOGGED_OUT, setLoginPanel, false, 0, true);
addEventListener(MenuEvent.LOG_OUT, logOut, false, 0, true);
setRegButton();
pagingData = new PagingData(11);
levelsCanvas = new Sprite();
addChild(levelsCanvas);
listLevels();
}
protected function loadEditor(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.LOAD_EDITOR));
}
protected function renderButtons(levels:XML):void{
var i:int;
var level:XML;
var solvedLevel:Boolean;
var levelButton:Button;
var tutorialButton:Button;
var startHere:StartHere;
var designLink:LinkButton;
pagingData.numResults = levels.levelCount;
pageCount.setText(((("Page " + (pagingData.currentPage + 1)) + " of ") + pagingData.getNumPages()));
learnToPlayButton.visible = false;
removeChild(levelsCanvas);
levelsCanvas = new Sprite();
addChild(levelsCanvas);
var userCookie:SharedObject = SharedObject.getLocal("user");
if (pagingData.currentPage == 0){
i = 1;
} else {
i = 0;
};
var levelNum:int = pagingData.getOffset();
while ((((levelNum < (pagingData.getOffset() + pagingData.resultsPerPage))) && ((levelNum < levels.levelCount)))) {
level = levels.level[levelNum];
solvedLevel = (userCookie.data[("level" + level.levelId)] == "true");
if (levelNum == 1){
tutorialButton = new OfficialLevelButton(0, 0, "", (userCookie.data["level14"] == "true"));
tutorialButton.setDownEvent(MenuEvent.LOAD_TUTORIALS);
tutorialButton.x = 250;
tutorialButton.y = 200;
levelsCanvas.addChild(tutorialButton);
startHere = new StartHere();
tutorialButton.addChild(startHere);
startHere.x = 40;
startHere.y = 5;
};
levelButton = new OfficialLevelButton(level.levelId, level.levelNumber, level.levelName, solvedLevel);
levelButton.x = (250 + ((i % 2) * 220));
levelButton.y = (200 + (Math.floor((i / 2)) * 47));
levelsCanvas.addChild(levelButton);
if (solvedLevel){
designLink = new LinkButton("Other Players' Designs", 12, "contraptionFont");
designLink.embedFonts = true;
designLink.textColor = 0x663300;
designLink.x = (levelButton.x + 45);
designLink.y = (levelButton.y + 27);
levelsCanvas.addChild(designLink);
designLink.levelId = level.levelId;
designLink.setDownEvent(MenuEvent.LOAD_LEVEL_SOLUTIONS);
};
i++;
levelNum++;
};
finishedLoading();
}
protected function loadSolutions(event:MenuEvent):void{
dispatchEvent(event);
}
protected function loadUserGenLevels(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.LOAD_USER_GENERATED_LEVELS));
}
protected function loadSavedLevels(event:Event):void{
var user:User = User.getInstance();
var menuEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_SAVED_LEVELS);
menuEvent.userId = user.getUserId();
menuEvent.userName = user.getUserName();
dispatchEvent(menuEvent);
}
override public function refresh():void{
User.getInstance().refreshRegistered();
loginPanel.refresh();
setRegButton();
listLevels();
}
protected function setLoginPanel(event:Event):void{
loginPanel.refresh();
}
protected function setRegButton():void{
var linkBackButton:SimpleButton;
if (!Contraption.INCLUDE_PAYPAL_LINKS){
linkBackButton = new LinkBackButton();
addChild(linkBackButton);
linkBackButton.addEventListener(MouseEvent.MOUSE_DOWN, linkToSite);
return;
};
if (((!(User.getInstance().isRegistered())) && ((regButton == null)))){
regButton = new FullVersionButton();
addChild(regButton);
regButton.addEventListener(MouseEvent.MOUSE_DOWN, registerMenu, false, 0, true);
};
if (((User.getInstance().isRegistered()) && (!((regButton == null))))){
removeChild(regButton);
regButton = null;
};
}
protected function nextPage(event:Event):void{
if (pagingData.currentPage < (pagingData.getNumPages() - 1)){
pagingData.currentPage++;
};
listLevels();
}
protected function logOut(event:Event):void{
User.getInstance().logOut();
dispatchEvent(new MenuEvent(MenuEvent.LOGGED_OUT, true, true));
}
protected function listLevels():void{
renderButtons(OfficialLevels.getLeveListXML());
}
protected function registerMenu(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.BUY_GAME));
}
protected function loadSavedDesigns(event:Event):void{
var user:User = User.getInstance();
var menuEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_SAVED_DESIGNS);
menuEvent.userId = user.getUserId();
menuEvent.userName = user.getUserName();
dispatchEvent(menuEvent);
}
protected function previousPage(event:Event):void{
if (pagingData.currentPage > 0){
pagingData.currentPage--;
};
listLevels();
}
public function linkToSite(event:Event):void{
var request:URLRequest = new URLRequest("http://fantasticcontraption.com");
navigateToURL(request);
}
protected function loadLevel(event:Event):void{
event.stopPropagation();
var menuEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_LEVEL);
menuEvent.levelId = event.target.levelId;
dispatchEvent(menuEvent);
}
}
}//package contraption.menu
Section 118
//MenuEvent (contraption.menu.MenuEvent)
package contraption.menu {
import flash.events.*;
public class MenuEvent extends Event {
public var userId:int;
public var tutorialNumber:int;
public var levelNumber:int;
public var userName:String;
public var designId:int;
public var levelId:int;
public static const LOAD_SAVED_LEVELS:String = "loadSavedLevels";
public static const CURTAIN_OPEN_COMPLETE:String = "curtainOpenComplete";
public static const LOGGED_IN:String = "loggedIn";
public static const LOAD_LEVEL_SOLUTIONS:String = "loadLevelSolutions";
public static const LOAD_OFFICIAL_LEVEL:String = "loadOfficialLevel";
public static const RETURN_TO_MAIN_MENU:String = "returnToMainMenu";
public static const LOG_OUT:String = "logOut";
public static const LOAD_LEVEL_LINK_MENU:String = "loadLevelLinkMenu";
public static const LOAD_USER_GENERATED_LEVELS:String = "loadUserGeneratedLevels";
public static const LOAD_LINKED_IN_MENU:String = "loadLinkedInMenu";
public static const LOAD_TUTORIALS:String = "loadTutorials";
public static const LOG_IN:String = "logIn";
public static const CHANGE_GRAPHICS_OPTION:String = "changeGraphicsOption";
public static const NEW_USER:String = "newUser";
public static const RESET_PASSWORD:String = "resetPassword";
public static const UPDATE_USER_INFO:String = "updateUserInfo";
public static const BUY_GAME:String = "buyGame";
public static const TUTORIAL_LEVEL_COMPLETE:String = "tutorialLevelComplete";
public static const LOAD_DESIGN:String = "loadDesign";
public static const LOAD_USER_MENU:String = "loadUserMenu";
public static const LEVEL_COMPLETE:String = "levelComplete";
public static const LOG_IN_FAILED:String = "loginFailed";
public static const REMOVE_SPINNER:String = "removeSpinner";
public static const TRY_LEVEL:String = "tryLevel";
public static const LOAD_TUTORIAL_LEVEL:String = "loadTutorialLevel";
public static const ADD_SPINNER:String = "addSpinner";
public static const LOAD_LEVEL:String = "loadLevel";
public static const MENU_BACK:String = "menuBack";
public static const FINISHED_LOADING:String = "finishLoading";
public static const DELETE_LEVEL:String = "deleteLevel";
public static const RESET_PASSWORD_FAILED:String = "resetPasswordFailed";
public static const DELETE_DESIGN:String = "deleteDesign";
public static const SAVE_CONTRAPTION:String = "saveDesign";
public static const LOAD_SAVED_DESIGNS:String = "loadSavedDesigns";
public static const LOAD_EDITOR:String = "loadEditor";
public static const EDIT_LEVEL:String = "editLevel";
public static const LOGGED_OUT:String = "loggedOut";
public static const LOAD_DESIGN_LINK_MENU:String = "loadDesignLinkMenu";
public static const OPEN_CURTAIN:String = "openCurtain";
public function MenuEvent(eventType:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(eventType, bubbles, cancelable);
}
override public function clone():Event{
var e:MenuEvent = new MenuEvent(type, bubbles, cancelable);
e.levelId = levelId;
e.levelNumber = levelNumber;
e.tutorialNumber = tutorialNumber;
e.designId = designId;
e.userId = userId;
e.userName = userName;
return (e);
}
}
}//package contraption.menu
Section 119
//MenuWindow (contraption.menu.MenuWindow)
package contraption.menu {
import flash.events.*;
import contraption.*;
public class MenuWindow extends ActionContainerImpl {
public function MenuWindow(showReturnButtons:Boolean=true){
super();
if (showReturnButtons){
addChild(new MenuBackground());
addChild(new MenuTopButtons());
};
}
protected function returnToMainMenu(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.RETURN_TO_MAIN_MENU));
}
public function removeSpinner(event:Event=null):void{
dispatchEvent(new MenuEvent(MenuEvent.REMOVE_SPINNER, true, true));
}
protected function menuBack(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK));
}
public function addSpinner(event:Event=null):void{
dispatchEvent(new MenuEvent(MenuEvent.ADD_SPINNER, true, true));
}
public function finishedLoading():void{
dispatchEvent(new MenuEvent(MenuEvent.FINISHED_LOADING));
}
public function refresh():void{
}
public function disposeMenu():void{
}
}
}//package contraption.menu
Section 120
//ModalMenu (contraption.menu.ModalMenu)
package contraption.menu {
import flash.events.*;
import flash.display.*;
public class ModalMenu extends MenuWindow {
public function ModalMenu(title:String, defaultBackground:Boolean=true){
var backgroundClip:MovieClip;
var text:TextArea;
super(false);
graphics.beginFill(0xFFFFFF, 0.4);
graphics.drawRect(0, 0, 700, 500);
if (defaultBackground){
backgroundClip = new ModalMenuCloud();
backgroundClip.x = 100;
backgroundClip.y = 50;
addChild(backgroundClip);
text = new TextArea(title, 30, "contraptionFont", "center");
text.embedFonts = true;
text.bold();
text.width = 200;
text.x = 215;
text.y = 130;
addChild(text);
};
addEventListener(MouseEvent.MOUSE_DOWN, stopEvent);
}
protected function stopEvent(event:Event):void{
event.stopPropagation();
}
}
}//package contraption.menu
Section 121
//MouseBlockingBackground (contraption.menu.MouseBlockingBackground)
package contraption.menu {
import contraption.*;
public class MouseBlockingBackground extends ActionContainerImpl {
public function MouseBlockingBackground(){
super();
}
override public function getAllowableActions():Actions{
var allowableActions:Actions = new Actions();
return (allowableActions);
}
}
}//package contraption.menu
Section 122
//MuteButton (contraption.menu.MuteButton)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.display.*;
public class MuteButton extends Button {
protected var buttonGraphics:SimpleButton;
public function MuteButton(){
super();
buttonWidth = 25;
buttonHeight = 25;
buttonGraphics = new SoundOnButton();
addChild(buttonGraphics);
setButton();
}
override protected function buttonPress(event:MouseEvent):void{
var config:Configuration = Configuration.getInstance();
config.setMute(!(config.isMuted()));
setButton();
}
protected function setButton():void{
removeChild(buttonGraphics);
var mute:Boolean = Configuration.getInstance().isMuted();
Music.getInstance().setMute(mute);
if (mute){
buttonGraphics = new SoundOffButton();
} else {
buttonGraphics = new SoundOnButton();
};
addChild(buttonGraphics);
}
}
}//package contraption.menu
Section 123
//NewUserMenu (contraption.menu.NewUserMenu)
package contraption.menu {
import flash.events.*;
import contraption.*;
public class NewUserMenu extends ModalMenu {
protected var passwordField:TextBox;
protected var nameField:TextBox;
protected var emailField:TextBox;
protected var validationError:TextArea;
protected var confirmPasswordField:TextBox;
public function NewUserMenu():void{
var text:TextArea;
var newUserButton:Button;
super("New User");
validationError = new TextArea("");
validationError.x = 275;
validationError.y = 170;
validationError.textColor = 16720418;
validationError.width = 250;
validationError.height = 50;
addChild(validationError);
text = new TextArea("User Name:");
text.x = 270;
text.y = 200;
addChild(text);
text = new TextArea("Email Address:");
text.x = 250;
text.y = 230;
addChild(text);
text = new TextArea("Password:");
text.x = 275;
text.y = 260;
addChild(text);
text = new TextArea("Confirm Password:");
text.x = 230;
text.y = 290;
addChild(text);
nameField = new TextBox(100, 20, 15);
nameField.x = 350;
nameField.y = 200;
addChild(nameField);
emailField = new TextBox(150, 20, 100);
emailField.x = 350;
emailField.y = 230;
addChild(emailField);
passwordField = new TextBox(100, 20, 15, true);
passwordField.x = 350;
passwordField.y = 260;
addChild(passwordField);
confirmPasswordField = new TextBox(100, 20, 15, true);
confirmPasswordField.x = 350;
confirmPasswordField.y = 290;
addChild(confirmPasswordField);
newUserButton = new NewUserButton();
newUserButton.x = 230;
newUserButton.y = 320;
addChild(newUserButton);
newUserButton.addEventListener(MenuEvent.NEW_USER, newUser);
var cancelButton:Button = new SmallCancelButton();
cancelButton.x = 360;
cancelButton.y = 320;
addChild(cancelButton);
}
protected function loginComplete(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK, true, true));
dispatchEvent(new MenuEvent(MenuEvent.LOGGED_IN));
}
protected function newUserFailed(event:Event):void{
validationError.text = "Aw, that user name is taken";
}
protected function isValidEmail(email:String):Boolean{
var emailExpression:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
return (emailExpression.test(email));
}
protected function newUser(event:MenuEvent):void{
event.stopPropagation();
if (!validate()){
return;
};
var user:User = User.getInstance();
user.addEventListener(MenuEvent.LOGGED_IN, loginComplete);
user.addEventListener(MenuEvent.LOG_IN_FAILED, newUserFailed);
user.newUser(nameField.getText(), emailField.getText(), passwordField.getText());
}
protected function validate():Boolean{
validationError.text = "";
if (!isValidEmail(emailField.getText())){
validationError.appendText("Invalid email address\n");
};
if (passwordField.getText() != confirmPasswordField.getText()){
validationError.appendText("Password fields do not match\n");
};
if (nameField.getText() == ""){
validationError.appendText("Please enter a user name\n");
};
return ((validationError.text == ""));
}
}
}//package contraption.menu
Section 124
//NoTabButton (contraption.menu.NoTabButton)
package contraption.menu {
import flash.display.*;
public class NoTabButton extends SimpleButton {
public function NoTabButton(){
super();
tabEnabled = false;
}
}
}//package contraption.menu
Section 125
//OfficialLevelButton (contraption.menu.OfficialLevelButton)
package contraption.menu {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class OfficialLevelButton extends Button {
protected var circle:SimpleButton;
protected var origCircleUpState:DisplayObject;
protected var nameLink:LinkButton;
protected var levelName:String;
public function OfficialLevelButton(levelId:int, levelNumber:int, levelName:String, solved:Boolean){
var numberText:TextArea;
buttonWidth = 200;
buttonHeight = 40;
this.levelId = levelId;
this.levelNumber = levelNumber;
this.levelName = levelName;
this.downEvent = MenuEvent.LOAD_OFFICIAL_LEVEL;
if (solved){
circle = new LevelCircleChecked();
} else {
circle = new LevelCircle();
};
circle.x = 20;
circle.y = 20;
origCircleUpState = circle.upState;
addChild(circle);
numberText = new TextArea(levelNumber.toString(), 18, "contraptionFont", TextFormatAlign.CENTER);
numberText.embedFonts = true;
numberText.width = 30;
numberText.x = 5;
numberText.y = 8;
addChild(numberText);
nameLink = new LinkButton(levelName, 18, "contraptionFont", true);
nameLink.embedFonts = true;
nameLink.textColor = 0;
nameLink.x = 45;
nameLink.y = 5;
addChild(nameLink);
super();
}
override protected function mouseOut(event:MouseEvent):void{
circle.upState = origCircleUpState;
nameLink.removeUnderline();
}
override protected function mouseOver(event:MouseEvent):void{
circle.upState = circle.overState;
nameLink.addUnderline();
}
}
}//package contraption.menu
Section 126
//PagingData (contraption.menu.PagingData)
package contraption.menu {
public class PagingData {
public var numResults:int;
public var resultsPerPage:int;
public var currentPage:int;
public function PagingData(resultsPerPage:int):void{
super();
this.numResults = 0;
this.resultsPerPage = resultsPerPage;
this.currentPage = 0;
}
public function getNumPages():int{
return (Math.ceil((numResults / resultsPerPage)));
}
public function getOffset():int{
return ((currentPage * resultsPerPage));
}
}
}//package contraption.menu
Section 127
//PleaseRegisterMenu (contraption.menu.PleaseRegisterMenu)
package contraption.menu {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public class PleaseRegisterMenu extends ModalMenu {
protected var canvas:Sprite;
public function PleaseRegisterMenu():void{
var backButton:Button;
var text:TextArea;
var linkButton:LinkButton;
super("Restricted");
if (Contraption.INCLUDE_PAYPAL_LINKS){
text = new TextArea(((("Sorry, you need to buy the full version first!\n\n" + "For $10 you can make your own levels, \nplay other player's new levels, ") + "and watch \nsolutions to player-made levels. \n\nYou'll also be ") + "helping to support independant \ngame development.\n\n"));
text.x = 250;
text.y = 175;
addChild(text);
} else {
text = new TextArea((("Sorry, you need to buy the full version first!\n\n" + "For $10 you can make your own levels, \nplay other player's new levels, ") + "and watch \nsolutions to player-made levels.\n\nPlay ad free and get the full version here:"));
text.x = 250;
text.y = 175;
addChild(text);
linkButton = new LinkButton("FantasticContraption.com");
linkButton.width = 200;
linkButton.x = 295;
linkButton.y = 297;
addChild(linkButton);
linkButton.addEventListener(MouseEvent.MOUSE_DOWN, linkToSite);
};
backButton = new SmallBackButton();
backButton.x = 230;
backButton.y = 320;
addChild(backButton);
var buyButton:Button = new BuyGameButton();
buyButton.x = 360;
buyButton.y = 320;
if (Contraption.INCLUDE_PAYPAL_LINKS){
addChild(buyButton);
};
}
public function linkToSite(event:Event):void{
var request:URLRequest = new URLRequest("http://fantasticcontraption.com");
navigateToURL(request);
}
}
}//package contraption.menu
Section 128
//PublishButton (contraption.menu.PublishButton)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.net.*;
import flash.text.*;
public class PublishButton extends Button {
public var updateMode:int;
protected var textField:TextField;
public var publish:Boolean;
protected var buttonGraphic:Button;
public var id:int;
public static var DESIGN_MODE:int = 1;
public static var LEVEL_MODE:int = 0;
public function PublishButton(id:int, publish:Boolean, updateMode:int){
super();
this.updateMode = updateMode;
this.publish = publish;
this.id = id;
if (this.publish){
buttonGraphic = new UnPublishButton();
} else {
buttonGraphic = new DoPublishButton();
};
determineToolTip();
addChild(buttonGraphic);
buttonGraphic.addEventListener(MouseEvent.MOUSE_DOWN, setPublish, false, 0, true);
}
protected function confirmPublish(event:Event):void{
removeChild(buttonGraphic);
if (publish){
buttonGraphic = new UnPublishButton();
} else {
buttonGraphic = new DoPublishButton();
};
determineToolTip();
addChild(buttonGraphic);
buttonGraphic.addEventListener(MouseEvent.MOUSE_DOWN, setPublish, false, 0, true);
}
protected function determineToolTip():void{
var toolTip:String;
if (publish){
toolTip = "Un-Publish: stop sharing this ";
} else {
toolTip = "Publish: share this ";
};
if (updateMode == LEVEL_MODE){
toolTip = (toolTip + "level ");
} else {
toolTip = (toolTip + "contraption ");
};
toolTip = (toolTip + "\nwith other users online");
buttonGraphic.setToolTip(toolTip);
}
protected function setPublish(event:Event):void{
var publishString:String;
publish = !(publish);
if (publish){
publishString = "1";
} else {
publishString = "0";
};
var setPublish:XML = <setPublish/>
;
if (updateMode == LEVEL_MODE){
setPublish.appendChild((("<levelId>" + id) + "</levelId>"));
} else {
setPublish.appendChild((("<designId>" + id) + "</designId>"));
};
setPublish.appendChild((("<publish>" + publishString) + "</publish>"));
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, confirmPublish);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/setPublish.php");
var variables:URLVariables = new URLVariables();
variables.xml = setPublish;
variables.userId = User.getInstance().getUserId();
variables.password = User.getInstance().getPassword();
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
}
}//package contraption.menu
Section 129
//SaveContraptionMenu (contraption.menu.SaveContraptionMenu)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
import flash.external.*;
public class SaveContraptionMenu extends ModalMenu {
protected var isSolution:Boolean;
protected var nameField:TextBox;
protected var loginMenu:Sprite;
protected var saveMenu:Sprite;
protected var currentLevelId:int;
protected var validationError:TextField;
protected var descriptionField:TextBox;
protected var xml:XML;
public function SaveContraptionMenu(xml:XML, isSolution:Boolean, currentLevelId:int):void{
var loginButton:Button;
super("Save Design");
this.xml = xml;
this.isSolution = isSolution;
this.currentLevelId = currentLevelId;
saveMenu = new Sprite();
addChild(saveMenu);
validationError = new TextArea("");
validationError.x = 270;
validationError.y = 190;
validationError.textColor = 16720418;
validationError.width = 250;
saveMenu.addChild(validationError);
var text:TextArea = new TextArea("Name:");
text.x = 270;
text.y = 220;
saveMenu.addChild(text);
text = new TextArea("Description:");
text.x = 240;
text.y = 250;
saveMenu.addChild(text);
nameField = new TextBox(100, 20, 15);
nameField.x = 320;
nameField.y = 220;
saveMenu.addChild(nameField);
descriptionField = new TextBox(200, 40, 50);
descriptionField.x = 320;
descriptionField.y = 250;
saveMenu.addChild(descriptionField);
var saveButton:Button = new SmallSaveButton();
saveButton.x = 230;
saveButton.y = 310;
saveMenu.addChild(saveButton);
saveButton.addEventListener(MouseEvent.MOUSE_DOWN, save);
var cancelButton:Button = new SmallCancelButton();
cancelButton.x = 360;
cancelButton.y = 310;
saveMenu.addChild(cancelButton);
loginMenu = new Sprite();
addChild(loginMenu);
text = new TextArea();
text.setText("Before you save you need to sign in or create \nan account. Only takes a second, I promise!");
text.x = 240;
text.y = 190;
loginMenu.addChild(text);
loginButton = new LogInButton();
loginButton.x = 230;
loginButton.y = 310;
loginMenu.addChild(loginButton);
var newUserButton:Button = new NewUserButton();
newUserButton.x = 290;
newUserButton.y = 250;
loginMenu.addChild(newUserButton);
cancelButton = new SmallCancelButton();
cancelButton.x = 360;
cancelButton.y = 310;
loginMenu.addChild(cancelButton);
setMenu();
}
protected function setMenu():void{
saveMenu.visible = false;
loginMenu.visible = false;
if (User.getInstance().isLoggedIn()){
saveMenu.visible = true;
} else {
loginMenu.visible = true;
};
}
protected function save(event:Event):void{
if (!validate()){
return;
};
var levelSave:XML = <saveDesign/>
;
levelSave.appendChild((("<name>" + nameField.getText()) + "</name>"));
levelSave.appendChild((("<description>" + descriptionField.getText()) + "</description>"));
levelSave.appendChild((("<userId>" + User.getInstance().getUserId()) + "</userId>"));
levelSave.appendChild((("<levelId>" + currentLevelId) + "</levelId>"));
if (isSolution){
levelSave.appendChild("<isSolution>1</isSolution>");
} else {
levelSave.appendChild("<isSolution>0</isSolution>");
};
levelSave.appendChild(xml);
var loader:URLLoader = new ContraptionUrlLoader();
loader.addEventListener(MenuEvent.ADD_SPINNER, bubble);
loader.addEventListener(MenuEvent.REMOVE_SPINNER, bubble);
loader.addEventListener(Event.COMPLETE, saveComplete);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/saveDesign.php");
var variables:URLVariables = new URLVariables();
variables.xml = levelSave;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
if (Contraption.VERSION_NAME == "fantasticcontraption.com"){
ExternalInterface.call("pageTracker._trackPageview", "/saveDesign");
};
}
protected function saveComplete(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK, true, true));
var menuEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_DESIGN_LINK_MENU, true, true);
menuEvent.designId = event.target.data;
dispatchEvent(menuEvent);
}
public function bubble(event:Event):void{
dispatchEvent(event);
}
override public function refresh():void{
setMenu();
}
protected function validate():Boolean{
validationError.text = "";
if (nameField.getText() == ""){
validationError.text = "Please provide a name";
return (false);
};
return (true);
}
}
}//package contraption.menu
Section 130
//SavedContraptionRow (contraption.menu.SavedContraptionRow)
package contraption.menu {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class SavedContraptionRow extends MovieClip {
protected var userName:String;
protected var userId:int;
public function SavedContraptionRow(editable:Boolean, designId:int, designName:String, designDescription:String, publish:Boolean, userName:String, userId:int, quality:Number){
var text:TextArea;
var designButton:Button;
var linkButton:Button;
var publishButton:PublishButton;
var deleteButton:Button;
var userButton:LinkButton;
var starBar:StarBar;
super();
this.userId = userId;
this.userName = userName;
var rowBackground:MovieClip = new SavedLevelBackground();
addChild(rowBackground);
var format:TextFormat = new TextFormat();
format.size = 20;
format.bold = true;
text = new TextArea(designName, 19, "contraptionFont");
text.embedFonts = true;
text.x = 10;
text.y = 10;
rowBackground.addChild(text);
text = new TextArea(designDescription);
text.wordWrap = true;
text.height = 40;
text.width = 280;
text.x = 10;
text.y = 50;
rowBackground.addChild(text);
if (editable){
designButton = new PlayDesignSmallButton();
designButton.designId = designId;
designButton.x = 260;
designButton.y = 10;
rowBackground.addChild(designButton);
linkButton = new LinkDesignButton();
linkButton.designId = designId;
linkButton.x = 300;
linkButton.y = 10;
rowBackground.addChild(linkButton);
publishButton = new PublishButton(designId, publish, PublishButton.DESIGN_MODE);
publishButton.x = 340;
publishButton.y = 10;
rowBackground.addChild(publishButton);
deleteButton = new DeleteDesignButton();
deleteButton.designId = designId;
deleteButton.x = 340;
deleteButton.y = 55;
rowBackground.addChild(deleteButton);
} else {
text = new TextArea("By:");
text.x = 150;
text.y = 15;
rowBackground.addChild(text);
userButton = new LinkButton(userName);
userButton.x = 170;
userButton.y = 15;
rowBackground.addChild(userButton);
userButton.addEventListener(MouseEvent.MOUSE_DOWN, loadUserMenu);
starBar = new StarBar(quality, designId, StarBar.QUALITY, StarBar.DESIGN);
starBar.x = 270;
starBar.y = 20;
rowBackground.addChild(starBar);
designButton = new PlayDesignSmallButton();
designButton.designId = designId;
designButton.x = 340;
designButton.y = 10;
rowBackground.addChild(designButton);
linkButton = new LinkDesignButton();
linkButton.designId = designId;
linkButton.x = 340;
linkButton.y = 55;
rowBackground.addChild(linkButton);
};
}
protected function loadUserMenu(event:MouseEvent):void{
var userMenuEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_USER_MENU, true, true);
userMenuEvent.userId = userId;
userMenuEvent.userName = userName;
dispatchEvent(userMenuEvent);
}
}
}//package contraption.menu
Section 131
//SaveDesignWindow (contraption.menu.SaveDesignWindow)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.net.*;
public class SaveDesignWindow extends SaveWindow {
public var levelId:int;// = 0
public function SaveDesignWindow(){
super();
}
override protected function save(event:MouseEvent):void{
var levelSave:XML = <saveDesign/>
;
levelSave.appendChild((("<name>" + nameField.text) + "</name>"));
levelSave.appendChild((("<description>" + descriptionField.text) + "</description>"));
levelSave.appendChild((("<userId>" + User.getInstance().getUserId()) + "</userId>"));
levelSave.appendChild((("<levelId>" + levelId) + "</levelId>"));
levelSave.appendChild(levelXml);
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, completeHandler);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/saveDesign.php");
var variables:URLVariables = new URLVariables();
variables.xml = levelSave;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
}
}//package contraption.menu
Section 132
//SavedLevelBackgroundBase (contraption.menu.SavedLevelBackgroundBase)
package contraption.menu {
import flash.events.*;
import flash.display.*;
public class SavedLevelBackgroundBase extends MovieClip {
protected var theMask:SavedLevelBackgroundMask;
public function SavedLevelBackgroundBase(){
theMask = new SavedLevelBackgroundMask();
super();
addChild(theMask);
this.mask = theMask;
theMask.gotoAndPlay("default");
gotoAndPlay("default");
this.addEventListener(MouseEvent.ROLL_OVER, mouseOver);
this.addEventListener(MouseEvent.ROLL_OUT, mouseOut);
}
protected function mouseOut(event:MouseEvent):void{
if (event.eventPhase != EventPhase.AT_TARGET){
return;
};
if (currentLabel == "open"){
theMask.gotoAndPlay("up");
gotoAndPlay("up");
} else {
theMask.gotoAndPlay("default");
gotoAndPlay("default");
};
}
protected function mouseOver(event:MouseEvent):void{
if (event.eventPhase != EventPhase.AT_TARGET){
return;
};
theMask.gotoAndPlay("over");
gotoAndPlay("over");
}
}
}//package contraption.menu
Section 133
//SavedLevelRow (contraption.menu.SavedLevelRow)
package contraption.menu {
import flash.display.*;
import flash.text.*;
public class SavedLevelRow extends MovieClip {
public function SavedLevelRow(levelId:int, levelName:String, levelDescription:String, publish:Boolean, editable:Boolean){
var rowBackground:MovieClip;
var text:TextArea;
var publishButton:PublishButton;
var deleteButton:Button;
super();
rowBackground = new SavedLevelBackground();
addChild(rowBackground);
var format:TextFormat = new TextFormat();
format.size = 20;
format.bold = true;
text = new TextArea(levelName, 19, "contraptionFont");
text.embedFonts = true;
text.x = 10;
text.y = 10;
rowBackground.addChild(text);
var levelButton:Button = new PlayLevelSmallButton();
levelButton.levelId = levelId;
levelButton.x = 220;
levelButton.y = 10;
rowBackground.addChild(levelButton);
var linkButton:Button = new LinkLevelButton();
linkButton.levelId = levelId;
linkButton.x = 260;
linkButton.y = 10;
rowBackground.addChild(linkButton);
var solutionsButton:Button = new SolutionsButton();
solutionsButton.levelId = levelId;
solutionsButton.x = 300;
solutionsButton.y = 10;
rowBackground.addChild(solutionsButton);
if (editable){
publishButton = new PublishButton(levelId, publish, PublishButton.LEVEL_MODE);
publishButton.x = 340;
publishButton.y = 10;
rowBackground.addChild(publishButton);
};
text = new TextArea(levelDescription);
text.wordWrap = true;
text.height = 40;
text.width = 280;
text.x = 10;
text.y = 50;
rowBackground.addChild(text);
if (editable){
deleteButton = new DeleteLevelButton();
deleteButton.levelId = levelId;
deleteButton.x = 300;
deleteButton.y = 55;
rowBackground.addChild(deleteButton);
};
var editButton:Button = new EditLevelButton();
editButton.levelId = levelId;
editButton.x = 340;
editButton.y = 55;
rowBackground.addChild(editButton);
}
}
}//package contraption.menu
Section 134
//SaveEvent (contraption.menu.SaveEvent)
package contraption.menu {
import flash.events.*;
public class SaveEvent extends Event {
public var isSolution:Boolean;// = false
public var currentLevelId:int;
public var xml:XML;
public static const SAVE_CONTRAPTION:String = "saveContraption";
public static const SAVE_LEVEL:String = "saveLevel";
public function SaveEvent(eventType:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(eventType, bubbles, cancelable);
}
override public function clone():Event{
var e:SaveEvent = new SaveEvent(type, bubbles, cancelable);
e.xml = xml;
e.isSolution = isSolution;
e.currentLevelId = currentLevelId;
return (e);
}
}
}//package contraption.menu
Section 135
//SaveLevelMenu (contraption.menu.SaveLevelMenu)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.display.*;
import flash.net.*;
public class SaveLevelMenu extends ModalMenu {
protected var loginMenu:Sprite;
protected var descriptionField:TextBox;
protected var validationError:TextArea;
protected var nameField:TextBox;
protected var xml:XML;
protected var saveMenu:Sprite;
public function SaveLevelMenu(xml:XML):void{
var text:TextArea;
var cancelButton:Button;
var loginButton:Button;
super("Save Level");
this.xml = xml;
saveMenu = new Sprite();
addChild(saveMenu);
validationError = new TextArea("");
validationError.x = 270;
validationError.y = 180;
validationError.textColor = 16720418;
validationError.width = 250;
saveMenu.addChild(validationError);
text = new TextArea("Name:");
text.x = 270;
text.y = 210;
saveMenu.addChild(text);
text = new TextArea("Description:");
text.x = 240;
text.y = 240;
saveMenu.addChild(text);
nameField = new TextBox(100, 20, 15);
nameField.x = 320;
nameField.y = 210;
saveMenu.addChild(nameField);
descriptionField = new TextBox(200, 40, 50);
descriptionField.x = 320;
descriptionField.y = 240;
saveMenu.addChild(descriptionField);
var saveButton:Button = new SmallSaveButton();
saveButton.x = 230;
saveButton.y = 310;
saveMenu.addChild(saveButton);
saveButton.addEventListener(MouseEvent.MOUSE_DOWN, save);
cancelButton = new SmallCancelButton();
cancelButton.x = 360;
cancelButton.y = 310;
saveMenu.addChild(cancelButton);
loginMenu = new Sprite();
addChild(loginMenu);
text = new TextArea(("In order to save you must log in or create an account.\n\n" + "(it will only take a second, I promise)"));
text.x = 250;
text.y = 190;
text.width = 400;
text.height = 100;
loginMenu.addChild(text);
loginButton = new LogInButton();
loginButton.x = 230;
loginButton.y = 260;
loginMenu.addChild(loginButton);
var newUserButton:Button = new NewUserButton();
newUserButton.x = 360;
newUserButton.y = 260;
loginMenu.addChild(newUserButton);
cancelButton = new SmallCancelButton();
cancelButton.x = 360;
cancelButton.y = 320;
loginMenu.addChild(cancelButton);
setMenu();
}
protected function setMenu():void{
saveMenu.visible = false;
loginMenu.visible = false;
if (User.getInstance().isLoggedIn()){
saveMenu.visible = true;
} else {
loginMenu.visible = true;
};
}
protected function save(event:Event):void{
if (!validate()){
return;
};
var levelSave:XML = <saveLevel/>
;
levelSave.appendChild((("<name>" + nameField.getText()) + "</name>"));
levelSave.appendChild((("<description>" + descriptionField.getText()) + "</description>"));
levelSave.appendChild((("<userId>" + User.getInstance().getUserId()) + "</userId>"));
levelSave.appendChild(xml);
var loader:URLLoader = new ContraptionUrlLoader();
loader.addEventListener(MenuEvent.ADD_SPINNER, bubble);
loader.addEventListener(MenuEvent.REMOVE_SPINNER, bubble);
loader.addEventListener(Event.COMPLETE, saveComplete);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/saveLevel.php");
var variables:URLVariables = new URLVariables();
variables.xml = levelSave;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
protected function saveComplete(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK, true, true));
var menuEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_LEVEL_LINK_MENU, true, true);
menuEvent.levelId = event.target.data;
dispatchEvent(menuEvent);
}
public function bubble(event:Event):void{
dispatchEvent(event);
}
override public function refresh():void{
setMenu();
}
protected function validate():Boolean{
validationError.text = "";
if (nameField.getText() == ""){
validationError.text = "Please provide a name";
return (false);
};
return (true);
}
}
}//package contraption.menu
Section 136
//SaveLevelWindow (contraption.menu.SaveLevelWindow)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.net.*;
public class SaveLevelWindow extends SaveWindow {
public function SaveLevelWindow(){
super();
}
override protected function save(event:MouseEvent):void{
var levelSave:XML = <saveLevel/>
;
levelSave.appendChild((("<name>" + nameField.text) + "</name>"));
levelSave.appendChild((("<description>" + descriptionField.text) + "</description>"));
levelSave.appendChild((("<userId>" + User.getInstance().getUserId()) + "</userId>"));
levelSave.appendChild(levelXml);
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, completeHandler);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/saveLevel.php");
var variables:URLVariables = new URLVariables();
variables.xml = levelSave;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
}
}//package contraption.menu
Section 137
//SaveWindow (contraption.menu.SaveWindow)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.display.*;
import flash.text.*;
import flash.errors.*;
public class SaveWindow extends MenuWindow {
public var savedLink:TextField;
protected var controlPanel:Sprite;
protected var loginMenu:LogInMenu;
public var nameField:TextField;
public var levelXml:XML;
protected var saveButton:Button;
public var descriptionField:TextField;
public function SaveWindow():void{
super(false);
controlPanel = new Sprite();
addChild(controlPanel);
controlPanel.visible = false;
var closeButton:Button = new Button("Close");
closeButton.x = 10;
closeButton.y = 10;
addChild(closeButton);
closeButton.addEventListener(MouseEvent.MOUSE_DOWN, close);
saveButton = new Button("Save");
saveButton.x = 90;
saveButton.y = 10;
addChild(saveButton);
saveButton.addEventListener(MouseEvent.MOUSE_DOWN, save);
savedLink = new TextField();
savedLink.x = 10;
savedLink.y = 120;
savedLink.width = 350;
controlPanel.addChild(savedLink);
var textField:TextField = new TextField();
textField.x = 10;
textField.y = 60;
textField.height = 20;
textField.text = "Name:";
controlPanel.addChild(textField);
nameField = new TextField();
nameField.type = TextFieldType.INPUT;
nameField.x = 80;
nameField.y = 60;
nameField.background = true;
nameField.backgroundColor = 0xFFFFFF;
nameField.height = 20;
controlPanel.addChild(nameField);
nameField.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
textField = new TextField();
textField.x = 10;
textField.y = 90;
textField.height = 20;
textField.text = "Description:";
controlPanel.addChild(textField);
descriptionField = new TextField();
descriptionField.type = TextFieldType.INPUT;
descriptionField.x = 80;
descriptionField.y = 90;
descriptionField.background = true;
descriptionField.backgroundColor = 0xFFFFFF;
descriptionField.height = 20;
controlPanel.addChild(descriptionField);
descriptionField.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
loginMenu = new LogInMenu();
loginMenu.x = 10;
loginMenu.y = 120;
addChild(loginMenu);
loginMenu.visible = false;
loginMenu.addEventListener(MenuEvent.LOGGED_IN, loggedIn);
addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
opaqueBackground = 0xEEEEEE;
visible = false;
}
protected function loggedIn(event:Event):void{
controlPanel.visible = true;
loginMenu.visible = false;
saveButton.visible = true;
}
public function open(levelXml:XML):void{
this.levelXml = levelXml;
savedLink.text = "";
visible = true;
if (User.getInstance().isLoggedIn()){
controlPanel.visible = true;
} else {
loginMenu.visible = true;
saveButton.visible = false;
};
}
protected function completeHandler(event:Event):void{
savedLink.text = event.target.data;
}
public function close(event:MouseEvent):void{
visible = false;
}
protected function keyDown(event:KeyboardEvent):void{
if (((!(parent)) || ((visible == false)))){
return;
};
event.stopPropagation();
}
protected function save(event:MouseEvent):void{
throw (new IllegalOperationError("You must extend SaveMenu and implement \"save\""));
}
protected function mouseDown(event:Event):void{
event.stopPropagation();
}
}
}//package contraption.menu
Section 138
//SceneChange (contraption.menu.SceneChange)
package contraption.menu {
import flash.display.*;
public class SceneChange extends MovieClip {
public var lockClosed:Boolean;// = false
public var doOpen:Boolean;// = false
public function SceneChange(){
super();
stop();
}
public function open():void{
if (lockClosed){
return;
};
if (currentLabel == "open"){
gotoAndPlay("open");
dispatchEvent(new MenuEvent(MenuEvent.OPEN_CURTAIN));
} else {
doOpen = true;
};
}
public function jumpToClosed():void{
gotoAndStop("open");
}
public function close():void{
if (!lockClosed){
gotoAndPlay("close");
doOpen = false;
};
}
}
}//package contraption.menu
Section 139
//SelectDifficultyButton (contraption.menu.SelectDifficultyButton)
package contraption.menu {
import flash.geom.*;
public class SelectDifficultyButton extends Button {
public function SelectDifficultyButton(rating:int){
super();
addChild(new Star(1, new Point(5, 5), true, 6750054));
if (rating > 1){
addChild(new Star(2, new Point(17, 5), true, 6750054));
};
if (rating > 2){
addChild(new Star(3, new Point(29, 5), true, 6750054));
};
if (rating > 3){
addChild(new Star(4, new Point(41, 5), true, 6750054));
};
if (rating > 4){
addChild(new Star(5, new Point(53, 5), true, 6750054));
};
}
}
}//package contraption.menu
Section 140
//SortedPagingData (contraption.menu.SortedPagingData)
package contraption.menu {
public class SortedPagingData extends PagingData {
public var sortValue:String;
public static const SORT_BY_QUALITY:String = "quality";
public static const SORT_BY_DATE:String = "date";
public function SortedPagingData(resultsPerPage:int):void{
super(resultsPerPage);
sortValue = SORT_BY_QUALITY;
}
}
}//package contraption.menu
Section 141
//Spinner (contraption.menu.Spinner)
package contraption.menu {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class Spinner extends MovieClip {
public function Spinner(){
super();
graphics.beginFill(0xFFFFFF, 0);
graphics.drawRect(0, 0, 700, 500);
var format:TextFormat = new TextFormat();
format.size = 28;
format.bold = true;
var text:TextField = new TextField();
text.text = "Working...";
text.height = 40;
text.width = 200;
text.mouseEnabled = false;
text.x = 400;
text.y = 50;
text.setTextFormat(format);
addChild(text);
addEventListener(MouseEvent.MOUSE_DOWN, stopEvent);
addEventListener(KeyboardEvent.KEY_DOWN, stopEvent);
}
protected function stopEvent(event:Event):void{
event.stopPropagation();
}
}
}//package contraption.menu
Section 142
//Star (contraption.menu.Star)
package contraption.menu {
import contraption.*;
import flash.geom.*;
public class Star extends ActionContainerImpl {
protected var rating:int;
public function Star(rating:int, position:Point, fill:Boolean, starColour:int){
super();
this.rating = rating;
drawStar(fill, starColour);
this.x = position.x;
this.y = position.y;
}
override public function getAllowableActions():Actions{
var allowableActions:Actions = new Actions();
allowableActions.button = true;
return (allowableActions);
}
public function getRating():int{
return (rating);
}
protected function drawStar(fill:Boolean, starColour:int):void{
graphics.lineStyle(2, 16777062);
if (fill){
graphics.beginFill(starColour);
} else {
graphics.beginFill(16777062);
};
graphics.drawCircle(0, 0, 7);
}
}
}//package contraption.menu
Section 143
//StarBar (contraption.menu.StarBar)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.geom.*;
import flash.net.*;
public class StarBar extends ActionContainerImpl {
protected var stars:Array;
protected var barType:int;
protected var table:int;
protected var id:int;
protected var rating:Number;
protected var starColour:int;
public static const LEVEL:int = 0;
public static const DESIGN:int = 1;
public static const DIFFICULTY:int = 1;
public static const QUALITY:int = 0;
public function StarBar(rating:Number, id:int, barType:int, table:int):void{
super();
this.id = id;
this.barType = barType;
this.table = table;
if (barType == QUALITY){
starColour = 16737894;
} else {
starColour = 6750054;
};
setRating(rating);
addEventListener(MouseEvent.ROLL_OVER, mouseOver);
addEventListener(MouseEvent.ROLL_OUT, mouseOut);
}
protected function drawStarBar():void{
var i:int;
if (stars != null){
i = 0;
while (i < stars.length) {
removeChild(stars[i]);
i++;
};
};
stars = new Array();
addStar(1, new Point(5, 5), true);
addStar(2, new Point(17, 5), (rating > 1.5));
addStar(3, new Point(29, 5), (rating > 2.5));
addStar(4, new Point(41, 5), (rating > 3.5));
addStar(5, new Point(53, 5), (rating >= 4.5));
}
protected function addRating(event:Event):void{
var user:User = User.getInstance();
if (!user.isLoggedIn()){
return;
};
var rating:int = event.target.getRating();
var setRating:XML = <setRating/>
;
if (table == LEVEL){
setRating.appendChild((("<levelId>" + id) + "</levelId>"));
} else {
setRating.appendChild((("<designId>" + id) + "</designId>"));
};
if (barType == QUALITY){
setRating.appendChild((("<qualityRating>" + rating) + "</qualityRating>"));
} else {
setRating.appendChild((("<difficultyRating>" + rating) + "</difficultyRating>"));
};
setRating.appendChild((("<userId>" + user.getUserId()) + "</userId>"));
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, addRatingResponse);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/setRating.php");
var variables:URLVariables = new URLVariables();
variables.xml = setRating;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
protected function addRatingResponse(event:Event):void{
setRating(event.target.data);
}
protected function addStar(rating:int, position:Point, fill:Boolean):Star{
var star:Star = new Star(rating, position, fill, starColour);
star.addEventListener(MouseEvent.MOUSE_DOWN, addRating, false, 0, true);
addChild(star);
stars.push(star);
return (star);
}
protected function mouseOut(event:MouseEvent):void{
dispatchEvent(new TooltipEvent(TooltipEvent.REMOVE_TOOLTIP, true, true));
}
protected function mouseOver(event:MouseEvent):void{
var tooltipEvent:TooltipEvent = new TooltipEvent(TooltipEvent.ADD_TOOLTIP, true, true);
if (table == LEVEL){
tooltipEvent.toolTip = "Level ";
} else {
tooltipEvent.toolTip = "Contraption ";
};
if (barType == QUALITY){
tooltipEvent.toolTip = "Quality Rating";
} else {
tooltipEvent.toolTip = (tooltipEvent.toolTip + "Difficulty");
};
dispatchEvent(tooltipEvent);
}
public function setRating(rating:Number):void{
this.rating = rating;
drawStarBar();
}
}
}//package contraption.menu
Section 144
//TextArea (contraption.menu.TextArea)
package contraption.menu {
import flash.text.*;
public class TextArea extends TextField {
protected var format:TextFormat;
public function TextArea(text:String="", textSize:int=13, font:String="arial", align:String="left"):void{
super();
format = new TextFormat();
format.font = font;
format.size = textSize;
if (align == TextFormatAlign.LEFT){
this.autoSize = "left";
} else {
format.align = align;
};
defaultTextFormat = format;
this.text = text;
mouseEnabled = false;
}
public function setAlign(align:String):void{
format.align = align;
defaultTextFormat = format;
}
public function bold():void{
format.bold = true;
defaultTextFormat = format;
}
public function setHtmlText(text:String):void{
this.htmlText = text;
}
public function setText(text:String):void{
this.text = text;
}
}
}//package contraption.menu
Section 145
//TextBox (contraption.menu.TextBox)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.text.*;
public class TextBox extends ActionContainerImpl {
protected var textField:TextField;
public function TextBox(width:int=80, height:int=20, maxChars:int=0, displayAsPassword:Boolean=false):void{
super();
textField = new TextField();
textField.border = true;
textField.type = TextFieldType.INPUT;
textField.background = true;
textField.backgroundColor = 0xFFFFFF;
textField.width = width;
textField.height = height;
textField.maxChars = maxChars;
textField.displayAsPassword = displayAsPassword;
if (height > 20){
textField.wordWrap = true;
};
addChild(textField);
textField.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
var format:TextFormat = new TextFormat();
format.font = "arial";
format.size = 12;
textField.defaultTextFormat = format;
graphics.beginFill(0);
graphics.drawRect(0, 0, width, height);
}
override public function getAllowableActions():Actions{
var allowableActions:Actions = new Actions();
allowableActions.inputText = true;
return (allowableActions);
}
protected function keyDown(event:KeyboardEvent):void{
event.stopPropagation();
}
public function getText():String{
return (textField.text);
}
public function setText(text:String):void{
textField.text = text;
}
}
}//package contraption.menu
Section 146
//ToggleGraphicsButton (contraption.menu.ToggleGraphicsButton)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.display.*;
public class ToggleGraphicsButton extends Button {
protected var buttonGraphics:SimpleButton;
public function ToggleGraphicsButton(){
super();
buttonWidth = 25;
buttonHeight = 25;
buttonGraphics = new GraphicsOnButton();
addChild(buttonGraphics);
setButton();
}
override protected function buttonPress(event:MouseEvent):void{
var config:Configuration = Configuration.getInstance();
config.setSimpleGraphicsMode(!(config.isInSimpleGraphicsMode()));
setButton();
dispatchEvent(new MenuEvent(MenuEvent.CHANGE_GRAPHICS_OPTION, true, true));
}
public function setButton():void{
removeChild(buttonGraphics);
if (Configuration.getInstance().isInSimpleGraphicsMode()){
buttonGraphics = new GraphicsOffButton();
setToolTip("Turn simple graphics off");
} else {
buttonGraphics = new GraphicsOnButton();
setToolTip("Use simple graphics\n(if things are running slow)");
};
addChild(buttonGraphics);
}
}
}//package contraption.menu
Section 147
//TooltipEvent (contraption.menu.TooltipEvent)
package contraption.menu {
import flash.events.*;
public class TooltipEvent extends Event {
public var toolTip:String;
public static const REMOVE_TOOLTIP:String = "removeTooltip";
public static const ADD_TOOLTIP:String = "addTooltip";
public function TooltipEvent(eventType:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(eventType, bubbles, cancelable);
}
override public function clone():Event{
var e:TooltipEvent = new TooltipEvent(type, bubbles, cancelable);
e.toolTip = toolTip;
return (e);
}
}
}//package contraption.menu
Section 148
//TutorialButton (contraption.menu.TutorialButton)
package contraption.menu {
import flash.events.*;
import contraption.tutorials.*;
public class TutorialButton extends Button {
public function TutorialButton(){
super();
}
override protected function buttonPress(event:MouseEvent):void{
if (!isEnabled){
return;
};
var tutorialEvent:TutorialEvent = new TutorialEvent(downEvent, true, true);
dispatchEvent(tutorialEvent);
}
}
}//package contraption.menu
Section 149
//UpdateUserInfoMenu (contraption.menu.UpdateUserInfoMenu)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.text.*;
public class UpdateUserInfoMenu extends ModalMenu {
protected var passwordField:TextBox;
protected var validationError:TextArea;
protected var emailField:TextBox;
protected var confirmPasswordField:TextBox;
public function UpdateUserInfoMenu():void{
var text:TextField;
super("Account");
var user:User = User.getInstance();
validationError = new TextArea("");
validationError.x = 270;
validationError.y = 175;
validationError.textColor = 16720418;
validationError.width = 250;
validationError.height = 50;
addChild(validationError);
text = new TextArea("User Name:");
text.x = 270;
text.y = 200;
addChild(text);
text = new TextArea("Email Address:");
text.x = 250;
text.y = 230;
addChild(text);
text = new TextArea("New Password:");
text.x = 248;
text.y = 260;
addChild(text);
text = new TextArea("Confirm New Password:");
text.x = 200;
text.y = 290;
text.width = 200;
addChild(text);
text = new TextArea(user.getUserName());
text.x = 350;
text.y = 200;
addChild(text);
emailField = new TextBox(150, 20, 100);
emailField.setText(user.getEmail());
emailField.x = 350;
emailField.y = 230;
addChild(emailField);
passwordField = new TextBox(100, 20, 15, true);
passwordField.x = 350;
passwordField.y = 260;
addChild(passwordField);
confirmPasswordField = new TextBox(100, 20, 15, true);
confirmPasswordField.x = 350;
confirmPasswordField.y = 290;
addChild(confirmPasswordField);
var updateButton:Button = new UpdateUserInfoSubmitButton();
updateButton.x = 230;
updateButton.y = 320;
addChild(updateButton);
updateButton.addEventListener(MenuEvent.UPDATE_USER_INFO, updateInfo);
var cancelButton:Button = new SmallCancelButton();
cancelButton.x = 360;
cancelButton.y = 320;
addChild(cancelButton);
}
protected function updateComplete(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK, true, true));
}
protected function isValidEmail(email:String):Boolean{
var emailExpression:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
return (emailExpression.test(email));
}
protected function validate():Boolean{
validationError.text = "";
if (!isValidEmail(emailField.getText())){
validationError.appendText("Invalid email address\n");
};
if (passwordField.getText() != confirmPasswordField.getText()){
validationError.appendText("Password fields do not match\n");
};
return ((validationError.text == ""));
}
protected function updateInfo(event:MenuEvent):void{
event.stopPropagation();
if (!validate()){
return;
};
var user:User = User.getInstance();
user.addEventListener(MenuEvent.UPDATE_USER_INFO, updateComplete, false, 0, true);
user.updateInfo(emailField.getText(), passwordField.getText());
}
}
}//package contraption.menu
Section 150
//UserDesignsMenu (contraption.menu.UserDesignsMenu)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
public class UserDesignsMenu extends MenuWindow {
protected var pageCount:TextArea;
protected var contraptionCanvas:Sprite;
protected var editable:Boolean;
protected var displayMode:int;
protected var id:int;
protected var pagingData:PagingData;
public static var LEVEL_MODE:int = 1;
public static var USER_MODE:int = 0;
public function UserDesignsMenu(id:int, displayMode:int):void{
var button:Button;
super();
this.id = id;
this.displayMode = displayMode;
editable = (((User.getInstance().getUserId() == id)) && ((displayMode == USER_MODE)));
pageCount = new TextArea();
pageCount.x = 385;
pageCount.y = 155;
pageCount.bold();
pageCount.setAlign(TextFormatAlign.CENTER);
pageCount.width = 200;
pageCount.textColor = 0x663300;
addChild(pageCount);
button = new PreviousPageButton();
button.x = 340;
button.y = 150;
addChild(button);
button.addEventListener(MouseEvent.MOUSE_DOWN, previousPage, false, 0, true);
button = new NextPageButton();
button.x = 480;
button.y = 150;
addChild(button);
button.addEventListener(MouseEvent.MOUSE_DOWN, nextPage, false, 0, true);
pagingData = new PagingData(4);
contraptionCanvas = new Sprite();
addChild(contraptionCanvas);
listDesigns();
}
protected function previousPage(event:Event):void{
if (pagingData.currentPage > 0){
pagingData.currentPage--;
};
listDesigns();
}
protected function deleteDesign(e:Event):void{
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, confirmDelete);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/deleteDesign.php");
var variables:URLVariables = new URLVariables();
variables.designId = e.target.designId;
variables.userId = User.getInstance().getUserId();
variables.password = User.getInstance().getPassword();
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
protected function renderButtons(event:Event):void{
var designs:XML;
var design:XML;
var contraptionRow:MovieClip;
var publishBool:Boolean;
var message:TextArea;
var messageText:String;
designs = new XML(event.target.data);
pagingData.numResults = designs.designCount;
pageCount.setText(((("Page " + (pagingData.currentPage + 1)) + " of ") + pagingData.getNumPages()));
removeChild(contraptionCanvas);
contraptionCanvas = new Sprite();
addChild(contraptionCanvas);
var i:int;
for each (design in designs.design) {
if (design.publish == "1"){
publishBool = true;
} else {
publishBool = false;
};
contraptionRow = new SavedContraptionRow(editable, design.designId, design.name, design.description, publishBool, design.userName, design.userId, design.quality);
contraptionRow.x = 225;
contraptionRow.y = (200 + (i * 65));
contraptionCanvas.addChildAt(contraptionRow, 0);
contraptionRow.addEventListener(MenuEvent.DELETE_DESIGN, deleteDesign, false, 0, true);
i++;
};
if (i == 0){
if (editable){
messageText = "You haven't saved any\ndesigns yet";
} else {
messageText = "There are not yet any\nsaved designs here";
};
message = new TextArea(messageText, 18);
message.x = 320;
message.y = 300;
message.bold();
message.textColor = 0x663300;
addChild(message);
};
finishedLoading();
}
protected function loadUserMenu(event:Event):void{
event.stopPropagation();
var menuEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_USER_MENU);
menuEvent.userId = event.target.userId;
menuEvent.userName = event.target.userName;
dispatchEvent(menuEvent);
}
protected function nextPage(event:Event):void{
if (pagingData.currentPage < (pagingData.getNumPages() - 1)){
pagingData.currentPage++;
};
listDesigns();
}
protected function confirmDelete(event:Event):void{
listDesigns();
}
override public function refresh():void{
listDesigns();
}
protected function listDesigns():void{
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, renderButtons);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/getUserDesigns.php");
var variables:URLVariables = new URLVariables();
if (displayMode == USER_MODE){
if (!editable){
variables.onlyPublished = "1";
};
variables.userId = id;
} else {
variables.levelId = id;
variables.onlyPublished = "1";
};
variables.limitOffset = pagingData.getOffset();
variables.limitCount = pagingData.resultsPerPage;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
protected function loadDesign(event:Event):void{
event.stopPropagation();
var menuEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_DESIGN);
menuEvent.designId = event.target.designId;
dispatchEvent(menuEvent);
}
}
}//package contraption.menu
Section 151
//UserGenLevelRow (contraption.menu.UserGenLevelRow)
package contraption.menu {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class UserGenLevelRow extends MovieClip {
protected var userName:String;
protected var userId:int;
public function UserGenLevelRow(levelId:int, levelName:String, levelDescription:String, userName:String, userId:int, difficulty:int, quality:int){
var texty:TextField;
super();
this.userId = userId;
this.userName = userName;
var rowBackground:MovieClip = new SavedLevelBackground();
addChild(rowBackground);
var text:TextArea = new TextArea(levelName, 16, "contraptionFont");
text.embedFonts = true;
text.x = 10;
text.y = 5;
rowBackground.addChild(text);
texty = new TextField();
texty.text = "By:";
texty.mouseEnabled = false;
texty.x = 20;
texty.y = 25;
rowBackground.addChild(texty);
var userButton:LinkButton = new LinkButton(userName);
userButton.x = 40;
userButton.y = 25;
rowBackground.addChild(userButton);
userButton.addEventListener(MouseEvent.MOUSE_DOWN, loadUserMenu);
var starBar:StarBar = new StarBar(difficulty, levelId, StarBar.DIFFICULTY, StarBar.LEVEL);
starBar.x = 220;
starBar.y = 10;
rowBackground.addChild(starBar);
starBar = new StarBar(quality, levelId, StarBar.QUALITY, StarBar.LEVEL);
starBar.x = 220;
starBar.y = 30;
rowBackground.addChild(starBar);
var levelButton:Button = new PlayLevelSmallButton();
levelButton.levelId = levelId;
levelButton.x = 300;
levelButton.y = 10;
rowBackground.addChild(levelButton);
var linkButton:Button = new LinkLevelButton();
linkButton.levelId = levelId;
linkButton.x = 340;
linkButton.y = 10;
rowBackground.addChild(linkButton);
texty = new TextField();
texty.wordWrap = true;
texty.text = levelDescription;
texty.height = 40;
texty.width = 280;
texty.mouseEnabled = false;
texty.x = 10;
texty.y = 50;
rowBackground.addChild(texty);
var solutionsButton:Button = new SolutionsButton();
solutionsButton.levelId = levelId;
solutionsButton.x = 340;
solutionsButton.y = 55;
rowBackground.addChild(solutionsButton);
}
protected function loadUserMenu(event:MouseEvent):void{
var userMenuEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_USER_MENU, true, true);
userMenuEvent.userId = userId;
userMenuEvent.userName = userName;
dispatchEvent(userMenuEvent);
}
}
}//package contraption.menu
Section 152
//UserGenLevelsMenu (contraption.menu.UserGenLevelsMenu)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
public class UserGenLevelsMenu extends MenuWindow {
protected var pageCount:TextArea;
protected var threeDifficultyButton:Button;
protected var qualitySortButton:LinkButton;
protected var oneDifficultyButton:Button;
protected var allDifficultyButton:LinkButton;
protected var fourDifficultyButton:Button;
protected var pagingData:SortedPagingData;
protected var fiveDifficultyButton:Button;
protected var levelsCanvas:Sprite;
protected var pleaseRegisterMenu:PleaseRegisterMenu;
protected var selectedDifficulty:int;// = 0
protected var twoDifficultyButton:Button;
protected var dateSortButton:LinkButton;
public function UserGenLevelsMenu():void{
var button:Button;
super();
pageCount = new TextArea();
pageCount.x = 395;
pageCount.y = 145;
pageCount.bold();
pageCount.textColor = 0x663300;
addChild(pageCount);
button = new PreviousPageButton();
button.x = 340;
button.y = 140;
addChild(button);
button.addEventListener(MouseEvent.MOUSE_DOWN, previousPage, false, 0, true);
button = new NextPageButton();
button.x = 480;
button.y = 140;
addChild(button);
button.addEventListener(MouseEvent.MOUSE_DOWN, nextPage, false, 0, true);
dateSortButton = new LinkButton("Sort by Date");
dateSortButton.x = 315;
dateSortButton.y = 175;
addChild(dateSortButton);
dateSortButton.addEventListener(MouseEvent.MOUSE_DOWN, dateSort, false, 0, true);
qualitySortButton = new LinkButton("Sort by Rating");
qualitySortButton.x = 475;
qualitySortButton.y = 175;
qualitySortButton.disable();
addChild(qualitySortButton);
qualitySortButton.addEventListener(MouseEvent.MOUSE_DOWN, qualitySort, false, 0, true);
pagingData = new SortedPagingData(4);
levelsCanvas = new Sprite();
addChild(levelsCanvas);
addDifficultySelectors();
listLevels();
pleaseRegisterMenu = new PleaseRegisterMenu();
if (!User.getInstance().isRegistered()){
addChild(pleaseRegisterMenu);
};
}
protected function dateSort(event:Event):void{
qualitySortButton.enable();
dateSortButton.disable();
pagingData.currentPage = 0;
pagingData.sortValue = SortedPagingData.SORT_BY_DATE;
listLevels();
}
protected function enabledButtons():void{
allDifficultyButton.enable();
oneDifficultyButton.enable();
twoDifficultyButton.enable();
threeDifficultyButton.enable();
fourDifficultyButton.enable();
fiveDifficultyButton.enable();
}
protected function selectDifficultyAll(event:Event):void{
selectedDifficulty = 0;
listLevels();
enabledButtons();
allDifficultyButton.disable();
}
protected function loadLevel(event:Event):void{
event.stopPropagation();
var menuEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_LEVEL);
menuEvent.levelId = event.target.levelId;
dispatchEvent(menuEvent);
}
protected function loadUserMenu(event:Event):void{
event.stopPropagation();
var menuEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_USER_MENU);
menuEvent.userId = event.target.userId;
menuEvent.userName = event.target.userName;
dispatchEvent(menuEvent);
}
protected function renderButtons(event:Event):void{
var levels:XML;
var level:XML;
var levelRow:MovieClip;
levels = new XML(event.target.data);
pagingData.numResults = levels.levelCount;
pageCount.setText(((("Page " + (pagingData.currentPage + 1)) + " of ") + pagingData.getNumPages()));
removeChild(levelsCanvas);
levelsCanvas = new Sprite();
addChild(levelsCanvas);
var i:int;
for each (level in levels.level) {
levelRow = new UserGenLevelRow(level.levelId, level.levelName, level.description, level.userName, level.userId, level.difficulty, level.quality);
levelRow.x = 225;
levelRow.y = (200 + (i * 70));
levelsCanvas.addChildAt(levelRow, 0);
i++;
};
finishedLoading();
if (!User.getInstance().isRegistered()){
addChild(pleaseRegisterMenu);
};
}
protected function loadSolutions(event:MenuEvent):void{
dispatchEvent(event);
}
protected function selectDifficultyTwo(event:Event):void{
selectedDifficulty = 2;
listLevels();
enabledButtons();
twoDifficultyButton.disable();
}
override public function refresh():void{
listLevels();
}
protected function nextPage(event:Event):void{
if (pagingData.currentPage < (pagingData.getNumPages() - 1)){
pagingData.currentPage++;
};
listLevels();
}
protected function selectDifficultyFour(event:Event):void{
selectedDifficulty = 4;
listLevels();
enabledButtons();
fourDifficultyButton.disable();
}
protected function selectDifficultyThree(event:Event):void{
selectedDifficulty = 3;
listLevels();
enabledButtons();
threeDifficultyButton.disable();
}
protected function addDifficultySelectors():void{
var text:TextField;
var format:TextFormat = new TextFormat();
format.bold = true;
format.size = 15;
text = new TextField();
text.text = "Filter by\nDifficulty:";
text.autoSize = "left";
text.x = 10;
text.y = 85;
text.setTextFormat(format);
text.mouseEnabled = false;
addChild(text);
allDifficultyButton = new LinkButton("Show all levels");
allDifficultyButton.x = 10;
allDifficultyButton.y = 225;
addChild(allDifficultyButton);
allDifficultyButton.disable();
allDifficultyButton.addEventListener(MouseEvent.MOUSE_DOWN, selectDifficultyAll, false, 0, true);
oneDifficultyButton = new SelectDifficultyButton(1);
oneDifficultyButton.x = 15;
oneDifficultyButton.y = 130;
addChild(oneDifficultyButton);
oneDifficultyButton.addEventListener(MouseEvent.MOUSE_DOWN, selectDifficultyOne, false, 0, true);
twoDifficultyButton = new SelectDifficultyButton(2);
twoDifficultyButton.x = 15;
twoDifficultyButton.y = 150;
addChild(twoDifficultyButton);
twoDifficultyButton.addEventListener(MouseEvent.MOUSE_DOWN, selectDifficultyTwo, false, 0, true);
threeDifficultyButton = new SelectDifficultyButton(3);
threeDifficultyButton.x = 15;
threeDifficultyButton.y = 170;
addChild(threeDifficultyButton);
threeDifficultyButton.addEventListener(MouseEvent.MOUSE_DOWN, selectDifficultyThree, false, 0, true);
fourDifficultyButton = new SelectDifficultyButton(4);
fourDifficultyButton.x = 15;
fourDifficultyButton.y = 190;
addChild(fourDifficultyButton);
fourDifficultyButton.addEventListener(MouseEvent.MOUSE_DOWN, selectDifficultyFour, false, 0, true);
fiveDifficultyButton = new SelectDifficultyButton(5);
fiveDifficultyButton.x = 15;
fiveDifficultyButton.y = 210;
addChild(fiveDifficultyButton);
fiveDifficultyButton.addEventListener(MouseEvent.MOUSE_DOWN, selectDifficultyFive, false, 0, true);
}
protected function selectDifficultyOne(event:Event):void{
selectedDifficulty = 1;
listLevels();
enabledButtons();
oneDifficultyButton.disable();
}
protected function listLevels():void{
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, renderButtons, false, 0, true);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/getUserGenLevels.php");
var variables:URLVariables = new URLVariables();
variables.limitOffset = pagingData.getOffset();
variables.limitCount = pagingData.resultsPerPage;
if (selectedDifficulty != 0){
variables.difficultyRating = selectedDifficulty;
};
variables.orderBy = pagingData.sortValue;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
protected function previousPage(event:Event):void{
if (pagingData.currentPage > 0){
pagingData.currentPage--;
};
listLevels();
}
protected function selectDifficultyFive(event:Event):void{
selectedDifficulty = 5;
listLevels();
enabledButtons();
fiveDifficultyButton.disable();
}
protected function qualitySort(event:Event):void{
qualitySortButton.disable();
dateSortButton.enable();
pagingData.currentPage = 0;
pagingData.sortValue = SortedPagingData.SORT_BY_QUALITY;
listLevels();
}
}
}//package contraption.menu
Section 153
//UserLevelsMenu (contraption.menu.UserLevelsMenu)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.display.*;
import flash.net.*;
public class UserLevelsMenu extends MenuWindow {
protected var pageCount:TextArea;
protected var editable:Boolean;
protected var userId:int;
protected var levelsCanvas:Sprite;
protected var pleaseRegisterMenu:PleaseRegisterMenu;
protected var pagingData:PagingData;
public function UserLevelsMenu(userId:int):void{
var button:Button;
super();
this.userId = userId;
editable = (User.getInstance().getUserId() == userId);
pageCount = new TextArea();
pageCount.x = 395;
pageCount.y = 155;
pageCount.bold();
pageCount.textColor = 0x663300;
addChild(pageCount);
button = new PreviousPageButton();
button.x = 340;
button.y = 150;
addChild(button);
button.addEventListener(MouseEvent.MOUSE_DOWN, previousPage, false, 0, true);
button = new NextPageButton();
button.x = 480;
button.y = 150;
addChild(button);
button.addEventListener(MouseEvent.MOUSE_DOWN, nextPage, false, 0, true);
pagingData = new PagingData(4);
levelsCanvas = new Sprite();
addChild(levelsCanvas);
listLevels();
pleaseRegisterMenu = new PleaseRegisterMenu();
if (!User.getInstance().isRegistered()){
addChild(pleaseRegisterMenu);
};
}
override public function refresh():void{
listLevels();
}
protected function nextPage(event:Event):void{
if (pagingData.currentPage < (pagingData.getNumPages() - 1)){
pagingData.currentPage++;
};
listLevels();
}
protected function renderButtons(event:Event):void{
var levels:XML;
var level:XML;
var levelRow:MovieClip;
var publishBool:Boolean;
var message:TextArea;
var messageText:String;
levels = new XML(event.target.data);
pagingData.numResults = levels.levelCount;
pageCount.setText(((("Page " + (pagingData.currentPage + 1)) + " of ") + pagingData.getNumPages()));
removeChild(levelsCanvas);
levelsCanvas = new Sprite();
addChild(levelsCanvas);
var i:int;
for each (level in levels.level) {
if (level.publish == "1"){
publishBool = true;
} else {
publishBool = false;
};
levelRow = new SavedLevelRow(level.levelId, level.levelName, level.description, publishBool, editable);
levelRow.x = 225;
levelRow.y = (200 + (i * 70));
levelsCanvas.addChildAt(levelRow, 0);
levelRow.addEventListener(MenuEvent.DELETE_LEVEL, deleteLevel, false, 0, true);
i++;
};
if (i == 0){
if (editable){
messageText = "You haven't saved any\nlevels yet";
} else {
messageText = "There are not yet any\nsaved levels here";
};
message = new TextArea(messageText, 18);
message.x = 320;
message.y = 300;
message.bold();
message.textColor = 0x663300;
addChild(message);
};
finishedLoading();
if (!User.getInstance().isRegistered()){
addChild(pleaseRegisterMenu);
};
}
protected function listLevels():void{
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, renderButtons, false, 0, true);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/getUserLevels.php");
var variables:URLVariables = new URLVariables();
variables.userId = userId;
if (!editable){
variables.onlyPublished = "1";
};
variables.limitOffset = pagingData.getOffset();
variables.limitCount = pagingData.resultsPerPage;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
protected function confirmDelete(event:Event):void{
listLevels();
}
protected function loadSolutions(event:MenuEvent):void{
dispatchEvent(event);
}
protected function previousPage(event:Event):void{
if (pagingData.currentPage > 0){
pagingData.currentPage--;
};
listLevels();
}
protected function deleteLevel(e:Event):void{
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, confirmDelete);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/deleteLevel.php");
var variables:URLVariables = new URLVariables();
variables.levelId = e.target.levelId;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
protected function loadLevel(event:Event):void{
event.stopPropagation();
var menuEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_LEVEL);
menuEvent.levelId = event.target.levelId;
dispatchEvent(menuEvent);
}
}
}//package contraption.menu
Section 154
//UserMenu (contraption.menu.UserMenu)
package contraption.menu {
import flash.text.*;
public class UserMenu extends MenuWindow {
protected var userId:int;
protected var userName:String;
public function UserMenu(userId:int, userName:String){
super();
this.userName = userName;
this.userId = userId;
var backgroundClip:ModalMenuCloud = new ModalMenuCloud();
backgroundClip.x = 100;
backgroundClip.y = 80;
addChild(backgroundClip);
var format:TextFormat = new TextFormat();
format.size = 22;
format.bold = true;
var text:TextArea = new TextArea((userName + "'s Stuff"), 22, "arial", TextFieldAutoSize.CENTER);
text.bold();
text.width = 250;
text.x = 250;
text.y = 200;
addChild(text);
var button:Button = new SavedLevelsButton();
button.userId = userId;
button.x = 300;
button.y = 320;
addChild(button);
button = new SavedContraptionsButton();
button.userId = userId;
button.x = 300;
button.y = 250;
addChild(button);
}
}
}//package contraption.menu
Section 155
//XmlWindow (contraption.menu.XmlWindow)
package contraption.menu {
import flash.events.*;
import flash.text.*;
public class XmlWindow extends MenuWindow {
public var loadButton:Button;
public var xmlField:TextField;
public function XmlWindow():void{
loadButton = new Button("Load");
super(false);
var closeButton:Button = new Button("Close");
closeButton.x = 10;
closeButton.y = 10;
addChild(closeButton);
closeButton.addEventListener(MouseEvent.MOUSE_DOWN, closeXmlWindow);
loadButton.x = 80;
loadButton.y = 10;
addChild(loadButton);
xmlField = new TextField();
xmlField.width = 200;
xmlField.height = 300;
xmlField.type = TextFieldType.INPUT;
xmlField.background = true;
xmlField.backgroundColor = 0xFFFFFF;
xmlField.multiline = true;
xmlField.x = 10;
xmlField.y = 60;
addChild(xmlField);
visible = false;
}
protected function closeXmlWindow(event:MouseEvent):void{
visible = false;
}
}
}//package contraption.menu
Section 156
//AddedBlockBetweenWheelsOverlay (contraption.tutorials.AddedBlockBetweenWheelsOverlay)
package contraption.tutorials {
import contraption.*;
import contraption.blocks.*;
public class AddedBlockBetweenWheelsOverlay extends TutorialOverlay {
protected var player:Player;
public function AddedBlockBetweenWheelsOverlay(){
super();
}
override public function init(player:Player):void{
this.player = player;
player.addEventListener(TutorialEvent.ADDED_BLOCK, checkBlock, false, 0, true);
}
public function checkBlock(event:TutorialEvent):void{
if ((event.block as Rod).doesJoinWheelMiddles()){
overlayFinished();
} else {
player.deleteBlock(event.block);
};
}
override public function dispose(player:Player):void{
player.addEventListener(TutorialEvent.ADDED_BLOCK, checkBlock);
}
}
}//package contraption.tutorials
Section 157
//AddedBlockOverlay (contraption.tutorials.AddedBlockOverlay)
package contraption.tutorials {
import contraption.*;
public class AddedBlockOverlay extends TutorialOverlay {
public function AddedBlockOverlay(){
super();
}
override public function init(player:Player):void{
player.addEventListener(TutorialEvent.ADDED_BLOCK, overlayFinished, false, 0, true);
}
override public function dispose(player:Player):void{
player.removeEventListener(TutorialEvent.ADDED_BLOCK, overlayFinished);
}
}
}//package contraption.tutorials
Section 158
//DeleteBlockOverlay (contraption.tutorials.DeleteBlockOverlay)
package contraption.tutorials {
import contraption.*;
public class DeleteBlockOverlay extends TutorialOverlay {
public function DeleteBlockOverlay(){
super();
}
override public function init(player:Player):void{
player.addEventListener(TutorialEvent.REMOVED_BLOCK, overlayFinished, false, 0, true);
}
override public function dispose(player:Player):void{
player.removeEventListener(TutorialEvent.REMOVED_BLOCK, overlayFinished);
}
}
}//package contraption.tutorials
Section 159
//DeleteSelectedOverlay (contraption.tutorials.DeleteSelectedOverlay)
package contraption.tutorials {
import contraption.*;
public class DeleteSelectedOverlay extends TutorialOverlay {
public function DeleteSelectedOverlay(){
super();
}
override public function init(player:Player):void{
player.addEventListener(TutorialEvent.SELECTED_DELETE, overlayFinished, false, 0, true);
}
override public function dispose(player:Player):void{
player.removeEventListener(TutorialEvent.SELECTED_DELETE, overlayFinished);
}
}
}//package contraption.tutorials
Section 160
//HollowSelectedOverlay (contraption.tutorials.HollowSelectedOverlay)
package contraption.tutorials {
import contraption.*;
public class HollowSelectedOverlay extends TutorialOverlay {
public function HollowSelectedOverlay(){
super();
}
override public function init(player:Player):void{
player.addEventListener(TutorialEvent.SELECTED_HOLLOW, overlayFinished, false, 0, true);
}
override public function dispose(player:Player):void{
player.removeEventListener(TutorialEvent.SELECTED_HOLLOW, overlayFinished);
}
}
}//package contraption.tutorials
Section 161
//PressStartOverlay (contraption.tutorials.PressStartOverlay)
package contraption.tutorials {
import contraption.*;
public class PressStartOverlay extends TutorialOverlay {
public function PressStartOverlay(){
super();
}
override public function init(player:Player):void{
player.addEventListener(TutorialEvent.SELECTED_START, overlayFinished, false, 0, true);
}
override public function dispose(player:Player):void{
player.removeEventListener(TutorialEvent.SELECTED_START, overlayFinished);
}
}
}//package contraption.tutorials
Section 162
//PressStopOverlay (contraption.tutorials.PressStopOverlay)
package contraption.tutorials {
import contraption.*;
public class PressStopOverlay extends TutorialOverlay {
public function PressStopOverlay(){
super();
}
override public function init(player:Player):void{
player.addEventListener(TutorialEvent.SELECTED_STOP, overlayFinished, false, 0, true);
}
override public function dispose(player:Player):void{
player.removeEventListener(TutorialEvent.SELECTED_STOP, overlayFinished);
}
}
}//package contraption.tutorials
Section 163
//TutorialEvent (contraption.tutorials.TutorialEvent)
package contraption.tutorials {
import flash.events.*;
import contraption.blocks.*;
public class TutorialEvent extends Event {
public var block:Block;
public static const FINISHED_OVERLAY:String = "finishedOverlay";
public static const SELECTED_CLOCKWISE_WHEEL:String = "selectedClockwiseWheel";
public static const SELECTED_STOP:String = "selectedStop";
public static const ADDED_BLOCK:String = "addedBlock";
public static const SELECTED_DELETE:String = "selectedDelete";
public static const SELECTED_HOLLOW:String = "selectedWater";
public static const SKIP_TUTORIAL:String = "skipTutorial";
public static const REMOVED_BLOCK:String = "removedBlock";
public static const SELECTED_START:String = "selectedStart";
public function TutorialEvent(eventType:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(eventType, bubbles, cancelable);
}
override public function clone():Event{
var e:TutorialEvent = new TutorialEvent(type, bubbles, cancelable);
e.block = block;
return (e);
}
}
}//package contraption.tutorials
Section 164
//TutorialLevel1Overlays (contraption.tutorials.TutorialLevel1Overlays)
package contraption.tutorials {
import de.polygonal.ds.*;
public class TutorialLevel1Overlays extends TutorialOverlays {
public function TutorialLevel1Overlays():void{
overlays = new SLinkedList();
overlays.append(new tut1Welcome());
overlays.append(new tut1PinkBall());
overlays.append(new tut1Goal());
overlays.append(new tut1Workshop());
overlays.append(new tut1SelectWheel());
overlays.append(new tut1DrawWheel());
overlays.append(new tut1SelectWater());
overlays.append(new tut1DrawWater());
overlays.append(new tut1PressStart());
overlays.append(new tutLocked());
super();
}
}
}//package contraption.tutorials
Section 165
//TutorialLevel2Overlays (contraption.tutorials.TutorialLevel2Overlays)
package contraption.tutorials {
import de.polygonal.ds.*;
public class TutorialLevel2Overlays extends TutorialOverlays {
public function TutorialLevel2Overlays():void{
overlays = new SLinkedList();
overlays.append(new tut2Welcome());
overlays.append(new tut2FirstTry());
overlays.append(new tut2FirstStop());
overlays.append(new tut2FirstSelectDelete());
overlays.append(new tut2DeleteFirstRod());
overlays.append(new tut2FirstSelectWater());
overlays.append(new tut2FirstDrawWater());
overlays.append(new tut2SecondTry());
overlays.append(new tut2SecondStop());
overlays.append(new tut2SecondSelectDelete());
overlays.append(new tut2DeleteSecondRod());
overlays.append(new tut2SecondSelectWater());
overlays.append(new tut2SecondDrawWater());
overlays.append(new tut2ThirdTry());
overlays.append(new tut2ThirdTry());
overlays.append(new tutLocked());
super();
}
}
}//package contraption.tutorials
Section 166
//TutorialLevel3Overlays (contraption.tutorials.TutorialLevel3Overlays)
package contraption.tutorials {
import de.polygonal.ds.*;
public class TutorialLevel3Overlays extends TutorialOverlays {
public function TutorialLevel3Overlays():void{
overlays = new SLinkedList();
overlays.append(new tut3Wheels());
overlays.append(new tut3NonPowerWheel());
overlays.append(new tut3Water());
overlays.append(new tut3Wood());
overlays.append(new tut3Move());
overlays.append(new tut3Delete());
overlays.append(new tut3Start());
overlays.append(new tut3Zoom());
overlays.append(new tut3Save());
overlays.append(new tut3Back());
overlays.append(new tut3Goodbye());
super();
}
}
}//package contraption.tutorials
Section 167
//TutorialOverlay (contraption.tutorials.TutorialOverlay)
package contraption.tutorials {
import flash.events.*;
import contraption.*;
import flash.display.*;
public class TutorialOverlay extends MovieClip {
public function TutorialOverlay():void{
super();
addEventListener(MouseEvent.MOUSE_DOWN, stopEvent);
}
protected function stopEvent(event:Event):void{
event.stopPropagation();
}
protected function overlayFinished(event:Event=null):void{
dispatchEvent(new TutorialEvent(TutorialEvent.FINISHED_OVERLAY, true, true));
}
public function dispose(player:Player):void{
}
public function init(player:Player):void{
}
}
}//package contraption.tutorials
Section 168
//TutorialOverlays (contraption.tutorials.TutorialOverlays)
package contraption.tutorials {
import de.polygonal.ds.*;
public class TutorialOverlays {
protected var currentOverlay:SListNode;
protected var overlays:SLinkedList;
public function TutorialOverlays():void{
super();
currentOverlay = overlays.head;
}
public function firstOverlay():TutorialOverlay{
return ((overlays.head.data as TutorialOverlay));
}
public function getNext():TutorialOverlay{
if (currentOverlay.next == null){
return (null);
};
currentOverlay = currentOverlay.next;
return ((currentOverlay.data as TutorialOverlay));
}
}
}//package contraption.tutorials
Section 169
//TutorialPlayer (contraption.tutorials.TutorialPlayer)
package contraption.tutorials {
import flash.events.*;
import contraption.menu.*;
import contraption.*;
import flash.display.*;
import contraption.blocks.*;
import contraption.data.*;
public class TutorialPlayer extends Player {
protected var tutorialNumber:int;
protected var tutorialCanvas:Sprite;
protected var currentOverlay:TutorialOverlay;
protected var overlays:TutorialOverlays;
public function TutorialPlayer(stage:Stage, parentContraption:Contraption){
super(stage, parentContraption);
tutorialCanvas = new Sprite();
addChild(tutorialCanvas);
var skipButton:SkipTutorialButton = new SkipTutorialButton();
skipButton.x = 570;
skipButton.y = 430;
skipButton.addEventListener(TutorialEvent.SKIP_TUTORIAL, skipTutorial, false, 0, true);
addChild(skipButton);
}
public function loadTutorialLevel(tutorialNumber:int):void{
var retrieveLevel:XML = TutorialLevels.getTutorialLevels()[("level" + tutorialNumber)].retrieveLevel[0];
loadRetrievedLevelFromXML(retrieveLevel);
this.tutorialNumber = retrieveLevel.tutorialNumber;
switch (tutorialNumber){
case 1:
overlays = new TutorialLevel1Overlays();
break;
case 2:
overlays = new TutorialLevel2Overlays();
break;
case 3:
overlays = new TutorialLevel3Overlays();
break;
default:
throw (new Error("Invalid Tutorial"));
};
loadOverlay(overlays.firstOverlay());
}
override protected function startSimulation(e:Event):void{
super.startSimulation(e);
dispatchEvent(new TutorialEvent(TutorialEvent.SELECTED_START, true, true));
}
protected function loadOverlay(newOverlay:TutorialOverlay):void{
if (currentOverlay != null){
currentOverlay.dispose(this);
tutorialCanvas.removeChild(currentOverlay);
};
if (newOverlay != null){
currentOverlay = newOverlay;
currentOverlay.init(this);
currentOverlay.addEventListener(TutorialEvent.FINISHED_OVERLAY, incrementOverlay, false, 0, true);
tutorialCanvas.addChild(currentOverlay);
};
}
override protected function loadNextLevel():void{
var completeEvent:MenuEvent = new MenuEvent(MenuEvent.TUTORIAL_LEVEL_COMPLETE, true, true);
completeEvent.tutorialNumber = tutorialNumber;
dispatchEvent(completeEvent);
}
override protected function clockwiseWheelMode(e:Event):void{
super.clockwiseWheelMode(e);
dispatchEvent(new TutorialEvent(TutorialEvent.SELECTED_CLOCKWISE_WHEEL, true, true));
}
override protected function updateMoveScreen(event:MouseEvent=null):void{
}
override protected function zoomIn(event:Event=null):void{
}
override protected function hollowRodMode(e:Event):void{
super.hollowRodMode(e);
dispatchEvent(new TutorialEvent(TutorialEvent.SELECTED_HOLLOW, true, true));
}
protected function incrementOverlay(event:TutorialEvent):void{
var newOverlay:TutorialOverlay = overlays.getNext();
loadOverlay(newOverlay);
}
override public function deleteBlock(block:Block):void{
super.deleteBlock(block);
var event:TutorialEvent = new TutorialEvent(TutorialEvent.REMOVED_BLOCK, true, true);
event.block = block;
dispatchEvent(event);
}
override protected function enterDeleteMode(e:Event):void{
super.enterDeleteMode(e);
dispatchEvent(new TutorialEvent(TutorialEvent.SELECTED_DELETE, true, true));
}
override protected function keyDown(event:KeyboardEvent):void{
}
override protected function stopSimulation(e:Event):void{
super.stopSimulation(e);
dispatchEvent(new TutorialEvent(TutorialEvent.SELECTED_STOP, true, true));
}
override protected function addedBlock(block:Block):void{
super.addedBlock(block);
var event:TutorialEvent = new TutorialEvent(TutorialEvent.ADDED_BLOCK, true, true);
event.block = block;
dispatchEvent(event);
}
override protected function mouseWheel(event:MouseEvent):void{
}
override public function addTitle(title:String):void{
}
override protected function hasPermissionToPlay():Boolean{
return (true);
}
override protected function zoomOut(event:Event=null):void{
}
protected function skipTutorial(event:Event):void{
loadNextLevel();
}
}
}//package contraption.tutorials
Section 170
//WheelSelectedOverlay (contraption.tutorials.WheelSelectedOverlay)
package contraption.tutorials {
import contraption.*;
public class WheelSelectedOverlay extends TutorialOverlay {
public function WheelSelectedOverlay(){
super();
}
override public function init(player:Player):void{
player.addEventListener(TutorialEvent.SELECTED_CLOCKWISE_WHEEL, overlayFinished, false, 0, true);
}
override public function dispose(player:Player):void{
player.removeEventListener(TutorialEvent.SELECTED_CLOCKWISE_WHEEL, overlayFinished);
}
}
}//package contraption.tutorials
Section 171
//ActionContainer (contraption.ActionContainer)
package contraption {
public interface ActionContainer {
function getAllowableActions():Actions;
function setAllowableActions(C:\development\whirled\Contraption;contraption;ActionContainer.as:Actions):void;
}
}//package contraption
Section 172
//ActionContainerImpl (contraption.ActionContainerImpl)
package contraption {
import flash.display.*;
public class ActionContainerImpl extends MovieClip implements ActionContainer {
protected var allowableActions:Actions;
public function ActionContainerImpl():void{
super();
initAllowableActions();
}
public function getAllowableActions():Actions{
return (allowableActions);
}
protected function initAllowableActions():void{
allowableActions = new Actions();
}
public function setAllowableActions(allowableActions:Actions):void{
this.allowableActions = allowableActions;
}
}
}//package contraption
Section 173
//Actions (contraption.Actions)
package contraption {
public class Actions {
public var alwaysDrag:Boolean;
public var build:Boolean;
public var move:Boolean;
public var button:Boolean;
public var drag:Boolean;
public var inputText:Boolean;
public var delete_:Boolean;
public function Actions(){
super();
}
}
}//package contraption
Section 174
//Arena (contraption.Arena)
package contraption {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import contraption.blocks.*;
import flash.geom.*;
import flash.net.*;
import de.polygonal.ds.*;
import Box2D.Dynamics.*;
import flash.text.*;
import contraption.data.*;
import flash.ui.*;
import flash.errors.*;
public class Arena extends MenuWindow {
protected var goalBlocks:SLinkedList;
protected var movingScreen:Boolean;// = false
protected var physicsWorld:b2World;
protected var saveButton:Button;
protected var dashboard:Dashboard;
protected var editing:Boolean;
protected var screenMoveX:Number;
protected var screenMoveY:Number;
protected var arenaForegroundCanvas:Sprite;
protected var permissionToPlayLevel:Boolean;// = true
protected var endZone:EndZone;
protected var startZone:StartZone;
protected var targetScale:Number;// = 1
protected var levelId:int;// = 0
protected var parentContraption:Contraption;
public var arenaCanvas:Sprite;
protected var scaleVelocity:Number;// = 0
protected var arenaBackgroundCanvas:Sprite;
protected var playerBlocks:BlockCollection;
protected var saveWindow:SaveWindow;
protected var arenaBlocks:SLinkedList;
protected var xmlWindow:XmlWindow;
protected var menuButton:Button;
protected var ta:TextField;
protected var levelNumber:int;// = 0
public static var ARENA_WIDTH:Number = 2000;
public static var MAXIMUM_SCALE:Number = 2.5;
public static var ARENA_HEIGHT:Number = 1450;
public function Arena(stage:Stage, parentContraption:Contraption, editing:Boolean):void{
arenaCanvas = new Sprite();
arenaForegroundCanvas = new Sprite();
arenaBackgroundCanvas = new Sprite();
xmlWindow = new XmlWindow();
super(false);
graphics.beginFill(0xFFFFFF, 0);
graphics.drawRect(0, 0, 700, 500);
this.parentContraption = parentContraption;
this.editing = editing;
addChild(arenaCanvas);
arenaCanvas.addChild(arenaBackgroundCanvas);
arenaCanvas.addChild(arenaForegroundCanvas);
var clouds:Clouds = new Clouds();
clouds.x = -1000;
clouds.y = -1000;
arenaBackgroundCanvas.addChild(clouds);
ta = new TextField();
ta.width = 200;
addChild(ta);
ta.mouseEnabled = false;
playerBlocks = new BlockCollection();
goalBlocks = new SLinkedList();
arenaBlocks = new SLinkedList();
startZone = new StartZone(editing);
startZone.setPosition(new Point(-150, 50));
arenaBackgroundCanvas.addChild(startZone);
endZone = new EndZone(editing);
endZone.setPosition(new Point(150, 50));
arenaBackgroundCanvas.addChild(endZone);
arenaCanvas.x = 350;
arenaCanvas.y = 250;
dashboard = new DashboardImpl();
dashboard.gotoAndPlay(1);
addChild(dashboard);
dashboard.addEventListener(DashboardEvent.ZOOM_IN, zoomIn);
dashboard.addEventListener(DashboardEvent.ZOOM_OUT, zoomOut);
menuButton = new Button("Back to\nMenu");
menuButton.x = 600;
menuButton.y = 340;
addChild(menuButton);
menuButton.addEventListener(MouseEvent.MOUSE_DOWN, returnToMenu);
xmlWindow = new XmlWindow();
addChild(xmlWindow);
addEventListener(Event.ENTER_FRAME, update, false, 0, true);
var globalListener:GlobalListener = GlobalListener.getInstance();
globalListener.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheel, false, 0, true);
globalListener.addEventListener(KeyboardEvent.KEY_DOWN, keyDown, false, 0, true);
parentContraption.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown, false, 0, true);
parentContraption.addEventListener(MouseEvent.MOUSE_MOVE, updateMoveScreen, false, 0, true);
parentContraption.addEventListener(MouseEvent.MOUSE_UP, stopMoveScreen, false, 0, true);
}
public function loadBlocks(id:int, loadDesign:Boolean, useOfficialLevelNumber:Boolean=false):void{
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadLevelHandler);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/retrieveLevel.php");
var variables:URLVariables = new URLVariables();
if (loadDesign){
variables.loadDesign = 1;
};
if (useOfficialLevelNumber){
variables.useOfficialLevelNumber = 1;
};
variables.id = id;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
protected function newSaveWindow():SaveWindow{
throw (new IllegalOperationError("You must extend Arena and implement \"newSaveWindow\""));
}
protected function checkPlayerBlocksAreWithinStart():void{
var block:Object;
var rod:Rod;
var blockIter:Iterator = arenaBlocks.getIterator();
blockIter = playerBlocks.getIterator();
while (blockIter.hasNext()) {
block = blockIter.next();
if ((block as Wheel)){
};
if ((block as Rod)){
rod = (block as Rod);
if (((!(startZone.isInside(rod.point1))) || (!(startZone.isInside(rod.point2))))){
deleteBlock(rod);
};
};
};
}
public function loadOfficialLevel(levelNumber:int):void{
loadRetrievedLevelFromXML(OfficialLevels.getOfficialLevels()[("level" + levelNumber)].retrieveLevel[0]);
}
protected function addGoalBlock(block:EditableBlock):void{
addEditableBlock(block);
goalBlocks.append(block);
playerBlocks.append(block);
}
override public function disposeMenu():void{
super.disposeMenu();
GlobalListener.getInstance().removeEventListener(KeyboardEvent.KEY_DOWN, keyDown);
}
public function deleteBlock(block:Block):void{
removeChildBlock(block);
playerBlocks.deleteBlock(physicsWorld, block);
}
protected function getToppestLeftest(point1:Point, point2:Point):Point{
var point:Point = new Point(point1.x, point1.y);
if (point1.x > point2.x){
point.x = point2.x;
};
if (point1.y > point2.y){
point.y = point2.y;
};
return (point);
}
protected function hasPermissionToPlay():Boolean{
return (((!((levelNumber == 0))) || (User.getInstance().isRegistered())));
}
protected function loadLevelHandler(event:Event):void{
loadRetrievedLevelFromXML(new XML(event.target.data));
}
protected function beginMoveScreen(screenMoveX:Number, screenMoveY:Number):void{
movingScreen = true;
this.screenMoveX = screenMoveX;
this.screenMoveY = screenMoveY;
}
protected function limitZoom():void{
if (targetScale > MAXIMUM_SCALE){
targetScale = MAXIMUM_SCALE;
} else {
if ((targetScale * ARENA_WIDTH) < 700){
targetScale = (700 / ARENA_WIDTH);
} else {
if ((targetScale * ARENA_HEIGHT) < 500){
targetScale = (500 / ARENA_HEIGHT);
};
};
};
}
protected function addTutorialOverlay(levelNumber:int):void{
if (levelNumber == 2){
arenaBackgroundCanvas.addChild(new Level4Overlay());
};
}
protected function mouseWheel(event:MouseEvent):void{
if (!hasFocus()){
return;
};
targetScale = (targetScale + (event.delta / 50));
limitZoom();
}
public function addTitle(title:String):void{
var text:TextArea = new TextArea(title, 26, "contraptionFont", "right");
text.embedFonts = true;
text.height = 50;
text.width = 400;
text.x = 240;
text.y = 430;
addChild(text);
}
protected function clearPlayerBlocks():void{
var block:Block;
var blockIter:Iterator = playerBlocks.getIterator();
while (blockIter.hasNext()) {
block = (blockIter.next() as Block);
block.destroyBlock(physicsWorld);
removeChildBlock(block);
};
playerBlocks.clear();
}
public function loadLevel(levelId:int):void{
loadBlocks(levelId, false);
}
public function initZoomAndScroll():void{
var block:Block;
var topLeft:Point = new Point(100000, 100000);
var bottomRight:Point = new Point(-100000, -100000);
topLeft = getToppestLeftest(topLeft, startZone.getPosition().subtract(new Point((startZone.getWidth() / 2), (startZone.getHeight() / 2))));
topLeft = getToppestLeftest(topLeft, endZone.getPosition().subtract(new Point((endZone.getWidth() / 2), (endZone.getHeight() / 2))));
bottomRight = getBottomestRightest(bottomRight, startZone.getPosition().add(new Point((endZone.getWidth() / 2), (endZone.getHeight() / 2))));
bottomRight = getBottomestRightest(bottomRight, endZone.getPosition().add(new Point((endZone.getWidth() / 2), (endZone.getHeight() / 2))));
var blockIter:Iterator = goalBlocks.getIterator();
while (blockIter.hasNext()) {
block = (blockIter.next() as Block);
topLeft = getToppestLeftest(topLeft, block.getPosition());
bottomRight = getBottomestRightest(bottomRight, block.getPosition());
};
arenaCanvas.x = -((((topLeft.x + bottomRight.x) / 2) - (700 / 2)));
arenaCanvas.y = (-((((topLeft.y + bottomRight.y) / 2) - (500 / 2))) / (4 / 5));
var xDist:Number = (bottomRight.x - topLeft.x);
var yDist:Number = (bottomRight.y - topLeft.y);
if (xDist > yDist){
targetScale = (700 / (xDist + 100));
} else {
targetScale = ((500 / (yDist + 100)) / (4 / 5));
};
scaleTo(targetScale);
}
protected function limitCanvasMovement():void{
var localTopLeft:Point = arenaCanvas.globalToLocal(parentContraption.localToGlobal(new Point(0, 0)));
var localBottomRight:Point = arenaCanvas.globalToLocal(parentContraption.localToGlobal(new Point(700, 500)));
if (localTopLeft.x < (-(ARENA_WIDTH) / 2)){
arenaCanvas.x = ((ARENA_WIDTH / 2) * arenaCanvas.scaleX);
} else {
if (localBottomRight.x > (ARENA_WIDTH / 2)){
arenaCanvas.x = -((((ARENA_WIDTH / 2) * arenaCanvas.scaleX) - 700));
};
};
if (localTopLeft.y < (-(ARENA_HEIGHT) / 2)){
arenaCanvas.y = ((ARENA_HEIGHT / 2) * arenaCanvas.scaleX);
} else {
if (localBottomRight.y > (ARENA_HEIGHT / 2)){
arenaCanvas.y = -((((ARENA_HEIGHT / 2) * arenaCanvas.scaleX) - 500));
};
};
}
protected function keyDown(event:KeyboardEvent):void{
if (!hasFocus()){
return;
};
if (event.keyCode == Keyboard.LEFT){
arenaCanvas.x = (arenaCanvas.x + 20);
};
if (event.keyCode == Keyboard.RIGHT){
arenaCanvas.x = (arenaCanvas.x - 20);
};
if (event.keyCode == Keyboard.UP){
arenaCanvas.y = (arenaCanvas.y + 20);
};
if (event.keyCode == Keyboard.DOWN){
arenaCanvas.y = (arenaCanvas.y - 20);
};
limitCanvasMovement();
if (event.keyCode == 73){
zoomIn();
};
if (event.keyCode == 79){
zoomOut();
};
if (targetScale > MAXIMUM_SCALE){
targetScale = MAXIMUM_SCALE;
} else {
if ((targetScale * ARENA_WIDTH) < 700){
targetScale = (700 / ARENA_WIDTH);
};
};
if (event.keyCode == 88){
};
}
public function update(e:Event):void{
if (arenaCanvas.scaleX > (targetScale + 0.01)){
scaleTo((arenaCanvas.scaleX - scaleVelocity));
scaleVelocity = (scaleVelocity + 0.01);
if (scaleVelocity > ((arenaCanvas.scaleX - targetScale) / 5)){
scaleVelocity = ((arenaCanvas.scaleX - targetScale) / 5);
};
} else {
if (arenaCanvas.scaleX < (targetScale - 0.01)){
scaleTo((arenaCanvas.scaleX - scaleVelocity));
scaleVelocity = (scaleVelocity - 0.01);
if (scaleVelocity < ((arenaCanvas.scaleX - targetScale) / 5)){
scaleVelocity = ((arenaCanvas.scaleX - targetScale) / 5);
};
};
};
}
protected function returnToMenu(event:MouseEvent):void{
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK));
}
public function loadDesign(designId:int):void{
loadBlocks(designId, true);
}
protected function getBottomestRightest(point1:Point, point2:Point):Point{
var point:Point = new Point(point1.x, point1.y);
if (point1.x < point2.x){
point.x = point2.x;
};
if (point1.y < point2.y){
point.y = point2.y;
};
return (point);
}
protected function onBeginEditing(event:BeginEditingEvent):void{
addChildBlock(event.block);
}
protected function addChildBlock(block:Block):void{
block.addEventListener(BeginEditingEvent.BEGIN_EDITING, onBeginEditing);
block.addEventListener(DeleteBlockEvent.DELETE_BLOCK, onDelete);
arenaForegroundCanvas.addChild(block);
arenaBackgroundCanvas.addChild(block.getBlockBackground());
}
public function loadFromXml(xml:XML):void{
var block:EditableBlock;
var blockXml:XML;
var playerBlock:Block;
var blockIter:Iterator = arenaBlocks.getIterator();
while (blockIter.hasNext()) {
block = (blockIter.next() as EditableBlock);
block.destroyBlock(physicsWorld);
removeChildBlock(block);
};
arenaBlocks.clear();
clearPlayerBlocks();
playerBlocks = new BlockCollection();
goalBlocks = new SLinkedList();
arenaBlocks = new SLinkedList();
startZone.setFromXML(xml.start[0]);
endZone.setFromXML(xml.end[0]);
for each (blockXml in xml.levelBlocks.*) {
block = BlockCollection.createLevelBlockFromXml(blockXml, physicsWorld, editing);
addArenaBlock(block);
};
for each (blockXml in xml.playerBlocks.*) {
playerBlock = playerBlocks.createPlayerBlockFromXml(blockXml, editing);
if (playerBlock.isGoalBlock){
goalBlocks.append(playerBlock);
};
addChildBlock(playerBlock);
};
checkPlayerBlocksAreWithinStart();
finishedLoading();
if (!hasPermissionToPlay()){
addChild(new LinkedIntoBadLevelMenu());
permissionToPlayLevel = false;
};
}
protected function stopMoveScreen(event:MouseEvent=null):void{
movingScreen = false;
}
protected function zoomIn(event:Event=null):void{
targetScale = (targetScale + 0.1);
limitZoom();
}
protected function loadFromxmlWindow(event:MouseEvent):void{
loadFromXml(new XML(xmlWindow.xmlField.text));
}
protected function updateMoveScreen(event:MouseEvent=null):void{
if (movingScreen){
arenaCanvas.x = (arenaCanvas.x + (mouseX - screenMoveX));
arenaCanvas.y = (arenaCanvas.y + (mouseY - screenMoveY));
screenMoveX = mouseX;
screenMoveY = mouseY;
limitCanvasMovement();
};
}
protected function addArenaBlock(block:EditableBlock):void{
addEditableBlock(block);
arenaBlocks.append(block);
}
protected function scaleTo(scale:Number):void{
if ((((stage == null)) || ((arenaCanvas == null)))){
return;
};
var middlePoint:Point = arenaCanvas.globalToLocal(parentContraption.localToGlobal(new Point((700 / 2), (500 / 2))));
var deltaScale:Number = (scale - arenaCanvas.scaleX);
arenaCanvas.scaleX = scale;
arenaCanvas.scaleY = scale;
arenaCanvas.x = (arenaCanvas.x - (middlePoint.x * deltaScale));
arenaCanvas.y = (arenaCanvas.y - (middlePoint.y * deltaScale));
limitCanvasMovement();
}
protected function mouseDown(event:MouseEvent):void{
if (((!(parent)) || ((visible == false)))){
return;
};
event.stopPropagation();
beginMoveScreen(mouseX, mouseY);
}
protected function addEditableBlock(block:EditableBlock):void{
addChildBlock(block);
}
protected function onDelete(event:DeleteBlockEvent):void{
var block:EditableBlock = event.block;
block.destroyBlock(physicsWorld);
removeChildBlock(block);
if (arenaBlocks.nodeOf(block) != null){
arenaBlocks.remove(arenaBlocks.nodeOf(block));
};
if (goalBlocks.nodeOf(block) != null){
goalBlocks.remove(goalBlocks.nodeOf(block));
};
if (playerBlocks.nodeOf(block) != null){
playerBlocks.remove(playerBlocks.nodeOf(block));
};
}
protected function loadRetrievedLevelFromXML(retrieveLevel:XML):void{
levelId = retrieveLevel.levelId;
levelNumber = retrieveLevel.levelNumber;
loadFromXml(retrieveLevel.level[0]);
addTitle(retrieveLevel.name);
addTutorialOverlay(levelNumber);
initZoomAndScroll();
}
public function getLevelXml():XML{
var block:Block;
var blockXml:XML;
var saveXml:XML = <level/>
;
var levelBlocksXml:XML = <levelBlocks/>
;
var playerBlocksXml:XML = <playerBlocks/>
;
saveXml.appendChild(levelBlocksXml);
saveXml.appendChild(playerBlocksXml);
saveXml.appendChild(startZone.getXml());
saveXml.appendChild(endZone.getXml());
var blockIter:Iterator = arenaBlocks.getIterator();
while (blockIter.hasNext()) {
block = (blockIter.next() as EditableBlock);
levelBlocksXml.appendChild(block.getXml());
};
blockIter = playerBlocks.getIterator();
while (blockIter.hasNext()) {
block = (blockIter.next() as Block);
block.saveIndex = undefined;
};
blockIter = playerBlocks.getIterator();
var i:int;
while (blockIter.hasNext()) {
block = (blockIter.next() as Block);
block.saveIndex = i;
i++;
};
blockIter = playerBlocks.getIterator();
while (blockIter.hasNext()) {
block = (blockIter.next() as Block);
blockXml = block.getXml();
playerBlocksXml.appendChild(blockXml);
};
return (saveXml);
}
protected function removeChildBlock(block:Block):void{
arenaForegroundCanvas.removeChild(block);
arenaBackgroundCanvas.removeChild(block.getBlockBackground());
}
public function hasFocus():Boolean{
return (((((((parent) && ((visible == true)))) && (parentContraption.isCurrentMenu(this)))) && (permissionToPlayLevel)));
}
protected function zoomOut(event:Event=null):void{
targetScale = (targetScale - 0.1);
limitZoom();
}
public function isInStartZone(point:Point):Boolean{
return (startZone.isInside(arenaCanvas.globalToLocal(parentContraption.localToGlobal(point))));
}
}
}//package contraption
Section 175
//BuildingPointer (contraption.BuildingPointer)
package contraption {
import flash.display.*;
public class BuildingPointer extends MousePointer {
public function BuildingPointer(acting:Boolean):void{
super(acting);
}
override protected function getActingPointer():MovieClip{
return (new BuildingMousePointer());
}
override protected function getPointer():MovieClip{
return (new BuildingMousePointer());
}
}
}//package contraption
Section 176
//ButtonPointer (contraption.ButtonPointer)
package contraption {
import flash.display.*;
public class ButtonPointer extends MousePointer {
public function ButtonPointer(acting:Boolean):void{
super(acting);
}
override protected function getActingPointer():MovieClip{
return (new ButtonMousePointer());
}
override protected function getPointer():MovieClip{
return (new ButtonMousePointer());
}
}
}//package contraption
Section 177
//Configuration (contraption.Configuration)
package contraption {
import flash.net.*;
public class Configuration {
protected var simpleGraphicsMode:Boolean;
protected var userCookie:SharedObject;
protected var mute:Boolean;
private static var allowInstantiation:Boolean;
private static var instance:Configuration;
public function Configuration():void{
super();
if (!allowInstantiation){
throw (new Error("Error: Instantiation failed: Use Configuration.getInstance() instead of new."));
};
userCookie = SharedObject.getLocal("configuration");
if (userCookie.data.simpleGraphicsMode != null){
simpleGraphicsMode = (userCookie.data.simpleGraphicsMode as Boolean);
mute = (userCookie.data.mute as Boolean);
} else {
simpleGraphicsMode = false;
};
}
public function isMuted():Boolean{
return (mute);
}
public function setSimpleGraphicsMode(simpleGraphicsMode:Boolean):void{
this.simpleGraphicsMode = simpleGraphicsMode;
userCookie.data.simpleGraphicsMode = simpleGraphicsMode;
}
public function setMute(mute:Boolean):void{
this.mute = mute;
userCookie.data.mute = mute;
}
public function isInSimpleGraphicsMode():Boolean{
return (simpleGraphicsMode);
}
public static function getInstance():Configuration{
if (instance == null){
allowInstantiation = true;
instance = new (Configuration);
allowInstantiation = false;
};
return (instance);
}
}
}//package contraption
Section 178
//ContraptionUrlLoader (contraption.ContraptionUrlLoader)
package contraption {
import flash.events.*;
import contraption.menu.*;
import flash.net.*;
public class ContraptionUrlLoader extends URLLoader {
protected var addSpinner:Boolean;
public function ContraptionUrlLoader(addSpinner:Boolean=true, request:URLRequest=null){
super(request);
this.addSpinner = addSpinner;
addEventListener(Event.COMPLETE, loadComplete);
}
protected function loadComplete(event:Event):void{
if (addSpinner){
dispatchEvent(new MenuEvent(MenuEvent.REMOVE_SPINNER, true, true));
};
}
override public function load(request:URLRequest):void{
if (addSpinner){
dispatchEvent(new MenuEvent(MenuEvent.ADD_SPINNER, true, true));
};
super.load(request);
}
}
}//package contraption
Section 179
//DeletePointer (contraption.DeletePointer)
package contraption {
import flash.display.*;
public class DeletePointer extends MousePointer {
public function DeletePointer(acting:Boolean):void{
super(acting);
}
override protected function getActingPointer():MovieClip{
return (new DeleteMousePointer());
}
override protected function getPointer():MovieClip{
return (new DeleteMousePointer());
}
}
}//package contraption
Section 180
//DragPointer (contraption.DragPointer)
package contraption {
import flash.display.*;
public class DragPointer extends MousePointer {
public function DragPointer(acting:Boolean):void{
super(acting);
}
override protected function getActingPointer():MovieClip{
return (new DragActingMousePointer());
}
override protected function getPointer():MovieClip{
return (new DragMousePointer());
}
}
}//package contraption
Section 181
//Editor (contraption.Editor)
package contraption {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import contraption.blocks.*;
import flash.geom.*;
public class Editor extends Arena {
protected var pleaseRegisterMenu:PleaseRegisterMenu;
public function Editor(stage:Stage, parentContraption:Contraption){
super(stage, parentContraption, true);
graphics.beginFill(16703853, 1);
graphics.drawRect(0, 0, 700, 500);
dashboard.setMode(Dashboard.MODE_EDIT_LEVEL);
dashboard.addEventListener(DashboardEvent.SAVE, saveLevel);
dashboard.addEventListener(DashboardEvent.GOAL_CIRCLE, addGoalCircle);
dashboard.addEventListener(DashboardEvent.GOAL_SQUARE, addGoalRectangle);
dashboard.addEventListener(DashboardEvent.STATIC_CIRCLE, addStaticCircle);
dashboard.addEventListener(DashboardEvent.STATIC_SQUARE, addStaticRectangle);
dashboard.addEventListener(DashboardEvent.DYNAMIC_CIRCLE, addDynamicCircle);
dashboard.addEventListener(DashboardEvent.DYNAMIC_SQUARE, addDynamicRectangle);
dashboard.addEventListener(DashboardEvent.TEST_LEVEL, tryLevel);
pleaseRegisterMenu = new PleaseRegisterMenu();
if (!User.getInstance().isRegistered()){
addChild(pleaseRegisterMenu);
};
}
protected function addStaticRectangle(event:Event):void{
if (isOverMaxBlocks()){
return;
};
var block:EditableBlock = new StaticRectangle(true, arenaCanvas.globalToLocal(new Point(200, 200)));
addArenaBlock(block);
}
protected function addGoalCircle(event:Event):void{
if (isOverMaxBlocks()){
return;
};
var block:EditableBlock = new Wheel(arenaCanvas.globalToLocal(new Point(200, 200)), Wheel.NO_SPIN, 0, NaN, true, true);
addGoalBlock(block);
}
protected function saveLevel(event:Event):void{
if (event.target == this){
return;
};
event.stopPropagation();
var saveEvent:SaveEvent = new SaveEvent(SaveEvent.SAVE_LEVEL, true, true);
saveEvent.xml = getLevelXml();
dispatchEvent(saveEvent);
}
protected function tryLevel(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.TRY_LEVEL));
}
protected function isOverMaxBlocks():Boolean{
return (false);
}
override protected function newSaveWindow():SaveWindow{
return (new SaveLevelWindow());
}
protected function addDynamicRectangle(event:Event):void{
if (isOverMaxBlocks()){
return;
};
var block:EditableBlock = new DynamicRectangle(true, false, arenaCanvas.globalToLocal(new Point(200, 200)));
addArenaBlock(block);
}
protected function addDynamicCircle(event:Event):void{
if (isOverMaxBlocks()){
return;
};
var block:EditableBlock = new DynamicCircle(true, arenaCanvas.globalToLocal(new Point(200, 200)));
addArenaBlock(block);
}
protected function addGoalRectangle(event:Event):void{
if (isOverMaxBlocks()){
return;
};
var block:EditableBlock = new JointedDynamicRectangle(true, true, arenaCanvas.globalToLocal(new Point(200, 200)));
addGoalBlock(block);
}
protected function addStaticCircle(event:Event):void{
if (isOverMaxBlocks()){
return;
};
var block:EditableBlock = new StaticCircle(true, arenaCanvas.globalToLocal(new Point(200, 200)));
addArenaBlock(block);
}
}
}//package contraption
Section 182
//EndZone (contraption.EndZone)
package contraption {
import contraption.menu.*;
public class EndZone extends StartZone {
public function EndZone(editing:Boolean):void{
super(editing);
}
override protected function drawZone():void{
var text:TextArea;
if (!editing){
text = new TextArea("Goal", 18);
text.bold();
text.textColor = 15496308;
text.x = -22;
text.y = -15;
addChild(text);
};
super.drawZone();
}
override protected function initAllowableActions():void{
allowableActions = new Actions();
allowableActions.alwaysDrag = true;
}
override protected function getColour():int{
return (15831441);
}
override protected function getXmlRoot():XML{
return (<end/>
);
}
override protected function getBorderColour():int{
return (12281446);
}
}
}//package contraption
Section 183
//GlobalListener (contraption.GlobalListener)
package contraption {
import flash.display.*;
import com.whirled.game.*;
public class GlobalListener {
protected var whirledControl:GameControl;
protected var stage:Stage;
protected var whirledConnected:Boolean;// = false
private static var allowInstantiation:Boolean;
private static var instance:GlobalListener;
public function GlobalListener():void{
super();
if (!allowInstantiation){
throw (new Error("Error: Instantiation failed: Use Configuration.getInstance() instead of new."));
};
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void{
if (whirledConnected){
whirledControl.local.removeEventListener(type, listener, useCapture);
} else {
stage.removeEventListener(type, listener, useCapture);
};
}
public function init(stage:Stage, uiRoot:DisplayObject):void{
this.stage = stage;
whirledControl = new GameControl(uiRoot);
if (whirledControl.isConnected()){
whirledConnected = true;
};
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{
if (whirledConnected){
whirledControl.local.addEventListener(type, listener, useCapture, priority, useWeakReference);
} else {
stage.addEventListener(type, listener, useCapture, priority, useWeakReference);
};
}
public static function getInstance():GlobalListener{
if (instance == null){
allowInstantiation = true;
instance = new (GlobalListener);
allowInstantiation = false;
};
return (instance);
}
}
}//package contraption
Section 184
//ModeEvent (contraption.ModeEvent)
package contraption {
import flash.events.*;
public class ModeEvent extends Event {
public var actionType:int;
public static const ACTION_UNKNOWN:int = 0;
public static const ACTION_BUILD:int = 2;
public static const DEFAULT_MODE:String = "defaultMode";
public static const MOVE_MODE:String = "moveMode";
public static const END_ACTION:String = "endAction";
public static const START_ACTION:String = "startAction";
public static const DELETE_MODE:String = "deleteMode";
public static const ACTION_MOVE:int = 1;
public static const ACTION_BUTTON:int = 3;
public function ModeEvent(eventType:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(eventType, bubbles, cancelable);
actionType = ACTION_UNKNOWN;
}
override public function clone():Event{
var e:ModeEvent = new ModeEvent(type, bubbles, cancelable);
e.actionType = actionType;
return (e);
}
}
}//package contraption
Section 185
//MousePointer (contraption.MousePointer)
package contraption {
import flash.display.*;
public class MousePointer extends Sprite {
protected var acting:Boolean;
public static var NORMAL_DOWN:Number = 1;
public static var BUILDING_UP:Number = 2;
public static var DRAG_UP:Number = 8;
public static var MOVE_UP:Number = 6;
public static var BUILDING_DOWN:Number = 3;
public static var DELETE_UP:Number = 4;
public static var MOVE_DOWN:Number = 7;
public static var BUTTON_DOWN:Number = 11;
public static var NORMAL_UP:Number = 0;
public static var DELETE_DOWN:Number = 5;
public static var BUTTON_UP:Number = 10;
public static var DRAG_DOWN:Number = 9;
public function MousePointer(acting:Boolean):void{
super();
mouseEnabled = false;
if (acting){
drawActingPointer();
} else {
drawPointer();
};
}
public function getActing():Boolean{
return (acting);
}
protected function getPointer():MovieClip{
return (new DefaultMousePointer());
}
protected function drawActingPointer():void{
var pointer:MovieClip = getActingPointer();
pointer.mouseEnabled = false;
addChild(pointer);
}
protected function drawPointer():void{
var pointer:MovieClip = getPointer();
pointer.mouseEnabled = false;
addChild(pointer);
}
protected function getActingPointer():MovieClip{
return (new DefaultMousePointer());
}
}
}//package contraption
Section 186
//MovePointer (contraption.MovePointer)
package contraption {
import flash.display.*;
public class MovePointer extends MousePointer {
public function MovePointer(acting:Boolean):void{
super(acting);
}
override protected function getActingPointer():MovieClip{
return (new MoveMousePointer());
}
override protected function getPointer():MovieClip{
return (new MoveMousePointer());
}
}
}//package contraption
Section 187
//Music (contraption.Music)
package contraption {
import flash.net.*;
import flash.media.*;
public class Music {
protected var mute:Boolean;// = false
protected var arenaSound:Sound;
protected var menuSound:Sound;
protected var menuSoundChannel:SoundChannel;
protected var playRegisteredSound:Boolean;// = false
protected var arenaSoundChannel:SoundChannel;
protected var playArenaSound:Boolean;// = false
private static var allowInstantiation:Boolean;
private static var instance:Music;
public function Music():void{
var req:URLRequest;
super();
if (!allowInstantiation){
throw (new Error("Error: Instantiation failed: Use Music.getInstance() instead of new."));
};
playRegisteredSound = User.getInstance().isRegistered();
mute = Configuration.getInstance().isMuted();
menuSound = new Sound();
if (playRegisteredSound){
req = new URLRequest("http://fantasticcontraption.com/game/arenaLoop.mp3");
} else {
req = new URLRequest("http://fantasticcontraption.com/game/menuLoop.mp3");
};
var context:SoundLoaderContext = new SoundLoaderContext(4000, true);
menuSound.load(req, context);
arenaSound = menuSound;
}
public function playMenu():void{
return (playArena());
}
protected function checkRegistered():void{
var req:URLRequest;
var context:SoundLoaderContext;
if (((User.getInstance().isRegistered()) && (!(playRegisteredSound)))){
playRegisteredSound = true;
setMute(true);
Configuration.getInstance().setMute(false);
menuSound = new Sound();
req = new URLRequest("http://fc.pegproductions.com/arenaLoop.mp3");
context = new SoundLoaderContext(4000, true);
menuSound.load(req, context);
arenaSound = menuSound;
mute = false;
};
}
public function playArena():void{
checkRegistered();
playArenaSound = true;
if (mute){
return;
};
if (menuSoundChannel != null){
menuSoundChannel.stop();
menuSoundChannel = null;
};
if (arenaSoundChannel == null){
arenaSoundChannel = arenaSound.play(0, 10000000);
};
}
public function stopSound():void{
setMute(true);
}
public function setMute(mute:Boolean):void{
this.mute = mute;
if (mute){
if (menuSoundChannel != null){
menuSoundChannel.stop();
menuSoundChannel = null;
};
if (arenaSoundChannel != null){
arenaSoundChannel.stop();
arenaSoundChannel = null;
};
} else {
if (playArenaSound){
playArena();
} else {
playMenu();
};
};
}
public static function getInstance():Music{
if (instance == null){
allowInstantiation = true;
instance = new (Music);
//unresolved jump
var _slot1 = e;
allowInstantiation = false;
};
return (instance);
}
}
}//package contraption
Section 188
//NoJointedCollisionsFilter (contraption.NoJointedCollisionsFilter)
package contraption {
import contraption.blocks.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class NoJointedCollisionsFilter extends b2CollisionFilter {
public static var b2_defaultFilter:b2CollisionFilter = new b2CollisionFilter();
public function NoJointedCollisionsFilter(){
super();
}
override public function ShouldCollide(shape1:b2Shape, shape2:b2Shape):Boolean{
if (!super.ShouldCollide(shape1, shape2)){
return (false);
};
var block1:Block = (shape1.GetUserData() as Block);
var block2:Block = (shape2.GetUserData() as Block);
if ((((block1 == null)) || ((block2 == null)))){
return (true);
};
if (((block1.collidesWithJointedBlocks()) && (block2.collidesWithJointedBlocks()))){
return (true);
};
if (((!((block1.jointedBlocks == null))) && (!((block1.jointedBlocks[block2] == null))))){
return (false);
};
return (true);
}
}
}//package contraption
Section 189
//Player (contraption.Player)
package contraption {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import contraption.blocks.*;
import flash.geom.*;
import flash.net.*;
import de.polygonal.ds.*;
import Box2D.Dynamics.*;
import flash.utils.*;
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Collision.Shapes.*;
import flash.text.*;
import flash.ui.*;
public class Player extends Arena {
public var currentLevelId:int;// = 0
public var currentLevelXml:XML;
public var moveMode:Boolean;// = false
protected var movingJoints:Dictionary;
protected var buildingBlockType:BlockType;
public var linkedIn:Boolean;
protected var movingJOriginal:Point;
protected var buildingBlock:Block;
public var building:Boolean;// = false
protected var movingJ:Boolean;// = false
protected var movingBlocksOriginalPosition:SLinkedList;
public var hasFinishedLevel:Boolean;// = false
public var running:Boolean;// = false
public var m_iterations:int;// = 10
public var m_timeStep:Number;// = 0.0333333333333333
protected var moving:Boolean;// = false
protected var movingIllegal:Boolean;
protected var movingJointsOriginalPosition:Dictionary;
protected var movingIllegalNotification:Sprite;
private var ox:Number;
private var oy:Number;
protected var movingJoint:JointCollection;
public var deleteMode:Boolean;// = false
protected var te:TextField;
protected var movingBlocks:SLinkedList;
protected var movingNumCollisions:int;
public function Player(stage:Stage, parentContraption:Contraption, linkedIn:Boolean=false, testingLevel:Boolean=false){
buildingBlockType = BlockType.ROD_HOLLOW;
super(stage, parentContraption, false);
this.linkedIn = linkedIn;
if (!testingLevel){
dashboard.setMode(Dashboard.MODE_EDIT_CONTRPATION);
} else {
dashboard.setMode(Dashboard.MODE_TEST_LEVEL);
};
dashboard.addEventListener(DashboardEvent.GO, startSimulation);
dashboard.addEventListener(DashboardEvent.STOP, stopSimulation);
dashboard.addEventListener(DashboardEvent.CW_WHEEL, clockwiseWheelMode);
dashboard.addEventListener(DashboardEvent.CCW_WHEEL, counterClockwiseWheelMode);
dashboard.addEventListener(DashboardEvent.NP_WHEEL, noSpinWheelMode);
dashboard.addEventListener(DashboardEvent.HOLLOW_ROD, hollowRodMode);
dashboard.addEventListener(DashboardEvent.SOLID_ROD, solidRodMode);
dashboard.addEventListener(DashboardEvent.MOVE, enterMoveMode);
dashboard.addEventListener(DashboardEvent.DELETE, enterDeleteMode);
dashboard.addEventListener(DashboardEvent.SAVE, saveDesign);
solidRodMode();
var globalListener:GlobalListener = GlobalListener.getInstance();
globalListener.addEventListener(KeyboardEvent.KEY_UP, keyUp, false, 0, true);
parentContraption.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
parentContraption.addEventListener(MouseEvent.MOUSE_UP, mouseUp, false, 0, true);
resetPhysicsWorld();
parentContraption.addEventListener(MouseEvent.MOUSE_MOVE, updateMoving, false, 0, true);
parentContraption.addEventListener(MouseEvent.MOUSE_MOVE, drawBuilding, false, 0, true);
parentContraption.addEventListener(MenuEvent.SAVE_CONTRAPTION, saveSolutionDesign, false, 0, true);
parentContraption.addEventListener(MenuEvent.CHANGE_GRAPHICS_OPTION, updateBlockGraphics, false, 0, true);
te = new TextField();
te.mouseEnabled = false;
addChild(te);
var graphicsButton:Button = new ToggleGraphicsButton();
graphicsButton.x = 10;
graphicsButton.y = 425;
addChild(graphicsButton);
}
protected function endTryLevel(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK));
}
protected function startSimulation(e:Event):void{
if (running){
return;
};
mouseUp();
running = true;
currentLevelXml = null;
currentLevelXml = getLevelXml();
loadFromXml(currentLevelXml);
resetPhysicsWorld();
initPlayerBlocks();
initJoints();
initArenaBlocks();
var parent:Sprite = (dashboard.stopButton.parent as Sprite);
if (parent == null){
parent = (dashboard.goButton.parent as Sprite);
};
parent.addChild(dashboard.stopButton);
parent.removeChild(dashboard.goButton);
}
override protected function initAllowableActions():void{
allowableActions = new Actions();
allowableActions.alwaysDrag = true;
}
protected function loadNextLevel():void{
var completeEvent:MenuEvent = new MenuEvent(MenuEvent.LEVEL_COMPLETE, true, true);
completeEvent.levelNumber = levelNumber;
completeEvent.levelId = levelId;
dispatchEvent(completeEvent);
}
override protected function newSaveWindow():SaveWindow{
return (new SaveDesignWindow());
}
protected function initPlayerBlocks():void{
var block:Block;
var blockIter:Iterator = playerBlocks.getIterator();
while (blockIter.hasNext()) {
block = (blockIter.next() as Block);
block.generatePhysicsBody(physicsWorld);
block.setJointedBlocks();
};
}
protected function getIllegalNotification(ox:Number, oy:Number, ex:Number, ey:Number):Sprite{
var minSize = 60;
var width:Number = Math.abs((ox - ex));
if (Math.abs((oy - ey)) > width){
width = Math.abs((oy - ey));
};
if (width < minSize){
width = minSize;
};
var notification:Sprite = new Sprite();
notification.graphics.lineStyle(3, 16720418);
notification.graphics.moveTo((width / 4), (width / 4));
notification.graphics.lineTo((-(width) / 4), (-(width) / 4));
notification.graphics.moveTo((width / 4), (-(width) / 4));
notification.graphics.lineTo((-(width) / 4), (width / 4));
notification.x = (ox + ((ex - ox) / 2));
notification.y = (oy + ((ey - oy) / 2));
return (notification);
}
protected function resetMode():void{
moveMode = false;
deleteMode = false;
}
protected function updateMoving(e:Event):void{
var block:Block;
var pos:Point;
var joint:JointCollection;
if (movingJ){
updateMovingJ();
};
if (!moving){
return;
};
var dx:Number = (arenaCanvas.mouseX - ox);
var dy:Number = (arenaCanvas.mouseY - oy);
var blockIter:Iterator = movingBlocks.getIterator();
while (blockIter.hasNext()) {
block = (blockIter.next() as Block);
pos = block.getPosition();
block.setPosition(new Point((pos.x + dx), (pos.y + dy)));
};
for each (joint in movingJoints) {
pos = joint.getPosition();
joint.setPosition(new Point((pos.x + dx), (pos.y + dy)));
};
movingIllegalNotification.x = (movingIllegalNotification.x + dx);
movingIllegalNotification.y = (movingIllegalNotification.y + dy);
if (countCollisions() > movingNumCollisions){
movingIllegal = true;
movingIllegalNotification.visible = true;
} else {
movingIllegal = false;
movingIllegalNotification.visible = false;
};
ox = arenaCanvas.mouseX;
oy = arenaCanvas.mouseY;
}
protected function saveDesign(event:Event, isSolution:Boolean=false):void{
if (event.target == this){
return;
};
event.stopPropagation();
var saveEvent:SaveEvent = new SaveEvent(SaveEvent.SAVE_CONTRAPTION, true, true);
saveEvent.xml = getLevelXml();
saveEvent.currentLevelId = levelId;
saveEvent.isSolution = isSolution;
dispatchEvent(saveEvent);
}
protected function mouseUp(event:MouseEvent=null):void{
var newBlock:Block;
if (((!((movingIllegalNotification == null))) && (arenaCanvas.contains(movingIllegalNotification)))){
arenaCanvas.removeChild(movingIllegalNotification);
movingIllegalNotification = null;
};
if (movingJ){
movingJ = false;
if (movingIllegal){
movingJoint.moveJoint(movingJOriginal.subtract(movingJoint.getPosition()));
};
};
if (movingScreen){
movingScreen = false;
};
if (moving){
stopMoving();
};
if (((running) || (!(building)))){
return;
};
if (building){
building = false;
removeChildBlock(buildingBlock);
playerBlocks.deleteBlock(physicsWorld, buildingBlock);
buildingBlock = null;
};
var ex:Number = arenaCanvas.mouseX;
var ey:Number = arenaCanvas.mouseY;
var startX:Number = startZone.getPosition().x;
var startY:Number = startZone.getPosition().y;
var startWidth:Number = startZone.getWidth();
var startHeight:Number = startZone.getHeight();
if ((((Math.abs((ox - startX)) > (startWidth / 2))) || ((Math.abs((ex - startX)) > (startWidth / 2))))){
return;
};
if ((((Math.abs((oy - startY)) > (startHeight / 2))) || ((Math.abs((ey - startY)) > (startHeight / 2))))){
return;
};
if (buildingBlockType == BlockType.ROD_HOLLOW){
newBlock = playerBlocks.createHollowRod(new Point(ox, oy), new Point(ex, ey), arenaCanvas.scaleX, null, true);
} else {
if (buildingBlockType == BlockType.ROD_SOLID){
newBlock = playerBlocks.createSolidRod(new Point(ox, oy), new Point(ex, ey), arenaCanvas.scaleX, null, true);
} else {
if (buildingBlockType == BlockType.WHEEL_NO_SPIN){
newBlock = playerBlocks.createWheel(new Point(ex, ey), arenaCanvas.scaleX, Wheel.NO_SPIN);
} else {
if (buildingBlockType == BlockType.WHEEL_CLOCKWISE){
newBlock = playerBlocks.createWheel(new Point(ex, ey), arenaCanvas.scaleX, Wheel.CLOCKWISE);
} else {
if (buildingBlockType == BlockType.WHEEL_COUNTER_CLOCKWISE){
newBlock = playerBlocks.createWheel(new Point(ex, ey), arenaCanvas.scaleX, Wheel.COUNTER_CLOCKWISE);
};
};
};
};
};
addChildBlock(newBlock);
newBlock.generatePhysicsBody(physicsWorld);
if (checkCollisions(newBlock)){
playerBlocks.deleteBlock(physicsWorld, newBlock);
removeChildBlock(newBlock);
} else {
addedBlock(newBlock);
};
}
override protected function keyDown(event:KeyboardEvent):void{
super.keyDown(event);
if (!hasFocus()){
return;
};
if (event.keyCode == Keyboard.SPACE){
if (running){
stopSimulation(null);
} else {
startSimulation(null);
};
};
if (event.keyCode == Keyboard.SHIFT){
dispatchEvent(new ModeEvent(ModeEvent.MOVE_MODE));
};
if (event.keyCode == Keyboard.CONTROL){
dispatchEvent(new ModeEvent(ModeEvent.DELETE_MODE));
};
if (running){
return;
};
if (event.keyCode == 82){
hollowRodMode(null);
};
if (event.keyCode == 83){
solidRodMode(null);
};
if (event.keyCode == 85){
noSpinWheelMode(null);
};
if (event.keyCode == 87){
clockwiseWheelMode(null);
};
if (event.keyCode == 67){
counterClockwiseWheelMode(null);
};
}
protected function hasWon():Boolean{
var block:Block;
var pos:Point;
var width:Number;
var height:Number;
var blockLeft:Number;
var blockRight:Number;
var blockTop:Number;
var blockBottom:Number;
if (goalBlocks.isEmpty()){
return (false);
};
var blockIter:Iterator = goalBlocks.getIterator();
var endLeft:Number = (endZone.getPosition().x - (endZone.getWidth() / 2));
var endRight:Number = (endZone.getPosition().x + (endZone.getWidth() / 2));
var endTop:Number = (endZone.getPosition().y - (endZone.getHeight() / 2));
var endBottom:Number = (endZone.getPosition().y + (endZone.getHeight() / 2));
while (blockIter.hasNext()) {
block = (blockIter.next() as Block);
if ((block as Wheel)){
blockLeft = (block.x - (block.getWidth() / 2));
blockRight = (block.x + (block.getWidth() / 2));
blockTop = (block.y - (block.getWidth() / 2));
blockBottom = (block.y + (block.getWidth() / 2));
} else {
blockLeft = (block.x - ((block.width - 4) / 2));
blockRight = (block.x + ((block.width - 4) / 2));
blockTop = (block.y - ((block.height - 4) / 2));
blockBottom = (block.y + ((block.height - 4) / 2));
};
if ((((((((blockLeft < endLeft)) || ((blockRight > endRight)))) || ((blockTop < endTop)))) || ((blockBottom > endBottom)))){
return (false);
};
};
return (true);
}
protected function clockwiseWheelMode(e:Event):void{
resetMode();
buildingBlockType = BlockType.WHEEL_CLOCKWISE;
dashboard.hilightButton(dashboard.cwWheelButton);
dispatchEvent(new ModeEvent(ModeEvent.DEFAULT_MODE));
}
override public function disposeMenu():void{
super.disposeMenu();
stopSimulation(null);
parentContraption.removeEventListener(MenuEvent.SAVE_CONTRAPTION, saveSolutionDesign);
}
protected function drawBuilding(e:Event):void{
var newBlock:Block;
if (!building){
return;
};
if (buildingBlock != null){
removeChildBlock(buildingBlock);
playerBlocks.deleteBlock(physicsWorld, buildingBlock);
};
var ex:Number = arenaCanvas.mouseX;
var ey:Number = arenaCanvas.mouseY;
if (buildingBlockType == BlockType.ROD_HOLLOW){
newBlock = playerBlocks.createHollowRod(new Point(ox, oy), new Point(ex, ey), arenaCanvas.scaleX, null, true);
} else {
if (buildingBlockType == BlockType.ROD_SOLID){
newBlock = playerBlocks.createSolidRod(new Point(ox, oy), new Point(ex, ey), arenaCanvas.scaleX, null, true);
} else {
if (buildingBlockType == BlockType.WHEEL_NO_SPIN){
newBlock = playerBlocks.createWheel(new Point(ex, ey), arenaCanvas.scaleX, Wheel.NO_SPIN);
} else {
if (buildingBlockType == BlockType.WHEEL_CLOCKWISE){
newBlock = playerBlocks.createWheel(new Point(ex, ey), arenaCanvas.scaleX, Wheel.CLOCKWISE);
} else {
if (buildingBlockType == BlockType.WHEEL_COUNTER_CLOCKWISE){
newBlock = playerBlocks.createWheel(new Point(ex, ey), arenaCanvas.scaleX, Wheel.COUNTER_CLOCKWISE);
};
};
};
};
};
if ((newBlock as Wheel)){
ox = ex;
oy = ey;
};
buildingBlock = newBlock;
addChildBlock(buildingBlock);
buildingBlock.generatePhysicsBody(physicsWorld);
if (movingIllegalNotification != null){
arenaCanvas.removeChild(movingIllegalNotification);
movingIllegalNotification = null;
};
if (checkCollisions(buildingBlock)){
movingIllegalNotification = getIllegalNotification(ox, oy, ex, ey);
arenaCanvas.addChild(movingIllegalNotification);
};
}
protected function checkCollisions(newBlock:Block):Boolean{
var block1:Block;
var block2:Block;
physicsWorld.CleanBodyList();
physicsWorld.m_contactManager.CleanContactList();
physicsWorld.m_contactManager.Collide(newBlock.getPhysicsBody());
var c:b2Contact = physicsWorld.GetContactList();
while (c != null) {
block1 = (c.GetShape1().GetBody().GetUserData() as Block);
block2 = (c.GetShape2().GetBody().GetUserData() as Block);
if ((((((c.GetManifoldCount() > 0)) && ((((block1 == newBlock)) || ((block2 == newBlock)))))) && (!(block1.isJointedTo(block2))))){
return (true);
};
c = c.m_next;
};
return (false);
}
protected function hollowRodMode(e:Event):void{
resetMode();
buildingBlockType = BlockType.ROD_HOLLOW;
dashboard.hilightButton(dashboard.hollowRodButton);
dispatchEvent(new ModeEvent(ModeEvent.DEFAULT_MODE));
}
override protected function loadLevelHandler(event:Event):void{
super.loadLevelHandler(event);
if (((linkedIn) && (hasPermissionToPlay()))){
addChild(new LinkInMenu());
};
}
override public function getLevelXml():XML{
if (currentLevelXml != null){
return (currentLevelXml);
};
return (super.getLevelXml());
}
protected function stopSimulation(e:Event):void{
if (!running){
return;
};
running = false;
hasFinishedLevel = false;
var blockIter:Iterator = playerBlocks.getIterator();
while (blockIter.hasNext()) {
(blockIter.next() as Block).stopJoints(physicsWorld);
};
blockIter = playerBlocks.getIterator();
while (blockIter.hasNext()) {
(blockIter.next() as Block).resetBlock(physicsWorld);
};
blockIter = arenaBlocks.getIterator();
while (blockIter.hasNext()) {
(blockIter.next() as Block).resetBlock(physicsWorld);
};
resetPhysicsWorld();
initPlayerBlocks();
initArenaBlocks();
initBuildingBoundries();
var parent:Sprite = (dashboard.stopButton.parent as Sprite);
if (parent == null){
parent = (dashboard.goButton.parent as Sprite);
};
parent.addChild(dashboard.goButton);
parent.removeChild(dashboard.stopButton);
}
public function isRunning():Boolean{
return (running);
}
protected function initBuildingBoundries():void{
startZone.x;
var boxDef:b2BoxDef = new b2BoxDef();
var bodyDef:b2BodyDef = new b2BodyDef();
boxDef.extents.Set((ARENA_WIDTH / 2), (ARENA_HEIGHT / 2));
boxDef.categoryBits = 0xFFFFFF;
bodyDef.AddShape(boxDef);
bodyDef.position.x = ((startZone.getPosition().x + (startZone.width / 2)) + (ARENA_WIDTH / 2));
bodyDef.position.y = startZone.getPosition().y;
bodyDef.userData = new Block();
physicsWorld.CreateBody(bodyDef);
bodyDef.position.x = ((startZone.getPosition().x - (startZone.width / 2)) - (ARENA_WIDTH / 2));
bodyDef.position.y = startZone.getPosition().y;
bodyDef.userData = new Block();
physicsWorld.CreateBody(bodyDef);
bodyDef.position.x = startZone.getPosition().x;
bodyDef.position.y = ((startZone.getPosition().y + (startZone.height / 2)) + (ARENA_HEIGHT / 2));
bodyDef.userData = new Block();
physicsWorld.CreateBody(bodyDef);
bodyDef.position.x = startZone.getPosition().x;
bodyDef.position.y = ((startZone.getPosition().y - (startZone.height / 2)) - (ARENA_HEIGHT / 2));
bodyDef.userData = new Block();
physicsWorld.CreateBody(bodyDef);
}
public function updateMovingJ():void{
var dx:Number = (arenaCanvas.mouseX - ox);
var dy:Number = (arenaCanvas.mouseY - oy);
movingJoint.moveJoint(new Point(dx, dy));
movingIllegalNotification.x = (movingIllegalNotification.x + dx);
movingIllegalNotification.y = (movingIllegalNotification.y + dy);
if (countCollisions() > movingNumCollisions){
movingIllegal = true;
movingIllegalNotification.visible = true;
} else {
movingIllegal = false;
movingIllegalNotification.visible = false;
};
ox = arenaCanvas.mouseX;
oy = arenaCanvas.mouseY;
}
protected function counterClockwiseWheelMode(e:Event):void{
resetMode();
buildingBlockType = BlockType.WHEEL_COUNTER_CLOCKWISE;
dashboard.hilightButton(dashboard.ccwWheelButton);
dispatchEvent(new ModeEvent(ModeEvent.DEFAULT_MODE));
}
protected function noSpinWheelMode(e:Event):void{
resetMode();
buildingBlockType = BlockType.WHEEL_NO_SPIN;
dashboard.hilightButton(dashboard.npWheelButton);
dispatchEvent(new ModeEvent(ModeEvent.DEFAULT_MODE));
}
protected function initArenaBlocks():void{
var blockIter:Iterator = arenaBlocks.getIterator();
while (blockIter.hasNext()) {
(blockIter.next() as Block).generatePhysicsBody(physicsWorld);
};
}
protected function enterMoveMode(e:Event):void{
resetMode();
dashboard.hilightButton(dashboard.moveButton);
moveMode = true;
dispatchEvent(new ModeEvent(ModeEvent.MOVE_MODE));
}
override public function loadFromXml(xml:XML):void{
super.loadFromXml(xml);
initArenaBlocks();
initPlayerBlocks();
initBuildingBoundries();
}
override public function update(event:Event):void{
var bb:b2Body;
var joint:b2Joint;
var revJoint:b2RevoluteJoint;
var distance:b2Vec2;
var userCookie:SharedObject;
if (((running) && (!((physicsWorld == null))))){
physicsWorld.Step(m_timeStep, m_iterations);
bb = physicsWorld.m_bodyList;
while (bb) {
if ((bb.m_userData is Block)){
(bb.m_userData as Block).updateFromPhysicsBody();
};
bb = bb.m_next;
};
joint = physicsWorld.GetJointList();
while (joint) {
revJoint = (joint as b2RevoluteJoint);
distance = new b2Vec2(revJoint.GetAnchor1().x, revJoint.GetAnchor1().y);
distance.Subtract(revJoint.GetAnchor2());
if ((Math.abs(distance.x) + Math.abs(distance.y)) > 50){
physicsWorld.DestroyJoint(joint);
};
joint = joint.m_next;
};
if (((!(hasFinishedLevel)) && (hasWon()))){
hasFinishedLevel = true;
userCookie = SharedObject.getLocal("user");
userCookie.data[("level" + levelId)] = "true";
userCookie.flush();
loadNextLevel();
};
};
super.update(event);
}
protected function beginMoving():void{
var movingJoint:JointCollection;
var block:Block;
var position:Point;
var joint:JointCollection;
var modeEvent:ModeEvent;
var jointedBlock:Block;
ox = arenaCanvas.mouseX;
oy = arenaCanvas.mouseY;
movingIllegal = false;
movingNumCollisions = countCollisions();
if (movingIllegalNotification){
arenaCanvas.removeChild(movingIllegalNotification);
};
movingIllegalNotification = new Sprite();
arenaCanvas.addChild(movingIllegalNotification);
movingJoint = playerBlocks.getClosestJointCollection(new Point(ox, oy));
if (((!((movingJoint == null))) && (((Point.distance(movingJoint.getPosition(), new Point(ox, oy)) * scaleX) < 8)))){
movingJ = true;
this.movingJoint = movingJoint;
movingJOriginal = movingJoint.getPosition();
movingIllegalNotification.x = ox;
movingIllegalNotification.y = oy;
movingIllegalNotification.graphics.lineStyle(3, 16720418);
movingIllegalNotification.graphics.moveTo(20, 20);
movingIllegalNotification.graphics.lineTo(-20, -20);
movingIllegalNotification.graphics.moveTo(20, -20);
movingIllegalNotification.graphics.lineTo(-20, 20);
movingIllegalNotification.visible = false;
arenaCanvas.addChild(movingIllegalNotification);
modeEvent = new ModeEvent(ModeEvent.START_ACTION, true);
modeEvent.actionType = ModeEvent.ACTION_MOVE;
dispatchEvent(modeEvent);
currentLevelXml = null;
return;
};
block = playerBlocks.getClosestBlock(new Point(arenaCanvas.mouseX, arenaCanvas.mouseY));
if ((((block == null)) || (((block.getDistance(new Point(arenaCanvas.mouseX, arenaCanvas.mouseY)) * scaleX) > 20)))){
beginMoveScreen(mouseX, mouseY);
return;
};
moving = true;
movingBlocks = new SLinkedList();
movingBlocksOriginalPosition = new SLinkedList();
movingJoints = new Dictionary();
movingJointsOriginalPosition = new Dictionary();
var topX:Number = -1000000;
var topY:Number = -1000000;
var bottomX:Number = 1000000;
var bottomY:Number = 1000000;
var jointedBlocks:Dictionary = new Dictionary();
jointedBlocks[block] = block;
var isEmpty:Boolean;
while (!(isEmpty)) {
isEmpty = true;
for each (jointedBlock in jointedBlocks) {
if (movingBlocks.nodeOf(jointedBlock) == null){
isEmpty = false;
jointedBlock.addJointedBlocks(jointedBlocks);
jointedBlock.addJoints(movingJoints);
movingBlocks.append(jointedBlock);
position = jointedBlock.getPosition();
movingBlocksOriginalPosition.append(position);
delete jointedBlocks[jointedBlock];
jointedBlock.alpha = 0.5;
if ((position.x + 20) > topX){
topX = (position.x + 20);
};
if ((position.y + 20) > topY){
topY = (position.y + 20);
};
if ((position.x - 20) < bottomX){
bottomX = (position.x - 20);
};
if ((position.y - 20) < bottomY){
bottomY = (position.y - 20);
};
} else {
delete jointedBlocks[jointedBlock];
};
};
};
for each (joint in movingJoints) {
movingJointsOriginalPosition[joint] = joint.getPosition();
};
movingIllegalNotification.graphics.lineStyle(3, 16720418);
movingIllegalNotification.graphics.moveTo(topX, topY);
movingIllegalNotification.graphics.lineTo(bottomX, bottomY);
movingIllegalNotification.graphics.moveTo(topX, bottomY);
movingIllegalNotification.graphics.lineTo(bottomX, topY);
movingIllegalNotification.visible = false;
arenaCanvas.addChild(movingIllegalNotification);
modeEvent = new ModeEvent(ModeEvent.START_ACTION, true);
modeEvent.actionType = ModeEvent.ACTION_MOVE;
dispatchEvent(modeEvent);
currentLevelXml = null;
}
protected function initJoints():void{
var blockIter:Iterator = playerBlocks.getIterator();
while (blockIter.hasNext()) {
(blockIter.next() as Block).startJoints(physicsWorld);
};
}
protected function solidRodMode(e:Event=null):void{
resetMode();
buildingBlockType = BlockType.ROD_SOLID;
dashboard.hilightButton(dashboard.solidRodButton);
dispatchEvent(new ModeEvent(ModeEvent.DEFAULT_MODE));
}
protected function keyUp(event:KeyboardEvent):void{
if ((((event.keyCode == Keyboard.SHIFT)) || ((event.keyCode == Keyboard.CONTROL)))){
dispatchEvent(new ModeEvent(ModeEvent.DEFAULT_MODE));
};
}
protected function checkPlayerBlocksLegality():void{
var block:Block;
var rod:Rod;
var blockIter:Iterator = arenaBlocks.getIterator();
blockIter = playerBlocks.getIterator();
while (blockIter.hasNext()) {
block = (blockIter.next() as Block);
if ((block as Wheel)){
};
if ((block as Rod)){
rod = (block as Rod);
if (((!(startZone.isInside(rod.point1))) || (!(startZone.isInside(rod.point2))))){
deleteBlock(rod);
};
};
if (checkCollisions(block)){
deleteBlock(block);
};
};
}
protected function enterDeleteMode(e:Event):void{
resetMode();
dashboard.hilightButton(dashboard.deleteButton);
deleteMode = true;
dispatchEvent(new ModeEvent(ModeEvent.DELETE_MODE));
}
override protected function mouseDown(event:MouseEvent):void{
var block:Block;
var modeEvent:ModeEvent;
if ((((((((visible == false)) || (building))) || (moving))) || (movingJ))){
return;
};
if (((running) || (!(startZone.isInside(new Point(arenaCanvas.mouseX, arenaCanvas.mouseY)))))){
if (((running) && (startZone.isInside(new Point(arenaCanvas.mouseX, arenaCanvas.mouseY))))){
dashboard.pingStopButton();
};
beginMoveScreen(mouseX, mouseY);
return;
};
if (((event.shiftKey) || (moveMode))){
beginMoving();
} else {
if (((event.ctrlKey) || (deleteMode))){
block = playerBlocks.getClosestBlock(new Point(arenaCanvas.mouseX, arenaCanvas.mouseY), false);
if (((!((block == null))) && (((block.getDistance(new Point(arenaCanvas.mouseX, arenaCanvas.mouseY)) * scaleX) < 20)))){
deleteBlock(block);
currentLevelXml = null;
};
} else {
if (playerBlocks.size < 120){
ox = arenaCanvas.mouseX;
oy = arenaCanvas.mouseY;
building = true;
drawBuilding(null);
modeEvent = new ModeEvent(ModeEvent.START_ACTION, true);
modeEvent.actionType = ModeEvent.ACTION_BUILD;
dispatchEvent(modeEvent);
currentLevelXml = null;
};
};
};
}
protected function addedBlock(block:Block):void{
}
public function addEndTryButton():void{
removeChild(menuButton);
removeChild(saveButton);
var endTryButton:Button = new Button("Back To Editor");
endTryButton.x = 600;
endTryButton.y = 340;
addChild(endTryButton);
endTryButton.addEventListener(MouseEvent.MOUSE_DOWN, endTryLevel);
}
protected function updateBlockGraphics(event:Event=null):void{
var block:Block;
var blockIter:Iterator = playerBlocks.getIterator();
while (blockIter.hasNext()) {
block = (blockIter.next() as Block);
block.reDrawBlock();
};
}
protected function countCollisions():int{
var count:int;
physicsWorld.CleanBodyList();
physicsWorld.m_contactManager.CleanContactList();
physicsWorld.m_contactManager.Collide();
var c:b2Contact = physicsWorld.GetContactList();
while (c != null) {
count = (count + c.GetManifoldCount());
c = c.m_next;
};
return (count);
}
protected function resetPhysicsWorld():void{
var worldAABB:b2AABB = new b2AABB();
worldAABB.minVertex.Set(-(ARENA_WIDTH), -(ARENA_HEIGHT));
worldAABB.maxVertex.Set(ARENA_WIDTH, ARENA_HEIGHT);
var gravity:b2Vec2 = new b2Vec2(0, 300);
var doSleep:Boolean;
physicsWorld = new b2World(worldAABB, gravity, doSleep);
physicsWorld.SetFilter(new NoJointedCollisionsFilter());
}
protected function saveSolutionDesign(event:Event):void{
saveDesign(event, true);
}
protected function stopMoving():void{
var block:Block;
var pos:Point;
var joint:JointCollection;
moving = false;
var positionIter:Iterator = movingBlocksOriginalPosition.getIterator();
var blockIter:Iterator = movingBlocks.getIterator();
while (((blockIter.hasNext()) && (positionIter.hasNext()))) {
block = (blockIter.next() as Block);
pos = (positionIter.next() as Point);
if (movingIllegal){
block.setPosition(pos);
};
block.alpha = 1;
};
if (movingIllegal){
for each (joint in movingJoints) {
joint.setPosition(movingJointsOriginalPosition[joint]);
};
};
movingBlocks = null;
movingBlocksOriginalPosition = null;
}
}
}//package contraption
Section 190
//StartZone (contraption.StartZone)
package contraption {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
public class StartZone extends ActionContainerImpl {
protected var zoneWidth:Number;
protected var my0:Number;
protected var moving:Boolean;// = false
protected var editing:Boolean;
protected var mx0:Number;
protected var resizeCorner:Sprite;
protected var resizing:Boolean;// = false
protected var zoneHeight:Number;
protected static const MIN_ZONE_WIDTH:int = 100;
public function StartZone(editing:Boolean):void{
setWidth(200);
setHeight(200);
setPosition(new Point(10, 10));
this.editing = editing;
if (editing){
resizeCorner = newResizeCorner();
addChild(resizeCorner);
resizeCorner.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownR);
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownM);
};
drawZone();
super();
}
protected function getColour():int{
return (12377081);
}
public function setWidth(value:Number):void{
zoneWidth = value;
}
public function isInside(point:Point):Boolean{
var left:Number = (getPosition().x - (getWidth() / 2));
var right:Number = (getPosition().x + (getWidth() / 2));
var top:Number = (getPosition().y - (getHeight() / 2));
var bottom:Number = (getPosition().y + (getHeight() / 2));
if ((((((((point.x > (left - 4))) && ((point.x < (right + 4))))) && ((point.y > (top - 4))))) && ((point.y < (bottom + 4))))){
return (true);
};
return (false);
}
protected function mouseDownR(event:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveR, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpR, false, 0, true);
event.stopPropagation();
resizing = true;
var modeEvent:ModeEvent = new ModeEvent(ModeEvent.START_ACTION, true, true);
modeEvent.actionType = ModeEvent.ACTION_BUTTON;
dispatchEvent(modeEvent);
}
protected function mouseDownM(event:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveM, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpM, false, 0, true);
event.stopPropagation();
mx0 = this.mouseX;
my0 = this.mouseY;
moving = true;
}
protected function getBorderColour():int{
return (7829486);
}
protected function drawZone():void{
graphics.clear();
graphics.lineStyle(4, getBorderColour());
graphics.beginFill(getColour());
graphics.drawRect((-(getWidth()) / 2), (-(getHeight()) / 2), getWidth(), getHeight());
if (resizeCorner != null){
resizeCorner.x = (getWidth() / 2);
resizeCorner.y = (getHeight() / 2);
};
}
override protected function initAllowableActions():void{
allowableActions = new Actions();
allowableActions.alwaysDrag = true;
if (!editing){
allowableActions.build = true;
allowableActions.drag = true;
};
}
public function getWidth():Number{
return (zoneWidth);
}
public function setFromXML(xml:XML):void{
setWidth(new Number(xml.width));
setHeight(new Number(xml.height));
var position:Point = new Point();
position.x = new Number(xml.position.x);
position.y = new Number(xml.position.y);
setPosition(position);
drawZone();
}
public function getHeight():Number{
return (zoneHeight);
}
public function getPosition():Point{
return (new Point(x, y));
}
public function getXml():XML{
var xml:XML = new XML(getXmlRoot());
var position:XML = new XML(<position></position>
);
position.appendChild((("<x>" + getPosition().x) + "</x>"));
position.appendChild((("<y>" + getPosition().y) + "</y>"));
xml.appendChild(position);
xml.appendChild((("<width>" + getWidth()) + "</width>"));
xml.appendChild((("<height>" + getHeight()) + "</height>"));
return (xml);
}
protected function getXmlRoot():XML{
return (<start/>
);
}
public function setPosition(value:Point):void{
x = value.x;
y = value.y;
}
protected function mouseUpM(event:MouseEvent):void{
moving = false;
}
public function setHeight(value:Number):void{
zoneHeight = value;
}
protected function mouseUpR(event:MouseEvent):void{
resizing = false;
}
protected function newResizeCorner():Sprite{
var resizeCorner:ActionContainerImpl = new ActionContainerImpl();
var actions:Actions = new Actions();
actions.button = true;
resizeCorner.setAllowableActions(actions);
resizeCorner.graphics.lineStyle(4, 0xFFFF00);
resizeCorner.graphics.beginFill(0xFFFF, 0.5);
resizeCorner.graphics.drawRect(-6, -6, 12, 12);
return (resizeCorner);
}
protected function mouseMoveR(event:MouseEvent):void{
if (!resizing){
return;
};
var newWidth:Number = (mouseX * 2);
var newHeight:Number = (mouseY * 2);
if (newWidth < MIN_ZONE_WIDTH){
newWidth = MIN_ZONE_WIDTH;
};
if (newHeight < MIN_ZONE_WIDTH){
newHeight = MIN_ZONE_WIDTH;
};
setWidth(newWidth);
setHeight(newHeight);
drawZone();
}
protected function mouseMoveM(event:MouseEvent):void{
if (!moving){
return;
};
setPosition(new Point((parent.mouseX - mx0), (parent.mouseY - my0)));
}
}
}//package contraption
Section 191
//User (contraption.User)
package contraption {
import flash.events.*;
import contraption.menu.*;
import flash.net.*;
import flash.external.*;
public class User extends EventDispatcher {
protected var registered:Boolean;
protected var userId:int;
protected var loggedIn:Boolean;
protected var password:String;
protected var email:String;
protected var userName:String;
private static var allowInstantiation:Boolean;
private static var instance:User;
public function User():void{
super();
if (!allowInstantiation){
throw (new Error("Error: Instantiation failed: Use User.getInstance() instead of new."));
};
registered = false;
var userCookie:SharedObject = SharedObject.getLocal("user");
if (userCookie.data.userId != null){
loggedIn = true;
userId = userCookie.data.userId;
userName = userCookie.data.userName;
email = userCookie.data.email;
password = userCookie.data.password;
registered = userCookie.data.registered;
} else {
loggedIn = false;
};
}
public function logIn(userName:String, password:String):void{
this.userName = userName;
var loader:URLLoader = new ContraptionUrlLoader();
loader.addEventListener(MenuEvent.ADD_SPINNER, bubble);
loader.addEventListener(MenuEvent.REMOVE_SPINNER, bubble);
loader.addEventListener(Event.COMPLETE, logInComplete);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/logIn.php");
var variables:URLVariables = new URLVariables();
variables.userName = userName;
variables.password = password;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
public function resetPassword(userName:String, email:String):void{
var loader:URLLoader = new ContraptionUrlLoader();
loader.addEventListener(MenuEvent.ADD_SPINNER, bubble);
loader.addEventListener(MenuEvent.REMOVE_SPINNER, bubble);
loader.addEventListener(Event.COMPLETE, resetPasswordComplete);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/resetPassword.php");
var variables:URLVariables = new URLVariables();
variables.userName = userName;
variables.email = email;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
public function newUser(userName:String, email:String, password:String):void{
this.userName = userName;
var loader:URLLoader = new ContraptionUrlLoader();
loader.addEventListener(MenuEvent.ADD_SPINNER, bubble);
loader.addEventListener(MenuEvent.REMOVE_SPINNER, bubble);
loader.addEventListener(Event.COMPLETE, logInComplete);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/newUser.php");
var variables:URLVariables = new URLVariables();
variables.userName = userName;
variables.email = email;
variables.password = password;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
if (Contraption.VERSION_NAME == "fantasticcontraption.com"){
ExternalInterface.call("pageTracker._trackPageview", "/newUser");
};
}
public function getPassword():String{
return (password);
}
public function isRegistered():Boolean{
return (registered);
}
public function refreshRegistered():void{
if (!isLoggedIn()){
return;
};
var loader:URLLoader = new ContraptionUrlLoader();
loader.addEventListener(MenuEvent.ADD_SPINNER, bubble);
loader.addEventListener(MenuEvent.REMOVE_SPINNER, bubble);
loader.addEventListener(Event.COMPLETE, refreshRegisteredComplete);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/getRegistered.php");
var variables:URLVariables = new URLVariables();
variables.userId = userId;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
public function refreshRegisteredComplete(event:Event):void{
registered = (event.target.data == "1");
var userCookie:SharedObject = SharedObject.getLocal("user");
userCookie.data.registered = registered;
userCookie.flush();
}
public function updateInfo(email:String, password:String):void{
var loader:URLLoader = new ContraptionUrlLoader();
loader.addEventListener(MenuEvent.ADD_SPINNER, bubble);
loader.addEventListener(MenuEvent.REMOVE_SPINNER, bubble);
loader.addEventListener(Event.COMPLETE, updateInfoComplete);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/updateUserInfo.php");
var variables:URLVariables = new URLVariables();
variables.userId = getUserId();
variables.email = email;
variables.newPassword = password;
variables.originalPassword = getPassword();
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
public function isLoggedIn():Boolean{
return (loggedIn);
}
public function logInComplete(event:Event):void{
var userData:XML;
userData = new XML(event.target.data);
if (userData.userId.toString() == ""){
dispatchEvent(new MenuEvent(MenuEvent.LOG_IN_FAILED));
return;
};
userId = userData.userId;
userName = userData.userName;
email = userData.email;
password = userData.password;
registered = (userData.isRegistered == 1);
loggedIn = true;
var userCookie:SharedObject = SharedObject.getLocal("user");
userCookie.data.userId = userId;
userCookie.data.userName = userName;
userCookie.data.email = email;
userCookie.data.password = password;
userCookie.data.registered = registered;
userCookie.flush();
dispatchEvent(new MenuEvent(MenuEvent.LOGGED_IN, true, true));
}
public function resetPasswordComplete(event:Event):void{
throw (event.target.data);
}
public function bubble(event:Event):void{
dispatchEvent(event);
}
public function getEmail():String{
return (email);
}
public function logOut():void{
loggedIn = false;
userId = 0;
userName = null;
email = null;
password = null;
registered = false;
var userCookie:SharedObject = SharedObject.getLocal("user");
userCookie.data.userId = null;
userCookie.data.userName = null;
userCookie.data.email = null;
userCookie.data.password = null;
userCookie.data.registered = null;
userCookie.flush();
}
public function getUserName():String{
return (userName);
}
public function updateInfoComplete(event:Event):void{
var userData:XML;
userData = new XML(event.target.data);
if (userData.email.toString() == ""){
throw (new Error(("whoa! badness in the user update server call:" + event.target.data)));
};
email = userData.email;
password = userData.password;
var userCookie:SharedObject = SharedObject.getLocal("user");
userCookie.data.email = email;
userCookie.data.password = password;
userCookie.flush();
dispatchEvent(new MenuEvent(MenuEvent.UPDATE_USER_INFO));
}
public function getUserId():int{
return (userId);
}
public static function getInstance():User{
if (instance == null){
allowInstantiation = true;
instance = new (User);
allowInstantiation = false;
};
return (instance);
}
}
}//package contraption
Section 192
//Stream_14 (contraption_objects_fla.Stream_14)
package contraption_objects_fla {
import flash.display.*;
public dynamic class Stream_14 extends MovieClip {
public var dropBouncing:MovieClip;
}
}//package contraption_objects_fla
Section 193
//StreamBG_9 (contraption_objects_fla.StreamBG_9)
package contraption_objects_fla {
import flash.display.*;
public dynamic class StreamBG_9 extends MovieClip {
public var dropBouncing:MovieClip;
}
}//package contraption_objects_fla
Section 194
//Buttons_3 (Dashboard_fla.Buttons_3)
package Dashboard_fla {
import flash.display.*;
import flash.text.*;
public dynamic class Buttons_3 extends MovieClip {
public var tooltip:TextField;
public var saveButton:SaveButton;
public var zoomButtons:MovieClip;
public var levelButtons:MovieClip;
public var contraptionButtons:MovieClip;
public var backTestButton:BackTestButton;
public var backButton:BackButton;
public function Buttons_3(){
addFrameScript(0, frame1);
}
function frame1(){
}
}
}//package Dashboard_fla
Section 195
//ContraptionButtons_9 (Dashboard_fla.ContraptionButtons_9)
package Dashboard_fla {
import flash.display.*;
public dynamic class ContraptionButtons_9 extends MovieClip {
public var goStopButtons:MovieClip;
public var moveButton:MoveButton;
public var npWheelButton:NonPoweredWheelButton;
public var cwWheelButton:ClockwiseWheelButton;
public var solidRodButton:SolidRodButton;
public var hollowRodButton:HollowRodButton;
public var deleteButton:DeleteButton;
public var ccwWheelButton:CounterClockwiseWheelButton;
}
}//package Dashboard_fla
Section 196
//GoStopButtons_35 (Dashboard_fla.GoStopButtons_35)
package Dashboard_fla {
import flash.events.*;
import flash.display.*;
public dynamic class GoStopButtons_35 extends MovieClip {
public var stopButtonPing:StopButtonPing;
public var goButton:GoButton;
public var stopButton:StopButton;
public function GoStopButtons_35(){
addFrameScript(0, frame1);
}
function frame1(){
goButton.addEventListener(MouseEvent.MOUSE_DOWN, buttonPressed);
stopButton.addEventListener(MouseEvent.MOUSE_DOWN, buttonPressed);
}
public function buttonPressed(_arg1:MouseEvent):void{
}
}
}//package Dashboard_fla
Section 197
//LevelButtons_41 (Dashboard_fla.LevelButtons_41)
package Dashboard_fla {
import flash.display.*;
public dynamic class LevelButtons_41 extends MovieClip {
public var dynamicCircleButton:DynamicCircleButton;
public var testLevelButton:TestLevelButton;
public var staticSquareButton:StaticSquareButton;
public var goalSquareButton:GoalSquareButton;
public var dynamicSquareButton:DynamicSquareButton;
public var staticCircleButton:StaticCircleButton;
public var goalCircleButton:GoalCircleButton;
}
}//package Dashboard_fla
Section 198
//Stream_22 (Dashboard_fla.Stream_22)
package Dashboard_fla {
import flash.display.*;
public dynamic class Stream_22 extends MovieClip {
public var dropBouncing:MovieClip;
}
}//package Dashboard_fla
Section 199
//ZoomButtons_5 (Dashboard_fla.ZoomButtons_5)
package Dashboard_fla {
import flash.display.*;
public dynamic class ZoomButtons_5 extends MovieClip {
public var zoomOutButton:ZoomOutButton;
public var zoomInButton:ZoomInButton;
}
}//package Dashboard_fla
Section 200
//compareStringCaseInSensitive (de.polygonal.ds.sort.compare.compareStringCaseInSensitive)
package de.polygonal.ds.sort.compare {
public function compareStringCaseInSensitive(a:String, b:String):int{
var r:int;
var k:int;
var i:int;
a = a.toLowerCase();
b = b.toLowerCase();
if ((a.length + b.length) > 2){
r = 0;
k = ((a.length > b.length)) ? a.length : b.length;
i = 0;
while (i < k) {
r = (a.charCodeAt(i) - b.charCodeAt(i));
if (r != 0){
break;
};
i++;
};
return (r);
} else {
};
return ((!NULL! - !NULL!));
}
}//package de.polygonal.ds.sort.compare
Section 201
//compareStringCaseInSensitiveDesc (de.polygonal.ds.sort.compare.compareStringCaseInSensitiveDesc)
package de.polygonal.ds.sort.compare {
public function compareStringCaseInSensitiveDesc(a:String, b:String):int{
var r:int;
var k:int;
var i:int;
a = a.toLowerCase();
b = b.toLowerCase();
if ((a.length + b.length) > 2){
r = 0;
k = ((a.length > b.length)) ? a.length : b.length;
i = 0;
while (i < k) {
r = (b.charCodeAt(i) - a.charCodeAt(i));
if (r != 0){
break;
};
i++;
};
return (r);
} else {
};
return ((!NULL! - !NULL!));
}
}//package de.polygonal.ds.sort.compare
Section 202
//compareStringCaseSensitive (de.polygonal.ds.sort.compare.compareStringCaseSensitive)
package de.polygonal.ds.sort.compare {
public function compareStringCaseSensitive(a:String, b:String):int{
var r:int;
var k:int;
var i:int;
if ((a.length + b.length) > 2){
r = 0;
k = ((a.length > b.length)) ? a.length : b.length;
i = 0;
while (i < k) {
r = (a.charCodeAt(i) - b.charCodeAt(i));
if (r != 0){
break;
};
i++;
};
return (r);
} else {
};
return ((!NULL! - !NULL!));
}
}//package de.polygonal.ds.sort.compare
Section 203
//compareStringCaseSensitiveDesc (de.polygonal.ds.sort.compare.compareStringCaseSensitiveDesc)
package de.polygonal.ds.sort.compare {
public function compareStringCaseSensitiveDesc(a:String, b:String):int{
var r:int;
var k:int;
var i:int;
if ((a.length + b.length) > 2){
r = 0;
k = ((a.length > b.length)) ? a.length : b.length;
i = 0;
while (i < k) {
r = (b.charCodeAt(i) - a.charCodeAt(i));
if (r != 0){
break;
};
i++;
};
return (r);
} else {
};
return ((!NULL! - !NULL!));
}
}//package de.polygonal.ds.sort.compare
Section 204
//sLinkedInsertionSort (de.polygonal.ds.sort.sLinkedInsertionSort)
package de.polygonal.ds.sort {
import de.polygonal.ds.*;
public function sLinkedInsertionSort(node:SListNode, descending:Boolean=false):SListNode{
var j:int;
var val:Number;
var a:Array = [];
var k:int;
var h:SListNode = node;
var n:SListNode = node;
while (n) {
var _temp1 = k;
k = (k + 1);
var _local10 = _temp1;
a[_local10] = n.data;
n = n.next;
};
if (k <= 1){
return (h);
};
var i = 1;
while (i < k) {
val = a[i];
j = i;
while ((((j > 0)) && ((a[int((j - 1))] > val)))) {
a[j] = a[int((j - 1))];
j--;
};
a[j] = val;
i++;
};
n = h;
i = 0;
while (n) {
var _temp2 = i;
i = (i + 1);
n.data = a[_temp2];
n = n.next;
};
return (h);
}
}//package de.polygonal.ds.sort
Section 205
//sLinkedInsertionSortCmp (de.polygonal.ds.sort.sLinkedInsertionSortCmp)
package de.polygonal.ds.sort {
import de.polygonal.ds.*;
public function sLinkedInsertionSortCmp(node:SListNode, cmp:Function, descending:Boolean=false):SListNode{
var j:int;
var i:int;
var val:*;
var a:Array = [];
var k:int;
var h:SListNode = node;
var n:SListNode = node;
while (n) {
var _temp1 = k;
k = (k + 1);
var _local11 = _temp1;
a[_local11] = n.data;
n = n.next;
};
if (descending){
if (k <= 1){
return (h);
};
i = 1;
while (i < k) {
val = a[i];
j = i;
while ((((j > 0)) && ((cmp(a[int((j - 1))], val) < 0)))) {
a[j] = a[int((j - 1))];
j--;
};
a[j] = val;
i++;
};
} else {
if (k <= 1){
return (h);
};
i = 1;
while (i < k) {
val = a[i];
j = i;
while ((((j > 0)) && ((cmp(a[int((j - 1))], val) > 0)))) {
a[j] = a[int((j - 1))];
j--;
};
a[j] = val;
i++;
};
};
n = h;
i = 0;
while (n) {
var _temp2 = i;
i = (i + 1);
n.data = a[_temp2];
n = n.next;
};
return (h);
}
}//package de.polygonal.ds.sort
Section 206
//sLinkedMergeSort (de.polygonal.ds.sort.sLinkedMergeSort)
package de.polygonal.ds.sort {
import de.polygonal.ds.*;
public function sLinkedMergeSort(node:SListNode, descending:Boolean=false):SListNode{
var p:SListNode;
var q:SListNode;
var e:SListNode;
var tail:SListNode;
var nmerges:int;
var psize:int;
var qsize:int;
var i:int;
if (!node){
return (null);
};
var h:SListNode = node;
var insize = 1;
if (descending){
while (true) {
p = h;
tail = null;
h = tail;
nmerges = 0;
while (p) {
nmerges++;
i = 0;
psize = 0;
q = p;
while (i < insize) {
psize++;
q = q.next;
if (!q){
break;
};
i++;
};
qsize = insize;
while ((((psize > 0)) || ((((qsize > 0)) && (q))))) {
if (psize == 0){
e = q;
q = q.next;
qsize--;
} else {
if ((((qsize == 0)) || (!(q)))){
e = p;
p = p.next;
psize--;
} else {
if ((p.data - q.data) >= 0){
e = p;
p = p.next;
psize--;
} else {
e = q;
q = q.next;
qsize--;
};
};
};
if (tail){
tail.next = e;
} else {
h = e;
};
tail = e;
};
p = q;
};
tail.next = null;
if (nmerges <= 1){
return (h);
};
insize = (insize << 1);
};
} else {
while (true) {
p = h;
tail = null;
h = tail;
nmerges = 0;
while (p) {
nmerges++;
i = 0;
psize = 0;
q = p;
while (i < insize) {
psize++;
q = q.next;
if (!q){
break;
};
i++;
};
qsize = insize;
while ((((psize > 0)) || ((((qsize > 0)) && (q))))) {
if (psize == 0){
e = q;
q = q.next;
qsize--;
} else {
if ((((qsize == 0)) || (!(q)))){
e = p;
p = p.next;
psize--;
} else {
if ((p.data - q.data) <= 0){
e = p;
p = p.next;
psize--;
} else {
e = q;
q = q.next;
qsize--;
};
};
};
if (tail){
tail.next = e;
} else {
h = e;
};
tail = e;
};
p = q;
};
tail.next = null;
if (nmerges <= 1){
return (h);
};
insize = (insize << 1);
};
};
return (null);
}
}//package de.polygonal.ds.sort
Section 207
//sLinkedMergeSortCmp (de.polygonal.ds.sort.sLinkedMergeSortCmp)
package de.polygonal.ds.sort {
import de.polygonal.ds.*;
public function sLinkedMergeSortCmp(node:SListNode, cmp:Function, descending:Boolean=false):SListNode{
var p:SListNode;
var q:SListNode;
var e:SListNode;
var tail:SListNode;
var nmerges:int;
var psize:int;
var qsize:int;
var i:int;
if (((!(node)) || ((cmp == null)))){
return (null);
};
var h:SListNode = node;
var insize = 1;
if (descending){
while (true) {
p = h;
tail = null;
h = tail;
nmerges = 0;
while (p) {
nmerges++;
i = 0;
psize = 0;
q = p;
while (i < insize) {
psize++;
q = q.next;
if (!q){
break;
};
i++;
};
qsize = insize;
while ((((psize > 0)) || ((((qsize > 0)) && (q))))) {
if (psize == 0){
e = q;
q = q.next;
qsize--;
} else {
if ((((qsize == 0)) || (!(q)))){
e = p;
p = p.next;
psize--;
} else {
if (cmp(p.data, q.data) >= 0){
e = p;
p = p.next;
psize--;
} else {
e = q;
q = q.next;
qsize--;
};
};
};
if (tail){
tail.next = e;
} else {
h = e;
};
tail = e;
};
p = q;
};
tail.next = null;
if (nmerges <= 1){
return (h);
};
insize = (insize << 1);
};
} else {
while (true) {
p = h;
tail = null;
h = tail;
nmerges = 0;
while (p) {
nmerges++;
i = 0;
psize = 0;
q = p;
while (i < insize) {
psize++;
q = q.next;
if (!q){
break;
};
i++;
};
qsize = insize;
while ((((psize > 0)) || ((((qsize > 0)) && (q))))) {
if (psize == 0){
e = q;
q = q.next;
qsize--;
} else {
if ((((qsize == 0)) || (!(q)))){
e = p;
p = p.next;
psize--;
} else {
if (cmp(p.data, q.data) <= 0){
e = p;
p = p.next;
psize--;
} else {
e = q;
q = q.next;
qsize--;
};
};
};
if (tail){
tail.next = e;
} else {
h = e;
};
tail = e;
};
p = q;
};
tail.next = null;
if (nmerges <= 1){
return (h);
};
insize = (insize << 1);
};
};
return (null);
}
}//package de.polygonal.ds.sort
Section 208
//Collection (de.polygonal.ds.Collection)
package de.polygonal.ds {
public interface Collection {
function get size():int;
function isEmpty():Boolean;
function getIterator():Iterator;
function clear():void;
function toArray():Array;
function contains():Boolean;
}
}//package de.polygonal.ds
Section 209
//Iterator (de.polygonal.ds.Iterator)
package de.polygonal.ds {
public interface Iterator {
function start():void;
function set data(C:\development\whirled\Contraption;de\polygonal\ds;Iterator.as):void;
function get data();
function next();
function hasNext():Boolean;
}
}//package de.polygonal.ds
Section 210
//LinkedListNode (de.polygonal.ds.LinkedListNode)
package de.polygonal.ds {
public interface LinkedListNode {
}
}//package de.polygonal.ds
Section 211
//SLinkedList (de.polygonal.ds.SLinkedList)
package de.polygonal.ds {
import de.polygonal.ds.sort.compare.*;
import de.polygonal.ds.sort.*;
public class SLinkedList implements Collection {
private var _count:int;
public var tail:SListNode;
public var head:SListNode;
public static const MERGE_SORT:int = (1 << 2);
public static const DESCENDING:int = (1 << 4);
public static const NUMERIC:int = (1 << 3);
public static const INSERTION_SORT:int = (1 << 1);
public function SLinkedList(... _args){
super();
head = (tail = null);
_count = 0;
if (_args.length > 0){
append.apply(this, _args);
};
}
public function get size():int{
return (_count);
}
public function isEmpty():Boolean{
return ((_count == 0));
}
public function remove(itr:SListIterator):Boolean{
if (((!((itr.list == this))) || (!(itr.node)))){
return (false);
};
var node:SListNode = head;
if (itr.node == head){
itr.forth();
removeHead();
return (true);
};
while (node.next != itr.node) {
node = node.next;
};
itr.forth();
if (node.next == tail){
tail = node;
};
node.next = itr.node;
_count--;
return (true);
}
public function removeHead(){
var obj:*;
var node:SListNode;
if (head){
obj = head.data;
if (head == tail){
head = (tail = null);
} else {
node = head;
head = head.next;
node.next = null;
if (head == null){
tail = null;
};
};
_count--;
return (obj);
};
return (null);
}
public function clear():void{
var next:SListNode;
var node:SListNode = head;
head = null;
while (node) {
next = node.next;
node.next = null;
node = next;
};
_count = 0;
}
public function prepend(... _args):SListNode{
var t:SListNode;
var i:int;
var k:int = _args.length;
var node:SListNode = new SListNode(_args[int((k - 1))]);
if (head){
node.next = head;
head = node;
} else {
head = (tail = node);
};
if (k > 1){
t = node;
i = (k - 2);
while (i >= 0) {
node = new SListNode(_args[i]);
node.next = head;
head = node;
i--;
};
_count = (_count + k);
return (t);
};
_count++;
return (node);
}
public function popDown():void{
var node:SListNode;
var t:SListNode = tail;
if (head.next == tail){
tail = head;
head = t;
tail.next = null;
head.next = tail;
} else {
node = head;
while (node.next != tail) {
node = node.next;
};
tail = node;
tail.next = null;
t.next = head;
head = t;
};
}
public function concat(... _args):SLinkedList{
var a:SLinkedList;
var n:SListNode;
var c:SLinkedList = new SLinkedList();
n = head;
while (n) {
c.append(n.data);
n = n.next;
};
var k:int = _args.length;
var i:int;
while (i < k) {
a = _args[i];
n = a.head;
while (n) {
c.append(n.data);
n = n.next;
};
i++;
};
return (c);
}
public function append(... _args):SListNode{
var t:SListNode;
var i:int;
var k:int = _args.length;
var node:SListNode = new SListNode(_args[0]);
if (head){
tail.next = node;
tail = node;
} else {
head = (tail = node);
};
if (k > 1){
t = node;
i = 1;
while (i < k) {
node = new SListNode(_args[i]);
tail.next = node;
tail = node;
i++;
};
_count = (_count + k);
return (t);
};
_count++;
return (node);
}
public function sort(... _args):void{
var b:int;
var cmp:Function;
var o:*;
if (_count <= 1){
return;
};
if (_args.length > 0){
b = 0;
cmp = null;
o = _args[0];
if ((o is Function)){
cmp = o;
if (_args.length > 1){
o = _args[1];
if ((o is int)){
b = o;
};
};
} else {
if ((o is int)){
b = o;
};
};
if (Boolean(cmp)){
if ((b & 2)){
head = sLinkedInsertionSortCmp(head, cmp, (b == 18));
} else {
head = sLinkedMergeSortCmp(head, cmp, (b == 16));
};
} else {
if ((b & 2)){
if ((b & 4)){
if (b == 22){
head = sLinkedInsertionSortCmp(head, compareStringCaseSensitiveDesc);
} else {
if (b == 14){
head = sLinkedInsertionSortCmp(head, compareStringCaseInSensitive);
} else {
if (b == 30){
head = sLinkedInsertionSortCmp(head, compareStringCaseInSensitiveDesc);
} else {
head = sLinkedInsertionSortCmp(head, compareStringCaseSensitive);
};
};
};
} else {
head = sLinkedInsertionSort(head, (b == 18));
};
} else {
if ((b & 4)){
if (b == 20){
head = sLinkedMergeSortCmp(head, compareStringCaseSensitiveDesc);
} else {
if (b == 12){
head = sLinkedMergeSortCmp(head, compareStringCaseInSensitive);
} else {
if (b == 28){
head = sLinkedMergeSortCmp(head, compareStringCaseInSensitiveDesc);
} else {
head = sLinkedMergeSortCmp(head, compareStringCaseSensitive);
};
};
};
} else {
if ((b & 16)){
head = sLinkedMergeSort(head, true);
};
};
};
};
} else {
head = sLinkedMergeSort(head);
};
}
public function reverse():void{
if (_count == 0){
return;
};
var a:Array = new Array(_count);
var i:int;
var node:SListNode = head;
while (node) {
var _temp1 = i;
i = (i + 1);
var _local4 = _temp1;
a[_local4] = node;
node = node.next;
};
a.reverse();
node = (head = a[0]);
i = 1;
while (i < _count) {
node = (node.next = a[i]);
i++;
};
node.next = null;
tail = node;
a = null;
}
public function insertAfter(itr:SListIterator, obj):SListNode{
var node:SListNode;
if (itr.list != this){
return (null);
};
if (itr.node){
node = new SListNode(obj);
itr.node.insertAfter(node);
if (itr.node == tail){
tail = itr.node.next;
};
_count++;
return (node);
//unresolved jump
};
return (append(obj));
}
public function getIterator():Iterator{
return (new SListIterator(this, head));
}
public function toArray():Array{
var a:Array = [];
var node:SListNode = head;
while (node) {
a.push(node.data);
node = node.next;
};
return (a);
}
public function contains(obj):Boolean{
var node:SListNode = head;
while (node) {
if (node.data == obj){
return (true);
};
node = node.next;
};
return (false);
}
public function getListIterator():SListIterator{
return (new SListIterator(this, head));
}
public function join(sep):String{
if (_count == 0){
return ("");
};
var s:String = "";
var node:SListNode = head;
while (node.next) {
s = (s + (node.data + sep));
node = node.next;
};
s = (s + node.data);
return (s);
}
public function toString():String{
return ((("[SlinkedList, size=" + size) + "]"));
}
public function removeTail(){
var obj:*;
var node:SListNode;
if (tail){
obj = tail.data;
if (head == tail){
head = (tail = null);
} else {
node = head;
while (node.next != tail) {
node = node.next;
};
tail = node;
node.next = null;
};
_count--;
return (obj);
};
return (null);
}
public function merge(... _args):void{
var a:SLinkedList;
a = _args[0];
if (head){
tail.next = a.head;
tail = a.tail;
} else {
head = a.head;
tail = a.tail;
};
var k:int = _args.length;
var i = 1;
while (i < k) {
a = _args[i];
tail.next = a.head;
tail = a.tail;
_count = (_count + a.size);
i++;
};
}
public function nodeOf(obj, from:SListIterator=null):SListIterator{
if (from != null){
if (from.list != null){
return (null);
};
};
var node:SListNode = ((from)==null) ? head : from.node;
while (node) {
if (node.data === obj){
return (new SListIterator(this, node));
};
node = node.next;
};
return (null);
}
public function dump():String{
if (!head){
return ("SLinkedList: (empty)");
};
var s = (((("SLinkedList: has " + _count) + " node") + ((_count == 1)) ? "" : "s") + "\n|< Head\n");
var itr:SListIterator = getListIterator();
while (itr.valid()) {
s = (s + (("\t" + itr.data) + "\n"));
itr.forth();
};
s = (s + "Tail >|");
return (s);
}
public function splice(start:SListIterator, deleteCount:uint=4294967295, ... _args):SLinkedList{
var s:SListNode;
var t:SListNode;
var c:SLinkedList;
var i:int;
var k:int;
var n:SListNode;
if (start){
if (start.list != this){
return (null);
};
};
if (start.node){
s = start.node;
t = head;
while (t.next != s) {
t = t.next;
};
c = new SLinkedList();
if (deleteCount == 4294967295){
if (start.node == tail){
return (c);
};
while (start.node) {
c.append(start.node.data);
start.remove();
};
start.list = c;
start.node = s;
return (c);
} else {
i = 0;
while (i < deleteCount) {
if (start.node){
c.append(start.node.data);
start.remove();
} else {
break;
};
i++;
};
};
k = _args.length;
if (k > 0){
if (_count == 0){
i = 0;
while (i < k) {
append(_args[i]);
i++;
};
} else {
if (t == null){
n = prepend(_args[0]);
i = 1;
while (i < k) {
n.insertAfter(new SListNode(_args[i]));
if (n == tail){
tail = n.next;
};
n = n.next;
_count++;
i++;
};
} else {
n = t;
i = 0;
while (i < k) {
n.insertAfter(new SListNode(_args[i]));
if (n == tail){
tail = n.next;
};
n = n.next;
_count++;
i++;
};
};
};
start.node = n;
} else {
start.node = s;
};
start.list = c;
return (c);
};
return (null);
}
public function shiftUp():void{
var t:SListNode = head;
if (head.next == tail){
head = tail;
tail = t;
tail.next = null;
head.next = tail;
} else {
head = head.next;
tail.next = t;
t.next = null;
tail = t;
};
}
}
}//package de.polygonal.ds
Section 212
//SListIterator (de.polygonal.ds.SListIterator)
package de.polygonal.ds {
public class SListIterator implements Iterator {
public var node:SListNode;
public var list:SLinkedList;
public function SListIterator(list:SLinkedList=null, node:SListNode=null){
super();
this.list = list;
this.node = node;
}
public function remove():Boolean{
return (list.remove(this));
}
public function start():void{
if (list){
node = list.head;
};
}
public function get data(){
if (node){
return (node.data);
};
return (null);
}
public function forth():void{
if (node){
node = node.next;
};
}
public function toString():String{
return ((("{SListIterator: data=" + node.data) + "}"));
}
public function hasNext():Boolean{
return (Boolean(node));
}
public function valid():Boolean{
return (Boolean(node));
}
public function next(){
var obj:*;
if (hasNext()){
obj = node.data;
node = node.next;
return (obj);
};
return (null);
}
public function set data(obj):void{
node.data = obj;
}
public function end():void{
if (list){
node = list.tail;
};
}
}
}//package de.polygonal.ds
Section 213
//SListNode (de.polygonal.ds.SListNode)
package de.polygonal.ds {
public class SListNode implements LinkedListNode {
public var next:SListNode;
public var data;
public function SListNode(obj){
super();
data = obj;
next = null;
}
public function insertAfter(node:SListNode):void{
node.next = next;
next = node;
}
public function toString():String{
return ((("[SListNode, data=" + data) + "]"));
}
}
}//package de.polygonal.ds
Section 214
//FontAsset (mx.core.FontAsset)
package mx.core {
import flash.text.*;
public class FontAsset extends Font implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
public function FontAsset(){
super();
}
}
}//package mx.core
Section 215
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 216
//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 217
//BackButton (BackButton)
package {
import contraption.menu.*;
public dynamic class BackButton extends DashboardButton {
}
}//package
Section 218
//BackTestButton (BackTestButton)
package {
import contraption.menu.*;
public dynamic class BackTestButton extends DashboardButton {
}
}//package
Section 219
//BackToMenuButton (BackToMenuButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class BackToMenuButton extends Button {
public function BackToMenuButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.MENU_BACK;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 220
//BobbingCloud (BobbingCloud)
package {
import flash.display.*;
public dynamic class BobbingCloud extends MovieClip {
}
}//package
Section 221
//Border (Border)
package {
import flash.display.*;
public dynamic class Border extends MovieClip {
}
}//package
Section 222
//BubbleSceneChange (BubbleSceneChange)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class BubbleSceneChange extends SceneChange {
public function BubbleSceneChange(){
addFrameScript(0, frame1, 14, frame15);
}
function frame15(){
if (!doOpen){
stop();
} else {
dispatchEvent(new MenuEvent(MenuEvent.OPEN_CURTAIN));
};
}
function frame1(){
stop();
}
}
}//package
Section 223
//BuildingMousePointer (BuildingMousePointer)
package {
import flash.display.*;
public dynamic class BuildingMousePointer extends MovieClip {
}
}//package
Section 224
//ButtonBack (ButtonBack)
package {
import contraption.menu.*;
public dynamic class ButtonBack extends NoTabButton {
}
}//package
Section 225
//ButtonMousePointer (ButtonMousePointer)
package {
import flash.display.*;
public dynamic class ButtonMousePointer extends MovieClip {
}
}//package
Section 226
//BuyGameButton (BuyGameButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class BuyGameButton extends Button {
public function BuyGameButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.BUY_GAME;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 227
//BuyMenuBackground (BuyMenuBackground)
package {
import flash.display.*;
public dynamic class BuyMenuBackground extends MovieClip {
}
}//package
Section 228
//ClockwiseWheel (ClockwiseWheel)
package {
import flash.display.*;
public dynamic class ClockwiseWheel extends MovieClip {
}
}//package
Section 229
//ClockwiseWheelButton (ClockwiseWheelButton)
package {
import contraption.menu.*;
public dynamic class ClockwiseWheelButton extends DashboardButton {
}
}//package
Section 230
//ClockwiseWheelGraphic (ClockwiseWheelGraphic)
package {
import flash.display.*;
public dynamic class ClockwiseWheelGraphic extends MovieClip {
}
}//package
Section 231
//Clouds (Clouds)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class Clouds extends MovieClip {
public var SCENE_WIDTH:int;
public var cloudArray:Array;
public var SCENE_HEIGHT:int;
public var speedArray:Array;
public var NUM_CLOUDS:int;
public var SPEED_MODIFIER:Number;
public function Clouds(){
addFrameScript(0, frame1);
}
public function getRandomSpeed():int{
return (getRandomNumber(1, 5));
}
public function moveClouds(_arg1:Event):void{
var _local2:int;
var _local3:BobbingCloud;
var _local4:Number;
_local2 = 0;
while (_local2 < cloudArray.length) {
_local3 = cloudArray[_local2];
_local4 = speedArray[_local2];
_local3.x = (_local3.x + ((5 * _local4) * SPEED_MODIFIER));
if (_local3.x > (SCENE_WIDTH + 50)){
removeChild(_local3);
_local3 = new BobbingCloud();
_local3.x = -325;
_local3.y = getRandomNumber(0, (SCENE_HEIGHT - 200));
addChild(_local3);
cloudArray[_local2] = _local3;
speedArray[_local2] = getRandomSpeed();
};
_local2++;
};
}
function frame1(){
cloudArray = new Array();
speedArray = new Array();
SCENE_WIDTH = 2000;
SCENE_HEIGHT = 1400;
SPEED_MODIFIER = 0.05;
NUM_CLOUDS = 5;
setup();
addEventListener(Event.ENTER_FRAME, moveClouds);
}
public function getRandomNumber(_arg1:int, _arg2:int):int{
return ((Math.round((Math.random() * (_arg2 - _arg1))) + _arg1));
}
public function setup():void{
var _local1:int;
var _local2:BobbingCloud;
var _local3:int;
_local1 = 0;
while (_local1 < NUM_CLOUDS) {
_local2 = new BobbingCloud();
_local2.x = getRandomNumber(0, (SCENE_WIDTH - 200));
_local2.y = getRandomNumber(0, (SCENE_HEIGHT - 200));
setRandomBob(_local2);
_local3 = getRandomSpeed();
addChild(_local2);
cloudArray.push(_local2);
speedArray.push(_local3);
_local1++;
};
}
public function setRandomBob(_arg1:BobbingCloud):void{
var _local2:int;
_local2 = getRandomNumber(1, 70);
_arg1.gotoAndPlay(_local2);
}
}
}//package
Section 232
//ContinueButton (ContinueButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class ContinueButton extends Button {
public function ContinueButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.MENU_BACK;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 233
//ContinueTutorialButton (ContinueTutorialButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class ContinueTutorialButton extends Button {
public function ContinueTutorialButton(){
addFrameScript(0, frame1);
}
function frame1(){
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 234
//Contraption (Contraption)
package {
import flash.events.*;
import contraption.menu.*;
import contraption.*;
import flash.display.*;
import contraption.blocks.*;
import flash.geom.*;
import contraption.tutorials.*;
import flash.net.*;
import de.polygonal.ds.*;
import com.whirled.game.*;
import flash.text.*;
import flash.ui.*;
import flash.external.*;
public class Contraption extends MovieClip {
protected var pointerMode:String;
protected var mouseType:int;
protected var acting:Boolean;// = false
protected var menuCanvas:Sprite;
protected var spinner:MovieClip;
protected var newMenu:MenuWindow;
protected var mainMenu:MainMenu;
protected var mousePointer:MousePointer;
protected var player:Player;
protected var sceneChange:SceneChange;
protected var splash:MovieClip;
protected var menuStack:SLinkedList;
protected var toolTip:Sprite;
protected var tf:TextField;
protected var editor:Editor;
protected var currentMenu:MenuWindow;
public static const VERSION_NUMBER:String = "1.026";
public static const VERSION_NAME:String = "kongregate.com";
public static const INCLUDE_PAYPAL_LINKS:Boolean = false;
protected static var LAWS_FONT:Class = Contraption_LAWS_FONT;
public function Contraption():void{
super();
Music.getInstance().playMenu();
var t:Object = new YourSavedLevelsButton();
t = new YourSavedContraptionsButton();
t = new NewLevelButton();
t = new UserGenLevelsButton();
t = new LogInButton();
t = new LogOutButton();
t = new NewUserButton();
t = new SmallCancelButton();
t = new ResetPasswordButton();
t = new UpdateUserInfoButton();
t = new PreviousMenuButton();
t = new MainMenuButton();
t = new BuyGameButton();
t = new TutorialNextButton();
if (VERSION_NAME != "whirled.com"){
stage.frameRate = 30;
};
graphics.beginFill(8895985);
graphics.drawRect(0, 0, 700, 500);
menuCanvas = new Sprite();
addChild(menuCanvas);
authenticate();
var muteButton:Button = new MuteButton();
muteButton.x = 10;
muteButton.y = 455;
addChild(muteButton);
tf = new TextField();
tf.y = 460;
tf.width = 2000;
addChild(tf);
tf.mouseEnabled = false;
var theMask:Sprite = new Sprite();
theMask.graphics.beginFill(8895985);
theMask.graphics.drawRect(0, 0, 700, 500);
addChild(theMask);
mask = theMask;
spinner = new Spinner();
mousePointer = new MousePointer(acting);
mousePointer.visible = false;
addChild(mousePointer);
pointerMode = ModeEvent.DEFAULT_MODE;
sceneChange = new BubbleSceneChange();
sceneChange.addEventListener(MenuEvent.OPEN_CURTAIN, showNewMenu, false, 0, true);
sceneChange.addEventListener(MenuEvent.CURTAIN_OPEN_COMPLETE, curtainOpenComplete, false, 0, true);
menuStack = new SLinkedList();
mainMenu = new MainMenu();
loadMenu(mainMenu);
sceneChange.jumpToClosed();
sceneChange.lockClosed = true;
splash = new Splash();
splash.x = 350;
splash.y = 250;
sceneChange.addChild(splash);
sceneChange.addEventListener(MouseEvent.MOUSE_DOWN, closeSplash, false, 0, true);
var globalListener:GlobalListener = GlobalListener.getInstance();
globalListener.init(stage, this);
globalListener.addEventListener(KeyboardEvent.KEY_DOWN, closeSplash, false, 0, true);
var levelId:String = root.loaderInfo.parameters.levelId;
var designId:String = root.loaderInfo.parameters.designId;
var editId:String = root.loaderInfo.parameters.editId;
if (((!((levelId == null))) && (!((levelId == ""))))){
loadLevel(new int(levelId));
} else {
if (((!((designId == null))) && (!((designId == ""))))){
loadDesign(new int(designId), true);
} else {
if (((!((editId == null))) && (!((editId == ""))))){
editLevel(new int(editId));
};
};
};
addEventListener(Event.ENTER_FRAME, update, false, 0, true);
globalListener.addEventListener(Event.MOUSE_LEAVE, mouseOut, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_DOWN, startAction, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_UP, endAction, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_MOVE, setPointerHandler, false, 0, true);
globalListener.addEventListener(Event.UNLOAD, unload, false, 0, true);
addEventListener(TooltipEvent.ADD_TOOLTIP, addTooltip, false, 0, true);
addEventListener(TooltipEvent.REMOVE_TOOLTIP, removeTooltip, false, 0, true);
var border:MovieClip = new Border();
border.x = 351;
border.y = 247;
addChild(border);
}
protected function mouseOut(event:Event):void{
Mouse.show();
mousePointer.visible = false;
}
protected function setPointer(setActing:Boolean=false, actingType:int=0):void{
var newMouseType:int;
var objectUnderPointer:ActionContainer;
var allowableActions:Actions;
if (VERSION_NAME == "whirled.com"){
return;
};
if (acting){
if (actingType != ModeEvent.ACTION_UNKNOWN){
menuCanvas.removeChild(mousePointer);
if (actingType == ModeEvent.ACTION_MOVE){
mousePointer = new MovePointer(acting);
} else {
if (actingType == ModeEvent.ACTION_BUILD){
mousePointer = new BuildingPointer(acting);
} else {
if (actingType == ModeEvent.ACTION_BUTTON){
mousePointer = new ButtonPointer(acting);
};
};
};
menuCanvas.addChild(mousePointer);
};
return;
};
if (setActing){
acting = true;
};
var objectsUnderPointer:Array = getObjectsUnderPoint(localToGlobal(new Point(mouseX, mouseY)));
Mouse.hide();
mousePointer.visible = true;
var i:int = (objectsUnderPointer.length - 1);
while (i >= 0) {
if ((objectsUnderPointer[i] as ActionContainer)){
objectUnderPointer = (objectsUnderPointer[i] as ActionContainer);
if ((((((player == null)) || (player.isInStartZone(new Point(mouseX, mouseY))))) || (!((objectUnderPointer as Block))))){
break;
};
};
if (((!((objectsUnderPointer[i] == this))) && ((objectsUnderPointer[i].parent as MouseBlockingBackground)))){
objectUnderPointer = (objectsUnderPointer[i] as ActionContainer);
break;
};
i--;
};
if (objectUnderPointer != null){
allowableActions = objectUnderPointer.getAllowableActions();
} else {
allowableActions = new Actions();
};
var running:Boolean;
if (((!((player == null))) && (player.isRunning()))){
running = true;
};
if (allowableActions.button){
newMouseType = MousePointer.BUTTON_UP;
} else {
if ((((pointerMode == ModeEvent.DELETE_MODE)) && (!(running)))){
if (allowableActions.delete_){
newMouseType = MousePointer.DELETE_UP;
} else {
newMouseType = MousePointer.NORMAL_UP;
};
} else {
if ((((pointerMode == ModeEvent.MOVE_MODE)) && (allowableActions.drag))){
newMouseType = MousePointer.DRAG_UP;
} else {
if ((((((pointerMode == ModeEvent.MOVE_MODE)) && (allowableActions.move))) && (!(running)))){
newMouseType = MousePointer.MOVE_UP;
} else {
if (((allowableActions.build) && (!(running)))){
newMouseType = MousePointer.BUILDING_UP;
} else {
if (allowableActions.alwaysDrag){
newMouseType = MousePointer.DRAG_UP;
} else {
newMouseType = MousePointer.NORMAL_UP;
};
};
};
};
};
};
if (acting){
newMouseType++;
};
if (newMouseType != mouseType){
mouseType = newMouseType;
menuCanvas.removeChild(mousePointer);
switch (newMouseType){
case MousePointer.NORMAL_UP:
mousePointer = new MousePointer(false);
break;
case MousePointer.NORMAL_DOWN:
mousePointer = new MousePointer(true);
break;
case MousePointer.BUILDING_UP:
mousePointer = new BuildingPointer(false);
break;
case MousePointer.BUILDING_DOWN:
mousePointer = new BuildingPointer(true);
break;
case MousePointer.DELETE_UP:
mousePointer = new DeletePointer(false);
break;
case MousePointer.DELETE_DOWN:
mousePointer = new DeletePointer(true);
break;
case MousePointer.MOVE_UP:
mousePointer = new MovePointer(false);
break;
case MousePointer.MOVE_DOWN:
mousePointer = new MovePointer(true);
break;
case MousePointer.DRAG_UP:
mousePointer = new DragPointer(false);
break;
case MousePointer.DRAG_DOWN:
mousePointer = new DragPointer(true);
break;
case MousePointer.BUTTON_UP:
mousePointer = new ButtonPointer(false);
break;
case MousePointer.BUTTON_DOWN:
mousePointer = new ButtonPointer(true);
break;
};
};
menuCanvas.addChild(mousePointer);
if (allowableActions.inputText){
mousePointer.visible = false;
} else {
mousePointer.visible = true;
};
mousePointer.x = mouseX;
mousePointer.y = mouseY;
}
protected function removeSpinner(event:MenuEvent):void{
if (menuCanvas.contains(spinner)){
menuCanvas.removeChild(spinner);
};
}
protected function closeSplash(event:Event):void{
splash.gotoAndPlay("leave");
sceneChange.removeEventListener(MouseEvent.MOUSE_DOWN, closeSplash);
GlobalListener.getInstance().removeEventListener(KeyboardEvent.KEY_DOWN, closeSplash);
sceneChange.lockClosed = false;
sceneChange.open();
event.stopPropagation();
}
protected function tryLevel(event:Event):void{
player = new Player(stage, this, false, true);
loadMenu(player);
player.loadFromXml(editor.getLevelXml());
player.initZoomAndScroll();
}
protected function defaultMode(event:Event=null):void{
pointerMode = ModeEvent.DEFAULT_MODE;
setPointer();
}
protected function bubble(e:Event):void{
dispatchEvent(e);
}
protected function loadTutorialLevel(tutorialNumber:int):void{
player = new TutorialPlayer(stage, this);
loadMenu(player);
(player as TutorialPlayer).loadTutorialLevel(tutorialNumber);
}
public function checkAccessComplete(event:Event):void{
var access:XML = new XML(event.target.data);
if (access.permission == "false"){
deniedPermissionToPlay(access.message);
};
}
protected function loadOfficialLevel(levelNumber:int):void{
player = new Player(stage, this);
loadMenu(player);
player.loadOfficialLevel(levelNumber);
finishLoading();
}
protected function moveMode(event:Event=null):void{
pointerMode = ModeEvent.MOVE_MODE;
setPointer();
}
protected function loadUserGenLevels(event:Event):void{
loadMenu(new UserGenLevelsMenu());
}
protected function loadTutorials(event:MenuEvent):void{
loadTutorialLevel(1);
}
protected function removeTooltip(event:TooltipEvent):void{
if (toolTip){
menuCanvas.removeChild(toolTip);
};
toolTip = null;
}
protected function editLevel(editId:int):void{
editor = new Editor(stage, this);
loadMenu(editor);
editor.loadLevel(editId);
}
public function checkAccess():void{
var loader:URLLoader = new ContraptionUrlLoader();
loader.addEventListener(Event.COMPLETE, checkAccessComplete);
var request:URLRequest = new URLRequest("http://FantasticContraption.com/checkAccess.php");
var variables:URLVariables = new URLVariables();
variables.versionName = VERSION_NAME;
variables.versionNumber = VERSION_NUMBER;
variables.requestingDomain = currentDomain();
request.data = variables;
request.method = URLRequestMethod.GET;
loader.load(request);
if (VERSION_NAME == "fantasticcontraption.com"){
ExternalInterface.call("pageTracker._trackPageview", ("/gameStart?versionName=" + VERSION_NAME));
};
}
protected function currentDomain():String{
if (new GameControl(this).isConnected()){
return ("whirled.com");
};
var urlStart:int = (stage.loaderInfo.loaderURL.indexOf("://") + 3);
var urlEnd:int = stage.loaderInfo.loaderURL.indexOf("/", urlStart);
var domain:String = stage.loaderInfo.loaderURL.substring(urlStart, urlEnd);
var LastDot:int = (domain.lastIndexOf(".") - 1);
var domEnd:int = (domain.lastIndexOf(".", LastDot) + 1);
return (domain.substring(domEnd, domain.length));
}
protected function tutorialLevelCompleteMenu(event:MenuEvent):void{
loadModalMenu(new CompletedTutorialLevelMenu(event.tutorialNumber));
}
public function unload(event:Event):void{
removeEventListener(Event.ENTER_FRAME, update);
Music.getInstance().stopSound();
}
protected function addTooltip(event:TooltipEvent):void{
if (toolTip){
menuCanvas.removeChild(toolTip);
};
var textField:TextField = new TextField();
textField.autoSize = "left";
textField.text = event.toolTip;
toolTip = new Sprite();
toolTip.graphics.lineStyle(2, 14509636);
toolTip.graphics.beginFill(16772795);
toolTip.graphics.drawRect(0, 0, (textField.width + 5), (textField.height + 5));
toolTip.addChild(textField);
toolTip.x = (mouseX - (toolTip.width / 2));
toolTip.y = ((mouseY - toolTip.height) - 25);
if (toolTip.x < 0){
toolTip.x = (mouseX + 20);
};
if (toolTip.y < 0){
toolTip.y = (mouseY + 50);
};
menuCanvas.addChild(toolTip);
}
protected function loadLinkedInMenu(event:MenuEvent):void{
loadModalMenu(new LinkInMenu());
}
protected function addMenu(menu:MenuWindow):void{
addMenuListeners(menu);
menuStack.append(menu);
menuCanvas.addChild(menu);
acting = false;
setPointer();
}
protected function loadSavedLevels(event:MenuEvent):void{
var userId:int = event.userId;
if (userId == 0){
userId = User.getInstance().getUserId();
};
loadMenu(new UserLevelsMenu(userId));
}
protected function finishLoading(event:MenuEvent=null):void{
if (newMenu == null){
return;
};
if (menuCanvas.contains(sceneChange)){
sceneChange.open();
} else {
showNewMenu();
};
}
protected function loadTutorialLevelHandler(event:MenuEvent):void{
loadTutorialLevel(event.tutorialNumber);
}
protected function loadLevelHandler(event:MenuEvent):void{
loadLevel(event.levelId);
}
protected function loadUpdateUserInfoMenu(event:MenuEvent):void{
loadModalMenu(new UpdateUserInfoMenu());
}
protected function loadOfficialLevelHandler(event:MenuEvent):void{
if (event.levelNumber == 0){
return (loadLevel(event.levelId));
};
loadOfficialLevel(event.levelNumber);
}
protected function deniedPermissionToPlay(message:String):void{
menuCanvas.visible = false;
var text:TextArea = new TextArea(message, 14);
text.bold();
text.mouseEnabled = true;
text.x = 200;
text.y = 200;
addChild(text);
throw (("Error: " + message));
}
protected function loadSaveLevelMenu(event:SaveEvent):void{
loadModalMenu(new SaveLevelMenu(event.xml));
}
protected function loadResetPasswordMenu(event:MenuEvent):void{
menuBack();
loadModalMenu(new LostPasswordMenu());
}
protected function loadDesign(designId:int, linkedIn:Boolean=false):void{
player = new Player(stage, this, linkedIn);
loadMenu(player);
player.loadDesign(designId);
}
protected function loadMainMenu(event:MenuEvent=null):void{
var menu:MenuWindow;
var menuIter:Iterator = menuStack.getIterator();
while (menuIter.hasNext()) {
menu = menuIter.next();
menu.disposeMenu();
if (menuCanvas.contains(menu)){
menuCanvas.removeChild(menu);
};
};
menuStack.clear();
mainMenu.refresh();
mainMenu.visible = true;
menuCanvas.addChild(mainMenu);
menuStack.append(mainMenu);
currentMenu = mainMenu;
}
protected function addSpinner(event:MenuEvent):void{
menuCanvas.addChild(spinner);
}
protected function loadLogInMenu(event:MenuEvent):void{
loadModalMenu(new LogInMenu());
}
protected function loadNewUserMenu(event:MenuEvent):void{
loadModalMenu(new NewUserMenu());
}
protected function loadLevel(levelId:int):void{
player = new Player(stage, this);
loadMenu(player);
player.loadLevel(levelId);
}
protected function setPointerHandler(event:Event):void{
setPointer();
}
protected function editLevelHandler(event:MenuEvent):void{
editLevel(event.levelId);
}
protected function loadBuyGameMenu(event:MenuEvent):void{
loadModalMenu(new BuyGameMenu());
}
protected function endAction(event:Event=null):void{
acting = false;
setPointer();
}
protected function authenticate(allowDomain:String="example.com"):void{
checkAccess();
}
protected function loadLevelLinkMenu(event:MenuEvent):void{
loadModalMenu(new LevelLinkMenu(event.levelId));
}
protected function curtainOpenComplete(event:MenuEvent):void{
menuCanvas.removeChild(sceneChange);
}
protected function loadDesignLinkMenu(event:MenuEvent):void{
loadModalMenu(new DesignLinkMenu(event.designId));
}
protected function loadUserMenu(event:MenuEvent):void{
loadMenu(new UserMenu(event.userId, event.userName));
finishLoading();
}
protected function showNewMenu(event:MenuEvent=null):void{
var menuIter:SListIterator;
var menu:MenuWindow;
if (currentMenu != null){
menuCanvas.removeChild(currentMenu);
};
newMenu.visible = true;
currentMenu = newMenu;
newMenu = null;
if ((currentMenu as Player)){
menuIter = menuStack.getListIterator();
while (menuIter.hasNext()) {
menu = (menuIter.next() as MenuWindow);
if ((((((menu as ModalMenu)) || ((menu as Player)))) && (!((menu == currentMenu))))){
if (menuCanvas.contains(menu)){
menuCanvas.removeChild(menu);
};
menuStack.remove(menuStack.nodeOf(menu));
};
};
};
}
protected function loadMenu(menu:MenuWindow):void{
menu.visible = false;
newMenu = menu;
addMenu(menu);
sceneChange.close();
menuCanvas.addChild(sceneChange);
if ((newMenu as Arena)){
Music.getInstance().playArena();
} else {
Music.getInstance().playMenu();
};
}
protected function loadDesignHandler(event:MenuEvent):void{
loadDesign(event.designId);
}
protected function levelCompleteMenu(event:MenuEvent):void{
loadModalMenu(new CompletedLevelMenu(event.levelNumber, event.levelId));
}
protected function loadSaveContraptionMenu(event:SaveEvent):void{
loadModalMenu(new SaveContraptionMenu(event.xml, event.isSolution, event.currentLevelId));
}
protected function loadModalMenu(menu:ModalMenu):void{
addMenu(menu);
}
protected function deleteMode(event:Event=null):void{
pointerMode = ModeEvent.DELETE_MODE;
setPointer();
}
protected function startAction(event:Event=null):void{
if ((event as ModeEvent)){
setPointer(true, (event as ModeEvent).actionType);
} else {
setPointer(true);
};
}
protected function loadEditor(event:MenuEvent):void{
editor = new Editor(stage, this);
loadMenu(editor);
finishLoading();
}
protected function menuBack(event:MenuEvent=null):void{
var menu:MenuWindow = (menuStack.tail.data as MenuWindow);
menu.disposeMenu();
menuCanvas.removeChild(menu);
menuStack.removeTail();
if (menuStack.tail == null){
loadMainMenu();
};
menu = (menuStack.tail.data as MenuWindow);
menu.refresh();
menu.visible = true;
menuCanvas.addChild(menu);
currentMenu = menu;
acting = false;
setPointer();
if ((currentMenu as Arena)){
Music.getInstance().playArena();
} else {
Music.getInstance().playMenu();
};
}
protected function update(event:Event):void{
mousePointer.x = mouseX;
mousePointer.y = mouseY;
}
protected function loadSavedDesigns(event:MenuEvent):void{
var userId:int = event.userId;
if (userId == 0){
userId = User.getInstance().getUserId();
};
loadMenu(new UserDesignsMenu(userId, UserDesignsMenu.USER_MODE));
}
protected function loadLevelSolutions(event:MenuEvent):void{
loadMenu(new UserDesignsMenu(event.levelId, UserDesignsMenu.LEVEL_MODE));
}
public function isCurrentMenu(menu:MenuWindow):Boolean{
return ((menu == (menuStack.tail.data as MenuWindow)));
}
protected function addMenuListeners(menu:MenuWindow):void{
menu.addEventListener(MenuEvent.LOAD_EDITOR, loadEditor, false, 0, true);
menu.addEventListener(MenuEvent.LOAD_LEVEL, loadLevelHandler, false, 0, true);
menu.addEventListener(MenuEvent.LOAD_OFFICIAL_LEVEL, loadOfficialLevelHandler, false, 0, true);
menu.addEventListener(MenuEvent.LOAD_TUTORIAL_LEVEL, loadTutorialLevelHandler, false, 0, true);
menu.addEventListener(MenuEvent.EDIT_LEVEL, editLevelHandler, false, 0, true);
menu.addEventListener(MenuEvent.LOAD_SAVED_DESIGNS, loadSavedDesigns, false, 0, true);
menu.addEventListener(MenuEvent.LOAD_SAVED_LEVELS, loadSavedLevels, false, 0, true);
menu.addEventListener(MenuEvent.LOAD_TUTORIALS, loadTutorials, false, 0, true);
menu.addEventListener(MenuEvent.LOAD_USER_GENERATED_LEVELS, loadUserGenLevels, false, 0, true);
menu.addEventListener(MenuEvent.LOAD_LEVEL_SOLUTIONS, loadLevelSolutions, false, 0, true);
menu.addEventListener(MenuEvent.LOAD_DESIGN, loadDesignHandler, false, 0, true);
menu.addEventListener(MenuEvent.TRY_LEVEL, tryLevel, false, 0, true);
menu.addEventListener(MenuEvent.RETURN_TO_MAIN_MENU, loadMainMenu, false, 0, true);
menu.addEventListener(MenuEvent.MENU_BACK, menuBack, false, 0, true);
menu.addEventListener(MenuEvent.FINISHED_LOADING, finishLoading, false, 0, true);
menu.addEventListener(MenuEvent.LOAD_USER_MENU, loadUserMenu, false, 0, true);
menu.addEventListener(MenuEvent.LOG_IN, loadLogInMenu, false, 0, true);
menu.addEventListener(MenuEvent.NEW_USER, loadNewUserMenu, false, 0, true);
menu.addEventListener(MenuEvent.RESET_PASSWORD, loadResetPasswordMenu, false, 0, true);
menu.addEventListener(MenuEvent.UPDATE_USER_INFO, loadUpdateUserInfoMenu, false, 0, true);
menu.addEventListener(MenuEvent.LOAD_LEVEL_LINK_MENU, loadLevelLinkMenu, false, 0, true);
menu.addEventListener(MenuEvent.LOAD_DESIGN_LINK_MENU, loadDesignLinkMenu, false, 0, true);
menu.addEventListener(MenuEvent.LEVEL_COMPLETE, levelCompleteMenu, false, 0, true);
menu.addEventListener(MenuEvent.TUTORIAL_LEVEL_COMPLETE, tutorialLevelCompleteMenu, false, 0, true);
menu.addEventListener(MenuEvent.LOAD_LINKED_IN_MENU, loadLinkedInMenu, false, 0, true);
menu.addEventListener(MenuEvent.BUY_GAME, loadBuyGameMenu, false, 0, true);
menu.addEventListener(MenuEvent.ADD_SPINNER, addSpinner, false, 0, true);
menu.addEventListener(MenuEvent.REMOVE_SPINNER, removeSpinner, false, 0, true);
menu.addEventListener(SaveEvent.SAVE_CONTRAPTION, loadSaveContraptionMenu, false, 0, true);
menu.addEventListener(SaveEvent.SAVE_LEVEL, loadSaveLevelMenu, false, 0, true);
menu.addEventListener(ModeEvent.MOVE_MODE, moveMode, false, 0, true);
menu.addEventListener(ModeEvent.DELETE_MODE, deleteMode, false, 0, true);
menu.addEventListener(ModeEvent.DEFAULT_MODE, defaultMode, false, 0, true);
menu.addEventListener(ModeEvent.START_ACTION, startAction, false, 0, true);
menu.addEventListener(MenuEvent.LOGGED_IN, bubble, false, 0, true);
}
}
}//package
Section 235
//Contraption_LAWS_FONT (Contraption_LAWS_FONT)
package {
import mx.core.*;
public class Contraption_LAWS_FONT extends FontAsset {
}
}//package
Section 236
//CounterClockwiseWheel (CounterClockwiseWheel)
package {
import flash.display.*;
public dynamic class CounterClockwiseWheel extends MovieClip {
}
}//package
Section 237
//CounterClockwiseWheelButton (CounterClockwiseWheelButton)
package {
import contraption.menu.*;
public dynamic class CounterClockwiseWheelButton extends DashboardButton {
}
}//package
Section 238
//CounterClockwiseWheelGraphic (CounterClockwiseWheelGraphic)
package {
import flash.display.*;
public dynamic class CounterClockwiseWheelGraphic extends MovieClip {
}
}//package
Section 239
//DashBackground (DashBackground)
package {
import contraption.menu.*;
public dynamic class DashBackground extends MouseBlockingBackground {
}
}//package
Section 240
//DashboardImpl (DashboardImpl)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
import adobe.utils.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class DashboardImpl extends Dashboard {
public var expander;
public function DashboardImpl(){
addFrameScript(0, frame1);
}
function frame1(){
expander = (getChildAt(0) as Expander);
fatInitFunction = fatInit;
initFat();
}
public function fatInit(_arg1:String):void{
zoomInButton = expander.dash.zoomButtons.zoomInButton;
zoomOutButton = expander.dash.zoomButtons.zoomOutButton;
if (_arg1 == MODE_EDIT_LEVEL){
expander.dash.removeChild(expander.dash.contraptionButtons);
testLevelButton = expander.dash.levelButtons.testLevelButton;
goalCircleButton = expander.dash.levelButtons.goalCircleButton;
goalSquareButton = expander.dash.levelButtons.goalSquareButton;
staticCircleButton = expander.dash.levelButtons.staticCircleButton;
staticSquareButton = expander.dash.levelButtons.staticSquareButton;
dynamicCircleButton = expander.dash.levelButtons.dynamicCircleButton;
dynamicSquareButton = expander.dash.levelButtons.dynamicSquareButton;
} else {
expander.dash.removeChild(expander.dash.levelButtons);
goButton = expander.dash.contraptionButtons.goStopButtons.goButton;
stopButton = expander.dash.contraptionButtons.goStopButtons.stopButton;
stopButtonPing = expander.dash.contraptionButtons.goStopButtons.stopButtonPing;
cwWheelButton = expander.dash.contraptionButtons.cwWheelButton;
ccwWheelButton = expander.dash.contraptionButtons.ccwWheelButton;
npWheelButton = expander.dash.contraptionButtons.npWheelButton;
hollowRodButton = expander.dash.contraptionButtons.hollowRodButton;
solidRodButton = expander.dash.contraptionButtons.solidRodButton;
moveButton = expander.dash.contraptionButtons.moveButton;
deleteButton = expander.dash.contraptionButtons.deleteButton;
};
if (_arg1 == MODE_TEST_LEVEL){
backButton = expander.dash.backTestButton;
expander.dash.removeChild(expander.dash.saveButton);
expander.dash.removeChild(expander.dash.backButton);
} else {
saveButton = expander.dash.saveButton;
backButton = expander.dash.backButton;
expander.dash.removeChild(expander.dash.backTestButton);
};
tooltip = expander.dash.tooltip;
init();
}
}
}//package
Section 241
//DefaultMousePointer (DefaultMousePointer)
package {
import flash.display.*;
public dynamic class DefaultMousePointer extends MovieClip {
}
}//package
Section 242
//DeleteButton (DeleteButton)
package {
import contraption.menu.*;
public dynamic class DeleteButton extends DashboardButton {
}
}//package
Section 243
//DeleteDesignButton (DeleteDesignButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class DeleteDesignButton extends Button {
public function DeleteDesignButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.DELETE_DESIGN;
toolTip = "Delete this contraption";
buttonWidth = 30;
buttonHeight = 30;
}
}
}//package
Section 244
//DeleteLevelButton (DeleteLevelButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class DeleteLevelButton extends Button {
public function DeleteLevelButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.DELETE_LEVEL;
toolTip = "Delete this level";
buttonWidth = 30;
buttonHeight = 30;
}
}
}//package
Section 245
//DeleteMousePointer (DeleteMousePointer)
package {
import flash.display.*;
public dynamic class DeleteMousePointer extends MovieClip {
}
}//package
Section 246
//DoPublishButton (DoPublishButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class DoPublishButton extends Button {
public function DoPublishButton(){
addFrameScript(0, frame1);
}
function frame1(){
buttonWidth = 30;
buttonHeight = 30;
}
}
}//package
Section 247
//DragActingMousePointer (DragActingMousePointer)
package {
import flash.display.*;
public dynamic class DragActingMousePointer extends MovieClip {
}
}//package
Section 248
//DragMousePointer (DragMousePointer)
package {
import flash.display.*;
public dynamic class DragMousePointer extends MovieClip {
}
}//package
Section 249
//DynamicCircleButton (DynamicCircleButton)
package {
import contraption.menu.*;
public dynamic class DynamicCircleButton extends DashboardButton {
}
}//package
Section 250
//DynamicSquareButton (DynamicSquareButton)
package {
import contraption.menu.*;
public dynamic class DynamicSquareButton extends DashboardButton {
}
}//package
Section 251
//EditLevelButton (EditLevelButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class EditLevelButton extends Button {
public function EditLevelButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.EDIT_LEVEL;
toolTip = "Edit this level";
buttonWidth = 30;
buttonHeight = 30;
}
}
}//package
Section 252
//Expander (Expander)
package {
import flash.events.*;
import flash.display.*;
public dynamic class Expander extends MovieClip {
public var expandButton:SimpleButton;
public var dash:MovieClip;
public function Expander(){
addFrameScript(0, frame1, 1, frame2, 12, frame13, 13, frame14);
}
function frame14(){
stop();
}
function frame1(){
expandButton.addEventListener(MouseEvent.CLICK, expandButtonClick);
}
function frame13(){
gotoAndStop("contracted");
}
public function expandButtonClick(_arg1:MouseEvent){
if (currentLabel == "contracted"){
gotoAndPlay("expanding");
} else {
if (currentLabel == "expanded"){
gotoAndPlay("contracting");
};
};
}
function frame2(){
stop();
}
}
}//package
Section 253
//FullVersionButton (FullVersionButton)
package {
import flash.display.*;
public dynamic class FullVersionButton extends SimpleButton {
}
}//package
Section 254
//GoalCircleButton (GoalCircleButton)
package {
import contraption.menu.*;
public dynamic class GoalCircleButton extends DashboardButton {
}
}//package
Section 255
//GoalSquareButton (GoalSquareButton)
package {
import contraption.menu.*;
public dynamic class GoalSquareButton extends DashboardButton {
}
}//package
Section 256
//GoButton (GoButton)
package {
import contraption.menu.*;
public dynamic class GoButton extends DashboardButton {
}
}//package
Section 257
//GraphicsOffButton (GraphicsOffButton)
package {
import flash.display.*;
public dynamic class GraphicsOffButton extends SimpleButton {
}
}//package
Section 258
//GraphicsOnButton (GraphicsOnButton)
package {
import flash.display.*;
public dynamic class GraphicsOnButton extends SimpleButton {
}
}//package
Section 259
//HollowRod (HollowRod)
package {
import flash.display.*;
public dynamic class HollowRod extends MovieClip {
public var one:MovieClip;
}
}//package
Section 260
//HollowRodButton (HollowRodButton)
package {
import contraption.menu.*;
public dynamic class HollowRodButton extends DashboardButton {
}
}//package
Section 261
//HollowRodGraphic (HollowRodGraphic)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
import adobe.utils.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class HollowRodGraphic extends MovieClip {
public var four:MovieClip;
public var two:MovieClip;
public var one:MovieClip;
public var three:MovieClip;
public function HollowRodGraphic(){
addFrameScript(0, frame1);
}
function frame1(){
one.gotoAndPlay(1);
two.gotoAndPlay(11);
three.gotoAndPlay(21);
four.gotoAndPlay(31);
one.dropBouncing.gotoAndPlay(1);
two.dropBouncing.gotoAndPlay(7);
three.dropBouncing.gotoAndPlay(14);
four.dropBouncing.gotoAndPlay(21);
}
}
}//package
Section 262
//HollowRodGraphicBG (HollowRodGraphicBG)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
import adobe.utils.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class HollowRodGraphicBG extends MovieClip {
public var four:MovieClip;
public var two:MovieClip;
public var one:MovieClip;
public var three:MovieClip;
public function HollowRodGraphicBG(){
addFrameScript(0, frame1);
}
function frame1(){
one.gotoAndPlay(1);
two.gotoAndPlay(11);
three.gotoAndPlay(21);
four.gotoAndPlay(31);
one.dropBouncing.gotoAndPlay(1);
two.dropBouncing.gotoAndPlay(7);
three.dropBouncing.gotoAndPlay(14);
four.dropBouncing.gotoAndPlay(21);
}
}
}//package
Section 263
//LearnToPlayButton (LearnToPlayButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class LearnToPlayButton extends Button {
public function LearnToPlayButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_TUTORIALS;
buttonWidth = 218;
buttonHeight = 46;
}
}
}//package
Section 264
//LeftArrow (LeftArrow)
package {
import contraption.menu.*;
public dynamic class LeftArrow extends NoTabButton {
}
}//package
Section 265
//Level4Overlay (Level4Overlay)
package {
import flash.display.*;
public dynamic class Level4Overlay extends MovieClip {
}
}//package
Section 266
//LevelCircle (LevelCircle)
package {
import contraption.menu.*;
public dynamic class LevelCircle extends NoTabButton {
}
}//package
Section 267
//LevelCircleChecked (LevelCircleChecked)
package {
import contraption.menu.*;
public dynamic class LevelCircleChecked extends NoTabButton {
}
}//package
Section 268
//LinkBackButton (LinkBackButton)
package {
import flash.display.*;
public dynamic class LinkBackButton extends SimpleButton {
}
}//package
Section 269
//LinkDesignButton (LinkDesignButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class LinkDesignButton extends Button {
public function LinkDesignButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_DESIGN_LINK_MENU;
toolTip = "Link to this contraption";
buttonWidth = 30;
buttonHeight = 30;
}
}
}//package
Section 270
//LinkedInOverlay (LinkedInOverlay)
package {
import flash.display.*;
public dynamic class LinkedInOverlay extends MovieClip {
}
}//package
Section 271
//LinkLevelButton (LinkLevelButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class LinkLevelButton extends Button {
public function LinkLevelButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_LEVEL_LINK_MENU;
toolTip = "Link to this level";
buttonWidth = 30;
buttonHeight = 30;
}
}
}//package
Section 272
//LogInButton (LogInButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class LogInButton extends Button {
public function LogInButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOG_IN;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 273
//LogOutButton (LogOutButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class LogOutButton extends Button {
public function LogOutButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOG_OUT;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 274
//MainMenuButton (MainMenuButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class MainMenuButton extends Button {
public function MainMenuButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.RETURN_TO_MAIN_MENU;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 275
//MainMenuButtons (MainMenuButtons)
package {
import flash.display.*;
public dynamic class MainMenuButtons extends MovieClip {
}
}//package
Section 276
//MenuBackground (MenuBackground)
package {
import flash.display.*;
public dynamic class MenuBackground extends MovieClip {
}
}//package
Section 277
//MenuTopButtons (MenuTopButtons)
package {
import flash.display.*;
public dynamic class MenuTopButtons extends MovieClip {
}
}//package
Section 278
//ModalMenuCloud (ModalMenuCloud)
package {
import flash.display.*;
public dynamic class ModalMenuCloud extends MovieClip {
}
}//package
Section 279
//MoveButton (MoveButton)
package {
import contraption.menu.*;
public dynamic class MoveButton extends DashboardButton {
}
}//package
Section 280
//MoveMousePointer (MoveMousePointer)
package {
import flash.display.*;
public dynamic class MoveMousePointer extends MovieClip {
}
}//package
Section 281
//NewLevelButton (NewLevelButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class NewLevelButton extends Button {
public function NewLevelButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_EDITOR;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 282
//NewUserButton (NewUserButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class NewUserButton extends Button {
public function NewUserButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.NEW_USER;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 283
//NextLevelButton (NextLevelButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class NextLevelButton extends Button {
public function NextLevelButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_LEVEL;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 284
//NextPageButton (NextPageButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class NextPageButton extends Button {
public function NextPageButton(){
addFrameScript(0, frame1);
}
function frame1(){
buttonWidth = 37;
buttonHeight = 27;
}
}
}//package
Section 285
//NonPoweredWheelButton (NonPoweredWheelButton)
package {
import contraption.menu.*;
public dynamic class NonPoweredWheelButton extends DashboardButton {
}
}//package
Section 286
//NonPoweredWheelGraphic (NonPoweredWheelGraphic)
package {
import flash.display.*;
public dynamic class NonPoweredWheelGraphic extends MovieClip {
}
}//package
Section 287
//PlayDesignSmallButton (PlayDesignSmallButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class PlayDesignSmallButton extends Button {
public function PlayDesignSmallButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_DESIGN;
toolTip = "View this contraption";
buttonWidth = 30;
buttonHeight = 30;
}
}
}//package
Section 288
//PlayGameButton (PlayGameButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class PlayGameButton extends Button {
public function PlayGameButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.MENU_BACK;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 289
//PlayLevelSmallButton (PlayLevelSmallButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class PlayLevelSmallButton extends Button {
public function PlayLevelSmallButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_LEVEL;
toolTip = "Play this level";
buttonWidth = 30;
buttonHeight = 30;
}
}
}//package
Section 290
//PreviousMenuButton (PreviousMenuButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class PreviousMenuButton extends Button {
public function PreviousMenuButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.MENU_BACK;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 291
//PreviousPageButton (PreviousPageButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class PreviousPageButton extends Button {
public function PreviousPageButton(){
addFrameScript(0, frame1);
}
function frame1(){
buttonWidth = 37;
buttonHeight = 27;
}
}
}//package
Section 292
//ResetPasswordButton (ResetPasswordButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class ResetPasswordButton extends Button {
public function ResetPasswordButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.RESET_PASSWORD;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 293
//RightArrow (RightArrow)
package {
import contraption.menu.*;
public dynamic class RightArrow extends NoTabButton {
}
}//package
Section 294
//SaveButton (SaveButton)
package {
import contraption.menu.*;
public dynamic class SaveButton extends DashboardButton {
}
}//package
Section 295
//SavedContraptionsButton (SavedContraptionsButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class SavedContraptionsButton extends Button {
public function SavedContraptionsButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_SAVED_DESIGNS;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 296
//SavedLevelBackground (SavedLevelBackground)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class SavedLevelBackground extends SavedLevelBackgroundBase {
public function SavedLevelBackground(){
addFrameScript(9, frame10, 19, frame20);
}
function frame10(){
stop();
}
function frame20(){
stop();
}
}
}//package
Section 297
//SavedLevelBackgroundMask (SavedLevelBackgroundMask)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class SavedLevelBackgroundMask extends MovieClip {
public function SavedLevelBackgroundMask(){
addFrameScript(9, frame10, 19, frame20);
}
function frame10(){
stop();
}
function frame20(){
stop();
}
}
}//package
Section 298
//SavedLevelsButton (SavedLevelsButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class SavedLevelsButton extends Button {
public function SavedLevelsButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_SAVED_LEVELS;
requiresLogIn = true;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 299
//SkipTutorialButton (SkipTutorialButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import contraption.tutorials.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class SkipTutorialButton extends TutorialButton {
public function SkipTutorialButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = TutorialEvent.SKIP_TUTORIAL;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 300
//SmallBackButton (SmallBackButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class SmallBackButton extends Button {
public function SmallBackButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.MENU_BACK;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 301
//SmallCancelButton (SmallCancelButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class SmallCancelButton extends Button {
public function SmallCancelButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.MENU_BACK;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 302
//SmallSaveButton (SmallSaveButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class SmallSaveButton extends Button {
public function SmallSaveButton(){
addFrameScript(0, frame1);
}
function frame1(){
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 303
//SolidRodButton (SolidRodButton)
package {
import contraption.menu.*;
public dynamic class SolidRodButton extends DashboardButton {
}
}//package
Section 304
//SolidRodGraphic (SolidRodGraphic)
package {
import flash.display.*;
public dynamic class SolidRodGraphic extends MovieClip {
}
}//package
Section 305
//SolidRodGraphicBG (SolidRodGraphicBG)
package {
import flash.display.*;
public dynamic class SolidRodGraphicBG extends MovieClip {
}
}//package
Section 306
//SolutionsButton (SolutionsButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class SolutionsButton extends Button {
public function SolutionsButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_LEVEL_SOLUTIONS;
toolTip = "View published designs people\nhave made for this level";
buttonWidth = 30;
buttonHeight = 30;
}
}
}//package
Section 307
//SoundOffButton (SoundOffButton)
package {
import flash.display.*;
public dynamic class SoundOffButton extends SimpleButton {
}
}//package
Section 308
//SoundOnButton (SoundOnButton)
package {
import flash.display.*;
public dynamic class SoundOnButton extends SimpleButton {
}
}//package
Section 309
//Splash (Splash)
package {
import flash.display.*;
public dynamic class Splash extends MovieClip {
public function Splash(){
addFrameScript(18, frame19, 29, frame30);
}
function frame19(){
stop();
}
function frame30(){
stop();
}
}
}//package
Section 310
//StartHere (StartHere)
package {
import flash.display.*;
public dynamic class StartHere extends MovieClip {
}
}//package
Section 311
//StaticCircleButton (StaticCircleButton)
package {
import contraption.menu.*;
public dynamic class StaticCircleButton extends DashboardButton {
}
}//package
Section 312
//StaticSquareButton (StaticSquareButton)
package {
import contraption.menu.*;
public dynamic class StaticSquareButton extends DashboardButton {
}
}//package
Section 313
//StopButton (StopButton)
package {
import contraption.menu.*;
public dynamic class StopButton extends DashboardButton {
}
}//package
Section 314
//StopButtonPing (StopButtonPing)
package {
import flash.display.*;
public dynamic class StopButtonPing extends MovieClip {
public function StopButtonPing(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package
Section 315
//TestLevelButton (TestLevelButton)
package {
import contraption.menu.*;
public dynamic class TestLevelButton extends DashboardButton {
}
}//package
Section 316
//tut1DrawWater (tut1DrawWater)
package {
import contraption.tutorials.*;
public dynamic class tut1DrawWater extends AddedBlockBetweenWheelsOverlay {
}
}//package
Section 317
//tut1DrawWheel (tut1DrawWheel)
package {
import contraption.tutorials.*;
public dynamic class tut1DrawWheel extends AddedBlockOverlay {
}
}//package
Section 318
//tut1Goal (tut1Goal)
package {
import contraption.tutorials.*;
public dynamic class tut1Goal extends TutorialOverlay {
}
}//package
Section 319
//tut1PinkBall (tut1PinkBall)
package {
import contraption.tutorials.*;
public dynamic class tut1PinkBall extends TutorialOverlay {
}
}//package
Section 320
//tut1PressStart (tut1PressStart)
package {
import contraption.tutorials.*;
public dynamic class tut1PressStart extends PressStartOverlay {
}
}//package
Section 321
//tut1SelectWater (tut1SelectWater)
package {
import contraption.tutorials.*;
public dynamic class tut1SelectWater extends HollowSelectedOverlay {
}
}//package
Section 322
//tut1SelectWheel (tut1SelectWheel)
package {
import contraption.tutorials.*;
public dynamic class tut1SelectWheel extends WheelSelectedOverlay {
}
}//package
Section 323
//tut1Welcome (tut1Welcome)
package {
import contraption.tutorials.*;
public dynamic class tut1Welcome extends TutorialOverlay {
}
}//package
Section 324
//tut1Workshop (tut1Workshop)
package {
import contraption.tutorials.*;
public dynamic class tut1Workshop extends TutorialOverlay {
}
}//package
Section 325
//tut2DeleteFirstRod (tut2DeleteFirstRod)
package {
import contraption.tutorials.*;
public dynamic class tut2DeleteFirstRod extends DeleteBlockOverlay {
}
}//package
Section 326
//tut2DeleteSecondRod (tut2DeleteSecondRod)
package {
import contraption.tutorials.*;
public dynamic class tut2DeleteSecondRod extends DeleteBlockOverlay {
}
}//package
Section 327
//tut2FirstDrawWater (tut2FirstDrawWater)
package {
import contraption.tutorials.*;
public dynamic class tut2FirstDrawWater extends AddedBlockBetweenWheelsOverlay {
}
}//package
Section 328
//tut2FirstSelectDelete (tut2FirstSelectDelete)
package {
import contraption.tutorials.*;
public dynamic class tut2FirstSelectDelete extends DeleteSelectedOverlay {
}
}//package
Section 329
//tut2FirstSelectWater (tut2FirstSelectWater)
package {
import contraption.tutorials.*;
public dynamic class tut2FirstSelectWater extends HollowSelectedOverlay {
}
}//package
Section 330
//tut2FirstStop (tut2FirstStop)
package {
import contraption.tutorials.*;
public dynamic class tut2FirstStop extends PressStopOverlay {
}
}//package
Section 331
//tut2FirstTry (tut2FirstTry)
package {
import contraption.tutorials.*;
public dynamic class tut2FirstTry extends PressStartOverlay {
}
}//package
Section 332
//tut2SecondDrawWater (tut2SecondDrawWater)
package {
import contraption.tutorials.*;
public dynamic class tut2SecondDrawWater extends AddedBlockBetweenWheelsOverlay {
}
}//package
Section 333
//tut2SecondSelectDelete (tut2SecondSelectDelete)
package {
import contraption.tutorials.*;
public dynamic class tut2SecondSelectDelete extends DeleteSelectedOverlay {
}
}//package
Section 334
//tut2SecondSelectWater (tut2SecondSelectWater)
package {
import contraption.tutorials.*;
public dynamic class tut2SecondSelectWater extends HollowSelectedOverlay {
}
}//package
Section 335
//tut2SecondStop (tut2SecondStop)
package {
import contraption.tutorials.*;
public dynamic class tut2SecondStop extends PressStopOverlay {
}
}//package
Section 336
//tut2SecondTry (tut2SecondTry)
package {
import contraption.tutorials.*;
public dynamic class tut2SecondTry extends PressStartOverlay {
}
}//package
Section 337
//tut2ThirdTry (tut2ThirdTry)
package {
import contraption.tutorials.*;
public dynamic class tut2ThirdTry extends PressStartOverlay {
}
}//package
Section 338
//tut2Welcome (tut2Welcome)
package {
import contraption.tutorials.*;
public dynamic class tut2Welcome extends TutorialOverlay {
}
}//package
Section 339
//tut3Back (tut3Back)
package {
import contraption.tutorials.*;
public dynamic class tut3Back extends TutorialOverlay {
}
}//package
Section 340
//tut3Delete (tut3Delete)
package {
import contraption.tutorials.*;
public dynamic class tut3Delete extends TutorialOverlay {
}
}//package
Section 341
//tut3Goodbye (tut3Goodbye)
package {
import contraption.tutorials.*;
public dynamic class tut3Goodbye extends TutorialOverlay {
}
}//package
Section 342
//tut3Move (tut3Move)
package {
import contraption.tutorials.*;
public dynamic class tut3Move extends TutorialOverlay {
}
}//package
Section 343
//tut3NonPowerWheel (tut3NonPowerWheel)
package {
import contraption.tutorials.*;
public dynamic class tut3NonPowerWheel extends TutorialOverlay {
}
}//package
Section 344
//tut3Save (tut3Save)
package {
import contraption.tutorials.*;
public dynamic class tut3Save extends TutorialOverlay {
}
}//package
Section 345
//tut3Start (tut3Start)
package {
import contraption.tutorials.*;
public dynamic class tut3Start extends TutorialOverlay {
}
}//package
Section 346
//tut3Water (tut3Water)
package {
import contraption.tutorials.*;
public dynamic class tut3Water extends TutorialOverlay {
}
}//package
Section 347
//tut3Wheels (tut3Wheels)
package {
import contraption.tutorials.*;
public dynamic class tut3Wheels extends TutorialOverlay {
}
}//package
Section 348
//tut3Wood (tut3Wood)
package {
import contraption.tutorials.*;
public dynamic class tut3Wood extends TutorialOverlay {
}
}//package
Section 349
//tut3Zoom (tut3Zoom)
package {
import contraption.tutorials.*;
public dynamic class tut3Zoom extends TutorialOverlay {
}
}//package
Section 350
//tutLocked (tutLocked)
package {
import contraption.tutorials.*;
public dynamic class tutLocked extends TutorialOverlay {
}
}//package
Section 351
//TutorialNextButton (TutorialNextButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import contraption.tutorials.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class TutorialNextButton extends TutorialButton {
public function TutorialNextButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = TutorialEvent.FINISHED_OVERLAY;
buttonWidth = 56;
buttonHeight = 42;
}
}
}//package
Section 352
//UnPublishButton (UnPublishButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class UnPublishButton extends Button {
public function UnPublishButton(){
addFrameScript(0, frame1);
}
function frame1(){
buttonWidth = 30;
buttonHeight = 30;
}
}
}//package
Section 353
//UpdateUserInfoButton (UpdateUserInfoButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class UpdateUserInfoButton extends Button {
public function UpdateUserInfoButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.UPDATE_USER_INFO;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 354
//UpdateUserInfoSubmitButton (UpdateUserInfoSubmitButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class UpdateUserInfoSubmitButton extends Button {
public function UpdateUserInfoSubmitButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.UPDATE_USER_INFO;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 355
//UserGenLevelsButton (UserGenLevelsButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class UserGenLevelsButton extends Button {
public function UserGenLevelsButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_USER_GENERATED_LEVELS;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 356
//YourSavedContraptionsButton (YourSavedContraptionsButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class YourSavedContraptionsButton extends Button {
public function YourSavedContraptionsButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_SAVED_DESIGNS;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 357
//YourSavedLevelsButton (YourSavedLevelsButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import flash.utils.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.external.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
public dynamic class YourSavedLevelsButton extends Button {
public function YourSavedLevelsButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_SAVED_LEVELS;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 358
//ZoomInButton (ZoomInButton)
package {
import contraption.menu.*;
public dynamic class ZoomInButton extends DashboardButton {
}
}//package
Section 359
//ZoomOutButton (ZoomOutButton)
package {
import contraption.menu.*;
public dynamic class ZoomOutButton extends DashboardButton {
}
}//package