Section 1
//anim_ripple_45 (ArtAssets_fla.anim_ripple_45)
package ArtAssets_fla {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class anim_ripple_45 extends MovieClip {
public function anim_ripple_45(){
addFrameScript(9, frame10);
}
function frame10(){
gotoAndPlay(1);
}
}
}//package ArtAssets_fla
Section 2
//LevelDot_140 (ArtAssets_fla.LevelDot_140)
package ArtAssets_fla {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class LevelDot_140 extends MovieClip {
public function LevelDot_140(){
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package ArtAssets_fla
Section 3
//MapScreenFlashStatic_139 (ArtAssets_fla.MapScreenFlashStatic_139)
package ArtAssets_fla {
import flash.display.*;
public dynamic class MapScreenFlashStatic_139 extends MovieClip {
public var levelDot10:MovieClip;
public var levelDot11:MovieClip;
public var levelDot12:MovieClip;
public var levelDot13:MovieClip;
public var mapObjects:MovieClip;
public var levelDot1:MovieClip;
public var levelDot2:MovieClip;
public var levelDot4:MovieClip;
public var levelDot5:MovieClip;
public var levelDot6:MovieClip;
public var levelDot8:MovieClip;
public var levelDot3:MovieClip;
public var levelDot7:MovieClip;
public var levelDot0:MovieClip;
public var levelDot9:MovieClip;
}
}//package ArtAssets_fla
Section 4
//SolarAnim_31 (ArtAssets_fla.SolarAnim_31)
package ArtAssets_fla {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class SolarAnim_31 extends MovieClip {
public function SolarAnim_31(){
addFrameScript(0, frame1, 3, frame4, 7, frame8, 11, frame12, 15, frame16);
}
function frame12(){
gotoAndPlay(9);
}
function frame16(){
gotoAndPlay(13);
}
function frame1(){
gotoAndPlay(1);
}
function frame4(){
gotoAndPlay(1);
}
function frame8(){
gotoAndPlay(5);
}
}
}//package ArtAssets_fla
Section 5
//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 6
//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 7
//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 8
//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 9
//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 10
//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 11
//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 12
//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 13
//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 14
//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 15
//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 16
//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 17
//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 18
//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 19
//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 20
//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 21
//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 22
//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 23
//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 24
//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 25
//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 26
//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 27
//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 28
//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 29
//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 30
//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 31
//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 32
//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 33
//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 34
//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 35
//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 36
//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 37
//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 38
//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 39
//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 40
//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 41
//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 42
//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 43
//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 44
//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 45
//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 46
//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 47
//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 48
//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 49
//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 50
//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 51
//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 52
//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 53
//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 54
//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 55
//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 56
//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 57
//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 58
//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 59
//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 60
//b2BodyDef (Box2D.Dynamics.b2BodyDef)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
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 61
//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 62
//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 63
//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 64
//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 65
//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.*;
import Box2D.Common.*;
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 66
//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 67
//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 68
//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{
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));
reDrawBlock();
}
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 = 14487825;
innerColour = 0xDDDDDD;
};
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 interpolateColor(c1:uint, c2:uint, ratio:Number):uint{
var r1:Number = ((c1 >> 16) & 0xFF);
var g1:Number = ((c1 >> 8) & 0xFF);
var b1:Number = ((c1 >> 0) & 0xFF);
var r2:Number = ((c2 >> 16) & 0xFF);
var g2:Number = ((c2 >> 8) & 0xFF);
var b2:Number = ((c2 >> 0) & 0xFF);
var rr1:int = ((ratio * (r2 - r1)) + r1);
if (rr1 < 0){
rr1 = 0;
};
if (rr1 > 0xFF){
rr1 = 0xFF;
};
var gg1:int = ((ratio * (g2 - g1)) + g1);
if (gg1 < 0){
gg1 = 0;
};
if (gg1 > 0xFF){
gg1 = 0xFF;
};
var bb1:int = ((ratio * (b2 - b1)) + b1);
if (bb1 < 0){
bb1 = 0;
};
if (bb1 > 0xFF){
bb1 = 0xFF;
};
return ((((rr1 * 65536) + (gg1 * 0x0100)) + bb1));
}
protected function getXmlRoot():XML{
throw (new IllegalOperationError("You must extend EditableBlock and implement \"getXmlRoot\""));
}
public function getBlockBackground():Sprite{
return (blockBackground);
}
protected function getGradientBoxMatrix(ww:Number, hh:Number, rot:Number, tx:Number, ty:Number):Matrix{
var m:Matrix = new Matrix();
m.createGradientBox(100, 100);
m.translate(-50, -50);
m.scale((ww / 100), (hh / 100));
m.rotate(rot);
m.translate(tx, ty);
return (m);
}
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 69
//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);
}
protected function newHollowRod(point1:Point, point2:Point):Rod{
return (new Rod(point1, point2));
}
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 newSolarPanel(point1:Point, point2:Point):Rod{
return (new SolarPanel(point1, point2));
}
protected function newSolidRod(point1:Point, point2:Point):Rod{
return (new SolidRod(point1, point2));
}
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 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 "SolarPanel":
block = createSolarPanel(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 "DynamicSun":
block = createWheel(centerPoint, 1, Wheel.DYNAMIC_SUN, rotation, (width / 2), editing, isGoalBlock, blockXmlNode.joints[0]);
break;
case "JointedDynamicRectangle":
block = new JointedDynamicRectangle(editing, true);
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 createSolarPanel(point1:Point, point2:Point, scale:Number, joints:XML=null, enforceMinWidth:Boolean=false):Rod{
return (createRod(point1, point2, scale, newSolarPanel, 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;
case "PriusShape":
block = new PriusShape(editing);
break;
default:
throw (new ArgumentError("xml contains an unrecognized level block type"));
};
block.setFromXML(blockXmlNode);
return (block);
}
}
}//package contraption.blocks
Section 70
//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 SOLAR_PANEL: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 71
//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 72
//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(15832621);
canvas.graphics.drawCircle(0, 0, (getWidth() - 4));
canvas.graphics.endFill();
backgroundCanvas.graphics.lineStyle(6, 16560470, 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 73
//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(15832621);
if (isGoalBlock){
canvas.graphics.beginFill(7593520);
};
canvas.graphics.drawRect(((-(getWidth()) / 2) + 4), ((-(getHeight()) / 2) + 4), (getWidth() - 8), (getHeight() - 8));
canvas.graphics.endFill();
backgroundCanvas.graphics.lineStyle(6, 16560470, 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 74
//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=false, 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));
setBlockCanvas();
}
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)));
setBlockCanvas();
}
}
}//package contraption.blocks
Section 75
//EditableSun (contraption.blocks.EditableSun)
package contraption.blocks {
import flash.events.*;
import contraption.*;
import flash.display.*;
import flash.geom.*;
public class EditableSun extends EditableBlock {
public function EditableSun(editing:Boolean=false, mov:MovieClip=null, isGoalBlock:Boolean=false, position:Point=null){
if (mov != null){
addChild(mov);
mov.x = 0;
mov.y = 0;
};
super(isGoalBlock);
if (position != null){
setPosition(position);
};
this.editing = editing;
setBlockCanvas();
}
override protected function drawBlock(Canvas:Sprite, backgroundCanvas:Sprite):void{
}
override protected function initAllowableActions():void{
allowableActions = new Actions();
}
override protected function setBlockCanvas():void{
var changedEditing:Boolean;
if (editing){
editing = false;
changedEditing = true;
};
super.setBlockCanvas();
if (changedEditing){
editing = true;
};
if (editing){
rotateCorner = newRotateCorner();
blockForegroundCanvas.addChild(rotateCorner);
rotateCorner.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownO);
rotateCorner.x = (getWidth() / 2);
rotateCorner.y = (-(getHeight()) / 2);
};
}
override protected function getXmlRoot():XML{
return (new XML("<sun>"));
}
public function setGraphic(mov:MovieClip):void{
addChild(mov);
}
}
}//package contraption.blocks
Section 76
//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 77
//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 78
//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 79
//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 80
//PriusShape (contraption.blocks.PriusShape)
package contraption.blocks {
import flash.display.*;
import flash.geom.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import contraption.data.*;
public class PriusShape extends EditableBlock {
protected var customIsBackground:Boolean;
protected var mrotation:Number;
protected var scalex:Number;
protected var scaley:Number;
protected var customImage:MovieClip;
protected var customImageName:String;
public function PriusShape(editing:Boolean=false, position:Point=null){
super(editing, false, position);
generatePhysicsBodyDef();
}
override public function getXml():XML{
var xml:XML = super.getXml();
xml.appendChild((("<customImage>" + customImageName) + "</customImage>"));
xml.appendChild((("<scalex>" + scalex) + "</scalex>"));
xml.appendChild((("<scaley>" + scaley) + "</scaley>"));
return (xml);
}
override protected function getXmlRoot():XML{
return (<PriusShape/>
);
}
public function getMaskBits():int{
return (0);
}
override public function setFromXML(xml:XML):void{
customImageName = new String(xml.customImage);
customImage = BackgroundLinks.getZoneItem(customImageName);
customIsBackground = false;
if (customImageName == "Sun_Vector_Mov"){
customIsBackground = true;
};
if (xml.scalex){
scalex = xml.scalex;
} else {
scalex = 1;
};
if (xml.scaley){
scaley = xml.scaley;
} else {
scaley = 1;
};
super.setFromXML(xml);
}
override protected function drawBlock(canvas:Sprite, backgroundCanvas:Sprite):void{
if (customImageName == null){
return;
};
canvas.graphics.clear();
customImage.scaleX = scalex;
customImage.scaleY = scaley;
customImage.rotation = getRotation();
if (customIsBackground){
backgroundCanvas.addChild(customImage);
} else {
canvas.addChild(customImage);
};
}
override protected function generatePhysicsBodyDef():b2BodyDef{
var body:b2Body;
var bodyDef:b2BodyDef = new b2BodyDef();
var circleDef:b2CircleDef = 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);
}
public function getCategoryBits():int{
return (0);
}
}
}//package contraption.blocks
Section 81
//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)));
var width:Number = Point.distance(point1, point2);
if (width < 1){
width = 1;
};
super.setWidth(width);
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 (3381759);
}
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 rodTile:Sprite;
var width:Number = (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 (8701183);
}
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 82
//SolarPanel (contraption.blocks.SolarPanel)
package contraption.blocks {
import flash.display.*;
import flash.geom.*;
import de.polygonal.ds.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class SolarPanel extends Rod {
protected var moviesList:SLinkedList;
protected var mLength:Number;
protected static var mFrameCount:int = 0;
public function SolarPanel(point1:Point, point2:Point){
var tempSolarGraph:SolarPanelGraphic;
moviesList = new SLinkedList();
super(point1, point2);
mLength = Point.distance(point1, point2);
if (mFrameCount == 0){
tempSolarGraph = new SolarPanelGraphic();
mFrameCount = tempSolarGraph.totalFrames;
};
}
public function setFrame(frameNum:int):void{
var iter:Iterator = moviesList.getIterator();
while (iter.hasNext()) {
iter.data.gotoAndStop(frameNum);
iter.next();
};
}
override protected function getTile():Sprite{
var myImage:SolarPanelGraphic = new SolarPanelGraphic();
moviesList.append(myImage);
return (myImage);
}
public function Compare(spanel:SolarPanel):Boolean{
if (spanel.point1 != this.point1){
return (false);
};
if (spanel.point2 != this.point2){
return (false);
};
if (spanel.mLength != this.mLength){
return (false);
};
return (true);
}
override public function getCategoryBits():int{
return (0x0100);
}
override public function getMaskBits():int{
return (~(16));
}
override protected function getSimpleBackgroundColour():int{
return (16052271);
}
override protected function getXmlRoot():XML{
return (<SolarPanel/>
);
}
public function changeTint(tint:Number):void{
var cTint:ColorTransform = blockForegroundCanvas.transform.colorTransform;
cTint.color = tint;
cTint.blueMultiplier = tint;
cTint.redMultiplier = tint;
cTint.greenMultiplier = tint;
blockForegroundCanvas.transform.colorTransform = cTint;
}
override protected function generatePhysicsBodyDef():b2BodyDef{
var phys:b2BodyDef = super.generatePhysicsBodyDef();
var boxDef:b2BoxDef = (phys.shapes[0] as b2BoxDef);
boxDef.density = 1.5;
return (phys);
}
override protected function getTileBackground():Sprite{
return (new SolarPanelGraphicBG());
}
override protected function getSimpleColour():int{
return (0xFF9900);
}
public function getFrameCount():int{
return (mFrameCount);
}
public function getLength():Number{
return (mLength);
}
override public function getHeight():Number{
return (8);
}
}
}//package contraption.blocks
Section 83
//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 (10079283);
}
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 (8538396);
}
override public function getHeight():Number{
return (8);
}
}
}//package contraption.blocks
Section 84
//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 body:b2Body;
bodyDef = new b2BodyDef();
var circleDef:b2CircleDef = 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{
var arenaWidth:Number = 2000;
var arenaHeight:Number = 1450;
var radius:Number = (getWidth() - 4);
var p1:Point = new Point(0, -(radius));
var p2:Point = new Point(0, radius);
var minY:Number = ((p1.y + (arenaHeight / 2)) + y);
var maxY:Number = ((p2.y + (arenaHeight / 2)) + y);
var ratio1:Number = (minY / arenaHeight);
var ratio2:Number = (maxY / arenaHeight);
var c1:uint = 9829677;
var c2:uint = 340736;
var c1i:uint = interpolateColor(c1, c2, ratio1);
var c2i:uint = interpolateColor(c1, c2, ratio2);
var colors1:Array = [c1i, c2i];
var ratios:Array = [0, 0xFF];
var alphas:Array = [1, 1];
var hh:Number = (maxY - minY);
var matr1:Matrix = getGradientBoxMatrix(hh, hh, (0.5 * Math.PI), 0, 0);
var matr2:Matrix = new Matrix();
matr2.rotate(-(((rotation * Math.PI) / 180)));
matr1.concat(matr2);
canvas.graphics.beginGradientFill(GradientType.LINEAR, colors1, alphas, ratios, matr1, InterpolationMethod.LINEAR_RGB, SpreadMethod.PAD, 0);
canvas.graphics.drawCircle(0, 0, getWidth());
canvas.graphics.endFill();
}
override protected function getXmlRoot():XML{
return (<StaticCircle/>
);
}
override public function getHeight():Number{
return (getWidth());
}
}
}//package contraption.blocks
Section 85
//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 body:b2Body;
var boxDef:b2BoxDef = new b2BoxDef();
var bodyDef:b2BodyDef = 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{
var arenaWidth:Number = 2000;
var arenaHeight:Number = 1450;
var matrp:Matrix = new Matrix();
matrp.rotate((rotation * (Math.PI / 180)));
var p1:Point = new Point(((-(getWidth()) / 2) + 4), ((-(getHeight()) / 2) + 4));
var p2:Point = new Point(((p1.x + getWidth()) - 8), p1.y);
var p3:Point = new Point(((p1.x + getWidth()) - 8), ((p1.y + getHeight()) - 8));
var p4:Point = new Point(p1.x, ((p1.y + getHeight()) - 8));
p1 = matrp.transformPoint(p1);
p2 = matrp.transformPoint(p2);
p3 = matrp.transformPoint(p3);
p4 = matrp.transformPoint(p4);
var ww:Number = (p2.x - p1.x);
var hh:Number = (p2.y - p1.y);
var y1:Number = ((p1.y + (arenaHeight / 2)) + y);
var y2:Number = ((p2.y + (arenaHeight / 2)) + y);
var y3:Number = ((p3.y + (arenaHeight / 2)) + y);
var y4:Number = ((p4.y + (arenaHeight / 2)) + y);
var minY:Number = y1;
if (y2 < minY){
minY = y2;
};
if (y3 < minY){
minY = y3;
};
if (y4 < minY){
minY = y4;
};
var maxY:Number = y1;
if (y2 > maxY){
maxY = y2;
};
if (y3 > maxY){
maxY = y3;
};
if (y4 > maxY){
maxY = y4;
};
var ratio1:Number = (minY / arenaHeight);
var ratio2:Number = (maxY / arenaHeight);
var c1:uint = 9829677;
var c2:uint = 340736;
var c1i:uint = interpolateColor(c1, c2, ratio1);
var c2i:uint = interpolateColor(c1, c2, ratio2);
var colors1:Array = [c1i, c2i];
var alphas:Array = [1, 1];
var ratios:Array = [0, 0xFF];
var hh2:Number = (maxY - minY);
var matr1:Matrix = getGradientBoxMatrix(hh2, hh2, (0.5 * Math.PI), 0, 0);
var matr2:Matrix = new Matrix();
matr2.rotate(-(((rotation * Math.PI) / 180)));
matr1.concat(matr2);
canvas.graphics.beginGradientFill(GradientType.LINEAR, colors1, alphas, ratios, matr1, InterpolationMethod.LINEAR_RGB, SpreadMethod.PAD, 0);
canvas.graphics.drawRect((-(getWidth()) / 2), (-(getHeight()) / 2), getWidth(), getHeight());
canvas.graphics.endFill();
}
override protected function getXmlRoot():XML{
return (<StaticRectangle/>
);
}
}
}//package contraption.blocks
Section 86
//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 87
//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 DYNAMIC_SUN:int = 2;
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))) && (isGoalBlock))){
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/>
);
};
if (spinDirection == DYNAMIC_SUN){
return (<DynamicSun/>
);
};
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 bodyDef:b2BodyDef;
var body:b2Body;
bodyDef = 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 wheelGraphicTemp:Sprite;
var wheelGraphic:Sprite;
var x:Number = getPosition().x;
var y:Number = getPosition().y;
if (isGoalBlock){
if (spinDirection == DYNAMIC_SUN){
wheelGraphicTemp = (new SunGoalObject() as Sprite);
canvas.addChild(wheelGraphicTemp);
} else {
canvas.graphics.beginFill(7461934);
canvas.graphics.drawCircle(0, 0, (getRadius() - 4));
backgroundColour = 7461934;
};
} 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 88
//BackgroundLinks (contraption.data.BackgroundLinks)
package contraption.data {
import flash.display.*;
public class BackgroundLinks {
public function BackgroundLinks(){
super();
}
public static function getShapeObject(str:String):MovieClip{
var data:MovieClip;
switch (str){
case "BG_02_Mov":
data = new BG_02_Mov();
break;
case "sunSprite":
data = new SunGoalObject();
break;
case "newMov":
data = new newMov();
break;
};
return (data);
}
public static function getBitMapDataFromName(str:String, xsize:int, ysize:int):BitmapData{
var data:BitmapData;
switch (str){
};
return (data);
}
public static function getZoneItem(str:String):MovieClip{
var data:MovieClip;
switch (str){
case "Prius_Vector_Mov":
data = new Prius_Vector_Mov();
break;
case "Prius_Hatch_Mov":
data = new Prius_Hatch_Mov();
break;
case "Prius_Hatch_Mov1":
data = new Prius_Hatch_Mov1();
break;
case "Sun_Vector_Mov":
data = new Sun_Vector_Mov();
break;
case "Sun_VectorFG_Mov":
data = new Sun_VectorFG_Mov();
break;
case "newMov":
data = new newMov();
break;
};
return (data);
}
}
}//package contraption.data
Section 89
//OfficialLevelsExp (contraption.data.OfficialLevelsExp)
package contraption.data {
public class OfficialLevelsExp {
public function OfficialLevelsExp(){
super();
}
public static function getOfficialLevels():XML{
return (<officialLevelsExp>
<level1>
<retrieveLevel>
<levelId>91</levelId>
<levelNumber>1</levelNumber>
<name>HARMONY</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>90</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-150</x>
<y>-15.35</y>
</position>
<width>319</width>
<height>38</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-246</x>
<y>-61.15</y>
</position>
<width>320</width>
<height>38</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>286</x>
<y>131.75</y>
</position>
<width>546</width>
<height>142</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-325.5999999999999</x>
<y>-108</y>
</position>
<width>319</width>
<height>38</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-421.35</x>
<y>-156</y>
</position>
<width>319</width>
<height>38</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-59.89999999999999</x>
<y>32</y>
</position>
<width>319</width>
<height>38</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0.1418970546041639</rotation>
<position>
<x>-262.9999999999999</x>
<y>-156</y>
</position>
<width>19</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-579.4000000000001</x>
<y>-156</y>
</position>
<width>19</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-482.8000000000001</x>
<y>-108.05</y>
</position>
<width>19</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-167.29999999999995</x>
<y>-108</y>
</position>
<width>19</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-404.70000000000005</x>
<y>-61.15</y>
</position>
<width>19</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-309.5</x>
<y>-15.35</y>
</position>
<width>19</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-218.00000000000003</x>
<y>32</y>
</position>
<width>19</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>97.9</x>
<y>32</y>
</position>
<width>19</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>7.75</x>
<y>-15.35</y>
</position>
<width>19</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-87.94999999999999</x>
<y>-61.15</y>
</position>
<width>19</width>
<height>19</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>556.9499999999999</x>
<y>131.75</y>
</position>
<width>71</width>
<height>71</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>12.850000000000012</x>
<y>131.7</y>
</position>
<width>71</width>
<height>71</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<DynamicSun id="0">
<rotation>0</rotation>
<position>
<x>-524.1</x>
<y>-249.85</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</DynamicSun>
</playerBlocks>
<start>
<position>
<x>-493</x>
<y>-224.95000000000002</y>
</position>
<width>156.5</width>
<height>109.5</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>498.85</x>
<y>11.75</y>
</position>
<width>100</width>
<height>100</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level1>
<level2>
<retrieveLevel>
<levelId>55</levelId>
<levelNumber>2</levelNumber>
<name>EARTH</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>75</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-197.60000000000016</x>
<y>11.299999999999947</y>
</position>
<width>698</width>
<height>89.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>218.2500000000002</x>
<y>46.54999999999996</y>
</position>
<width>78.2</width>
<height>78.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-538.4500000000002</x>
<y>76</y>
</position>
<width>109.6</width>
<height>109.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>463.9999999999998</x>
<y>-109.14999999999996</y>
</position>
<width>88.7</width>
<height>88.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.12426877318936597</rotation>
<position>
<x>-10.349999999999966</x>
<y>-9.300000000000054</y>
</position>
<width>295.2</width>
<height>78</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.25508136736211384</rotation>
<position>
<x>168.9</x>
<y>-32.85</y>
</position>
<width>337.1</width>
<height>99.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.4369750044206394</rotation>
<position>
<x>288</x>
<y>-80.30000000000001</y>
</position>
<width>354.8</width>
<height>81.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>353.25000000000006</x>
<y>10.00000000000005</y>
</position>
<width>105.5</width>
<height>105.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<JointedDynamicRectangle id="0">
<rotation>0</rotation>
<position>
<x>-387.2999999999999</x>
<y>-173.95</y>
</position>
<width>37.4</width>
<height>34</height>
<goalBlock>true</goalBlock>
<joints/>
</JointedDynamicRectangle>
</playerBlocks>
<start>
<position>
<x>-367.20000000000005</x>
<y>-132.85</y>
</position>
<width>277.7</width>
<height>197.2</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>460.25</x>
<y>-218.75</y>
</position>
<width>135</width>
<height>135</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level2>
<level3>
<retrieveLevel>
<levelId>16</levelId>
<levelNumber>3</levelNumber>
<name>GREEN</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>0.14999999999997726</x>
<y>150.90000000000006</y>
</position>
<width>1178.3</width>
<height>148.70000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.5420166574463934</rotation>
<position>
<x>105.4</x>
<y>38.299999999999976</y>
</position>
<width>440.4</width>
<height>153.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>421.2500000000001</x>
<y>-84.09999999999998</y>
</position>
<width>336.3</width>
<height>113.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>370.69999999999993</x>
<y>37.94999999999995</y>
</position>
<width>437.4</width>
<height>183.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-581.1499999999999</x>
<y>150.8</y>
</position>
<width>74.3</width>
<height>74.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>581.3499999999998</x>
<y>42.25</y>
</position>
<width>183</width>
<height>183</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-352.75</x>
<y>-83.00000000000003</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-447.70000000000005</x>
<y>-19.55</y>
</position>
<width>272.6</width>
<height>205.9</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>463.75</x>
<y>-185.5</y>
</position>
<width>217.4</width>
<height>100</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level3>
<level4>
<retrieveLevel>
<levelId>102</levelId>
<levelNumber>4</levelNumber>
<name>OPTIMISM</name>
<level>
<backGround>
<sprite>
<name>newMov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>90</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>65.79999999999993</x>
<y>100.29999999999995</y>
</position>
<width>1153.3</width>
<height>133.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.06828220593308276</rotation>
<position>
<x>287.5999999999999</x>
<y>-241.40000000000003</y>
</position>
<width>12</width>
<height>106.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.08285998600496836</rotation>
<position>
<x>387.85</x>
<y>-242.80000000000004</y>
</position>
<width>12</width>
<height>105.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>421.75000000000006</x>
<y>-358.25</y>
</position>
<width>22</width>
<height>222.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>506.4</x>
<y>18.099999999999977</y>
</position>
<width>250.6</width>
<height>30.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>482.45</x>
<y>-164.30000000000007</y>
</position>
<width>26.1</width>
<height>366.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.7160430277757371</rotation>
<position>
<x>478.6</x>
<y>-315.1</y>
</position>
<width>160.10000000000002</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>407.7999999999999</x>
<y>-283.35</y>
</position>
<width>39.1</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.4913692097874672</rotation>
<position>
<x>506.05</x>
<y>-263.09999999999997</y>
</position>
<width>44.6</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-505.0000000000002</x>
<y>100.2</y>
</position>
<width>66.7</width>
<height>66.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>641.2</x>
<y>100.2</y>
</position>
<width>66.60000000000001</width>
<height>66.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>108.90000000000003</x>
<y>-55.299999999999955</y>
</position>
<width>24.8</width>
<height>66.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-104.65</x>
<y>-25.449999999999992</y>
</position>
<width>31.6</width>
<height>31.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-142.15000000000003</x>
<y>-14.150000000000029</y>
</position>
<width>29.4</width>
<height>29.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>169.05</x>
<y>-38.799999999999955</y>
</position>
<width>18.3</width>
<height>62.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>110.3</x>
<y>-16.099999999999987</y>
</position>
<width>113.5</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<PriusShape>
<rotation>0</rotation>
<position>
<x>208.04999999999987</x>
<y>-168.25</y>
</position>
<width>0</width>
<height>0</height>
<goalBlock>false</goalBlock>
<joints/>
<customImage>Prius_Hatch_Mov1</customImage>
<scalex>-0.75</scalex>
<scaley>0.75</scaley>
</PriusShape>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-72.35000000000001</x>
<y>-27.35000000000001</y>
</position>
<width>38.3</width>
<height>38.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-39.69999999999999</x>
<y>-33.000000000000014</y>
</position>
<width>45.1</width>
<height>45.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-2.4499999999999833</x>
<y>-37.500000000000036</y>
</position>
<width>54.2</width>
<height>54.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>39.30000000000002</x>
<y>-47.65000000000001</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>70.75</x>
<y>-47.00000000000002</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-151.25000000000003</x>
<y>-7.650000000000012</y>
</position>
<width>24.9</width>
<height>24.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.28823536222305535</rotation>
<position>
<x>298.3500000000001</x>
<y>-98.74999999999996</y>
</position>
<width>237.8</width>
<height>33</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>248.6</x>
<y>-17.350000000000012</y>
</position>
<width>19.3</width>
<height>113</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>370</x>
<y>-35.250000000000014</y>
</position>
<width>24.9</width>
<height>176.60000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>1.5861316766444964</rotation>
<position>
<x>162.45000000000002</x>
<y>-137.3</y>
</position>
<width>10</width>
<height>35</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.6804349991877989</rotation>
<position>
<x>122.25000000000003</x>
<y>-116.99999999999996</y>
</position>
<width>4</width>
<height>60</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-364.75</x>
<y>-103.45</y>
</position>
<width>26.3</width>
<height>26.3</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-330.70000000000005</x>
<y>-58.800000000000004</y>
</position>
<width>234.8</width>
<height>180.10000000000002</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>338</x>
<y>-241.65</y>
</position>
<width>100</width>
<height>100</height>
<customImage>null</customImage>
<scalex>0.75</scalex>
<scaley>0.75</scaley>
<rotation>0</rotation>
</end>
</level>
</retrieveLevel>
</level4>
<level5>
<retrieveLevel>
<levelId>31</levelId>
<levelNumber>5</levelNumber>
<name>EVOLUTION</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0.33488143316902663</rotation>
<position>
<x>18.249999999999957</x>
<y>134.3499999999999</y>
</position>
<width>474.9</width>
<height>152</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-345.25</x>
<y>83.80000000000001</y>
</position>
<width>328.70000000000005</width>
<height>198</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>136.04999999999995</x>
<y>-103.7</y>
</position>
<width>35.4</width>
<height>28.3</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>192.70000000000005</x>
<y>-75.74999999999993</y>
</position>
<width>38.8</width>
<height>31.9</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0.4369924089493992</rotation>
<position>
<x>170.45</x>
<y>34.65</y>
</position>
<width>54.3</width>
<height>41</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0.5602932504392916</rotation>
<position>
<x>126.35000000000008</x>
<y>-19.099999999999987</y>
</position>
<width>43.6</width>
<height>56.3</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0.8887324886193426</rotation>
<position>
<x>165.75</x>
<y>-216.40000000000003</y>
</position>
<width>31.3</width>
<height>34.5</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>33.9500000000001</x>
<y>210.85</y>
</position>
<width>1086.4</width>
<height>156.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>573.9499999999998</x>
<y>211.04999999999995</y>
</position>
<width>78.9</width>
<height>78.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-498.3999999999999</x>
<y>136.30000000000004</y>
</position>
<width>151.70000000000002</width>
<height>151.70000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>702.5500000000001</x>
<y>-202.55000000000004</y>
</position>
<width>99</width>
<height>99</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.5497379035234652</rotation>
<position>
<x>834.45</x>
<y>-278.25</y>
</position>
<width>117</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>854.5500000000001</x>
<y>-198.7500000000001</y>
</position>
<width>117</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.637991639743888</rotation>
<position>
<x>829.0500000000002</x>
<y>-117.95000000000005</y>
</position>
<width>117</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.9636715344506644</rotation>
<position>
<x>619.7</x>
<y>-73.59999999999997</y>
</position>
<width>117</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.5272048377643993</rotation>
<position>
<x>570.8000000000001</x>
<y>-280.6</y>
</position>
<width>117</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.9594016395057576</rotation>
<position>
<x>619.65</x>
<y>-331.2</y>
</position>
<width>117</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.006895189462393203</rotation>
<position>
<x>549.4499999999999</x>
<y>-203.85</y>
</position>
<width>117</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>1.5732786065086366</rotation>
<position>
<x>701.65</x>
<y>-50.400000000000055</y>
</position>
<width>117</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>1.0561477911921564</rotation>
<position>
<x>778.3999999999997</x>
<y>-71.10000000000001</y>
</position>
<width>117</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.967699779170501</rotation>
<position>
<x>790.8500000000001</x>
<y>-325.95</y>
</position>
<width>117</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.48377759751704513</rotation>
<position>
<x>567.5999999999999</x>
<y>-129.59999999999997</y>
</position>
<width>117</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>1.5683352881348112</rotation>
<position>
<x>705.15</x>
<y>-355.3</y>
</position>
<width>117</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-424.4</x>
<y>-195.1</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-363.65000000000003</x>
<y>-129</y>
</position>
<width>317.40000000000003</width>
<height>234.3</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>449.45000000000005</x>
<y>70.35000000000001</y>
</position>
<width>154.9</width>
<height>128.5</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level5>
<level6>
<retrieveLevel>
<levelId>89</levelId>
<levelNumber>6</levelNumber>
<name>STAR</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-261.25</x>
<y>94.04999999999995</y>
</position>
<width>195.4</width>
<height>126</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>169.95</x>
<y>112.15</y>
</position>
<width>321.5</width>
<height>54</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>15.199999999999978</x>
<y>39.99999999999999</y>
</position>
<width>12</width>
<height>128</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-167.15000000000006</x>
<y>93.90000000000002</y>
</position>
<width>63</width>
<height>63</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-355.1</x>
<y>93.84999999999997</y>
</position>
<width>63</width>
<height>63</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0.24410377271141823</rotation>
<position>
<x>328.95</x>
<y>112</y>
</position>
<width>27</width>
<height>27</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-366.55</x>
<y>-289.05</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-366.55</x>
<y>-292.1</y>
</position>
<width>12.3</width>
<height>169.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-370.15</x>
<y>-292.15</y>
</position>
<width>191</width>
<height>12.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.7777331260951306</rotation>
<position>
<x>-365.50000000000006</x>
<y>-287.5</y>
</position>
<width>174.3</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.7106613675950615</rotation>
<position>
<x>-365.55000000000007</x>
<y>-293.6</y>
</position>
<width>173</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>125.05000000000004</x>
<y>68.5</y>
</position>
<width>84</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>85.35</x>
<y>44.05</y>
</position>
<width>12</width>
<height>49.900000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>164.7</x>
<y>46.3</y>
</position>
<width>12</width>
<height>53.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>58.150000000000006</x>
<y>42.35</y>
</position>
<width>30.6</width>
<height>30.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>170.4</x>
<y>41.70000000000001</y>
</position>
<width>26.1</width>
<height>26.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>212.35</x>
<y>54.8</y>
</position>
<width>24.9</width>
<height>24.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>238.45</x>
<y>57.65</y>
</position>
<width>18.1</width>
<height>18.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>159.05</x>
<y>24.2</y>
</position>
<width>14.7</width>
<height>14.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<PriusShape>
<rotation>0</rotation>
<position>
<x>246.15</x>
<y>-8.500000000000057</y>
</position>
<width>0</width>
<height>0</height>
<goalBlock>false</goalBlock>
<joints/>
<customImage>Sun_VectorFG_Mov</customImage>
<scalex>-0.5</scalex>
<scaley>0.5</scaley>
</PriusShape>
<PriusShape>
<rotation>0</rotation>
<position>
<x>258</x>
<y>75</y>
</position>
<width>0</width>
<height>0</height>
<goalBlock>false</goalBlock>
<joints/>
<customImage>Sun_Vector_Mov</customImage>
<scalex>-1</scalex>
<scaley>1</scaley>
</PriusShape>
<StaticRectangle>
<rotation>-0.7444853336220081</rotation>
<position>
<x>71.35</x>
<y>-26.4</y>
</position>
<width>6</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-1.041962115560767</rotation>
<position>
<x>80.44999999999999</x>
<y>-20.1</y>
</position>
<width>6</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-1.3406613776896656</rotation>
<position>
<x>93.2</x>
<y>-15.499999999999996</y>
</position>
<width>6</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-1.4843074268765224</rotation>
<position>
<x>105.45</x>
<y>-13.750000000000004</y>
</position>
<width>6</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-1.5823565054503064</rotation>
<position>
<x>114</x>
<y>-13.249999999999996</y>
</position>
<width>6</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.3718225606611545</rotation>
<position>
<x>134.45</x>
<y>-17.799999999999997</y>
</position>
<width>6</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.9477203927141036</rotation>
<position>
<x>143.5</x>
<y>-21.9</y>
</position>
<width>6</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.7910160818224033</rotation>
<position>
<x>152.15</x>
<y>-27.799999999999997</y>
</position>
<width>6</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.6644953990947571</rotation>
<position>
<x>159</x>
<y>-34.1</y>
</position>
<width>6</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.4993467216801299</rotation>
<position>
<x>161.2</x>
<y>-36.8</y>
</position>
<width>6</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<DynamicSun id="0">
<rotation>0</rotation>
<position>
<x>-312.4</x>
<y>-84.05</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</DynamicSun>
</playerBlocks>
<start>
<position>
<x>-260.65</x>
<y>-60.5</y>
</position>
<width>250</width>
<height>250</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>112.5</x>
<y>-75</y>
</position>
<width>70</width>
<height>70</height>
<customImage>null</customImage>
<scalex>-1</scalex>
<scaley>1</scaley>
<rotation>0</rotation>
<isCircle>false</isCircle>
</end>
</level>
</retrieveLevel>
</level6>
<level7>
<retrieveLevel>
<levelId>88</levelId>
<levelNumber>7</levelNumber>
<name>HOPE</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-384.05000000000007</x>
<y>26.1</y>
</position>
<width>396.3</width>
<height>98.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>147.95000000000005</x>
<y>-155.25</y>
</position>
<width>58.6</width>
<height>58.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0.19882233626645576</rotation>
<position>
<x>-441.59999999999997</x>
<y>-255.10000000000002</y>
</position>
<width>272</width>
<height>46.900000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.17759247287701374</rotation>
<position>
<x>-79.99999999999996</x>
<y>45.749999999999986</y>
</position>
<width>234.5</width>
<height>98.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.194730456457347</rotation>
<position>
<x>34.00000000000005</x>
<y>19.450000000000006</y>
</position>
<width>18.7</width>
<height>25.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>443.95</x>
<y>261.55000000000007</y>
</position>
<width>247.20000000000002</width>
<height>148.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-574.6999999999999</x>
<y>-281.55</y>
</position>
<width>23.5</width>
<height>23.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-309.80000000000007</x>
<y>-228.89999999999995</y>
</position>
<width>23.200000000000003</width>
<height>23.200000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-580.5000000000002</x>
<y>26.09999999999999</y>
</position>
<width>49.300000000000004</width>
<height>49.300000000000004</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>35.250000000000014</x>
<y>66.39999999999999</y>
</position>
<width>48.900000000000006</width>
<height>48.900000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>322.75</x>
<y>261.45000000000005</y>
</position>
<width>74.10000000000001</width>
<height>74.10000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>564.5500000000001</x>
<y>261.50000000000006</y>
</position>
<width>74.10000000000001</width>
<height>74.10000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-524.15</x>
<y>-325.45</y>
</position>
<width>37.1</width>
<height>37.1</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-459.35</x>
<y>-102.95</y>
</position>
<width>230.70000000000002</width>
<height>201.8</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>451.15000000000003</x>
<y>140.05</y>
</position>
<width>140</width>
<height>107.10000000000001</height>
<customImage>null</customImage>
<scalex>-0.5</scalex>
<scaley>0.5</scaley>
<rotation>0</rotation>
</end>
</level>
</retrieveLevel>
</level7>
<level8>
<retrieveLevel>
<levelId>86</levelId>
<levelNumber>8</levelNumber>
<name>WIND</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-266.1000000000002</x>
<y>218.4000000000001</y>
</position>
<width>1254.9</width>
<height>86.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-71.05000000000004</x>
<y>178.04999999999998</y>
</position>
<width>862.8000000000001</width>
<height>70.10000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-31.999999999999943</x>
<y>128.55</y>
</position>
<width>784.3000000000001</width>
<height>74.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>19.69999999999999</x>
<y>79</y>
</position>
<width>681.1</width>
<height>78.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>71.34999999999997</x>
<y>28.499999999999982</y>
</position>
<width>577.9</width>
<height>82.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>583.7</x>
<y>123.80000000000008</y>
</position>
<width>168.9</width>
<height>276.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>429.35</x>
<y>166.90000000000003</y>
</position>
<width>156.9</width>
<height>189.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.01680113303128883</rotation>
<position>
<x>-198.85</x>
<y>-275.9</y>
</position>
<width>980.5</width>
<height>94.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-606.5</x>
<y>-399.6</y>
</position>
<width>66</width>
<height>66</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-686.0000000000001</x>
<y>-282.45</y>
</position>
<width>47.400000000000006</width>
<height>47.400000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>289.3</x>
<y>-268.74999999999994</y>
</position>
<width>47.1</width>
<height>47.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-892.5000000000002</x>
<y>218.25</y>
</position>
<width>43.1</width>
<height>43.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<JointedDynamicRectangle id="0">
<rotation>0</rotation>
<position>
<x>-813.8500000000001</x>
<y>-14.600000000000012</y>
</position>
<width>39.400000000000006</width>
<height>39.400000000000006</height>
<goalBlock>true</goalBlock>
<joints/>
</JointedDynamicRectangle>
</playerBlocks>
<start>
<position>
<x>-726.5</x>
<y>59.85</y>
</position>
<width>297.2</width>
<height>235.3</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>430.3</x>
<y>29.700000000000003</y>
</position>
<width>150</width>
<height>85</height>
<customImage>null</customImage>
<scalex>-0.5</scalex>
<scaley>0.5</scaley>
<rotation>0</rotation>
</end>
</level>
</retrieveLevel>
</level8>
<level9>
<retrieveLevel>
<levelId>100</levelId>
<levelNumber>9</levelNumber>
<name>SUN</name>
<level>
<backGround>
<sprite>
<name>newMov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>62.90000000000015</x>
<y>109.19999999999992</y>
</position>
<width>988</width>
<height>88</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>553.5499999999998</x>
<y>109.15000000000003</y>
</position>
<width>44</width>
<height>44</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-346.15</x>
<y>6.000000000000014</y>
</position>
<width>170</width>
<height>216</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-346.04999999999995</x>
<y>-96.85</y>
</position>
<width>85</width>
<height>85</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.027075800032494657</rotation>
<position>
<x>111.35</x>
<y>25.4</y>
</position>
<width>12</width>
<height>48.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>215.35</x>
<y>44.4</y>
</position>
<width>196.2</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>181.60000000000005</x>
<y>-5.700000000000012</y>
</position>
<width>75.1</width>
<height>19.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>221.05</x>
<y>18.05</y>
</position>
<width>30.700000000000003</width>
<height>30.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>254.85</x>
<y>26.100000000000005</y>
</position>
<width>23.4</width>
<height>23.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>292.15</x>
<y>31.900000000000013</y>
</position>
<width>20.5</width>
<height>20.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>316.3</x>
<y>37.05</y>
</position>
<width>13.2</width>
<height>13.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<PriusShape>
<rotation>0</rotation>
<position>
<x>83.89999999999995</x>
<y>-69</y>
</position>
<width>0</width>
<height>0</height>
<goalBlock>false</goalBlock>
<joints/>
<customImage>Prius_Hatch_Mov</customImage>
<scalex>0.5</scalex>
<scaley>0.5</scaley>
</PriusShape>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>188.45</x>
<y>23.800000000000004</y>
</position>
<width>20.3</width>
<height>20.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.2843910731490126</rotation>
<position>
<x>119.29999999999995</x>
<y>-49.400000000000006</y>
</position>
<width>19.5</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.6652291304752567</rotation>
<position>
<x>138.4</x>
<y>-37.25</y>
</position>
<width>4</width>
<height>44.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-285.4000000000002</x>
<y>-189.9000000000001</y>
</position>
<width>15</width>
<height>15</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
<NoSpinWheel id="1">
<rotation>0</rotation>
<position>
<x>-337.84999999999997</x>
<y>-467.8</y>
</position>
<width>15</width>
<height>15</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
<NoSpinWheel id="2">
<rotation>0</rotation>
<position>
<x>-320.8499999999999</x>
<y>-278.7</y>
</position>
<width>15</width>
<height>15</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-109.6</x>
<y>-3.35</y>
</position>
<width>314.40000000000003</width>
<height>144.9</height>
<customImage>null</customImage>
<scalex>0</scalex>
<scaley>0</scaley>
<rotation>0</rotation>
</start>
<end>
<position>
<x>143.15</x>
<y>18.75</y>
</position>
<width>60</width>
<height>50</height>
<customImage>null</customImage>
<scalex>0</scalex>
<scaley>0</scaley>
<rotation>0</rotation>
</end>
</level>
</retrieveLevel>
</level9>
<level10>
<retrieveLevel>
<levelId>17</levelId>
<levelNumber>10</levelNumber>
<name>FREEDOM</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>90</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>-0.4027479907392192</rotation>
<position>
<x>95.09999999999992</x>
<y>131.65000000000006</y>
</position>
<width>584.3000000000001</width>
<height>78</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-423.0500000000002</x>
<y>249.2</y>
</position>
<width>469.7000000000001</width>
<height>78</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>608.3000000000001</x>
<y>5.349999999999991</y>
</position>
<width>372.3</width>
<height>78</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-260.8</x>
<y>41.300000000000004</y>
</position>
<width>39</width>
<height>39</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0.22995285897262552</rotation>
<position>
<x>271.95000000000016</x>
<y>-185.50000000000003</y>
</position>
<width>39</width>
<height>39</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-659.25</x>
<y>248.95000000000007</y>
</position>
<width>39</width>
<height>39</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>295.85</x>
<y>-52.74999999999999</y>
</position>
<width>29.7</width>
<height>29.7</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>172.54999999999998</x>
<y>0.350000000000005</y>
</position>
<width>36.3</width>
<height>36.3</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>36.450000000000024</x>
<y>53.55</y>
</position>
<width>29.7</width>
<height>29.7</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-114.5</x>
<y>113.05</y>
</position>
<width>26.4</width>
<height>26.4</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticRectangle>
<rotation>-0.4026785087045665</rotation>
<position>
<x>8.499999999999943</x>
<y>-73.45000000000002</y>
</position>
<width>582.6</width>
<height>78</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>792.1500000000001</x>
<y>5.649999999999983</y>
</position>
<width>39</width>
<height>39</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-180.25000000000003</x>
<y>259.55</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-547.6</x>
<y>98.05</y>
</position>
<width>23.4</width>
<height>23.4</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-516</x>
<y>136.70000000000002</y>
</position>
<width>261.2</width>
<height>166.70000000000002</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>693.5</x>
<y>-112.5</y>
</position>
<width>200</width>
<height>200</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level10>
<level11>
<retrieveLevel>
<levelId>62</levelId>
<levelNumber>11</levelNumber>
<name>ENERGY</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>62.750000000000114</x>
<y>301.8499999999999</y>
</position>
<width>1342.8000000000002</width>
<height>66.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.805782783508977</rotation>
<position>
<x>594.0999999999999</x>
<y>41.8</y>
</position>
<width>190.4</width>
<height>202.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>93.45</x>
<y>155.90000000000003</y>
</position>
<width>52.7</width>
<height>52.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>120.79999999999995</x>
<y>240.6</y>
</position>
<width>31.6</width>
<height>157.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>129.45</x>
<y>99.29999999999995</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-98.15000000000002</x>
<y>153.44999999999996</y>
</position>
<width>42</width>
<height>42</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-216.15</x>
<y>169.99999999999994</y>
</position>
<width>38.8</width>
<height>38.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>159.34999999999994</x>
<y>162.55</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-100.15000000000003</x>
<y>263.2</y>
</position>
<width>21</width>
<height>112.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.005460362593653345</rotation>
<position>
<x>594.8</x>
<y>154.89999999999992</y>
</position>
<width>278.1</width>
<height>230.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-69.10000000000002</x>
<y>188.8</y>
</position>
<width>36.1</width>
<height>36.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-128.59999999999997</x>
<y>187.3</y>
</position>
<width>36</width>
<height>36</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-195.7500000000001</x>
<y>199.25</y>
</position>
<width>38.900000000000006</width>
<height>38.900000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-246.10000000000005</x>
<y>200.40000000000003</y>
</position>
<width>36.3</width>
<height>36.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>722.4499999999999</x>
<y>42.55000000000001</y>
</position>
<width>23.9</width>
<height>144.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-331.95</x>
<y>214.55</y>
</position>
<width>25.9</width>
<height>25.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-314.6</x>
<y>250.00000000000003</y>
</position>
<width>17.5</width>
<height>63.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-221.95</x>
<y>264.35</y>
</position>
<width>14</width>
<height>101.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>3.650000000000052</x>
<y>134.35000000000002</y>
</position>
<width>42.1</width>
<height>42.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-291.90000000000003</x>
<y>211.55</y>
</position>
<width>26.700000000000003</width>
<height>26.700000000000003</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-0.4999999999999965</x>
<y>243.70000000000005</y>
</position>
<width>33.800000000000004</width>
<height>154.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-32.44999999999995</x>
<y>173.3</y>
</position>
<width>43</width>
<height>43</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>37.85000000000001</x>
<y>175.8</y>
</position>
<width>42</width>
<height>42</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-313.15</x>
<y>181.25</y>
</position>
<width>21</width>
<height>21</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-607.0499999999998</x>
<y>301.8999999999999</y>
</position>
<width>33.300000000000004</width>
<height>33.300000000000004</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-524.65</x>
<y>121.15</y>
</position>
<width>20.5</width>
<height>20.5</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-459.25</x>
<y>173.60000000000002</y>
</position>
<width>220.9</width>
<height>189.4</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>334.8</x>
<y>215.65</y>
</position>
<width>238.4</width>
<height>115.7</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level11>
<level12>
<retrieveLevel>
<levelId>19</levelId>
<levelNumber>12</levelNumber>
<name>PERFORMANCE</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0.00022410315265511405</rotation>
<position>
<x>-256.6</x>
<y>148.35</y>
</position>
<width>735.8000000000001</width>
<height>160</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>1.7566163480476296</rotation>
<position>
<x>501</x>
<y>-351.95000000000005</y>
</position>
<width>20.200000000000003</width>
<height>494.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-139.49999999999997</x>
<y>72.85000000000002</y>
</position>
<width>33.5</width>
<height>33.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-244.49999999999991</x>
<y>73.15</y>
</position>
<width>33.5</width>
<height>33.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-348.5</x>
<y>74.14999999999996</y>
</position>
<width>33.5</width>
<height>33.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>480.2999999999999</x>
<y>148.40000000000003</y>
</position>
<width>464.1</width>
<height>160</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>336.65</x>
<y>-35.05000000000002</y>
</position>
<width>19.6</width>
<height>195.6</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>441.25</x>
<y>-615.45</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticRectangle>
<rotation>-0.5134817168271435</rotation>
<position>
<x>707.8499999999996</x>
<y>-38.299999999999955</y>
</position>
<width>599.2</width>
<height>53.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>935.75</x>
<y>-279.00000000000006</y>
</position>
<width>83.80000000000001</width>
<height>229</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-622.3</x>
<y>148.20000000000002</y>
</position>
<width>80</width>
<height>80</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>709.7500000000001</x>
<y>148.39999999999995</y>
</position>
<width>80</width>
<height>80</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>20.49999999999997</x>
<y>216.85</y>
</position>
<width>1244.3000000000002</width>
<height>23.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<JointedDynamicRectangle id="0">
<rotation>0</rotation>
<position>
<x>-576.5999999999999</x>
<y>-132.1</y>
</position>
<width>34.6</width>
<height>34.7</height>
<goalBlock>true</goalBlock>
<joints/>
</JointedDynamicRectangle>
</playerBlocks>
<start>
<position>
<x>-521.5</x>
<y>-43.650000000000006</y>
</position>
<width>229.5</width>
<height>255.5</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>181.20000000000002</x>
<y>144.15</y>
</position>
<width>150.3</width>
<height>148.4</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level12>
<level13>
<retrieveLevel>
<levelId>23</levelId>
<levelNumber>13</levelNumber>
<name>INSPIRED</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>38.150000000000006</x>
<y>37.59999999999999</y>
</position>
<width>856</width>
<height>126.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>39.400000000000055</x>
<y>-16.149999999999956</y>
</position>
<width>558</width>
<height>134</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>40.55000000000001</x>
<y>-86.05000000000005</y>
</position>
<width>367.7</width>
<height>114.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>44.14999999999996</x>
<y>-127.49999999999994</y>
</position>
<width>202.9</width>
<height>107.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>47.74999999999997</x>
<y>-175.99999999999997</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>46.200000000000045</x>
<y>119.54999999999998</y>
</position>
<width>1306.1</width>
<height>160</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-605.8500000000003</x>
<y>119.39999999999992</y>
</position>
<width>80</width>
<height>80</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>697.7</x>
<y>119.40000000000003</y>
</position>
<width>80</width>
<height>80</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<JointedDynamicRectangle id="0">
<rotation>0</rotation>
<position>
<x>-552.6499999999999</x>
<y>-75.85000000000001</y>
</position>
<width>56.9</width>
<height>50.5</height>
<goalBlock>true</goalBlock>
<joints/>
</JointedDynamicRectangle>
</playerBlocks>
<start>
<position>
<x>-515.4</x>
<y>-43.550000000000004</y>
</position>
<width>246.6</width>
<height>208.7</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>597.75</x>
<y>-26</y>
</position>
<width>229.2</width>
<height>148.4</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level13>
<level14>
<retrieveLevel>
<levelId>20</levelId>
<levelNumber>14</levelNumber>
<name>Inspiring</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-417.4</x>
<y>347.69999999999993</y>
</position>
<width>785.5</width>
<height>111.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>-533.5500000000001</x>
<y>226.6</y>
</position>
<width>20.8</width>
<height>137.70000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>-408.8</x>
<y>230.45</y>
</position>
<width>20.9</width>
<height>125.2</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>-269.5999999999999</x>
<y>228.3499999999999</y>
</position>
<width>30.4</width>
<height>130.4</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>-155.55</x>
<y>224.2</y>
</position>
<width>26.200000000000003</width>
<height>135.9</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<DynamicRectangle>
<rotation>0</rotation>
<position>
<x>-55.95</x>
<y>222.45</y>
</position>
<width>22.3</width>
<height>150.3</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>555.25</x>
<y>435.90000000000015</y>
</position>
<width>890.8000000000001</width>
<height>321.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.04463512661567572</rotation>
<position>
<x>-435.25</x>
<y>-312.8500000000001</y>
</position>
<width>573.4</width>
<height>27.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.08532938200856</rotation>
<position>
<x>-508.4</x>
<y>-162.65000000000003</y>
</position>
<width>773.1</width>
<height>24.6</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>1.3834574169462674</rotation>
<position>
<x>-226.29999999999995</x>
<y>1.3999999999999773</y>
</position>
<width>23.4</width>
<height>819.9000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.4583568135013427</rotation>
<position>
<x>-817.8000000000001</x>
<y>215.75000000000009</y>
</position>
<width>150.3</width>
<height>350.70000000000005</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-320.9</x>
<y>-396.65</y>
</position>
<width>33.4</width>
<height>33.4</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>509.35</x>
<y>-20.74999999999999</y>
</position>
<width>298.2</width>
<height>172.60000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>398.85</x>
<y>-229.60000000000008</y>
</position>
<width>77.9</width>
<height>506.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.7423478555128651</rotation>
<position>
<x>345.35</x>
<y>421.75000000000006</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.7641009354927443</rotation>
<position>
<x>420.60000000000014</x>
<y>435.75</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.7578569196735316</rotation>
<position>
<x>540.3000000000001</x>
<y>413.40000000000003</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-221.9500000000001</x>
<y>729.8500000000001</y>
</position>
<width>2065.1</width>
<height>339.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.7758355154482058</rotation>
<position>
<x>95.5</x>
<y>557.7</y>
</position>
<width>139.20000000000002</width>
<height>111.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0.802744626560817</rotation>
<position>
<x>714.9500000000002</x>
<y>442.8</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-869.8999999999999</x>
<y>-255.8</y>
</position>
<width>50.1</width>
<height>139.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>155.29999999999998</x>
<y>-133.70000000000002</y>
</position>
<width>44.5</width>
<height>139.1</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>557.6</x>
<y>-193.59999999999997</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>537.6</x>
<y>-194.25</y>
</position>
<width>231.6</width>
<height>211.9</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>-506.20000000000005</x>
<y>461.05</y>
</position>
<width>200</width>
<height>200</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level14>
<level15>
<retrieveLevel>
<levelId>24</levelId>
<levelNumber>15</levelNumber>
<name>Hill Start Assist</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>1.4810190148817353</rotation>
<position>
<x>-471.64999999999986</x>
<y>251.19999999999996</y>
</position>
<width>121.10000000000001</width>
<height>227.20000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.26573685438417566</rotation>
<position>
<x>-245.60000000000002</x>
<y>212.05</y>
</position>
<width>286.6</width>
<height>128.70000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.46161327592690865</rotation>
<position>
<x>-21.449999999999967</x>
<y>125</y>
</position>
<width>323.8</width>
<height>122.80000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.6196979535132054</rotation>
<position>
<x>196.24999999999994</x>
<y>-0.5999999999999659</y>
</position>
<width>319.90000000000003</width>
<height>128.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>-0.03718159184996528</rotation>
<position>
<x>316.25</x>
<y>27.299999999999955</y>
</position>
<width>241.3</width>
<height>125.80000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>346.8999999999999</x>
<y>-45.25000000000001</y>
</position>
<width>111.7</width>
<height>111.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>499</x>
<y>137.49999999999997</y>
</position>
<width>312.6</width>
<height>145.20000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>32.85000000000002</x>
<y>279.7999999999999</y>
</position>
<width>1244.9</width>
<height>161.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>166.75000000000017</x>
<y>168.20000000000005</y>
</position>
<width>390.70000000000005</width>
<height>212.20000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-704.0500000000001</x>
<y>274.3</y>
</position>
<width>133.9</width>
<height>133.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>646.8500000000001</x>
<y>232.35000000000002</y>
</position>
<width>167.4</width>
<height>167.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-466.75000000000006</x>
<y>-244.9</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-533.8</x>
<y>-236.54999999999998</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-505.90000000000003</x>
<y>-314.70000000000005</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-483.55</x>
<y>84.45000000000002</y>
</position>
<width>33.5</width>
<height>33.5</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-477.3</x>
<y>103.25</y>
</position>
<width>200</width>
<height>200</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>535.9</x>
<y>13.950000000000001</y>
</position>
<width>228.9</width>
<height>167.5</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level15>
<level16>
<retrieveLevel>
<levelId>28</levelId>
<levelNumber>16</levelNumber>
<name>Advanced Technology</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>53.85000000000001</x>
<y>44.34999999999999</y>
</position>
<width>856</width>
<height>126.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>59.00000000000003</x>
<y>5.400000000000006</y>
</position>
<width>558</width>
<height>133.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>62.05000000000001</x>
<y>-39.04999999999999</y>
</position>
<width>367.7</width>
<height>114.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>71.54999999999998</x>
<y>-70.65</y>
</position>
<width>202.9</width>
<height>107.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>77.09999999999997</x>
<y>-130.95</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>46.200000000000045</x>
<y>119.54999999999998</y>
</position>
<width>1306.1</width>
<height>164.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-587.45</x>
<y>151.6</y>
</position>
<width>114.3</width>
<height>114.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>688.55</x>
<y>148.5</y>
</position>
<width>107.9</width>
<height>107.9</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-422.34999999999997</x>
<y>202.39999999999998</y>
</position>
<width>82.5</width>
<height>82.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-228.65000000000003</x>
<y>230.94999999999996</y>
</position>
<width>127</width>
<height>127</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>47.44999999999996</x>
<y>237.3499999999999</y>
</position>
<width>177.7</width>
<height>177.7</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>323.65000000000003</x>
<y>237.39999999999998</y>
</position>
<width>133.3</width>
<height>133.3</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>536.25</x>
<y>192.95000000000005</y>
</position>
<width>101.5</width>
<height>101.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<JointedDynamicRectangle id="0">
<rotation>0</rotation>
<position>
<x>-550.6999999999999</x>
<y>-116.94999999999999</y>
</position>
<width>56.9</width>
<height>50.5</height>
<goalBlock>true</goalBlock>
<joints/>
</JointedDynamicRectangle>
</playerBlocks>
<start>
<position>
<x>-486.9</x>
<y>-53.75</y>
</position>
<width>246.6</width>
<height>208.7</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>591.15</x>
<y>-12.6</y>
</position>
<width>233.9</width>
<height>202.3</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level16>
<level17>
<retrieveLevel>
<levelId>69</levelId>
<levelNumber>17</levelNumber>
<name>Overcoming Obstacles</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>-0.313688479589072</rotation>
<position>
<x>9.949999999999989</x>
<y>87.10000000000001</y>
</position>
<width>551</width>
<height>122.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>176.70000000000002</x>
<y>-112.10000000000002</y>
</position>
<width>37.4</width>
<height>37.4</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>222.1</x>
<y>-72</y>
</position>
<width>24.1</width>
<height>24.1</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>128.59999999999997</x>
<y>-202.9</y>
</position>
<width>34.800000000000004</width>
<height>34.800000000000004</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>142.00000000000003</x>
<y>-43.75</y>
</position>
<width>18.7</width>
<height>18.7</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>100.60000000000004</x>
<y>-86.44999999999999</y>
</position>
<width>37.4</width>
<height>37.4</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-245.29999999999998</x>
<y>180.65000000000003</y>
</position>
<width>72.10000000000001</width>
<height>72.10000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>272.8</x>
<y>17.75</y>
</position>
<width>74.8</width>
<height>74.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-620.7</x>
<y>96.5</y>
</position>
<width>40.1</width>
<height>267.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-590</x>
<y>-34.400000000000006</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-588.65</x>
<y>228.75</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>45.300000000000004</x>
<y>192.50000000000006</y>
</position>
<width>165.5</width>
<height>165.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>621</x>
<y>-237.10000000000002</y>
</position>
<width>133.8</width>
<height>133.8</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>751.25</x>
<y>-145.5</y>
</position>
<width>84.5</width>
<height>84.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>672</x>
<y>-32.849999999999994</y>
</position>
<width>105.60000000000001</width>
<height>105.60000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-233.29999999999995</x>
<y>-5</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-183.85000000000002</x>
<y>45.650000000000006</y>
</position>
<width>161</width>
<height>152.3</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>168.3</x>
<y>-94.80000000000001</y>
</position>
<width>171</width>
<height>187</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level17>
<level18>
<retrieveLevel>
<levelId>76</levelId>
<levelNumber>18</levelNumber>
<name>Care Free</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticRectangle>
<rotation>0</rotation>
<position>
<x>-17.399999999999977</x>
<y>390.40000000000003</y>
</position>
<width>1971.5</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-466.59999999999997</x>
<y>233.6</y>
</position>
<width>150.8</width>
<height>150.8</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>-42.14999999999996</x>
<y>-135.04999999999998</y>
</position>
<width>27.900000000000002</width>
<height>27.900000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>122.65000000000003</x>
<y>-182.50000000000003</y>
</position>
<width>33.6</width>
<height>33.6</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<DynamicCircle>
<rotation>0</rotation>
<position>
<x>259.40000000000003</x>
<y>-48.45000000000001</y>
</position>
<width>22.3</width>
<height>22.3</height>
<goalBlock>false</goalBlock>
<joints/>
</DynamicCircle>
<StaticRectangle>
<rotation>-0.12231504338612546</rotation>
<position>
<x>289.30000000000007</x>
<y>355.79999999999995</y>
</position>
<width>564.8000000000001</width>
<height>12</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>619.85</x>
<y>-192.55</y>
</position>
<width>89.2</width>
<height>89.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>399.6500000000001</x>
<y>-298.5</y>
</position>
<width>55.800000000000004</width>
<height>55.800000000000004</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>171</x>
<y>-357.00000000000006</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-559.4000000000001</x>
<y>-117.19999999999999</y>
</position>
<width>111.5</width>
<height>111.5</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-302.9</x>
<y>-273.3</y>
</position>
<width>94.80000000000001</width>
<height>94.80000000000001</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-43.599999999999966</x>
<y>-343.04999999999995</y>
</position>
<width>61.400000000000006</width>
<height>61.400000000000006</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<NoSpinWheel id="0">
<rotation>0</rotation>
<position>
<x>-757.3499999999999</x>
<y>108.55</y>
</position>
<width>40</width>
<height>40</height>
<goalBlock>true</goalBlock>
<joints/>
</NoSpinWheel>
</playerBlocks>
<start>
<position>
<x>-779.1</x>
<y>226.20000000000002</y>
</position>
<width>324</width>
<height>318.40000000000003</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>789</x>
<y>167.25</y>
</position>
<width>250.9</width>
<height>440.5</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level18>
<level19>
<retrieveLevel>
<levelId>60</levelId>
<levelNumber>19</levelNumber>
<name>Natural Harmony</name>
<level>
<backGround>
<sprite>
<name>BG_02_Mov</name>
<xsize>640</xsize>
<ysize>480</ysize>
</sprite>
</backGround>
<sun>
<angle>45</angle>
</sun>
<levelBlocks>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-387.25</x>
<y>156.65</y>
</position>
<width>96.2</width>
<height>96.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>0.5965748838334806</rotation>
<position>
<x>-237</x>
<y>221.15</y>
</position>
<width>321.6</width>
<height>123.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>-4.050000000000004</x>
<y>377.40000000000003</y>
</position>
<width>132.20000000000002</width>
<height>132.20000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticRectangle>
<rotation>-0.5312896669482357</rotation>
<position>
<x>251.95</x>
<y>234.20000000000002</y>
</position>
<width>407.6</width>
<height>129.20000000000002</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticRectangle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>441.7999999999999</x>
<y>156.19999999999996</y>
</position>
<width>93.2</width>
<height>93.2</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
<StaticCircle>
<rotation>0</rotation>
<position>
<x>12.849999999999955</x>
<y>-79.15</y>
</position>
<width>196.4</width>
<height>196.4</height>
<goalBlock>false</goalBlock>
<joints/>
</StaticCircle>
</levelBlocks>
<playerBlocks>
<JointedDynamicRectangle id="0">
<rotation>0</rotation>
<position>
<x>-409.50000000000006</x>
<y>-20.19999999999999</y>
</position>
<width>50</width>
<height>50</height>
<goalBlock>true</goalBlock>
<joints/>
</JointedDynamicRectangle>
</playerBlocks>
<start>
<position>
<x>-386.90000000000003</x>
<y>33.45</y>
</position>
<width>200</width>
<height>200</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</start>
<end>
<position>
<x>428.20000000000005</x>
<y>29.5</y>
</position>
<width>200</width>
<height>200</height>
<customImage>null</customImage>
<scalex>NaN</scalex>
<scaley>NaN</scaley>
<rotation>NaN</rotation>
</end>
</level>
</retrieveLevel>
</level19>
</officialLevelsExp>
);
}
public static function getLeveListXML():XML{
return (<levelList>
<levelCount>20</levelCount>
<level>
<levelName>HARMONY</levelName>
<description>level 3!</description>
<levelId>91</levelId>
<levelNumber>1</levelNumber>
</level>
<level>
<levelName>EARTH</levelName>
<description></description>
<levelId>55</levelId>
<levelNumber>2</levelNumber>
</level>
<level>
<levelName>GREEN</levelName>
<description></description>
<levelId>16</levelId>
<levelNumber>3</levelNumber>
</level>
<level>
<levelName>OPTIMISM</levelName>
<description>j2</description>
<levelId>102</levelId>
<levelNumber>4</levelNumber>
</level>
<level>
<levelName>EVOLUTION</levelName>
<description></description>
<levelId>31</levelId>
<levelNumber>5</levelNumber>
</level>
<level>
<levelName>STAR</levelName>
<description>medium</description>
<levelId>89</levelId>
<levelNumber>6</levelNumber>
</level>
<level>
<levelName>HOPE</levelName>
<description>easyish</description>
<levelId>88</levelId>
<levelNumber>7</levelNumber>
</level>
<level>
<levelName>WIND</levelName>
<description>6ish</description>
<levelId>86</levelId>
<levelNumber>8</levelNumber>
</level>
<level>
<levelName>SUN</levelName>
<description></description>
<levelId>100</levelId>
<levelNumber>9</levelNumber>
</level>
<level>
<levelName>FREEDOM</levelName>
<description></description>
<levelId>17</levelId>
<levelNumber>10</levelNumber>
</level>
<level>
<levelName>ENERGY</levelName>
<description></description>
<levelId>62</levelId>
<levelNumber>11</levelNumber>
</level>
<level>
<levelName>PERFORMANCE</levelName>
<description></description>
<levelId>19</levelId>
<levelNumber>12</levelNumber>
</level>
<level>
<levelName>INSPIRED</levelName>
<description></description>
<levelId>23</levelId>
<levelNumber>13</levelNumber>
</level>
<level>
<levelName>Inspiring</levelName>
<description></description>
<levelId>20</levelId>
<levelNumber>14</levelNumber>
</level>
<level>
<levelName>Hill Start Assist</levelName>
<description></description>
<levelId>24</levelId>
<levelNumber>15</levelNumber>
</level>
<level>
<levelName>Advanced Technology</levelName>
<description></description>
<levelId>28</levelId>
<levelNumber>16</levelNumber>
</level>
<level>
<levelName>Overcoming Obstacles</levelName>
<description></description>
<levelId>69</levelId>
<levelNumber>17</levelNumber>
</level>
<level>
<levelName>Care Free</levelName>
<description></description>
<levelId>76</levelId>
<levelNumber>18</levelNumber>
</level>
<level>
<levelName>Natural Harmony</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>
<level>
<levelName>Pit & Pendulum</levelName>
<description></description>
<levelId>868</levelId>
<levelNumber>22</levelNumber>
</level>
<level>
<levelName>Chimichangas</levelName>
<description></description>
<levelId>80432</levelId>
<levelNumber>23</levelNumber>
</level>
<level>
<levelName>Ack and Forth</levelName>
<description></description>
<levelId>61704</levelId>
<levelNumber>24</levelNumber>
</level>
<level>
<levelName>Tote 'em Pole</levelName>
<description></description>
<levelId>55555</levelId>
<levelNumber>25</levelNumber>
</level>
<level>
<levelName>Canyon</levelName>
<description></description>
<levelId>81679</levelId>
<levelNumber>26</levelNumber>
</level>
<level>
<levelName>Default</levelName>
<description></description>
<levelId>74376</levelId>
<levelNumber>27</levelNumber>
</level>
<level>
<levelName>Brick Layer</levelName>
<description></description>
<levelId>5109</levelId>
<levelNumber>28</levelNumber>
</level>
<level>
<levelName>Stuck</levelName>
<description></description>
<levelId>72627</levelId>
<levelNumber>29</levelNumber>
</level>
<level>
<levelName>Crown Jewels</levelName>
<description></description>
<levelId>75888</levelId>
<levelNumber>30</levelNumber>
</level>
<level>
<levelName>Projected</levelName>
<description></description>
<levelId>55555</levelId>
<levelNumber>31</levelNumber>
</level>
<level>
<levelName>Be a Champ</levelName>
<description></description>
<levelId>72743</levelId>
<levelNumber>32</levelNumber>
</level>
<level>
<levelName>Sunset</levelName>
<description></description>
<levelId>74274</levelId>
<levelNumber>33</levelNumber>
</level>
<level>
<levelName>Displacement</levelName>
<description></description>
<levelId>79565</levelId>
<levelNumber>34</levelNumber>
</level>
<level>
<levelName>Gate Keeper</levelName>
<description></description>
<levelId>180614</levelId>
<levelNumber>35</levelNumber>
</level>
<level>
<levelName>Fix Big Ben</levelName>
<description></description>
<levelId>44106</levelId>
<levelNumber>36</levelNumber>
</level>
<level>
<levelName>Close the Door</levelName>
<description></description>
<levelId>10130</levelId>
<levelNumber>37</levelNumber>
</level>
<level>
<levelName>Skyscaper</levelName>
<description></description>
<levelId>82409</levelId>
<levelNumber>38</levelNumber>
</level>
<level>
<levelName>On the Edge</levelName>
<description></description>
<levelId>3024</levelId>
<levelNumber>39</levelNumber>
</level>
<level>
<levelName>Sisyphea</levelName>
<description></description>
<levelId>21</levelId>
<levelNumber>40</levelNumber>
</level>
<level>
<levelName>Under Over</levelName>
<description></description>
<levelId>30</levelId>
<levelNumber>41</levelNumber>
</level>
<level>
<levelName>More Balls</levelName>
<description></description>
<levelId>71621</levelId>
<levelNumber>42</levelNumber>
</level>
</levelList>
);
}
}
}//package contraption.data
Section 90
//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>
<sun>
<angle>45</angle>
</sun>
<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>
<sun>
<angle>45</angle>
</sun>
<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>
<SolarPanel 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>
</SolarPanel>
<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>
<sun>
<angle>45</angle>
</sun>
<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 91
//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.MOUSE_OVER, mouseOver);
addEventListener(MouseEvent.MOUSE_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 92
//CompletedLevelMenu (contraption.menu.CompletedLevelMenu)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.net.*;
import contraption.data.*;
public class CompletedLevelMenu extends ModalMenu {
protected var bIsLastLevel:Boolean;// = false
protected var bUseMapScreen:Boolean;// = false
protected var mapScreen:MapScreen;// = null
protected var levelNumber:int;
protected var levelId:int;
public function CompletedLevelMenu(levelNumber:int, levelId:int, efficiency:Number):void{
var textGoodString:String;
var textString:String;
var data:Object;
var userCookie:SharedObject;
var levels:XML;
var i:int;
var level:XML;
var solvedLevel:Boolean;
var nextLevel:Button;
trace(("CompletedLevelMenu " + levelNumber));
bUseMapScreen = false;
bIsLastLevel = false;
if (levelNumber == 13){
bIsLastLevel = true;
};
super("", false);
if (bIsLastLevel){
addWinBackground("");
addDefaultBackground("");
} else {
if (bUseMapScreen){
mapScreen = new MapScreen();
addChild(mapScreen);
data = {};
data.startingLevel = (levelNumber + 0);
data.targetLevel = (levelNumber + 1);
data.completedLevels = new Array();
data.completedLevels.push(0);
userCookie = SharedObject.getLocal("user");
levels = OfficialLevelsExp.getLeveListXML();
i = 0;
while (i < 13) {
level = levels.level[i];
solvedLevel = (userCookie.data[("level" + level.levelId)] == "true");
if (solvedLevel){
data.completedLevels.push((i + 1));
};
i++;
};
mapScreen.init(data);
mapScreen.moveSpeed = 2;
} else {
addDefaultBackground("");
};
};
this.levelNumber = levelNumber;
this.levelId = levelId;
if (levelId != 0){
if (((User.getInstance().isRegistered()) && ((levelNumber <= 18)))){
if (((!((levelNumber == 0))) && (!(bIsLastLevel)))){
nextLevel = new NextLevelButton();
nextLevel.x = 235;
nextLevel.y = 284;
addChild(nextLevel);
nextLevel.addEventListener(MenuEvent.LOAD_LEVEL, loadLevel);
};
};
};
if (efficiency > 80){
textGoodString = "Excellent Job!";
textString = ((((("Energy Efficiency: " + String((int((efficiency * 100)) / 100))) + "%\n") + "Congratulations!\n") + "You've finished the level,\n") + "with excellent energy efficiency!\n");
} else {
if (efficiency > 20){
textGoodString = "Good Job!";
textString = ((((("Energy Efficiency: " + String((int((efficiency * 100)) / 100))) + "%\n") + "Congratulations!\n") + "You've finished the level,\n") + "with good energy efficiency!\n");
} else {
textGoodString = "Nice Job!";
textString = ((((("Energy Efficiency: " + String((int((efficiency * 100)) / 100))) + "%\n") + "Congratulations!\n") + "You've finished the level,\n") + "try to be more energy efficient!\n");
};
};
var textGood:TextArea = new TextArea(textGoodString, 28);
textGood.textColor = 5991283;
textGood.x = 120;
textGood.y = 140;
addChild(textGood);
var text:TextArea = new TextArea();
text.embedFonts = true;
text.textColor = 29104;
text.setText(textString);
text.x = 120;
text.y = 180;
addChild(text);
var menuButton:Button = new BackToMenuButton();
menuButton.x = 110;
menuButton.y = 253;
addChild(menuButton);
menuButton.addEventListener(MenuEvent.MENU_BACK, backToMenu);
var saveButton:Button = new SmallSaveButton();
saveButton.x = 235;
saveButton.y = 253;
addChild(saveButton);
saveButton.addEventListener(MouseEvent.MOUSE_DOWN, save);
var priusButton:Button = new PriusLinkButton();
priusButton.x = 460;
priusButton.y = 270;
addChild(priusButton);
priusButton.addEventListener(MouseEvent.MOUSE_DOWN, priusLink);
var cancelButton:Button = new SmallBackButton();
cancelButton.x = 110;
cancelButton.y = 284;
addChild(cancelButton);
}
protected function backToMenu(event:Event):void{
removeMap();
event.stopPropagation();
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK, true, true));
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK, true, true));
}
protected function loadLevel(event:Event):void{
trace(("loadLevel " + levelNumber));
removeMap();
event.stopPropagation();
var levelEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_OFFICIAL_LEVEL, true, true);
levelEvent.levelNumber = (levelNumber + 1);
trace(("loadLevel going to level " + levelNumber));
dispatchEvent(levelEvent);
}
protected function removeMap():void{
if (mapScreen){
removeChild(mapScreen);
mapScreen.purge();
mapScreen = null;
};
}
protected function save(event:Event):void{
dispatchEvent(new SaveEvent(MenuEvent.SAVE_CONTRAPTION, true, true));
}
}
}//package contraption.menu
Section 93
//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 textGood:TextArea;
var text:TextArea;
super("");
this.tutorialNumber = tutorialNumber;
var nextLevel:Button = new ContinueTutorialButton();
nextLevel.x = 230;
nextLevel.y = 270;
addChild(nextLevel);
if (tutorialNumber < 3){
nextLevel.addEventListener(MouseEvent.MOUSE_DOWN, loadTutorial);
textGood = new TextArea("Nice Job!", 28);
textGood.textColor = 5991283;
textGood.x = 120;
textGood.y = 140;
addChild(textGood);
text = new TextArea();
text.textColor = 29104;
text.setText(("You have finished this tutorial level.\n" + "Let's move on to the next one."));
text.x = 120;
text.y = 180;
addChild(text);
} else {
nextLevel.addEventListener(MouseEvent.MOUSE_DOWN, startLevels);
textGood = new TextArea("Nice Job!", 28);
textGood.textColor = 5991283;
textGood.x = 120;
textGood.y = 140;
addChild(textGood);
text = new TextArea();
text.textColor = 29104;
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 = 120;
text.y = 180;
addChild(text);
};
var menuButton:Button = new BackToMenuButton();
menuButton.x = 110;
menuButton.y = 270;
addChild(menuButton);
menuButton.addEventListener(MenuEvent.MENU_BACK, backToMenu);
var priusButton:Button = new PriusLinkButton();
priusButton.x = 460;
priusButton.y = 270;
addChild(priusButton);
priusButton.addEventListener(MouseEvent.MOUSE_DOWN, priusLink);
}
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 94
//Dashboard (contraption.menu.Dashboard)
package contraption.menu {
import flash.events.*;
import flash.display.*;
import contraption.blocks.*;
import flash.text.*;
public class Dashboard extends MovieClip {
public var initSunFunc:Function;
public var tooltip:TextField;
public var viewDesignsButton:DashboardButton;
public var dynamicCircleButton:DashboardButton;
public var zoomOutButton:DashboardButton;
public var dynamicSquareButton:DashboardButton;
public var goalSquareButton:DashboardButton;
public var saveButton:DashboardButton;
protected var mode:String;
public var solarPowerMeter:MovieClip;
public var zoomInButton:DashboardButton;
public var staticCircleButton:DashboardButton;
public var hollowRodButton:DashboardButton;
public var goButton:DashboardButton;
public var deleteButton:DashboardButton;
protected var fatInitFunction:Function;
public var npWheelButton:DashboardButton;
public var sun:MovieClip;
public var stopButton:DashboardButton;
public var solarPanelButton:DashboardButton;
public var ccwWheelButton:DashboardButton;
public var cwWheelButton:DashboardButton;
public var staticSquareButton:DashboardButton;
public var editSun:EditableSun;
public var testLevelButton:DashboardButton;
public var stopButtonPing:MovieClip;
public var moveButton:DashboardButton;
public var goalCircleButton:DashboardButton;
public var solidRodButton:DashboardButton;
public var solarPowerLargeMeter:MovieClip;
protected var hilightedButton: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{
var editable:EditableSun;
zoomInButton.init(DashboardEvent.ZOOM_IN, "Zoom In (Mouse Wheel Up)", this);
zoomOutButton.init(DashboardEvent.ZOOM_OUT, "Zoom Out (Mouse Wheel Down)", 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);
editable = new EditableSun(true, sun);
sun = editable;
addChild(sun);
} 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);
solarPanelButton.init(DashboardEvent.SOLAR_PANEL, "Solar Panel (P) : will feed energy back to the batteries depending on angle to the sun", this);
hilightButton(solidRodButton);
viewDesignsButton.init(DashboardEvent.VIEWDESIGN, "View Other Players Designs", this);
viewDesignsButton.addEventListener(MouseEvent.MOUSE_DOWN, viewDesignPress);
};
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);
if (initSunFunc != null){
initSunFunc();
};
}
public function setMode(mode:String):void{
this.mode = mode;
}
protected function buttonPress(event:MouseEvent):void{
event.stopPropagation();
}
protected function viewDesignPress(event:MouseEvent):void{
var menuEvent:MenuEvent = new MenuEvent(MenuEvent.LOAD_SAVED_DESIGNS, true, true);
menuEvent.cameFromPlayer = true;
dispatchEvent(menuEvent);
}
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;
};
var format:TextFormat = new TextFormat();
format.font = "contraptionFont";
format.size = tooltip.defaultTextFormat.size;
tooltip.embedFonts = true;
tooltip.defaultTextFormat = format;
}
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 95
//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 96
//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 SOLAR_PANEL:String = "solarPanel";
public static const ZOOM_OUT:String = "zoomOut";
public static const STATIC_SQUARE:String = "staticSquare";
public static const ZOOM_IN:String = "zoomIn";
public static const SAVE:String = "save";
public static const HOLLOW_ROD:String = "hollowRod";
public static const MOVE:String = "move";
public static const GOAL_SQUARE:String = "goalSquare";
public static const VIEWDESIGN:String = "viewDesign";
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 WIN_LEVEL:String = "WIN_LEVEL";
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 97
//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(((Contraption.SERVER_LOCATION + "/?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 98
//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 99
//LinkButton (contraption.menu.LinkButton)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.text.*;
public class LinkButton extends TextField implements ActionContainer {
public 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="contraptionFont", neverUnderline:Boolean=false, useBackground:Boolean=false, alignment:String="left"):void{
super();
this.text = text;
textColor = 0xFF;
this.embedFonts = true;
if (useBackground){
this.background = true;
this.backgroundColor = 0xFFFFFF;
this.border = true;
this.borderColor = 0;
this.alpha = 0.75;
};
format = new TextFormat();
format.font = font;
format.bold = true;
format.size = textSize;
format.align = alignment;
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 100
//LinkedIntoBadLevelMenu (contraption.menu.LinkedIntoBadLevelMenu)
package contraption.menu {
import flash.display.*;
public class LinkedIntoBadLevelMenu extends ModalMenu {
protected var canvas:Sprite;
public function LinkedIntoBadLevelMenu():void{
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);
}
}
}//package contraption.menu
Section 101
//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 102
//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 103
//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(){
super();
loggedInPanel = new Sprite();
addChild(loggedInPanel);
loggedOutPanel = new Sprite();
addChild(loggedOutPanel);
var button: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 104
//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 105
//MainMenu (contraption.menu.MainMenu)
package contraption.menu {
import flash.events.*;
import contraption.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
import contraption.data.*;
public class MainMenu extends MenuWindow {
protected var namesCanvas:MovieClip;
protected var menuRoadClip:MenuRoad;
protected var menuBackgroundClip:MenuBackground;
protected var loginPanel:LoginPanel;
protected var regButton:SimpleButton;
protected var levelsCanvas:Sprite;
protected var mapScreen:MapScreen;// = null
protected var menuMapClip:MenuMap;
protected var viewingSolutions:Boolean;// = false
protected static var lastCompletedLevelID:int = 0;
protected static var currentLevel:int = 0;
protected static var lastCompletedLevel:int = 0;
public function MainMenu():void{
loginPanel = new LoginPanel();
super(false);
menuBackgroundClip = new MenuBackground();
addChild(menuBackgroundClip);
var mainMenu:MainMenuButtons = new MainMenuButtons();
addChild(mainMenu);
addEventListener(MenuEvent.LOGGED_OUT, setLoginPanel, false, 0, true);
addEventListener(MenuEvent.LOG_OUT, logOut, false, 0, true);
setRegButton();
levelsCanvas = new Sprite();
addChild(levelsCanvas);
namesCanvas = new MovieClip();
addChild(namesCanvas);
listLevels();
}
protected function loadEditor(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.LOAD_EDITOR));
}
protected function renderButtons(levels:XML):void{
var level:XML;
var solvedLevel:Boolean;
var efficiency:Number;
var levelName:OfficialLevelName;
var levelButton:Button;
var p:Point;
removeChild(levelsCanvas);
removeChild(namesCanvas);
levelsCanvas = new Sprite();
addChild(levelsCanvas);
namesCanvas = new MovieClip();
addChild(namesCanvas);
var userCookie:SharedObject = SharedObject.getLocal("user");
var curMaxLevel = 13;
var highestLevel:int;
var prevSolved:Boolean;
var data:Object = {};
data.completedLevels = new Array();
var bTutSolved = (userCookie.data["level14"] == "true");
var tutLevelName:OfficialLevelName = new OfficialLevelName("TUTORIALS", bTutSolved, -1);
tutLevelName.setDownEvent(MenuEvent.LOAD_TUTORIALS);
namesCanvas.addChild(tutLevelName);
var tutorialButton:OfficialLevelButton = new OfficialLevelButton(0, 0, "", bTutSolved, tutLevelName);
tutorialButton.setDownEvent(MenuEvent.LOAD_TUTORIALS);
var tp:Point = getMapButtonXY(0);
tutorialButton.x = tp.x;
tutorialButton.y = tp.y;
tutLevelName.x = tp.x;
tutLevelName.y = tp.y;
levelsCanvas.addChild(tutorialButton);
if (!bTutSolved){
tutorialButton.makeVisible(true);
} else {
prevSolved = true;
highestLevel = 1;
data.completedLevels.push(0);
};
lastCompletedLevel = -1;
var levelNum:int;
while ((((levelNum < curMaxLevel)) && ((levelNum < levels.levelCount)))) {
level = levels.level[levelNum];
solvedLevel = (userCookie.data[("level" + level.levelId)] == "true");
efficiency = (userCookie.data[("efficiency" + level.levelId)] as Number);
if (lastCompletedLevelID == level.levelId){
lastCompletedLevel = (levelNum + 1);
};
prevSolved = solvedLevel;
highestLevel = (levelNum + 1);
levelName = new OfficialLevelName(level.levelName, solvedLevel, efficiency);
namesCanvas.addChild(levelName);
levelButton = new OfficialLevelButton(level.levelId, level.levelNumber, level.levelName, solvedLevel, levelName);
levelsCanvas.addChild(levelButton);
p = getMapButtonXY((levelNum + 1));
levelButton.x = p.x;
levelButton.y = p.y;
levelName.x = p.x;
levelName.y = p.y;
if (solvedLevel){
data.completedLevels.push((levelNum + 1));
};
levelNum++;
};
data.startingLevel = currentLevel;
data.targetLevel = currentLevel;
if (lastCompletedLevel >= 0){
currentLevel = lastCompletedLevel;
data.targetLevel = lastCompletedLevel;
lastCompletedLevelID = 0;
};
if (data.startingLevel > 13){
data.startingLevel = 13;
};
if (data.targetLevel > 13){
data.targetLevel = 13;
};
mapScreen.init(data);
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 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 registerMenu(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.BUY_GAME));
}
protected function logOut(event:Event):void{
User.getInstance().logOut();
dispatchEvent(new MenuEvent(MenuEvent.LOGGED_OUT, true, true));
}
protected function setLoginPanel(event:Event):void{
loginPanel.refresh();
}
protected function listLevels():void{
if (mapScreen){
menuBackgroundClip.removeChild(mapScreen);
mapScreen = null;
};
mapScreen = new MapScreen();
menuBackgroundClip.addChild(mapScreen);
renderButtons(OfficialLevelsExp.getLeveListXML());
}
protected function getMapButtonXY(iButton:int):Point{
var p:Point = new Point(0, 0);
var name:String = ("levelDot" + iButton);
var refbtn:DisplayObject = mapScreen.getChildByName(name);
if (refbtn){
p.x = (refbtn.x - 18);
p.y = refbtn.y;
return (p);
};
switch (iButton){
case 0:
default:
p.x = 50;
p.y = 30;
break;
case 1:
p.x = 50;
p.y = 50;
break;
case 2:
p.x = 50;
p.y = 70;
break;
case 3:
p.x = 50;
p.y = 90;
break;
case 4:
p.x = 50;
p.y = 110;
break;
case 5:
p.x = 50;
p.y = 130;
break;
case 6:
p.x = 50;
p.y = 150;
break;
case 7:
p.x = 50;
p.y = 170;
break;
case 8:
p.x = 50;
p.y = 190;
break;
case 9:
p.x = 50;
p.y = 210;
break;
case 10:
p.x = 250;
p.y = 30;
break;
case 11:
p.x = 250;
p.y = 50;
break;
case 12:
p.x = 250;
p.y = 70;
break;
case 13:
p.x = 250;
p.y = 90;
break;
case 14:
p.x = 250;
p.y = 110;
break;
case 15:
p.x = 250;
p.y = 130;
break;
case 16:
p.x = 250;
p.y = 150;
break;
case 17:
p.x = 250;
p.y = 170;
break;
case 18:
p.x = 250;
p.y = 190;
break;
case 19:
p.x = 250;
p.y = 210;
break;
};
return (p);
}
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);
}
public function linkToSite(event:Event):void{
var request:URLRequest = new URLRequest(Contraption.SERVER_LOCATION);
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);
}
public static function SetLastCompletedLevelID(iLevelID:int):void{
lastCompletedLevelID = iLevelID;
}
}
}//package contraption.menu
Section 106
//MenuEvent (contraption.menu.MenuEvent)
package contraption.menu {
import flash.events.*;
public class MenuEvent extends Event {
public var designId:int;
public var cameFromPlayer:Boolean;// = false
public var userId:int;
public var tutorialNumber:int;
public var efficiency:Number;
public var levelNumber:int;
public var userName:String;
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 LOAD_ALL_SAVED_DESIGNS:String = "loadAllSavedDesigns";
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 LOAD_TUTORIAL_LEVEL:String = "loadTutorialLevel";
public static const TRY_LEVEL:String = "tryLevel";
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_TESTLEVEL:String = "loadTestlevel";
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;
e.efficiency = efficiency;
return (e);
}
}
}//package contraption.menu
Section 107
//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 108
//ModalMenu (contraption.menu.ModalMenu)
package contraption.menu {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public class ModalMenu extends MenuWindow {
public function ModalMenu(title:String, defaultBackground:Boolean=true){
super(false);
graphics.beginFill(0xFFFFFF, 0);
graphics.drawRect(0, 0, 700, 500);
if (defaultBackground){
addDefaultBackground(title);
};
addEventListener(MouseEvent.MOUSE_DOWN, stopEvent);
}
protected function stopEvent(event:Event):void{
event.stopPropagation();
}
public function addWinBackground(title:String):void{
var text:TextArea;
var backgroundClip:MovieClip = new WinScreen();
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);
}
public function addDefaultBackground(title:String):void{
var backgroundClip:MovieClip = new popupWinScreen();
backgroundClip.x = 350;
backgroundClip.y = 250;
addChild(backgroundClip);
var text:TextArea = new TextArea(title, 30, "contraptionFont", "center");
text.embedFonts = true;
text.bold();
text.width = 200;
text.x = 215;
text.y = 130;
addChild(text);
}
protected function priusLink(event:Event):void{
navigateToURL(new URLRequest("http://www.toyota.com/vehicles/minisite/newprius/"), "Toyota Prius");
event.stopPropagation();
}
}
}//package contraption.menu
Section 109
//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 110
//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 111
//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{
super("New User");
validationError = new TextArea("");
validationError.x = 275;
validationError.y = 170;
validationError.textColor = 16720418;
validationError.width = 250;
validationError.height = 50;
addChild(validationError);
var text:TextArea = 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);
var newUserButton:Button = 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 112
//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 113
//OfficialLevelButton (contraption.menu.OfficialLevelButton)
package contraption.menu {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class OfficialLevelButton extends Button {
protected var origCircleUpState:DisplayObject;
protected var nameLink:LinkButton;
protected var circle:SimpleButton;
protected var levelName:String;
protected var nameSprite:OfficialLevelName;
public var bAlwaysOn:Boolean;// = false
public function OfficialLevelButton(levelId:int, levelNumber:int, levelName:String, solved:Boolean, nameSprite:OfficialLevelName){
buttonWidth = 22;
buttonHeight = 10;
this.levelId = levelId;
this.levelNumber = levelNumber;
this.levelName = levelName;
this.downEvent = MenuEvent.LOAD_OFFICIAL_LEVEL;
this.nameSprite = nameSprite;
if (solved){
circle = new LevelCircleChecked();
} else {
circle = new LevelCircle();
};
circle.x = 20;
circle.y = 0;
origCircleUpState = circle.upState;
addChild(circle);
var levelNumberString:String = "";
var numberText:TextArea = new TextArea(levelNumberString, 14, "contraptionFont", TextFormatAlign.CENTER);
numberText.embedFonts = true;
numberText.width = 30;
numberText.x = 5;
numberText.y = -10;
numberText.mouseEnabled = false;
addChild(numberText);
mouseEnabled = false;
super();
}
public function makeVisible(bAlwaysOn:Boolean=false):void{
this.bAlwaysOn = bAlwaysOn;
circle.upState = circle.overState;
if (nameSprite){
if (!nameSprite.nameLink.enabled){
nameSprite.nameLink.enable();
nameSprite.nameLink.visible = true;
nameSprite.nameLink.textColor = 0xDDDDDD;
nameSprite.backgroundSprite.visible = true;
};
};
}
override protected function mouseOut(event:MouseEvent):void{
circle.upState = origCircleUpState;
event.stopPropagation();
if (((nameSprite) && (!(bAlwaysOn)))){
if (nameSprite.nameLink.enabled){
nameSprite.nameLink.disable();
nameSprite.nameLink.visible = false;
nameSprite.backgroundSprite.visible = false;
};
};
}
override protected function mouseOver(event:MouseEvent):void{
circle.upState = circle.overState;
event.stopPropagation();
if (((nameSprite) && (!(bAlwaysOn)))){
if (!nameSprite.nameLink.enabled){
nameSprite.nameLink.enable();
nameSprite.nameLink.visible = true;
nameSprite.nameLink.textColor = 0xFFFFFF;
nameSprite.backgroundSprite.visible = true;
};
};
}
}
}//package contraption.menu
Section 114
//OfficialLevelName (contraption.menu.OfficialLevelName)
package contraption.menu {
import flash.events.*;
import flash.display.*;
public class OfficialLevelName extends MovieClip {
protected var mLevelEfficiency:String;
public var nameLink:LinkButton;
protected var levelName:String;
public var backgroundSprite:Sprite;
protected var downEvent:String;
public function OfficialLevelName(levelName:String, solved:Boolean, levelEficiency:Number=0){
this.levelName = levelName;
if (((solved) && ((levelEficiency >= 0)))){
if (levelEficiency == 0){
mLevelEfficiency = "0.0";
} else {
this.mLevelEfficiency = String((int((levelEficiency * 100)) / 100));
};
nameLink = new LinkButton(((levelName + "\nEfficiency : ") + this.mLevelEfficiency), 14, "contraptionFont", true, false, "center");
} else {
nameLink = new LinkButton(levelName, 14, "contraptionFont", true);
};
var offset:Number = 0;
if (nameLink.textHeight < 20){
offset = 17;
};
nameLink.textColor = 0xFFFFFF;
nameLink.x = ((-(nameLink.width) / 2) + 18);
nameLink.y = (-76 + offset);
nameLink.visible = false;
nameLink.disable();
nameLink.mouseEnabled = true;
backgroundSprite = new Sprite();
addChild(backgroundSprite);
backgroundSprite.graphics.beginFill(6675685, 1);
var arrow:ArrowMap = new ArrowMap();
arrow.x = (nameLink.x + (nameLink.width / 2));
arrow.y = -28;
arrow.scaleX = 0.35;
arrow.scaleY = 0.35;
backgroundSprite.addChild(arrow);
var widthMin:Number = 100;
if (widthMin < nameLink.textWidth){
widthMin = nameLink.textWidth;
};
backgroundSprite.graphics.drawRoundRect(((-(widthMin) / 2) + 4), (nameLink.y - 3), (widthMin + 30), (nameLink.textHeight + 10), 9, 9);
backgroundSprite.graphics.endFill();
backgroundSprite.visible = false;
addChild(nameLink);
graphics.beginFill(0, 0);
graphics.drawRect(0, 0, 1, 1);
super();
addEventListener(MouseEvent.MOUSE_DOWN, buttonPress);
}
protected function buttonPress(event:MouseEvent):void{
var menuEvent:MenuEvent;
if (downEvent != null){
menuEvent = new MenuEvent(downEvent, true, true);
dispatchEvent(menuEvent);
};
}
public function setDownEvent(event:String):void{
downEvent = event;
}
}
}//package contraption.menu
Section 115
//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((Contraption.SERVER_LOCATION + "/saveDesign.php"));
var variables:URLVariables = new URLVariables();
variables.xml = levelSave;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
}
}//package contraption.menu
Section 116
//SaveEvent (contraption.menu.SaveEvent)
package contraption.menu {
import flash.events.*;
public class SaveEvent extends Event {
public var levelIDString:String;// = null
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;
e.levelIDString = levelIDString;
return (e);
}
}
}//package contraption.menu
Section 117
//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((Contraption.SERVER_LOCATION + "/saveLevel.php"));
var variables:URLVariables = new URLVariables();
variables.xml = levelSave;
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
}
}
}//package contraption.menu
Section 118
//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 119
//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 120
//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 121
//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="contraptionFont", 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;
this.embedFonts = true;
}
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 122
//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.embedFonts = true;
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 = "contraptionFont";
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 123
//TickCounter (contraption.menu.TickCounter)
package contraption.menu {
import flash.text.*;
public class TickCounter extends TextField {
protected var paused:Boolean;// = false
protected var count:int;
public function TickCounter(){
super();
count = 0;
text = (count + "");
}
public function reset():void{
paused = false;
count = 0;
text = (count + "");
}
public function pause():void{
paused = true;
}
public function increment():void{
if (!paused){
count++;
};
text = (count + "");
}
}
}//package contraption.menu
Section 124
//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 125
//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 126
//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 127
//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 128
//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, "contraptionFont", 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 129
//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 130
//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 131
//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 132
//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 133
//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 134
//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 135
//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 136
//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 137
//SolarSelectedOverlay (contraption.tutorials.SolarSelectedOverlay)
package contraption.tutorials {
import contraption.*;
public class SolarSelectedOverlay extends TutorialOverlay {
public function SolarSelectedOverlay(){
super();
}
override public function init(player:Player):void{
player.addEventListener(TutorialEvent.SELECTED_SOLAR, overlayFinished, false, 0, true);
}
override public function dispose(player:Player):void{
player.removeEventListener(TutorialEvent.SELECTED_SOLAR, overlayFinished);
}
}
}//package contraption.tutorials
Section 138
//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_SOLAR:String = "selectedSolar";
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 139
//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 tut1EnergyBar());
overlays.append(new tut1Workshop());
overlays.append(new tut1SelectWheel());
overlays.append(new tut1DrawWheel());
overlays.append(new tut1SelectSolar());
overlays.append(new tut1SolarDir());
overlays.append(new tut1DrawWater());
overlays.append(new tut1PressStart());
overlays.append(new tutLocked());
super();
}
}
}//package contraption.tutorials
Section 140
//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 141
//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 tut3Solar());
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 142
//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 143
//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 144
//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 solarPanelMode(e:Event=null):void{
super.solarPanelMode(e);
dispatchEvent(new TutorialEvent(TutorialEvent.SELECTED_SOLAR, 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 public 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{
flagTutorialComplete();
loadNextLevel();
}
}
}//package contraption.tutorials
Section 145
//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 146
//ActionContainer (contraption.ActionContainer)
package contraption {
public interface ActionContainer {
function getAllowableActions():Actions;
function setAllowableActions(C:\Tor\Prius\FantasticContraption\src;contraption;ActionContainer.as:Actions):void;
}
}//package contraption
Section 147
//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 148
//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 149
//Arena (contraption.Arena)
package contraption {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import contraption.blocks.*;
import flash.geom.*;
import de.polygonal.ds.*;
import Box2D.Dynamics.*;
import flash.net.*;
import flash.text.*;
import contraption.data.*;
import flash.ui.*;
import flash.errors.*;
public class Arena extends MenuWindow {
protected var saveButton:Button;
protected var levelIdCustom:String;// = null
protected var loader:Loader;
protected var endZone:EndZone;
protected var permissionToPlayLevel:Boolean;// = true
protected var startZone:StartZone;
protected var targetScale:Number;// = 1
public var arenaCanvas:Sprite;
protected var parentContraption:Contraption;
protected var scaleVelocity:Number;// = 0
protected var arenaBackgroundCanvas:Sprite;
protected var movingScreen:Boolean;// = false
protected var arenaBlocks:SLinkedList;
protected var menuButton:Button;
protected var ta:TextField;
protected var goalBlocks:SLinkedList;
protected var physicsWorld:b2World;
protected var dashboard:Dashboard;
protected var editing:Boolean;
protected var screenMoveX:Number;
protected var screenMoveY:Number;
protected var arenaForegroundCanvas:Sprite;
protected var levelId:int;// = 0
protected var arenaBackgroundImage:Sprite;
protected var playerBlocks:BlockCollection;
protected var saveWindow:SaveWindow;
protected var sunAngle:Number;// = 0
protected var levelNumber:int;// = 0
protected var xmlWindow:XmlWindow;
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();
arenaBackgroundImage = new Sprite();
xmlWindow = new XmlWindow();
super(false);
graphics.beginFill(0xFFFFFF, 0);
graphics.drawRect(0, 0, 700, 500);
this.parentContraption = parentContraption;
this.editing = editing;
addChild(arenaBackgroundImage);
addChild(arenaCanvas);
arenaCanvas.addChild(arenaBackgroundCanvas);
arenaCanvas.addChild(arenaForegroundCanvas);
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((Contraption.SERVER_LOCATION + "/retrieveLevel2.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);
}
public function loadOfficialLevel(levelNumber:int):void{
loadRetrievedLevelFromXML(OfficialLevelsExp.getOfficialLevels()[("level" + levelNumber)].retrieveLevel[0]);
}
override public function disposeMenu():void{
super.disposeMenu();
GlobalListener.getInstance().removeEventListener(KeyboardEvent.KEY_DOWN, keyDown);
}
protected function loadLevelHandler(event:Event):void{
loadRetrievedLevelFromXML(new XML(event.target.data));
}
protected function addTutorialOverlay(levelNumber:int):void{
}
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);
};
};
};
}
public function addTitle(title:String):void{
var text:TextArea = new TextArea(title, 12, "contraptionFont", "right");
text.embedFonts = true;
text.height = 50;
text.width = 450;
text.textColor = 45047;
text.x = 235;
text.y = 470;
var rect:Rectangle = text.getBounds(text);
var sprite:Sprite = new Sprite();
addChild(sprite);
sprite.graphics.beginFill(0xFFFFFF, 0.8);
sprite.graphics.drawRoundRect((((rect.x + rect.width) - text.textWidth) - 12), (rect.y - 4), (text.textWidth + 20), (text.textHeight + 10), 10, 10);
sprite.graphics.endFill();
sprite.x = text.x;
sprite.y = text.y;
addChild(text);
}
protected function onBeginEditing(event:BeginEditingEvent):void{
addChildBlock(event.block);
}
protected function beginMoveScreen(screenMoveX:Number, screenMoveY:Number):void{
movingScreen = true;
this.screenMoveX = screenMoveX;
this.screenMoveY = screenMoveY;
}
public function loadLevel(levelId:int):void{
loadBlocks(levelId, false);
}
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();
};
}
public function getLevelIdentifyer():String{
if (this.levelIdCustom == null){
return (levelId.toString());
};
return (levelIdCustom);
}
public function loadDesign(designId:int):void{
loadBlocks(designId, true);
}
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();
var carBlocks:SLinkedList = new SLinkedList();
startZone.setFromXML(xml.start[0]);
endZone.setFromXML(xml.end[0]);
for each (blockXml in xml.sun.*) {
sunAngle = new Number(blockXml[0]);
};
for each (blockXml in xml.levelBlocks.*) {
block = BlockCollection.createLevelBlockFromXml(blockXml, physicsWorld, editing);
addArenaBlock(block);
if ((block is PriusShape)){
carBlocks.append(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;
};
if (!carBlocks.isEmpty()){
makeCarsOnTop(carBlocks);
};
carBlocks.clear();
addBackground();
}
protected function loadFromxmlWindow(event:MouseEvent):void{
loadFromXml(new XML(xmlWindow.xmlField.text));
}
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());
}
protected function addArenaBlock(block:EditableBlock):void{
addEditableBlock(block);
arenaBlocks.append(block);
}
protected function stopMoveScreen(event:MouseEvent=null):void{
movingScreen = false;
}
protected function zoomIn(event:Event=null):void{
targetScale = (targetScale + 0.1);
limitZoom();
}
public function hasFocus():Boolean{
return (((((((parent) && ((visible == true)))) && (parentContraption.isCurrentMenu(this)))) && (permissionToPlayLevel)));
}
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();
}
public function loadSharedObjectDesign(xmldata:XML):void{
}
public function getLevelXml():XML{
var block:Block;
var blockXml:XML;
var saveXml:XML = <level/>
;
var levelBlocksXml:XML = <levelBlocks/>
;
var playerBlocksXml:XML = <playerBlocks/>
;
var backGroundXml:XML = <backGround/>
;
var sunXml:XML = <sun/>
;
saveXml.appendChild(sunXml);
saveXml.appendChild(levelBlocksXml);
saveXml.appendChild(playerBlocksXml);
saveXml.appendChild(startZone.getXml());
saveXml.appendChild(endZone.getXml());
if ((dashboard.sun is EditableSun)){
sunXml.appendChild((("<angle>" + ((dashboard.sun.getRotation() * 180) / Math.PI)) + "</angle>"));
} else {
sunXml.appendChild((("<angle>" + sunAngle) + "</angle>"));
};
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 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));
};
}
public function loadRetrievedLevelFromXML(retrieveLevel:XML):void{
levelId = retrieveLevel.levelId;
levelNumber = retrieveLevel.levelNumber;
loadFromXml(retrieveLevel.level[0]);
addTitle(retrieveLevel.name);
addTutorialOverlay(levelNumber);
initZoomAndScroll();
}
protected function addEditableBlock(block:EditableBlock):void{
addChildBlock(block);
}
protected function removeChildBlock(block:Block):void{
arenaForegroundCanvas.removeChild(block);
arenaBackgroundCanvas.removeChild(block.getBlockBackground());
}
protected function zoomOut(event:Event=null):void{
targetScale = (targetScale - 0.1);
limitZoom();
}
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);
};
};
};
}
protected function addGoalBlock(block:EditableBlock):void{
addEditableBlock(block);
goalBlocks.append(block);
playerBlocks.append(block);
}
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 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);
}
public function setCustomLevelID(id:String):void{
levelIdCustom = id;
}
public function addBackground():void{
arenaBackgroundImage.addChild(BackgroundLinks.getShapeObject("BG_02_Mov"));
}
protected function mouseWheel(event:MouseEvent):void{
if (!hasFocus()){
return;
};
targetScale = (targetScale + (event.delta / 50));
limitZoom();
event.stopPropagation();
}
protected function hasPermissionToPlay():Boolean{
return (((!((levelNumber == 0))) || (User.getInstance().isRegistered())));
}
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 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);
var distanceX:Number = ((Math.abs((this.startZone.x - this.endZone.x)) + (endZone.width / 2)) + (startZone.width / 2));
var distanceY:Number = ((Math.abs((this.startZone.y - this.endZone.y)) + (endZone.height / 2)) + (startZone.height / 2));
var finalX:Number = ((xDist)>distanceX) ? xDist : distanceX;
var finalY:Number = ((yDist)>distanceY) ? yDist : distanceY;
if (finalX > finalY){
targetScale = (700 / (finalX + 200));
} else {
targetScale = (500 / (finalY + 300));
};
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 makeCarsOnTop(list:SLinkedList):void{
var block:EditableBlock;
var blockIter:Iterator = list.getIterator();
while (blockIter.hasNext()) {
block = blockIter.next();
arenaForegroundCanvas.setChildIndex(block, (arenaForegroundCanvas.numChildren - 1));
};
}
protected function returnToMenu(event:MouseEvent):void{
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK));
}
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);
}
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 mouseDown(event:MouseEvent):void{
if (((!(parent)) || ((visible == false)))){
return;
};
event.stopPropagation();
beginMoveScreen(mouseX, mouseY);
}
public function isInStartZone(point:Point):Boolean{
return (startZone.isInside(arenaCanvas.globalToLocal(parentContraption.localToGlobal(point))));
}
}
}//package contraption
Section 150
//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 151
//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 152
//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 153
//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 154
//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 155
//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 156
//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 {
public function Editor(stage:Stage, parentContraption:Contraption){
super(stage, parentContraption, true);
graphics.beginFill(9225791, 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);
}
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 addDynamicRectangle(event:Event):void{
if (isOverMaxBlocks()){
return;
};
var block:EditableBlock = new DynamicRectangle(true, false, 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 addGoalRectangle(event:Event):void{
if (isOverMaxBlocks()){
return;
};
var block:EditableBlock = new JointedDynamicRectangle(true, true, arenaCanvas.globalToLocal(new Point(200, 200)));
addGoalBlock(block);
}
protected function isOverMaxBlocks():Boolean{
return (false);
}
override protected function newSaveWindow():SaveWindow{
return (new SaveLevelWindow());
}
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 addStaticCircle(event:Event):void{
if (isOverMaxBlocks()){
return;
};
var block:EditableBlock = new StaticCircle(true, arenaCanvas.globalToLocal(new Point(200, 200)));
addArenaBlock(block);
}
}
}//package contraption
Section 157
//EndZone (contraption.EndZone)
package contraption {
import contraption.menu.*;
public class EndZone extends StartZone {
private var text:TextArea;
public function EndZone(editing:Boolean):void{
super(editing);
}
override protected function drawZone():void{
if (!editing){
if (text == null){
text = new TextArea("GOAL", 18, "contraptionFont");
text.textColor = 0xFFFFFF;
addChild(text);
};
text.x = (0 - (text.textWidth / 2));
text.y = (0 - (text.textHeight / 2));
};
super.drawZone();
}
override protected function initAllowableActions():void{
allowableActions = new Actions();
allowableActions.alwaysDrag = true;
}
override protected function getColour():int{
return (3592955);
}
override protected function getXmlRoot():XML{
return (<end/>
);
}
override protected function getBorderColour():int{
return (3592955);
}
}
}//package contraption
Section 158
//GlobalListener (contraption.GlobalListener)
package contraption {
import flash.display.*;
public class GlobalListener {
protected var stage:Stage;
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 init(stage:Stage, uiRoot:DisplayObject):void{
this.stage = stage;
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void{
stage.removeEventListener(type, listener, useCapture);
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{
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 159
//GUID (contraption.GUID)
package contraption {
import flash.display.*;
import flash.system.*;
public class GUID extends Sprite {
private static var counter:Number = 0;
public function GUID(){
super();
}
private static function sha1_kt(t:Number):Number{
return (((t)<20) ? 1518500249 : ((t)<40) ? 1859775393 : ((t)<60) ? -1894007588 : -899497514);
}
private static function binb2hex(binarray:Array):String{
var str:String = new String("");
var tab:String = new String("0123456789abcdef");
var i:Number = 0;
while (i < (binarray.length * 4)) {
str = (str + (tab.charAt(((binarray[(i >> 2)] >> (((3 - (i % 4)) * 8) + 4)) & 15)) + tab.charAt(((binarray[(i >> 2)] >> ((3 - (i % 4)) * 8)) & 15))));
i++;
};
return (str);
}
private static function core_sha1(x:Array, len:Number):Array{
var olda:Number;
var oldb:Number;
var oldc:Number;
var oldd:Number;
var olde:Number;
var j:Number;
var t:Number;
x[(len >> 5)] = (x[(len >> 5)] | (128 << (24 - (len % 32))));
x[((((len + 64) >> 9) << 4) + 15)] = len;
var w:Array = new Array(80);
var a:Number = 1732584193;
var b:Number = -271733879;
var c:Number = -1732584194;
var d:Number = 271733878;
var e:Number = -1009589776;
var i:Number = 0;
while (i < x.length) {
olda = a;
oldb = b;
oldc = c;
oldd = d;
olde = e;
j = 0;
while (j < 80) {
if (j < 16){
w[j] = x[(i + j)];
} else {
w[j] = rol((((w[(j - 3)] ^ w[(j - 8)]) ^ w[(j - 14)]) ^ w[(j - 16)]), 1);
};
t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), safe_add(safe_add(e, w[j]), sha1_kt(j)));
e = d;
d = c;
c = rol(b, 30);
b = a;
a = t;
j++;
};
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
e = safe_add(e, olde);
i = (i + 16);
};
return (new Array(a, b, c, d, e));
}
private static function calculate(src:String):String{
return (hex_sha1(src));
}
private static function sha1_ft(t:Number, b:Number, c:Number, d:Number):Number{
if (t < 20){
return (((b & c) | (~(b) & d)));
};
if (t < 40){
return (((b ^ c) ^ d));
};
if (t < 60){
return ((((b & c) | (b & d)) | (c & d)));
};
return (((b ^ c) ^ d));
}
private static function hex_sha1(src:String):String{
return (binb2hex(core_sha1(str2binb(src), (src.length * 8))));
}
private static function str2binb(str:String):Array{
var bin:Array = new Array();
var mask:Number = ((1 << 8) - 1);
var i:Number = 0;
while (i < (str.length * 8)) {
bin[(i >> 5)] = (bin[(i >> 5)] | ((str.charCodeAt((i / 8)) & mask) << (24 - (i % 32))));
i = (i + 8);
};
return (bin);
}
private static function rol(num:Number, cnt:Number):Number{
return (((num << cnt) | (num >>> (32 - cnt))));
}
public static function create():String{
var dt:Date = new Date();
var id1:Number = dt.getTime();
var id2:Number = (Math.random() * Number.MAX_VALUE);
var id3:String = Capabilities.serverString;
var rawID:String = calculate((((id1 + id3) + id2) + counter++)).toUpperCase();
var finalString:String = ((((((((rawID.substring(0, 8) + "-") + rawID.substring(8, 12)) + "-") + rawID.substring(12, 16)) + "-") + rawID.substring(16, 20)) + "-") + rawID.substring(20, 32));
return (finalString);
}
private static function safe_add(x:Number, y:Number):Number{
var lsw:Number = ((x & 0xFFFF) + (y & 0xFFFF));
var msw:Number = (((x >> 16) + (y >> 16)) + (lsw >> 16));
return (((msw << 16) | (lsw & 0xFFFF)));
}
}
}//package contraption
Section 160
//KongAPI (contraption.KongAPI)
package contraption {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.system.*;
public class KongAPI extends MovieClip {
protected var loadLevelFunc:Function;
protected var loadDesignFunc:Function;
protected var loadedAPI:Boolean;
public var kongregate;
public function KongAPI(theRoot:DisplayObject, loadLevel:Function, loadDesign:Function, params):void{
var api_url:String;
super();
loadLevelFunc = loadLevel;
loadDesignFunc = loadDesign;
var paramObj:Object = params;
LoaderInfo(theRoot.loaderInfo).parameters;
Security.allowDomain(new URLRequest("www.kongshred.com"));
var loaderContext:LoaderContext = new LoaderContext();
loaderContext.checkPolicyFile = true;
if (paramObj != null){
api_url = paramObj.api_path;
loadedAPI = true;
} else {
api_url = "http://www.kongshred.com/flash/API_AS3_Local.swf";
loadedAPI = false;
};
trace(("API path: " + api_url));
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.load(new URLRequest(api_url));
this.addChild(loader);
}
public function browseDesignByLevel(levelName:String):void{
trace(("KONG: Design browsing level(label) (and newest): " + levelName));
kongregate.sharedContent.browse("design", "BY_NEWEST", levelName);
}
public function browseMyDesigns():void{
kongregate.sharedContent.browse("design", "BY_OWN");
}
public function saveLevel(levelData:XML, levelThumb:Sprite):void{
var so:SharedObject = SharedObject.getLocal("priuslevel.xml", "/");
so.data["level"] = levelData;
so.flush();
var label:String = ((kongregate.user.getName() + "_&&_") + GUID.create());
var levelSData:String = levelData.toString();
kongregate.sharedContent.save("level", levelData.toString(), onLevelSaved, levelThumb, label);
}
private function onLevelSaved(params:Object):void{
var name:String;
var permalink:String;
if (!params.success){
trace(params.toString());
} else {
name = params.name;
permalink = params.permalink;
};
}
public function browseMyLevels():void{
kongregate.sharedContent.browse("level", "BY_OWN");
}
public function isMyLevel(label:String):Boolean{
var name:String = label.substr(0, label.indexOf("_&&_"));
return ((kongregate.user.getName() == name));
}
public function submit_finishedLevels():void{
kongregate.stats.submit("finishedlevels", 1);
}
public function submit_efficiencyMaster():void{
kongregate.stats.submit("efficencyMaster", 1);
}
public function loadedRealAPI():Boolean{
return (loadedAPI);
}
public function submit_finishedLevels100():void{
kongregate.stats.submit("finishlevels100", 1);
}
public function browseLevels():void{
kongregate.sharedContent.browse("level");
}
public function browseAllDesign():void{
kongregate.sharedContent.browse("design");
}
public function saveDesign(levelID:String, contraptionData:XML, levelThumb:Sprite=null):void{
trace(("KONG: Saving Design (label): " + levelID.toString()));
kongregate.sharedContent.save("design", contraptionData.toString(), onLevelSaved, levelThumb, levelID);
}
private function loadComplete(event:Event):void{
kongregate = event.target.content;
kongregate.sharedContent.addLoadListener("level", loadLevelFunc);
kongregate.sharedContent.addLoadListener("design", loadDesignFunc);
kongregate.services.connect();
}
}
}//package contraption
Section 161
//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 162
//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 163
//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 164
//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{
super();
if (!allowInstantiation){
throw (new Error("Error: Instantiation failed: Use Music.getInstance() instead of new."));
};
playRegisteredSound = User.getInstance().isRegistered();
mute = Configuration.getInstance().isMuted();
arenaSound = new Prius_Track3();
}
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 165
//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 166
//Player (contraption.Player)
package contraption {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import contraption.blocks.*;
import flash.geom.*;
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.net.*;
import flash.text.*;
import flash.ui.*;
public class Player extends Arena {
public var currentLevelId:int;// = 0
protected var buildingBlockType:BlockType;
public var moveMode:Boolean;// = false
protected var movingJoints:Dictionary;
protected var solarPowerSystem:SolarPowerSystem;
public var linkedIn:Boolean;
protected var buildingBlock:Block;
public var m_iterations:int;// = 10
protected var moving:Boolean;// = false
protected var movingIllegal:Boolean;
protected var movingJointsOriginalPosition:Dictionary;
protected var movingIllegalNotification:Sprite;
protected var mIsLoaded:Boolean;// = false
protected var isCurrentDesignSolution:Boolean;// = false
protected var solarPanLList:SLinkedList;
protected var te:TextField;
protected var movingBlocks:SLinkedList;
public var currentLevelXml:XML;
protected var tickCounter:TickCounter;
protected var movingJOriginal:Point;
protected var movingBlocksOriginalPosition:SLinkedList;
public var building:Boolean;// = false
protected var movingJ:Boolean;// = false
public var hasFinishedLevel:Boolean;// = false
public var running:Boolean;// = false
public var m_timeStep:Number;// = 0.0333333333333333
private var ox:Number;
private var oy:Number;
protected var movingJoint:JointCollection;
public var deleteMode:Boolean;// = false
protected var movingNumCollisions:int;
public function Player(stage:Stage, parentContraption:Contraption, linkedIn:Boolean=false, testingLevel:Boolean=false){
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.SOLAR_PANEL, solarPanelMode);
dashboard.addEventListener(DashboardEvent.MOVE, enterMoveMode);
dashboard.addEventListener(DashboardEvent.DELETE, enterDeleteMode);
dashboard.addEventListener(DashboardEvent.SAVE, saveDesign);
dashboard.addEventListener(DashboardEvent.WIN_LEVEL, winLevelEvent);
dashboard.initSunFunc = initSunAngle;
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, saveDesign, false, 0, true);
parentContraption.addEventListener(MenuEvent.CHANGE_GRAPHICS_OPTION, updateBlockGraphics, false, 0, true);
te = new TextField();
te.mouseEnabled = false;
addChild(te);
tickCounter = new TickCounter();
tickCounter.x = 650;
tickCounter.y = 470;
tickCounter.visible = false;
addChild(tickCounter);
var graphicsButton:Button = new ToggleGraphicsButton();
graphicsButton.x = 10;
graphicsButton.y = 425;
addChild(graphicsButton);
solarPowerSystem = new SolarPowerSystem();
setTimeout(finishLoading, 500);
}
protected function winLevel():void{
var num:Number;
hasFinishedLevel = true;
isCurrentDesignSolution = true;
var userCookie:SharedObject = SharedObject.getLocal("user");
userCookie.data[("level" + levelId)] = "true";
MainMenu.SetLastCompletedLevelID(levelId);
if (userCookie.data[("efficiency" + levelId)]){
num = userCookie.data[("efficiency" + levelId)];
if (num < solarPowerSystem.getCurrentPower()){
userCookie.data[("efficiency" + levelId)] = solarPowerSystem.getCurrentPower();
};
} else {
userCookie.data[("efficiency" + levelId)] = solarPowerSystem.getCurrentPower();
};
userCookie.flush();
checkKongStats();
loadNextLevel();
tickCounter.pause();
}
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);
tickCounter.reset();
}
protected function loadNextLevel():void{
trace(("loadNextLevel " + levelNumber));
var completeEvent:MenuEvent = new MenuEvent(MenuEvent.LEVEL_COMPLETE, true, true);
completeEvent.levelNumber = levelNumber;
completeEvent.levelId = levelId;
completeEvent.efficiency = solarPowerSystem.getCurrentPower();
dispatchEvent(completeEvent);
}
protected function solarPanelMode(e:Event=null):void{
resetMode();
buildingBlockType = BlockType.SOLAR_PANEL;
dashboard.hilightButton(dashboard.solarPanelButton);
dispatchEvent(new ModeEvent(ModeEvent.DEFAULT_MODE));
}
protected function hollowRodMode(e:Event):void{
resetMode();
buildingBlockType = BlockType.ROD_HOLLOW;
dashboard.hilightButton(dashboard.hollowRodButton);
dispatchEvent(new ModeEvent(ModeEvent.DEFAULT_MODE));
}
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.SOLAR_PANEL){
newBlock = playerBlocks.createSolarPanel(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 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;
if (!startZone.isInside(new Point(ex, ey))){
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);
} else {
if (buildingBlockType == BlockType.SOLAR_PANEL){
newBlock = playerBlocks.createSolarPanel(new Point(ox, oy), new Point(ex, ey), arenaCanvas.scaleX, null, true);
};
};
};
};
};
};
addChildBlock(newBlock);
newBlock.generatePhysicsBody(physicsWorld);
if (checkCollisions(newBlock)){
playerBlocks.deleteBlock(physicsWorld, newBlock);
removeChildBlock(newBlock);
} else {
addedBlock(newBlock);
};
}
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, saveDesign);
}
protected function finishLoading():void{
mIsLoaded = true;
}
override protected function loadLevelHandler(event:Event):void{
super.loadLevelHandler(event);
if (((linkedIn) && (hasPermissionToPlay()))){
addChild(new LinkInMenu());
};
}
protected function counterClockwiseWheelMode(e:Event):void{
resetMode();
buildingBlockType = BlockType.WHEEL_COUNTER_CLOCKWISE;
dashboard.hilightButton(dashboard.ccwWheelButton);
dispatchEvent(new ModeEvent(ModeEvent.DEFAULT_MODE));
}
public function isRunning():Boolean{
return (running);
}
protected function initBuildingBoundries():void{
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);
}
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);
};
}
public function flagTutorialComplete():void{
var userCookie:SharedObject = SharedObject.getLocal("user");
userCookie.data[("level" + levelId)] = "true";
userCookie.data[("efficiency" + levelId)] = 100;
userCookie.flush();
}
public function initSunAngle():void{
if (dashboard.sun != null){
dashboard.sun.rotation = sunAngle;
};
}
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();
if (dashboard.initSunFunc != null){
dashboard.initSunFunc();
};
}
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 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;
isCurrentDesignSolution = false;
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;
isCurrentDesignSolution = false;
}
protected function initJoints():void{
var blockIter:Iterator = playerBlocks.getIterator();
while (blockIter.hasNext()) {
(blockIter.next() as Block).startJoints(physicsWorld);
};
}
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);
};
};
}
override public function getLevelXml():XML{
if (currentLevelXml != null){
return (currentLevelXml);
};
return (super.getLevelXml());
}
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 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 winLevelEvent(event:Event):void{
if (!hasFinishedLevel){
winLevel();
};
}
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 endTryLevel(event:Event):void{
dispatchEvent(new MenuEvent(MenuEvent.MENU_BACK));
}
override protected function initAllowableActions():void{
allowableActions = new Actions();
allowableActions.alwaysDrag = true;
}
override protected function newSaveWindow():SaveWindow{
return (new SaveDesignWindow());
}
protected function resetMode():void{
moveMode = false;
deleteMode = false;
}
protected function saveDesign(event:Event):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.levelIDString = getLevelIdentifyer();
saveEvent.isSolution = isCurrentDesignSolution;
saveEvent.levelIDString = this.getLevelIdentifyer();
dispatchEvent(saveEvent);
}
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 (event.keyCode == 84){
tickCounter.visible = !(tickCounter.visible);
};
if (running){
return;
};
if (event.keyCode == 82){
hollowRodMode(null);
};
if (event.keyCode == 83){
solidRodMode(null);
};
if (event.keyCode == 80){
solarPanelMode(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;
var r:Number;
var deg:Number;
var p:Point;
var i:Number;
var vertLength:Number;
var horzLength:Number;
var ii:int;
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));
if (endZone.isCustomShape()){
r = (block.getWidth() / 2);
p = new Point();
i = 0;
while (i < 20) {
deg = (((2 * Math.PI) / 20) * i);
p.x = ((r * Math.cos(deg)) + block.x);
p.y = ((r * Math.sin(deg)) + block.y);
if (!endZone.isInside(p)){
return (false);
};
i++;
};
return (true);
};
} 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 (endZone.isCustomShape()){
vertLength = (blockTop - blockBottom);
horzLength = (blockRight - blockLeft);
vertLength = (vertLength / 5);
horzLength = (horzLength / 5);
ii = 0;
while (ii < 5) {
if (!endZone.isInside(new Point(blockLeft, (blockBottom + (vertLength * ii))))){
return (false);
};
if (!endZone.isInside(new Point(blockRight, (blockBottom + (vertLength * ii))))){
return (false);
};
if (!endZone.isInside(new Point((blockLeft + (horzLength * ii)), blockTop))){
return (false);
};
if (!endZone.isInside(new Point((blockLeft + (horzLength * ii)), blockBottom))){
return (false);
};
ii++;
};
return (true);
};
};
if (!endZone.isCustomShape()){
if ((((((((blockLeft < endLeft)) || ((blockRight > endRight)))) || ((blockTop < endTop)))) || ((blockBottom > endBottom)))){
return (false);
};
};
};
return (true);
}
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);
}
public 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);
solarPowerSystem.ResetPower();
tickCounter.pause();
solarPanLList.clear();
solarPanLList = null;
dashboard.solarPowerMeter.gotoAndStop(1);
}
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;
}
override public function update(event:Event):void{
var wheelCount:int;
var loadSpanels:Boolean;
var bb:b2Body;
var solarPow:Number;
var range:Number;
var finalNum:int;
var joint:b2Joint;
var revJoint:b2RevoluteJoint;
var distance:b2Vec2;
if (((running) && (!((physicsWorld == null))))){
tickCounter.increment();
physicsWorld.Step(m_timeStep, m_iterations);
wheelCount = 0;
loadSpanels = false;
if (this.solarPanLList == null){
loadSpanels = true;
solarPanLList = new SLinkedList();
};
bb = physicsWorld.m_bodyList;
while (bb) {
if ((bb.m_userData is Block)){
if ((bb.m_userData is Wheel)){
if ((bb.m_userData as Wheel).spinDirection != Wheel.NO_SPIN){
if (solarPowerSystem.checkWheelConnect((bb.m_userData as Wheel))){
wheelCount++;
};
};
};
(bb.m_userData as Block).updateFromPhysicsBody();
if (loadSpanels){
if ((bb.m_userData is SolarPanel)){
solarPanLList.append(bb.m_userData);
};
};
};
bb = bb.m_next;
};
solarPow = solarPowerSystem.calculatePowerTick(solarPanLList, sunAngle, wheelCount);
range = (solarPowerSystem.getMaxPower() / dashboard.solarPowerMeter.totalFrames);
finalNum = (solarPow / range);
if (finalNum < 0){
finalNum = 0;
};
if ((((solarPow < solarPowerSystem.getMaxPower())) || (loadSpanels))){
dashboard.solarPowerMeter.gotoAndStop((dashboard.solarPowerMeter.totalFrames - finalNum));
};
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()))){
winLevel();
};
};
super.update(event);
}
protected function solidRodMode(e:Event=null):void{
resetMode();
buildingBlockType = BlockType.ROD_SOLID;
dashboard.hilightButton(dashboard.solidRodButton);
dispatchEvent(new ModeEvent(ModeEvent.DEFAULT_MODE));
}
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))) || (!(mIsLoaded)))){
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;
isCurrentDesignSolution = false;
};
} 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;
isCurrentDesignSolution = false;
};
};
};
}
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 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 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;
}
public static function checkKongStats():void{
var levelIds:Array = new Array(13);
levelIds[0] = 91;
levelIds[1] = 55;
levelIds[2] = 16;
levelIds[3] = 102;
levelIds[4] = 31;
levelIds[5] = 89;
levelIds[6] = 88;
levelIds[7] = 86;
levelIds[8] = 100;
levelIds[9] = 17;
levelIds[10] = 62;
levelIds[11] = 19;
levelIds[12] = 23;
var finishedAll:Boolean;
var finishedAll100:Boolean;
var got100:Boolean;
var userCookie:SharedObject = SharedObject.getLocal("user");
var i:int;
while (i < levelIds.length) {
if ((((userCookie.data[("level" + levelIds[i])] == null)) || ((!(userCookie.data[("level" + levelIds[i])]) == "true")))){
finishedAll = false;
};
if ((((userCookie.data[("efficiency" + levelIds[i])] == null)) || ((!(userCookie.data[("efficiency" + levelIds[i])]) == 100)))){
finishedAll100 = false;
} else {
got100 = true;
};
i++;
};
if (!Contraption.kongregateAPI.loadedRealAPI()){
return;
};
if (finishedAll){
Contraption.kongregateAPI.submit_finishedLevels();
};
if (finishedAll100){
Contraption.kongregateAPI.submit_finishedLevels100();
};
if (got100){
Contraption.kongregateAPI.submit_efficiencyMaster();
};
}
}
}//package contraption
Section 167
//SolarPowerSystem (contraption.SolarPowerSystem)
package contraption {
import contraption.blocks.*;
import de.polygonal.ds.*;
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class SolarPowerSystem {
protected var mCount:int;
protected var mPower:Number;
protected static var mMinPower:Number = 0;
protected static var mWheelDrain:Number = 0.5;
protected static var mMaxPower:Number = 100;
protected static var mHighPower:Number = 0.005;
protected static var mWinPower:Number = 0.1;
protected static var mLowPower:Number = 0;
public function SolarPowerSystem():void{
super();
mPower = 100;
mCount = 0;
}
public function ResetPower():void{
mPower = 100;
}
public function checkWheelConnect(wheel:Wheel):Boolean{
var b2:b2Body = wheel.getPhysicsBody();
if (b2.GetJointList() == null){
return (false);
};
return (true);
}
public function getCurrentPower():Number{
return (mPower);
}
public function hasEnoughPower():Boolean{
return ((mPower >= mWinPower));
}
public function calculatePowerTick(solarPanels:SLinkedList, sunAngle:Number, wheelCount:int):Number{
var spanel:SolarPanel;
var temppower:Number;
var col:int;
var panelAngle:Number;
var panelVect:b2Vec2;
var sunVect:b2Vec2;
var numOfSteps:int;
var num:Number;
var stepping:Number;
var tempInt:int;
if (solarPanels == null){
return (0);
};
sunAngle = ((Math.PI * sunAngle) / 180);
var spanelIter:Iterator = solarPanels.getIterator();
panelVect = new b2Vec2();
sunVect = new b2Vec2(Math.sin(sunAngle), Math.cos(sunAngle));
sunVect.Normalize();
while (spanelIter.hasNext()) {
spanel = (spanelIter.next() as SolarPanel);
numOfSteps = spanel.getFrameCount();
panelAngle = spanel.getPhysicsBody().GetRotation();
panelVect.x = Math.sin(panelAngle);
panelVect.y = Math.cos(panelAngle);
panelVect.Normalize();
num = ((panelVect.x * sunVect.x) + (panelVect.y * sunVect.y));
num = ((num / (panelVect.Length() * sunVect.Length())) * (180 / Math.PI));
stepping = (90 / numOfSteps);
num = Math.abs(num);
if (num > 90){
num = (num - 90);
};
num = (90 - num);
tempInt = (num / stepping);
spanel.setFrame(tempInt);
temppower = ((num / 90) * (mHighPower - mLowPower));
mPower = (mPower + (temppower * spanel.getLength()));
};
mPower = (mPower - (mWheelDrain * wheelCount));
if (mPower > mMaxPower){
mPower = mMaxPower;
} else {
if (mPower < mMinPower){
mPower = mMinPower;
};
};
return (mPower);
}
public function getMaxPower():Number{
return (mMaxPower);
}
}
}//package contraption
Section 168
//StartZone (contraption.StartZone)
package contraption {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import Box2D.Common.Math.*;
import contraption.data.*;
public class StartZone extends ActionContainerImpl {
protected var resizing:Boolean;// = false
protected var moving:Boolean;// = false
protected var my0:Number;
protected var customImageName:String;
protected var editing:Boolean;
private var isCircle:Boolean;// = false
protected var mx0:Number;
protected var customImage:MovieClip;
protected var scalex:Number;
protected var scaley:Number;
protected var mrotation:Number;
protected var zoneHeight:Number;
protected var resizeCorner:Sprite;
protected var zoneWidth: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 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);
}
public function setWidth(value:Number):void{
zoneWidth = value;
}
protected function mouseUpM(event:MouseEvent):void{
moving = false;
}
public function isInside(point:Point):Boolean{
var v:b2Vec2;
var temp:Number;
var rad:Number;
var left:Number;
var right:Number;
var top:Number;
var bottom:Number;
if (customImage){
point = parent.parent.localToGlobal(point);
return (customImage.hitTestPoint(point.x, point.y, true));
};
if (isCircle){
v = new b2Vec2();
v.x = (getPosition().x - point.x);
v.y = (getPosition().y - point.y);
temp = v.Length();
rad = getWidth();
trace(((("InsideCircle: Length = " + temp.toString()) + "\t\t radius = ") + rad.toString()));
return ((temp <= rad));
};
left = (getPosition().x - (getWidth() / 2));
right = (getPosition().x + (getWidth() / 2));
top = (getPosition().y - (getHeight() / 2));
bottom = (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 getColour():int{
return (13625329);
}
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 (13625329);
}
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);
if (xml.child("isCircle").length() > 0){
this.isCircle = new Boolean(xml.isCircle);
};
customImageName = xml.customImage;
customImage = BackgroundLinks.getZoneItem(customImageName);
if (xml.scalex){
scalex = xml.scalex;
} else {
scalex = 1;
};
if (xml.scaley){
scaley = xml.scaley;
} else {
scaley = 1;
};
if (xml.rotation){
mrotation = xml.rotation;
};
drawZone();
}
protected function drawZone():void{
if (customImage){
graphics.clear();
customImage.scaleX = scalex;
customImage.scaleY = scaley;
customImage.rotation = mrotation;
addChild(customImage);
} else {
if (isCircle){
graphics.clear();
graphics.lineStyle(4, getBorderColour(), 0.7);
graphics.beginFill(getColour(), 0.7);
graphics.drawCircle(0, 0, getWidth());
if (resizeCorner != null){
resizeCorner.x = (getWidth() / 2);
resizeCorner.y = (getWidth() / 2);
};
} else {
graphics.clear();
graphics.lineStyle(4, getBorderColour(), 0.7);
graphics.beginFill(getColour(), 0.7);
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 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>"));
xml.appendChild((("<customImage>" + customImageName) + "</customImage>"));
xml.appendChild((("<scalex>" + scalex) + "</scalex>"));
xml.appendChild((("<scaley>" + scaley) + "</scaley>"));
xml.appendChild((("<rotation>" + mrotation) + "</rotation>"));
if (isCircle){
xml.appendChild((("<isCircle>" + isCircle) + "</isCircle>"));
};
return (xml);
}
public function isCustomShape():Boolean{
return (!((customImage == null)));
}
protected function getXmlRoot():XML{
return (<start/>
);
}
public function setHeight(value:Number):void{
zoneHeight = value;
}
public function setPosition(value:Point):void{
x = value.x;
y = value.y;
}
protected function mouseMoveM(event:MouseEvent):void{
if (!moving){
return;
};
setPosition(new Point((parent.mouseX - mx0), (parent.mouseY - my0)));
}
protected function mouseUpR(event:MouseEvent):void{
resizing = false;
}
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();
}
}
}//package contraption
Section 169
//Transition_Movie (contraption.Transition_Movie)
package contraption {
import flash.display.*;
public class Transition_Movie extends MovieClip {
public var OnFirstTransition:Function;
public function Transition_Movie(){
super();
}
}
}//package contraption
Section 170
//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 = true;
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 = true;
} 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((Contraption.SERVER_LOCATION + "/logIn_fc.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((Contraption.SERVER_LOCATION + "/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((Contraption.SERVER_LOCATION + "/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 (true);
}
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((Contraption.SERVER_LOCATION + "/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();
if (((registered) && ((Contraption.VERSION_NAME == "fantasticcontraption.com")))){
ExternalInterface.call("setRegistered");
};
}
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((Contraption.SERVER_LOCATION + "/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;
trace("bleh");
trace(event.target.data);
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 = true;
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 171
//Stream_15 (contraption_objects_fla.Stream_15)
package contraption_objects_fla {
import flash.display.*;
public dynamic class Stream_15 extends MovieClip {
public var dropBouncing:MovieClip;
}
}//package contraption_objects_fla
Section 172
//StreamBG_10 (contraption_objects_fla.StreamBG_10)
package contraption_objects_fla {
import flash.display.*;
public dynamic class StreamBG_10 extends MovieClip {
public var dropBouncing:MovieClip;
}
}//package contraption_objects_fla
Section 173
//anim_left_30 (Dashboard_fla.anim_left_30)
package Dashboard_fla {
import flash.display.*;
public dynamic class anim_left_30 extends MovieClip {
public function anim_left_30(){
addFrameScript(29, frame30);
}
function frame30(){
gotoAndPlay(1);
}
}
}//package Dashboard_fla
Section 174
//anim_solar_19 (Dashboard_fla.anim_solar_19)
package Dashboard_fla {
import flash.display.*;
public dynamic class anim_solar_19 extends MovieClip {
public function anim_solar_19(){
addFrameScript(29, frame30);
}
function frame30(){
gotoAndPlay(1);
}
}
}//package Dashboard_fla
Section 175
//anim_water_21 (Dashboard_fla.anim_water_21)
package Dashboard_fla {
import flash.display.*;
public dynamic class anim_water_21 extends MovieClip {
public function anim_water_21(){
addFrameScript(29, frame30);
}
function frame30(){
gotoAndPlay(1);
}
}
}//package Dashboard_fla
Section 176
//anim_wood_17 (Dashboard_fla.anim_wood_17)
package Dashboard_fla {
import flash.display.*;
public dynamic class anim_wood_17 extends MovieClip {
public function anim_wood_17(){
addFrameScript(19, frame20);
}
function frame20(){
gotoAndPlay(1);
}
}
}//package Dashboard_fla
Section 177
//BatteryBarAnim_6 (Dashboard_fla.BatteryBarAnim_6)
package Dashboard_fla {
import flash.display.*;
public dynamic class BatteryBarAnim_6 extends MovieClip {
public function BatteryBarAnim_6(){
addFrameScript(0, frame1, 30, frame31);
}
function frame1(){
stop();
}
function frame31(){
stop();
}
}
}//package Dashboard_fla
Section 178
//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 _background:DashBackground;
public var backButton:BackButton;
public function Buttons_3(){
addFrameScript(0, frame1);
}
function frame1(){
}
}
}//package Dashboard_fla
Section 179
//ContraptionButtons_10 (Dashboard_fla.ContraptionButtons_10)
package Dashboard_fla {
import flash.display.*;
public dynamic class ContraptionButtons_10 extends MovieClip {
public var goStopButtons:MovieClip;
public var moveButton:MoveButton;
public var npWheelButton:NonPoweredWheelButton;
public var cwWheelButton:ClockwiseWheelButton;
public var solidRodButton:SolidRodButton;
public var playerSun:grph_SunPlay;
public var deleteButton:DeleteButton;
public var hollowRodButton:HollowRodButton;
public var viewDesignButton:SavedContraptionButton;
public var ccwWheelButton:CounterClockwiseWheelButton;
public var solarPanelButton:SolarPanelButton;
}
}//package Dashboard_fla
Section 180
//GoStopButtons_32 (Dashboard_fla.GoStopButtons_32)
package Dashboard_fla {
import flash.events.*;
import flash.display.*;
public dynamic class GoStopButtons_32 extends MovieClip {
public var stopButtonPing:StopButtonPing;
public var goButton:GoButton;
public var stopButton:StopButton;
public function GoStopButtons_32(){
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 181
//HUD_Solar_5 (Dashboard_fla.HUD_Solar_5)
package Dashboard_fla {
import flash.display.*;
public dynamic class HUD_Solar_5 extends MovieClip {
public var batterybaranim:MovieClip;
}
}//package Dashboard_fla
Section 182
//LevelButtons_38 (Dashboard_fla.LevelButtons_38)
package Dashboard_fla {
import flash.display.*;
public dynamic class LevelButtons_38 extends MovieClip {
public var dynamicCircleButton:DynamicCircleButton;
public var testLevelButton:TestLevelButton;
public var grphSun:flEditableSun;
public var staticSquareButton:StaticSquareButton;
public var goalSquareButton:GoalSquareButton;
public var dynamicSquareButton:DynamicSquareButton;
public var staticCircleButton:StaticCircleButton;
public var goalCircleButton:GoalCircleButton;
}
}//package Dashboard_fla
Section 183
//SavedContraptionsButton_13 (Dashboard_fla.SavedContraptionsButton_13)
package Dashboard_fla {
import flash.display.*;
public dynamic class SavedContraptionsButton_13 extends MovieClip {
public function SavedContraptionsButton_13(){
addFrameScript(0, frame1);
}
function frame1(){
}
}
}//package Dashboard_fla
Section 184
//ZoomButtons_7 (Dashboard_fla.ZoomButtons_7)
package Dashboard_fla {
import flash.display.*;
public dynamic class ZoomButtons_7 extends MovieClip {
public var zoomOutButton:ZoomOutButton;
public var zoomInButton:ZoomInButton;
}
}//package Dashboard_fla
Section 185
//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 186
//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 187
//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 188
//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 189
//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 190
//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 191
//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 192
//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 193
//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 194
//Iterator (de.polygonal.ds.Iterator)
package de.polygonal.ds {
public interface Iterator {
function start():void;
function set data(C:\Tor\Prius\FantasticContraption\src;de\polygonal\ds;Iterator.as):void;
function get data();
function next();
function hasNext():Boolean;
}
}//package de.polygonal.ds
Section 195
//LinkedListNode (de.polygonal.ds.LinkedListNode)
package de.polygonal.ds {
public interface LinkedListNode {
}
}//package de.polygonal.ds
Section 196
//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 197
//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 198
//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 199
//LevelDot_12 (logo_fla.LevelDot_12)
package logo_fla {
import flash.display.*;
public dynamic class LevelDot_12 extends MovieClip {
public function LevelDot_12(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package logo_fla
Section 200
//MapObjects_14 (logo_fla.MapObjects_14)
package logo_fla {
import flash.display.*;
public dynamic class MapObjects_14 extends MovieClip {
public var car:Car;
}
}//package logo_fla
Section 201
//FontAsset (mx.core.FontAsset)
package mx.core {
import flash.text.*;
public class FontAsset extends Font implements IFlexAsset {
mx_internal static const VERSION:String = "3.2.0.3958";
public function FontAsset(){
super();
}
}
}//package mx.core
Section 202
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 203
//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 204
//AllDesignsContraptionsButton (AllDesignsContraptionsButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class AllDesignsContraptionsButton extends Button {
public function AllDesignsContraptionsButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_ALL_SAVED_DESIGNS;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 205
//ArrowMap (ArrowMap)
package {
import flash.display.*;
public dynamic class ArrowMap extends MovieClip {
}
}//package
Section 206
//BackButton (BackButton)
package {
import contraption.menu.*;
public dynamic class BackButton extends DashboardButton {
}
}//package
Section 207
//BackTestButton (BackTestButton)
package {
import contraption.menu.*;
public dynamic class BackTestButton extends DashboardButton {
}
}//package
Section 208
//BackToMenuButton (BackToMenuButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class BackToMenuButton extends Button {
public function BackToMenuButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.MENU_BACK;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 209
//BG_02_Mov (BG_02_Mov)
package {
import flash.display.*;
public dynamic class BG_02_Mov extends MovieClip {
}
}//package
Section 210
//BuildingMousePointer (BuildingMousePointer)
package {
import flash.display.*;
public dynamic class BuildingMousePointer extends MovieClip {
}
}//package
Section 211
//ButtonBack (ButtonBack)
package {
import contraption.menu.*;
public dynamic class ButtonBack extends NoTabButton {
}
}//package
Section 212
//ButtonMousePointer (ButtonMousePointer)
package {
import flash.display.*;
public dynamic class ButtonMousePointer extends MovieClip {
}
}//package
Section 213
//Car (Car)
package {
import flash.display.*;
public dynamic class Car extends MovieClip {
}
}//package
Section 214
//ClockwiseWheelButton (ClockwiseWheelButton)
package {
import contraption.menu.*;
public dynamic class ClockwiseWheelButton extends DashboardButton {
}
}//package
Section 215
//ClockwiseWheelGraphic (ClockwiseWheelGraphic)
package {
import flash.display.*;
public dynamic class ClockwiseWheelGraphic extends MovieClip {
}
}//package
Section 216
//ContinueButton (ContinueButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class ContinueButton extends Button {
public function ContinueButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.MENU_BACK;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 217
//ContinueTutorialButton (ContinueTutorialButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class ContinueTutorialButton extends Button {
public function ContinueTutorialButton(){
addFrameScript(0, frame1);
}
function frame1(){
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 218
//Contraption (Contraption)
package {
import flash.events.*;
import contraption.menu.*;
import contraption.*;
import flash.display.*;
import contraption.blocks.*;
import flash.geom.*;
import de.polygonal.ds.*;
import contraption.tutorials.*;
import flash.net.*;
import flash.text.*;
import flash.ui.*;
import flash.system.*;
public class Contraption extends MovieClip {
protected var acting:Boolean;// = false
protected var spinner:MovieClip;
protected var newMenu:MenuWindow;
protected var sceneChange:SceneChange;
protected var splash:MovieClip;
protected var menuStack:SLinkedList;
protected var urlLoader:URLLoader;
protected var tf:TextField;
protected var editor:Editor;
protected var currentMenu:MenuWindow;
protected var mouseType:int;
protected var pointerMode:String;
public var passedArgs:Object;
protected var menuCanvas:Sprite;
protected var mainMenu:MainMenu;
protected var mousePointer:MousePointer;
protected var player:Player;
protected var toolTip:Sprite;
public var LEVELIDENT:String;
public static const INCLUDE_PAYPAL_LINKS:Boolean = false;
public static const VERSION_NUMBER:String = "1.027";
public static const SERVER_LOCATION:String = "";
public static const VERSION_NAME:String = "Contraption_Prius";
public static var LAWS_FONT:Class = Contraption_LAWS_FONT;
public static var kongregateAPI:KongAPI;
public function Contraption():void{
super();
this.addEventListener(Event.ADDED_TO_STAGE, ContraptionInit);
}
public function finishingLoadingTest(e:Event):void{
var _xml:XML;
var e = e;
_xml = new XML(urlLoader.data);
//unresolved jump
var _slot1 = error;
throw (new Error(("XML Error:" + _slot1)));
if (_xml){
editor = new Editor(stage, this);
loadMenu(editor);
editor.loadFromXml(_xml);
editor.initZoomAndScroll();
};
}
protected function loadUpdateUserInfoMenu(event:MenuEvent):void{
loadModalMenu(new UpdateUserInfoMenu());
}
protected function loadUserGenLevels(event:Event):void{
kongregateAPI.browseLevels();
}
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 loadSavedLevels(event:MenuEvent):void{
kongregateAPI.browseMyLevels();
}
protected function tutorialLevelCompleteMenu(event:MenuEvent):void{
loadModalMenu(new CompletedTutorialLevelMenu(event.tutorialNumber));
}
protected function addTooltip(event:TooltipEvent):void{
if (toolTip){
menuCanvas.removeChild(toolTip);
};
var textField:TextField = new TextField();
textField.embedFonts = true;
var textFormat:TextFormat = new TextFormat();
textFormat.font = "contraptionFont";
textFormat.size = 12;
textFormat.color = 0xFFFFFF;
textField.autoSize = "left";
textField.text = event.toolTip;
textField.setTextFormat(textFormat);
toolTip = new Sprite();
toolTip.graphics.beginFill(6675685);
toolTip.graphics.drawRoundRect(-2, -2, (textField.width + 5), (textField.height + 5), 10, 10);
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 finishLoading(event:MenuEvent=null):void{
if (newMenu == null){
return;
};
if (sceneChange != null){
if (menuCanvas.contains(sceneChange)){
sceneChange.open();
} else {
showNewMenu();
};
} else {
showNewMenu();
};
}
protected function loadLevelHandler(event:MenuEvent):void{
loadLevel(event.levelId);
}
protected function addSpinner(event:MenuEvent):void{
menuCanvas.addChild(spinner);
}
protected function loadDesignFromApi(params:Object):void{
player = new Player(stage, this);
player.setCustomLevelID(params.label);
LEVELIDENT = params.label;
loadMenu(player);
player.loadFromXml(new XML(params.content));
player.initZoomAndScroll();
finishLoading();
}
protected function loadSaveContraptionMenu(event:SaveEvent):void{
player.stopSimulation(null);
kongregateAPI.saveDesign(event.levelIDString, event.xml, player.arenaCanvas);
}
protected function loadLogInMenu(event:MenuEvent):void{
loadModalMenu(new LogInMenu());
}
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 loadLevel(levelId:int):void{
player = new Player(stage, this);
loadMenu(player);
player.loadLevel(levelId);
}
protected function startAction(event:Event=null):void{
if ((event as ModeEvent)){
setPointer(true, (event as ModeEvent).actionType);
} else {
setPointer(true);
};
}
protected function setPointerHandler(event:Event):void{
setPointer();
}
protected function editLevelHandler(event:MenuEvent):void{
editLevel(event.levelId);
}
protected function loadBuyGameMenu(event:MenuEvent):void{
}
protected function curtainOpenComplete(event:MenuEvent):void{
menuCanvas.removeChild(sceneChange);
}
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);
if ((newMenu as Arena)){
Music.getInstance().playArena();
} else {
Music.getInstance().playMenu();
};
}
protected function loadDesignHandler(event:MenuEvent):void{
loadDesign(event.designId);
}
protected function mouseOut(event:Event):void{
Mouse.show();
mousePointer.visible = false;
}
protected function loadModalMenu(menu:ModalMenu):void{
addMenu(menu);
}
protected function setPointer(setActing:Boolean=false, actingType:int=0):void{
var newMouseType:int;
var objectUnderPointer:ActionContainer;
var allowableActions:Actions;
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 loadLevelSolutions(event:MenuEvent):void{
}
protected function defaultMode(event:Event=null):void{
pointerMode = ModeEvent.DEFAULT_MODE;
setPointer();
}
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();
if (event != null){
event.stopPropagation();
};
}
protected function loadTutorialLevel(tutorialNumber:int):void{
player = new TutorialPlayer(stage, this);
loadMenu(player);
(player as TutorialPlayer).loadTutorialLevel(tutorialNumber);
}
protected function tryLevel(event:Event):void{
player = new Player(stage, this, false, true);
loadMenu(player);
player.setCustomLevelID(editor.getLevelIdentifyer());
player.loadFromXml(editor.getLevelXml());
player.initZoomAndScroll();
}
protected function bubble(e:Event):void{
dispatchEvent(e);
mainMenu.refresh();
}
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_ALL_SAVED_DESIGNS, loadAllDesignsHandler, 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);
menu.addEventListener(MenuEvent.LOGGED_OUT, bubble, false, 0, true);
}
protected function loadTutorials(event:MenuEvent):void{
loadTutorialLevel(1);
}
protected function editLevel(editId:int):void{
editor = new Editor(stage, this);
loadMenu(editor);
editor.loadLevel(editId);
}
protected function currentDomain():String{
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 addMenu(menu:MenuWindow):void{
addMenuListeners(menu);
menuStack.append(menu);
menuCanvas.addChild(menu);
acting = false;
setPointer();
}
protected function loadLinkedInMenu(event:MenuEvent):void{
loadModalMenu(new LinkInMenu());
}
protected function loadTutorialLevelHandler(event:MenuEvent):void{
loadTutorialLevel(event.tutorialNumber);
}
protected function loadOfficialLevelHandler(event:MenuEvent):void{
if (event.levelNumber == 0){
LEVELIDENT = event.levelId.toString();
return (loadLevel(event.levelId));
};
LEVELIDENT = event.levelId.toString();
trace(("Set Level Ident to : " + LEVELIDENT.toString()));
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 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 loadSaveLevelMenu(event:SaveEvent):void{
kongregateAPI.saveLevel(event.xml, editor.arenaCanvas);
}
protected function update(event:Event):void{
mousePointer.x = mouseX;
mousePointer.y = mouseY;
}
protected function loadNewUserMenu(event:MenuEvent):void{
loadModalMenu(new NewUserMenu());
}
public function loadTestLevel(event:Event):void{
Security.allowDomain("darkvoodoogames.com");
urlLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, finishingLoadingTest);
urlLoader.load(new URLRequest("http://www.darkvoodoogames.com/prius/prius.xml"));
var userCookie:SharedObject = SharedObject.getLocal("user");
var i:int;
while (i < 100) {
userCookie.data[("level" + i)] = "true";
i++;
};
userCookie.flush();
}
public function reportKeyDown(event:KeyboardEvent):void{
if (event.keyCode == 76){
loadTestLevel(null);
};
}
protected function loadAllDesignsHandler(event:MenuEvent):void{
kongregateAPI.browseAllDesign();
}
protected function ContraptionInit(e:Event):void{
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 TutorialNextButton();
graphics.beginFill(8895985);
graphics.drawRect(0, 0, 700, 500);
menuCanvas = new Sprite();
addChild(menuCanvas);
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;
menuStack = new SLinkedList();
mainMenu = new MainMenu();
loadMenu(mainMenu);
splash = new Splash();
splash.x = 350;
splash.y = 250;
splash.gotoAndPlay("leave");
var globalListener:GlobalListener = GlobalListener.getInstance();
globalListener.init(stage, this);
globalListener.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown, false, 0, true);
kongregateAPI = new KongAPI(this.root, loadLevelFromApi, loadDesignFromApi, passedArgs);
addChild(kongregateAPI);
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);
addChild(new PriusTransition());
var fontArray:Array = Font.enumerateFonts(false);
showNewMenu();
}
protected function authenticate(allowDomain:String="example.com"):void{
if (currentDomain().toLowerCase() != VERSION_NAME){
deniedPermissionToPlay((((("Wrong domain: '" + currentDomain()) + "' expected: '") + VERSION_NAME) + "'"));
};
}
protected function loadLevelLinkMenu(event:MenuEvent):void{
loadModalMenu(new LevelLinkMenu(event.levelId));
}
protected function levelCompleteMenu(event:MenuEvent):void{
loadModalMenu(new CompletedLevelMenu(event.levelNumber, event.levelId, event.efficiency));
}
protected function loadDesignLinkMenu(event:MenuEvent):void{
loadModalMenu(new DesignLinkMenu(event.designId));
}
protected function removeTooltip(event:TooltipEvent):void{
if (toolTip){
menuCanvas.removeChild(toolTip);
};
toolTip = null;
}
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 loadUserMenu(event:MenuEvent):void{
loadMenu(new UserMenu(event.userId, event.userName));
finishLoading();
}
protected function deleteMode(event:Event=null):void{
pointerMode = ModeEvent.DELETE_MODE;
setPointer();
}
protected function endAction(event:Event=null):void{
acting = false;
setPointer();
}
protected function loadLevelFromApi(params:Object):void{
if (kongregateAPI.isMyLevel(params.label)){
editor = new Editor(stage, this);
editor.setCustomLevelID(params.label);
loadMenu(editor);
LEVELIDENT = params.label;
editor.loadFromXml(new XML(params.content));
editor.initZoomAndScroll();
finishLoading();
} else {
player = new Player(stage, this);
player.setCustomLevelID(params.label);
loadMenu(player);
LEVELIDENT = params.label;
player.loadFromXml(new XML(params.content));
player.addTitle(params.name);
player.initZoomAndScroll();
finishLoading();
};
}
protected function loadEditor(event:MenuEvent):void{
editor = new Editor(stage, this);
loadMenu(editor);
finishLoading();
}
protected function loadSavedDesigns(event:MenuEvent):void{
if (event.cameFromPlayer){
trace(("Browsing Designs for: " + LEVELIDENT.toString()));
kongregateAPI.browseDesignByLevel(LEVELIDENT);
} else {
trace("Browsing my designs");
kongregateAPI.browseMyDesigns();
};
}
protected function removeSpinner(event:MenuEvent):void{
if (menuCanvas.contains(spinner)){
menuCanvas.removeChild(spinner);
};
}
public function isCurrentMenu(menu:MenuWindow):Boolean{
return ((menu == (menuStack.tail.data as MenuWindow)));
}
public function unload(event:Event):void{
removeEventListener(Event.ENTER_FRAME, update);
Music.getInstance().stopSound();
}
}
}//package
Section 219
//Contraption_LAWS_FONT (Contraption_LAWS_FONT)
package {
import mx.core.*;
public class Contraption_LAWS_FONT extends FontAsset {
}
}//package
Section 220
//CounterClockwiseWheelButton (CounterClockwiseWheelButton)
package {
import contraption.menu.*;
public dynamic class CounterClockwiseWheelButton extends DashboardButton {
}
}//package
Section 221
//CounterClockwiseWheelGraphic (CounterClockwiseWheelGraphic)
package {
import flash.display.*;
public dynamic class CounterClockwiseWheelGraphic extends MovieClip {
}
}//package
Section 222
//DashBackground (DashBackground)
package {
import contraption.menu.*;
public dynamic class DashBackground extends MouseBlockingBackground {
}
}//package
Section 223
//DashboardImpl (DashboardImpl)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
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;
sun = expander.dash.levelButtons.grphSun;
} 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;
solarPanelButton = expander.dash.contraptionButtons.solarPanelButton;
moveButton = expander.dash.contraptionButtons.moveButton;
deleteButton = expander.dash.contraptionButtons.deleteButton;
solarPowerMeter = expander.dash._background.HUD_Solar.batterybaranim;
sun = expander.dash.contraptionButtons.playerSun;
viewDesignsButton = expander.dash.contraptionButtons.viewDesignButton;
};
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 224
//DefaultMousePointer (DefaultMousePointer)
package {
import flash.display.*;
public dynamic class DefaultMousePointer extends MovieClip {
}
}//package
Section 225
//DeleteButton (DeleteButton)
package {
import contraption.menu.*;
public dynamic class DeleteButton extends DashboardButton {
}
}//package
Section 226
//DeleteMousePointer (DeleteMousePointer)
package {
import flash.display.*;
public dynamic class DeleteMousePointer extends MovieClip {
}
}//package
Section 227
//DragActingMousePointer (DragActingMousePointer)
package {
import flash.display.*;
public dynamic class DragActingMousePointer extends MovieClip {
}
}//package
Section 228
//DragMousePointer (DragMousePointer)
package {
import flash.display.*;
public dynamic class DragMousePointer extends MovieClip {
}
}//package
Section 229
//DynamicCircleButton (DynamicCircleButton)
package {
import contraption.menu.*;
public dynamic class DynamicCircleButton extends DashboardButton {
}
}//package
Section 230
//DynamicSquareButton (DynamicSquareButton)
package {
import contraption.menu.*;
public dynamic class DynamicSquareButton extends DashboardButton {
}
}//package
Section 231
//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 232
//FindSmoothPathBetweenNodes (FindSmoothPathBetweenNodes)
package {
import flash.geom.*;
public class FindSmoothPathBetweenNodes {
public function FindSmoothPathBetweenNodes():void{
super();
}
private static function findValue(point0:Number, point1:Number, point2:Number, point3:Number, time:Number):Number{
var timeSub:Number = (1 - time);
var returnVal:Number = (Math.pow(timeSub, 3) * point0);
returnVal = (returnVal + (((3 * time) * Math.pow(timeSub, 2)) * point1));
returnVal = (returnVal + (((3 * Math.pow(time, 2)) * timeSub) * point2));
returnVal = (returnVal + (Math.pow(time, 3) * point3));
return (returnVal);
}
private static function findTheAngle(point1:Point, point2:Point):Number{
var px:Number = (point1.x - point2.x);
var py:Number = (point1.y - point2.y);
var radians:Number = Math.atan2(py, px);
var tempAngle:Number = Math.floor(((radians * 180) / Math.PI));
return (tempAngle);
}
public static function getArrayOfPoints(_nodeArray:Array, _evenSpacing:Boolean=false, _dotDistance:Number=10):Array{
var dist:Number;
var subItem:Point;
var firstItem:Point;
var secondItem:Point;
var thirdItem:Point;
var theSubAngle:Number;
var firstDist:Number;
var radians:Number;
var x0speed:Number;
var y0speed:Number;
var secondDist:Number;
var xspeed:Number;
var yspeed:Number;
var node1:Point;
var node2:Point;
var _point:Point;
if (_dotDistance < 0.1){
_dotDistance = 0.1;
};
var pathArray:Array = [];
var theAngle:Number = 0;
var percent:Number = 0;
var percentStepping:Number = 0.05;
var drawCurrentItem:int;
var stopRender:Boolean;
_nodeArray.unshift(_nodeArray[0]);
_nodeArray.push(_nodeArray[(_nodeArray.length - 1)]);
while (!(stopRender)) {
if (percent >= 1){
percent = 0;
drawCurrentItem = (drawCurrentItem + 1);
if (drawCurrentItem < (_nodeArray.length - 1)){
subItem = _nodeArray[(drawCurrentItem - 1)];
firstItem = _nodeArray[drawCurrentItem];
secondItem = _nodeArray[(drawCurrentItem + 1)];
thirdItem = _nodeArray[(drawCurrentItem + 2)];
if (thirdItem == null){
theAngle = 0;
stopRender = true;
} else {
theSubAngle = findTheAngle(subItem, secondItem);
theAngle = findTheAngle(firstItem, thirdItem);
if (_evenSpacing){
dist = findDistance(firstItem, secondItem);
percentStepping = (_dotDistance / dist);
};
firstDist = (findDistance(secondItem, subItem) * 0.15);
radians = ((theSubAngle / 180) * Math.PI);
x0speed = (Math.cos(radians) * firstDist);
y0speed = (Math.sin(radians) * firstDist);
secondDist = (findDistance(firstItem, thirdItem) * 0.15);
radians = ((theAngle / 180) * Math.PI);
xspeed = (Math.cos(radians) * secondDist);
yspeed = (Math.sin(radians) * secondDist);
node1 = new Point((firstItem.x - x0speed), (firstItem.y - y0speed));
node2 = new Point((secondItem.x + xspeed), (secondItem.y + yspeed));
};
} else {
stopRender = true;
};
} else {
_point = new Point();
if (((((((!((firstItem == null))) && (!((secondItem == null))))) && (!((node1 == null))))) && (!((node2 == null))))){
_point.x = findValue(firstItem.x, node1.x, node2.x, secondItem.x, percent);
_point.y = findValue(firstItem.y, node1.y, node2.y, secondItem.y, percent);
pathArray.push(_point);
};
};
percent = (percent + percentStepping);
};
return (pathArray);
}
public static function findDistance(_point1:Point, _point2:Point):Number{
var dx:Number = (_point1.x - _point2.x);
var dy:Number = (_point1.y - _point2.y);
return (Math.floor(Math.sqrt(((dx * dx) + (dy * dy)))));
}
}
}//package
Section 233
//flEditableSun (flEditableSun)
package {
import contraption.blocks.*;
public dynamic class flEditableSun extends EditableSun {
}
}//package
Section 234
//FullVersionButton (FullVersionButton)
package {
import flash.display.*;
public dynamic class FullVersionButton extends SimpleButton {
}
}//package
Section 235
//GoalCircleButton (GoalCircleButton)
package {
import contraption.menu.*;
public dynamic class GoalCircleButton extends DashboardButton {
}
}//package
Section 236
//GoalSquareButton (GoalSquareButton)
package {
import contraption.menu.*;
public dynamic class GoalSquareButton extends DashboardButton {
}
}//package
Section 237
//GoButton (GoButton)
package {
import contraption.menu.*;
public dynamic class GoButton extends DashboardButton {
}
}//package
Section 238
//GraphicsOffButton (GraphicsOffButton)
package {
import flash.display.*;
public dynamic class GraphicsOffButton extends SimpleButton {
}
}//package
Section 239
//GraphicsOnButton (GraphicsOnButton)
package {
import flash.display.*;
public dynamic class GraphicsOnButton extends SimpleButton {
}
}//package
Section 240
//grph_SunPlay (grph_SunPlay)
package {
import flash.display.*;
public dynamic class grph_SunPlay extends MovieClip {
}
}//package
Section 241
//HollowRodButton (HollowRodButton)
package {
import contraption.menu.*;
public dynamic class HollowRodButton extends DashboardButton {
}
}//package
Section 242
//HollowRodGraphic (HollowRodGraphic)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
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 243
//HollowRodGraphicBG (HollowRodGraphicBG)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
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 244
//LevelCircle (LevelCircle)
package {
import contraption.menu.*;
public dynamic class LevelCircle extends NoTabButton {
}
}//package
Section 245
//LevelCircleChecked (LevelCircleChecked)
package {
import contraption.menu.*;
public dynamic class LevelCircleChecked extends NoTabButton {
}
}//package
Section 246
//LinkBackButton (LinkBackButton)
package {
import flash.display.*;
public dynamic class LinkBackButton extends SimpleButton {
}
}//package
Section 247
//LinkedInOverlay (LinkedInOverlay)
package {
import flash.display.*;
public dynamic class LinkedInOverlay extends MovieClip {
}
}//package
Section 248
//LogInButton (LogInButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class LogInButton extends Button {
public function LogInButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOG_IN;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 249
//LogOutButton (LogOutButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class LogOutButton extends Button {
public function LogOutButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOG_OUT;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 250
//MainMenuButton (MainMenuButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
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 251
//MainMenuButtons (MainMenuButtons)
package {
import flash.display.*;
public dynamic class MainMenuButtons extends MovieClip {
}
}//package
Section 252
//MapScreen (MapScreen)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
public class MapScreen extends MapScreenFlash {
public var level:int;
public var speed:Number;
public var targetAnimFrame:Number;
public var moving:Boolean;
public var newMove:Boolean;
public var angle:Number;
public var car:MovieClip;// = null
public var fullPath:Array;// = null
public var ad:Number;
public var bBackward:Boolean;// = false
public var theMapObjects:MovieClip;// = null
public var targetLevel:int;
public var newDistance:Number;
public var moveSpeed:int;
public var mapObjectList:Array;
public var oldDistance:Number;
public static var wantGreenDots:Boolean = true;
public static var path:Array = [[193, 163, 208, 165, 239, 172, 0x0100, 188, 246, 210, 247, 224, 265, 229, 280, 228], [280, 228, 294, 228, 316, 227, 332, 210, 320, 188, 327, 175, 347, 173, 360, 171], [360, 171, 371, 171, 416, 170, 470, 159, 0x0200, 166, 516, 183, 518, 192], [518, 192, 523, 218, 559, 244, 560, 258, 534, 258], [534, 258, 519, 259, 507, 260, 480, 0x0100, 469, 246, 460, 240, 446, 241], [446, 241, 432, 244, 412, 258, 398, 277, 381, 282, 362, 282], [362, 282, 348, 285, 335, 295, 329, 317, 308, 330, 291, 330, 273, 329], [273, 329, 254, 329, 207, 329, 160, 345, 147, 345, 128, 345], [128, 345, 108, 346, 89, 361, 93, 387, 128, 396, 183, 397, 205, 396], [205, 396, 230, 397, 279, 401, 333, 394, 356, 393], [356, 393, 378, 394, 390, 389, 385, 373, 367, 362, 367, 349, 390, 341, 421, 342], [421, 342, 440, 339, 463, 331, 491, 331, 510, 328], [510, 328, 528, 332, 541, 345, 608, 376], [608, 376], [608, 376], [608, 376]];
public static var MIN_Y:Number = 160;
public static var MAX_SCALE:Number = 1.5;
public static var directions:int = 36;
public static var MIN_SCALE:Number = 1;
public static var MAX_Y:Number = 425;
public function MapScreen(){
mapObjectList = [];
super();
}
public function generatePath(p:int):void{
var i:int;
var i2:int;
var nodeArray:Array = [];
var _nodePoint:Point = new Point();
if (!bBackward){
i = 0;
while (i < path[p].length) {
_nodePoint = new Point();
_nodePoint.x = path[p][i];
_nodePoint.y = path[p][(i + 1)];
nodeArray.push(_nodePoint);
i = (i + 2);
};
} else {
i2 = (path[p].length - 2);
while (i2 >= 0) {
_nodePoint = new Point();
_nodePoint.x = path[p][i2];
_nodePoint.y = path[p][(i2 + 1)];
nodeArray.push(_nodePoint);
i2 = (i2 - 2);
};
};
var pointsArray:Array = FindSmoothPathBetweenNodes.getArrayOfPoints(nodeArray, true, speed);
fullPath.push(pointsArray);
}
public function scaleCar():void{
var yd:Number = (car.y - MIN_Y);
var ydp:Number = (yd / (MAX_Y - MIN_Y));
var cs:Number = ((ydp * (MAX_SCALE - MIN_SCALE)) + MIN_SCALE);
car.scaleX = (car.scaleY = cs);
}
public function get dx():Number{
return (fullPath[level][0].x);
}
public function init(data:Object):void{
var c:String;
var emptyArray:Array;
var i:int;
var len:int;
level = data.startingLevel;
targetLevel = data.targetLevel;
if (level > 13){
level = 13;
};
if (targetLevel > 13){
targetLevel = 13;
};
bBackward = false;
if (targetLevel < level){
bBackward = true;
level--;
};
theMapObjects = (getChildByName("mapObjects") as MovieClip);
mapObjectList = [];
var idx:int;
while (idx < theMapObjects.numChildren) {
mapObjectList.push(theMapObjects.getChildAt(idx));
idx++;
};
car = (mapObjects.getChildByName("car") as MovieClip);
for (c in data.completedLevels) {
if (wantGreenDots){
this[("levelDot" + data.completedLevels[c])].gotoAndStop(2);
};
};
speed = 4;
moveSpeed = 1;
targetAnimFrame = 19;
car.gotoAndStop(targetAnimFrame);
addEventListener(Event.ENTER_FRAME, onFrame);
addEventListener(Event.REMOVED_FROM_STAGE, onRemoveFromStage);
emptyArray = [];
fullPath = emptyArray;
i = 0;
while (i < path.length) {
generatePath(i);
i++;
};
moving = false;
newMove = true;
if (!bBackward){
car.x = path[level][0];
car.y = path[level][1];
} else {
len = path[level].length;
car.x = path[level][((len - 2) + 0)];
car.y = path[level][((len - 2) + 1)];
};
depthSort();
scaleCar();
if (targetLevel != level){
moveToNextCity();
};
}
public function move():void{
if (level >= fullPath.length){
level = (fullPath.length - 1);
};
if (fullPath[level].length == 0){
onMoveComplete();
} else {
angle = Math.atan2((dy - car.y), (dx - car.x));
car.x = fullPath[level][0].x;
car.y = fullPath[level][0].y;
fullPath[level].splice(0, 1);
};
if (newMove == false){
setDirectionFrame();
} else {
newMove = false;
};
depthSort();
scaleCar();
}
public function moveToNextCity():void{
moving = true;
newMove = true;
}
public function onFrame(e:Event):void{
var e = e;
var timer:Timer = new Timer(1000, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, function ():void{
var i:int;
if (moving){
i = 0;
while (i < moveSpeed) {
move();
i++;
};
};
});
timer.start();
}
public function get dy():Number{
return (fullPath[level][0].y);
}
public function purge():void{
mapObjectList = [];
}
private function depthSort():void{
mapObjectList.sortOn("y", Array.NUMERIC);
var i:int;
while (i < mapObjectList.length) {
theMapObjects.setChildIndex(mapObjectList[i], i);
i++;
};
}
public function onMoveComplete():void{
moving = false;
if (!bBackward){
level++;
if (level > 13){
level = 13;
};
if (level != targetLevel){
moveToNextCity();
};
} else {
level--;
if (level < 0){
level = 0;
};
if (level != (targetLevel - 1)){
moveToNextCity();
};
};
}
public function onRemoveFromStage(e:Event):void{
purge();
}
public function setDirectionFrame():void{
var inc:Number = ((Math.PI * 2) / directions);
targetAnimFrame = ((angle + Math.PI) / inc);
targetAnimFrame = Math.round(targetAnimFrame);
if (targetAnimFrame > directions){
targetAnimFrame = (targetAnimFrame - directions);
};
if (targetAnimFrame == 0){
targetAnimFrame = directions;
};
car.gotoAndStop(targetAnimFrame);
}
}
}//package
Section 253
//MapScreenFlash (MapScreenFlash)
package {
import flash.display.*;
public dynamic class MapScreenFlash extends MovieClip {
public var levelDot10:MovieClip;
public var levelDot11:MovieClip;
public var levelDot12:MovieClip;
public var levelDot13:MovieClip;
public var mapObjects:MovieClip;
public var levelDot1:MovieClip;
public var levelDot2:MovieClip;
public var levelDot4:MovieClip;
public var levelDot5:MovieClip;
public var levelDot6:MovieClip;
public var levelDot8:MovieClip;
public var levelDot3:MovieClip;
public var levelDot7:MovieClip;
public var levelDot0:MovieClip;
public var levelDot9:MovieClip;
}
}//package
Section 254
//MenuBackground (MenuBackground)
package {
import flash.display.*;
public dynamic class MenuBackground extends MovieClip {
}
}//package
Section 255
//MenuMap (MenuMap)
package {
import flash.display.*;
public dynamic class MenuMap extends MovieClip {
public var map_b10:SimpleButton;
public var map_b7:SimpleButton;
public var map_b11:SimpleButton;
public var map_b13:SimpleButton;
public var map_b18:SimpleButton;
public var map_b19:SimpleButton;
public var map_b14:SimpleButton;
public var map_b17:SimpleButton;
public var map_b12:SimpleButton;
public var map_b16:SimpleButton;
public var map_b20:SimpleButton;
public var map_b15:SimpleButton;
public var map_b1:SimpleButton;
public var map_b2:SimpleButton;
public var map_b3:SimpleButton;
public var map_b4:SimpleButton;
public var map_b5:SimpleButton;
public var map_b6:SimpleButton;
public var map_b8:SimpleButton;
public var map_b9:SimpleButton;
}
}//package
Section 256
//MenuRoad (MenuRoad)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class MenuRoad extends MovieClip {
public function MenuRoad(){
addFrameScript(0, frame1, 190, frame191);
}
function frame1(){
stop();
}
function frame191(){
stop();
}
}
}//package
Section 257
//MenuTopButtons (MenuTopButtons)
package {
import flash.display.*;
public dynamic class MenuTopButtons extends MovieClip {
}
}//package
Section 258
//ModalMenuCloud (ModalMenuCloud)
package {
import flash.display.*;
public dynamic class ModalMenuCloud extends MovieClip {
}
}//package
Section 259
//MoveButton (MoveButton)
package {
import contraption.menu.*;
public dynamic class MoveButton extends DashboardButton {
}
}//package
Section 260
//MoveMousePointer (MoveMousePointer)
package {
import flash.display.*;
public dynamic class MoveMousePointer extends MovieClip {
}
}//package
Section 261
//NewLevelButton (NewLevelButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class NewLevelButton extends Button {
public function NewLevelButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_EDITOR;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 262
//newMov (newMov)
package {
import flash.display.*;
public dynamic class newMov extends MovieClip {
}
}//package
Section 263
//NewUserButton (NewUserButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class NewUserButton extends Button {
public function NewUserButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.NEW_USER;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 264
//NextLevelButton (NextLevelButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class NextLevelButton extends Button {
public function NextLevelButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.LOAD_LEVEL;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 265
//NonPoweredWheelButton (NonPoweredWheelButton)
package {
import contraption.menu.*;
public dynamic class NonPoweredWheelButton extends DashboardButton {
}
}//package
Section 266
//NonPoweredWheelGraphic (NonPoweredWheelGraphic)
package {
import flash.display.*;
public dynamic class NonPoweredWheelGraphic extends MovieClip {
}
}//package
Section 267
//PlayGameButton (PlayGameButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class PlayGameButton extends Button {
public function PlayGameButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.MENU_BACK;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 268
//popupWinScreen (popupWinScreen)
package {
import flash.display.*;
public dynamic class popupWinScreen extends MovieClip {
}
}//package
Section 269
//PreviousMenuButton (PreviousMenuButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class PreviousMenuButton extends Button {
public function PreviousMenuButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.MENU_BACK;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 270
//Prius_Hatch_Mov (Prius_Hatch_Mov)
package {
import flash.display.*;
public dynamic class Prius_Hatch_Mov extends MovieClip {
}
}//package
Section 271
//Prius_Hatch_Mov1 (Prius_Hatch_Mov1)
package {
import flash.display.*;
public dynamic class Prius_Hatch_Mov1 extends MovieClip {
}
}//package
Section 272
//Prius_Track3 (Prius_Track3)
package {
import flash.media.*;
public dynamic class Prius_Track3 extends Sound {
}
}//package
Section 273
//Prius_Vector_Mov (Prius_Vector_Mov)
package {
import flash.display.*;
public dynamic class Prius_Vector_Mov extends MovieClip {
}
}//package
Section 274
//PriusLinkButton (PriusLinkButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class PriusLinkButton extends Button {
public function PriusLinkButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.RETURN_TO_MAIN_MENU;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 275
//PriusTransition (PriusTransition)
package {
import flash.events.*;
import contraption.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class PriusTransition extends Transition_Movie {
public function PriusTransition(){
addFrameScript(89, frame90);
}
function frame90(){
this.parent.removeChild(this);
this.stop();
}
}
}//package
Section 276
//ResetPasswordButton (ResetPasswordButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class ResetPasswordButton extends Button {
public function ResetPasswordButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.RESET_PASSWORD;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 277
//SaveButton (SaveButton)
package {
import contraption.menu.*;
public dynamic class SaveButton extends DashboardButton {
}
}//package
Section 278
//SavedContraptionButton (SavedContraptionButton)
package {
import contraption.menu.*;
public dynamic class SavedContraptionButton extends DashboardButton {
}
}//package
Section 279
//SavedContraptionsButton (SavedContraptionsButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
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 280
//SavedLevelsButton (SavedLevelsButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
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 281
//SkipTutorialButton (SkipTutorialButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import contraption.tutorials.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class SkipTutorialButton extends TutorialButton {
public function SkipTutorialButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = TutorialEvent.SKIP_TUTORIAL;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 282
//SmallBackButton (SmallBackButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class SmallBackButton extends Button {
public function SmallBackButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.MENU_BACK;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 283
//SmallCancelButton (SmallCancelButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class SmallCancelButton extends Button {
public function SmallCancelButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = MenuEvent.MENU_BACK;
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 284
//SmallSaveButton (SmallSaveButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class SmallSaveButton extends Button {
public function SmallSaveButton(){
addFrameScript(0, frame1);
}
function frame1(){
buttonWidth = 116;
buttonHeight = 42;
}
}
}//package
Section 285
//SolarPanelButton (SolarPanelButton)
package {
import contraption.menu.*;
public dynamic class SolarPanelButton extends DashboardButton {
}
}//package
Section 286
//SolarPanelGraphic (SolarPanelGraphic)
package {
import flash.display.*;
public dynamic class SolarPanelGraphic extends MovieClip {
public function SolarPanelGraphic(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4, 4, frame5);
}
function frame3(){
stop();
}
function frame1(){
stop();
}
function frame4(){
stop();
}
function frame5(){
stop();
}
function frame2(){
stop();
}
}
}//package
Section 287
//SolarPanelGraphicBG (SolarPanelGraphicBG)
package {
import flash.display.*;
public dynamic class SolarPanelGraphicBG extends MovieClip {
}
}//package
Section 288
//SolidRodButton (SolidRodButton)
package {
import contraption.menu.*;
public dynamic class SolidRodButton extends DashboardButton {
}
}//package
Section 289
//SolidRodGraphic (SolidRodGraphic)
package {
import flash.display.*;
public dynamic class SolidRodGraphic extends MovieClip {
}
}//package
Section 290
//SolidRodGraphicBG (SolidRodGraphicBG)
package {
import flash.display.*;
public dynamic class SolidRodGraphicBG extends MovieClip {
}
}//package
Section 291
//SoundOffButton (SoundOffButton)
package {
import flash.display.*;
public dynamic class SoundOffButton extends SimpleButton {
}
}//package
Section 292
//SoundOnButton (SoundOnButton)
package {
import flash.display.*;
public dynamic class SoundOnButton extends SimpleButton {
}
}//package
Section 293
//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 294
//StaticCircleButton (StaticCircleButton)
package {
import contraption.menu.*;
public dynamic class StaticCircleButton extends DashboardButton {
}
}//package
Section 295
//StaticSquareButton (StaticSquareButton)
package {
import contraption.menu.*;
public dynamic class StaticSquareButton extends DashboardButton {
}
}//package
Section 296
//StopButton (StopButton)
package {
import contraption.menu.*;
public dynamic class StopButton extends DashboardButton {
}
}//package
Section 297
//StopButtonPing (StopButtonPing)
package {
import flash.display.*;
public dynamic class StopButtonPing extends MovieClip {
public function StopButtonPing(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package
Section 298
//Sun_Vector_Mov (Sun_Vector_Mov)
package {
import flash.display.*;
public dynamic class Sun_Vector_Mov extends MovieClip {
}
}//package
Section 299
//Sun_VectorFG_Mov (Sun_VectorFG_Mov)
package {
import flash.display.*;
public dynamic class Sun_VectorFG_Mov extends MovieClip {
}
}//package
Section 300
//SunGoalObject (SunGoalObject)
package {
import flash.display.*;
public dynamic class SunGoalObject extends MovieClip {
}
}//package
Section 301
//TestLevelButton (TestLevelButton)
package {
import contraption.menu.*;
public dynamic class TestLevelButton extends DashboardButton {
}
}//package
Section 302
//Tree (Tree)
package {
import flash.display.*;
public dynamic class Tree extends MovieClip {
}
}//package
Section 303
//tut1DrawWater (tut1DrawWater)
package {
import contraption.tutorials.*;
public dynamic class tut1DrawWater extends AddedBlockBetweenWheelsOverlay {
}
}//package
Section 304
//tut1DrawWheel (tut1DrawWheel)
package {
import contraption.tutorials.*;
public dynamic class tut1DrawWheel extends AddedBlockOverlay {
}
}//package
Section 305
//tut1EnergyBar (tut1EnergyBar)
package {
import contraption.tutorials.*;
public dynamic class tut1EnergyBar extends TutorialOverlay {
}
}//package
Section 306
//tut1Goal (tut1Goal)
package {
import contraption.tutorials.*;
public dynamic class tut1Goal extends TutorialOverlay {
}
}//package
Section 307
//tut1PinkBall (tut1PinkBall)
package {
import contraption.tutorials.*;
public dynamic class tut1PinkBall extends TutorialOverlay {
}
}//package
Section 308
//tut1PressStart (tut1PressStart)
package {
import contraption.tutorials.*;
public dynamic class tut1PressStart extends PressStartOverlay {
}
}//package
Section 309
//tut1SelectSolar (tut1SelectSolar)
package {
import contraption.tutorials.*;
public dynamic class tut1SelectSolar extends SolarSelectedOverlay {
}
}//package
Section 310
//tut1SelectWheel (tut1SelectWheel)
package {
import contraption.tutorials.*;
public dynamic class tut1SelectWheel extends WheelSelectedOverlay {
}
}//package
Section 311
//tut1SolarDir (tut1SolarDir)
package {
import contraption.tutorials.*;
public dynamic class tut1SolarDir extends TutorialOverlay {
}
}//package
Section 312
//tut1Welcome (tut1Welcome)
package {
import contraption.tutorials.*;
public dynamic class tut1Welcome extends TutorialOverlay {
}
}//package
Section 313
//tut1Workshop (tut1Workshop)
package {
import contraption.tutorials.*;
public dynamic class tut1Workshop extends TutorialOverlay {
}
}//package
Section 314
//tut2DeleteFirstRod (tut2DeleteFirstRod)
package {
import contraption.tutorials.*;
public dynamic class tut2DeleteFirstRod extends DeleteBlockOverlay {
}
}//package
Section 315
//tut2DeleteSecondRod (tut2DeleteSecondRod)
package {
import contraption.tutorials.*;
public dynamic class tut2DeleteSecondRod extends DeleteBlockOverlay {
}
}//package
Section 316
//tut2FirstDrawWater (tut2FirstDrawWater)
package {
import contraption.tutorials.*;
public dynamic class tut2FirstDrawWater extends AddedBlockBetweenWheelsOverlay {
}
}//package
Section 317
//tut2FirstSelectDelete (tut2FirstSelectDelete)
package {
import contraption.tutorials.*;
public dynamic class tut2FirstSelectDelete extends DeleteSelectedOverlay {
}
}//package
Section 318
//tut2FirstSelectWater (tut2FirstSelectWater)
package {
import contraption.tutorials.*;
public dynamic class tut2FirstSelectWater extends HollowSelectedOverlay {
}
}//package
Section 319
//tut2FirstStop (tut2FirstStop)
package {
import contraption.tutorials.*;
public dynamic class tut2FirstStop extends PressStopOverlay {
}
}//package
Section 320
//tut2FirstTry (tut2FirstTry)
package {
import contraption.tutorials.*;
public dynamic class tut2FirstTry extends PressStartOverlay {
}
}//package
Section 321
//tut2SecondDrawWater (tut2SecondDrawWater)
package {
import contraption.tutorials.*;
public dynamic class tut2SecondDrawWater extends AddedBlockBetweenWheelsOverlay {
}
}//package
Section 322
//tut2SecondSelectDelete (tut2SecondSelectDelete)
package {
import contraption.tutorials.*;
public dynamic class tut2SecondSelectDelete extends DeleteSelectedOverlay {
}
}//package
Section 323
//tut2SecondSelectWater (tut2SecondSelectWater)
package {
import contraption.tutorials.*;
public dynamic class tut2SecondSelectWater extends HollowSelectedOverlay {
}
}//package
Section 324
//tut2SecondStop (tut2SecondStop)
package {
import contraption.tutorials.*;
public dynamic class tut2SecondStop extends PressStopOverlay {
}
}//package
Section 325
//tut2SecondTry (tut2SecondTry)
package {
import contraption.tutorials.*;
public dynamic class tut2SecondTry extends PressStartOverlay {
}
}//package
Section 326
//tut2ThirdTry (tut2ThirdTry)
package {
import contraption.tutorials.*;
public dynamic class tut2ThirdTry extends PressStartOverlay {
}
}//package
Section 327
//tut2Welcome (tut2Welcome)
package {
import contraption.tutorials.*;
public dynamic class tut2Welcome extends TutorialOverlay {
}
}//package
Section 328
//tut3Back (tut3Back)
package {
import contraption.tutorials.*;
public dynamic class tut3Back extends TutorialOverlay {
}
}//package
Section 329
//tut3Delete (tut3Delete)
package {
import contraption.tutorials.*;
public dynamic class tut3Delete extends TutorialOverlay {
}
}//package
Section 330
//tut3Goodbye (tut3Goodbye)
package {
import contraption.tutorials.*;
public dynamic class tut3Goodbye extends TutorialOverlay {
}
}//package
Section 331
//tut3Move (tut3Move)
package {
import contraption.tutorials.*;
public dynamic class tut3Move extends TutorialOverlay {
}
}//package
Section 332
//tut3NonPowerWheel (tut3NonPowerWheel)
package {
import contraption.tutorials.*;
public dynamic class tut3NonPowerWheel extends TutorialOverlay {
}
}//package
Section 333
//tut3Save (tut3Save)
package {
import contraption.tutorials.*;
public dynamic class tut3Save extends TutorialOverlay {
}
}//package
Section 334
//tut3Solar (tut3Solar)
package {
import contraption.tutorials.*;
public dynamic class tut3Solar extends TutorialOverlay {
}
}//package
Section 335
//tut3Start (tut3Start)
package {
import contraption.tutorials.*;
public dynamic class tut3Start extends TutorialOverlay {
}
}//package
Section 336
//tut3Water (tut3Water)
package {
import contraption.tutorials.*;
public dynamic class tut3Water extends TutorialOverlay {
}
}//package
Section 337
//tut3Wheels (tut3Wheels)
package {
import contraption.tutorials.*;
public dynamic class tut3Wheels extends TutorialOverlay {
}
}//package
Section 338
//tut3Wood (tut3Wood)
package {
import contraption.tutorials.*;
public dynamic class tut3Wood extends TutorialOverlay {
}
}//package
Section 339
//tut3Zoom (tut3Zoom)
package {
import contraption.tutorials.*;
public dynamic class tut3Zoom extends TutorialOverlay {
}
}//package
Section 340
//tutLocked (tutLocked)
package {
import contraption.tutorials.*;
public dynamic class tutLocked extends TutorialOverlay {
}
}//package
Section 341
//TutorialNextButton (TutorialNextButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import contraption.tutorials.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
public dynamic class TutorialNextButton extends TutorialButton {
public function TutorialNextButton(){
addFrameScript(0, frame1);
}
function frame1(){
downEvent = TutorialEvent.FINISHED_OVERLAY;
buttonWidth = 56;
buttonHeight = 42;
}
}
}//package
Section 342
//UpdateUserInfoButton (UpdateUserInfoButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
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 343
//UpdateUserInfoSubmitButton (UpdateUserInfoSubmitButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
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 344
//UserGenLevelsButton (UserGenLevelsButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
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 345
//WinScreen (WinScreen)
package {
import flash.display.*;
public dynamic class WinScreen extends MovieClip {
}
}//package
Section 346
//YourSavedContraptionsButton (YourSavedContraptionsButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
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 347
//YourSavedLevelsButton (YourSavedLevelsButton)
package {
import flash.events.*;
import contraption.menu.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
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 348
//ZoomInButton (ZoomInButton)
package {
import contraption.menu.*;
public dynamic class ZoomInButton extends DashboardButton {
}
}//package
Section 349
//ZoomOutButton (ZoomOutButton)
package {
import contraption.menu.*;
public dynamic class ZoomOutButton extends DashboardButton {
}
}//package