Section 1
//Beam_91 (BalloonHack_fla.Beam_91)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Beam_91 extends MovieClip {
public function Beam_91(){
addFrameScript(93, this.frame94, 107, this.frame108);
}
function frame94(){
gotoAndPlay("beamRunning");
}
function frame108(){
stop();
}
}
}//package BalloonHack_fla
Section 2
//BikerAnim_146 (BalloonHack_fla.BikerAnim_146)
package BalloonHack_fla {
import flash.events.*;
import flash.display.*;
public dynamic class BikerAnim_146 extends MovieClip {
public var skipFrames:Number;
public var skipCounter:Number;
public function BikerAnim_146(){
addFrameScript(0, this.frame1, 96, this.frame97);
}
public function resolveEnterFrame(_arg1:Event):void{
if (this.skipCounter > 0){
this.skipCounter--;
return;
};
if (currentFrame == totalFrames){
return;
};
gotoAndStop((currentFrame + 1));
this.skipCounter = this.skipFrames;
}
function frame1(){
stop();
addEventListener(Event.ENTER_FRAME, this.resolveEnterFrame);
this.skipFrames = 3;
this.skipCounter = this.skipFrames;
}
function frame97(){
gotoAndStop(1);
}
}
}//package BalloonHack_fla
Section 3
//BootAnim_170 (BalloonHack_fla.BootAnim_170)
package BalloonHack_fla {
import flash.events.*;
import flash.display.*;
public dynamic class BootAnim_170 extends MovieClip {
public var skipFrames:Number;
public var skipCounter:Number;
public function BootAnim_170(){
addFrameScript(0, this.frame1, 38, this.frame39);
}
public function resolveEnterFrame(_arg1:Event):void{
if (this.skipCounter > 0){
this.skipCounter--;
return;
};
if (currentFrame == totalFrames){
return;
};
gotoAndStop((currentFrame + 1));
this.skipCounter = this.skipFrames;
}
function frame39(){
gotoAndPlay(1);
}
function frame1(){
stop();
addEventListener(Event.ENTER_FRAME, this.resolveEnterFrame);
this.skipFrames = 3;
this.skipCounter = this.skipFrames;
}
}
}//package BalloonHack_fla
Section 4
//CactusAnim_184 (BalloonHack_fla.CactusAnim_184)
package BalloonHack_fla {
import flash.events.*;
import flash.display.*;
public dynamic class CactusAnim_184 extends MovieClip {
public var skipFrames:Number;
public var skipCounter:Number;
public function CactusAnim_184(){
addFrameScript(0, this.frame1, 42, this.frame43);
}
public function resolveEnterFrame(_arg1:Event):void{
if (this.skipCounter > 0){
this.skipCounter--;
return;
};
if (currentFrame == totalFrames){
return;
};
gotoAndStop((currentFrame + 1));
this.skipCounter = this.skipFrames;
}
function frame1(){
stop();
addEventListener(Event.ENTER_FRAME, this.resolveEnterFrame);
this.skipFrames = 3;
this.skipCounter = this.skipFrames;
}
function frame43(){
gotoAndPlay(1);
}
}
}//package BalloonHack_fla
Section 5
//CatAnim_123 (BalloonHack_fla.CatAnim_123)
package BalloonHack_fla {
import flash.events.*;
import flash.display.*;
public dynamic class CatAnim_123 extends MovieClip {
public var skipFrames:Number;
public var skipCounter:Number;
public function CatAnim_123(){
addFrameScript(0, this.frame1, 19, this.frame20);
}
public function resolveEnterFrame(_arg1:Event):void{
if (this.skipCounter > 0){
this.skipCounter--;
return;
};
if (currentFrame == totalFrames){
return;
};
gotoAndStop((currentFrame + 1));
this.skipCounter = this.skipFrames;
}
function frame1(){
stop();
addEventListener(Event.ENTER_FRAME, this.resolveEnterFrame);
this.skipFrames = 3;
this.skipCounter = this.skipFrames;
}
function frame20(){
gotoAndPlay(1);
}
}
}//package BalloonHack_fla
Section 6
//EditButton_200 (BalloonHack_fla.EditButton_200)
package BalloonHack_fla {
import flash.display.*;
public dynamic class EditButton_200 extends MovieClip {
public function EditButton_200(){
addFrameScript(0, this.frame1, 28, this.frame29);
}
function frame29(){
stop();
}
function frame1(){
stop();
}
}
}//package BalloonHack_fla
Section 7
//Electricity_100 (BalloonHack_fla.Electricity_100)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Electricity_100 extends MovieClip {
public function Electricity_100(){
addFrameScript(40, this.frame41);
}
function frame41(){
gotoAndPlay("electricityStart");
}
}
}//package BalloonHack_fla
Section 8
//EyeAnim_145 (BalloonHack_fla.EyeAnim_145)
package BalloonHack_fla {
import flash.events.*;
import flash.display.*;
public dynamic class EyeAnim_145 extends MovieClip {
public var skipFrames:Number;
public var skipCounter:Number;
public function EyeAnim_145(){
addFrameScript(0, this.frame1, 400, this.frame401);
}
public function resolveEnterFrame(_arg1:Event):void{
if (this.skipCounter > 0){
this.skipCounter--;
return;
};
if (currentFrame == totalFrames){
return;
};
gotoAndStop((currentFrame + 1));
this.skipCounter = this.skipFrames;
}
function frame1(){
stop();
addEventListener(Event.ENTER_FRAME, this.resolveEnterFrame);
this.skipFrames = 3;
this.skipCounter = this.skipFrames;
}
function frame401(){
gotoAndPlay(1);
}
}
}//package BalloonHack_fla
Section 9
//HomeButton_26 (BalloonHack_fla.HomeButton_26)
package BalloonHack_fla {
import flash.display.*;
public dynamic class HomeButton_26 extends MovieClip {
public function HomeButton_26(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 10
//HowToPlayButton_199 (BalloonHack_fla.HowToPlayButton_199)
package BalloonHack_fla {
import flash.display.*;
public dynamic class HowToPlayButton_199 extends MovieClip {
public function HowToPlayButton_199(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 11
//JuicyFruitLinkButton_233 (BalloonHack_fla.JuicyFruitLinkButton_233)
package BalloonHack_fla {
import flash.display.*;
public dynamic class JuicyFruitLinkButton_233 extends MovieClip {
public function JuicyFruitLinkButton_233(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 12
//Level10Button_212 (BalloonHack_fla.Level10Button_212)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level10Button_212 extends MovieClip {
public function Level10Button_212(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 13
//Level11Button_223 (BalloonHack_fla.Level11Button_223)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level11Button_223 extends MovieClip {
public function Level11Button_223(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 14
//Level12Button_224 (BalloonHack_fla.Level12Button_224)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level12Button_224 extends MovieClip {
public function Level12Button_224(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 15
//Level13Button_225 (BalloonHack_fla.Level13Button_225)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level13Button_225 extends MovieClip {
public function Level13Button_225(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 16
//Level14Button_226 (BalloonHack_fla.Level14Button_226)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level14Button_226 extends MovieClip {
public function Level14Button_226(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 17
//Level15Button_227 (BalloonHack_fla.Level15Button_227)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level15Button_227 extends MovieClip {
public function Level15Button_227(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 18
//Level16Button_213 (BalloonHack_fla.Level16Button_213)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level16Button_213 extends MovieClip {
public function Level16Button_213(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 19
//Level17Button_214 (BalloonHack_fla.Level17Button_214)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level17Button_214 extends MovieClip {
public function Level17Button_214(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 20
//Level18Button_215 (BalloonHack_fla.Level18Button_215)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level18Button_215 extends MovieClip {
public function Level18Button_215(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 21
//Level19Button_216 (BalloonHack_fla.Level19Button_216)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level19Button_216 extends MovieClip {
public function Level19Button_216(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 22
//Level1Button_218 (BalloonHack_fla.Level1Button_218)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level1Button_218 extends MovieClip {
public function Level1Button_218(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 23
//Level20Button_217 (BalloonHack_fla.Level20Button_217)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level20Button_217 extends MovieClip {
public function Level20Button_217(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 24
//Level2Button_219 (BalloonHack_fla.Level2Button_219)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level2Button_219 extends MovieClip {
public function Level2Button_219(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 25
//Level3Button_220 (BalloonHack_fla.Level3Button_220)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level3Button_220 extends MovieClip {
public function Level3Button_220(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 26
//Level4Button_221 (BalloonHack_fla.Level4Button_221)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level4Button_221 extends MovieClip {
public function Level4Button_221(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 27
//Level5Button_222 (BalloonHack_fla.Level5Button_222)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level5Button_222 extends MovieClip {
public function Level5Button_222(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 28
//Level6Button_208 (BalloonHack_fla.Level6Button_208)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level6Button_208 extends MovieClip {
public function Level6Button_208(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 29
//Level7Button_209 (BalloonHack_fla.Level7Button_209)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level7Button_209 extends MovieClip {
public function Level7Button_209(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 30
//Level8Button_210 (BalloonHack_fla.Level8Button_210)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level8Button_210 extends MovieClip {
public function Level8Button_210(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 31
//Level9Button_211 (BalloonHack_fla.Level9Button_211)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Level9Button_211 extends MovieClip {
public function Level9Button_211(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package BalloonHack_fla
Section 32
//NextButton_204 (BalloonHack_fla.NextButton_204)
package BalloonHack_fla {
import flash.display.*;
public dynamic class NextButton_204 extends MovieClip {
public function NextButton_204(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 33
//NextLevelButton_196 (BalloonHack_fla.NextLevelButton_196)
package BalloonHack_fla {
import flash.display.*;
public dynamic class NextLevelButton_196 extends MovieClip {
public function NextLevelButton_196(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 34
//NoButton_192 (BalloonHack_fla.NoButton_192)
package BalloonHack_fla {
import flash.display.*;
public dynamic class NoButton_192 extends MovieClip {
public function NoButton_192(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 35
//Particles_92 (BalloonHack_fla.Particles_92)
package BalloonHack_fla {
import flash.display.*;
public dynamic class Particles_92 extends MovieClip {
public function Particles_92(){
addFrameScript(93, this.frame94, 107, this.frame108);
}
function frame94(){
gotoAndPlay("beamRunning");
}
function frame108(){
stop();
}
}
}//package BalloonHack_fla
Section 36
//PauseButton_232 (BalloonHack_fla.PauseButton_232)
package BalloonHack_fla {
import flash.display.*;
public dynamic class PauseButton_232 extends MovieClip {
public function PauseButton_232(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 37
//PlayButton_205 (BalloonHack_fla.PlayButton_205)
package BalloonHack_fla {
import flash.display.*;
public dynamic class PlayButton_205 extends MovieClip {
public function PlayButton_205(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 38
//PlayNowButton_198 (BalloonHack_fla.PlayNowButton_198)
package BalloonHack_fla {
import flash.display.*;
public dynamic class PlayNowButton_198 extends MovieClip {
public function PlayNowButton_198(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 39
//PrevButton_203 (BalloonHack_fla.PrevButton_203)
package BalloonHack_fla {
import flash.display.*;
public dynamic class PrevButton_203 extends MovieClip {
public function PrevButton_203(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 40
//puff_82 (BalloonHack_fla.puff_82)
package BalloonHack_fla {
import flash.display.*;
public dynamic class puff_82 extends MovieClip {
public function puff_82(){
addFrameScript(35, this.frame36);
}
function frame36(){
stop();
}
}
}//package BalloonHack_fla
Section 41
//QuitButton_105 (BalloonHack_fla.QuitButton_105)
package BalloonHack_fla {
import flash.display.*;
public dynamic class QuitButton_105 extends MovieClip {
public function QuitButton_105(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 42
//RestartButton_106 (BalloonHack_fla.RestartButton_106)
package BalloonHack_fla {
import flash.display.*;
public dynamic class RestartButton_106 extends MovieClip {
public function RestartButton_106(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 43
//ResumeButton_120 (BalloonHack_fla.ResumeButton_120)
package BalloonHack_fla {
import flash.display.*;
public dynamic class ResumeButton_120 extends MovieClip {
public function ResumeButton_120(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 44
//RetryButton_121 (BalloonHack_fla.RetryButton_121)
package BalloonHack_fla {
import flash.display.*;
public dynamic class RetryButton_121 extends MovieClip {
public function RetryButton_121(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 45
//TestLevelButton_117 (BalloonHack_fla.TestLevelButton_117)
package BalloonHack_fla {
import flash.display.*;
public dynamic class TestLevelButton_117 extends MovieClip {
public function TestLevelButton_117(){
addFrameScript(0, this.frame1, 28, this.frame29);
}
function frame29(){
stop();
}
function frame1(){
stop();
}
}
}//package BalloonHack_fla
Section 46
//TopHatAnim_171 (BalloonHack_fla.TopHatAnim_171)
package BalloonHack_fla {
import flash.events.*;
import flash.display.*;
public dynamic class TopHatAnim_171 extends MovieClip {
public var skipFrames:Number;
public var skipCounter:Number;
public function TopHatAnim_171(){
addFrameScript(0, this.frame1);
}
public function resolveEnterFrame(_arg1:Event):void{
if (this.skipCounter > 0){
this.skipCounter--;
return;
};
if (currentFrame == totalFrames){
return;
};
gotoAndStop((currentFrame + 1));
this.skipCounter = this.skipFrames;
}
function frame1(){
stop();
addEventListener(Event.ENTER_FRAME, this.resolveEnterFrame);
this.skipFrames = 3;
this.skipCounter = this.skipFrames;
}
}
}//package BalloonHack_fla
Section 47
//UFOBeam_90 (BalloonHack_fla.UFOBeam_90)
package BalloonHack_fla {
import flash.display.*;
public dynamic class UFOBeam_90 extends MovieClip {
public var layer1:MovieClip;
public var layer2:MovieClip;
public var layer4:MovieClip;
public var layer3:MovieClip;
public function UFOBeam_90(){
addFrameScript(0, this.frame1);
}
function frame1(){
}
}
}//package BalloonHack_fla
Section 48
//ViewXMLButton_118 (BalloonHack_fla.ViewXMLButton_118)
package BalloonHack_fla {
import flash.display.*;
public dynamic class ViewXMLButton_118 extends MovieClip {
public function ViewXMLButton_118(){
addFrameScript(0, this.frame1, 28, this.frame29);
}
function frame29(){
stop();
}
function frame1(){
stop();
}
}
}//package BalloonHack_fla
Section 49
//YesButton_191 (BalloonHack_fla.YesButton_191)
package BalloonHack_fla {
import flash.display.*;
public dynamic class YesButton_191 extends MovieClip {
public function YesButton_191(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package BalloonHack_fla
Section 50
//b2CircleShape (Box2D.Collision.Shapes.b2CircleShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2CircleShape extends b2Shape {
b2internal var m_p:b2Vec2;
public function b2CircleShape(radius:Number=0){
m_p = new b2Vec2();
super();
m_type = e_circleShape;
m_radius = radius;
}
override public function ComputeSubmergedArea(normal:b2Vec2, offset:Number, xf:b2Transform, c:b2Vec2):Number{
var area:Number;
var p:b2Vec2 = b2Math.MulX(xf, m_p);
var l:Number = -((b2Math.Dot(normal, p) - offset));
if (l < (-(m_radius) + Number.MIN_VALUE)){
return (0);
};
if (l > m_radius){
c.SetV(p);
return (((Math.PI * m_radius) * m_radius));
};
var r2:Number = (m_radius * m_radius);
var l2:Number = (l * l);
area = ((r2 * (Math.asin((l / m_radius)) + (Math.PI / 2))) + (l * Math.sqrt((r2 - l2))));
var com:Number = (((-2 / 3) * Math.pow((r2 - l2), 1.5)) / area);
c.x = (p.x + (normal.x * com));
c.y = (p.y + (normal.y * com));
return (area);
}
override public function TestPoint(transform:b2Transform, p:b2Vec2):Boolean{
var tMat:b2Mat22 = transform.R;
var dX:Number = (transform.position.x + ((tMat.col1.x * m_p.x) + (tMat.col2.x * m_p.y)));
var dY:Number = (transform.position.y + ((tMat.col1.y * m_p.x) + (tMat.col2.y * m_p.y)));
dX = (p.x - dX);
dY = (p.y - dY);
return ((((dX * dX) + (dY * dY)) <= (m_radius * m_radius)));
}
public function GetRadius():Number{
return (m_radius);
}
override public function Set(other:b2Shape):void{
var other2:b2CircleShape;
super.Set(other);
if ((other is b2CircleShape)){
other2 = (other as b2CircleShape);
m_p.SetV(other2.m_p);
};
}
override public function ComputeMass(massData:b2MassData, density:Number):void{
massData.mass = (((density * b2Settings.b2_pi) * m_radius) * m_radius);
massData.center.SetV(m_p);
massData.I = (massData.mass * (((0.5 * m_radius) * m_radius) + ((m_p.x * m_p.x) + (m_p.y * m_p.y))));
}
override public function RayCast(output:b2RayCastOutput, input:b2RayCastInput, transform:b2Transform):Boolean{
var sY:Number;
var tMat:b2Mat22 = transform.R;
var positionX:Number = (transform.position.x + ((tMat.col1.x * m_p.x) + (tMat.col2.x * m_p.y)));
var positionY:Number = (transform.position.y + ((tMat.col1.y * m_p.x) + (tMat.col2.y * m_p.y)));
var sX:Number = (input.p1.x - positionX);
sY = (input.p1.y - positionY);
var b:Number = (((sX * sX) + (sY * sY)) - (m_radius * m_radius));
var rX:Number = (input.p2.x - input.p1.x);
var rY:Number = (input.p2.y - input.p1.y);
var c:Number = ((sX * rX) + (sY * rY));
var rr:Number = ((rX * rX) + (rY * rY));
var sigma:Number = ((c * c) - (rr * b));
if ((((sigma < 0)) || ((rr < Number.MIN_VALUE)))){
return (false);
};
var a:Number = -((c + Math.sqrt(sigma)));
if ((((0 <= a)) && ((a <= (input.maxFraction * rr))))){
a = (a / rr);
output.fraction = a;
output.normal.x = (sX + (a * rX));
output.normal.y = (sY + (a * rY));
output.normal.Normalize();
return (true);
};
return (false);
}
public function SetLocalPosition(position:b2Vec2):void{
m_p.SetV(position);
}
public function SetRadius(radius:Number):void{
m_radius = radius;
}
override public function Copy():b2Shape{
var s:b2Shape = new b2CircleShape();
s.Set(this);
return (s);
}
override public function ComputeAABB(aabb:b2AABB, transform:b2Transform):void{
var tMat:b2Mat22 = transform.R;
var pX:Number = (transform.position.x + ((tMat.col1.x * m_p.x) + (tMat.col2.x * m_p.y)));
var pY:Number = (transform.position.y + ((tMat.col1.y * m_p.x) + (tMat.col2.y * m_p.y)));
aabb.lowerBound.Set((pX - m_radius), (pY - m_radius));
aabb.upperBound.Set((pX + m_radius), (pY + m_radius));
}
public function GetLocalPosition():b2Vec2{
return (m_p);
}
}
}//package Box2D.Collision.Shapes
Section 51
//b2EdgeShape (Box2D.Collision.Shapes.b2EdgeShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2EdgeShape extends b2Shape {
b2internal var m_normal:b2Vec2;
b2internal var m_cornerConvex1:Boolean;
b2internal var m_cornerConvex2:Boolean;
b2internal var m_cornerDir1:b2Vec2;
b2internal var m_v1:b2Vec2;
b2internal var m_v2:b2Vec2;
private var s_supportVec:b2Vec2;
b2internal var m_coreV1:b2Vec2;
b2internal var m_coreV2:b2Vec2;
b2internal var m_cornerDir2:b2Vec2;
b2internal var m_nextEdge:b2EdgeShape;
b2internal var m_direction:b2Vec2;
b2internal var m_prevEdge:b2EdgeShape;
b2internal var m_length:Number;
public function b2EdgeShape(v1:b2Vec2, v2:b2Vec2){
s_supportVec = new b2Vec2();
m_v1 = new b2Vec2();
m_v2 = new b2Vec2();
m_coreV1 = new b2Vec2();
m_coreV2 = new b2Vec2();
m_normal = new b2Vec2();
m_direction = new b2Vec2();
m_cornerDir1 = new b2Vec2();
m_cornerDir2 = new b2Vec2();
super();
m_type = e_edgeShape;
m_prevEdge = null;
m_nextEdge = null;
m_v1 = v1;
m_v2 = v2;
m_direction.Set((m_v2.x - m_v1.x), (m_v2.y - m_v1.y));
m_length = m_direction.Normalize();
m_normal.Set(m_direction.y, -(m_direction.x));
m_coreV1.Set(((-(b2Settings.b2_toiSlop) * (m_normal.x - m_direction.x)) + m_v1.x), ((-(b2Settings.b2_toiSlop) * (m_normal.y - m_direction.y)) + m_v1.y));
m_coreV2.Set(((-(b2Settings.b2_toiSlop) * (m_normal.x + m_direction.x)) + m_v2.x), ((-(b2Settings.b2_toiSlop) * (m_normal.y + m_direction.y)) + m_v2.y));
m_cornerDir1 = m_normal;
m_cornerDir2.Set(-(m_normal.x), -(m_normal.y));
}
override public function ComputeSubmergedArea(normal:b2Vec2, offset:Number, xf:b2Transform, c:b2Vec2):Number{
var v0:b2Vec2 = new b2Vec2((normal.x * offset), (normal.y * offset));
var v1:b2Vec2 = b2Math.MulX(xf, m_v1);
var v2:b2Vec2 = b2Math.MulX(xf, m_v2);
var d1:Number = (b2Math.Dot(normal, v1) - offset);
var d2:Number = (b2Math.Dot(normal, v2) - offset);
if (d1 > 0){
if (d2 > 0){
return (0);
};
v1.x = (((-(d2) / (d1 - d2)) * v1.x) + ((d1 / (d1 - d2)) * v2.x));
v1.y = (((-(d2) / (d1 - d2)) * v1.y) + ((d1 / (d1 - d2)) * v2.y));
} else {
if (d2 > 0){
v2.x = (((-(d2) / (d1 - d2)) * v1.x) + ((d1 / (d1 - d2)) * v2.x));
v2.y = (((-(d2) / (d1 - d2)) * v1.y) + ((d1 / (d1 - d2)) * v2.y));
};
};
c.x = (((v0.x + v1.x) + v2.x) / 3);
c.y = (((v0.y + v1.y) + v2.y) / 3);
return ((0.5 * (((v1.x - v0.x) * (v2.y - v0.y)) - ((v1.y - v0.y) * (v2.x - v0.x)))));
}
override public function ComputeAABB(aabb:b2AABB, transform:b2Transform):void{
var v1X:Number;
var v1Y:Number;
var v2X:Number;
var v2Y:Number;
var tMat:b2Mat22 = transform.R;
v1X = (transform.position.x + ((tMat.col1.x * m_v1.x) + (tMat.col2.x * m_v1.y)));
v1Y = (transform.position.y + ((tMat.col1.y * m_v1.x) + (tMat.col2.y * m_v1.y)));
v2X = (transform.position.x + ((tMat.col1.x * m_v2.x) + (tMat.col2.x * m_v2.y)));
v2Y = (transform.position.y + ((tMat.col1.y * m_v2.x) + (tMat.col2.y * m_v2.y)));
if (v1X < v2X){
aabb.lowerBound.x = v1X;
aabb.upperBound.x = v2X;
} else {
aabb.lowerBound.x = v2X;
aabb.upperBound.x = v1X;
};
if (v1Y < v2Y){
aabb.lowerBound.y = v1Y;
aabb.upperBound.y = v2Y;
} else {
aabb.lowerBound.y = v2Y;
aabb.upperBound.y = v1Y;
};
}
public function GetCorner1Vector():b2Vec2{
return (m_cornerDir1);
}
public function GetCorner2Vector():b2Vec2{
return (m_cornerDir2);
}
public function GetDirectionVector():b2Vec2{
return (m_direction);
}
public function GetCoreVertex1():b2Vec2{
return (m_coreV1);
}
public function GetCoreVertex2():b2Vec2{
return (m_coreV2);
}
public function GetFirstVertex(xf:b2Transform):b2Vec2{
var tMat:b2Mat22 = xf.R;
return (new b2Vec2((xf.position.x + ((tMat.col1.x * m_coreV1.x) + (tMat.col2.x * m_coreV1.y))), (xf.position.y + ((tMat.col1.y * m_coreV1.x) + (tMat.col2.y * m_coreV1.y)))));
}
public function GetNormalVector():b2Vec2{
return (m_normal);
}
public function GetNextEdge():b2EdgeShape{
return (m_nextEdge);
}
override public function RayCast(output:b2RayCastOutput, input:b2RayCastInput, transform:b2Transform):Boolean{
var tMat:b2Mat22;
var bX:Number;
var bY:Number;
var a:Number;
var mu2:Number;
var nLen:Number;
var rX:Number = (input.p2.x - input.p1.x);
var rY:Number = (input.p2.y - input.p1.y);
tMat = transform.R;
var v1X:Number = (transform.position.x + ((tMat.col1.x * m_v1.x) + (tMat.col2.x * m_v1.y)));
var v1Y:Number = (transform.position.y + ((tMat.col1.y * m_v1.x) + (tMat.col2.y * m_v1.y)));
var nX:Number = ((transform.position.y + ((tMat.col1.y * m_v2.x) + (tMat.col2.y * m_v2.y))) - v1Y);
var nY:Number = -(((transform.position.x + ((tMat.col1.x * m_v2.x) + (tMat.col2.x * m_v2.y))) - v1X));
var k_slop:Number = (100 * Number.MIN_VALUE);
var denom:Number = -(((rX * nX) + (rY * nY)));
if (denom > k_slop){
bX = (input.p1.x - v1X);
bY = (input.p1.y - v1Y);
a = ((bX * nX) + (bY * nY));
if ((((0 <= a)) && ((a <= (input.maxFraction * denom))))){
mu2 = ((-(rX) * bY) + (rY * bX));
if (((((-(k_slop) * denom) <= mu2)) && ((mu2 <= (denom * (1 + k_slop)))))){
a = (a / denom);
output.fraction = a;
nLen = Math.sqrt(((nX * nX) + (nY * nY)));
output.normal.x = (nX / nLen);
output.normal.y = (nY / nLen);
return (true);
};
};
};
return (false);
}
override public function ComputeMass(massData:b2MassData, density:Number):void{
massData.mass = 0;
massData.center.SetV(m_v1);
massData.I = 0;
}
public function Corner1IsConvex():Boolean{
return (m_cornerConvex1);
}
public function Corner2IsConvex():Boolean{
return (m_cornerConvex2);
}
public function Support(xf:b2Transform, dX:Number, dY:Number):b2Vec2{
var tMat:b2Mat22 = xf.R;
var v1X:Number = (xf.position.x + ((tMat.col1.x * m_coreV1.x) + (tMat.col2.x * m_coreV1.y)));
var v1Y:Number = (xf.position.y + ((tMat.col1.y * m_coreV1.x) + (tMat.col2.y * m_coreV1.y)));
var v2X:Number = (xf.position.x + ((tMat.col1.x * m_coreV2.x) + (tMat.col2.x * m_coreV2.y)));
var v2Y:Number = (xf.position.y + ((tMat.col1.y * m_coreV2.x) + (tMat.col2.y * m_coreV2.y)));
if (((v1X * dX) + (v1Y * dY)) > ((v2X * dX) + (v2Y * dY))){
s_supportVec.x = v1X;
s_supportVec.y = v1Y;
} else {
s_supportVec.x = v2X;
s_supportVec.y = v2Y;
};
return (s_supportVec);
}
b2internal function SetNextEdge(edge:b2EdgeShape, core:b2Vec2, cornerDir:b2Vec2, convex:Boolean):void{
m_nextEdge = edge;
m_coreV2 = core;
m_cornerDir2 = cornerDir;
m_cornerConvex2 = convex;
}
public function GetPrevEdge():b2EdgeShape{
return (m_prevEdge);
}
public function GetVertex1():b2Vec2{
return (m_v1);
}
public function GetVertex2():b2Vec2{
return (m_v2);
}
b2internal function SetPrevEdge(edge:b2EdgeShape, core:b2Vec2, cornerDir:b2Vec2, convex:Boolean):void{
m_prevEdge = edge;
m_coreV1 = core;
m_cornerDir1 = cornerDir;
m_cornerConvex1 = convex;
}
public function GetLength():Number{
return (m_length);
}
override public function TestPoint(transform:b2Transform, p:b2Vec2):Boolean{
return (false);
}
}
}//package Box2D.Collision.Shapes
Section 52
//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 53
//b2PolygonShape (Box2D.Collision.Shapes.b2PolygonShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2PolygonShape extends b2Shape {
b2internal var m_vertexCount:int;
b2internal var m_vertices:Array;
b2internal var m_centroid:b2Vec2;
b2internal var m_normals:Array;
private static var s_mat:b2Mat22 = new b2Mat22();
public function b2PolygonShape(){
super();
m_type = e_polygonShape;
m_centroid = new b2Vec2();
m_vertices = new Array();
m_normals = new Array();
}
override public function Set(other:b2Shape):void{
var other2:b2PolygonShape;
var i:int;
super.Set(other);
if ((other is b2PolygonShape)){
other2 = (other as b2PolygonShape);
m_centroid.SetV(other2.m_centroid);
m_vertexCount = other2.m_vertexCount;
Reserve(m_vertexCount);
i = 0;
while (i < m_vertexCount) {
m_vertices[i].SetV(other2.m_vertices[i]);
m_normals[i].SetV(other2.m_normals[i]);
i++;
};
};
}
override public function ComputeAABB(aabb:b2AABB, xf:b2Transform):void{
var vX:Number;
var vY:Number;
var tMat:b2Mat22 = xf.R;
var tVec:b2Vec2 = m_vertices[0];
var lowerX:Number = (xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var lowerY:Number = (xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
var upperX:Number = lowerX;
var upperY:Number = lowerY;
var i = 1;
while (i < m_vertexCount) {
tVec = m_vertices[i];
vX = (xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
vY = (xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
lowerX = ((lowerX < vX)) ? lowerX : vX;
lowerY = ((lowerY < vY)) ? lowerY : vY;
upperX = ((upperX > vX)) ? upperX : vX;
upperY = ((upperY > vY)) ? upperY : vY;
i++;
};
aabb.lowerBound.x = (lowerX - m_radius);
aabb.lowerBound.y = (lowerY - m_radius);
aabb.upperBound.x = (upperX + m_radius);
aabb.upperBound.y = (upperY + m_radius);
}
override public function ComputeSubmergedArea(normal:b2Vec2, offset:Number, xf:b2Transform, c:b2Vec2):Number{
var i:int;
var p3:b2Vec2;
var isSubmerged:Boolean;
var md:b2MassData;
var triangleArea:Number;
var normalL:b2Vec2 = b2Math.MulTMV(xf.R, normal);
var offsetL:Number = (offset - b2Math.Dot(normal, xf.position));
var depths:Array = new Array();
var diveCount:int;
var intoIndex = -1;
var outoIndex = -1;
var lastSubmerged:Boolean;
i = 0;
while (i < m_vertexCount) {
depths[i] = (b2Math.Dot(normalL, m_vertices[i]) - offsetL);
isSubmerged = (depths[i] < -(Number.MIN_VALUE));
if (i > 0){
if (isSubmerged){
if (!lastSubmerged){
intoIndex = (i - 1);
diveCount++;
};
} else {
if (lastSubmerged){
outoIndex = (i - 1);
diveCount++;
};
};
};
lastSubmerged = isSubmerged;
i++;
};
switch (diveCount){
case 0:
if (lastSubmerged){
md = new b2MassData();
ComputeMass(md, 1);
c.SetV(b2Math.MulX(xf, md.center));
return (md.mass);
};
return (0);
case 1:
if (intoIndex == -1){
intoIndex = (m_vertexCount - 1);
} else {
outoIndex = (m_vertexCount - 1);
};
break;
};
var intoIndex2:int = ((intoIndex + 1) % m_vertexCount);
var outoIndex2:int = ((outoIndex + 1) % m_vertexCount);
var intoLamdda:Number = ((0 - depths[intoIndex]) / (depths[intoIndex2] - depths[intoIndex]));
var outoLamdda:Number = ((0 - depths[outoIndex]) / (depths[outoIndex2] - depths[outoIndex]));
var intoVec:b2Vec2 = new b2Vec2(((m_vertices[intoIndex].x * (1 - intoLamdda)) + (m_vertices[intoIndex2].x * intoLamdda)), ((m_vertices[intoIndex].y * (1 - intoLamdda)) + (m_vertices[intoIndex2].y * intoLamdda)));
var outoVec:b2Vec2 = new b2Vec2(((m_vertices[outoIndex].x * (1 - outoLamdda)) + (m_vertices[outoIndex2].x * outoLamdda)), ((m_vertices[outoIndex].y * (1 - outoLamdda)) + (m_vertices[outoIndex2].y * outoLamdda)));
var area:Number = 0;
var center:b2Vec2 = new b2Vec2();
var p2:b2Vec2 = m_vertices[intoIndex2];
i = intoIndex2;
while (i != outoIndex2) {
i = ((i + 1) % m_vertexCount);
if (i == outoIndex2){
p3 = outoVec;
} else {
p3 = m_vertices[i];
};
triangleArea = (0.5 * (((p2.x - intoVec.x) * (p3.y - intoVec.y)) - ((p2.y - intoVec.y) * (p3.x - intoVec.x))));
area = (area + triangleArea);
center.x = (center.x + ((triangleArea * ((intoVec.x + p2.x) + p3.x)) / 3));
center.y = (center.y + ((triangleArea * ((intoVec.y + p2.y) + p3.y)) / 3));
p2 = p3;
};
center.Multiply((1 / area));
c.SetV(b2Math.MulX(xf, center));
return (area);
}
public function GetVertices():Array{
return (m_vertices);
}
public function SetAsOrientedBox(hx:Number, hy:Number, center:b2Vec2=null, angle:Number=0):void{
m_vertexCount = 4;
Reserve(4);
m_vertices[0].Set(-(hx), -(hy));
m_vertices[1].Set(hx, -(hy));
m_vertices[2].Set(hx, hy);
m_vertices[3].Set(-(hx), hy);
m_normals[0].Set(0, -1);
m_normals[1].Set(1, 0);
m_normals[2].Set(0, 1);
m_normals[3].Set(-1, 0);
m_centroid = center;
var xf:b2Transform = new b2Transform();
xf.position = center;
xf.R.Set(angle);
var i:int;
while (i < m_vertexCount) {
m_vertices[i] = b2Math.MulX(xf, m_vertices[i]);
m_normals[i] = b2Math.MulMV(xf.R, m_normals[i]);
i++;
};
}
override public function Copy():b2Shape{
var s:b2PolygonShape = new b2PolygonShape();
s.Set(this);
return (s);
}
public function SetAsBox(hx:Number, hy:Number):void{
m_vertexCount = 4;
Reserve(4);
m_vertices[0].Set(-(hx), -(hy));
m_vertices[1].Set(hx, -(hy));
m_vertices[2].Set(hx, hy);
m_vertices[3].Set(-(hx), hy);
m_normals[0].Set(0, -1);
m_normals[1].Set(1, 0);
m_normals[2].Set(0, 1);
m_normals[3].Set(-1, 0);
m_centroid.SetZero();
}
private function Reserve(count:int):void{
var i:int = m_vertices.length;
while (i < count) {
m_vertices[i] = new b2Vec2();
m_normals[i] = new b2Vec2();
i++;
};
}
public function GetNormals():Array{
return (m_normals);
}
public function SetAsArray(vertices:Array, vertexCount:Number=0):void{
var tVec:b2Vec2;
var v:Array = new Array();
for each (tVec in vertices) {
v.push(tVec);
};
SetAsVector(v, vertexCount);
}
override public function RayCast(output:b2RayCastOutput, input:b2RayCastInput, transform:b2Transform):Boolean{
var tX:Number;
var tY:Number;
var tMat:b2Mat22;
var tVec:b2Vec2;
var numerator:Number;
var denominator:Number;
var lower:Number = 0;
var upper:Number = input.maxFraction;
tX = (input.p1.x - transform.position.x);
tY = (input.p1.y - transform.position.y);
tMat = transform.R;
var p1X:Number = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
var p1Y:Number = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
tX = (input.p2.x - transform.position.x);
tY = (input.p2.y - transform.position.y);
tMat = transform.R;
var p2X:Number = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
var p2Y:Number = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
var dX:Number = (p2X - p1X);
var dY:Number = (p2Y - p1Y);
var index = -1;
var i:int;
while (i < m_vertexCount) {
tVec = m_vertices[i];
tX = (tVec.x - p1X);
tY = (tVec.y - p1Y);
tVec = m_normals[i];
numerator = ((tVec.x * tX) + (tVec.y * tY));
denominator = ((tVec.x * dX) + (tVec.y * dY));
if (denominator == 0){
if (numerator < 0){
return (false);
};
} else {
if ((((denominator < 0)) && ((numerator < (lower * denominator))))){
lower = (numerator / denominator);
index = i;
} else {
if ((((denominator > 0)) && ((numerator < (upper * denominator))))){
upper = (numerator / denominator);
};
};
};
if (upper < (lower - Number.MIN_VALUE)){
return (false);
};
i++;
};
if (index >= 0){
output.fraction = lower;
tMat = transform.R;
tVec = m_normals[index];
output.normal.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
output.normal.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
return (true);
};
return (false);
}
override public function ComputeMass(massData:b2MassData, density:Number):void{
var p2:b2Vec2;
var p3:b2Vec2;
var e1X:Number;
var e1Y:Number;
var e2X:Number;
var e2Y:Number;
var D:Number;
var triangleArea:Number;
var px:Number;
var py:Number;
var ex1:Number;
var ey1:Number;
var ex2:Number;
var ey2:Number;
var intx2:Number;
var inty2:Number;
if (m_vertexCount == 2){
massData.center.x = (0.5 * (m_vertices[0].x + m_vertices[1].x));
massData.center.y = (0.5 * (m_vertices[0].y + m_vertices[1].y));
massData.mass = 0;
massData.I = 0;
return;
};
var centerX:Number = 0;
var centerY:Number = 0;
var area:Number = 0;
var I:Number = 0;
var p1X:Number = 0;
var p1Y:Number = 0;
var k_inv3:Number = (1 / 3);
var i:int;
while (i < m_vertexCount) {
p2 = m_vertices[i];
p3 = (((i + 1) < m_vertexCount)) ? m_vertices[int((i + 1))] : m_vertices[0];
e1X = (p2.x - p1X);
e1Y = (p2.y - p1Y);
e2X = (p3.x - p1X);
e2Y = (p3.y - p1Y);
D = ((e1X * e2Y) - (e1Y * e2X));
triangleArea = (0.5 * D);
area = (area + triangleArea);
centerX = (centerX + ((triangleArea * k_inv3) * ((p1X + p2.x) + p3.x)));
centerY = (centerY + ((triangleArea * k_inv3) * ((p1Y + p2.y) + p3.y)));
px = p1X;
py = p1Y;
ex1 = e1X;
ey1 = e1Y;
ex2 = e2X;
ey2 = e2Y;
intx2 = ((k_inv3 * ((0.25 * (((ex1 * ex1) + (ex2 * ex1)) + (ex2 * ex2))) + ((px * ex1) + (px * ex2)))) + ((0.5 * px) * px));
inty2 = ((k_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 = (density * area);
centerX = (centerX * (1 / area));
centerY = (centerY * (1 / area));
massData.center.Set(centerX, centerY);
massData.I = (density * I);
}
public function SetAsEdge(v1:b2Vec2, v2:b2Vec2):void{
m_vertexCount = 2;
Reserve(2);
m_vertices[0].SetV(v1);
m_vertices[1].SetV(v2);
m_centroid.x = (0.5 * (v1.x + v2.x));
m_centroid.y = (0.5 * (v1.y + v2.y));
m_normals[0] = b2Math.CrossVF(b2Math.SubtractVV(v2, v1), 1);
m_normals[0].Normalize();
m_normals[1].x = -(m_normals[0].x);
m_normals[1].y = -(m_normals[0].y);
}
public function GetVertexCount():int{
return (m_vertexCount);
}
private function Validate():Boolean{
return (false);
}
public function SetAsVector(vertices:Array, vertexCount:Number=0):void{
var i:int;
var i1:int;
var i2:int;
var edge:b2Vec2;
if (vertexCount == 0){
vertexCount = vertices.length;
};
b2Settings.b2Assert((2 <= vertexCount));
m_vertexCount = vertexCount;
Reserve(vertexCount);
i = 0;
while (i < m_vertexCount) {
m_vertices[i].SetV(vertices[i]);
i++;
};
i = 0;
while (i < m_vertexCount) {
i1 = i;
i2 = (((i + 1) < m_vertexCount)) ? (i + 1) : 0;
edge = b2Math.SubtractVV(m_vertices[i2], m_vertices[i1]);
b2Settings.b2Assert((edge.LengthSquared() > Number.MIN_VALUE));
m_normals[i].SetV(b2Math.CrossVF(edge, 1));
m_normals[i].Normalize();
i++;
};
m_centroid = ComputeCentroid(m_vertices, m_vertexCount);
}
public function GetSupport(d:b2Vec2):int{
var value:Number;
var bestIndex:int;
var bestValue:Number = ((m_vertices[0].x * d.x) + (m_vertices[0].y * d.y));
var i = 1;
while (i < m_vertexCount) {
value = ((m_vertices[i].x * d.x) + (m_vertices[i].y * d.y));
if (value > bestValue){
bestIndex = i;
bestValue = value;
};
i++;
};
return (bestIndex);
}
public function GetSupportVertex(d:b2Vec2):b2Vec2{
var value:Number;
var bestIndex:int;
var bestValue:Number = ((m_vertices[0].x * d.x) + (m_vertices[0].y * d.y));
var i = 1;
while (i < m_vertexCount) {
value = ((m_vertices[i].x * d.x) + (m_vertices[i].y * d.y));
if (value > bestValue){
bestIndex = i;
bestValue = value;
};
i++;
};
return (m_vertices[bestIndex]);
}
override public function TestPoint(xf:b2Transform, p:b2Vec2):Boolean{
var tVec:b2Vec2;
var dot:Number;
var tMat:b2Mat22 = xf.R;
var tX:Number = (p.x - xf.position.x);
var tY:Number = (p.y - xf.position.y);
var pLocalX:Number = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
var pLocalY:Number = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
var i:int;
while (i < m_vertexCount) {
tVec = m_vertices[i];
tX = (pLocalX - tVec.x);
tY = (pLocalY - tVec.y);
tVec = m_normals[i];
dot = ((tVec.x * tX) + (tVec.y * tY));
if (dot > 0){
return (false);
};
i++;
};
return (true);
}
b2internal static function ComputeOBB(obb:b2OBB, vs:Array, count:int):void{
var i:int;
var root:b2Vec2;
var uxX:Number;
var uxY:Number;
var length:Number;
var uyX:Number;
var uyY:Number;
var lowerX:Number;
var lowerY:Number;
var upperX:Number;
var upperY:Number;
var j:int;
var area:Number;
var dX:Number;
var dY:Number;
var rX:Number;
var rY:Number;
var centerX:Number;
var centerY:Number;
var tMat:b2Mat22;
var p:Array = new Array((count + 1));
i = 0;
while (i < count) {
p[i] = vs[i];
i++;
};
p[count] = p[0];
var minArea:Number = Number.MAX_VALUE;
i = 1;
while (i <= count) {
root = p[int((i - 1))];
uxX = (p[i].x - root.x);
uxY = (p[i].y - root.y);
length = Math.sqrt(((uxX * uxX) + (uxY * uxY)));
uxX = (uxX / length);
uxY = (uxY / length);
uyX = -(uxY);
uyY = uxX;
lowerX = Number.MAX_VALUE;
lowerY = Number.MAX_VALUE;
upperX = -(Number.MAX_VALUE);
upperY = -(Number.MAX_VALUE);
j = 0;
while (j < count) {
dX = (p[j].x - root.x);
dY = (p[j].y - root.y);
rX = ((uxX * dX) + (uxY * dY));
rY = ((uyX * dX) + (uyY * dY));
if (rX < lowerX){
lowerX = rX;
};
if (rY < lowerY){
lowerY = rY;
};
if (rX > upperX){
upperX = rX;
};
if (rY > upperY){
upperY = rY;
};
j++;
};
area = ((upperX - lowerX) * (upperY - lowerY));
if (area < (0.95 * minArea)){
minArea = area;
obb.R.col1.x = uxX;
obb.R.col1.y = uxY;
obb.R.col2.x = uyX;
obb.R.col2.y = uyY;
centerX = (0.5 * (lowerX + upperX));
centerY = (0.5 * (lowerY + upperY));
tMat = obb.R;
obb.center.x = (root.x + ((tMat.col1.x * centerX) + (tMat.col2.x * centerY)));
obb.center.y = (root.y + ((tMat.col1.y * centerX) + (tMat.col2.y * centerY)));
obb.extents.x = (0.5 * (upperX - lowerX));
obb.extents.y = (0.5 * (upperY - lowerY));
};
i++;
};
}
public static function AsVector(vertices:Array, vertexCount:Number):b2PolygonShape{
var polygonShape:b2PolygonShape = new (b2PolygonShape);
polygonShape.SetAsVector(vertices, vertexCount);
return (polygonShape);
}
public static function AsArray(vertices:Array, vertexCount:Number):b2PolygonShape{
var polygonShape:b2PolygonShape = new (b2PolygonShape);
polygonShape.SetAsArray(vertices, vertexCount);
return (polygonShape);
}
public static function AsBox(hx:Number, hy:Number):b2PolygonShape{
var polygonShape:b2PolygonShape = new (b2PolygonShape);
polygonShape.SetAsBox(hx, hy);
return (polygonShape);
}
public static function AsOrientedBox(hx:Number, hy:Number, center:b2Vec2=null, angle:Number=0):b2PolygonShape{
var polygonShape:b2PolygonShape = new (b2PolygonShape);
polygonShape.SetAsOrientedBox(hx, hy, center, angle);
return (polygonShape);
}
public static function ComputeCentroid(vs:Array, count:uint):b2Vec2{
var c:b2Vec2;
var inv3:Number;
var p2:b2Vec2;
var p3:b2Vec2;
var e1X:Number;
var e1Y:Number;
var e2X:Number;
var e2Y:Number;
var D:Number;
var triangleArea:Number;
c = new b2Vec2();
var area:Number = 0;
var p1X:Number = 0;
var p1Y:Number = 0;
inv3 = (1 / 3);
var i:int;
while (i < count) {
p2 = vs[i];
p3 = (((i + 1) < count)) ? vs[int((i + 1))] : vs[0];
e1X = (p2.x - p1X);
e1Y = (p2.y - p1Y);
e2X = (p3.x - p1X);
e2Y = (p3.y - p1Y);
D = ((e1X * e2Y) - (e1Y * e2X));
triangleArea = (0.5 * D);
area = (area + triangleArea);
c.x = (c.x + ((triangleArea * inv3) * ((p1X + p2.x) + p3.x)));
c.y = (c.y + ((triangleArea * inv3) * ((p1Y + p2.y) + p3.y)));
i++;
};
c.x = (c.x * (1 / area));
c.y = (c.y * (1 / area));
return (c);
}
public static function AsEdge(v1:b2Vec2, v2:b2Vec2):b2PolygonShape{
var polygonShape:b2PolygonShape = new (b2PolygonShape);
polygonShape.SetAsEdge(v1, v2);
return (polygonShape);
}
}
}//package Box2D.Collision.Shapes
Section 54
//b2Shape (Box2D.Collision.Shapes.b2Shape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2Shape {
b2internal var m_radius:Number;
b2internal var m_type:int;
b2internal static const e_polygonShape:int = 1;
public static const e_hitCollide:int = 1;
public static const e_missCollide:int = 0;
b2internal static const e_edgeShape:int = 2;
b2internal static const e_shapeTypeCount:int = 3;
b2internal static const e_unknownShape:int = -1;
b2internal static const e_circleShape:int = 0;
public static const e_startsInsideCollide:int = -1;
public function b2Shape(){
super();
m_type = e_unknownShape;
m_radius = b2Settings.b2_linearSlop;
}
public function RayCast(output:b2RayCastOutput, input:b2RayCastInput, transform:b2Transform):Boolean{
return (false);
}
public function ComputeSubmergedArea(normal:b2Vec2, offset:Number, xf:b2Transform, c:b2Vec2):Number{
return (0);
}
public function Set(other:b2Shape):void{
m_radius = other.m_radius;
}
public function ComputeMass(massData:b2MassData, density:Number):void{
}
public function GetType():int{
return (m_type);
}
public function Copy():b2Shape{
return (null);
}
public function ComputeAABB(aabb:b2AABB, xf:b2Transform):void{
}
public function TestPoint(xf:b2Transform, p:b2Vec2):Boolean{
return (false);
}
public static function TestOverlap(shape1:b2Shape, transform1:b2Transform, shape2:b2Shape, transform2:b2Transform):Boolean{
var input:b2DistanceInput = new b2DistanceInput();
input.proxyA = new b2DistanceProxy();
input.proxyA.Set(shape1);
input.proxyB = new b2DistanceProxy();
input.proxyB.Set(shape2);
input.transformA = transform1;
input.transformB = transform2;
input.useRadii = true;
var simplexCache:b2SimplexCache = new b2SimplexCache();
simplexCache.count = 0;
var output:b2DistanceOutput = new b2DistanceOutput();
b2Distance.Distance(output, simplexCache, input);
return ((output.distance < (10 * Number.MIN_VALUE)));
}
}
}//package Box2D.Collision.Shapes
Section 55
//b2AABB (Box2D.Collision.b2AABB)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2AABB {
public var upperBound:b2Vec2;
public var lowerBound:b2Vec2;
public function b2AABB(){
lowerBound = new b2Vec2();
upperBound = new b2Vec2();
super();
}
public function Contains(aabb:b2AABB):Boolean{
var result:Boolean;
result = ((result) && ((lowerBound.x <= aabb.lowerBound.x)));
result = ((result) && ((lowerBound.y <= aabb.lowerBound.y)));
result = ((result) && ((aabb.upperBound.x <= upperBound.x)));
result = ((result) && ((aabb.upperBound.y <= upperBound.y)));
return (result);
}
public function RayCast(output:b2RayCastOutput, input:b2RayCastInput):Boolean{
var normal:b2Vec2;
var inv_d:Number;
var t1:Number;
var t2:Number;
var t3:Number;
var s:Number;
var tmin:Number = -(Number.MAX_VALUE);
var tmax:Number = Number.MAX_VALUE;
var pX:Number = input.p1.x;
var pY:Number = input.p1.y;
var dX:Number = (input.p2.x - input.p1.x);
var dY:Number = (input.p2.y - input.p1.y);
var absDX:Number = Math.abs(dX);
var absDY:Number = Math.abs(dY);
normal = output.normal;
if (absDX < Number.MIN_VALUE){
if ((((pX < lowerBound.x)) || ((upperBound.x < pX)))){
return (false);
};
} else {
inv_d = (1 / dX);
t1 = ((lowerBound.x - pX) * inv_d);
t2 = ((upperBound.x - pX) * inv_d);
s = -1;
if (t1 > t2){
t3 = t1;
t1 = t2;
t2 = t3;
s = 1;
};
if (t1 > tmin){
normal.x = s;
normal.y = 0;
tmin = t1;
};
tmax = Math.min(tmax, t2);
if (tmin > tmax){
return (false);
};
};
if (absDY < Number.MIN_VALUE){
if ((((pY < lowerBound.y)) || ((upperBound.y < pY)))){
return (false);
};
} else {
inv_d = (1 / dY);
t1 = ((lowerBound.y - pY) * inv_d);
t2 = ((upperBound.y - pY) * inv_d);
s = -1;
if (t1 > t2){
t3 = t1;
t1 = t2;
t2 = t3;
s = 1;
};
if (t1 > tmin){
normal.y = s;
normal.x = 0;
tmin = t1;
};
tmax = Math.min(tmax, t2);
if (tmin > tmax){
return (false);
};
};
output.fraction = tmin;
return (true);
}
public function GetCenter():b2Vec2{
return (new b2Vec2(((lowerBound.x + upperBound.x) / 2), ((lowerBound.y + upperBound.y) / 2)));
}
public function IsValid():Boolean{
var dX:Number = (upperBound.x - lowerBound.x);
var dY:Number = (upperBound.y - lowerBound.y);
var valid:Boolean = (((dX >= 0)) && ((dY >= 0)));
valid = ((((valid) && (lowerBound.IsValid()))) && (upperBound.IsValid()));
return (valid);
}
public function TestOverlap(other:b2AABB):Boolean{
var d1X:Number = (other.lowerBound.x - upperBound.x);
var d1Y:Number = (other.lowerBound.y - upperBound.y);
var d2X:Number = (lowerBound.x - other.upperBound.x);
var d2Y:Number = (lowerBound.y - other.upperBound.y);
if ((((d1X > 0)) || ((d1Y > 0)))){
return (false);
};
if ((((d2X > 0)) || ((d2Y > 0)))){
return (false);
};
return (true);
}
public function GetExtents():b2Vec2{
return (new b2Vec2(((upperBound.x - lowerBound.x) / 2), ((upperBound.y - lowerBound.y) / 2)));
}
public function Combine(aabb1:b2AABB, aabb2:b2AABB):void{
lowerBound.x = Math.min(aabb1.lowerBound.x, aabb2.lowerBound.x);
lowerBound.y = Math.min(aabb1.lowerBound.y, aabb2.lowerBound.y);
upperBound.x = Math.max(aabb1.upperBound.x, aabb2.upperBound.x);
upperBound.y = Math.max(aabb1.upperBound.y, aabb2.upperBound.y);
}
public static function Combine(aabb1:b2AABB, aabb2:b2AABB):b2AABB{
var aabb:b2AABB = new (b2AABB);
aabb.Combine(aabb1, aabb2);
return (aabb);
}
}
}//package Box2D.Collision
Section 56
//b2Collision (Box2D.Collision.b2Collision)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Collision {
public static const b2_nullFeature:uint = 0xFF;
private static var b2CollidePolyTempVec:b2Vec2 = new b2Vec2();
private static var s_v12:b2Vec2 = new b2Vec2();
private static var s_v11:b2Vec2 = new b2Vec2();
private static var s_edgeBO:Array = new Array(1);
private static var s_tangent2:b2Vec2 = new b2Vec2();
private static var s_planePoint:b2Vec2 = new b2Vec2();
private static var s_localTangent:b2Vec2 = new b2Vec2();
private static var s_clipPoints1:Array = MakeClipPointVector();
private static var s_clipPoints2:Array = MakeClipPointVector();
private static var s_localNormal:b2Vec2 = new b2Vec2();
private static var s_edgeAO:Array = new Array(1);
private static var s_tangent:b2Vec2 = new b2Vec2();
private static var s_normal:b2Vec2 = new b2Vec2();
private static var s_incidentEdge:Array = MakeClipPointVector();
public function b2Collision(){
super();
}
public static function EdgeSeparation(poly1:b2PolygonShape, xf1:b2Transform, edge1:int, poly2:b2PolygonShape, xf2:b2Transform):Number{
var tMat:b2Mat22;
var tVec:b2Vec2;
var dot:Number;
var count1:int = poly1.m_vertexCount;
var vertices1:Array = poly1.m_vertices;
var normals1:Array = poly1.m_normals;
var count2:int = poly2.m_vertexCount;
var vertices2:Array = poly2.m_vertices;
tMat = xf1.R;
tVec = normals1[edge1];
var normal1WorldX:Number = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
var normal1WorldY:Number = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = xf2.R;
var normal1X:Number = ((tMat.col1.x * normal1WorldX) + (tMat.col1.y * normal1WorldY));
var normal1Y:Number = ((tMat.col2.x * normal1WorldX) + (tMat.col2.y * normal1WorldY));
var index:int;
var minDot:Number = Number.MAX_VALUE;
var i:int;
while (i < count2) {
tVec = vertices2[i];
dot = ((tVec.x * normal1X) + (tVec.y * normal1Y));
if (dot < minDot){
minDot = dot;
index = i;
};
i++;
};
tVec = vertices1[edge1];
tMat = xf1.R;
var v1X:Number = (xf1.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var v1Y:Number = (xf1.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tVec = vertices2[index];
tMat = xf2.R;
var v2X:Number = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var v2Y:Number = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
v2X = (v2X - v1X);
v2Y = (v2Y - v1Y);
var separation:Number = ((v2X * normal1WorldX) + (v2Y * normal1WorldY));
return (separation);
}
public static function ClipSegmentToLine(vOut:Array, vIn:Array, normal:b2Vec2, offset:Number):int{
var cv:ClipVertex;
var numOut:int;
var vIn0:b2Vec2;
var distance0:Number;
var interp:Number;
var tVec:b2Vec2;
var cv2:ClipVertex;
numOut = 0;
cv = vIn[0];
vIn0 = cv.v;
cv = vIn[1];
var vIn1:b2Vec2 = cv.v;
distance0 = (((normal.x * vIn0.x) + (normal.y * vIn0.y)) - offset);
var distance1:Number = (((normal.x * vIn1.x) + (normal.y * vIn1.y)) - offset);
if (distance0 <= 0){
var _temp1 = numOut;
numOut = (numOut + 1);
vOut[_temp1].Set(vIn[0]);
};
if (distance1 <= 0){
var _temp2 = numOut;
numOut = (numOut + 1);
vOut[_temp2].Set(vIn[1]);
};
if ((distance0 * distance1) < 0){
interp = (distance0 / (distance0 - distance1));
cv = vOut[numOut];
tVec = cv.v;
tVec.x = (vIn0.x + (interp * (vIn1.x - vIn0.x)));
tVec.y = (vIn0.y + (interp * (vIn1.y - vIn0.y)));
cv = vOut[numOut];
if (distance0 > 0){
cv2 = vIn[0];
cv.id = cv2.id;
} else {
cv2 = vIn[1];
cv.id = cv2.id;
};
numOut++;
};
return (numOut);
}
private static function MakeClipPointVector():Array{
var r:Array = new Array(2);
r[0] = new ClipVertex();
r[1] = new ClipVertex();
return (r);
}
public static function CollideCircles(manifold:b2Manifold, circle1:b2CircleShape, xf1:b2Transform, circle2:b2CircleShape, xf2:b2Transform):void{
var tMat:b2Mat22;
var tVec:b2Vec2;
manifold.m_pointCount = 0;
tMat = xf1.R;
tVec = circle1.m_p;
var p1X:Number = (xf1.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var p1Y:Number = (xf1.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tMat = xf2.R;
tVec = circle2.m_p;
var p2X:Number = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var p2Y:Number = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
var dX:Number = (p2X - p1X);
var dY:Number = (p2Y - p1Y);
var distSqr:Number = ((dX * dX) + (dY * dY));
var radius:Number = (circle1.m_radius + circle2.m_radius);
if (distSqr > (radius * radius)){
return;
};
manifold.m_type = b2Manifold.e_circles;
manifold.m_localPoint.SetV(circle1.m_p);
manifold.m_localPlaneNormal.SetZero();
manifold.m_pointCount = 1;
manifold.m_points[0].m_localPoint.SetV(circle2.m_p);
manifold.m_points[0].m_id.key = 0;
}
public static function FindIncidentEdge(c:Array, poly1:b2PolygonShape, xf1:b2Transform, edge1:int, poly2:b2PolygonShape, xf2:b2Transform):void{
var tMat:b2Mat22;
var tVec:b2Vec2;
var tClip:ClipVertex;
var dot:Number;
var count1:int = poly1.m_vertexCount;
var normals1:Array = poly1.m_normals;
var count2:int = poly2.m_vertexCount;
var vertices2:Array = poly2.m_vertices;
var normals2:Array = poly2.m_normals;
tMat = xf1.R;
tVec = normals1[edge1];
var normal1X:Number = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
var normal1Y:Number = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = xf2.R;
var tX:Number = ((tMat.col1.x * normal1X) + (tMat.col1.y * normal1Y));
normal1Y = ((tMat.col2.x * normal1X) + (tMat.col2.y * normal1Y));
normal1X = tX;
var index:int;
var minDot:Number = Number.MAX_VALUE;
var i:int;
while (i < count2) {
tVec = normals2[i];
dot = ((normal1X * tVec.x) + (normal1Y * tVec.y));
if (dot < minDot){
minDot = dot;
index = i;
};
i++;
};
var i1:int = index;
var i2:int = (((i1 + 1) < count2)) ? (i1 + 1) : 0;
tClip = c[0];
tVec = vertices2[i1];
tMat = xf2.R;
tClip.v.x = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
tClip.v.y = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tClip.id.features.referenceEdge = edge1;
tClip.id.features.incidentEdge = i1;
tClip.id.features.incidentVertex = 0;
tClip = c[1];
tVec = vertices2[i2];
tMat = xf2.R;
tClip.v.x = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
tClip.v.y = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tClip.id.features.referenceEdge = edge1;
tClip.id.features.incidentEdge = i2;
tClip.id.features.incidentVertex = 1;
}
public static function CollidePolygonAndCircle(manifold:b2Manifold, polygon:b2PolygonShape, xf1:b2Transform, circle:b2CircleShape, xf2:b2Transform):void{
var tPoint:b2ManifoldPoint;
var dX:Number;
var dY:Number;
var positionX:Number;
var positionY:Number;
var tVec:b2Vec2;
var tMat:b2Mat22;
var dist:Number;
var s:Number;
var faceCenterX:Number;
var faceCenterY:Number;
manifold.m_pointCount = 0;
tMat = xf2.R;
tVec = circle.m_p;
var cX:Number = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var cY:Number = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
dX = (cX - xf1.position.x);
dY = (cY - xf1.position.y);
tMat = xf1.R;
var cLocalX:Number = ((dX * tMat.col1.x) + (dY * tMat.col1.y));
var cLocalY:Number = ((dX * tMat.col2.x) + (dY * tMat.col2.y));
var normalIndex:int;
var separation:Number = -(Number.MAX_VALUE);
var radius:Number = (polygon.m_radius + circle.m_radius);
var vertexCount:int = polygon.m_vertexCount;
var vertices:Array = polygon.m_vertices;
var normals:Array = polygon.m_normals;
var i:int;
while (i < vertexCount) {
tVec = vertices[i];
dX = (cLocalX - tVec.x);
dY = (cLocalY - tVec.y);
tVec = normals[i];
s = ((tVec.x * dX) + (tVec.y * dY));
if (s > radius){
return;
};
if (s > separation){
separation = s;
normalIndex = i;
};
i++;
};
var vertIndex1:int = normalIndex;
var vertIndex2:int = (((vertIndex1 + 1) < vertexCount)) ? (vertIndex1 + 1) : 0;
var v1:b2Vec2 = vertices[vertIndex1];
var v2:b2Vec2 = vertices[vertIndex2];
if (separation < Number.MIN_VALUE){
manifold.m_pointCount = 1;
manifold.m_type = b2Manifold.e_faceA;
manifold.m_localPlaneNormal.SetV(normals[normalIndex]);
manifold.m_localPoint.x = (0.5 * (v1.x + v2.x));
manifold.m_localPoint.y = (0.5 * (v1.y + v2.y));
manifold.m_points[0].m_localPoint.SetV(circle.m_p);
manifold.m_points[0].m_id.key = 0;
return;
};
var u1:Number = (((cLocalX - v1.x) * (v2.x - v1.x)) + ((cLocalY - v1.y) * (v2.y - v1.y)));
var u2:Number = (((cLocalX - v2.x) * (v1.x - v2.x)) + ((cLocalY - v2.y) * (v1.y - v2.y)));
if (u1 <= 0){
if ((((cLocalX - v1.x) * (cLocalX - v1.x)) + ((cLocalY - v1.y) * (cLocalY - v1.y))) > (radius * radius)){
return;
};
manifold.m_pointCount = 1;
manifold.m_type = b2Manifold.e_faceA;
manifold.m_localPlaneNormal.x = (cLocalX - v1.x);
manifold.m_localPlaneNormal.y = (cLocalY - v1.y);
manifold.m_localPlaneNormal.Normalize();
manifold.m_localPoint.SetV(v1);
manifold.m_points[0].m_localPoint.SetV(circle.m_p);
manifold.m_points[0].m_id.key = 0;
} else {
if (u2 <= 0){
if ((((cLocalX - v2.x) * (cLocalX - v2.x)) + ((cLocalY - v2.y) * (cLocalY - v2.y))) > (radius * radius)){
return;
};
manifold.m_pointCount = 1;
manifold.m_type = b2Manifold.e_faceA;
manifold.m_localPlaneNormal.x = (cLocalX - v2.x);
manifold.m_localPlaneNormal.y = (cLocalY - v2.y);
manifold.m_localPlaneNormal.Normalize();
manifold.m_localPoint.SetV(v2);
manifold.m_points[0].m_localPoint.SetV(circle.m_p);
manifold.m_points[0].m_id.key = 0;
} else {
faceCenterX = (0.5 * (v1.x + v2.x));
faceCenterY = (0.5 * (v1.y + v2.y));
separation = (((cLocalX - faceCenterX) * normals[vertIndex1].x) + ((cLocalY - faceCenterY) * normals[vertIndex1].y));
if (separation > radius){
return;
};
manifold.m_pointCount = 1;
manifold.m_type = b2Manifold.e_faceA;
manifold.m_localPlaneNormal.x = normals[vertIndex1].x;
manifold.m_localPlaneNormal.y = normals[vertIndex1].y;
manifold.m_localPlaneNormal.Normalize();
manifold.m_localPoint.Set(faceCenterX, faceCenterY);
manifold.m_points[0].m_localPoint.SetV(circle.m_p);
manifold.m_points[0].m_id.key = 0;
};
};
}
public static function CollidePolygons(manifold:b2Manifold, polyA:b2PolygonShape, xfA:b2Transform, polyB:b2PolygonShape, xfB:b2Transform):void{
var cv:ClipVertex;
var poly1:b2PolygonShape;
var poly2:b2PolygonShape;
var xf1:b2Transform;
var xf2:b2Transform;
var edge1:int;
var flip:uint;
var tMat:b2Mat22;
var local_v12:b2Vec2;
var np:int;
var separation:Number;
var cp:b2ManifoldPoint;
var tX:Number;
var tY:Number;
manifold.m_pointCount = 0;
var totalRadius:Number = (polyA.m_radius + polyB.m_radius);
var edgeA:int;
s_edgeAO[0] = edgeA;
var separationA:Number = FindMaxSeparation(s_edgeAO, polyA, xfA, polyB, xfB);
edgeA = s_edgeAO[0];
if (separationA > totalRadius){
return;
};
var edgeB:int;
s_edgeBO[0] = edgeB;
var separationB:Number = FindMaxSeparation(s_edgeBO, polyB, xfB, polyA, xfA);
edgeB = s_edgeBO[0];
if (separationB > totalRadius){
return;
};
var k_relativeTol:Number = 0.98;
var k_absoluteTol:Number = 0.001;
if (separationB > ((k_relativeTol * separationA) + k_absoluteTol)){
poly1 = polyB;
poly2 = polyA;
xf1 = xfB;
xf2 = xfA;
edge1 = edgeB;
manifold.m_type = b2Manifold.e_faceB;
flip = 1;
} else {
poly1 = polyA;
poly2 = polyB;
xf1 = xfA;
xf2 = xfB;
edge1 = edgeA;
manifold.m_type = b2Manifold.e_faceA;
flip = 0;
};
var incidentEdge:Array = s_incidentEdge;
FindIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);
var count1:int = poly1.m_vertexCount;
var vertices1:Array = poly1.m_vertices;
var local_v11:b2Vec2 = vertices1[edge1];
if ((edge1 + 1) < count1){
local_v12 = vertices1[int((edge1 + 1))];
} else {
local_v12 = vertices1[0];
};
var localTangent:b2Vec2 = s_localTangent;
localTangent.Set((local_v12.x - local_v11.x), (local_v12.y - local_v11.y));
localTangent.Normalize();
var localNormal:b2Vec2 = s_localNormal;
localNormal.x = localTangent.y;
localNormal.y = -(localTangent.x);
var planePoint:b2Vec2 = s_planePoint;
planePoint.Set((0.5 * (local_v11.x + local_v12.x)), (0.5 * (local_v11.y + local_v12.y)));
var tangent:b2Vec2 = s_tangent;
tMat = xf1.R;
tangent.x = ((tMat.col1.x * localTangent.x) + (tMat.col2.x * localTangent.y));
tangent.y = ((tMat.col1.y * localTangent.x) + (tMat.col2.y * localTangent.y));
var tangent2:b2Vec2 = s_tangent2;
tangent2.x = -(tangent.x);
tangent2.y = -(tangent.y);
var normal:b2Vec2 = s_normal;
normal.x = tangent.y;
normal.y = -(tangent.x);
var v11:b2Vec2 = s_v11;
var v12:b2Vec2 = s_v12;
v11.x = (xf1.position.x + ((tMat.col1.x * local_v11.x) + (tMat.col2.x * local_v11.y)));
v11.y = (xf1.position.y + ((tMat.col1.y * local_v11.x) + (tMat.col2.y * local_v11.y)));
v12.x = (xf1.position.x + ((tMat.col1.x * local_v12.x) + (tMat.col2.x * local_v12.y)));
v12.y = (xf1.position.y + ((tMat.col1.y * local_v12.x) + (tMat.col2.y * local_v12.y)));
var frontOffset:Number = ((normal.x * v11.x) + (normal.y * v11.y));
var sideOffset1:Number = (((-(tangent.x) * v11.x) - (tangent.y * v11.y)) + totalRadius);
var sideOffset2:Number = (((tangent.x * v12.x) + (tangent.y * v12.y)) + totalRadius);
var clipPoints1:Array = s_clipPoints1;
var clipPoints2:Array = s_clipPoints2;
np = ClipSegmentToLine(clipPoints1, incidentEdge, tangent2, sideOffset1);
if (np < 2){
return;
};
np = ClipSegmentToLine(clipPoints2, clipPoints1, tangent, sideOffset2);
if (np < 2){
return;
};
manifold.m_localPlaneNormal.SetV(localNormal);
manifold.m_localPoint.SetV(planePoint);
var pointCount:int;
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
cv = clipPoints2[i];
separation = (((normal.x * cv.v.x) + (normal.y * cv.v.y)) - frontOffset);
if (separation <= totalRadius){
cp = manifold.m_points[pointCount];
tMat = xf2.R;
tX = (cv.v.x - xf2.position.x);
tY = (cv.v.y - xf2.position.y);
cp.m_localPoint.x = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
cp.m_localPoint.y = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
cp.m_id.Set(cv.id);
cp.m_id.features.flip = flip;
pointCount++;
};
i++;
};
manifold.m_pointCount = pointCount;
}
public static function FindMaxSeparation(edgeIndex:Array, poly1:b2PolygonShape, xf1:b2Transform, poly2:b2PolygonShape, xf2:b2Transform):Number{
var tVec:b2Vec2;
var tMat:b2Mat22;
var bestEdge:int;
var bestSeparation:Number;
var increment:int;
var dot:Number;
var count1:int = poly1.m_vertexCount;
var normals1:Array = poly1.m_normals;
tMat = xf2.R;
tVec = poly2.m_centroid;
var dX:Number = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var dY:Number = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tMat = xf1.R;
tVec = poly1.m_centroid;
dX = (dX - (xf1.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y))));
dY = (dY - (xf1.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y))));
var dLocal1X:Number = ((dX * xf1.R.col1.x) + (dY * xf1.R.col1.y));
var dLocal1Y:Number = ((dX * xf1.R.col2.x) + (dY * xf1.R.col2.y));
var edge:int;
var maxDot:Number = -(Number.MAX_VALUE);
var i:int;
while (i < count1) {
tVec = normals1[i];
dot = ((tVec.x * dLocal1X) + (tVec.y * dLocal1Y));
if (dot > maxDot){
maxDot = dot;
edge = i;
};
i++;
};
var s:Number = EdgeSeparation(poly1, xf1, edge, poly2, xf2);
var prevEdge:int = (((edge - 1) >= 0)) ? (edge - 1) : (count1 - 1);
var sPrev:Number = EdgeSeparation(poly1, xf1, prevEdge, poly2, xf2);
var nextEdge:int = (((edge + 1) < count1)) ? (edge + 1) : 0;
var sNext:Number = EdgeSeparation(poly1, xf1, nextEdge, poly2, xf2);
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, xf1, edge, poly2, xf2);
if (s > bestSeparation){
bestEdge = edge;
bestSeparation = s;
} else {
break;
};
};
edgeIndex[0] = bestEdge;
return (bestSeparation);
}
public static function TestOverlap(a:b2AABB, b:b2AABB):Boolean{
var t1:b2Vec2 = b.lowerBound;
var t2:b2Vec2 = a.upperBound;
var d1X:Number = (t1.x - t2.x);
var d1Y:Number = (t1.y - t2.y);
t1 = a.lowerBound;
t2 = b.upperBound;
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);
}
}
}//package Box2D.Collision
Section 57
//b2ContactID (Box2D.Collision.b2ContactID)
package Box2D.Collision {
import Box2D.Common.*;
public class b2ContactID {
b2internal var _key:uint;
public var features:Features;
public function b2ContactID(){
features = new Features();
super();
features._m_id = this;
}
public function Set(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._referenceEdge = (_key & 0xFF);
features._incidentEdge = (((_key & 0xFF00) >> 8) & 0xFF);
features._incidentVertex = (((_key & 0xFF0000) >> 16) & 0xFF);
features._flip = (((_key & 4278190080) >> 24) & 0xFF);
}
public function get key():uint{
return (_key);
}
}
}//package Box2D.Collision
Section 58
//b2ContactPoint (Box2D.Collision.b2ContactPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
public class b2ContactPoint {
public var friction:Number;
public var separation:Number;
public var normal:b2Vec2;
public var position:b2Vec2;
public var restitution:Number;
public var shape1:b2Shape;
public var shape2:b2Shape;
public var id:b2ContactID;
public var velocity:b2Vec2;
public function b2ContactPoint(){
position = new b2Vec2();
velocity = new b2Vec2();
normal = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Collision
Section 59
//b2Distance (Box2D.Collision.b2Distance)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Distance {
private static var b2_gjkIters:int;
private static var b2_gjkMaxIters:int;
private static var s_saveB:Array = new Array(3);
private static var s_simplex:b2Simplex = new b2Simplex();
private static var b2_gjkCalls:int;
private static var s_saveA:Array = new Array(3);
public function b2Distance(){
super();
}
public static function Distance(output:b2DistanceOutput, cache:b2SimplexCache, input:b2DistanceInput):void{
var i:int;
var p:b2Vec2;
var d:b2Vec2;
var vertex:b2SimplexVertex;
var duplicate:Boolean;
var rA:Number;
var rB:Number;
var normal:b2Vec2;
b2_gjkCalls++;
var proxyA:b2DistanceProxy = input.proxyA;
var proxyB:b2DistanceProxy = input.proxyB;
var transformA:b2Transform = input.transformA;
var transformB:b2Transform = input.transformB;
var simplex:b2Simplex = s_simplex;
simplex.ReadCache(cache, proxyA, transformA, proxyB, transformB);
var vertices:Array = simplex.m_vertices;
var k_maxIters = 20;
var saveA:Array = s_saveA;
var saveB:Array = s_saveB;
var saveCount:int;
var closestPoint:b2Vec2 = simplex.GetClosestPoint();
var distanceSqr1:Number = closestPoint.LengthSquared();
var distanceSqr2:Number = distanceSqr1;
var iter:int;
while (iter < k_maxIters) {
saveCount = simplex.m_count;
i = 0;
while (i < saveCount) {
saveA[i] = vertices[i].indexA;
saveB[i] = vertices[i].indexB;
i++;
};
switch (simplex.m_count){
case 1:
break;
case 2:
simplex.Solve2();
break;
case 3:
simplex.Solve3();
break;
default:
b2Settings.b2Assert(false);
};
if (simplex.m_count == 3){
break;
};
p = simplex.GetClosestPoint();
distanceSqr2 = p.LengthSquared();
if (distanceSqr2 > distanceSqr1){
};
distanceSqr1 = distanceSqr2;
d = simplex.GetSearchDirection();
if (d.LengthSquared() < (Number.MIN_VALUE * Number.MIN_VALUE)){
break;
};
vertex = vertices[simplex.m_count];
vertex.indexA = proxyA.GetSupport(b2Math.MulTMV(transformA.R, d.GetNegative()));
vertex.wA = b2Math.MulX(transformA, proxyA.GetVertex(vertex.indexA));
vertex.indexB = proxyB.GetSupport(b2Math.MulTMV(transformB.R, d));
vertex.wB = b2Math.MulX(transformB, proxyB.GetVertex(vertex.indexB));
vertex.w = b2Math.SubtractVV(vertex.wB, vertex.wA);
iter++;
b2_gjkIters++;
duplicate = false;
i = 0;
while (i < saveCount) {
if ((((vertex.indexA == saveA[i])) && ((vertex.indexB == saveB[i])))){
duplicate = true;
break;
};
i++;
};
if (duplicate){
break;
};
simplex.m_count++;
};
b2_gjkMaxIters = b2Math.Max(b2_gjkMaxIters, iter);
simplex.GetWitnessPoints(output.pointA, output.pointB);
output.distance = b2Math.SubtractVV(output.pointA, output.pointB).Length();
output.iterations = iter;
simplex.WriteCache(cache);
if (input.useRadii){
rA = proxyA.m_radius;
rB = proxyB.m_radius;
if ((((output.distance > (rA + rB))) && ((output.distance > Number.MIN_VALUE)))){
output.distance = (output.distance - (rA + rB));
normal = b2Math.SubtractVV(output.pointB, output.pointA);
normal.Normalize();
output.pointA.x = (output.pointA.x + (rA * normal.x));
output.pointA.y = (output.pointA.y + (rA * normal.y));
output.pointB.x = (output.pointB.x - (rB * normal.x));
output.pointB.y = (output.pointB.y - (rB * normal.y));
} else {
p = new b2Vec2();
p.x = (0.5 * (output.pointA.x + output.pointB.x));
p.y = (0.5 * (output.pointA.y + output.pointB.y));
output.pointA.x = (output.pointB.x = p.x);
output.pointA.y = (output.pointB.y = p.y);
output.distance = 0;
};
};
}
}
}//package Box2D.Collision
Section 60
//b2DistanceInput (Box2D.Collision.b2DistanceInput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2DistanceInput {
public var proxyA:b2DistanceProxy;
public var proxyB:b2DistanceProxy;
public var transformA:b2Transform;
public var transformB:b2Transform;
public var useRadii:Boolean;
public function b2DistanceInput(){
super();
}
}
}//package Box2D.Collision
Section 61
//b2DistanceOutput (Box2D.Collision.b2DistanceOutput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2DistanceOutput {
public var pointA:b2Vec2;
public var distance:Number;
public var iterations:int;
public var pointB:b2Vec2;
public function b2DistanceOutput(){
pointA = new b2Vec2();
pointB = new b2Vec2();
super();
}
}
}//package Box2D.Collision
Section 62
//b2DistanceProxy (Box2D.Collision.b2DistanceProxy)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2DistanceProxy {
public var m_radius:Number;
public var m_vertices:Array;
public var m_count:int;
public function b2DistanceProxy(){
super();
}
public function GetVertex(index:int):b2Vec2{
b2Settings.b2Assert((((0 <= index)) && ((index < m_count))));
return (m_vertices[index]);
}
public function Set(shape:b2Shape):void{
var circle:b2CircleShape;
var polygon:b2PolygonShape;
switch (shape.GetType()){
case b2Shape.e_circleShape:
circle = (shape as b2CircleShape);
m_vertices = new Array(1, true);
m_vertices[0] = circle.m_p;
m_count = 1;
m_radius = circle.m_radius;
break;
case b2Shape.e_polygonShape:
polygon = (shape as b2PolygonShape);
m_vertices = polygon.m_vertices;
m_count = polygon.m_vertexCount;
m_radius = polygon.m_radius;
break;
default:
b2Settings.b2Assert(false);
};
}
public function GetSupportVertex(d:b2Vec2):b2Vec2{
var value:Number;
var bestIndex:int;
var bestValue:Number = ((m_vertices[0].x * d.x) + (m_vertices[0].y * d.y));
var i = 1;
while (i < m_count) {
value = ((m_vertices[i].x * d.x) + (m_vertices[i].y * d.y));
if (value > bestValue){
bestIndex = i;
bestValue = value;
};
i++;
};
return (m_vertices[bestIndex]);
}
public function GetVertexCount():int{
return (m_count);
}
public function GetSupport(d:b2Vec2):Number{
var value:Number;
var bestIndex:int;
var bestValue:Number = ((m_vertices[0].x * d.x) + (m_vertices[0].y * d.y));
var i = 1;
while (i < m_count) {
value = ((m_vertices[i].x * d.x) + (m_vertices[i].y * d.y));
if (value > bestValue){
bestIndex = i;
bestValue = value;
};
i++;
};
return (bestIndex);
}
}
}//package Box2D.Collision
Section 63
//b2DynamicTree (Box2D.Collision.b2DynamicTree)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2DynamicTree {
private var m_insertionCount:int;
private var m_root:b2DynamicTreeNode;
private var m_freeList:b2DynamicTreeNode;
private var m_path:uint;
public function b2DynamicTree(){
super();
m_root = null;
m_freeList = null;
m_path = 0;
m_insertionCount = 0;
}
private function RemoveLeaf(leaf:b2DynamicTreeNode):void{
var sibling:b2DynamicTreeNode;
var oldAABB:b2AABB;
if (leaf == m_root){
m_root = null;
return;
};
var node2:b2DynamicTreeNode = leaf.parent;
var node1:b2DynamicTreeNode = node2.parent;
if (node2.child1 == leaf){
sibling = node2.child2;
} else {
sibling = node2.child1;
};
if (node1){
if (node1.child1 == node2){
node1.child1 = sibling;
} else {
node1.child2 = sibling;
};
sibling.parent = node1;
FreeNode(node2);
while (node1) {
oldAABB = node1.aabb;
node1.aabb = b2AABB.Combine(node1.child1.aabb, node1.child2.aabb);
if (oldAABB.Contains(node1.aabb)){
break;
};
node1 = node1.parent;
};
} else {
m_root = sibling;
sibling.parent = null;
FreeNode(node2);
};
}
public function GetFatAABB(proxy:b2DynamicTreeNode):b2AABB{
return (proxy.aabb);
}
public function Query(callback:Function, aabb:b2AABB):void{
var node:b2DynamicTreeNode;
var proceed:Boolean;
if (m_root == null){
return;
};
var stack:Array = new Array();
var count:int;
var _temp1 = count;
count = (count + 1);
var _local7 = _temp1;
stack[_local7] = m_root;
while (count > 0) {
--count;
node = stack[count];
if (node.aabb.TestOverlap(aabb)){
if (node.IsLeaf()){
proceed = callback(node);
if (!proceed){
return;
};
} else {
var _temp2 = count;
count = (count + 1);
var _local8 = _temp2;
stack[_local8] = node.child1;
var _temp3 = count;
count = (count + 1);
var _local9 = _temp3;
stack[_local9] = node.child2;
};
};
};
}
public function RayCast(callback:Function, input:b2RayCastInput):void{
var p1:b2Vec2;
var segmentAABB:b2AABB;
var tX:Number;
var tY:Number;
var node:b2DynamicTreeNode;
var c:b2Vec2;
var h:b2Vec2;
var separation:Number;
var subInput:b2RayCastInput;
if (m_root == null){
return;
};
p1 = input.p1;
var p2:b2Vec2 = input.p2;
var r:b2Vec2 = b2Math.SubtractVV(p1, p2);
r.Normalize();
var v:b2Vec2 = b2Math.CrossFV(1, r);
var abs_v:b2Vec2 = b2Math.AbsV(v);
var maxFraction:Number = input.maxFraction;
segmentAABB = new b2AABB();
tX = (p1.x + (maxFraction * (p2.x - p1.x)));
tY = (p1.y + (maxFraction * (p2.y - p1.y)));
segmentAABB.lowerBound.x = Math.min(p1.x, tX);
segmentAABB.lowerBound.y = Math.min(p1.y, tY);
segmentAABB.upperBound.x = Math.max(p1.x, tX);
segmentAABB.upperBound.y = Math.max(p1.y, tY);
var stack:Array = new Array();
var count:int;
var _temp1 = count;
count = (count + 1);
var _local19 = _temp1;
stack[_local19] = m_root;
while (count > 0) {
--count;
node = stack[count];
if (node.aabb.TestOverlap(segmentAABB) == false){
} else {
c = node.aabb.GetCenter();
h = node.aabb.GetExtents();
separation = ((Math.abs(((v.x * (p1.x - c.x)) + (v.y * (p1.y - c.y)))) - (abs_v.x * h.x)) - (abs_v.y * h.y));
if (separation > 0){
} else {
if (node.IsLeaf()){
subInput = new b2RayCastInput();
subInput.p1 = input.p1;
subInput.p2 = input.p2;
subInput.maxFraction = input.maxFraction;
maxFraction = callback(subInput, node);
if (maxFraction == 0){
return;
};
tX = (p1.x + (maxFraction * (p2.x - p1.x)));
tY = (p1.y + (maxFraction * (p2.y - p1.y)));
segmentAABB.lowerBound.x = Math.min(p1.x, tX);
segmentAABB.lowerBound.y = Math.min(p1.y, tY);
segmentAABB.upperBound.x = Math.max(p1.x, tX);
segmentAABB.upperBound.y = Math.max(p1.y, tY);
} else {
var _temp2 = count;
count = (count + 1);
var _local20 = _temp2;
stack[_local20] = node.child1;
var _temp3 = count;
count = (count + 1);
var _local21 = _temp3;
stack[_local21] = node.child2;
};
};
};
};
}
public function GetUserData(proxy:b2DynamicTreeNode){
return (proxy.userData);
}
private function FreeNode(node:b2DynamicTreeNode):void{
node.parent = m_freeList;
m_freeList = node;
}
public function Rebalance(iterations:int):void{
var node:b2DynamicTreeNode;
var bit:uint;
if (m_root == null){
return;
};
var i:int;
while (i < iterations) {
node = m_root;
bit = 0;
while (node.IsLeaf() == false) {
node = (((m_path >> bit) & 1)) ? node.child2 : node.child1;
bit = ((bit + 1) & 31);
};
m_path++;
RemoveLeaf(node);
InsertLeaf(node);
i++;
};
}
public function CreateProxy(aabb:b2AABB, userData):b2DynamicTreeNode{
var node:b2DynamicTreeNode;
var extendX:Number;
var extendY:Number;
node = AllocateNode();
extendX = b2Settings.b2_aabbExtension;
extendY = b2Settings.b2_aabbExtension;
node.aabb.lowerBound.x = (aabb.lowerBound.x - extendX);
node.aabb.lowerBound.y = (aabb.lowerBound.y - extendY);
node.aabb.upperBound.x = (aabb.upperBound.x + extendX);
node.aabb.upperBound.y = (aabb.upperBound.y + extendY);
node.userData = userData;
InsertLeaf(node);
return (node);
}
public function DestroyProxy(proxy:b2DynamicTreeNode):void{
RemoveLeaf(proxy);
FreeNode(proxy);
}
private function InsertLeaf(leaf:b2DynamicTreeNode):void{
var child1:*;
var child2:*;
var norm1:*;
var norm2:*;
m_insertionCount++;
if (m_root == null){
m_root = leaf;
m_root.parent = null;
return;
};
var center:b2Vec2 = leaf.aabb.GetCenter();
var sibling:b2DynamicTreeNode = m_root;
if (sibling.IsLeaf() == false){
do {
child1 = sibling.child1;
child2 = sibling.child2;
norm1 = (Math.abs((((child1.aabb.lowerBound.x + child1.aabb.upperBound.x) / 2) - center.x)) + Math.abs((((child1.aabb.lowerBound.y + child1.aabb.upperBound.y) / 2) - center.y)));
norm2 = (Math.abs((((child2.aabb.lowerBound.x + child2.aabb.upperBound.x) / 2) - center.x)) + Math.abs((((child2.aabb.lowerBound.y + child2.aabb.upperBound.y) / 2) - center.y)));
if (norm1 < norm2){
sibling = child1;
} else {
sibling = child2;
};
} while (sibling.IsLeaf() == false);
};
var node1:b2DynamicTreeNode = sibling.parent;
var node2:b2DynamicTreeNode = AllocateNode();
node2.parent = node1;
node2.userData = null;
node2.aabb.Combine(leaf.aabb, sibling.aabb);
if (node1){
if (sibling.parent.child1 == sibling){
node1.child1 = node2;
} else {
node1.child2 = node2;
};
node2.child1 = sibling;
node2.child2 = leaf;
sibling.parent = node2;
leaf.parent = node2;
do {
} while (!(node1.aabb.Contains(node2.aabb)));
} else {
node2.child1 = sibling;
node2.child2 = leaf;
sibling.parent = node2;
leaf.parent = node2;
m_root = node2;
};
}
public function MoveProxy(proxy:b2DynamicTreeNode, aabb:b2AABB, displacement:b2Vec2):Boolean{
var extendX:Number;
var extendY:Number;
b2Settings.b2Assert(proxy.IsLeaf());
if (proxy.aabb.Contains(aabb)){
return (false);
};
RemoveLeaf(proxy);
extendX = (b2Settings.b2_aabbExtension + (b2Settings.b2_aabbMultiplier * ((displacement.x > 0)) ? displacement.x : -(displacement.x)));
extendY = (b2Settings.b2_aabbExtension + (b2Settings.b2_aabbMultiplier * ((displacement.y > 0)) ? displacement.y : -(displacement.y)));
proxy.aabb.lowerBound.x = (aabb.lowerBound.x - extendX);
proxy.aabb.lowerBound.y = (aabb.lowerBound.y - extendY);
proxy.aabb.upperBound.x = (aabb.upperBound.x + extendX);
proxy.aabb.upperBound.y = (aabb.upperBound.y + extendY);
InsertLeaf(proxy);
return (true);
}
private function AllocateNode():b2DynamicTreeNode{
var node:b2DynamicTreeNode;
if (m_freeList){
node = m_freeList;
m_freeList = node.parent;
node.parent = null;
node.child1 = null;
node.child2 = null;
return (node);
};
return (new b2DynamicTreeNode());
}
}
}//package Box2D.Collision
Section 64
//b2DynamicTreeBroadPhase (Box2D.Collision.b2DynamicTreeBroadPhase)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2DynamicTreeBroadPhase implements IBroadPhase {
private var m_moveBuffer:Array;
private var m_tree:b2DynamicTree;
private var m_pairBuffer:Array;
private var m_pairCount:int;// = 0
private var m_proxyCount:int;
public function b2DynamicTreeBroadPhase(){
m_tree = new b2DynamicTree();
m_moveBuffer = new Array();
m_pairBuffer = new Array();
super();
}
public function Validate():void{
}
private function UnBufferMove(proxy:b2DynamicTreeNode):void{
var i:int = m_moveBuffer.indexOf(proxy);
m_moveBuffer.splice(i, 1);
}
private function BufferMove(proxy:b2DynamicTreeNode):void{
m_moveBuffer[m_moveBuffer.length] = proxy;
}
private function ComparePairs(pair1:b2DynamicTreePair, pair2:b2DynamicTreePair):int{
return (0);
}
public function GetProxyCount():int{
return (m_proxyCount);
}
public function GetFatAABB(proxy):b2AABB{
return (m_tree.GetFatAABB(proxy));
}
public function Query(callback:Function, aabb:b2AABB):void{
m_tree.Query(callback, aabb);
}
public function Rebalance(iterations:int):void{
m_tree.Rebalance(iterations);
}
public function TestOverlap(proxyA, proxyB):Boolean{
var aabbA:b2AABB = m_tree.GetFatAABB(proxyA);
var aabbB:b2AABB = m_tree.GetFatAABB(proxyB);
return (aabbA.TestOverlap(aabbB));
}
public function UpdatePairs(callback:Function):void{
var queryProxy:b2DynamicTreeNode;
var i:int;
var fatAABB:b2AABB;
var primaryPair:b2DynamicTreePair;
var userDataA:*;
var userDataB:*;
var pair:b2DynamicTreePair;
var callback = callback;
m_pairCount = 0;
for each (queryProxy in m_moveBuffer) {
var QueryCallback:Function = function (proxy:b2DynamicTreeNode):Boolean{
if (proxy == queryProxy){
return (true);
};
if (m_pairCount == m_pairBuffer.length){
m_pairBuffer[m_pairCount] = new b2DynamicTreePair();
};
var pair:b2DynamicTreePair = m_pairBuffer[m_pairCount];
pair.proxyA = ((proxy < queryProxy)) ? proxy : queryProxy;
pair.proxyB = ((proxy >= queryProxy)) ? proxy : queryProxy;
m_pairCount++;
return (true);
};
fatAABB = m_tree.GetFatAABB(queryProxy);
m_tree.Query(QueryCallback, fatAABB);
};
m_moveBuffer.length = 0;
i = 0;
while (i < m_pairCount) {
primaryPair = m_pairBuffer[i];
userDataA = m_tree.GetUserData(primaryPair.proxyA);
userDataB = m_tree.GetUserData(primaryPair.proxyB);
callback(userDataA, userDataB);
i = (i + 1);
while (i < m_pairCount) {
pair = m_pairBuffer[i];
if (((!((pair.proxyA == primaryPair.proxyA))) || (!((pair.proxyB == primaryPair.proxyB))))){
break;
};
i = (i + 1);
};
};
}
public function RayCast(callback:Function, input:b2RayCastInput):void{
m_tree.RayCast(callback, input);
}
public function CreateProxy(aabb:b2AABB, userData){
var proxy:b2DynamicTreeNode = m_tree.CreateProxy(aabb, userData);
m_proxyCount++;
BufferMove(proxy);
return (proxy);
}
public function GetUserData(proxy){
return (m_tree.GetUserData(proxy));
}
public function DestroyProxy(proxy):void{
UnBufferMove(proxy);
m_proxyCount--;
m_tree.DestroyProxy(proxy);
}
public function MoveProxy(proxy, aabb:b2AABB, displacement:b2Vec2):void{
var buffer:Boolean = m_tree.MoveProxy(proxy, aabb, displacement);
if (buffer){
BufferMove(proxy);
};
}
}
}//package Box2D.Collision
Section 65
//b2DynamicTreeNode (Box2D.Collision.b2DynamicTreeNode)
package Box2D.Collision {
public class b2DynamicTreeNode {
public var aabb:b2AABB;
public var parent:b2DynamicTreeNode;
public var userData;
public var child2:b2DynamicTreeNode;
public var child1:b2DynamicTreeNode;
public function b2DynamicTreeNode(){
aabb = new b2AABB();
super();
}
public function IsLeaf():Boolean{
return ((child1 == null));
}
}
}//package Box2D.Collision
Section 66
//b2DynamicTreePair (Box2D.Collision.b2DynamicTreePair)
package Box2D.Collision {
public class b2DynamicTreePair {
public var proxyA:b2DynamicTreeNode;
public var proxyB:b2DynamicTreeNode;
public function b2DynamicTreePair(){
super();
}
}
}//package Box2D.Collision
Section 67
//b2Manifold (Box2D.Collision.b2Manifold)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Manifold {
public var m_pointCount:int;// = 0
public var m_localPlaneNormal:b2Vec2;
public var m_type:int;
public var m_points:Array;
public var m_localPoint:b2Vec2;
public static const e_circles:int = 1;
public static const e_faceA:int = 2;
public static const e_faceB:int = 4;
public function b2Manifold(){
super();
m_points = new Array(b2Settings.b2_maxManifoldPoints);
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
m_points[i] = new b2ManifoldPoint();
i++;
};
m_localPlaneNormal = new b2Vec2();
m_localPoint = new b2Vec2();
}
public function Set(m:b2Manifold):void{
m_pointCount = m.m_pointCount;
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
(m_points[i] as b2ManifoldPoint).Set(m.m_points[i]);
i++;
};
m_localPlaneNormal.SetV(m.m_localPlaneNormal);
m_localPoint.SetV(m.m_localPoint);
m_type = m.m_type;
}
public function Reset():void{
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
(m_points[i] as b2ManifoldPoint).Reset();
i++;
};
m_localPlaneNormal.SetZero();
m_localPoint.SetZero();
m_type = 0;
m_pointCount = 0;
}
public function Copy():b2Manifold{
var copy:b2Manifold = new b2Manifold();
copy.Set(this);
return (copy);
}
}
}//package Box2D.Collision
Section 68
//b2ManifoldPoint (Box2D.Collision.b2ManifoldPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2ManifoldPoint {
public var m_localPoint:b2Vec2;
public var m_tangentImpulse:Number;
public var m_normalImpulse:Number;
public var m_id:b2ContactID;
public function b2ManifoldPoint(){
m_localPoint = new b2Vec2();
m_id = new b2ContactID();
super();
Reset();
}
public function Set(m:b2ManifoldPoint):void{
m_localPoint.SetV(m.m_localPoint);
m_normalImpulse = m.m_normalImpulse;
m_tangentImpulse = m.m_tangentImpulse;
m_id.Set(m.m_id);
}
public function Reset():void{
m_localPoint.SetZero();
m_normalImpulse = 0;
m_tangentImpulse = 0;
m_id.key = 0;
}
}
}//package Box2D.Collision
Section 69
//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 70
//b2RayCastInput (Box2D.Collision.b2RayCastInput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2RayCastInput {
public var p1:b2Vec2;
public var maxFraction:Number;
public var p2:b2Vec2;
public function b2RayCastInput(p1:b2Vec2=null, p2:b2Vec2=null, maxFraction:Number=1){
p1 = new b2Vec2();
p2 = new b2Vec2();
super();
if (p1){
this.p1.SetV(p1);
};
if (p2){
this.p2.SetV(p2);
};
this.maxFraction = maxFraction;
}
}
}//package Box2D.Collision
Section 71
//b2RayCastOutput (Box2D.Collision.b2RayCastOutput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2RayCastOutput {
public var fraction:Number;
public var normal:b2Vec2;
public function b2RayCastOutput(){
normal = new b2Vec2();
super();
}
}
}//package Box2D.Collision
Section 72
//b2SeparationFunction (Box2D.Collision.b2SeparationFunction)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
class b2SeparationFunction {
public var m_proxyA:b2DistanceProxy;
public var m_proxyB:b2DistanceProxy;
public var m_type:int;
public var m_axis:b2Vec2;
public var m_localPoint:b2Vec2;
public static const e_faceA:int = 2;
public static const e_faceB:int = 4;
public static const e_points:int = 1;
function b2SeparationFunction(){
m_localPoint = new b2Vec2();
m_axis = new b2Vec2();
super();
}
public function Initialize(cache:b2SimplexCache, proxyA:b2DistanceProxy, transformA:b2Transform, proxyB:b2DistanceProxy, transformB:b2Transform):void{
var localPointA:b2Vec2;
var localPointA1:b2Vec2;
var localPointA2:b2Vec2;
var localPointB:b2Vec2;
var localPointB1:b2Vec2;
var localPointB2:b2Vec2;
var pointAX:Number;
var pointAY:Number;
var pointBX:Number;
var pointBY:Number;
var normalX:Number;
var normalY:Number;
var tMat:b2Mat22;
var tVec:b2Vec2;
var s:Number;
var sgn:Number;
var pA:b2Vec2;
var dA:b2Vec2;
var pB:b2Vec2;
var dB:b2Vec2;
var a:Number;
var e:Number;
var r:b2Vec2;
var c:Number;
var f:Number;
var b:Number;
var denom:Number;
var t:Number;
m_proxyA = proxyA;
m_proxyB = proxyB;
var count:int = cache.count;
b2Settings.b2Assert((((0 < count)) && ((count < 3))));
if (count == 1){
m_type = e_points;
localPointA = m_proxyA.GetVertex(cache.indexA[0]);
localPointB = m_proxyB.GetVertex(cache.indexB[0]);
tVec = localPointA;
tMat = transformA.R;
pointAX = (transformA.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
pointAY = (transformA.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tVec = localPointB;
tMat = transformB.R;
pointBX = (transformB.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
pointBY = (transformB.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
m_axis.x = (pointBX - pointAX);
m_axis.y = (pointBY - pointAY);
m_axis.Normalize();
} else {
if (cache.indexB[0] == cache.indexB[1]){
m_type = e_faceA;
localPointA1 = m_proxyA.GetVertex(cache.indexA[0]);
localPointA2 = m_proxyA.GetVertex(cache.indexA[1]);
localPointB = m_proxyB.GetVertex(cache.indexB[0]);
m_localPoint.x = (0.5 * (localPointA1.x + localPointA2.x));
m_localPoint.y = (0.5 * (localPointA1.y + localPointA2.y));
m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointA2, localPointA1), 1);
m_axis.Normalize();
tVec = m_axis;
tMat = transformA.R;
normalX = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
normalY = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tVec = m_localPoint;
tMat = transformA.R;
pointAX = (transformA.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
pointAY = (transformA.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tVec = localPointB;
tMat = transformB.R;
pointBX = (transformB.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
pointBY = (transformB.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
s = (((pointBX - pointAX) * normalX) + ((pointBY - pointAY) * normalY));
if (s < 0){
m_axis.NegativeSelf();
};
} else {
if (cache.indexA[0] == cache.indexA[0]){
m_type = e_faceB;
localPointB1 = m_proxyB.GetVertex(cache.indexB[0]);
localPointB2 = m_proxyB.GetVertex(cache.indexB[1]);
localPointA = m_proxyA.GetVertex(cache.indexA[0]);
m_localPoint.x = (0.5 * (localPointB1.x + localPointB2.x));
m_localPoint.y = (0.5 * (localPointB1.y + localPointB2.y));
m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointB2, localPointB1), 1);
m_axis.Normalize();
tVec = m_axis;
tMat = transformB.R;
normalX = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
normalY = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tVec = m_localPoint;
tMat = transformB.R;
pointBX = (transformB.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
pointBY = (transformB.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tVec = localPointA;
tMat = transformA.R;
pointAX = (transformA.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
pointAY = (transformA.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
s = (((pointAX - pointBX) * normalX) + ((pointAY - pointBY) * normalY));
if (s < 0){
m_axis.NegativeSelf();
};
} else {
localPointA1 = m_proxyA.GetVertex(cache.indexA[0]);
localPointA2 = m_proxyA.GetVertex(cache.indexA[1]);
localPointB1 = m_proxyB.GetVertex(cache.indexB[0]);
localPointB2 = m_proxyB.GetVertex(cache.indexB[1]);
pA = b2Math.MulX(transformA, localPointA);
dA = b2Math.MulMV(transformA.R, b2Math.SubtractVV(localPointA2, localPointA1));
pB = b2Math.MulX(transformB, localPointB);
dB = b2Math.MulMV(transformB.R, b2Math.SubtractVV(localPointB2, localPointB1));
a = ((dA.x * dA.x) + (dA.y * dA.y));
e = ((dB.x * dB.x) + (dB.y * dB.y));
r = b2Math.SubtractVV(dB, dA);
c = ((dA.x * r.x) + (dA.y * r.y));
f = ((dB.x * r.x) + (dB.y * r.y));
b = ((dA.x * dB.x) + (dA.y * dB.y));
denom = ((a * e) - (b * b));
s = 0;
if (denom != 0){
s = b2Math.Clamp((((b * f) - (c * e)) / denom), 0, 1);
};
t = (((b * s) + f) / e);
if (t < 0){
t = 0;
s = b2Math.Clamp(((b - c) / a), 0, 1);
};
localPointA = new b2Vec2();
localPointA.x = (localPointA1.x + (s * (localPointA2.x - localPointA1.x)));
localPointA.y = (localPointA1.y + (s * (localPointA2.y - localPointA1.y)));
localPointB = new b2Vec2();
localPointB.x = (localPointB1.x + (s * (localPointB2.x - localPointB1.x)));
localPointB.y = (localPointB1.y + (s * (localPointB2.y - localPointB1.y)));
if ((((s == 0)) || ((s == 1)))){
m_type = e_faceB;
m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointB2, localPointB1), 1);
m_axis.Normalize();
m_localPoint = localPointB;
tVec = m_axis;
tMat = transformB.R;
normalX = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
normalY = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tVec = m_localPoint;
tMat = transformB.R;
pointBX = (transformB.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
pointBY = (transformB.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tVec = localPointA;
tMat = transformA.R;
pointAX = (transformA.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
pointAY = (transformA.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
sgn = (((pointAX - pointBX) * normalX) + ((pointAY - pointBY) * normalY));
if (s < 0){
m_axis.NegativeSelf();
};
} else {
m_type = e_faceA;
m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointA2, localPointA1), 1);
m_localPoint = localPointA;
tVec = m_axis;
tMat = transformA.R;
normalX = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
normalY = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tVec = m_localPoint;
tMat = transformA.R;
pointAX = (transformA.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
pointAY = (transformA.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tVec = localPointB;
tMat = transformB.R;
pointBX = (transformB.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
pointBY = (transformB.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
sgn = (((pointBX - pointAX) * normalX) + ((pointBY - pointAY) * normalY));
if (s < 0){
m_axis.NegativeSelf();
};
};
};
};
};
}
public function Evaluate(transformA:b2Transform, transformB:b2Transform):Number{
var axisA:b2Vec2;
var axisB:b2Vec2;
var localPointA:b2Vec2;
var localPointB:b2Vec2;
var pointA:b2Vec2;
var pointB:b2Vec2;
var seperation:Number;
var normal:b2Vec2;
switch (m_type){
case e_points:
axisA = b2Math.MulTMV(transformA.R, m_axis);
axisB = b2Math.MulTMV(transformB.R, m_axis.GetNegative());
localPointA = m_proxyA.GetSupportVertex(axisA);
localPointB = m_proxyB.GetSupportVertex(axisB);
pointA = b2Math.MulX(transformA, localPointA);
pointB = b2Math.MulX(transformB, localPointB);
seperation = (((pointB.x - pointA.x) * m_axis.x) + ((pointB.y - pointA.y) * m_axis.y));
return (seperation);
case e_faceA:
normal = b2Math.MulMV(transformA.R, m_axis);
pointA = b2Math.MulX(transformA, m_localPoint);
axisB = b2Math.MulTMV(transformB.R, normal.GetNegative());
localPointB = m_proxyB.GetSupportVertex(axisB);
pointB = b2Math.MulX(transformB, localPointB);
seperation = (((pointB.x - pointA.x) * normal.x) + ((pointB.y - pointA.y) * normal.y));
return (seperation);
case e_faceB:
normal = b2Math.MulMV(transformB.R, m_axis);
pointB = b2Math.MulX(transformB, m_localPoint);
axisA = b2Math.MulTMV(transformA.R, normal.GetNegative());
localPointA = m_proxyA.GetSupportVertex(axisA);
pointA = b2Math.MulX(transformA, localPointA);
seperation = (((pointA.x - pointB.x) * normal.x) + ((pointA.y - pointB.y) * normal.y));
return (seperation);
default:
b2Settings.b2Assert(false);
return (0);
};
}
}
}//package Box2D.Collision
Section 73
//b2Simplex (Box2D.Collision.b2Simplex)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
class b2Simplex {
public var m_v1:b2SimplexVertex;
public var m_v2:b2SimplexVertex;
public var m_v3:b2SimplexVertex;
public var m_vertices:Array;
public var m_count:int;
function b2Simplex(){
m_v1 = new b2SimplexVertex();
m_v2 = new b2SimplexVertex();
m_v3 = new b2SimplexVertex();
m_vertices = new Array(3);
super();
m_vertices[0] = m_v1;
m_vertices[1] = m_v2;
m_vertices[2] = m_v3;
}
public function GetSearchDirection():b2Vec2{
var e12:b2Vec2;
var sgn:Number;
switch (m_count){
case 1:
return (m_v1.w.GetNegative());
case 2:
e12 = b2Math.SubtractVV(m_v2.w, m_v1.w);
sgn = b2Math.CrossVV(e12, m_v1.w.GetNegative());
if (sgn > 0){
return (b2Math.CrossFV(1, e12));
};
return (b2Math.CrossVF(e12, 1));
default:
b2Settings.b2Assert(false);
return (new b2Vec2());
};
}
public function WriteCache(cache:b2SimplexCache):void{
cache.metric = GetMetric();
cache.count = uint(m_count);
var vertices:Array = m_vertices;
var i:int;
while (i < m_count) {
cache.indexA[i] = uint(vertices[i].indexA);
cache.indexB[i] = uint(vertices[i].indexB);
i++;
};
}
public function GetMetric():Number{
switch (m_count){
case 0:
b2Settings.b2Assert(false);
return (0);
case 1:
return (0);
case 2:
return (b2Math.SubtractVV(m_v1.w, m_v2.w).Length());
case 3:
return (b2Math.CrossVV(b2Math.SubtractVV(m_v2.w, m_v1.w), b2Math.SubtractVV(m_v3.w, m_v1.w)));
default:
b2Settings.b2Assert(false);
return (0);
};
}
public function ReadCache(cache:b2SimplexCache, proxyA:b2DistanceProxy, transformA:b2Transform, proxyB:b2DistanceProxy, transformB:b2Transform):void{
var wALocal:b2Vec2;
var wBLocal:b2Vec2;
var v:b2SimplexVertex;
var metric1:Number;
var metric2:Number;
b2Settings.b2Assert((((0 <= cache.count)) && ((cache.count <= 3))));
m_count = cache.count;
var vertices:Array = m_vertices;
var i:int;
while (i < m_count) {
v = vertices[i];
v.indexA = cache.indexA[i];
v.indexB = cache.indexB[i];
wALocal = proxyA.GetVertex(v.indexA);
wBLocal = proxyB.GetVertex(v.indexB);
v.wA = b2Math.MulX(transformA, wALocal);
v.wB = b2Math.MulX(transformB, wBLocal);
v.w = b2Math.SubtractVV(v.wB, v.wA);
v.a = 0;
i++;
};
if (m_count > 1){
metric1 = cache.metric;
metric2 = GetMetric();
if ((((((metric2 < (0.5 * metric1))) || (((2 * metric1) < metric2)))) || ((metric2 < Number.MIN_VALUE)))){
m_count = 0;
};
};
if (m_count == 0){
v = vertices[0];
v.indexA = 0;
v.indexB = 0;
wALocal = proxyA.GetVertex(0);
wBLocal = proxyB.GetVertex(0);
v.wA = b2Math.MulX(transformA, wALocal);
v.wB = b2Math.MulX(transformB, wBLocal);
v.w = b2Math.SubtractVV(v.wB, v.wA);
m_count = 1;
};
}
public function GetWitnessPoints(pA:b2Vec2, pB:b2Vec2):void{
switch (m_count){
case 0:
b2Settings.b2Assert(false);
break;
case 1:
pA.SetV(m_v1.wA);
pB.SetV(m_v1.wB);
break;
case 2:
pA.x = ((m_v1.a * m_v1.wA.x) + (m_v2.a * m_v2.wA.x));
pA.y = ((m_v1.a * m_v1.wA.y) + (m_v2.a * m_v2.wA.y));
pB.x = ((m_v1.a * m_v1.wB.x) + (m_v2.a * m_v2.wB.x));
pB.y = ((m_v1.a * m_v1.wB.y) + (m_v2.a * m_v2.wB.y));
break;
case 3:
pB.x = (pA.x = (((m_v1.a * m_v1.wA.x) + (m_v2.a * m_v2.wA.x)) + (m_v3.a * m_v3.wA.x)));
pB.y = (pA.y = (((m_v1.a * m_v1.wA.y) + (m_v2.a * m_v2.wA.y)) + (m_v3.a * m_v3.wA.y)));
break;
default:
b2Settings.b2Assert(false);
break;
};
}
public function Solve2():void{
var w1:b2Vec2 = m_v1.w;
var w2:b2Vec2 = m_v2.w;
var e12:b2Vec2 = b2Math.SubtractVV(w2, w1);
var d12_2:Number = -(((w1.x * e12.x) + (w1.y * e12.y)));
if (d12_2 <= 0){
m_v1.a = 1;
m_count = 1;
return;
};
var d12_1:Number = ((w2.x * e12.x) + (w2.y * e12.y));
if (d12_1 <= 0){
m_v2.a = 1;
m_count = 1;
m_v1.Set(m_v2);
return;
};
var inv_d12:Number = (1 / (d12_1 + d12_2));
m_v1.a = (d12_1 * inv_d12);
m_v2.a = (d12_2 * inv_d12);
m_count = 2;
}
public function Solve3():void{
var inv_d12:Number;
var inv_d13:Number;
var inv_d23:Number;
var w1:b2Vec2 = m_v1.w;
var w2:b2Vec2 = m_v2.w;
var w3:b2Vec2 = m_v3.w;
var e12:b2Vec2 = b2Math.SubtractVV(w2, w1);
var w1e12:Number = b2Math.Dot(w1, e12);
var w2e12:Number = b2Math.Dot(w2, e12);
var d12_1:Number = w2e12;
var d12_2:Number = -(w1e12);
var e13:b2Vec2 = b2Math.SubtractVV(w3, w1);
var w1e13:Number = b2Math.Dot(w1, e13);
var w3e13:Number = b2Math.Dot(w3, e13);
var d13_1:Number = w3e13;
var d13_2:Number = -(w1e13);
var e23:b2Vec2 = b2Math.SubtractVV(w3, w2);
var w2e23:Number = b2Math.Dot(w2, e23);
var w3e23:Number = b2Math.Dot(w3, e23);
var d23_1:Number = w3e23;
var d23_2:Number = -(w2e23);
var n123:Number = b2Math.CrossVV(e12, e13);
var d123_1:Number = (n123 * b2Math.CrossVV(w2, w3));
var d123_2:Number = (n123 * b2Math.CrossVV(w3, w1));
var d123_3:Number = (n123 * b2Math.CrossVV(w1, w2));
if ((((d12_2 <= 0)) && ((d13_2 <= 0)))){
m_v1.a = 1;
m_count = 1;
return;
};
if ((((((d12_1 > 0)) && ((d12_2 > 0)))) && ((d123_3 <= 0)))){
inv_d12 = (1 / (d12_1 + d12_2));
m_v1.a = (d12_1 * inv_d12);
m_v2.a = (d12_2 * inv_d12);
m_count = 2;
return;
};
if ((((((d13_1 > 0)) && ((d13_2 > 0)))) && ((d123_2 <= 0)))){
inv_d13 = (1 / (d13_1 + d13_2));
m_v1.a = (d13_1 * inv_d13);
m_v3.a = (d13_2 * inv_d13);
m_count = 2;
m_v2.Set(m_v3);
return;
};
if ((((d12_1 <= 0)) && ((d23_2 <= 0)))){
m_v2.a = 1;
m_count = 1;
m_v1.Set(m_v2);
return;
};
if ((((d13_1 <= 0)) && ((d23_1 <= 0)))){
m_v3.a = 1;
m_count = 1;
m_v1.Set(m_v3);
return;
};
if ((((((d23_1 > 0)) && ((d23_2 > 0)))) && ((d123_1 <= 0)))){
inv_d23 = (1 / (d23_1 + d23_2));
m_v2.a = (d23_1 * inv_d23);
m_v3.a = (d23_2 * inv_d23);
m_count = 2;
m_v1.Set(m_v3);
return;
};
var inv_d123:Number = (1 / ((d123_1 + d123_2) + d123_3));
m_v1.a = (d123_1 * inv_d123);
m_v2.a = (d123_2 * inv_d123);
m_v3.a = (d123_3 * inv_d123);
m_count = 3;
}
public function GetClosestPoint():b2Vec2{
switch (m_count){
case 0:
b2Settings.b2Assert(false);
return (new b2Vec2());
case 1:
return (m_v1.w);
case 2:
return (new b2Vec2(((m_v1.a * m_v1.w.x) + (m_v2.a * m_v2.w.x)), ((m_v1.a * m_v1.w.y) + (m_v2.a * m_v2.w.y))));
default:
b2Settings.b2Assert(false);
return (new b2Vec2());
};
}
}
}//package Box2D.Collision
Section 74
//b2SimplexCache (Box2D.Collision.b2SimplexCache)
package Box2D.Collision {
public class b2SimplexCache {
public var metric:Number;
public var count:uint;
public var indexB:Array;
public var indexA:Array;
public function b2SimplexCache(){
indexA = new Array(3);
indexB = new Array(3);
super();
}
}
}//package Box2D.Collision
Section 75
//b2SimplexVertex (Box2D.Collision.b2SimplexVertex)
package Box2D.Collision {
import Box2D.Common.Math.*;
class b2SimplexVertex {
public var a:Number;
public var wA:b2Vec2;
public var wB:b2Vec2;
public var indexA:int;
public var indexB:int;
public var w:b2Vec2;
function b2SimplexVertex(){
super();
}
public function Set(other:b2SimplexVertex):void{
wA.SetV(other.wA);
wB.SetV(other.wB);
w.SetV(other.w);
a = other.a;
indexA = other.indexA;
indexB = other.indexB;
}
}
}//package Box2D.Collision
Section 76
//b2TimeOfImpact (Box2D.Collision.b2TimeOfImpact)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2TimeOfImpact {
private static var b2_toiCalls:int = 0;
private static var s_xfA:b2Transform = new b2Transform();
private static var s_distanceInput:b2DistanceInput = new b2DistanceInput();
private static var s_xfB:b2Transform = new b2Transform();
private static var s_distanceOutput:b2DistanceOutput = new b2DistanceOutput();
private static var b2_toiMaxRootIters:int = 0;
private static var s_cache:b2SimplexCache = new b2SimplexCache();
private static var b2_toiRootIters:int = 0;
private static var b2_toiIters:int = 0;
private static var b2_toiMaxIters:int = 0;
private static var s_fcn:b2SeparationFunction = new b2SeparationFunction();
public function b2TimeOfImpact(){
super();
}
public static function TimeOfImpact(input:b2TOIInput):Number{
var separation:Number;
var newAlpha:Number;
var x1:Number;
var x2:Number;
var f1:Number;
var f2:Number;
var rootIterCount:int;
var x:Number;
var f:Number;
b2_toiCalls++;
var proxyA:b2DistanceProxy = input.proxyA;
var proxyB:b2DistanceProxy = input.proxyB;
var sweepA:b2Sweep = input.sweepA;
var sweepB:b2Sweep = input.sweepB;
b2Settings.b2Assert((sweepA.t0 == sweepB.t0));
b2Settings.b2Assert(((1 - sweepA.t0) > Number.MIN_VALUE));
var radius:Number = (proxyA.m_radius + proxyB.m_radius);
var tolerance:Number = input.tolerance;
var alpha:Number = 0;
var k_maxIterations = 1000;
var iter:int;
var target:Number = 0;
s_cache.count = 0;
s_distanceInput.useRadii = false;
while (true) {
sweepA.GetTransform(s_xfA, alpha);
sweepB.GetTransform(s_xfB, alpha);
s_distanceInput.proxyA = proxyA;
s_distanceInput.proxyB = proxyB;
s_distanceInput.transformA = s_xfA;
s_distanceInput.transformB = s_xfB;
b2Distance.Distance(s_distanceOutput, s_cache, s_distanceInput);
if (s_distanceOutput.distance <= 0){
alpha = 1;
break;
};
s_fcn.Initialize(s_cache, proxyA, s_xfA, proxyB, s_xfB);
separation = s_fcn.Evaluate(s_xfA, s_xfB);
if (separation <= 0){
alpha = 1;
break;
};
if (iter == 0){
if (separation > radius){
target = b2Math.Max((radius - tolerance), (0.75 * radius));
} else {
target = b2Math.Max((separation - tolerance), (0.02 * radius));
};
};
if ((separation - target) < (0.5 * tolerance)){
if (iter == 0){
alpha = 1;
break;
};
break;
};
newAlpha = alpha;
x1 = alpha;
x2 = 1;
f1 = separation;
sweepA.GetTransform(s_xfA, x2);
sweepB.GetTransform(s_xfB, x2);
f2 = s_fcn.Evaluate(s_xfA, s_xfB);
if (f2 >= target){
alpha = 1;
break;
};
rootIterCount = 0;
while (true) {
if ((rootIterCount & 1)){
x = (x1 + (((target - f1) * (x2 - x1)) / (f2 - f1)));
} else {
x = (0.5 * (x1 + x2));
};
sweepA.GetTransform(s_xfA, x);
sweepB.GetTransform(s_xfB, x);
f = s_fcn.Evaluate(s_xfA, s_xfB);
if (b2Math.Abs((f - target)) < (0.025 * tolerance)){
newAlpha = x;
break;
};
if (f > target){
x1 = x;
f1 = f;
} else {
x2 = x;
f2 = f;
};
rootIterCount++;
b2_toiRootIters++;
if (rootIterCount == 50){
break;
};
};
b2_toiMaxRootIters = b2Math.Max(b2_toiMaxRootIters, rootIterCount);
if (newAlpha < ((1 + (100 * Number.MIN_VALUE)) * alpha)){
break;
};
alpha = newAlpha;
iter++;
b2_toiIters++;
if (iter == k_maxIterations){
break;
};
};
b2_toiMaxIters = b2Math.Max(b2_toiMaxIters, iter);
return (alpha);
}
}
}//package Box2D.Collision
Section 77
//b2TOIInput (Box2D.Collision.b2TOIInput)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2TOIInput {
public var proxyA:b2DistanceProxy;
public var proxyB:b2DistanceProxy;
public var sweepA:b2Sweep;
public var sweepB:b2Sweep;
public var tolerance:Number;
public function b2TOIInput(){
proxyA = new b2DistanceProxy();
proxyB = new b2DistanceProxy();
sweepA = new b2Sweep();
sweepB = new b2Sweep();
super();
}
}
}//package Box2D.Collision
Section 78
//b2WorldManifold (Box2D.Collision.b2WorldManifold)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2WorldManifold {
public var m_normal:b2Vec2;
public var m_points:Array;
public function b2WorldManifold(){
m_normal = new b2Vec2();
super();
m_points = new Array(b2Settings.b2_maxManifoldPoints);
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
m_points[i] = new b2Vec2();
i++;
};
}
public function Initialize(manifold:b2Manifold, xfA:b2Transform, radiusA:Number, xfB:b2Transform, radiusB:Number):void{
var i:int;
var tVec:b2Vec2;
var tMat:b2Mat22;
var normalX:Number;
var normalY:Number;
var planePointX:Number;
var planePointY:Number;
var clipPointX:Number;
var clipPointY:Number;
var pointAX:Number;
var pointAY:Number;
var pointBX:Number;
var pointBY:Number;
var dX:Number;
var dY:Number;
var d2:Number;
var cAX:Number;
var cAY:Number;
var cBX:Number;
var cBY:Number;
var d:Number;
if (manifold.m_pointCount == 0){
return;
};
switch (manifold.m_type){
case b2Manifold.e_circles:
tMat = xfA.R;
tVec = manifold.m_localPoint;
pointAX = ((xfA.position.x + (tMat.col1.x * tVec.x)) + (tMat.col2.x * tVec.y));
pointAY = ((xfA.position.y + (tMat.col1.y * tVec.x)) + (tMat.col2.y * tVec.y));
tMat = xfB.R;
tVec = manifold.m_points[0].m_localPoint;
pointBX = ((xfB.position.x + (tMat.col1.x * tVec.x)) + (tMat.col2.x * tVec.y));
pointBY = ((xfB.position.y + (tMat.col1.y * tVec.x)) + (tMat.col2.y * tVec.y));
dX = (pointBX - pointAX);
dY = (pointBY - pointAY);
d2 = ((dX * dX) + (dY * dY));
if (d2 > (Number.MIN_VALUE * Number.MIN_VALUE)){
d = Math.sqrt(d2);
m_normal.x = (dX / d);
m_normal.y = (dY / d);
} else {
m_normal.x = 1;
m_normal.y = 0;
};
cAX = (pointAX + (radiusA * m_normal.x));
cAY = (pointAY + (radiusA * m_normal.y));
cBX = (pointBX - (radiusB * m_normal.x));
cBY = (pointBY - (radiusB * m_normal.y));
m_points[0].x = (0.5 * (cAX + cBX));
m_points[0].y = (0.5 * (cAY + cBY));
break;
case b2Manifold.e_faceA:
tMat = xfA.R;
tVec = manifold.m_localPlaneNormal;
normalX = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
normalY = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = xfA.R;
tVec = manifold.m_localPoint;
planePointX = ((xfA.position.x + (tMat.col1.x * tVec.x)) + (tMat.col2.x * tVec.y));
planePointY = ((xfA.position.y + (tMat.col1.y * tVec.x)) + (tMat.col2.y * tVec.y));
m_normal.x = normalX;
m_normal.y = normalY;
i = 0;
while (i < manifold.m_pointCount) {
tMat = xfB.R;
tVec = manifold.m_points[i].m_localPoint;
clipPointX = ((xfB.position.x + (tMat.col1.x * tVec.x)) + (tMat.col2.x * tVec.y));
clipPointY = ((xfB.position.y + (tMat.col1.y * tVec.x)) + (tMat.col2.y * tVec.y));
m_points[i].x = (clipPointX + ((0.5 * (((radiusA - ((clipPointX - planePointX) * normalX)) - ((clipPointY - planePointY) * normalY)) - radiusB)) * normalX));
m_points[i].y = (clipPointY + ((0.5 * (((radiusA - ((clipPointX - planePointX) * normalX)) - ((clipPointY - planePointY) * normalY)) - radiusB)) * normalY));
i++;
};
break;
case b2Manifold.e_faceB:
tMat = xfB.R;
tVec = manifold.m_localPlaneNormal;
normalX = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
normalY = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = xfB.R;
tVec = manifold.m_localPoint;
planePointX = ((xfB.position.x + (tMat.col1.x * tVec.x)) + (tMat.col2.x * tVec.y));
planePointY = ((xfB.position.y + (tMat.col1.y * tVec.x)) + (tMat.col2.y * tVec.y));
m_normal.x = -(normalX);
m_normal.y = -(normalY);
i = 0;
while (i < manifold.m_pointCount) {
tMat = xfA.R;
tVec = manifold.m_points[i].m_localPoint;
clipPointX = ((xfA.position.x + (tMat.col1.x * tVec.x)) + (tMat.col2.x * tVec.y));
clipPointY = ((xfA.position.y + (tMat.col1.y * tVec.x)) + (tMat.col2.y * tVec.y));
m_points[i].x = (clipPointX + ((0.5 * (((radiusB - ((clipPointX - planePointX) * normalX)) - ((clipPointY - planePointY) * normalY)) - radiusA)) * normalX));
m_points[i].y = (clipPointY + ((0.5 * (((radiusB - ((clipPointX - planePointX) * normalX)) - ((clipPointY - planePointY) * normalY)) - radiusA)) * normalY));
i++;
};
break;
};
}
}
}//package Box2D.Collision
Section 79
//ClipVertex (Box2D.Collision.ClipVertex)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class ClipVertex {
public var id:b2ContactID;
public var v:b2Vec2;
public function ClipVertex(){
v = new b2Vec2();
id = new b2ContactID();
super();
}
public function Set(other:ClipVertex):void{
v.SetV(other.v);
id.Set(other.id);
}
}
}//package Box2D.Collision
Section 80
//Features (Box2D.Collision.Features)
package Box2D.Collision {
import Box2D.Common.*;
public class Features {
b2internal var _referenceEdge:int;
b2internal var _incidentEdge:int;
b2internal var _flip:int;
b2internal var _incidentVertex:int;
b2internal var _m_id:b2ContactID;
public function Features(){
super();
}
public function get referenceEdge():int{
return (_referenceEdge);
}
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 referenceEdge(value:int):void{
_referenceEdge = value;
_m_id._key = ((_m_id._key & 4294967040) | (_referenceEdge & 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 81
//IBroadPhase (Box2D.Collision.IBroadPhase)
package Box2D.Collision {
import Box2D.Common.Math.*;
public interface IBroadPhase {
function GetFatAABB():b2AABB;
function Query(_arg1:Function, _arg2:b2AABB):void;
function Rebalance(/Users/friedman/Desktop/Test/src;Box2D/Collision;IBroadPhase.as:int):void;
function GetUserData(*);
function UpdatePairs(/Users/friedman/Desktop/Test/src;Box2D/Collision;IBroadPhase.as:Function):void;
function CreateProxy(_arg1:b2AABB, _arg2);
function DestroyProxy(/Users/friedman/Desktop/Test/src;Box2D/Collision;IBroadPhase.as):void;
function TestOverlap(_arg1, _arg2):Boolean;
function Validate():void;
function GetProxyCount():int;
function RayCast(_arg1:Function, _arg2:b2RayCastInput):void;
function MoveProxy(_arg1, _arg2:b2AABB, _arg3:b2Vec2):void;
}
}//package Box2D.Collision
Section 82
//b2Mat22 (Box2D.Common.Math.b2Mat22)
package Box2D.Common.Math {
public class b2Mat22 {
public var col1:b2Vec2;
public var col2:b2Vec2;
public function b2Mat22(){
col1 = new b2Vec2();
col2 = new b2Vec2();
super();
col1.x = (col2.y = 1);
}
public function SetIdentity():void{
col1.x = 1;
col2.x = 0;
col1.y = 0;
col2.y = 1;
}
public function SetVV(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{
var mat:b2Mat22 = new b2Mat22();
mat.SetM(this);
return (mat);
}
public function GetInverse(out:b2Mat22):b2Mat22{
var b:Number;
var det:Number;
var a:Number = col1.x;
b = col2.x;
var c:Number = col1.y;
var d:Number = col2.y;
det = ((a * d) - (b * c));
if (det != 0){
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 GetAngle():Number{
return (Math.atan2(col1.y, col1.x));
}
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));
if (det != 0){
det = (1 / det);
};
out.x = (det * ((a22 * bX) - (a12 * bY)));
out.y = (det * ((a11 * bY) - (a21 * bX)));
return (out);
}
public static function FromAngle(angle:Number):b2Mat22{
var mat:b2Mat22 = new (b2Mat22);
mat.Set(angle);
return (mat);
}
public static function FromVV(c1:b2Vec2, c2:b2Vec2):b2Mat22{
var mat:b2Mat22 = new (b2Mat22);
mat.SetVV(c1, c2);
return (mat);
}
}
}//package Box2D.Common.Math
Section 83
//b2Mat33 (Box2D.Common.Math.b2Mat33)
package Box2D.Common.Math {
public class b2Mat33 {
public var col1:b2Vec3;
public var col2:b2Vec3;
public var col3:b2Vec3;
public function b2Mat33(c1:b2Vec3=null, c2:b2Vec3=null, c3:b2Vec3=null){
col1 = new b2Vec3();
col2 = new b2Vec3();
col3 = new b2Vec3();
super();
if (((((!(c1)) && (!(c2)))) && (!(c3)))){
col1.SetZero();
col2.SetZero();
col3.SetZero();
} else {
col1.SetV(c1);
col2.SetV(c2);
col3.SetV(c3);
};
}
public function SetIdentity():void{
col1.x = 1;
col2.x = 0;
col3.x = 0;
col1.y = 0;
col2.y = 1;
col3.y = 0;
col1.z = 0;
col2.z = 0;
col3.z = 1;
}
public function Solve22(out:b2Vec2, bX:Number, bY:Number):b2Vec2{
var a11:Number;
var a21:Number;
a11 = col1.x;
var a12:Number = col2.x;
a21 = col1.y;
var a22:Number = col2.y;
var det:Number = ((a11 * a22) - (a12 * a21));
if (det != 0){
det = (1 / det);
};
out.x = (det * ((a22 * bX) - (a12 * bY)));
out.y = (det * ((a11 * bY) - (a21 * bX)));
return (out);
}
public function SetZero():void{
col1.x = 0;
col2.x = 0;
col3.x = 0;
col1.y = 0;
col2.y = 0;
col3.y = 0;
col1.z = 0;
col2.z = 0;
col3.z = 0;
}
public function SetM(m:b2Mat33):void{
col1.SetV(m.col1);
col2.SetV(m.col2);
col3.SetV(m.col3);
}
public function AddM(m:b2Mat33):void{
col1.x = (col1.x + m.col1.x);
col1.y = (col1.y + m.col1.y);
col1.z = (col1.z + m.col1.z);
col2.x = (col2.x + m.col2.x);
col2.y = (col2.y + m.col2.y);
col2.z = (col2.z + m.col2.z);
col3.x = (col3.x + m.col3.x);
col3.y = (col3.y + m.col3.y);
col3.z = (col3.z + m.col3.z);
}
public function SetVVV(c1:b2Vec3, c2:b2Vec3, c3:b2Vec3):void{
col1.SetV(c1);
col2.SetV(c2);
col3.SetV(c3);
}
public function Copy():b2Mat33{
return (new b2Mat33(col1, col2, col3));
}
public function Solve33(out:b2Vec3, bX:Number, bY:Number, bZ:Number):b2Vec3{
var a11:Number = col1.x;
var a21:Number = col1.y;
var a31:Number = col1.z;
var a12:Number = col2.x;
var a22:Number = col2.y;
var a32:Number = col2.z;
var a13:Number = col3.x;
var a23:Number = col3.y;
var a33:Number = col3.z;
var det:Number = (((a11 * ((a22 * a33) - (a32 * a23))) + (a21 * ((a32 * a13) - (a12 * a33)))) + (a31 * ((a12 * a23) - (a22 * a13))));
if (det != 0){
det = (1 / det);
};
out.x = (det * (((bX * ((a22 * a33) - (a32 * a23))) + (bY * ((a32 * a13) - (a12 * a33)))) + (bZ * ((a12 * a23) - (a22 * a13)))));
out.y = (det * (((a11 * ((bY * a33) - (bZ * a23))) + (a21 * ((bZ * a13) - (bX * a33)))) + (a31 * ((bX * a23) - (bY * a13)))));
out.z = (det * (((a11 * ((a22 * bZ) - (a32 * bY))) + (a21 * ((a32 * bX) - (a12 * bZ)))) + (a31 * ((a12 * bY) - (a22 * bX)))));
return (out);
}
}
}//package Box2D.Common.Math
Section 84
//b2Math (Box2D.Common.Math.b2Math)
package Box2D.Common.Math {
public class b2Math {
public static const b2Transform_identity:b2Transform = new b2Transform(b2Vec2_zero, b2Mat22_identity);
public static const b2Mat22_identity:b2Mat22 = b2Mat22.FromVV(new b2Vec2(1, 0), new b2Vec2(0, 1));
public static const b2Vec2_zero:b2Vec2 = new b2Vec2(0, 0);
public function b2Math(){
super();
}
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 AbsM(A:b2Mat22):b2Mat22{
var B:b2Mat22 = b2Mat22.FromVV(AbsV(A.col1), AbsV(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 MulMM(A:b2Mat22, B:b2Mat22):b2Mat22{
var C:b2Mat22 = b2Mat22.FromVV(MulMV(A, B.col1), MulMV(A, B.col2));
return (C);
}
public static function NextPowerOfTwo(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 Max(a:Number, b:Number):Number{
return (((a > b)) ? a : b);
}
public static function MulMV(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);
}
public static function CrossVF(a:b2Vec2, s:Number):b2Vec2{
var v:b2Vec2 = new b2Vec2((s * a.y), (-(s) * a.x));
return (v);
}
public static function MaxV(a:b2Vec2, b:b2Vec2):b2Vec2{
var c:b2Vec2 = new b2Vec2(Max(a.x, b.x), Max(a.y, b.y));
return (c);
}
public static function AbsV(a:b2Vec2):b2Vec2{
var b:b2Vec2 = new b2Vec2(Abs(a.x), Abs(a.y));
return (b);
}
public static function Distance(a:b2Vec2, b:b2Vec2):Number{
var cX:Number = (a.x - b.x);
var cY:Number = (a.y - b.y);
return (Math.sqrt(((cX * cX) + (cY * cY))));
}
public static function MulTMM(A:b2Mat22, B:b2Mat22):b2Mat22{
var c1:b2Vec2 = new b2Vec2(Dot(A.col1, B.col1), Dot(A.col2, B.col1));
var c2:b2Vec2 = new b2Vec2(Dot(A.col1, B.col2), Dot(A.col2, B.col2));
var C:b2Mat22 = b2Mat22.FromVV(c1, c2);
return (C);
}
public static function DistanceSquared(a:b2Vec2, b:b2Vec2):Number{
var cX:Number = (a.x - b.x);
var cY:Number = (a.y - b.y);
return (((cX * cX) + (cY * cY)));
}
public static function RandomRange(lo:Number, hi:Number):Number{
var r:Number = Math.random();
r = (((hi - lo) * r) + lo);
return (r);
}
public static function Clamp(a:Number, low:Number, high:Number):Number{
return (((a < low)) ? low : ((a > high)) ? high : a);
}
public static function MulXT(T:b2Transform, v:b2Vec2):b2Vec2{
var a:b2Vec2;
var tX:Number;
a = SubtractVV(v, T.position);
tX = ((a.x * T.R.col1.x) + (a.y * T.R.col1.y));
a.y = ((a.x * T.R.col2.x) + (a.y * T.R.col2.y));
a.x = tX;
return (a);
}
public static function AddMM(A:b2Mat22, B:b2Mat22):b2Mat22{
var C:b2Mat22 = b2Mat22.FromVV(AddVV(A.col1, B.col1), AddVV(A.col2, B.col2));
return (C);
}
public static function Random():Number{
return (((Math.random() * 2) - 1));
}
public static function MinV(a:b2Vec2, b:b2Vec2):b2Vec2{
var c:b2Vec2 = new b2Vec2(Min(a.x, b.x), Min(a.y, b.y));
return (c);
}
public static function CrossVV(a:b2Vec2, b:b2Vec2):Number{
return (((a.x * b.y) - (a.y * b.x)));
}
public static function MulTMV(A:b2Mat22, v:b2Vec2):b2Vec2{
var u:b2Vec2 = new b2Vec2(Dot(v, A.col1), Dot(v, A.col2));
return (u);
}
public static function Dot(a:b2Vec2, b:b2Vec2):Number{
return (((a.x * b.x) + (a.y * b.y)));
}
public static function Abs(a:Number):Number{
return (((a > 0)) ? a : -(a));
}
public static function CrossFV(s:Number, a:b2Vec2):b2Vec2{
var v:b2Vec2 = new b2Vec2((-(s) * a.y), (s * a.x));
return (v);
}
public static function Min(a:Number, b:Number):Number{
return (((a < b)) ? a : b);
}
public static function ClampV(a:b2Vec2, low:b2Vec2, high:b2Vec2):b2Vec2{
return (MaxV(low, MinV(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 Swap(a:Array, b:Array):void{
var tmp:* = a[0];
a[0] = b[0];
b[0] = tmp;
}
public static function MulX(T:b2Transform, v:b2Vec2):b2Vec2{
var a:b2Vec2;
a = MulMV(T.R, v);
a.x = (a.x + T.position.x);
a.y = (a.y + T.position.y);
return (a);
}
public static function IsPowerOfTwo(x:uint):Boolean{
var result:Boolean = (((x > 0)) && (((x & (x - 1)) == 0)));
return (result);
}
public static function IsValid(x:Number):Boolean{
return (isFinite(x));
}
}
}//package Box2D.Common.Math
Section 85
//b2Sweep (Box2D.Common.Math.b2Sweep)
package Box2D.Common.Math {
public class b2Sweep {
public var localCenter:b2Vec2;
public var a:Number;
public var c:b2Vec2;
public var c0:b2Vec2;
public var a0:Number;
public var t0:Number;
public function b2Sweep(){
localCenter = new b2Vec2();
c0 = new b2Vec2();
c = new b2Vec2();
super();
}
public function Advance(t:Number):void{
var alpha:Number;
if ((((t0 < t)) && (((1 - t0) > Number.MIN_VALUE)))){
alpha = ((t - t0) / (1 - t0));
c0.x = (((1 - alpha) * c0.x) + (alpha * c.x));
c0.y = (((1 - alpha) * c0.y) + (alpha * c.y));
a0 = (((1 - alpha) * a0) + (alpha * a));
t0 = t;
};
}
public function Set(other:b2Sweep):void{
localCenter.SetV(other.localCenter);
c0.SetV(other.c0);
c.SetV(other.c);
a0 = other.a0;
a = other.a;
t0 = other.t0;
}
public function Copy():b2Sweep{
var copy:b2Sweep = new b2Sweep();
copy.localCenter.SetV(localCenter);
copy.c0.SetV(c0);
copy.c.SetV(c);
copy.a0 = a0;
copy.a = a;
copy.t0 = t0;
return (copy);
}
public function GetTransform(xf:b2Transform, alpha:Number):void{
xf.position.x = (((1 - alpha) * c0.x) + (alpha * c.x));
xf.position.y = (((1 - alpha) * c0.y) + (alpha * c.y));
var angle:Number = (((1 - alpha) * a0) + (alpha * a));
xf.R.Set(angle);
var tMat:b2Mat22 = xf.R;
xf.position.x = (xf.position.x - ((tMat.col1.x * localCenter.x) + (tMat.col2.x * localCenter.y)));
xf.position.y = (xf.position.y - ((tMat.col1.y * localCenter.x) + (tMat.col2.y * localCenter.y)));
}
}
}//package Box2D.Common.Math
Section 86
//b2Transform (Box2D.Common.Math.b2Transform)
package Box2D.Common.Math {
public class b2Transform {
public var position:b2Vec2;
public var R:b2Mat22;
public function b2Transform(pos:b2Vec2=null, r:b2Mat22=null):void{
position = new b2Vec2();
R = new b2Mat22();
super();
if (pos){
position.SetV(pos);
R.SetM(r);
};
}
public function Initialize(pos:b2Vec2, r:b2Mat22):void{
position.SetV(pos);
R.SetM(r);
}
public function Set(x:b2Transform):void{
position.SetV(x.position);
R.SetM(x.R);
}
public function SetIdentity():void{
position.SetZero();
R.SetIdentity();
}
public function GetAngle():Number{
return (Math.atan2(R.col1.y, R.col1.x));
}
}
}//package Box2D.Common.Math
Section 87
//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 NegativeSelf():void{
x = -(x);
y = -(y);
}
public function Set(x_:Number=0, y_:Number=0):void{
x = x_;
y = y_;
}
public function LengthSquared():Number{
return (((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 Add(v:b2Vec2):void{
x = (x + v.x);
y = (y + v.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 GetNegative():b2Vec2{
return (new b2Vec2(-(x), -(y)));
}
public function Normalize():Number{
var length:Number = Math.sqrt(((x * x) + (y * y)));
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 Copy():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{
if (x < 0){
x = -(x);
};
if (y < 0){
y = -(y);
};
}
public function Subtract(v:b2Vec2):void{
x = (x - v.x);
y = (y - v.y);
}
public function MinV(b:b2Vec2):void{
x = ((x < b.x)) ? x : b.x;
y = ((y < b.y)) ? y : b.y;
}
public function MulTM(A:b2Mat22):void{
var tX:Number = b2Math.Dot(this, A.col1);
y = b2Math.Dot(this, A.col2);
x = tX;
}
public function IsValid():Boolean{
return (((b2Math.IsValid(x)) && (b2Math.IsValid(y))));
}
public static function Make(x_:Number, y_:Number):b2Vec2{
return (new b2Vec2(x_, y_));
}
}
}//package Box2D.Common.Math
Section 88
//b2Vec3 (Box2D.Common.Math.b2Vec3)
package Box2D.Common.Math {
public class b2Vec3 {
public var x:Number;
public var y:Number;
public var z:Number;
public function b2Vec3(x:Number=0, y:Number=0, z:Number=0){
super();
this.x = x;
this.y = y;
this.z = z;
}
public function NegativeSelf():void{
x = -(x);
y = -(y);
z = -(z);
}
public function Set(x:Number, y:Number, z:Number):void{
this.x = x;
this.y = y;
this.z = z;
}
public function Multiply(a:Number):void{
x = (x * a);
y = (y * a);
z = (z * a);
}
public function Add(v:b2Vec3):void{
x = (x + v.x);
y = (y + v.y);
z = (z + v.z);
}
public function SetZero():void{
x = (y = (z = 0));
}
public function GetNegative():b2Vec3{
return (new b2Vec3(-(x), -(y), -(z)));
}
public function SetV(v:b2Vec3):void{
x = v.x;
y = v.y;
z = v.z;
}
public function Copy():b2Vec3{
return (new b2Vec3(x, y, z));
}
public function Subtract(v:b2Vec3):void{
x = (x - v.x);
y = (y - v.y);
z = (z - v.z);
}
}
}//package Box2D.Common.Math
Section 89
//b2Color (Box2D.Common.b2Color)
package Box2D.Common {
import Box2D.Common.Math.*;
public class b2Color {
private var _r:uint;// = 0
private var _g:uint;// = 0
private var _b:uint;// = 0
public function b2Color(rr:Number, gg:Number, bb:Number){
super();
_r = uint((0xFF * b2Math.Clamp(rr, 0, 1)));
_g = uint((0xFF * b2Math.Clamp(gg, 0, 1)));
_b = uint((0xFF * b2Math.Clamp(bb, 0, 1)));
}
public function Set(rr:Number, gg:Number, bb:Number):void{
_r = uint((0xFF * b2Math.Clamp(rr, 0, 1)));
_g = uint((0xFF * b2Math.Clamp(gg, 0, 1)));
_b = uint((0xFF * b2Math.Clamp(bb, 0, 1)));
}
public function set b(bb:Number):void{
_b = uint((0xFF * b2Math.Clamp(bb, 0, 1)));
}
public function get color():uint{
return ((((_r << 16) | (_g << 8)) | _b));
}
public function set r(rr:Number):void{
_r = uint((0xFF * b2Math.Clamp(rr, 0, 1)));
}
public function set g(gg:Number):void{
_g = uint((0xFF * b2Math.Clamp(gg, 0, 1)));
}
}
}//package Box2D.Common
Section 90
//b2internal (Box2D.Common.b2internal)
package Box2D.Common {
public namespace b2internal = "http://www.box2d.org/ns/b2internal";
}//package Box2D.Common
Section 91
//b2Settings (Box2D.Common.b2Settings)
package Box2D.Common {
public class b2Settings {
public static const b2_polygonRadius:Number = (2 * b2_linearSlop);
public static const b2_pi:Number = Math.PI;
public static const b2_aabbExtension:Number = 0.1;
public static const b2_linearSleepTolerance:Number = 0.01;
public static const b2_maxTranslationSquared:Number = 4;
public static const b2_angularSlop:Number = ((2 / 180) * b2_pi);
public static const b2_linearSlop:Number = 0.005;
public static const b2_maxRotation:Number = (0.5 * b2_pi);
public static const b2_maxRotationSquared:Number = (b2_maxRotation * b2_maxRotation);
public static const b2_angularSleepTolerance:Number = ((2 / 180) * b2Settings.b2_pi);
public static const b2_timeToSleep:Number = 0.5;
public static const b2_maxTOIJointsPerIsland:int = 32;
public static const b2_contactBaumgarte:Number = 0.2;
public static const b2_maxTOIContactsPerIsland:int = 32;
public static const b2_maxManifoldPoints:int = 2;
public static const b2_maxAngularCorrection:Number = ((8 / 180) * b2_pi);
public static const b2_velocityThreshold:Number = 1;
public static const USHRT_MAX:int = 0xFFFF;
public static const VERSION:String = "2.1alpha";
public static const b2_toiSlop:Number = 0.04;
public static const b2_maxTranslation:Number = 2;
public static const b2_aabbMultiplier:Number = 2;
public static const b2_maxLinearCorrection:Number = 0.2;
public function b2Settings(){
super();
}
public static function b2MixFriction(friction1:Number, friction2:Number):Number{
return (Math.sqrt((friction1 * friction2)));
}
public static function b2MixRestitution(restitution1:Number, restitution2:Number):Number{
return (((restitution1 > restitution2)) ? restitution1 : restitution2);
}
public static function b2Assert(a:Boolean):void{
if (!a){
throw ("Assertion Failed");
};
}
}
}//package Box2D.Common
Section 92
//b2CircleContact (Box2D.Dynamics.Contacts.b2CircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2CircleContact extends b2Contact {
public function b2CircleContact(){
super();
}
override b2internal function Evaluate():void{
var bA:b2Body = m_fixtureA.GetBody();
var bB:b2Body = m_fixtureB.GetBody();
b2Collision.CollideCircles(m_manifold, (m_fixtureA.GetShape() as b2CircleShape), bA.m_xf, (m_fixtureB.GetShape() as b2CircleShape), bB.m_xf);
}
public function Reset(fixtureA:b2Fixture, fixtureB:b2Fixture):void{
super.Reset(fixtureA, fixtureB);
}
public static function Destroy(contact:b2Contact, allocator):void{
}
public static function Create(allocator):b2Contact{
return (new (b2CircleContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 93
//b2Contact (Box2D.Dynamics.Contacts.b2Contact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Contact {
b2internal var m_prev:b2Contact;
b2internal var m_next:b2Contact;
b2internal var m_oldManifold:b2Manifold;
b2internal var m_manifold:b2Manifold;
b2internal var m_fixtureB:b2Fixture;
b2internal var m_fixtureA:b2Fixture;
b2internal var m_nodeA:b2ContactEdge;
b2internal var m_flags:uint;
b2internal var m_toi:Number;
b2internal var m_nodeB:b2ContactEdge;
b2internal static var e_sensorFlag:uint = 1;
private static var s_input:b2TOIInput = new b2TOIInput();
b2internal static var e_touchingFlag:uint = 16;
b2internal static var e_enabledFlag:uint = 32;
b2internal static var e_continuousFlag:uint = 2;
b2internal static var e_toiFlag:uint = 8;
b2internal static var e_islandFlag:uint = 4;
b2internal static var e_filterFlag:uint = 64;
public function b2Contact(){
m_nodeA = new b2ContactEdge();
m_nodeB = new b2ContactEdge();
m_manifold = new b2Manifold();
m_oldManifold = new b2Manifold();
super();
}
public function IsContinuous():Boolean{
return (((m_flags & e_continuousFlag) == e_continuousFlag));
}
public function GetNext():b2Contact{
return (m_next);
}
public function FlagForFiltering():void{
m_flags = (m_flags | e_filterFlag);
}
public function IsEnabled():Boolean{
return (((m_flags & e_enabledFlag) == e_enabledFlag));
}
public function SetSensor(sensor:Boolean):void{
if (sensor){
m_flags = (m_flags | e_sensorFlag);
} else {
m_flags = (m_flags & ~(e_sensorFlag));
};
}
public function SetEnabled(flag:Boolean):void{
if (flag){
m_flags = (m_flags | e_enabledFlag);
} else {
m_flags = (m_flags & ~(e_enabledFlag));
};
}
public function IsSensor():Boolean{
return (((m_flags & e_sensorFlag) == e_sensorFlag));
}
public function GetManifold():b2Manifold{
return (m_manifold);
}
b2internal function Update(listener:b2ContactListener):void{
var shapeA:b2Shape;
var shapeB:b2Shape;
var xfA:b2Transform;
var xfB:b2Transform;
var i:int;
var mp2:b2ManifoldPoint;
var id2:b2ContactID;
var j:int;
var mp1:b2ManifoldPoint;
var tManifold:b2Manifold = m_oldManifold;
m_oldManifold = m_manifold;
m_manifold = tManifold;
m_flags = (m_flags | e_enabledFlag);
var touching:Boolean;
var wasTouching = ((m_flags & e_touchingFlag) == e_touchingFlag);
var bodyA:b2Body = m_fixtureA.m_body;
var bodyB:b2Body = m_fixtureB.m_body;
var aabbOverlap:Boolean = m_fixtureA.m_aabb.TestOverlap(m_fixtureB.m_aabb);
if ((m_flags & e_sensorFlag)){
if (aabbOverlap){
shapeA = m_fixtureA.GetShape();
shapeB = m_fixtureB.GetShape();
xfA = bodyA.GetTransform();
xfB = bodyB.GetTransform();
touching = b2Shape.TestOverlap(shapeA, xfA, shapeB, xfB);
};
m_manifold.m_pointCount = 0;
} else {
if (((((((!((bodyA.GetType() == b2Body.b2_dynamicBody))) || (bodyA.IsBullet()))) || (!((bodyB.GetType() == b2Body.b2_dynamicBody))))) || (bodyB.IsBullet()))){
m_flags = (m_flags | e_continuousFlag);
} else {
m_flags = (m_flags & ~(e_continuousFlag));
};
if (aabbOverlap){
Evaluate();
touching = (m_manifold.m_pointCount > 0);
i = 0;
while (i < m_manifold.m_pointCount) {
mp2 = m_manifold.m_points[i];
mp2.m_normalImpulse = 0;
mp2.m_tangentImpulse = 0;
id2 = mp2.m_id;
j = 0;
while (j < m_oldManifold.m_pointCount) {
mp1 = m_oldManifold.m_points[j];
if (mp1.m_id.key == id2.key){
mp2.m_normalImpulse = mp1.m_normalImpulse;
mp2.m_tangentImpulse = mp1.m_tangentImpulse;
break;
};
j++;
};
i++;
};
} else {
m_manifold.m_pointCount = 0;
};
if (touching != wasTouching){
bodyA.SetAwake(true);
bodyB.SetAwake(true);
};
};
if (touching){
m_flags = (m_flags | e_touchingFlag);
} else {
m_flags = (m_flags & ~(e_touchingFlag));
};
if ((((wasTouching == false)) && ((touching == true)))){
listener.BeginContact(this);
};
if ((((wasTouching == true)) && ((touching == false)))){
listener.EndContact(this);
};
if ((m_flags & e_sensorFlag) == 0){
listener.PreSolve(this, m_oldManifold);
};
}
public function GetWorldManifold(worldManifold:b2WorldManifold):void{
var bodyA:b2Body = m_fixtureA.GetBody();
var bodyB:b2Body = m_fixtureB.GetBody();
var shapeA:b2Shape = m_fixtureA.GetShape();
var shapeB:b2Shape = m_fixtureB.GetShape();
worldManifold.Initialize(m_manifold, bodyA.GetTransform(), shapeA.m_radius, bodyB.GetTransform(), shapeB.m_radius);
}
public function IsTouching():Boolean{
return (((m_flags & e_touchingFlag) == e_touchingFlag));
}
public function GetFixtureA():b2Fixture{
return (m_fixtureA);
}
public function GetFixtureB():b2Fixture{
return (m_fixtureB);
}
b2internal function Reset(fixtureA:b2Fixture=null, fixtureB:b2Fixture=null):void{
m_flags = e_enabledFlag;
if (((!(fixtureA)) || (!(fixtureB)))){
m_fixtureA = null;
m_fixtureB = null;
return;
};
if (((fixtureA.IsSensor()) || (fixtureB.IsSensor()))){
m_flags = (m_flags | e_sensorFlag);
};
var bodyA:b2Body = fixtureA.GetBody();
var bodyB:b2Body = fixtureB.GetBody();
if (((((((!((bodyA.GetType() == b2Body.b2_dynamicBody))) || (bodyA.IsBullet()))) || (!((bodyB.GetType() == b2Body.b2_dynamicBody))))) || (bodyB.IsBullet()))){
m_flags = (m_flags | e_continuousFlag);
};
m_fixtureA = fixtureA;
m_fixtureB = fixtureB;
m_manifold.m_pointCount = 0;
m_prev = null;
m_next = null;
m_nodeA.contact = null;
m_nodeA.prev = null;
m_nodeA.next = null;
m_nodeA.other = null;
m_nodeB.contact = null;
m_nodeB.prev = null;
m_nodeB.next = null;
m_nodeB.other = null;
}
b2internal function ComputeTOI(sweepA:b2Sweep, sweepB:b2Sweep):Number{
s_input.proxyA.Set(m_fixtureA.GetShape());
s_input.proxyB.Set(m_fixtureB.GetShape());
s_input.sweepA = sweepA;
s_input.sweepB = sweepB;
s_input.tolerance = b2Settings.b2_linearSlop;
return (b2TimeOfImpact.TimeOfImpact(s_input));
}
b2internal function Evaluate():void{
}
}
}//package Box2D.Dynamics.Contacts
Section 94
//b2ContactConstraint (Box2D.Dynamics.Contacts.b2ContactConstraint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2ContactConstraint {
public var type:int;
public var normalMass:b2Mat22;
public var K:b2Mat22;
public var manifold:b2Manifold;
public var radius:Number;
public var bodyA:b2Body;
public var bodyB:b2Body;
public var points:Array;
public var localPoint:b2Vec2;
public var pointCount:int;
public var normal:b2Vec2;
public var restitution:Number;
public var localPlaneNormal:b2Vec2;
public var friction:Number;
public function b2ContactConstraint(){
localPlaneNormal = new b2Vec2();
localPoint = new b2Vec2();
normal = new b2Vec2();
normalMass = new b2Mat22();
K = new b2Mat22();
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
points[i] = new b2ContactConstraintPoint();
i++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 95
//b2ContactConstraintPoint (Box2D.Dynamics.Contacts.b2ContactConstraintPoint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
public class b2ContactConstraintPoint {
public var localPoint:b2Vec2;
public var normalImpulse:Number;
public var rA:b2Vec2;
public var rB:b2Vec2;
public var tangentImpulse:Number;
public var equalizedMass:Number;
public var tangentMass:Number;
public var normalMass:Number;
public var velocityBias:Number;
public function b2ContactConstraintPoint(){
localPoint = new b2Vec2();
rA = new b2Vec2();
rB = new b2Vec2();
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 96
//b2ContactEdge (Box2D.Dynamics.Contacts.b2ContactEdge)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
public class b2ContactEdge {
public var other:b2Body;
public var prev:b2ContactEdge;
public var contact:b2Contact;
public var next:b2ContactEdge;
public function b2ContactEdge(){
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 97
//b2ContactFactory (Box2D.Dynamics.Contacts.b2ContactFactory)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2ContactFactory {
private var m_allocator;
private var m_registers:Array;
public function b2ContactFactory(allocator){
super();
m_allocator = allocator;
InitializeRegisters();
}
b2internal function InitializeRegisters():void{
var j:int;
m_registers = new Array(b2Shape.e_shapeTypeCount);
var i:int;
while (i < b2Shape.e_shapeTypeCount) {
m_registers[i] = new Array(b2Shape.e_shapeTypeCount);
j = 0;
while (j < b2Shape.e_shapeTypeCount) {
m_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_polygonShape, b2Shape.e_circleShape);
AddType(b2PolygonContact.Create, b2PolygonContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_polygonShape);
AddType(b2EdgeAndCircleContact.Create, b2EdgeAndCircleContact.Destroy, b2Shape.e_edgeShape, b2Shape.e_circleShape);
AddType(b2PolyAndEdgeContact.Create, b2PolyAndEdgeContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_edgeShape);
}
public function Destroy(contact:b2Contact):void{
if (contact.m_manifold.m_pointCount > 0){
contact.m_fixtureA.m_body.SetAwake(true);
contact.m_fixtureB.m_body.SetAwake(true);
};
var type1:int = contact.m_fixtureA.GetType();
var type2:int = contact.m_fixtureB.GetType();
var reg:b2ContactRegister = m_registers[type1][type2];
reg.poolCount++;
contact.m_next = reg.pool;
reg.pool = contact;
var destroyFcn:Function = reg.destroyFcn;
destroyFcn(contact, m_allocator);
}
b2internal function AddType(createFcn:Function, destroyFcn:Function, type1:int, type2:int):void{
m_registers[type1][type2].createFcn = createFcn;
m_registers[type1][type2].destroyFcn = destroyFcn;
m_registers[type1][type2].primary = true;
if (type1 != type2){
m_registers[type2][type1].createFcn = createFcn;
m_registers[type2][type1].destroyFcn = destroyFcn;
m_registers[type2][type1].primary = false;
};
}
public function Create(fixtureA:b2Fixture, fixtureB:b2Fixture):b2Contact{
var c:b2Contact;
var type1:int = fixtureA.GetType();
var type2:int = fixtureB.GetType();
var reg:b2ContactRegister = m_registers[type1][type2];
if (reg.pool){
c = reg.pool;
reg.pool = c.m_next;
reg.poolCount--;
c.Reset(fixtureA, fixtureB);
return (c);
};
var createFcn:Function = reg.createFcn;
if (createFcn != null){
if (reg.primary){
c = createFcn(m_allocator);
c.Reset(fixtureA, fixtureB);
return (c);
};
c = createFcn(m_allocator);
c.Reset(fixtureB, fixtureA);
return (c);
//unresolved jump
};
return (null);
}
}
}//package Box2D.Dynamics.Contacts
Section 98
//b2ContactRegister (Box2D.Dynamics.Contacts.b2ContactRegister)
package Box2D.Dynamics.Contacts {
public class b2ContactRegister {
public var primary:Boolean;
public var poolCount:int;
public var createFcn:Function;
public var destroyFcn:Function;
public var pool:b2Contact;
public function b2ContactRegister(){
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 99
//b2ContactSolver (Box2D.Dynamics.Contacts.b2ContactSolver)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2ContactSolver {
private var m_constraintCount:int;
b2internal var m_constraints:Array;
private var m_allocator;
private var m_step:b2TimeStep;
private static var s_psm:b2PositionSolverManifold = new b2PositionSolverManifold();
private static var s_worldManifold:b2WorldManifold = new b2WorldManifold();
public function b2ContactSolver(){
m_step = new b2TimeStep();
m_constraints = new Array();
super();
}
public function InitVelocityConstraints(step:b2TimeStep):void{
var tVec:b2Vec2;
var tVec2:b2Vec2;
var tMat:b2Mat22;
var c:b2ContactConstraint;
var bodyA:b2Body;
var bodyB:b2Body;
var invMassA:Number;
var invIA:Number;
var invMassB:Number;
var invIB:Number;
var normalX:Number;
var normalY:Number;
var tangentX:Number;
var tangentY:Number;
var tX:Number;
var j:int;
var tCount:int;
var ccp:b2ContactConstraintPoint;
var PX:Number;
var PY:Number;
var ccp2:b2ContactConstraintPoint;
var i:int;
while (i < m_constraintCount) {
c = m_constraints[i];
bodyA = c.bodyA;
bodyB = c.bodyB;
invMassA = bodyA.m_invMass;
invIA = bodyA.m_invI;
invMassB = bodyB.m_invMass;
invIB = bodyB.m_invI;
normalX = c.normal.x;
normalY = c.normal.y;
tangentX = normalY;
tangentY = -(normalX);
if (step.warmStarting){
tCount = c.pointCount;
j = 0;
while (j < tCount) {
ccp = c.points[j];
ccp.normalImpulse = (ccp.normalImpulse * step.dtRatio);
ccp.tangentImpulse = (ccp.tangentImpulse * step.dtRatio);
PX = ((ccp.normalImpulse * normalX) + (ccp.tangentImpulse * tangentX));
PY = ((ccp.normalImpulse * normalY) + (ccp.tangentImpulse * tangentY));
bodyA.m_angularVelocity = (bodyA.m_angularVelocity - (invIA * ((ccp.rA.x * PY) - (ccp.rA.y * PX))));
bodyA.m_linearVelocity.x = (bodyA.m_linearVelocity.x - (invMassA * PX));
bodyA.m_linearVelocity.y = (bodyA.m_linearVelocity.y - (invMassA * PY));
bodyB.m_angularVelocity = (bodyB.m_angularVelocity + (invIB * ((ccp.rB.x * PY) - (ccp.rB.y * PX))));
bodyB.m_linearVelocity.x = (bodyB.m_linearVelocity.x + (invMassB * PX));
bodyB.m_linearVelocity.y = (bodyB.m_linearVelocity.y + (invMassB * PY));
j++;
};
} else {
tCount = c.pointCount;
j = 0;
while (j < tCount) {
ccp2 = c.points[j];
ccp2.normalImpulse = 0;
ccp2.tangentImpulse = 0;
j++;
};
};
i++;
};
}
public function SolvePositionConstraints(baumgarte:Number):Boolean{
var c:b2ContactConstraint;
var bodyA:b2Body;
var bodyB:b2Body;
var invMassA:Number;
var invIA:Number;
var invMassB:Number;
var invIB:Number;
var normal:b2Vec2;
var j:int;
var ccp:b2ContactConstraintPoint;
var point:b2Vec2;
var separation:Number;
var rAX:Number;
var rAY:Number;
var rBX:Number;
var rBY:Number;
var C:Number;
var impulse:Number;
var PX:Number;
var PY:Number;
var minSeparation:Number = 0;
var i:int;
while (i < m_constraintCount) {
c = m_constraints[i];
bodyA = c.bodyA;
bodyB = c.bodyB;
invMassA = (bodyA.m_mass * bodyA.m_invMass);
invIA = (bodyA.m_mass * bodyA.m_invI);
invMassB = (bodyB.m_mass * bodyB.m_invMass);
invIB = (bodyB.m_mass * bodyB.m_invI);
s_psm.Initialize(c);
normal = s_psm.m_normal;
j = 0;
while (j < c.pointCount) {
ccp = c.points[j];
point = s_psm.m_points[j];
separation = s_psm.m_separations[j];
rAX = (point.x - bodyA.m_sweep.c.x);
rAY = (point.y - bodyA.m_sweep.c.y);
rBX = (point.x - bodyB.m_sweep.c.x);
rBY = (point.y - bodyB.m_sweep.c.y);
minSeparation = ((minSeparation < separation)) ? minSeparation : separation;
C = b2Math.Clamp((baumgarte * (separation + b2Settings.b2_linearSlop)), -(b2Settings.b2_maxLinearCorrection), 0);
impulse = (-(ccp.equalizedMass) * C);
PX = (impulse * normal.x);
PY = (impulse * normal.y);
bodyA.m_sweep.c.x = (bodyA.m_sweep.c.x - (invMassA * PX));
bodyA.m_sweep.c.y = (bodyA.m_sweep.c.y - (invMassA * PY));
bodyA.m_sweep.a = (bodyA.m_sweep.a - (invIA * ((rAX * PY) - (rAY * PX))));
bodyA.SynchronizeTransform();
bodyB.m_sweep.c.x = (bodyB.m_sweep.c.x + (invMassB * PX));
bodyB.m_sweep.c.y = (bodyB.m_sweep.c.y + (invMassB * PY));
bodyB.m_sweep.a = (bodyB.m_sweep.a + (invIB * ((rBX * PY) - (rBY * PX))));
bodyB.SynchronizeTransform();
j++;
};
i++;
};
return ((minSeparation > (-1.5 * b2Settings.b2_linearSlop)));
}
public function Initialize(step:b2TimeStep, contacts:Array, contactCount:int, allocator):void{
var contact:b2Contact;
var i:int;
var tVec:b2Vec2;
var tMat:b2Mat22;
var fixtureA:b2Fixture;
var fixtureB:b2Fixture;
var shapeA:b2Shape;
var shapeB:b2Shape;
var radiusA:Number;
var radiusB:Number;
var bodyA:b2Body;
var bodyB:b2Body;
var manifold:b2Manifold;
var friction:Number;
var restitution:Number;
var vAX:Number;
var vAY:Number;
var vBX:Number;
var vBY:Number;
var wA:Number;
var wB:Number;
var normalX:Number;
var normalY:Number;
var cc:b2ContactConstraint;
var k:uint;
var cp:b2ManifoldPoint;
var ccp:b2ContactConstraintPoint;
var rAX:Number;
var rAY:Number;
var rBX:Number;
var rBY:Number;
var rnA:Number;
var rnB:Number;
var kNormal:Number;
var kEqualized:Number;
var tangentX:Number;
var tangentY:Number;
var rtA:Number;
var rtB:Number;
var kTangent:Number;
var tX:Number;
var tY:Number;
var vRel:Number;
var ccp1:b2ContactConstraintPoint;
var ccp2:b2ContactConstraintPoint;
var invMassA:Number;
var invIA:Number;
var invMassB:Number;
var invIB:Number;
var rn1A:Number;
var rn1B:Number;
var rn2A:Number;
var rn2B:Number;
var k11:Number;
var k22:Number;
var k12:Number;
var k_maxConditionNumber:Number;
m_step.Set(step);
m_allocator = allocator;
m_constraintCount = contactCount;
while (m_constraints.length < m_constraintCount) {
m_constraints[m_constraints.length] = new b2ContactConstraint();
};
i = 0;
while (i < contactCount) {
contact = contacts[i];
fixtureA = contact.m_fixtureA;
fixtureB = contact.m_fixtureB;
shapeA = fixtureA.m_shape;
shapeB = fixtureB.m_shape;
radiusA = shapeA.m_radius;
radiusB = shapeB.m_radius;
bodyA = fixtureA.m_body;
bodyB = fixtureB.m_body;
manifold = contact.GetManifold();
friction = b2Settings.b2MixFriction(fixtureA.GetFriction(), fixtureB.GetFriction());
restitution = b2Settings.b2MixRestitution(fixtureA.GetRestitution(), fixtureB.GetRestitution());
vAX = bodyA.m_linearVelocity.x;
vAY = bodyA.m_linearVelocity.y;
vBX = bodyB.m_linearVelocity.x;
vBY = bodyB.m_linearVelocity.y;
wA = bodyA.m_angularVelocity;
wB = bodyB.m_angularVelocity;
b2Settings.b2Assert((manifold.m_pointCount > 0));
s_worldManifold.Initialize(manifold, bodyA.m_xf, radiusA, bodyB.m_xf, radiusB);
normalX = s_worldManifold.m_normal.x;
normalY = s_worldManifold.m_normal.y;
cc = m_constraints[i];
cc.bodyA = bodyA;
cc.bodyB = bodyB;
cc.manifold = manifold;
cc.normal.x = normalX;
cc.normal.y = normalY;
cc.pointCount = manifold.m_pointCount;
cc.friction = friction;
cc.restitution = restitution;
cc.localPlaneNormal.x = manifold.m_localPlaneNormal.x;
cc.localPlaneNormal.y = manifold.m_localPlaneNormal.y;
cc.localPoint.x = manifold.m_localPoint.x;
cc.localPoint.y = manifold.m_localPoint.y;
cc.radius = (radiusA + radiusB);
cc.type = manifold.m_type;
k = 0;
while (k < cc.pointCount) {
cp = manifold.m_points[k];
ccp = cc.points[k];
ccp.normalImpulse = cp.m_normalImpulse;
ccp.tangentImpulse = cp.m_tangentImpulse;
ccp.localPoint.SetV(cp.m_localPoint);
rAX = (ccp.rA.x = (s_worldManifold.m_points[k].x - bodyA.m_sweep.c.x));
rAY = (ccp.rA.y = (s_worldManifold.m_points[k].y - bodyA.m_sweep.c.y));
rBX = (ccp.rB.x = (s_worldManifold.m_points[k].x - bodyB.m_sweep.c.x));
rBY = (ccp.rB.y = (s_worldManifold.m_points[k].y - bodyB.m_sweep.c.y));
rnA = ((rAX * normalY) - (rAY * normalX));
rnB = ((rBX * normalY) - (rBY * normalX));
rnA = (rnA * rnA);
rnB = (rnB * rnB);
kNormal = (((bodyA.m_invMass + bodyB.m_invMass) + (bodyA.m_invI * rnA)) + (bodyB.m_invI * rnB));
ccp.normalMass = (1 / kNormal);
kEqualized = ((bodyA.m_mass * bodyA.m_invMass) + (bodyB.m_mass * bodyB.m_invMass));
kEqualized = (kEqualized + (((bodyA.m_mass * bodyA.m_invI) * rnA) + ((bodyB.m_mass * bodyB.m_invI) * rnB)));
ccp.equalizedMass = (1 / kEqualized);
tangentX = normalY;
tangentY = -(normalX);
rtA = ((rAX * tangentY) - (rAY * tangentX));
rtB = ((rBX * tangentY) - (rBY * tangentX));
rtA = (rtA * rtA);
rtB = (rtB * rtB);
kTangent = (((bodyA.m_invMass + bodyB.m_invMass) + (bodyA.m_invI * rtA)) + (bodyB.m_invI * rtB));
ccp.tangentMass = (1 / kTangent);
ccp.velocityBias = 0;
tX = (((vBX + (-(wB) * rBY)) - vAX) - (-(wA) * rAY));
tY = (((vBY + (wB * rBX)) - vAY) - (wA * rAX));
vRel = ((cc.normal.x * tX) + (cc.normal.y * tY));
if (vRel < -(b2Settings.b2_velocityThreshold)){
ccp.velocityBias = (ccp.velocityBias + (-(cc.restitution) * vRel));
};
k++;
};
if (cc.pointCount == 2){
ccp1 = cc.points[0];
ccp2 = cc.points[1];
invMassA = bodyA.m_invMass;
invIA = bodyA.m_invI;
invMassB = bodyB.m_invMass;
invIB = bodyB.m_invI;
rn1A = ((ccp1.rA.x * normalY) - (ccp1.rA.y * normalX));
rn1B = ((ccp1.rB.x * normalY) - (ccp1.rB.y * normalX));
rn2A = ((ccp2.rA.x * normalY) - (ccp2.rA.y * normalX));
rn2B = ((ccp2.rB.x * normalY) - (ccp2.rB.y * normalX));
k11 = (((invMassA + invMassB) + ((invIA * rn1A) * rn1A)) + ((invIB * rn1B) * rn1B));
k22 = (((invMassA + invMassB) + ((invIA * rn2A) * rn2A)) + ((invIB * rn2B) * rn2B));
k12 = (((invMassA + invMassB) + ((invIA * rn1A) * rn2A)) + ((invIB * rn1B) * rn2B));
k_maxConditionNumber = 100;
if ((k11 * k11) < (k_maxConditionNumber * ((k11 * k22) - (k12 * k12)))){
cc.K.col1.Set(k11, k12);
cc.K.col2.Set(k12, k22);
cc.K.GetInverse(cc.normalMass);
} else {
cc.pointCount = 1;
};
};
i++;
};
}
public function SolveVelocityConstraints():void{
var j:int;
var ccp:b2ContactConstraintPoint;
var rAX:Number;
var rAY:Number;
var rBX:Number;
var rBY:Number;
var dvX:Number;
var dvY:Number;
var vn:Number;
var vt:Number;
var lambda:Number;
var maxFriction:Number;
var newImpulse:Number;
var PX:Number;
var PY:Number;
var dX:Number;
var dY:Number;
var P1X:Number;
var P1Y:Number;
var P2X:Number;
var P2Y:Number;
var tMat:b2Mat22;
var tVec:b2Vec2;
var c:b2ContactConstraint;
var bodyA:b2Body;
var bodyB:b2Body;
var wA:Number;
var wB:Number;
var vA:b2Vec2;
var vB:b2Vec2;
var invMassA:Number;
var invIA:Number;
var invMassB:Number;
var invIB:Number;
var normalX:Number;
var normalY:Number;
var tangentX:Number;
var tangentY:Number;
var friction:Number;
var tX:Number;
var tCount:int;
var cp1:b2ContactConstraintPoint;
var cp2:b2ContactConstraintPoint;
var aX:Number;
var aY:Number;
var dv1X:Number;
var dv1Y:Number;
var dv2X:Number;
var dv2Y:Number;
var vn1:Number;
var vn2:Number;
var bX:Number;
var bY:Number;
var k_errorTol:Number;
var xX:Number;
var xY:Number;
var i:int;
while (i < m_constraintCount) {
c = m_constraints[i];
bodyA = c.bodyA;
bodyB = c.bodyB;
wA = bodyA.m_angularVelocity;
wB = bodyB.m_angularVelocity;
vA = bodyA.m_linearVelocity;
vB = bodyB.m_linearVelocity;
invMassA = bodyA.m_invMass;
invIA = bodyA.m_invI;
invMassB = bodyB.m_invMass;
invIB = bodyB.m_invI;
normalX = c.normal.x;
normalY = c.normal.y;
tangentX = normalY;
tangentY = -(normalX);
friction = c.friction;
j = 0;
while (j < c.pointCount) {
ccp = c.points[j];
dvX = (((vB.x - (wB * ccp.rB.y)) - vA.x) + (wA * ccp.rA.y));
dvY = (((vB.y + (wB * ccp.rB.x)) - vA.y) - (wA * ccp.rA.x));
vt = ((dvX * tangentX) + (dvY * tangentY));
lambda = (ccp.tangentMass * -(vt));
maxFriction = (friction * ccp.normalImpulse);
newImpulse = b2Math.Clamp((ccp.tangentImpulse + lambda), -(maxFriction), maxFriction);
lambda = (newImpulse - ccp.tangentImpulse);
PX = (lambda * tangentX);
PY = (lambda * tangentY);
vA.x = (vA.x - (invMassA * PX));
vA.y = (vA.y - (invMassA * PY));
wA = (wA - (invIA * ((ccp.rA.x * PY) - (ccp.rA.y * PX))));
vB.x = (vB.x + (invMassB * PX));
vB.y = (vB.y + (invMassB * PY));
wB = (wB + (invIB * ((ccp.rB.x * PY) - (ccp.rB.y * PX))));
ccp.tangentImpulse = newImpulse;
j++;
};
tCount = c.pointCount;
if (c.pointCount == 1){
ccp = c.points[0];
dvX = (((vB.x + (-(wB) * ccp.rB.y)) - vA.x) - (-(wA) * ccp.rA.y));
dvY = (((vB.y + (wB * ccp.rB.x)) - vA.y) - (wA * ccp.rA.x));
vn = ((dvX * normalX) + (dvY * normalY));
lambda = (-(ccp.normalMass) * (vn - ccp.velocityBias));
newImpulse = (ccp.normalImpulse + lambda);
newImpulse = ((newImpulse > 0)) ? newImpulse : 0;
lambda = (newImpulse - ccp.normalImpulse);
PX = (lambda * normalX);
PY = (lambda * normalY);
vA.x = (vA.x - (invMassA * PX));
vA.y = (vA.y - (invMassA * PY));
wA = (wA - (invIA * ((ccp.rA.x * PY) - (ccp.rA.y * PX))));
vB.x = (vB.x + (invMassB * PX));
vB.y = (vB.y + (invMassB * PY));
wB = (wB + (invIB * ((ccp.rB.x * PY) - (ccp.rB.y * PX))));
ccp.normalImpulse = newImpulse;
} else {
cp1 = c.points[0];
cp2 = c.points[1];
aX = cp1.normalImpulse;
aY = cp2.normalImpulse;
dv1X = (((vB.x - (wB * cp1.rB.y)) - vA.x) + (wA * cp1.rA.y));
dv1Y = (((vB.y + (wB * cp1.rB.x)) - vA.y) - (wA * cp1.rA.x));
dv2X = (((vB.x - (wB * cp2.rB.y)) - vA.x) + (wA * cp2.rA.y));
dv2Y = (((vB.y + (wB * cp2.rB.x)) - vA.y) - (wA * cp2.rA.x));
vn1 = ((dv1X * normalX) + (dv1Y * normalY));
vn2 = ((dv2X * normalX) + (dv2Y * normalY));
bX = (vn1 - cp1.velocityBias);
bY = (vn2 - cp2.velocityBias);
tMat = c.K;
bX = (bX - ((tMat.col1.x * aX) + (tMat.col2.x * aY)));
bY = (bY - ((tMat.col1.y * aX) + (tMat.col2.y * aY)));
k_errorTol = 0.001;
while (true) {
tMat = c.normalMass;
xX = -(((tMat.col1.x * bX) + (tMat.col2.x * bY)));
xY = -(((tMat.col1.y * bX) + (tMat.col2.y * bY)));
if ((((xX >= 0)) && ((xY >= 0)))){
dX = (xX - aX);
dY = (xY - aY);
P1X = (dX * normalX);
P1Y = (dX * normalY);
P2X = (dY * normalX);
P2Y = (dY * normalY);
vA.x = (vA.x - (invMassA * (P1X + P2X)));
vA.y = (vA.y - (invMassA * (P1Y + P2Y)));
wA = (wA - (invIA * ((((cp1.rA.x * P1Y) - (cp1.rA.y * P1X)) + (cp2.rA.x * P2Y)) - (cp2.rA.y * P2X))));
vB.x = (vB.x + (invMassB * (P1X + P2X)));
vB.y = (vB.y + (invMassB * (P1Y + P2Y)));
wB = (wB + (invIB * ((((cp1.rB.x * P1Y) - (cp1.rB.y * P1X)) + (cp2.rB.x * P2Y)) - (cp2.rB.y * P2X))));
cp1.normalImpulse = xX;
cp2.normalImpulse = xY;
break;
};
xX = (-(cp1.normalMass) * bX);
xY = 0;
vn1 = 0;
vn2 = ((c.K.col1.y * xX) + bY);
if ((((xX >= 0)) && ((vn2 >= 0)))){
dX = (xX - aX);
dY = (xY - aY);
P1X = (dX * normalX);
P1Y = (dX * normalY);
P2X = (dY * normalX);
P2Y = (dY * normalY);
vA.x = (vA.x - (invMassA * (P1X + P2X)));
vA.y = (vA.y - (invMassA * (P1Y + P2Y)));
wA = (wA - (invIA * ((((cp1.rA.x * P1Y) - (cp1.rA.y * P1X)) + (cp2.rA.x * P2Y)) - (cp2.rA.y * P2X))));
vB.x = (vB.x + (invMassB * (P1X + P2X)));
vB.y = (vB.y + (invMassB * (P1Y + P2Y)));
wB = (wB + (invIB * ((((cp1.rB.x * P1Y) - (cp1.rB.y * P1X)) + (cp2.rB.x * P2Y)) - (cp2.rB.y * P2X))));
cp1.normalImpulse = xX;
cp2.normalImpulse = xY;
break;
};
xX = 0;
xY = (-(cp2.normalMass) * bY);
vn1 = ((c.K.col2.x * xY) + bX);
vn2 = 0;
if ((((xY >= 0)) && ((vn1 >= 0)))){
dX = (xX - aX);
dY = (xY - aY);
P1X = (dX * normalX);
P1Y = (dX * normalY);
P2X = (dY * normalX);
P2Y = (dY * normalY);
vA.x = (vA.x - (invMassA * (P1X + P2X)));
vA.y = (vA.y - (invMassA * (P1Y + P2Y)));
wA = (wA - (invIA * ((((cp1.rA.x * P1Y) - (cp1.rA.y * P1X)) + (cp2.rA.x * P2Y)) - (cp2.rA.y * P2X))));
vB.x = (vB.x + (invMassB * (P1X + P2X)));
vB.y = (vB.y + (invMassB * (P1Y + P2Y)));
wB = (wB + (invIB * ((((cp1.rB.x * P1Y) - (cp1.rB.y * P1X)) + (cp2.rB.x * P2Y)) - (cp2.rB.y * P2X))));
cp1.normalImpulse = xX;
cp2.normalImpulse = xY;
break;
};
xX = 0;
xY = 0;
vn1 = bX;
vn2 = bY;
if ((((vn1 >= 0)) && ((vn2 >= 0)))){
dX = (xX - aX);
dY = (xY - aY);
P1X = (dX * normalX);
P1Y = (dX * normalY);
P2X = (dY * normalX);
P2Y = (dY * normalY);
vA.x = (vA.x - (invMassA * (P1X + P2X)));
vA.y = (vA.y - (invMassA * (P1Y + P2Y)));
wA = (wA - (invIA * ((((cp1.rA.x * P1Y) - (cp1.rA.y * P1X)) + (cp2.rA.x * P2Y)) - (cp2.rA.y * P2X))));
vB.x = (vB.x + (invMassB * (P1X + P2X)));
vB.y = (vB.y + (invMassB * (P1Y + P2Y)));
wB = (wB + (invIB * ((((cp1.rB.x * P1Y) - (cp1.rB.y * P1X)) + (cp2.rB.x * P2Y)) - (cp2.rB.y * P2X))));
cp1.normalImpulse = xX;
cp2.normalImpulse = xY;
break;
};
break;
};
};
bodyA.m_angularVelocity = wA;
bodyB.m_angularVelocity = wB;
i++;
};
}
public function FinalizeVelocityConstraints():void{
var c:b2ContactConstraint;
var m:b2Manifold;
var j:int;
var point1:b2ManifoldPoint;
var point2:b2ContactConstraintPoint;
var i:int;
while (i < m_constraintCount) {
c = m_constraints[i];
m = c.manifold;
j = 0;
while (j < c.pointCount) {
point1 = m.m_points[j];
point2 = c.points[j];
point1.m_normalImpulse = point2.normalImpulse;
point1.m_tangentImpulse = point2.tangentImpulse;
j++;
};
i++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 100
//b2EdgeAndCircleContact (Box2D.Dynamics.Contacts.b2EdgeAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2EdgeAndCircleContact extends b2Contact {
public function b2EdgeAndCircleContact(){
super();
}
override b2internal function Evaluate():void{
var bA:b2Body = m_fixtureA.GetBody();
var bB:b2Body = m_fixtureB.GetBody();
b2CollideEdgeAndCircle(m_manifold, (m_fixtureA.GetShape() as b2EdgeShape), bA.m_xf, (m_fixtureB.GetShape() as b2CircleShape), bB.m_xf);
}
private function b2CollideEdgeAndCircle(manifold:b2Manifold, edge:b2EdgeShape, xf1:b2Transform, circle:b2CircleShape, xf2:b2Transform):void{
}
public function Reset(fixtureA:b2Fixture, fixtureB:b2Fixture):void{
super.Reset(fixtureA, fixtureB);
}
public static function Destroy(contact:b2Contact, allocator):void{
}
public static function Create(allocator):b2Contact{
return (new (b2EdgeAndCircleContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 101
//b2PolyAndCircleContact (Box2D.Dynamics.Contacts.b2PolyAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolyAndCircleContact extends b2Contact {
public function b2PolyAndCircleContact(){
super();
}
override b2internal function Evaluate():void{
var bA:b2Body = m_fixtureA.m_body;
var bB:b2Body = m_fixtureB.m_body;
b2Collision.CollidePolygonAndCircle(m_manifold, (m_fixtureA.GetShape() as b2PolygonShape), bA.m_xf, (m_fixtureB.GetShape() as b2CircleShape), bB.m_xf);
}
public function Reset(fixtureA:b2Fixture, fixtureB:b2Fixture):void{
super.Reset(fixtureA, fixtureB);
b2Settings.b2Assert((fixtureA.GetType() == b2Shape.e_polygonShape));
b2Settings.b2Assert((fixtureB.GetType() == b2Shape.e_circleShape));
}
public static function Destroy(contact:b2Contact, allocator):void{
}
public static function Create(allocator):b2Contact{
return (new (b2PolyAndCircleContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 102
//b2PolyAndEdgeContact (Box2D.Dynamics.Contacts.b2PolyAndEdgeContact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolyAndEdgeContact extends b2Contact {
public function b2PolyAndEdgeContact(){
super();
}
override b2internal function Evaluate():void{
var bA:b2Body = m_fixtureA.GetBody();
var bB:b2Body = m_fixtureB.GetBody();
b2CollidePolyAndEdge(m_manifold, (m_fixtureA.GetShape() as b2PolygonShape), bA.m_xf, (m_fixtureB.GetShape() as b2EdgeShape), bB.m_xf);
}
private function b2CollidePolyAndEdge(manifold:b2Manifold, polygon:b2PolygonShape, xf1:b2Transform, edge:b2EdgeShape, xf2:b2Transform):void{
}
public function Reset(fixtureA:b2Fixture, fixtureB:b2Fixture):void{
super.Reset(fixtureA, fixtureB);
b2Settings.b2Assert((fixtureA.GetType() == b2Shape.e_polygonShape));
b2Settings.b2Assert((fixtureB.GetType() == b2Shape.e_edgeShape));
}
public static function Destroy(contact:b2Contact, allocator):void{
}
public static function Create(allocator):b2Contact{
return (new (b2PolyAndEdgeContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 103
//b2PolygonContact (Box2D.Dynamics.Contacts.b2PolygonContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolygonContact extends b2Contact {
public function b2PolygonContact(){
super();
}
override b2internal function Evaluate():void{
var bA:b2Body = m_fixtureA.GetBody();
var bB:b2Body = m_fixtureB.GetBody();
b2Collision.CollidePolygons(m_manifold, (m_fixtureA.GetShape() as b2PolygonShape), bA.m_xf, (m_fixtureB.GetShape() as b2PolygonShape), bB.m_xf);
}
public function Reset(fixtureA:b2Fixture, fixtureB:b2Fixture):void{
super.Reset(fixtureA, fixtureB);
}
public static function Destroy(contact:b2Contact, allocator):void{
}
public static function Create(allocator):b2Contact{
return (new (b2PolygonContact));
}
}
}//package Box2D.Dynamics.Contacts
Section 104
//b2PositionSolverManifold (Box2D.Dynamics.Contacts.b2PositionSolverManifold)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
class b2PositionSolverManifold {
public var m_points:Array;
public var m_normal:b2Vec2;
public var m_separations:Array;
private static var circlePointA:b2Vec2 = new b2Vec2();
private static var circlePointB:b2Vec2 = new b2Vec2();
function b2PositionSolverManifold(){
super();
m_normal = new b2Vec2();
m_separations = new Array(b2Settings.b2_maxManifoldPoints);
m_points = new Array(b2Settings.b2_maxManifoldPoints);
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
m_points[i] = new b2Vec2();
i++;
};
}
public function Initialize(cc:b2ContactConstraint):void{
var i:int;
var clipPointX:Number;
var clipPointY:Number;
var tMat:b2Mat22;
var tVec:b2Vec2;
var planePointX:Number;
var planePointY:Number;
var pointAX:Number;
var pointAY:Number;
var pointBX:Number;
var pointBY:Number;
var dX:Number;
var dY:Number;
var d2:Number;
var d:Number;
b2Settings.b2Assert((cc.pointCount > 0));
switch (cc.type){
case b2Manifold.e_circles:
tMat = cc.bodyA.m_xf.R;
tVec = cc.localPoint;
pointAX = (cc.bodyA.m_xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
pointAY = (cc.bodyA.m_xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tMat = cc.bodyB.m_xf.R;
tVec = cc.points[0].localPoint;
pointBX = (cc.bodyB.m_xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
pointBY = (cc.bodyB.m_xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
dX = (pointBX - pointAX);
dY = (pointBY - pointAY);
d2 = ((dX * dX) + (dY * dY));
if (d2 > (Number.MIN_VALUE * Number.MIN_VALUE)){
d = Math.sqrt(d2);
m_normal.x = (dX / d);
m_normal.y = (dY / d);
} else {
m_normal.x = 1;
m_normal.y = 0;
};
m_points[0].x = (0.5 * (pointAX + pointBX));
m_points[0].y = (0.5 * (pointAY + pointBY));
m_separations[0] = (((dX * m_normal.x) + (dY * m_normal.y)) - cc.radius);
break;
case b2Manifold.e_faceA:
tMat = cc.bodyA.m_xf.R;
tVec = cc.localPlaneNormal;
m_normal.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
m_normal.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = cc.bodyA.m_xf.R;
tVec = cc.localPoint;
planePointX = (cc.bodyA.m_xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
planePointY = (cc.bodyA.m_xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tMat = cc.bodyB.m_xf.R;
i = 0;
while (i < cc.pointCount) {
tVec = cc.points[i].localPoint;
clipPointX = (cc.bodyB.m_xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
clipPointY = (cc.bodyB.m_xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
m_separations[i] = ((((clipPointX - planePointX) * m_normal.x) + ((clipPointY - planePointY) * m_normal.y)) - cc.radius);
m_points[i].x = clipPointX;
m_points[i].y = clipPointY;
i++;
};
break;
case b2Manifold.e_faceB:
tMat = cc.bodyB.m_xf.R;
tVec = cc.localPlaneNormal;
m_normal.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
m_normal.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = cc.bodyB.m_xf.R;
tVec = cc.localPoint;
planePointX = (cc.bodyB.m_xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
planePointY = (cc.bodyB.m_xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tMat = cc.bodyA.m_xf.R;
i = 0;
while (i < cc.pointCount) {
tVec = cc.points[i].localPoint;
clipPointX = (cc.bodyA.m_xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
clipPointY = (cc.bodyA.m_xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
m_separations[i] = ((((clipPointX - planePointX) * m_normal.x) + ((clipPointY - planePointY) * m_normal.y)) - cc.radius);
m_points[i].Set(clipPointX, clipPointY);
i++;
};
m_normal.x = (m_normal.x * -1);
m_normal.y = (m_normal.y * -1);
break;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 105
//b2Controller (Box2D.Dynamics.Controllers.b2Controller)
package Box2D.Dynamics.Controllers {
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2Controller {
b2internal var m_world:b2World;
b2internal var m_prev:b2Controller;
b2internal var m_next:b2Controller;
protected var m_bodyList:b2ControllerEdge;
protected var m_bodyCount:int;
public function b2Controller(){
super();
}
public function AddBody(body:b2Body):void{
var edge:b2ControllerEdge = new b2ControllerEdge();
edge.controller = this;
edge.body = body;
edge.nextBody = m_bodyList;
edge.prevBody = null;
m_bodyList = edge;
if (edge.nextBody){
edge.nextBody.prevBody = edge;
};
m_bodyCount++;
edge.nextController = body.m_controllerList;
edge.prevController = null;
body.m_controllerList = edge;
if (edge.nextController){
edge.nextController.prevController = edge;
};
body.m_controllerCount++;
}
public function Draw(debugDraw:b2DebugDraw):void{
}
public function RemoveBody(body:b2Body):void{
var edge:b2ControllerEdge = body.m_controllerList;
while (((edge) && (!((edge.controller == this))))) {
edge = edge.nextController;
};
if (edge.prevBody){
edge.prevBody.nextBody = edge.nextBody;
};
if (edge.nextBody){
edge.nextBody.prevBody = edge.prevBody;
};
if (edge.nextController){
edge.nextController.prevController = edge.prevController;
};
if (edge.prevController){
edge.prevController.nextController = edge.nextController;
};
if (m_bodyList == edge){
m_bodyList = edge.nextBody;
};
if (body.m_controllerList == edge){
body.m_controllerList = edge.nextController;
};
body.m_controllerCount--;
m_bodyCount--;
}
public function GetNext():b2Controller{
return (m_next);
}
public function Clear():void{
while (m_bodyList) {
RemoveBody(m_bodyList.body);
};
}
public function Step(step:b2TimeStep):void{
}
public function GetBodyList():b2ControllerEdge{
return (m_bodyList);
}
public function GetWorld():b2World{
return (m_world);
}
}
}//package Box2D.Dynamics.Controllers
Section 106
//b2ControllerEdge (Box2D.Dynamics.Controllers.b2ControllerEdge)
package Box2D.Dynamics.Controllers {
import Box2D.Dynamics.*;
public class b2ControllerEdge {
public var body:b2Body;
public var nextBody:b2ControllerEdge;
public var nextController:b2ControllerEdge;
public var prevBody:b2ControllerEdge;
public var prevController:b2ControllerEdge;
public var controller:b2Controller;
public function b2ControllerEdge(){
super();
}
}
}//package Box2D.Dynamics.Controllers
Section 107
//b2DistanceJoint (Box2D.Dynamics.Joints.b2DistanceJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2DistanceJoint extends b2Joint {
private var m_localAnchor1:b2Vec2;
private var m_localAnchor2:b2Vec2;
private var m_length:Number;
private var m_mass:Number;
private var m_bias:Number;
private var m_gamma:Number;
private var m_u:b2Vec2;
private var m_impulse:Number;
private var m_dampingRatio:Number;
private var m_frequencyHz:Number;
public function b2DistanceJoint(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);
m_localAnchor1.SetV(def.localAnchorA);
m_localAnchor2.SetV(def.localAnchorB);
m_length = def.length;
m_frequencyHz = def.frequencyHz;
m_dampingRatio = def.dampingRatio;
m_impulse = 0;
m_gamma = 0;
m_bias = 0;
}
public function SetFrequency(hz:Number):void{
m_frequencyHz = hz;
}
public function GetFrequency():Number{
return (m_frequencyHz);
}
public function SetLength(length:Number):void{
m_length = length;
}
override b2internal function InitVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var tX:Number;
var bA:b2Body;
var bB:b2Body;
var r1Y:Number;
var r2Y:Number;
var C:Number;
var omega:Number;
var d:Number;
var k:Number;
var PX:Number;
var PY:Number;
bA = m_bodyA;
bB = m_bodyB;
tMat = bA.m_xf.R;
var r1X:Number = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
r1Y = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
var r2X:Number = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
r2Y = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
m_u.x = (((bB.m_sweep.c.x + r2X) - bA.m_sweep.c.x) - r1X);
m_u.y = (((bB.m_sweep.c.y + r2Y) - bA.m_sweep.c.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));
var invMass:Number = (((bA.m_invMass + ((bA.m_invI * cr1u) * cr1u)) + bB.m_invMass) + ((bB.m_invI * cr2u) * cr2u));
m_mass = ((invMass)!=0) ? (1 / invMass) : 0;
if (m_frequencyHz > 0){
C = (length - m_length);
omega = ((2 * Math.PI) * m_frequencyHz);
d = (((2 * m_mass) * m_dampingRatio) * omega);
k = ((m_mass * omega) * omega);
m_gamma = (step.dt * (d + (step.dt * k)));
m_gamma = ((m_gamma)!=0) ? (1 / m_gamma) : 0;
m_bias = (((C * step.dt) * k) * m_gamma);
m_mass = (invMass + m_gamma);
m_mass = ((m_mass)!=0) ? (1 / m_mass) : 0;
};
if (step.warmStarting){
m_impulse = (m_impulse * step.dtRatio);
PX = (m_impulse * m_u.x);
PY = (m_impulse * m_u.y);
bA.m_linearVelocity.x = (bA.m_linearVelocity.x - (bA.m_invMass * PX));
bA.m_linearVelocity.y = (bA.m_linearVelocity.y - (bA.m_invMass * PY));
bA.m_angularVelocity = (bA.m_angularVelocity - (bA.m_invI * ((r1X * PY) - (r1Y * PX))));
bB.m_linearVelocity.x = (bB.m_linearVelocity.x + (bB.m_invMass * PX));
bB.m_linearVelocity.y = (bB.m_linearVelocity.y + (bB.m_invMass * PY));
bB.m_angularVelocity = (bB.m_angularVelocity + (bB.m_invI * ((r2X * PY) - (r2Y * PX))));
} else {
m_impulse = 0;
};
}
public function SetDampingRatio(ratio:Number):void{
m_dampingRatio = ratio;
}
public function GetLength():Number{
return (m_length);
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
override public function GetReactionTorque(inv_dt:Number):Number{
return (0);
}
override public function GetReactionForce(inv_dt:Number):b2Vec2{
return (new b2Vec2(((inv_dt * m_impulse) * m_u.x), ((inv_dt * m_impulse) * m_u.y)));
}
override b2internal function SolvePositionConstraints(baumgarte:Number):Boolean{
var tMat:b2Mat22;
if (m_frequencyHz > 0){
return (true);
};
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
tMat = bA.m_xf.R;
var r1X:Number = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
var r2X:Number = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var dX:Number = (((bB.m_sweep.c.x + r2X) - bA.m_sweep.c.x) - r1X);
var dY:Number = (((bB.m_sweep.c.y + r2Y) - bA.m_sweep.c.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.Clamp(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);
bA.m_sweep.c.x = (bA.m_sweep.c.x - (bA.m_invMass * PX));
bA.m_sweep.c.y = (bA.m_sweep.c.y - (bA.m_invMass * PY));
bA.m_sweep.a = (bA.m_sweep.a - (bA.m_invI * ((r1X * PY) - (r1Y * PX))));
bB.m_sweep.c.x = (bB.m_sweep.c.x + (bB.m_invMass * PX));
bB.m_sweep.c.y = (bB.m_sweep.c.y + (bB.m_invMass * PY));
bB.m_sweep.a = (bB.m_sweep.a + (bB.m_invI * ((r2X * PY) - (r2Y * PX))));
bA.SynchronizeTransform();
bB.SynchronizeTransform();
return ((b2Math.Abs(C) < b2Settings.b2_linearSlop));
}
override b2internal function SolveVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
tMat = bA.m_xf.R;
var r1X:Number = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
var r2X:Number = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var v1X:Number = (bA.m_linearVelocity.x + (-(bA.m_angularVelocity) * r1Y));
var v1Y:Number = (bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X));
var v2X:Number = (bB.m_linearVelocity.x + (-(bB.m_angularVelocity) * r2Y));
var v2Y:Number = (bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X));
var Cdot:Number = ((m_u.x * (v2X - v1X)) + (m_u.y * (v2Y - v1Y)));
var impulse:Number = (-(m_mass) * ((Cdot + m_bias) + (m_gamma * m_impulse)));
m_impulse = (m_impulse + impulse);
var PX:Number = (impulse * m_u.x);
var PY:Number = (impulse * m_u.y);
bA.m_linearVelocity.x = (bA.m_linearVelocity.x - (bA.m_invMass * PX));
bA.m_linearVelocity.y = (bA.m_linearVelocity.y - (bA.m_invMass * PY));
bA.m_angularVelocity = (bA.m_angularVelocity - (bA.m_invI * ((r1X * PY) - (r1Y * PX))));
bB.m_linearVelocity.x = (bB.m_linearVelocity.x + (bB.m_invMass * PX));
bB.m_linearVelocity.y = (bB.m_linearVelocity.y + (bB.m_invMass * PY));
bB.m_angularVelocity = (bB.m_angularVelocity + (bB.m_invI * ((r2X * PY) - (r2Y * PX))));
}
public function GetDampingRatio():Number{
return (m_dampingRatio);
}
}
}//package Box2D.Dynamics.Joints
Section 108
//b2DistanceJointDef (Box2D.Dynamics.Joints.b2DistanceJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2DistanceJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var length:Number;
public var dampingRatio:Number;
public var localAnchorB:b2Vec2;
public var frequencyHz:Number;
public function b2DistanceJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_distanceJoint;
length = 1;
frequencyHz = 0;
dampingRatio = 0;
}
public function Initialize(bA:b2Body, bB:b2Body, anchorA:b2Vec2, anchorB:b2Vec2):void{
bodyA = bA;
bodyB = bB;
localAnchorA.SetV(bodyA.GetLocalPoint(anchorA));
localAnchorB.SetV(bodyB.GetLocalPoint(anchorB));
var dX:Number = (anchorB.x - anchorA.x);
var dY:Number = (anchorB.y - anchorA.y);
length = Math.sqrt(((dX * dX) + (dY * dY)));
frequencyHz = 0;
dampingRatio = 0;
}
}
}//package Box2D.Dynamics.Joints
Section 109
//b2FrictionJoint (Box2D.Dynamics.Joints.b2FrictionJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2FrictionJoint extends b2Joint {
private var m_maxTorque:Number;
private var m_angularImpulse:Number;
public var m_linearMass:b2Mat22;
private var m_localAnchorA:b2Vec2;
private var m_localAnchorB:b2Vec2;
public var m_angularMass:Number;
private var m_maxForce:Number;
private var m_linearImpulse:b2Vec2;
public function b2FrictionJoint(def:b2FrictionJointDef){
m_localAnchorA = new b2Vec2();
m_localAnchorB = new b2Vec2();
m_linearMass = new b2Mat22();
m_linearImpulse = new b2Vec2();
super(def);
m_localAnchorA.SetV(def.localAnchorA);
m_localAnchorB.SetV(def.localAnchorB);
m_linearMass.SetZero();
m_angularMass = 0;
m_linearImpulse.SetZero();
m_angularImpulse = 0;
m_maxForce = def.maxForce;
m_maxTorque = def.maxTorque;
}
public function SetMaxForce(force:Number):void{
m_maxForce = force;
}
override b2internal function InitVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var tX:Number;
var bA:b2Body;
var bB:b2Body;
var rAX:Number;
var rBX:Number;
var mA:Number;
var iA:Number;
var iB:Number;
var K:b2Mat22;
var P:b2Vec2;
bA = m_bodyA;
bB = m_bodyB;
tMat = bA.m_xf.R;
rAX = (m_localAnchorA.x - bA.m_sweep.localCenter.x);
var rAY:Number = (m_localAnchorA.y - bA.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rAX) + (tMat.col2.x * rAY));
rAY = ((tMat.col1.y * rAX) + (tMat.col2.y * rAY));
rAX = tX;
tMat = bB.m_xf.R;
rBX = (m_localAnchorB.x - bB.m_sweep.localCenter.x);
var rBY:Number = (m_localAnchorB.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rBX) + (tMat.col2.x * rBY));
rBY = ((tMat.col1.y * rBX) + (tMat.col2.y * rBY));
rBX = tX;
mA = bA.m_invMass;
var mB:Number = bB.m_invMass;
iA = bA.m_invI;
iB = bB.m_invI;
K = new b2Mat22();
K.col1.x = (mA + mB);
K.col2.x = 0;
K.col1.y = 0;
K.col2.y = (mA + mB);
K.col1.x = (K.col1.x + ((iA * rAY) * rAY));
K.col2.x = (K.col2.x + ((-(iA) * rAX) * rAY));
K.col1.y = (K.col1.y + ((-(iA) * rAX) * rAY));
K.col2.y = (K.col2.y + ((iA * rAX) * rAX));
K.col1.x = (K.col1.x + ((iB * rBY) * rBY));
K.col2.x = (K.col2.x + ((-(iB) * rBX) * rBY));
K.col1.y = (K.col1.y + ((-(iB) * rBX) * rBY));
K.col2.y = (K.col2.y + ((iB * rBX) * rBX));
K.GetInverse(m_linearMass);
m_angularMass = (iA + iB);
if (m_angularMass > 0){
m_angularMass = (1 / m_angularMass);
};
if (step.warmStarting){
m_linearImpulse.x = (m_linearImpulse.x * step.dtRatio);
m_linearImpulse.y = (m_linearImpulse.y * step.dtRatio);
m_angularImpulse = (m_angularImpulse * step.dtRatio);
P = m_linearImpulse;
bA.m_linearVelocity.x = (bA.m_linearVelocity.x - (mA * P.x));
bA.m_linearVelocity.y = (bA.m_linearVelocity.y - (mA * P.y));
bA.m_angularVelocity = (bA.m_angularVelocity - (iA * (((rAX * P.y) - (rAY * P.x)) + m_angularImpulse)));
bB.m_linearVelocity.x = (bB.m_linearVelocity.x + (mB * P.x));
bB.m_linearVelocity.y = (bB.m_linearVelocity.y + (mB * P.y));
bB.m_angularVelocity = (bB.m_angularVelocity + (iB * (((rBX * P.y) - (rBY * P.x)) + m_angularImpulse)));
} else {
m_linearImpulse.SetZero();
m_angularImpulse = 0;
};
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchorB));
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchorA));
}
override public function GetReactionTorque(inv_dt:Number):Number{
return ((inv_dt * m_angularImpulse));
}
public function SetMaxTorque(torque:Number):void{
m_maxTorque = torque;
}
override b2internal function SolvePositionConstraints(baumgarte:Number):Boolean{
return (true);
}
public function GetMaxTorque():Number{
return (m_maxTorque);
}
override b2internal function SolveVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var tX:Number;
var maxImpulse:Number;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
var vA:b2Vec2 = bA.m_linearVelocity;
var wA:Number = bA.m_angularVelocity;
var vB:b2Vec2 = bB.m_linearVelocity;
var wB:Number = bB.m_angularVelocity;
var mA:Number = bA.m_invMass;
var mB:Number = bB.m_invMass;
var iA:Number = bA.m_invI;
var iB:Number = bB.m_invI;
tMat = bA.m_xf.R;
var rAX:Number = (m_localAnchorA.x - bA.m_sweep.localCenter.x);
var rAY:Number = (m_localAnchorA.y - bA.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rAX) + (tMat.col2.x * rAY));
rAY = ((tMat.col1.y * rAX) + (tMat.col2.y * rAY));
rAX = tX;
tMat = bB.m_xf.R;
var rBX:Number = (m_localAnchorB.x - bB.m_sweep.localCenter.x);
var rBY:Number = (m_localAnchorB.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rBX) + (tMat.col2.x * rBY));
rBY = ((tMat.col1.y * rBX) + (tMat.col2.y * rBY));
rBX = tX;
var Cdot:Number = (wB - wA);
var impulse:Number = (-(m_angularMass) * Cdot);
var oldImpulse:Number = m_angularImpulse;
maxImpulse = (step.dt * m_maxTorque);
m_angularImpulse = b2Math.Clamp((m_angularImpulse + impulse), -(maxImpulse), maxImpulse);
impulse = (m_angularImpulse - oldImpulse);
wA = (wA - (iA * impulse));
wB = (wB + (iB * impulse));
var CdotX:Number = (((vB.x - (wB * rBY)) - vA.x) + (wA * rAY));
var CdotY:Number = (((vB.y + (wB * rBX)) - vA.y) - (wA * rAX));
var impulseV:b2Vec2 = b2Math.MulMV(m_linearMass, new b2Vec2(-(CdotX), -(CdotY)));
var oldImpulseV:b2Vec2 = m_linearImpulse.Copy();
m_linearImpulse.Add(impulseV);
maxImpulse = (step.dt * m_maxForce);
if (m_linearImpulse.LengthSquared() > (maxImpulse * maxImpulse)){
m_linearImpulse.Normalize();
m_linearImpulse.Multiply(maxImpulse);
};
impulseV = b2Math.SubtractVV(m_linearImpulse, oldImpulseV);
vA.x = (vA.x - (mA * impulseV.x));
vA.y = (vA.y - (mA * impulseV.y));
wA = (wA - (iA * ((rAX * impulseV.y) - (rAY * impulseV.x))));
vB.x = (vB.x + (mB * impulseV.x));
vB.y = (vB.y + (mB * impulseV.y));
wB = (wB + (iB * ((rBX * impulseV.y) - (rBY * impulseV.x))));
bA.m_angularVelocity = wA;
bB.m_angularVelocity = wB;
}
override public function GetReactionForce(inv_dt:Number):b2Vec2{
return (new b2Vec2((inv_dt * m_linearImpulse.x), (inv_dt * m_linearImpulse.y)));
}
public function GetMaxForce():Number{
return (m_maxForce);
}
}
}//package Box2D.Dynamics.Joints
Section 110
//b2FrictionJointDef (Box2D.Dynamics.Joints.b2FrictionJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2FrictionJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var maxTorque:Number;
public var maxForce:Number;
public var localAnchorB:b2Vec2;
public function b2FrictionJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_frictionJoint;
maxForce = 0;
maxTorque = 0;
}
public function Initialize(bA:b2Body, bB:b2Body, anchor:b2Vec2):void{
bodyA = bA;
bodyB = bB;
localAnchorA.SetV(bodyA.GetLocalPoint(anchor));
localAnchorB.SetV(bodyB.GetLocalPoint(anchor));
}
}
}//package Box2D.Dynamics.Joints
Section 111
//b2GearJoint (Box2D.Dynamics.Joints.b2GearJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2GearJoint extends b2Joint {
private var m_ground2:b2Body;
private var m_groundAnchor1:b2Vec2;
private var m_groundAnchor2:b2Vec2;
private var m_localAnchor1:b2Vec2;
private var m_localAnchor2:b2Vec2;
private var m_ratio:Number;
private var m_mass:Number;
private var m_impulse:Number;
private var m_prismatic2:b2PrismaticJoint;
private var m_ground1:b2Body;
private var m_revolute1:b2RevoluteJoint;
private var m_revolute2:b2RevoluteJoint;
private var m_prismatic1:b2PrismaticJoint;
private var m_constant:Number;
private var m_J:b2Jacobian;
public function b2GearJoint(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);
var type1:int = def.joint1.m_type;
var type2:int = def.joint2.m_type;
m_revolute1 = null;
m_prismatic1 = null;
m_revolute2 = null;
m_prismatic2 = null;
m_ground1 = def.joint1.GetBodyA();
m_bodyA = def.joint1.GetBodyB();
if (type1 == 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.GetBodyA();
m_bodyB = def.joint2.GetBodyB();
if (type2 == 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 b2internal function InitVelocityConstraints(step:b2TimeStep):void{
var bA:b2Body;
var ugX:Number;
var ugY:Number;
var rX:Number;
var rY:Number;
var tMat:b2Mat22;
var tVec:b2Vec2;
var crug:Number;
var tX:Number;
var g1:b2Body = m_ground1;
var g2:b2Body = m_ground2;
bA = m_bodyA;
var bB:b2Body = m_bodyB;
var K:Number = 0;
m_J.SetZero();
if (m_revolute1){
m_J.angularA = -1;
K = (K + bA.m_invI);
} else {
tMat = g1.m_xf.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 = bA.m_xf.R;
rX = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
rY = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rX) + (tMat.col2.x * rY));
rY = ((tMat.col1.y * rX) + (tMat.col2.y * rY));
rX = tX;
crug = ((rX * ugY) - (rY * ugX));
m_J.linearA.Set(-(ugX), -(ugY));
m_J.angularA = -(crug);
K = (K + (bA.m_invMass + ((bA.m_invI * crug) * crug)));
};
if (m_revolute2){
m_J.angularB = -(m_ratio);
K = (K + ((m_ratio * m_ratio) * bB.m_invI));
} else {
tMat = g2.m_xf.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 = bB.m_xf.R;
rX = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
rY = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rX) + (tMat.col2.x * rY));
rY = ((tMat.col1.y * rX) + (tMat.col2.y * rY));
rX = tX;
crug = ((rX * ugY) - (rY * ugX));
m_J.linearB.Set((-(m_ratio) * ugX), (-(m_ratio) * ugY));
m_J.angularB = (-(m_ratio) * crug);
K = (K + ((m_ratio * m_ratio) * (bB.m_invMass + ((bB.m_invI * crug) * crug))));
};
m_mass = ((K > 0)) ? (1 / K) : 0;
if (step.warmStarting){
bA.m_linearVelocity.x = (bA.m_linearVelocity.x + ((bA.m_invMass * m_impulse) * m_J.linearA.x));
bA.m_linearVelocity.y = (bA.m_linearVelocity.y + ((bA.m_invMass * m_impulse) * m_J.linearA.y));
bA.m_angularVelocity = (bA.m_angularVelocity + ((bA.m_invI * m_impulse) * m_J.angularA));
bB.m_linearVelocity.x = (bB.m_linearVelocity.x + ((bB.m_invMass * m_impulse) * m_J.linearB.x));
bB.m_linearVelocity.y = (bB.m_linearVelocity.y + ((bB.m_invMass * m_impulse) * m_J.linearB.y));
bB.m_angularVelocity = (bB.m_angularVelocity + ((bB.m_invI * m_impulse) * m_J.angularB));
} else {
m_impulse = 0;
};
}
override b2internal function SolveVelocityConstraints(step:b2TimeStep):void{
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
var Cdot:Number = m_J.Compute(bA.m_linearVelocity, bA.m_angularVelocity, bB.m_linearVelocity, bB.m_angularVelocity);
var impulse:Number = (-(m_mass) * Cdot);
m_impulse = (m_impulse + impulse);
bA.m_linearVelocity.x = (bA.m_linearVelocity.x + ((bA.m_invMass * impulse) * m_J.linearA.x));
bA.m_linearVelocity.y = (bA.m_linearVelocity.y + ((bA.m_invMass * impulse) * m_J.linearA.y));
bA.m_angularVelocity = (bA.m_angularVelocity + ((bA.m_invI * impulse) * m_J.angularA));
bB.m_linearVelocity.x = (bB.m_linearVelocity.x + ((bB.m_invMass * impulse) * m_J.linearB.x));
bB.m_linearVelocity.y = (bB.m_linearVelocity.y + ((bB.m_invMass * impulse) * m_J.linearB.y));
bB.m_angularVelocity = (bB.m_angularVelocity + ((bB.m_invI * impulse) * m_J.angularB));
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
public function SetRatio(ratio:Number):void{
m_ratio = ratio;
}
override public function GetReactionForce(inv_dt:Number):b2Vec2{
return (new b2Vec2(((inv_dt * m_impulse) * m_J.linearB.x), ((inv_dt * m_impulse) * m_J.linearB.y)));
}
override b2internal function SolvePositionConstraints(baumgarte:Number):Boolean{
var coordinate1:Number;
var coordinate2:Number;
var linearError:Number = 0;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
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);
bA.m_sweep.c.x = (bA.m_sweep.c.x + ((bA.m_invMass * impulse) * m_J.linearA.x));
bA.m_sweep.c.y = (bA.m_sweep.c.y + ((bA.m_invMass * impulse) * m_J.linearA.y));
bA.m_sweep.a = (bA.m_sweep.a + ((bA.m_invI * impulse) * m_J.angularA));
bB.m_sweep.c.x = (bB.m_sweep.c.x + ((bB.m_invMass * impulse) * m_J.linearB.x));
bB.m_sweep.c.y = (bB.m_sweep.c.y + ((bB.m_invMass * impulse) * m_J.linearB.y));
bB.m_sweep.a = (bB.m_sweep.a + ((bB.m_invI * impulse) * m_J.angularB));
bA.SynchronizeTransform();
bB.SynchronizeTransform();
return ((linearError < b2Settings.b2_linearSlop));
}
override public function GetReactionTorque(inv_dt:Number):Number{
var tMat:b2Mat22 = m_bodyB.m_xf.R;
var rX:Number = (m_localAnchor1.x - m_bodyB.m_sweep.localCenter.x);
var rY:Number = (m_localAnchor1.y - m_bodyB.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * rX) + (tMat.col2.x * rY));
rY = ((tMat.col1.y * rX) + (tMat.col2.y * rY));
rX = tX;
var PX:Number = (m_impulse * m_J.linearB.x);
var PY:Number = (m_impulse * m_J.linearB.y);
return ((inv_dt * (((m_impulse * m_J.angularB) - (rX * PY)) + (rY * PX))));
}
public function GetRatio():Number{
return (m_ratio);
}
}
}//package Box2D.Dynamics.Joints
Section 112
//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 113
//b2Jacobian (Box2D.Dynamics.Joints.b2Jacobian)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2Jacobian {
public var angularB:Number;
public var linearA:b2Vec2;
public var linearB:b2Vec2;
public var angularA:Number;
public function b2Jacobian(){
linearA = new b2Vec2();
linearB = new b2Vec2();
super();
}
public function Set(x1:b2Vec2, a1:Number, x2:b2Vec2, a2:Number):void{
linearA.SetV(x1);
angularA = a1;
linearB.SetV(x2);
angularB = a2;
}
public function SetZero():void{
linearA.SetZero();
angularA = 0;
linearB.SetZero();
angularB = 0;
}
public function Compute(x1:b2Vec2, a1:Number, x2:b2Vec2, a2:Number):Number{
return ((((((linearA.x * x1.x) + (linearA.y * x1.y)) + (angularA * a1)) + ((linearB.x * x2.x) + (linearB.y * x2.y))) + (angularB * a2)));
}
}
}//package Box2D.Dynamics.Joints
Section 114
//b2Joint (Box2D.Dynamics.Joints.b2Joint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2Joint {
b2internal var m_islandFlag:Boolean;
b2internal var m_prev:b2Joint;
b2internal var m_invMassA:Number;
b2internal var m_localCenterA:b2Vec2;
b2internal var m_type:int;
b2internal var m_bodyA:b2Body;
b2internal var m_bodyB:b2Body;
b2internal var m_edgeA:b2JointEdge;
b2internal var m_edgeB:b2JointEdge;
b2internal var m_next:b2Joint;
private var m_userData;
b2internal var m_invMassB:Number;
b2internal var m_localCenterB:b2Vec2;
b2internal var m_invIB:Number;
b2internal var m_collideConnected:Boolean;
b2internal var m_invIA:Number;
b2internal static const e_prismaticJoint:int = 2;
b2internal static const e_weldJoint:int = 8;
b2internal static const e_equalLimits:int = 3;
b2internal static const e_frictionJoint:int = 9;
b2internal static const e_lineJoint:int = 7;
b2internal static const e_gearJoint:int = 6;
b2internal static const e_atUpperLimit:int = 2;
b2internal static const e_atLowerLimit:int = 1;
b2internal static const e_revoluteJoint:int = 1;
b2internal static const e_inactiveLimit:int = 0;
b2internal static const e_pulleyJoint:int = 4;
b2internal static const e_unknownJoint:int = 0;
b2internal static const e_distanceJoint:int = 3;
b2internal static const e_mouseJoint:int = 5;
public function b2Joint(def:b2JointDef){
m_edgeA = new b2JointEdge();
m_edgeB = new b2JointEdge();
m_localCenterA = new b2Vec2();
m_localCenterB = new b2Vec2();
super();
b2Settings.b2Assert(!((def.bodyA == def.bodyB)));
m_type = def.type;
m_prev = null;
m_next = null;
m_bodyA = def.bodyA;
m_bodyB = def.bodyB;
m_collideConnected = def.collideConnected;
m_islandFlag = false;
m_userData = def.userData;
}
b2internal function InitVelocityConstraints(step:b2TimeStep):void{
}
public function GetBodyB():b2Body{
return (m_bodyB);
}
public function GetNext():b2Joint{
return (m_next);
}
public function GetAnchorA():b2Vec2{
return (null);
}
public function GetType():int{
return (m_type);
}
public function GetAnchorB():b2Vec2{
return (null);
}
public function GetBodyA():b2Body{
return (m_bodyA);
}
public function GetReactionTorque(inv_dt:Number):Number{
return (0);
}
public function GetUserData(){
return (m_userData);
}
public function GetReactionForce(inv_dt:Number):b2Vec2{
return (null);
}
b2internal function SolvePositionConstraints(baumgarte:Number):Boolean{
return (false);
}
public function IsActive():Boolean{
return (((m_bodyA.IsActive()) && (m_bodyB.IsActive())));
}
public function SetUserData(data):void{
m_userData = data;
}
b2internal function SolveVelocityConstraints(step:b2TimeStep):void{
}
b2internal function FinalizeVelocityConstraints():void{
}
b2internal static function Destroy(joint:b2Joint, allocator):void{
}
b2internal 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;
case e_lineJoint:
joint = new b2LineJoint((def as b2LineJointDef));
break;
case e_weldJoint:
joint = new b2WeldJoint((def as b2WeldJointDef));
break;
case e_frictionJoint:
joint = new b2FrictionJoint((def as b2FrictionJointDef));
break;
default:
break;
};
return (joint);
}
}
}//package Box2D.Dynamics.Joints
Section 115
//b2JointDef (Box2D.Dynamics.Joints.b2JointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointDef {
public var bodyB:b2Body;
public var type:int;
public var userData;
public var collideConnected:Boolean;
public var bodyA:b2Body;
public function b2JointDef(){
super();
type = b2Joint.e_unknownJoint;
userData = null;
bodyA = null;
bodyB = null;
collideConnected = false;
}
}
}//package Box2D.Dynamics.Joints
Section 116
//b2JointEdge (Box2D.Dynamics.Joints.b2JointEdge)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointEdge {
public var other:b2Body;
public var next:b2JointEdge;
public var prev:b2JointEdge;
public var joint:b2Joint;
public function b2JointEdge(){
super();
}
}
}//package Box2D.Dynamics.Joints
Section 117
//b2LineJoint (Box2D.Dynamics.Joints.b2LineJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2LineJoint extends b2Joint {
private var m_a1:Number;
private var m_a2:Number;
private var m_perp:b2Vec2;
private var m_lowerTranslation:Number;
b2internal var m_localXAxis1:b2Vec2;
private var m_impulse:b2Vec2;
private var m_enableLimit:Boolean;
private var m_maxMotorForce:Number;
private var m_localYAxis1:b2Vec2;
private var m_s2:Number;
private var m_axis:b2Vec2;
private var m_motorMass:Number;
private var m_s1:Number;
private var m_upperTranslation:Number;
b2internal var m_localAnchor1:b2Vec2;
b2internal var m_localAnchor2:b2Vec2;
private var m_limitState:int;
private var m_motorImpulse:Number;
private var m_motorSpeed:Number;
private var m_enableMotor:Boolean;
private var m_K:b2Mat22;
public function b2LineJoint(def:b2LineJointDef){
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_axis = new b2Vec2();
m_perp = new b2Vec2();
m_K = new b2Mat22();
m_impulse = new b2Vec2();
super(def);
m_localAnchor1.SetV(def.localAnchorA);
m_localAnchor2.SetV(def.localAnchorB);
m_localXAxis1.SetV(def.localAxisA);
m_localYAxis1.x = -(m_localXAxis1.y);
m_localYAxis1.y = m_localXAxis1.x;
m_impulse.SetZero();
m_motorMass = 0;
m_motorImpulse = 0;
m_lowerTranslation = def.lowerTranslation;
m_upperTranslation = def.upperTranslation;
m_maxMotorForce = def.maxMotorForce;
m_motorSpeed = def.motorSpeed;
m_enableLimit = def.enableLimit;
m_enableMotor = def.enableMotor;
m_limitState = e_inactiveLimit;
m_axis.SetZero();
m_perp.SetZero();
}
override b2internal function SolveVelocityConstraints(step:b2TimeStep):void{
var PX:Number;
var PY:Number;
var L1:Number;
var L2:Number;
var Cdot:Number;
var impulse:Number;
var oldImpulse:Number;
var maxImpulse:Number;
var Cdot2:Number;
var f1:b2Vec2;
var df:b2Vec2;
var b:Number;
var f2r:Number;
var df2:Number;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
var v1:b2Vec2 = bA.m_linearVelocity;
var w1:Number = bA.m_angularVelocity;
var v2:b2Vec2 = bB.m_linearVelocity;
var w2:Number = bB.m_angularVelocity;
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
Cdot = ((((m_axis.x * (v2.x - v1.x)) + (m_axis.y * (v2.y - v1.y))) + (m_a2 * w2)) - (m_a1 * w1));
impulse = (m_motorMass * (m_motorSpeed - Cdot));
oldImpulse = m_motorImpulse;
maxImpulse = (step.dt * m_maxMotorForce);
m_motorImpulse = b2Math.Clamp((m_motorImpulse + impulse), -(maxImpulse), maxImpulse);
impulse = (m_motorImpulse - oldImpulse);
PX = (impulse * m_axis.x);
PY = (impulse * m_axis.y);
L1 = (impulse * m_a1);
L2 = (impulse * m_a2);
v1.x = (v1.x - (m_invMassA * PX));
v1.y = (v1.y - (m_invMassA * PY));
w1 = (w1 - (m_invIA * L1));
v2.x = (v2.x + (m_invMassB * PX));
v2.y = (v2.y + (m_invMassB * PY));
w2 = (w2 + (m_invIB * L2));
};
var Cdot1:Number = ((((m_perp.x * (v2.x - v1.x)) + (m_perp.y * (v2.y - v1.y))) + (m_s2 * w2)) - (m_s1 * w1));
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
Cdot2 = ((((m_axis.x * (v2.x - v1.x)) + (m_axis.y * (v2.y - v1.y))) + (m_a2 * w2)) - (m_a1 * w1));
f1 = m_impulse.Copy();
df = m_K.Solve(new b2Vec2(), -(Cdot1), -(Cdot2));
m_impulse.Add(df);
if (m_limitState == e_atLowerLimit){
m_impulse.y = b2Math.Max(m_impulse.y, 0);
} else {
if (m_limitState == e_atUpperLimit){
m_impulse.y = b2Math.Min(m_impulse.y, 0);
};
};
b = (-(Cdot1) - ((m_impulse.y - f1.y) * m_K.col2.x));
if (m_K.col1.x != 0){
f2r = ((b / m_K.col1.x) + f1.x);
} else {
f2r = f1.x;
};
m_impulse.x = f2r;
df.x = (m_impulse.x - f1.x);
df.y = (m_impulse.y - f1.y);
PX = ((df.x * m_perp.x) + (df.y * m_axis.x));
PY = ((df.x * m_perp.y) + (df.y * m_axis.y));
L1 = ((df.x * m_s1) + (df.y * m_a1));
L2 = ((df.x * m_s2) + (df.y * m_a2));
v1.x = (v1.x - (m_invMassA * PX));
v1.y = (v1.y - (m_invMassA * PY));
w1 = (w1 - (m_invIA * L1));
v2.x = (v2.x + (m_invMassB * PX));
v2.y = (v2.y + (m_invMassB * PY));
w2 = (w2 + (m_invIB * L2));
} else {
if (m_K.col1.x != 0){
df2 = (-(Cdot1) / m_K.col1.x);
} else {
df2 = 0;
};
m_impulse.x = (m_impulse.x + df2);
PX = (df2 * m_perp.x);
PY = (df2 * m_perp.y);
L1 = (df2 * m_s1);
L2 = (df2 * m_s2);
v1.x = (v1.x - (m_invMassA * PX));
v1.y = (v1.y - (m_invMassA * PY));
w1 = (w1 - (m_invIA * L1));
v2.x = (v2.x + (m_invMassB * PX));
v2.y = (v2.y + (m_invMassB * PY));
w2 = (w2 + (m_invIB * L2));
};
bA.m_linearVelocity.SetV(v1);
bA.m_angularVelocity = w1;
bB.m_linearVelocity.SetV(v2);
bB.m_angularVelocity = w2;
}
public function GetUpperLimit():Number{
return (m_upperTranslation);
}
public function GetLowerLimit():Number{
return (m_lowerTranslation);
}
public function EnableMotor(flag:Boolean):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_enableMotor = flag;
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
public function GetJointTranslation():Number{
var tMat:b2Mat22;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
var p1:b2Vec2 = bA.GetWorldPoint(m_localAnchor1);
var p2:b2Vec2 = bB.GetWorldPoint(m_localAnchor2);
var dX:Number = (p2.x - p1.x);
var dY:Number = (p2.y - p1.y);
var axis:b2Vec2 = bA.GetWorldVector(m_localXAxis1);
var translation:Number = ((axis.x * dX) + (axis.y * dY));
return (translation);
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce(inv_dt:Number):b2Vec2{
return (new b2Vec2((inv_dt * ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.y) * m_axis.x))), (inv_dt * ((m_impulse.x * m_perp.y) + ((m_motorImpulse + m_impulse.y) * m_axis.y)))));
}
override b2internal function SolvePositionConstraints(baumgarte:Number):Boolean{
var limitC:Number;
var oldLimitImpulse:Number;
var tMat:b2Mat22;
var tX:Number;
var m1:Number;
var m2:Number;
var i1:Number;
var i2:Number;
var translation:Number;
var k11:Number;
var impulse1:Number;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
var c1:b2Vec2 = bA.m_sweep.c;
var a1:Number = bA.m_sweep.a;
var c2:b2Vec2 = bB.m_sweep.c;
var a2:Number = bB.m_sweep.a;
var linearError:Number = 0;
var angularError:Number = 0;
var active:Boolean;
var C2:Number = 0;
var R1:b2Mat22 = b2Mat22.FromAngle(a1);
var R2:b2Mat22 = b2Mat22.FromAngle(a2);
tMat = R1;
var r1X:Number = (m_localAnchor1.x - m_localCenterA.x);
var r1Y:Number = (m_localAnchor1.y - m_localCenterA.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = R2;
var r2X:Number = (m_localAnchor2.x - m_localCenterB.x);
var r2Y:Number = (m_localAnchor2.y - m_localCenterB.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var dX:Number = (((c2.x + r2X) - c1.x) - r1X);
var dY:Number = (((c2.y + r2Y) - c1.y) - r1Y);
if (m_enableLimit){
m_axis = b2Math.MulMV(R1, m_localXAxis1);
m_a1 = (((dX + r1X) * m_axis.y) - ((dY + r1Y) * m_axis.x));
m_a2 = ((r2X * m_axis.y) - (r2Y * m_axis.x));
translation = ((m_axis.x * dX) + (m_axis.y * dY));
if (b2Math.Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
C2 = b2Math.Clamp(translation, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
linearError = b2Math.Abs(translation);
active = true;
} else {
if (translation <= m_lowerTranslation){
C2 = b2Math.Clamp(((translation - m_lowerTranslation) + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
linearError = (m_lowerTranslation - translation);
active = true;
} else {
if (translation >= m_upperTranslation){
C2 = b2Math.Clamp(((translation - m_upperTranslation) + b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
linearError = (translation - m_upperTranslation);
active = true;
};
};
};
};
m_perp = b2Math.MulMV(R1, m_localYAxis1);
m_s1 = (((dX + r1X) * m_perp.y) - ((dY + r1Y) * m_perp.x));
m_s2 = ((r2X * m_perp.y) - (r2Y * m_perp.x));
var impulse:b2Vec2 = new b2Vec2();
var C1:Number = ((m_perp.x * dX) + (m_perp.y * dY));
linearError = b2Math.Max(linearError, b2Math.Abs(C1));
angularError = 0;
if (active){
m1 = m_invMassA;
m2 = m_invMassB;
i1 = m_invIA;
i2 = m_invIB;
m_K.col1.x = (((m1 + m2) + ((i1 * m_s1) * m_s1)) + ((i2 * m_s2) * m_s2));
m_K.col1.y = (((i1 * m_s1) * m_a1) + ((i2 * m_s2) * m_a2));
m_K.col2.x = m_K.col1.y;
m_K.col2.y = (((m1 + m2) + ((i1 * m_a1) * m_a1)) + ((i2 * m_a2) * m_a2));
m_K.Solve(impulse, -(C1), -(C2));
} else {
m1 = m_invMassA;
m2 = m_invMassB;
i1 = m_invIA;
i2 = m_invIB;
k11 = (((m1 + m2) + ((i1 * m_s1) * m_s1)) + ((i2 * m_s2) * m_s2));
if (k11 != 0){
impulse1 = (-(C1) / k11);
} else {
impulse1 = 0;
};
impulse.x = impulse1;
impulse.y = 0;
};
var PX:Number = ((impulse.x * m_perp.x) + (impulse.y * m_axis.x));
var PY:Number = ((impulse.x * m_perp.y) + (impulse.y * m_axis.y));
var L1:Number = ((impulse.x * m_s1) + (impulse.y * m_a1));
var L2:Number = ((impulse.x * m_s2) + (impulse.y * m_a2));
c1.x = (c1.x - (m_invMassA * PX));
c1.y = (c1.y - (m_invMassA * PY));
a1 = (a1 - (m_invIA * L1));
c2.x = (c2.x + (m_invMassB * PX));
c2.y = (c2.y + (m_invMassB * PY));
a2 = (a2 + (m_invIB * L2));
bA.m_sweep.a = a1;
bB.m_sweep.a = a2;
bA.SynchronizeTransform();
bB.SynchronizeTransform();
return ((((linearError <= b2Settings.b2_linearSlop)) && ((angularError <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(speed:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_motorSpeed = speed;
}
public function GetJointSpeed():Number{
var tMat:b2Mat22;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
tMat = bA.m_xf.R;
var r1X:Number = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
var r2X:Number = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var p1X:Number = (bA.m_sweep.c.x + r1X);
var p1Y:Number = (bA.m_sweep.c.y + r1Y);
var p2X:Number = (bB.m_sweep.c.x + r2X);
var p2Y:Number = (bB.m_sweep.c.y + r2Y);
var dX:Number = (p2X - p1X);
var dY:Number = (p2Y - p1Y);
var axis:b2Vec2 = bA.GetWorldVector(m_localXAxis1);
var v1:b2Vec2 = bA.m_linearVelocity;
var v2:b2Vec2 = bB.m_linearVelocity;
var w1:Number = bA.m_angularVelocity;
var w2:Number = bB.m_angularVelocity;
var speed:Number = (((dX * (-(w1) * axis.y)) + (dY * (w1 * axis.x))) + ((axis.x * (((v2.x + (-(w2) * r2Y)) - v1.x) - (-(w1) * r1Y))) + (axis.y * (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X)))));
return (speed);
}
override b2internal function InitVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var tX:Number;
var jointTransition:Number;
var PX:Number;
var PY:Number;
var L1:Number;
var L2:Number;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
m_localCenterA.SetV(bA.GetLocalCenter());
m_localCenterB.SetV(bB.GetLocalCenter());
var xf1:b2Transform = bA.GetTransform();
var xf2:b2Transform = bB.GetTransform();
tMat = bA.m_xf.R;
var r1X:Number = (m_localAnchor1.x - m_localCenterA.x);
var r1Y:Number = (m_localAnchor1.y - m_localCenterA.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
var r2X:Number = (m_localAnchor2.x - m_localCenterB.x);
var r2Y:Number = (m_localAnchor2.y - m_localCenterB.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var dX:Number = (((bB.m_sweep.c.x + r2X) - bA.m_sweep.c.x) - r1X);
var dY:Number = (((bB.m_sweep.c.y + r2Y) - bA.m_sweep.c.y) - r1Y);
m_invMassA = bA.m_invMass;
m_invMassB = bB.m_invMass;
m_invIA = bA.m_invI;
m_invIB = bB.m_invI;
m_axis.SetV(b2Math.MulMV(xf1.R, m_localXAxis1));
m_a1 = (((dX + r1X) * m_axis.y) - ((dY + r1Y) * m_axis.x));
m_a2 = ((r2X * m_axis.y) - (r2Y * m_axis.x));
m_motorMass = (((m_invMassA + m_invMassB) + ((m_invIA * m_a1) * m_a1)) + ((m_invIB * m_a2) * m_a2));
m_motorMass = ((m_motorMass > Number.MIN_VALUE)) ? (1 / m_motorMass) : 0;
m_perp.SetV(b2Math.MulMV(xf1.R, m_localYAxis1));
m_s1 = (((dX + r1X) * m_perp.y) - ((dY + r1Y) * m_perp.x));
m_s2 = ((r2X * m_perp.y) - (r2Y * m_perp.x));
var m1:Number = m_invMassA;
var m2:Number = m_invMassB;
var i1:Number = m_invIA;
var i2:Number = m_invIB;
m_K.col1.x = (((m1 + m2) + ((i1 * m_s1) * m_s1)) + ((i2 * m_s2) * m_s2));
m_K.col1.y = (((i1 * m_s1) * m_a1) + ((i2 * m_s2) * m_a2));
m_K.col2.x = m_K.col1.y;
m_K.col2.y = (((m1 + m2) + ((i1 * m_a1) * m_a1)) + ((i2 * m_a2) * m_a2));
if (m_enableLimit){
jointTransition = ((m_axis.x * dX) + (m_axis.y * dY));
if (b2Math.Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
m_limitState = e_equalLimits;
} else {
if (jointTransition <= m_lowerTranslation){
if (m_limitState != e_atLowerLimit){
m_limitState = e_atLowerLimit;
m_impulse.y = 0;
};
} else {
if (jointTransition >= m_upperTranslation){
if (m_limitState != e_atUpperLimit){
m_limitState = e_atUpperLimit;
m_impulse.y = 0;
};
} else {
m_limitState = e_inactiveLimit;
m_impulse.y = 0;
};
};
};
} else {
m_limitState = e_inactiveLimit;
};
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (step.warmStarting){
m_impulse.x = (m_impulse.x * step.dtRatio);
m_impulse.y = (m_impulse.y * step.dtRatio);
m_motorImpulse = (m_motorImpulse * step.dtRatio);
PX = ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.y) * m_axis.x));
PY = ((m_impulse.x * m_perp.y) + ((m_motorImpulse + m_impulse.y) * m_axis.y));
L1 = ((m_impulse.x * m_s1) + ((m_motorImpulse + m_impulse.y) * m_a1));
L2 = ((m_impulse.x * m_s2) + ((m_motorImpulse + m_impulse.y) * m_a2));
bA.m_linearVelocity.x = (bA.m_linearVelocity.x - (m_invMassA * PX));
bA.m_linearVelocity.y = (bA.m_linearVelocity.y - (m_invMassA * PY));
bA.m_angularVelocity = (bA.m_angularVelocity - (m_invIA * L1));
bB.m_linearVelocity.x = (bB.m_linearVelocity.x + (m_invMassB * PX));
bB.m_linearVelocity.y = (bB.m_linearVelocity.y + (m_invMassB * PY));
bB.m_angularVelocity = (bB.m_angularVelocity + (m_invIB * L2));
} else {
m_impulse.SetZero();
m_motorImpulse = 0;
};
}
public function GetMotorForce():Number{
return (m_motorImpulse);
}
public function SetMaxMotorForce(force:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_maxMotorForce = force;
}
public function EnableLimit(flag:Boolean):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_enableLimit = flag;
}
public function GetMaxMotorForce():Number{
return (m_maxMotorForce);
}
override public function GetReactionTorque(inv_dt:Number):Number{
return ((inv_dt * m_impulse.y));
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
return (m_enableMotor);
}
public function SetLimits(lower:Number, upper:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_lowerTranslation = lower;
m_upperTranslation = upper;
}
}
}//package Box2D.Dynamics.Joints
Section 118
//b2LineJointDef (Box2D.Dynamics.Joints.b2LineJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2LineJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var localAnchorB:b2Vec2;
public var upperTranslation:Number;
public var enableMotor:Boolean;
public var localAxisA:b2Vec2;
public var enableLimit:Boolean;
public var motorSpeed:Number;
public var maxMotorForce:Number;
public var lowerTranslation:Number;
public function b2LineJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
localAxisA = new b2Vec2();
super();
type = b2Joint.e_lineJoint;
localAxisA.Set(1, 0);
enableLimit = false;
lowerTranslation = 0;
upperTranslation = 0;
enableMotor = false;
maxMotorForce = 0;
motorSpeed = 0;
}
public function Initialize(bA:b2Body, bB:b2Body, anchor:b2Vec2, axis:b2Vec2):void{
bodyA = bA;
bodyB = bB;
localAnchorA = bodyA.GetLocalPoint(anchor);
localAnchorB = bodyB.GetLocalPoint(anchor);
localAxisA = bodyA.GetLocalVector(axis);
}
}
}//package Box2D.Dynamics.Joints
Section 119
//b2MouseJoint (Box2D.Dynamics.Joints.b2MouseJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2MouseJoint extends b2Joint {
private var K2:b2Mat22;
private var K1:b2Mat22;
private var m_beta:Number;
private var K:b2Mat22;
private var m_target:b2Vec2;
private var m_gamma:Number;
private var m_mass:b2Mat22;
private var m_impulse:b2Vec2;
private var m_localAnchor:b2Vec2;
private var m_C:b2Vec2;
private var m_maxForce:Number;
private var m_dampingRatio:Number;
private var m_frequencyHz:Number;
public function b2MouseJoint(def:b2MouseJointDef){
var tX:Number;
var tMat:b2Mat22;
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
m_localAnchor = new b2Vec2();
m_target = new b2Vec2();
m_impulse = new b2Vec2();
m_mass = new b2Mat22();
m_C = new b2Vec2();
super(def);
m_target.SetV(def.target);
tX = (m_target.x - m_bodyB.m_xf.position.x);
var tY:Number = (m_target.y - m_bodyB.m_xf.position.y);
tMat = m_bodyB.m_xf.R;
m_localAnchor.x = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
m_localAnchor.y = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
m_maxForce = def.maxForce;
m_impulse.SetZero();
m_frequencyHz = def.frequencyHz;
m_dampingRatio = def.dampingRatio;
m_beta = 0;
m_gamma = 0;
}
public function SetFrequency(hz:Number):void{
m_frequencyHz = hz;
}
public function SetTarget(target:b2Vec2):void{
if (m_bodyB.IsAwake() == false){
m_bodyB.SetAwake(true);
};
m_target = target;
}
public function GetFrequency():Number{
return (m_frequencyHz);
}
public function SetMaxForce(maxForce:Number):void{
m_maxForce = maxForce;
}
public function SetDampingRatio(ratio:Number):void{
m_dampingRatio = ratio;
}
override b2internal function InitVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var invMass:Number;
var invI:Number;
var b:b2Body = m_bodyB;
var mass:Number = b.GetMass();
var omega:Number = ((2 * Math.PI) * m_frequencyHz);
var d:Number = (((2 * mass) * m_dampingRatio) * omega);
var k:Number = ((mass * omega) * omega);
m_gamma = (step.dt * (d + (step.dt * k)));
m_gamma = ((m_gamma)!=0) ? (1 / m_gamma) : 0;
m_beta = ((step.dt * k) * m_gamma);
tMat = b.m_xf.R;
var rX:Number = (m_localAnchor.x - b.m_sweep.localCenter.x);
var rY:Number = (m_localAnchor.y - b.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * rX) + (tMat.col2.x * rY));
rY = ((tMat.col1.y * rX) + (tMat.col2.y * rY));
rX = tX;
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.GetInverse(m_mass);
m_C.x = ((b.m_sweep.c.x + rX) - m_target.x);
m_C.y = ((b.m_sweep.c.y + rY) - m_target.y);
b.m_angularVelocity = (b.m_angularVelocity * 0.98);
m_impulse.x = (m_impulse.x * step.dtRatio);
m_impulse.y = (m_impulse.y * step.dtRatio);
b.m_linearVelocity.x = (b.m_linearVelocity.x + (invMass * m_impulse.x));
b.m_linearVelocity.y = (b.m_linearVelocity.y + (invMass * m_impulse.y));
b.m_angularVelocity = (b.m_angularVelocity + (invI * ((rX * m_impulse.y) - (rY * m_impulse.x))));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor));
}
override public function GetAnchorA():b2Vec2{
return (m_target);
}
public function GetTarget():b2Vec2{
return (m_target);
}
override public function GetReactionTorque(inv_dt:Number):Number{
return (0);
}
override public function GetReactionForce(inv_dt:Number):b2Vec2{
return (new b2Vec2((inv_dt * m_impulse.x), (inv_dt * m_impulse.y)));
}
override b2internal function SolvePositionConstraints(baumgarte:Number):Boolean{
return (true);
}
override b2internal function SolveVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var tX:Number;
var tY:Number;
var b:b2Body = m_bodyB;
tMat = b.m_xf.R;
var rX:Number = (m_localAnchor.x - b.m_sweep.localCenter.x);
var rY:Number = (m_localAnchor.y - b.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rX) + (tMat.col2.x * rY));
rY = ((tMat.col1.y * rX) + (tMat.col2.y * rY));
rX = tX;
var CdotX:Number = (b.m_linearVelocity.x + (-(b.m_angularVelocity) * rY));
var CdotY:Number = (b.m_linearVelocity.y + (b.m_angularVelocity * rX));
tMat = m_mass;
tX = ((CdotX + (m_beta * m_C.x)) + (m_gamma * m_impulse.x));
tY = ((CdotY + (m_beta * 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 maxImpulse:Number = (step.dt * m_maxForce);
if (m_impulse.LengthSquared() > (maxImpulse * maxImpulse)){
m_impulse.Multiply((maxImpulse / m_impulse.Length()));
};
impulseX = (m_impulse.x - oldImpulseX);
impulseY = (m_impulse.y - oldImpulseY);
b.m_linearVelocity.x = (b.m_linearVelocity.x + (b.m_invMass * impulseX));
b.m_linearVelocity.y = (b.m_linearVelocity.y + (b.m_invMass * impulseY));
b.m_angularVelocity = (b.m_angularVelocity + (b.m_invI * ((rX * impulseY) - (rY * impulseX))));
}
public function GetMaxForce():Number{
return (m_maxForce);
}
public function GetDampingRatio():Number{
return (m_dampingRatio);
}
}
}//package Box2D.Dynamics.Joints
Section 120
//b2MouseJointDef (Box2D.Dynamics.Joints.b2MouseJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2MouseJointDef extends b2JointDef {
public var target:b2Vec2;
public var maxForce:Number;
public var dampingRatio:Number;
public var frequencyHz:Number;
public function b2MouseJointDef(){
target = new b2Vec2();
super();
type = b2Joint.e_mouseJoint;
maxForce = 0;
frequencyHz = 5;
dampingRatio = 0.7;
}
}
}//package Box2D.Dynamics.Joints
Section 121
//b2PrismaticJoint (Box2D.Dynamics.Joints.b2PrismaticJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2PrismaticJoint extends b2Joint {
private var m_a1:Number;
private var m_a2:Number;
private var m_perp:b2Vec2;
private var m_lowerTranslation:Number;
b2internal var m_localXAxis1:b2Vec2;
private var m_refAngle:Number;
private var m_impulse:b2Vec3;
private var m_enableLimit:Boolean;
private var m_maxMotorForce:Number;
private var m_localYAxis1:b2Vec2;
private var m_s2:Number;
private var m_axis:b2Vec2;
private var m_motorMass:Number;
private var m_s1:Number;
private var m_upperTranslation:Number;
b2internal var m_localAnchor1:b2Vec2;
b2internal var m_localAnchor2:b2Vec2;
private var m_limitState:int;
private var m_motorImpulse:Number;
private var m_motorSpeed:Number;
private var m_enableMotor:Boolean;
private var m_K:b2Mat33;
public function b2PrismaticJoint(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_axis = new b2Vec2();
m_perp = new b2Vec2();
m_K = new b2Mat33();
m_impulse = new b2Vec3();
super(def);
m_localAnchor1.SetV(def.localAnchorA);
m_localAnchor2.SetV(def.localAnchorB);
m_localXAxis1.SetV(def.localAxisA);
m_localYAxis1.x = -(m_localXAxis1.y);
m_localYAxis1.y = m_localXAxis1.x;
m_refAngle = def.referenceAngle;
m_impulse.SetZero();
m_motorMass = 0;
m_motorImpulse = 0;
m_lowerTranslation = def.lowerTranslation;
m_upperTranslation = def.upperTranslation;
m_maxMotorForce = def.maxMotorForce;
m_motorSpeed = def.motorSpeed;
m_enableLimit = def.enableLimit;
m_enableMotor = def.enableMotor;
m_limitState = e_inactiveLimit;
m_axis.SetZero();
m_perp.SetZero();
}
override b2internal function SolveVelocityConstraints(step:b2TimeStep):void{
var PX:Number;
var PY:Number;
var L1:Number;
var L2:Number;
var Cdot:Number;
var impulse:Number;
var oldImpulse:Number;
var maxImpulse:Number;
var Cdot2:Number;
var f1:b2Vec3;
var df:b2Vec3;
var bX:Number;
var bY:Number;
var f2r:b2Vec2;
var df2:b2Vec2;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
var v1:b2Vec2 = bA.m_linearVelocity;
var w1:Number = bA.m_angularVelocity;
var v2:b2Vec2 = bB.m_linearVelocity;
var w2:Number = bB.m_angularVelocity;
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
Cdot = ((((m_axis.x * (v2.x - v1.x)) + (m_axis.y * (v2.y - v1.y))) + (m_a2 * w2)) - (m_a1 * w1));
impulse = (m_motorMass * (m_motorSpeed - Cdot));
oldImpulse = m_motorImpulse;
maxImpulse = (step.dt * m_maxMotorForce);
m_motorImpulse = b2Math.Clamp((m_motorImpulse + impulse), -(maxImpulse), maxImpulse);
impulse = (m_motorImpulse - oldImpulse);
PX = (impulse * m_axis.x);
PY = (impulse * m_axis.y);
L1 = (impulse * m_a1);
L2 = (impulse * m_a2);
v1.x = (v1.x - (m_invMassA * PX));
v1.y = (v1.y - (m_invMassA * PY));
w1 = (w1 - (m_invIA * L1));
v2.x = (v2.x + (m_invMassB * PX));
v2.y = (v2.y + (m_invMassB * PY));
w2 = (w2 + (m_invIB * L2));
};
var Cdot1X:Number = ((((m_perp.x * (v2.x - v1.x)) + (m_perp.y * (v2.y - v1.y))) + (m_s2 * w2)) - (m_s1 * w1));
var Cdot1Y:Number = (w2 - w1);
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
Cdot2 = ((((m_axis.x * (v2.x - v1.x)) + (m_axis.y * (v2.y - v1.y))) + (m_a2 * w2)) - (m_a1 * w1));
f1 = m_impulse.Copy();
df = m_K.Solve33(new b2Vec3(), -(Cdot1X), -(Cdot1Y), -(Cdot2));
m_impulse.Add(df);
if (m_limitState == e_atLowerLimit){
m_impulse.z = b2Math.Max(m_impulse.z, 0);
} else {
if (m_limitState == e_atUpperLimit){
m_impulse.z = b2Math.Min(m_impulse.z, 0);
};
};
bX = (-(Cdot1X) - ((m_impulse.z - f1.z) * m_K.col3.x));
bY = (-(Cdot1Y) - ((m_impulse.z - f1.z) * m_K.col3.y));
f2r = m_K.Solve22(new b2Vec2(), bX, bY);
f2r.x = (f2r.x + f1.x);
f2r.y = (f2r.y + f1.y);
m_impulse.x = f2r.x;
m_impulse.y = f2r.y;
df.x = (m_impulse.x - f1.x);
df.y = (m_impulse.y - f1.y);
df.z = (m_impulse.z - f1.z);
PX = ((df.x * m_perp.x) + (df.z * m_axis.x));
PY = ((df.x * m_perp.y) + (df.z * m_axis.y));
L1 = (((df.x * m_s1) + df.y) + (df.z * m_a1));
L2 = (((df.x * m_s2) + df.y) + (df.z * m_a2));
v1.x = (v1.x - (m_invMassA * PX));
v1.y = (v1.y - (m_invMassA * PY));
w1 = (w1 - (m_invIA * L1));
v2.x = (v2.x + (m_invMassB * PX));
v2.y = (v2.y + (m_invMassB * PY));
w2 = (w2 + (m_invIB * L2));
} else {
df2 = m_K.Solve22(new b2Vec2(), -(Cdot1X), -(Cdot1Y));
m_impulse.x = (m_impulse.x + df2.x);
m_impulse.y = (m_impulse.y + df2.y);
PX = (df2.x * m_perp.x);
PY = (df2.x * m_perp.y);
L1 = ((df2.x * m_s1) + df2.y);
L2 = ((df2.x * m_s2) + df2.y);
v1.x = (v1.x - (m_invMassA * PX));
v1.y = (v1.y - (m_invMassA * PY));
w1 = (w1 - (m_invIA * L1));
v2.x = (v2.x + (m_invMassB * PX));
v2.y = (v2.y + (m_invMassB * PY));
w2 = (w2 + (m_invIB * L2));
};
bA.m_linearVelocity.SetV(v1);
bA.m_angularVelocity = w1;
bB.m_linearVelocity.SetV(v2);
bB.m_angularVelocity = w2;
}
public function GetUpperLimit():Number{
return (m_upperTranslation);
}
public function GetLowerLimit():Number{
return (m_lowerTranslation);
}
public function EnableMotor(flag:Boolean):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_enableMotor = flag;
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
public function GetJointTranslation():Number{
var tMat:b2Mat22;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
var p1:b2Vec2 = bA.GetWorldPoint(m_localAnchor1);
var p2:b2Vec2 = bB.GetWorldPoint(m_localAnchor2);
var dX:Number = (p2.x - p1.x);
var dY:Number = (p2.y - p1.y);
var axis:b2Vec2 = bA.GetWorldVector(m_localXAxis1);
var translation:Number = ((axis.x * dX) + (axis.y * dY));
return (translation);
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce(inv_dt:Number):b2Vec2{
return (new b2Vec2((inv_dt * ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.z) * m_axis.x))), (inv_dt * ((m_impulse.x * m_perp.y) + ((m_motorImpulse + m_impulse.z) * m_axis.y)))));
}
override b2internal function SolvePositionConstraints(baumgarte:Number):Boolean{
var limitC:Number;
var oldLimitImpulse:Number;
var tMat:b2Mat22;
var tX:Number;
var m1:Number;
var m2:Number;
var i1:Number;
var i2:Number;
var translation:Number;
var k11:Number;
var k12:Number;
var k22:Number;
var impulse1:b2Vec2;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
var c1:b2Vec2 = bA.m_sweep.c;
var a1:Number = bA.m_sweep.a;
var c2:b2Vec2 = bB.m_sweep.c;
var a2:Number = bB.m_sweep.a;
var linearError:Number = 0;
var angularError:Number = 0;
var active:Boolean;
var C2:Number = 0;
var R1:b2Mat22 = b2Mat22.FromAngle(a1);
var R2:b2Mat22 = b2Mat22.FromAngle(a2);
tMat = R1;
var r1X:Number = (m_localAnchor1.x - m_localCenterA.x);
var r1Y:Number = (m_localAnchor1.y - m_localCenterA.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = R2;
var r2X:Number = (m_localAnchor2.x - m_localCenterB.x);
var r2Y:Number = (m_localAnchor2.y - m_localCenterB.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var dX:Number = (((c2.x + r2X) - c1.x) - r1X);
var dY:Number = (((c2.y + r2Y) - c1.y) - r1Y);
if (m_enableLimit){
m_axis = b2Math.MulMV(R1, m_localXAxis1);
m_a1 = (((dX + r1X) * m_axis.y) - ((dY + r1Y) * m_axis.x));
m_a2 = ((r2X * m_axis.y) - (r2Y * m_axis.x));
translation = ((m_axis.x * dX) + (m_axis.y * dY));
if (b2Math.Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
C2 = b2Math.Clamp(translation, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
linearError = b2Math.Abs(translation);
active = true;
} else {
if (translation <= m_lowerTranslation){
C2 = b2Math.Clamp(((translation - m_lowerTranslation) + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
linearError = (m_lowerTranslation - translation);
active = true;
} else {
if (translation >= m_upperTranslation){
C2 = b2Math.Clamp(((translation - m_upperTranslation) + b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
linearError = (translation - m_upperTranslation);
active = true;
};
};
};
};
m_perp = b2Math.MulMV(R1, m_localYAxis1);
m_s1 = (((dX + r1X) * m_perp.y) - ((dY + r1Y) * m_perp.x));
m_s2 = ((r2X * m_perp.y) - (r2Y * m_perp.x));
var impulse:b2Vec3 = new b2Vec3();
var C1X:Number = ((m_perp.x * dX) + (m_perp.y * dY));
var C1Y:Number = ((a2 - a1) - m_refAngle);
linearError = b2Math.Max(linearError, b2Math.Abs(C1X));
angularError = b2Math.Abs(C1Y);
if (active){
m1 = m_invMassA;
m2 = m_invMassB;
i1 = m_invIA;
i2 = m_invIB;
m_K.col1.x = (((m1 + m2) + ((i1 * m_s1) * m_s1)) + ((i2 * m_s2) * m_s2));
m_K.col1.y = ((i1 * m_s1) + (i2 * m_s2));
m_K.col1.z = (((i1 * m_s1) * m_a1) + ((i2 * m_s2) * m_a2));
m_K.col2.x = m_K.col1.y;
m_K.col2.y = (i1 + i2);
m_K.col2.z = ((i1 * m_a1) + (i2 * m_a2));
m_K.col3.x = m_K.col1.z;
m_K.col3.y = m_K.col2.z;
m_K.col3.z = (((m1 + m2) + ((i1 * m_a1) * m_a1)) + ((i2 * m_a2) * m_a2));
m_K.Solve33(impulse, -(C1X), -(C1Y), -(C2));
} else {
m1 = m_invMassA;
m2 = m_invMassB;
i1 = m_invIA;
i2 = m_invIB;
k11 = (((m1 + m2) + ((i1 * m_s1) * m_s1)) + ((i2 * m_s2) * m_s2));
k12 = ((i1 * m_s1) + (i2 * m_s2));
k22 = (i1 + i2);
m_K.col1.Set(k11, k12, 0);
m_K.col2.Set(k12, k22, 0);
impulse1 = m_K.Solve22(new b2Vec2(), -(C1X), -(C1Y));
impulse.x = impulse1.x;
impulse.y = impulse1.y;
impulse.z = 0;
};
var PX:Number = ((impulse.x * m_perp.x) + (impulse.z * m_axis.x));
var PY:Number = ((impulse.x * m_perp.y) + (impulse.z * m_axis.y));
var L1:Number = (((impulse.x * m_s1) + impulse.y) + (impulse.z * m_a1));
var L2:Number = (((impulse.x * m_s2) + impulse.y) + (impulse.z * m_a2));
c1.x = (c1.x - (m_invMassA * PX));
c1.y = (c1.y - (m_invMassA * PY));
a1 = (a1 - (m_invIA * L1));
c2.x = (c2.x + (m_invMassB * PX));
c2.y = (c2.y + (m_invMassB * PY));
a2 = (a2 + (m_invIB * L2));
bA.m_sweep.a = a1;
bB.m_sweep.a = a2;
bA.SynchronizeTransform();
bB.SynchronizeTransform();
return ((((linearError <= b2Settings.b2_linearSlop)) && ((angularError <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(speed:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_motorSpeed = speed;
}
public function GetJointSpeed():Number{
var tMat:b2Mat22;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
tMat = bA.m_xf.R;
var r1X:Number = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
var r2X:Number = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var p1X:Number = (bA.m_sweep.c.x + r1X);
var p1Y:Number = (bA.m_sweep.c.y + r1Y);
var p2X:Number = (bB.m_sweep.c.x + r2X);
var p2Y:Number = (bB.m_sweep.c.y + r2Y);
var dX:Number = (p2X - p1X);
var dY:Number = (p2Y - p1Y);
var axis:b2Vec2 = bA.GetWorldVector(m_localXAxis1);
var v1:b2Vec2 = bA.m_linearVelocity;
var v2:b2Vec2 = bB.m_linearVelocity;
var w1:Number = bA.m_angularVelocity;
var w2:Number = bB.m_angularVelocity;
var speed:Number = (((dX * (-(w1) * axis.y)) + (dY * (w1 * axis.x))) + ((axis.x * (((v2.x + (-(w2) * r2Y)) - v1.x) - (-(w1) * r1Y))) + (axis.y * (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X)))));
return (speed);
}
override b2internal function InitVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var tX:Number;
var jointTransition:Number;
var PX:Number;
var PY:Number;
var L1:Number;
var L2:Number;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
m_localCenterA.SetV(bA.GetLocalCenter());
m_localCenterB.SetV(bB.GetLocalCenter());
var xf1:b2Transform = bA.GetTransform();
var xf2:b2Transform = bB.GetTransform();
tMat = bA.m_xf.R;
var r1X:Number = (m_localAnchor1.x - m_localCenterA.x);
var r1Y:Number = (m_localAnchor1.y - m_localCenterA.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
var r2X:Number = (m_localAnchor2.x - m_localCenterB.x);
var r2Y:Number = (m_localAnchor2.y - m_localCenterB.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var dX:Number = (((bB.m_sweep.c.x + r2X) - bA.m_sweep.c.x) - r1X);
var dY:Number = (((bB.m_sweep.c.y + r2Y) - bA.m_sweep.c.y) - r1Y);
m_invMassA = bA.m_invMass;
m_invMassB = bB.m_invMass;
m_invIA = bA.m_invI;
m_invIB = bB.m_invI;
m_axis.SetV(b2Math.MulMV(xf1.R, m_localXAxis1));
m_a1 = (((dX + r1X) * m_axis.y) - ((dY + r1Y) * m_axis.x));
m_a2 = ((r2X * m_axis.y) - (r2Y * m_axis.x));
m_motorMass = (((m_invMassA + m_invMassB) + ((m_invIA * m_a1) * m_a1)) + ((m_invIB * m_a2) * m_a2));
if (m_motorMass > Number.MIN_VALUE){
m_motorMass = (1 / m_motorMass);
};
m_perp.SetV(b2Math.MulMV(xf1.R, m_localYAxis1));
m_s1 = (((dX + r1X) * m_perp.y) - ((dY + r1Y) * m_perp.x));
m_s2 = ((r2X * m_perp.y) - (r2Y * m_perp.x));
var m1:Number = m_invMassA;
var m2:Number = m_invMassB;
var i1:Number = m_invIA;
var i2:Number = m_invIB;
m_K.col1.x = (((m1 + m2) + ((i1 * m_s1) * m_s1)) + ((i2 * m_s2) * m_s2));
m_K.col1.y = ((i1 * m_s1) + (i2 * m_s2));
m_K.col1.z = (((i1 * m_s1) * m_a1) + ((i2 * m_s2) * m_a2));
m_K.col2.x = m_K.col1.y;
m_K.col2.y = (i1 + i2);
m_K.col2.z = ((i1 * m_a1) + (i2 * m_a2));
m_K.col3.x = m_K.col1.z;
m_K.col3.y = m_K.col2.z;
m_K.col3.z = (((m1 + m2) + ((i1 * m_a1) * m_a1)) + ((i2 * m_a2) * m_a2));
if (m_enableLimit){
jointTransition = ((m_axis.x * dX) + (m_axis.y * dY));
if (b2Math.Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
m_limitState = e_equalLimits;
} else {
if (jointTransition <= m_lowerTranslation){
if (m_limitState != e_atLowerLimit){
m_limitState = e_atLowerLimit;
m_impulse.z = 0;
};
} else {
if (jointTransition >= m_upperTranslation){
if (m_limitState != e_atUpperLimit){
m_limitState = e_atUpperLimit;
m_impulse.z = 0;
};
} else {
m_limitState = e_inactiveLimit;
m_impulse.z = 0;
};
};
};
} else {
m_limitState = e_inactiveLimit;
};
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (step.warmStarting){
m_impulse.x = (m_impulse.x * step.dtRatio);
m_impulse.y = (m_impulse.y * step.dtRatio);
m_motorImpulse = (m_motorImpulse * step.dtRatio);
PX = ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.z) * m_axis.x));
PY = ((m_impulse.x * m_perp.y) + ((m_motorImpulse + m_impulse.z) * m_axis.y));
L1 = (((m_impulse.x * m_s1) + m_impulse.y) + ((m_motorImpulse + m_impulse.z) * m_a1));
L2 = (((m_impulse.x * m_s2) + m_impulse.y) + ((m_motorImpulse + m_impulse.z) * m_a2));
bA.m_linearVelocity.x = (bA.m_linearVelocity.x - (m_invMassA * PX));
bA.m_linearVelocity.y = (bA.m_linearVelocity.y - (m_invMassA * PY));
bA.m_angularVelocity = (bA.m_angularVelocity - (m_invIA * L1));
bB.m_linearVelocity.x = (bB.m_linearVelocity.x + (m_invMassB * PX));
bB.m_linearVelocity.y = (bB.m_linearVelocity.y + (m_invMassB * PY));
bB.m_angularVelocity = (bB.m_angularVelocity + (m_invIB * L2));
} else {
m_impulse.SetZero();
m_motorImpulse = 0;
};
}
public function GetMotorForce():Number{
return (m_motorImpulse);
}
public function SetMaxMotorForce(force:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_maxMotorForce = force;
}
public function EnableLimit(flag:Boolean):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_enableLimit = flag;
}
override public function GetReactionTorque(inv_dt:Number):Number{
return ((inv_dt * m_impulse.y));
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
return (m_enableMotor);
}
public function SetLimits(lower:Number, upper:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_lowerTranslation = lower;
m_upperTranslation = upper;
}
}
}//package Box2D.Dynamics.Joints
Section 122
//b2PrismaticJointDef (Box2D.Dynamics.Joints.b2PrismaticJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2PrismaticJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var motorSpeed:Number;
public var referenceAngle:Number;
public var localAnchorB:b2Vec2;
public var upperTranslation:Number;
public var lowerTranslation:Number;
public var localAxisA:b2Vec2;
public var enableLimit:Boolean;
public var enableMotor:Boolean;
public var maxMotorForce:Number;
public function b2PrismaticJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
localAxisA = new b2Vec2();
super();
type = b2Joint.e_prismaticJoint;
localAxisA.Set(1, 0);
referenceAngle = 0;
enableLimit = false;
lowerTranslation = 0;
upperTranslation = 0;
enableMotor = false;
maxMotorForce = 0;
motorSpeed = 0;
}
public function Initialize(bA:b2Body, bB:b2Body, anchor:b2Vec2, axis:b2Vec2):void{
bodyA = bA;
bodyB = bB;
localAnchorA = bodyA.GetLocalPoint(anchor);
localAnchorB = bodyB.GetLocalPoint(anchor);
localAxisA = bodyA.GetLocalVector(axis);
referenceAngle = (bodyB.GetAngle() - bodyA.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 123
//b2PulleyJoint (Box2D.Dynamics.Joints.b2PulleyJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2PulleyJoint extends b2Joint {
private var m_limitState1:int;
private var m_limitState2:int;
private var m_ground:b2Body;
private var m_maxLength2:Number;
private var m_maxLength1:Number;
private var m_impulse:Number;
private var m_constant:Number;
private var m_state:int;
private var m_ratio:Number;
private var m_groundAnchor1:b2Vec2;
private var m_groundAnchor2:b2Vec2;
private var m_localAnchor1:b2Vec2;
private var m_localAnchor2:b2Vec2;
private var m_limitMass1:Number;
private var m_limitMass2:Number;
private var m_pulleyMass:Number;
private var m_limitImpulse1:Number;
private var m_limitImpulse2:Number;
private var m_u1:b2Vec2;
private var m_u2:b2Vec2;
b2internal static const b2_minPulleyLength:Number = 2;
public function b2PulleyJoint(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_bodyA.m_world.m_groundBody;
m_groundAnchor1.x = (def.groundAnchorA.x - m_ground.m_xf.position.x);
m_groundAnchor1.y = (def.groundAnchorA.y - m_ground.m_xf.position.y);
m_groundAnchor2.x = (def.groundAnchorB.x - m_ground.m_xf.position.x);
m_groundAnchor2.y = (def.groundAnchorB.y - m_ground.m_xf.position.y);
m_localAnchor1.SetV(def.localAnchorA);
m_localAnchor2.SetV(def.localAnchorB);
m_ratio = def.ratio;
m_constant = (def.lengthA + (m_ratio * def.lengthB));
m_maxLength1 = b2Math.Min(def.maxLengthA, (m_constant - (m_ratio * b2_minPulleyLength)));
m_maxLength2 = b2Math.Min(def.maxLengthB, ((m_constant - b2_minPulleyLength) / m_ratio));
m_impulse = 0;
m_limitImpulse1 = 0;
m_limitImpulse2 = 0;
}
public function GetGroundAnchorB():b2Vec2{
var a:b2Vec2 = m_ground.m_xf.position.Copy();
a.Add(m_groundAnchor2);
return (a);
}
public function GetGroundAnchorA():b2Vec2{
var a:b2Vec2 = m_ground.m_xf.position.Copy();
a.Add(m_groundAnchor1);
return (a);
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
override public function GetReactionForce(inv_dt:Number):b2Vec2{
return (new b2Vec2(((inv_dt * m_impulse) * m_u2.x), ((inv_dt * m_impulse) * m_u2.y)));
}
override b2internal function SolvePositionConstraints(baumgarte:Number):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 oldImpulse:Number;
var oldLimitPositionImpulse:Number;
var tX:Number;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
var s1X:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var s1Y:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var s2X:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var s2Y:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
var linearError:Number = 0;
if (m_state == e_atUpperLimit){
tMat = bA.m_xf.R;
r1X = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
r1Y = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
r2X = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
r2Y = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
p1X = (bA.m_sweep.c.x + r1X);
p1Y = (bA.m_sweep.c.y + r1Y);
p2X = (bB.m_sweep.c.x + r2X);
p2Y = (bB.m_sweep.c.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.Max(linearError, -(C));
C = b2Math.Clamp((C + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
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);
bA.m_sweep.c.x = (bA.m_sweep.c.x + (bA.m_invMass * p1X));
bA.m_sweep.c.y = (bA.m_sweep.c.y + (bA.m_invMass * p1Y));
bA.m_sweep.a = (bA.m_sweep.a + (bA.m_invI * ((r1X * p1Y) - (r1Y * p1X))));
bB.m_sweep.c.x = (bB.m_sweep.c.x + (bB.m_invMass * p2X));
bB.m_sweep.c.y = (bB.m_sweep.c.y + (bB.m_invMass * p2Y));
bB.m_sweep.a = (bB.m_sweep.a + (bB.m_invI * ((r2X * p2Y) - (r2Y * p2X))));
bA.SynchronizeTransform();
bB.SynchronizeTransform();
};
if (m_limitState1 == e_atUpperLimit){
tMat = bA.m_xf.R;
r1X = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
r1Y = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
p1X = (bA.m_sweep.c.x + r1X);
p1Y = (bA.m_sweep.c.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.Max(linearError, -(C));
C = b2Math.Clamp((C + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
impulse = (-(m_limitMass1) * C);
p1X = (-(impulse) * m_u1.x);
p1Y = (-(impulse) * m_u1.y);
bA.m_sweep.c.x = (bA.m_sweep.c.x + (bA.m_invMass * p1X));
bA.m_sweep.c.y = (bA.m_sweep.c.y + (bA.m_invMass * p1Y));
bA.m_sweep.a = (bA.m_sweep.a + (bA.m_invI * ((r1X * p1Y) - (r1Y * p1X))));
bA.SynchronizeTransform();
};
if (m_limitState2 == e_atUpperLimit){
tMat = bB.m_xf.R;
r2X = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
r2Y = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
p2X = (bB.m_sweep.c.x + r2X);
p2Y = (bB.m_sweep.c.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.Max(linearError, -(C));
C = b2Math.Clamp((C + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
impulse = (-(m_limitMass2) * C);
p2X = (-(impulse) * m_u2.x);
p2Y = (-(impulse) * m_u2.y);
bB.m_sweep.c.x = (bB.m_sweep.c.x + (bB.m_invMass * p2X));
bB.m_sweep.c.y = (bB.m_sweep.c.y + (bB.m_invMass * p2Y));
bB.m_sweep.a = (bB.m_sweep.a + (bB.m_invI * ((r2X * p2Y) - (r2Y * p2X))));
bB.SynchronizeTransform();
};
return ((linearError < b2Settings.b2_linearSlop));
}
override b2internal function InitVelocityConstraints(step:b2TimeStep):void{
var bA:b2Body;
var bB:b2Body;
var tMat:b2Mat22;
var r1Y:Number;
var P1X:Number;
var P1Y:Number;
var P2X:Number;
var P2Y:Number;
bA = m_bodyA;
bB = m_bodyB;
tMat = bA.m_xf.R;
var r1X:Number = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
r1Y = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
var r2X:Number = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var p1X:Number = (bA.m_sweep.c.x + r1X);
var p1Y:Number = (bA.m_sweep.c.y + r1Y);
var p2X:Number = (bB.m_sweep.c.x + r2X);
var p2Y:Number = (bB.m_sweep.c.y + r2Y);
var s1X:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var s1Y:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var s2X:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var s2Y:Number = (m_ground.m_xf.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();
};
var C:Number = ((m_constant - length1) - (m_ratio * length2));
if (C > 0){
m_state = e_inactiveLimit;
m_impulse = 0;
} else {
m_state = e_atUpperLimit;
};
if (length1 < m_maxLength1){
m_limitState1 = e_inactiveLimit;
m_limitImpulse1 = 0;
} else {
m_limitState1 = e_atUpperLimit;
};
if (length2 < m_maxLength2){
m_limitState2 = e_inactiveLimit;
m_limitImpulse2 = 0;
} else {
m_limitState2 = e_atUpperLimit;
};
var cr1u1:Number = ((r1X * m_u1.y) - (r1Y * m_u1.x));
var cr2u2:Number = ((r2X * m_u2.y) - (r2Y * m_u2.x));
m_limitMass1 = (bA.m_invMass + ((bA.m_invI * cr1u1) * cr1u1));
m_limitMass2 = (bB.m_invMass + ((bB.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);
if (step.warmStarting){
m_impulse = (m_impulse * step.dtRatio);
m_limitImpulse1 = (m_limitImpulse1 * step.dtRatio);
m_limitImpulse2 = (m_limitImpulse2 * step.dtRatio);
P1X = ((-(m_impulse) - m_limitImpulse1) * m_u1.x);
P1Y = ((-(m_impulse) - m_limitImpulse1) * m_u1.y);
P2X = (((-(m_ratio) * m_impulse) - m_limitImpulse2) * m_u2.x);
P2Y = (((-(m_ratio) * m_impulse) - m_limitImpulse2) * m_u2.y);
bA.m_linearVelocity.x = (bA.m_linearVelocity.x + (bA.m_invMass * P1X));
bA.m_linearVelocity.y = (bA.m_linearVelocity.y + (bA.m_invMass * P1Y));
bA.m_angularVelocity = (bA.m_angularVelocity + (bA.m_invI * ((r1X * P1Y) - (r1Y * P1X))));
bB.m_linearVelocity.x = (bB.m_linearVelocity.x + (bB.m_invMass * P2X));
bB.m_linearVelocity.y = (bB.m_linearVelocity.y + (bB.m_invMass * P2Y));
bB.m_angularVelocity = (bB.m_angularVelocity + (bB.m_invI * ((r2X * P2Y) - (r2Y * P2X))));
} else {
m_impulse = 0;
m_limitImpulse1 = 0;
m_limitImpulse2 = 0;
};
}
override public function GetReactionTorque(inv_dt:Number):Number{
return (0);
}
public function GetRatio():Number{
return (m_ratio);
}
public function GetLength2():Number{
var p:b2Vec2 = m_bodyB.GetWorldPoint(m_localAnchor2);
var sX:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var sY:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
var dX:Number = (p.x - sX);
var dY:Number = (p.y - sY);
return (Math.sqrt(((dX * dX) + (dY * dY))));
}
override b2internal 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 oldImpulse:Number;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
tMat = bA.m_xf.R;
var r1X:Number = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
var r2X:Number = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
if (m_state == e_atUpperLimit){
v1X = (bA.m_linearVelocity.x + (-(bA.m_angularVelocity) * r1Y));
v1Y = (bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X));
v2X = (bB.m_linearVelocity.x + (-(bB.m_angularVelocity) * r2Y));
v2Y = (bB.m_linearVelocity.y + (bB.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));
oldImpulse = m_impulse;
m_impulse = b2Math.Max(0, (m_impulse + impulse));
impulse = (m_impulse - oldImpulse);
P1X = (-(impulse) * m_u1.x);
P1Y = (-(impulse) * m_u1.y);
P2X = ((-(m_ratio) * impulse) * m_u2.x);
P2Y = ((-(m_ratio) * impulse) * m_u2.y);
bA.m_linearVelocity.x = (bA.m_linearVelocity.x + (bA.m_invMass * P1X));
bA.m_linearVelocity.y = (bA.m_linearVelocity.y + (bA.m_invMass * P1Y));
bA.m_angularVelocity = (bA.m_angularVelocity + (bA.m_invI * ((r1X * P1Y) - (r1Y * P1X))));
bB.m_linearVelocity.x = (bB.m_linearVelocity.x + (bB.m_invMass * P2X));
bB.m_linearVelocity.y = (bB.m_linearVelocity.y + (bB.m_invMass * P2Y));
bB.m_angularVelocity = (bB.m_angularVelocity + (bB.m_invI * ((r2X * P2Y) - (r2Y * P2X))));
};
if (m_limitState1 == e_atUpperLimit){
v1X = (bA.m_linearVelocity.x + (-(bA.m_angularVelocity) * r1Y));
v1Y = (bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X));
Cdot = -(((m_u1.x * v1X) + (m_u1.y * v1Y)));
impulse = (-(m_limitMass1) * Cdot);
oldImpulse = m_limitImpulse1;
m_limitImpulse1 = b2Math.Max(0, (m_limitImpulse1 + impulse));
impulse = (m_limitImpulse1 - oldImpulse);
P1X = (-(impulse) * m_u1.x);
P1Y = (-(impulse) * m_u1.y);
bA.m_linearVelocity.x = (bA.m_linearVelocity.x + (bA.m_invMass * P1X));
bA.m_linearVelocity.y = (bA.m_linearVelocity.y + (bA.m_invMass * P1Y));
bA.m_angularVelocity = (bA.m_angularVelocity + (bA.m_invI * ((r1X * P1Y) - (r1Y * P1X))));
};
if (m_limitState2 == e_atUpperLimit){
v2X = (bB.m_linearVelocity.x + (-(bB.m_angularVelocity) * r2Y));
v2Y = (bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X));
Cdot = -(((m_u2.x * v2X) + (m_u2.y * v2Y)));
impulse = (-(m_limitMass2) * Cdot);
oldImpulse = m_limitImpulse2;
m_limitImpulse2 = b2Math.Max(0, (m_limitImpulse2 + impulse));
impulse = (m_limitImpulse2 - oldImpulse);
P2X = (-(impulse) * m_u2.x);
P2Y = (-(impulse) * m_u2.y);
bB.m_linearVelocity.x = (bB.m_linearVelocity.x + (bB.m_invMass * P2X));
bB.m_linearVelocity.y = (bB.m_linearVelocity.y + (bB.m_invMass * P2Y));
bB.m_angularVelocity = (bB.m_angularVelocity + (bB.m_invI * ((r2X * P2Y) - (r2Y * P2X))));
};
}
public function GetLength1():Number{
var p:b2Vec2 = m_bodyA.GetWorldPoint(m_localAnchor1);
var sX:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var sY:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var dX:Number = (p.x - sX);
var dY:Number = (p.y - sY);
return (Math.sqrt(((dX * dX) + (dY * dY))));
}
}
}//package Box2D.Dynamics.Joints
Section 124
//b2PulleyJointDef (Box2D.Dynamics.Joints.b2PulleyJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2PulleyJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var groundAnchorA:b2Vec2;
public var groundAnchorB:b2Vec2;
public var localAnchorB:b2Vec2;
public var ratio:Number;
public var maxLengthA:Number;
public var lengthA:Number;
public var lengthB:Number;
public var maxLengthB:Number;
public function b2PulleyJointDef(){
groundAnchorA = new b2Vec2();
groundAnchorB = new b2Vec2();
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_pulleyJoint;
groundAnchorA.Set(-1, 1);
groundAnchorB.Set(1, 1);
localAnchorA.Set(-1, 0);
localAnchorB.Set(1, 0);
lengthA = 0;
maxLengthA = 0;
lengthB = 0;
maxLengthB = 0;
ratio = 1;
collideConnected = true;
}
public function Initialize(bA:b2Body, bB:b2Body, gaA:b2Vec2, gaB:b2Vec2, anchorA:b2Vec2, anchorB:b2Vec2, r:Number):void{
bodyA = bA;
bodyB = bB;
groundAnchorA.SetV(gaA);
groundAnchorB.SetV(gaB);
localAnchorA = bodyA.GetLocalPoint(anchorA);
localAnchorB = bodyB.GetLocalPoint(anchorB);
var d1X:Number = (anchorA.x - gaA.x);
var d1Y:Number = (anchorA.y - gaA.y);
lengthA = Math.sqrt(((d1X * d1X) + (d1Y * d1Y)));
var d2X:Number = (anchorB.x - gaB.x);
var d2Y:Number = (anchorB.y - gaB.y);
lengthB = Math.sqrt(((d2X * d2X) + (d2Y * d2Y)));
ratio = r;
var C:Number = (lengthA + (ratio * lengthB));
maxLengthA = (C - (ratio * b2PulleyJoint.b2_minPulleyLength));
maxLengthB = ((C - b2PulleyJoint.b2_minPulleyLength) / ratio);
}
}
}//package Box2D.Dynamics.Joints
Section 125
//b2RevoluteJoint (Box2D.Dynamics.Joints.b2RevoluteJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2RevoluteJoint extends b2Joint {
private var m_mass:b2Mat33;
private var m_impulse:b2Vec3;
private var m_enableLimit:Boolean;
private var m_limitState:int;
private var m_motorMass:Number;
private var reduced:b2Vec2;
b2internal var m_localAnchor1:b2Vec2;
b2internal var m_localAnchor2:b2Vec2;
private var K1:b2Mat22;
private var K2:b2Mat22;
private var K3:b2Mat22;
private var K:b2Mat22;
private var m_motorImpulse:Number;
private var impulse2:b2Vec2;
private var impulse3:b2Vec3;
private var m_enableMotor:Boolean;
private var m_referenceAngle:Number;
private var m_upperAngle:Number;
private var m_motorSpeed:Number;
private var m_lowerAngle:Number;
private var m_maxMotorTorque:Number;
private static var tImpulse:b2Vec2 = new b2Vec2();
public function b2RevoluteJoint(def:b2RevoluteJointDef){
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
K3 = new b2Mat22();
impulse3 = new b2Vec3();
impulse2 = new b2Vec2();
reduced = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_impulse = new b2Vec3();
m_mass = new b2Mat33();
super(def);
m_localAnchor1.SetV(def.localAnchorA);
m_localAnchor2.SetV(def.localAnchorB);
m_referenceAngle = def.referenceAngle;
m_impulse.SetZero();
m_motorImpulse = 0;
m_lowerAngle = def.lowerAngle;
m_upperAngle = def.upperAngle;
m_maxMotorTorque = def.maxMotorTorque;
m_motorSpeed = def.motorSpeed;
m_enableLimit = def.enableLimit;
m_enableMotor = def.enableMotor;
m_limitState = e_inactiveLimit;
}
override b2internal function SolveVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var tX:Number;
var newImpulse:Number;
var r1X:Number;
var r1Y:Number;
var r2X:Number;
var r2Y:Number;
var Cdot:Number;
var impulse:Number;
var oldImpulse:Number;
var maxImpulse:Number;
var Cdot1X:Number;
var Cdot1Y:Number;
var Cdot2:Number;
var CdotX:Number;
var CdotY:Number;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
var v1:b2Vec2 = bA.m_linearVelocity;
var w1:Number = bA.m_angularVelocity;
var v2:b2Vec2 = bB.m_linearVelocity;
var w2:Number = bB.m_angularVelocity;
var m1:Number = bA.m_invMass;
var m2:Number = bB.m_invMass;
var i1:Number = bA.m_invI;
var i2:Number = bB.m_invI;
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
Cdot = ((w2 - w1) - m_motorSpeed);
impulse = (m_motorMass * -(Cdot));
oldImpulse = m_motorImpulse;
maxImpulse = (step.dt * m_maxMotorTorque);
m_motorImpulse = b2Math.Clamp((m_motorImpulse + impulse), -(maxImpulse), maxImpulse);
impulse = (m_motorImpulse - oldImpulse);
w1 = (w1 - (i1 * impulse));
w2 = (w2 + (i2 * impulse));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
tMat = bA.m_xf.R;
r1X = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
r1Y = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
r2X = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
r2Y = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
Cdot1X = (((v2.x + (-(w2) * r2Y)) - v1.x) - (-(w1) * r1Y));
Cdot1Y = (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X));
Cdot2 = (w2 - w1);
m_mass.Solve33(impulse3, -(Cdot1X), -(Cdot1Y), -(Cdot2));
if (m_limitState == e_equalLimits){
m_impulse.Add(impulse3);
} else {
if (m_limitState == e_atLowerLimit){
newImpulse = (m_impulse.z + impulse3.z);
if (newImpulse < 0){
m_mass.Solve22(reduced, -(Cdot1X), -(Cdot1Y));
impulse3.x = reduced.x;
impulse3.y = reduced.y;
impulse3.z = -(m_impulse.z);
m_impulse.x = (m_impulse.x + reduced.x);
m_impulse.y = (m_impulse.y + reduced.y);
m_impulse.z = 0;
};
} else {
if (m_limitState == e_atUpperLimit){
newImpulse = (m_impulse.z + impulse3.z);
if (newImpulse > 0){
m_mass.Solve22(reduced, -(Cdot1X), -(Cdot1Y));
impulse3.x = reduced.x;
impulse3.y = reduced.y;
impulse3.z = -(m_impulse.z);
m_impulse.x = (m_impulse.x + reduced.x);
m_impulse.y = (m_impulse.y + reduced.y);
m_impulse.z = 0;
};
};
};
};
v1.x = (v1.x - (m1 * impulse3.x));
v1.y = (v1.y - (m1 * impulse3.y));
w1 = (w1 - (i1 * (((r1X * impulse3.y) - (r1Y * impulse3.x)) + impulse3.z)));
v2.x = (v2.x + (m2 * impulse3.x));
v2.y = (v2.y + (m2 * impulse3.y));
w2 = (w2 + (i2 * (((r2X * impulse3.y) - (r2Y * impulse3.x)) + impulse3.z)));
} else {
tMat = bA.m_xf.R;
r1X = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
r1Y = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
r2X = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
r2Y = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
CdotX = (((v2.x + (-(w2) * r2Y)) - v1.x) - (-(w1) * r1Y));
CdotY = (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X));
m_mass.Solve22(impulse2, -(CdotX), -(CdotY));
m_impulse.x = (m_impulse.x + impulse2.x);
m_impulse.y = (m_impulse.y + impulse2.y);
v1.x = (v1.x - (m1 * impulse2.x));
v1.y = (v1.y - (m1 * impulse2.y));
w1 = (w1 - (i1 * ((r1X * impulse2.y) - (r1Y * impulse2.x))));
v2.x = (v2.x + (m2 * impulse2.x));
v2.y = (v2.y + (m2 * impulse2.y));
w2 = (w2 + (i2 * ((r2X * impulse2.y) - (r2Y * impulse2.x))));
};
bA.m_linearVelocity.SetV(v1);
bA.m_angularVelocity = w1;
bB.m_linearVelocity.SetV(v2);
bB.m_angularVelocity = w2;
}
public function GetUpperLimit():Number{
return (m_upperAngle);
}
public function GetLowerLimit():Number{
return (m_lowerAngle);
}
public function EnableMotor(flag:Boolean):void{
m_enableMotor = flag;
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchor2));
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchor1));
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce(inv_dt:Number):b2Vec2{
return (new b2Vec2((inv_dt * m_impulse.x), (inv_dt * m_impulse.y)));
}
override b2internal function SolvePositionConstraints(baumgarte:Number):Boolean{
var oldLimitImpulse:Number;
var C:Number;
var tMat:b2Mat22;
var tX:Number;
var impulseX:Number;
var impulseY:Number;
var angle:Number;
var limitImpulse:Number;
var uX:Number;
var uY:Number;
var k:Number;
var m:Number;
var k_beta:Number;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
var angularError:Number = 0;
var positionError:Number = 0;
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
angle = ((bB.m_sweep.a - bA.m_sweep.a) - m_referenceAngle);
limitImpulse = 0;
if (m_limitState == e_equalLimits){
C = b2Math.Clamp((angle - m_lowerAngle), -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
limitImpulse = (-(m_motorMass) * C);
angularError = b2Math.Abs(C);
} else {
if (m_limitState == e_atLowerLimit){
C = (angle - m_lowerAngle);
angularError = -(C);
C = b2Math.Clamp((C + b2Settings.b2_angularSlop), -(b2Settings.b2_maxAngularCorrection), 0);
limitImpulse = (-(m_motorMass) * C);
} else {
if (m_limitState == e_atUpperLimit){
C = (angle - m_upperAngle);
angularError = C;
C = b2Math.Clamp((C - b2Settings.b2_angularSlop), 0, b2Settings.b2_maxAngularCorrection);
limitImpulse = (-(m_motorMass) * C);
};
};
};
bA.m_sweep.a = (bA.m_sweep.a - (bA.m_invI * limitImpulse));
bB.m_sweep.a = (bB.m_sweep.a + (bB.m_invI * limitImpulse));
bA.SynchronizeTransform();
bB.SynchronizeTransform();
};
tMat = bA.m_xf.R;
var r1X:Number = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
var r2X:Number = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var CX:Number = (((bB.m_sweep.c.x + r2X) - bA.m_sweep.c.x) - r1X);
var CY:Number = (((bB.m_sweep.c.y + r2Y) - bA.m_sweep.c.y) - r1Y);
var CLengthSquared:Number = ((CX * CX) + (CY * CY));
var CLength:Number = Math.sqrt(CLengthSquared);
positionError = CLength;
var invMass1:Number = bA.m_invMass;
var invMass2:Number = bB.m_invMass;
var invI1:Number = bA.m_invI;
var invI2:Number = bB.m_invI;
var k_allowedStretch:Number = (10 * b2Settings.b2_linearSlop);
if (CLengthSquared > (k_allowedStretch * k_allowedStretch)){
uX = (CX / CLength);
uY = (CY / CLength);
k = (invMass1 + invMass2);
m = (1 / k);
impulseX = (m * -(CX));
impulseY = (m * -(CY));
k_beta = 0.5;
bA.m_sweep.c.x = (bA.m_sweep.c.x - ((k_beta * invMass1) * impulseX));
bA.m_sweep.c.y = (bA.m_sweep.c.y - ((k_beta * invMass1) * impulseY));
bB.m_sweep.c.x = (bB.m_sweep.c.x + ((k_beta * invMass2) * impulseX));
bB.m_sweep.c.y = (bB.m_sweep.c.y + ((k_beta * invMass2) * impulseY));
CX = (((bB.m_sweep.c.x + r2X) - bA.m_sweep.c.x) - r1X);
CY = (((bB.m_sweep.c.y + r2Y) - bA.m_sweep.c.y) - r1Y);
};
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, -(CX), -(CY));
impulseX = tImpulse.x;
impulseY = tImpulse.y;
bA.m_sweep.c.x = (bA.m_sweep.c.x - (bA.m_invMass * impulseX));
bA.m_sweep.c.y = (bA.m_sweep.c.y - (bA.m_invMass * impulseY));
bA.m_sweep.a = (bA.m_sweep.a - (bA.m_invI * ((r1X * impulseY) - (r1Y * impulseX))));
bB.m_sweep.c.x = (bB.m_sweep.c.x + (bB.m_invMass * impulseX));
bB.m_sweep.c.y = (bB.m_sweep.c.y + (bB.m_invMass * impulseY));
bB.m_sweep.a = (bB.m_sweep.a + (bB.m_invI * ((r2X * impulseY) - (r2Y * impulseX))));
bA.SynchronizeTransform();
bB.SynchronizeTransform();
return ((((positionError <= b2Settings.b2_linearSlop)) && ((angularError <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(speed:Number):void{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
m_motorSpeed = speed;
}
public function SetMaxMotorTorque(torque:Number):void{
m_maxMotorTorque = torque;
}
public function GetJointAngle():Number{
return (((m_bodyB.m_sweep.a - m_bodyA.m_sweep.a) - m_referenceAngle));
}
public function GetJointSpeed():Number{
return ((m_bodyB.m_angularVelocity - m_bodyA.m_angularVelocity));
}
public function GetMotorTorque():Number{
return (m_maxMotorTorque);
}
override b2internal function InitVelocityConstraints(step:b2TimeStep):void{
var bA:b2Body;
var bB:b2Body;
var tMat:b2Mat22;
var tX:Number;
var r1Y:Number;
var jointAngle:Number;
var PX:Number;
var PY:Number;
bA = m_bodyA;
bB = m_bodyB;
if (((m_enableMotor) || (m_enableLimit))){
};
tMat = bA.m_xf.R;
var r1X:Number = (m_localAnchor1.x - bA.m_sweep.localCenter.x);
r1Y = (m_localAnchor1.y - bA.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = bB.m_xf.R;
var r2X:Number = (m_localAnchor2.x - bB.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var m1:Number = bA.m_invMass;
var m2:Number = bB.m_invMass;
var i1:Number = bA.m_invI;
var i2:Number = bB.m_invI;
m_mass.col1.x = (((m1 + m2) + ((r1Y * r1Y) * i1)) + ((r2Y * r2Y) * i2));
m_mass.col2.x = (((-(r1Y) * r1X) * i1) - ((r2Y * r2X) * i2));
m_mass.col3.x = ((-(r1Y) * i1) - (r2Y * i2));
m_mass.col1.y = m_mass.col2.x;
m_mass.col2.y = (((m1 + m2) + ((r1X * r1X) * i1)) + ((r2X * r2X) * i2));
m_mass.col3.y = ((r1X * i1) + (r2X * i2));
m_mass.col1.z = m_mass.col3.x;
m_mass.col2.z = m_mass.col3.y;
m_mass.col3.z = (i1 + i2);
m_motorMass = (1 / (i1 + i2));
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (m_enableLimit){
jointAngle = ((bB.m_sweep.a - bA.m_sweep.a) - m_referenceAngle);
if (b2Math.Abs((m_upperAngle - m_lowerAngle)) < (2 * b2Settings.b2_angularSlop)){
m_limitState = e_equalLimits;
} else {
if (jointAngle <= m_lowerAngle){
if (m_limitState != e_atLowerLimit){
m_impulse.z = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (jointAngle >= m_upperAngle){
if (m_limitState != e_atUpperLimit){
m_impulse.z = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_impulse.z = 0;
};
};
};
} else {
m_limitState = e_inactiveLimit;
};
if (step.warmStarting){
m_impulse.x = (m_impulse.x * step.dtRatio);
m_impulse.y = (m_impulse.y * step.dtRatio);
m_motorImpulse = (m_motorImpulse * step.dtRatio);
PX = m_impulse.x;
PY = m_impulse.y;
bA.m_linearVelocity.x = (bA.m_linearVelocity.x - (m1 * PX));
bA.m_linearVelocity.y = (bA.m_linearVelocity.y - (m1 * PY));
bA.m_angularVelocity = (bA.m_angularVelocity - (i1 * ((((r1X * PY) - (r1Y * PX)) + m_motorImpulse) + m_impulse.z)));
bB.m_linearVelocity.x = (bB.m_linearVelocity.x + (m2 * PX));
bB.m_linearVelocity.y = (bB.m_linearVelocity.y + (m2 * PY));
bB.m_angularVelocity = (bB.m_angularVelocity + (i2 * ((((r2X * PY) - (r2Y * PX)) + m_motorImpulse) + m_impulse.z)));
} else {
m_impulse.SetZero();
m_motorImpulse = 0;
};
}
public function EnableLimit(flag:Boolean):void{
m_enableLimit = flag;
}
override public function GetReactionTorque(inv_dt:Number):Number{
return ((inv_dt * m_impulse.z));
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
m_bodyA.SetAwake(true);
m_bodyB.SetAwake(true);
return (m_enableMotor);
}
public function SetLimits(lower:Number, upper:Number):void{
m_lowerAngle = lower;
m_upperAngle = upper;
}
}
}//package Box2D.Dynamics.Joints
Section 126
//b2RevoluteJointDef (Box2D.Dynamics.Joints.b2RevoluteJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2RevoluteJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var referenceAngle:Number;
public var localAnchorB:b2Vec2;
public var motorSpeed:Number;
public var upperAngle:Number;
public var lowerAngle:Number;
public var enableLimit:Boolean;
public var enableMotor:Boolean;
public var maxMotorTorque:Number;
public function b2RevoluteJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_revoluteJoint;
localAnchorA.Set(0, 0);
localAnchorB.Set(0, 0);
referenceAngle = 0;
lowerAngle = 0;
upperAngle = 0;
maxMotorTorque = 0;
motorSpeed = 0;
enableLimit = false;
enableMotor = false;
}
public function Initialize(bA:b2Body, bB:b2Body, anchor:b2Vec2):void{
bodyA = bA;
bodyB = bB;
localAnchorA = bodyA.GetLocalPoint(anchor);
localAnchorB = bodyB.GetLocalPoint(anchor);
referenceAngle = (bodyB.GetAngle() - bodyA.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 127
//b2WeldJoint (Box2D.Dynamics.Joints.b2WeldJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2WeldJoint extends b2Joint {
private var m_impulse:b2Vec3;
private var m_referenceAngle:Number;
private var m_localAnchorA:b2Vec2;
private var m_localAnchorB:b2Vec2;
private var m_mass:b2Mat33;
public function b2WeldJoint(def:b2WeldJointDef){
m_localAnchorA = new b2Vec2();
m_localAnchorB = new b2Vec2();
m_impulse = new b2Vec3();
m_mass = new b2Mat33();
super(def);
m_localAnchorA.SetV(def.localAnchorA);
m_localAnchorB.SetV(def.localAnchorB);
m_referenceAngle = def.referenceAngle;
m_impulse.SetZero();
m_mass = new b2Mat33();
}
override b2internal function SolveVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var tX:Number;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
var vA:b2Vec2 = bA.m_linearVelocity;
var wA:Number = bA.m_angularVelocity;
var vB:b2Vec2 = bB.m_linearVelocity;
var wB:Number = bB.m_angularVelocity;
var mA:Number = bA.m_invMass;
var mB:Number = bB.m_invMass;
var iA:Number = bA.m_invI;
var iB:Number = bB.m_invI;
tMat = bA.m_xf.R;
var rAX:Number = (m_localAnchorA.x - bA.m_sweep.localCenter.x);
var rAY:Number = (m_localAnchorA.y - bA.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rAX) + (tMat.col2.x * rAY));
rAY = ((tMat.col1.y * rAX) + (tMat.col2.y * rAY));
rAX = tX;
tMat = bB.m_xf.R;
var rBX:Number = (m_localAnchorB.x - bB.m_sweep.localCenter.x);
var rBY:Number = (m_localAnchorB.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rBX) + (tMat.col2.x * rBY));
rBY = ((tMat.col1.y * rBX) + (tMat.col2.y * rBY));
rBX = tX;
var Cdot1X:Number = (((vB.x - (wB * rBY)) - vA.x) + (wA * rAY));
var Cdot1Y:Number = (((vB.y + (wB * rBX)) - vA.y) - (wA * rAX));
var Cdot2:Number = (wB - wA);
var impulse:b2Vec3 = new b2Vec3();
m_mass.Solve33(impulse, -(Cdot1X), -(Cdot1Y), -(Cdot2));
m_impulse.Add(impulse);
vA.x = (vA.x - (mA * impulse.x));
vA.y = (vA.y - (mA * impulse.y));
wA = (wA - (iA * (((rAX * impulse.y) - (rAY * impulse.x)) + impulse.z)));
vB.x = (vB.x + (mB * impulse.x));
vB.y = (vB.y + (mB * impulse.y));
wB = (wB + (iB * (((rBX * impulse.y) - (rBY * impulse.x)) + impulse.z)));
bA.m_angularVelocity = wA;
bB.m_angularVelocity = wB;
}
override public function GetReactionTorque(inv_dt:Number):Number{
return ((inv_dt * m_impulse.z));
}
override public function GetReactionForce(inv_dt:Number):b2Vec2{
return (new b2Vec2((inv_dt * m_impulse.x), (inv_dt * m_impulse.y)));
}
override b2internal function SolvePositionConstraints(baumgarte:Number):Boolean{
var tMat:b2Mat22;
var tX:Number;
var bA:b2Body = m_bodyA;
var bB:b2Body = m_bodyB;
tMat = bA.m_xf.R;
var rAX:Number = (m_localAnchorA.x - bA.m_sweep.localCenter.x);
var rAY:Number = (m_localAnchorA.y - bA.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rAX) + (tMat.col2.x * rAY));
rAY = ((tMat.col1.y * rAX) + (tMat.col2.y * rAY));
rAX = tX;
tMat = bB.m_xf.R;
var rBX:Number = (m_localAnchorB.x - bB.m_sweep.localCenter.x);
var rBY:Number = (m_localAnchorB.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rBX) + (tMat.col2.x * rBY));
rBY = ((tMat.col1.y * rBX) + (tMat.col2.y * rBY));
rBX = tX;
var mA:Number = bA.m_invMass;
var mB:Number = bB.m_invMass;
var iA:Number = bA.m_invI;
var iB:Number = bB.m_invI;
var C1X:Number = (((bB.m_sweep.c.x + rBX) - bA.m_sweep.c.x) - rAX);
var C1Y:Number = (((bB.m_sweep.c.y + rBY) - bA.m_sweep.c.y) - rAY);
var C2:Number = ((bB.m_sweep.a - bA.m_sweep.a) - m_referenceAngle);
var k_allowedStretch:Number = (10 * b2Settings.b2_linearSlop);
var positionError:Number = Math.sqrt(((C1X * C1X) + (C1Y * C1Y)));
var angularError:Number = b2Math.Abs(C2);
if (positionError > k_allowedStretch){
iA = (iA * 1);
iB = (iB * 1);
};
m_mass.col1.x = (((mA + mB) + ((rAY * rAY) * iA)) + ((rBY * rBY) * iB));
m_mass.col2.x = (((-(rAY) * rAX) * iA) - ((rBY * rBX) * iB));
m_mass.col3.x = ((-(rAY) * iA) - (rBY * iB));
m_mass.col1.y = m_mass.col2.x;
m_mass.col2.y = (((mA + mB) + ((rAX * rAX) * iA)) + ((rBX * rBX) * iB));
m_mass.col3.y = ((rAX * iA) + (rBX * iB));
m_mass.col1.z = m_mass.col3.x;
m_mass.col2.z = m_mass.col3.y;
m_mass.col3.z = (iA + iB);
var impulse:b2Vec3 = new b2Vec3();
m_mass.Solve33(impulse, -(C1X), -(C1Y), -(C2));
bA.m_sweep.c.x = (bA.m_sweep.c.x - (mA * impulse.x));
bA.m_sweep.c.y = (bA.m_sweep.c.y - (mA * impulse.y));
bA.m_sweep.a = (bA.m_sweep.a - (iA * (((rAX * impulse.y) - (rAY * impulse.x)) + impulse.z)));
bB.m_sweep.c.x = (bB.m_sweep.c.x + (mB * impulse.x));
bB.m_sweep.c.y = (bB.m_sweep.c.y + (mB * impulse.y));
bB.m_sweep.a = (bB.m_sweep.a + (iB * (((rBX * impulse.y) - (rBY * impulse.x)) + impulse.z)));
bA.SynchronizeTransform();
bB.SynchronizeTransform();
return ((((positionError <= b2Settings.b2_linearSlop)) && ((angularError <= b2Settings.b2_angularSlop))));
}
override b2internal function InitVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var tX:Number;
var bA:b2Body;
var bB:b2Body;
var rAX:Number;
var rAY:Number;
var rBX:Number;
var rBY:Number;
var mA:Number;
var mB:Number;
var iA:Number;
var iB:Number;
bA = m_bodyA;
bB = m_bodyB;
tMat = bA.m_xf.R;
rAX = (m_localAnchorA.x - bA.m_sweep.localCenter.x);
rAY = (m_localAnchorA.y - bA.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rAX) + (tMat.col2.x * rAY));
rAY = ((tMat.col1.y * rAX) + (tMat.col2.y * rAY));
rAX = tX;
tMat = bB.m_xf.R;
rBX = (m_localAnchorB.x - bB.m_sweep.localCenter.x);
rBY = (m_localAnchorB.y - bB.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rBX) + (tMat.col2.x * rBY));
rBY = ((tMat.col1.y * rBX) + (tMat.col2.y * rBY));
rBX = tX;
mA = bA.m_invMass;
mB = bB.m_invMass;
iA = bA.m_invI;
iB = bB.m_invI;
m_mass.col1.x = (((mA + mB) + ((rAY * rAY) * iA)) + ((rBY * rBY) * iB));
m_mass.col2.x = (((-(rAY) * rAX) * iA) - ((rBY * rBX) * iB));
m_mass.col3.x = ((-(rAY) * iA) - (rBY * iB));
m_mass.col1.y = m_mass.col2.x;
m_mass.col2.y = (((mA + mB) + ((rAX * rAX) * iA)) + ((rBX * rBX) * iB));
m_mass.col3.y = ((rAX * iA) + (rBX * iB));
m_mass.col1.z = m_mass.col3.x;
m_mass.col2.z = m_mass.col3.y;
m_mass.col3.z = (iA + iB);
if (step.warmStarting){
m_impulse.x = (m_impulse.x * step.dtRatio);
m_impulse.y = (m_impulse.y * step.dtRatio);
m_impulse.z = (m_impulse.z * step.dtRatio);
bA.m_linearVelocity.x = (bA.m_linearVelocity.x - (mA * m_impulse.x));
bA.m_linearVelocity.y = (bA.m_linearVelocity.y - (mA * m_impulse.y));
bA.m_angularVelocity = (bA.m_angularVelocity - (iA * (((rAX * m_impulse.y) - (rAY * m_impulse.x)) + m_impulse.z)));
bB.m_linearVelocity.x = (bB.m_linearVelocity.x + (mB * m_impulse.x));
bB.m_linearVelocity.y = (bB.m_linearVelocity.y + (mB * m_impulse.y));
bB.m_angularVelocity = (bB.m_angularVelocity + (iB * (((rBX * m_impulse.y) - (rBY * m_impulse.x)) + m_impulse.z)));
} else {
m_impulse.SetZero();
};
}
override public function GetAnchorA():b2Vec2{
return (m_bodyA.GetWorldPoint(m_localAnchorA));
}
override public function GetAnchorB():b2Vec2{
return (m_bodyB.GetWorldPoint(m_localAnchorB));
}
}
}//package Box2D.Dynamics.Joints
Section 128
//b2WeldJointDef (Box2D.Dynamics.Joints.b2WeldJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2WeldJointDef extends b2JointDef {
public var localAnchorA:b2Vec2;
public var referenceAngle:Number;
public var localAnchorB:b2Vec2;
public function b2WeldJointDef(){
localAnchorA = new b2Vec2();
localAnchorB = new b2Vec2();
super();
type = b2Joint.e_weldJoint;
referenceAngle = 0;
}
public function Initialize(bA:b2Body, bB:b2Body, anchor:b2Vec2):void{
bodyA = bA;
bodyB = bB;
localAnchorA.SetV(bodyA.GetLocalPoint(anchor));
localAnchorB.SetV(bodyB.GetLocalPoint(anchor));
referenceAngle = (bodyB.GetAngle() - bodyA.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 129
//b2Body (Box2D.Dynamics.b2Body)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Controllers.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2Body {
b2internal var m_xf:b2Transform;
b2internal var m_controllerCount:int;
b2internal var m_contactList:b2ContactEdge;
b2internal var m_invI:Number;
b2internal var m_fixtureCount:int;
b2internal var m_torque:Number;
b2internal var m_angularVelocity:Number;
b2internal var m_flags:uint;
b2internal var m_linearVelocity:b2Vec2;
b2internal var m_world:b2World;
b2internal var m_inertiaScale:Number;
b2internal var m_controllerList:b2ControllerEdge;
b2internal var m_fixtureList:b2Fixture;
b2internal var m_mass:Number;
b2internal var m_next:b2Body;
b2internal var m_force:b2Vec2;
b2internal var m_sweep:b2Sweep;
private var m_userData;
b2internal var m_invMass:Number;
b2internal var m_prev:b2Body;
b2internal var m_linearDamping:Number;
b2internal var m_type:int;
b2internal var m_angularDamping:Number;
b2internal var m_islandIndex:int;
b2internal var m_jointList:b2JointEdge;
b2internal var m_sleepTime:Number;
b2internal var m_I:Number;
b2internal static var e_fixedRotationFlag:uint = 16;
public static var b2_kinematicBody:uint = 1;
b2internal static var e_bulletFlag:uint = 8;
b2internal static var e_activeFlag:uint = 32;
b2internal static var e_allowSleepFlag:uint = 4;
b2internal static var e_awakeFlag:uint = 2;
public static var b2_dynamicBody:uint = 2;
b2internal static var e_islandFlag:uint = 1;
private static var s_xf1:b2Transform = new b2Transform();
public static var b2_staticBody:uint = 0;
public function b2Body(bd:b2BodyDef, world:b2World){
m_xf = new b2Transform();
m_sweep = new b2Sweep();
m_linearVelocity = new b2Vec2();
m_force = new b2Vec2();
super();
m_flags = 0;
if (bd.bullet){
m_flags = (m_flags | e_bulletFlag);
};
if (bd.fixedRotation){
m_flags = (m_flags | e_fixedRotationFlag);
};
if (bd.allowSleep){
m_flags = (m_flags | e_allowSleepFlag);
};
if (bd.awake){
m_flags = (m_flags | e_awakeFlag);
};
if (bd.active){
m_flags = (m_flags | e_activeFlag);
};
m_world = world;
m_xf.position.SetV(bd.position);
m_xf.R.Set(bd.angle);
m_sweep.localCenter.SetZero();
m_sweep.t0 = 1;
m_sweep.a0 = (m_sweep.a = bd.angle);
var tMat:b2Mat22 = m_xf.R;
var tVec:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
m_sweep.c.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
m_jointList = null;
m_controllerList = null;
m_contactList = null;
m_controllerCount = 0;
m_prev = null;
m_next = null;
m_linearVelocity.SetV(bd.linearVelocity);
m_angularVelocity = bd.angularVelocity;
m_linearDamping = bd.linearDamping;
m_angularDamping = bd.angularDamping;
m_force.Set(0, 0);
m_torque = 0;
m_sleepTime = 0;
m_type = bd.type;
if (m_type == b2_dynamicBody){
m_mass = 1;
m_invMass = 1;
} else {
m_mass = 0;
m_invMass = 0;
};
m_I = 0;
m_invI = 0;
m_inertiaScale = bd.inertiaScale;
m_userData = bd.userData;
m_fixtureList = null;
m_fixtureCount = 0;
}
public function SetLinearVelocity(v:b2Vec2):void{
if (m_type == b2_staticBody){
return;
};
m_linearVelocity.SetV(v);
}
public function ResetMassData():void{
var massData:b2MassData;
m_mass = 0;
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_sweep.localCenter.SetZero();
if ((((m_type == b2_staticBody)) || ((m_type == b2_kinematicBody)))){
return;
};
var center:b2Vec2 = b2Vec2.Make(0, 0);
var f:b2Fixture = m_fixtureList;
while (f) {
if (f.m_density == 0){
} else {
massData = f.GetMassData();
m_mass = (m_mass + massData.mass);
center.x = (center.x + (massData.center.x * massData.mass));
center.y = (center.y + (massData.center.y * massData.mass));
m_I = (m_I + massData.I);
};
f = f.m_next;
};
if (m_mass > 0){
m_invMass = (1 / m_mass);
center.x = (center.x * m_invMass);
center.y = (center.y * m_invMass);
} else {
m_mass = 1;
m_invMass = 1;
};
if ((((m_I > 0)) && (((m_flags & e_fixedRotationFlag) == 0)))){
m_I = (m_I - (m_mass * ((center.x * center.x) + (center.y * center.y))));
m_I = (m_I * m_inertiaScale);
b2Settings.b2Assert((m_I > 0));
m_invI = (1 / m_I);
} else {
m_I = 0;
m_invI = 0;
};
var oldCenter:b2Vec2 = m_sweep.c.Copy();
m_sweep.localCenter.SetV(center);
m_sweep.c0.SetV(b2Math.MulX(m_xf, m_sweep.localCenter));
m_sweep.c.SetV(m_sweep.c0);
m_linearVelocity.x = (m_linearVelocity.x + (m_angularVelocity * -((m_sweep.c.y - oldCenter.y))));
m_linearVelocity.y = (m_linearVelocity.y + (m_angularVelocity * (m_sweep.c.x - oldCenter.x)));
}
public function GetMassData(data:b2MassData):void{
data.mass = m_mass;
data.I = m_I;
data.center.SetV(m_sweep.localCenter);
}
public function Merge(other:b2Body):void{
var f:b2Fixture;
var body1:b2Body;
var body2:b2Body;
var next:b2Fixture;
f = other.m_fixtureList;
while (f) {
next = f.m_next;
other.m_fixtureCount--;
f.m_next = m_fixtureList;
m_fixtureList = f;
m_fixtureCount++;
f.m_body = body2;
f = next;
};
body1.m_fixtureCount = 0;
body1 = this;
body2 = other;
var center1:b2Vec2 = body1.GetWorldCenter();
var center2:b2Vec2 = body2.GetWorldCenter();
var velocity1:b2Vec2 = body1.GetLinearVelocity().Copy();
var velocity2:b2Vec2 = body2.GetLinearVelocity().Copy();
var angular1:Number = body1.GetAngularVelocity();
var angular:Number = body2.GetAngularVelocity();
body1.ResetMassData();
SynchronizeFixtures();
}
b2internal function SynchronizeTransform():void{
m_xf.R.Set(m_sweep.a);
var tMat:b2Mat22 = m_xf.R;
var tVec:b2Vec2 = m_sweep.localCenter;
m_xf.position.x = (m_sweep.c.x - ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
m_xf.position.y = (m_sweep.c.y - ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
}
public function SetMassData(massData:b2MassData):void{
b2Settings.b2Assert((m_world.IsLocked() == false));
if (m_world.IsLocked() == true){
return;
};
if (m_type != b2_dynamicBody){
return;
};
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_mass = massData.mass;
if (m_mass <= 0){
m_mass = 1;
};
m_invMass = (1 / m_mass);
if ((((massData.I > 0)) && (((m_flags & e_fixedRotationFlag) == 0)))){
m_I = (massData.I - (m_mass * ((massData.center.x * massData.center.x) + (massData.center.y * massData.center.y))));
m_invI = (1 / m_I);
};
var oldCenter:b2Vec2 = m_sweep.c.Copy();
m_sweep.localCenter.SetV(massData.center);
m_sweep.c0.SetV(b2Math.MulX(m_xf, m_sweep.localCenter));
m_sweep.c.SetV(m_sweep.c0);
m_linearVelocity.x = (m_linearVelocity.x + (m_angularVelocity * -((m_sweep.c.y - oldCenter.y))));
m_linearVelocity.y = (m_linearVelocity.y + (m_angularVelocity * (m_sweep.c.x - oldCenter.x)));
}
public function GetDefinition():b2BodyDef{
var bd:b2BodyDef = new b2BodyDef();
bd.type = GetType();
bd.allowSleep = ((m_flags & e_allowSleepFlag) == e_allowSleepFlag);
bd.angle = GetAngle();
bd.angularDamping = m_angularDamping;
bd.angularVelocity = m_angularVelocity;
bd.fixedRotation = ((m_flags & e_fixedRotationFlag) == e_fixedRotationFlag);
bd.bullet = ((m_flags & e_bulletFlag) == e_bulletFlag);
bd.awake = ((m_flags & e_awakeFlag) == e_awakeFlag);
bd.linearDamping = m_linearDamping;
bd.linearVelocity.SetV(GetLinearVelocity());
bd.position = GetPosition();
bd.userData = GetUserData();
return (bd);
}
public function GetControllerList():b2ControllerEdge{
return (m_controllerList);
}
public function GetFixtureList():b2Fixture{
return (m_fixtureList);
}
public function SetAngularVelocity(omega:Number):void{
if (m_type == b2_staticBody){
return;
};
m_angularVelocity = omega;
}
public function GetAngle():Number{
return (m_sweep.a);
}
public function GetLinearVelocityFromLocalPoint(localPoint:b2Vec2):b2Vec2{
var A:b2Mat22 = m_xf.R;
var worldPoint:b2Vec2 = new b2Vec2(((A.col1.x * localPoint.x) + (A.col2.x * localPoint.y)), ((A.col1.y * localPoint.x) + (A.col2.y * localPoint.y)));
worldPoint.x = (worldPoint.x + m_xf.position.x);
worldPoint.y = (worldPoint.y + m_xf.position.y);
return (new b2Vec2((m_linearVelocity.x - (m_angularVelocity * (worldPoint.y - m_sweep.c.y))), (m_linearVelocity.y + (m_angularVelocity * (worldPoint.x - m_sweep.c.x)))));
}
public function GetNext():b2Body{
return (m_next);
}
public function GetMass():Number{
return (m_mass);
}
public function ApplyForce(force:b2Vec2, point:b2Vec2):void{
if (m_type != b2_dynamicBody){
return;
};
if (IsAwake() == false){
SetAwake(true);
};
m_force.x = (m_force.x + force.x);
m_force.y = (m_force.y + force.y);
m_torque = (m_torque + (((point.x - m_sweep.c.x) * force.y) - ((point.y - m_sweep.c.y) * force.x)));
}
public function CreateFixture(def:b2FixtureDef):b2Fixture{
var broadPhase:IBroadPhase;
if (m_world.IsLocked() == true){
return (null);
};
var fixture:b2Fixture = new b2Fixture();
fixture.Create(this, m_xf, def);
if ((m_flags & e_activeFlag)){
broadPhase = m_world.m_contactManager.m_broadPhase;
fixture.CreateProxy(broadPhase, m_xf);
};
fixture.m_next = m_fixtureList;
m_fixtureList = fixture;
m_fixtureCount++;
fixture.m_body = this;
if (fixture.m_density > 0){
ResetMassData();
};
m_world.m_flags = (m_world.m_flags | b2World.e_newFixture);
return (fixture);
}
public function SetTransform(xf:b2Transform):void{
SetPositionAndAngle(xf.position, xf.GetAngle());
}
public function IsAwake():Boolean{
return (((m_flags & e_awakeFlag) == e_awakeFlag));
}
public function GetWorldVector(localVector:b2Vec2):b2Vec2{
return (b2Math.MulMV(m_xf.R, localVector));
}
b2internal function Advance(t:Number):void{
m_sweep.Advance(t);
m_sweep.c.SetV(m_sweep.c0);
m_sweep.a = m_sweep.a0;
SynchronizeTransform();
}
public function SetAwake(flag:Boolean):void{
if (flag){
m_flags = (m_flags | e_awakeFlag);
m_sleepTime = 0;
} else {
m_flags = (m_flags & ~(e_awakeFlag));
m_sleepTime = 0;
m_linearVelocity.SetZero();
m_angularVelocity = 0;
m_force.SetZero();
m_torque = 0;
};
}
public function GetUserData(){
return (m_userData);
}
public function GetWorldCenter():b2Vec2{
return (m_sweep.c);
}
public function SetUserData(data):void{
m_userData = data;
}
public function GetLocalVector(worldVector:b2Vec2):b2Vec2{
return (b2Math.MulTMV(m_xf.R, worldVector));
}
public function GetPosition():b2Vec2{
return (m_xf.position);
}
public function GetLinearVelocityFromWorldPoint(worldPoint:b2Vec2):b2Vec2{
return (new b2Vec2((m_linearVelocity.x - (m_angularVelocity * (worldPoint.y - m_sweep.c.y))), (m_linearVelocity.y + (m_angularVelocity * (worldPoint.x - m_sweep.c.x)))));
}
public function CreateFixture2(shape:b2Shape, density:Number=0):b2Fixture{
var def:b2FixtureDef = new b2FixtureDef();
def.shape = shape;
def.density = density;
return (CreateFixture(def));
}
public function GetLinearDamping():Number{
return (m_linearDamping);
}
public function GetLocalCenter():b2Vec2{
return (m_sweep.localCenter);
}
public function SetPosition(position:b2Vec2):void{
SetPositionAndAngle(position, GetAngle());
}
private function connectEdges(s1:b2EdgeShape, s2:b2EdgeShape, angle1:Number):Number{
var angle2:Number = Math.atan2(s2.GetDirectionVector().y, s2.GetDirectionVector().x);
var coreOffset:Number = Math.tan(((angle2 - angle1) * 0.5));
var core:b2Vec2 = b2Math.MulFV(coreOffset, s2.GetDirectionVector());
core = b2Math.SubtractVV(core, s2.GetNormalVector());
core = b2Math.MulFV(b2Settings.b2_toiSlop, core);
core = b2Math.AddVV(core, s2.GetVertex1());
var cornerDir:b2Vec2 = b2Math.AddVV(s1.GetDirectionVector(), s2.GetDirectionVector());
cornerDir.Normalize();
var convex = (b2Math.Dot(s1.GetDirectionVector(), s2.GetNormalVector()) > 0);
s1.SetNextEdge(s2, core, cornerDir, convex);
s2.SetPrevEdge(s1, core, cornerDir, convex);
return (angle2);
}
public function GetType():uint{
return (m_type);
}
public function GetAngularDamping():Number{
return (m_angularDamping);
}
public function SetType(type:uint):void{
if (m_type == type){
return;
};
m_type = type;
ResetMassData();
if (m_type == b2_staticBody){
m_linearVelocity.SetZero();
m_angularVelocity = 0;
};
SetAwake(true);
m_force.SetZero();
m_torque = 0;
var ce:b2ContactEdge = m_contactList;
while (ce) {
ce.contact.FlagForFiltering();
ce = ce.next;
};
}
public function SetAngularDamping(angularDamping:Number):void{
m_angularDamping = angularDamping;
}
public function GetInertia():Number{
return (m_I);
}
public function SetAngle(angle:Number):void{
SetPositionAndAngle(GetPosition(), angle);
}
public function GetJointList():b2JointEdge{
return (m_jointList);
}
public function GetLocalPoint(worldPoint:b2Vec2):b2Vec2{
return (b2Math.MulXT(m_xf, worldPoint));
}
public function ApplyImpulse(impulse:b2Vec2, point:b2Vec2):void{
if (m_type != b2_dynamicBody){
return;
};
if (IsAwake() == false){
SetAwake(true);
};
m_linearVelocity.x = (m_linearVelocity.x + (m_invMass * impulse.x));
m_linearVelocity.y = (m_linearVelocity.y + (m_invMass * impulse.y));
m_angularVelocity = (m_angularVelocity + (m_invI * (((point.x - m_sweep.c.x) * impulse.y) - ((point.y - m_sweep.c.y) * impulse.x))));
}
public function GetContactList():b2ContactEdge{
return (m_contactList);
}
public function GetAngularVelocity():Number{
return (m_angularVelocity);
}
public function DestroyFixture(fixture:b2Fixture):void{
var c:b2Contact;
var fixtureA:b2Fixture;
var fixtureB:b2Fixture;
var broadPhase:IBroadPhase;
if (m_world.IsLocked() == true){
return;
};
var node:b2Fixture = m_fixtureList;
var ppF:b2Fixture;
var found:Boolean;
while (node != null) {
if (node == fixture){
if (ppF){
ppF.m_next = fixture.m_next;
} else {
m_fixtureList = fixture.m_next;
};
found = true;
break;
};
ppF = node;
node = node.m_next;
};
var edge:b2ContactEdge = m_contactList;
while (edge) {
c = edge.contact;
edge = edge.next;
fixtureA = c.GetFixtureA();
fixtureB = c.GetFixtureB();
if ((((fixture == fixtureA)) || ((fixture == fixtureB)))){
m_world.m_contactManager.Destroy(c);
};
};
if ((m_flags & e_activeFlag)){
broadPhase = m_world.m_contactManager.m_broadPhase;
fixture.DestroyProxy(broadPhase);
};
fixture.Destroy();
fixture.m_body = null;
fixture.m_next = null;
m_fixtureCount--;
ResetMassData();
}
public function IsSleepingAllowed():Boolean{
return (((m_flags & e_allowSleepFlag) == e_allowSleepFlag));
}
public function GetTransform():b2Transform{
return (m_xf);
}
b2internal function SynchronizeFixtures():void{
var f:b2Fixture;
var xf1:b2Transform = s_xf1;
xf1.R.Set(m_sweep.a0);
var tMat:b2Mat22 = xf1.R;
var tVec:b2Vec2 = m_sweep.localCenter;
xf1.position.x = (m_sweep.c0.x - ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
xf1.position.y = (m_sweep.c0.y - ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
var broadPhase:IBroadPhase = m_world.m_contactManager.m_broadPhase;
f = m_fixtureList;
while (f) {
f.Synchronize(broadPhase, xf1, m_xf);
f = f.m_next;
};
}
public function SetSleepingAllowed(flag:Boolean):void{
if (flag){
m_flags = (m_flags | e_allowSleepFlag);
} else {
m_flags = (m_flags & ~(e_allowSleepFlag));
SetAwake(true);
};
}
public function SetBullet(flag:Boolean):void{
if (flag){
m_flags = (m_flags | e_bulletFlag);
} else {
m_flags = (m_flags & ~(e_bulletFlag));
};
}
public function SetPositionAndAngle(position:b2Vec2, angle:Number):void{
var f:b2Fixture;
if (m_world.IsLocked() == true){
return;
};
m_xf.R.Set(angle);
m_xf.position.SetV(position);
var tMat:b2Mat22 = m_xf.R;
var tVec:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
m_sweep.c.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
m_sweep.a0 = (m_sweep.a = angle);
var broadPhase:IBroadPhase = m_world.m_contactManager.m_broadPhase;
f = m_fixtureList;
while (f) {
f.Synchronize(broadPhase, m_xf, m_xf);
f = f.m_next;
};
m_world.m_contactManager.FindNewContacts();
}
public function IsFixedRotation():Boolean{
return (((m_flags & e_fixedRotationFlag) == e_fixedRotationFlag));
}
public function SetActive(flag:Boolean):void{
var broadPhase:IBroadPhase;
var f:b2Fixture;
var ce:b2ContactEdge;
var ce0:b2ContactEdge;
if (flag == IsActive()){
return;
};
if (flag){
m_flags = (m_flags | e_activeFlag);
broadPhase = m_world.m_contactManager.m_broadPhase;
f = m_fixtureList;
while (f) {
f.CreateProxy(broadPhase, m_xf);
f = f.m_next;
};
} else {
m_flags = (m_flags & ~(e_activeFlag));
broadPhase = m_world.m_contactManager.m_broadPhase;
f = m_fixtureList;
while (f) {
f.DestroyProxy(broadPhase);
f = f.m_next;
};
ce = m_contactList;
while (ce) {
ce0 = ce;
ce = ce.next;
m_world.m_contactManager.Destroy(ce0.contact);
};
m_contactList = null;
};
}
public function IsActive():Boolean{
return (((m_flags & e_activeFlag) == e_activeFlag));
}
b2internal function ShouldCollide(other:b2Body):Boolean{
if (((!((m_type == b2_dynamicBody))) && (!((other.m_type == b2_dynamicBody))))){
return (false);
};
var jn:b2JointEdge = m_jointList;
while (jn) {
if (jn.other == other){
if (jn.joint.m_collideConnected == false){
return (false);
};
};
jn = jn.next;
};
return (true);
}
public function IsBullet():Boolean{
return (((m_flags & e_bulletFlag) == e_bulletFlag));
}
public function GetWorldPoint(localPoint:b2Vec2):b2Vec2{
var A:b2Mat22 = m_xf.R;
var u:b2Vec2 = new b2Vec2(((A.col1.x * localPoint.x) + (A.col2.x * localPoint.y)), ((A.col1.y * localPoint.x) + (A.col2.y * localPoint.y)));
u.x = (u.x + m_xf.position.x);
u.y = (u.y + m_xf.position.y);
return (u);
}
public function SetFixedRotation(fixed:Boolean):void{
if (fixed){
m_flags = (m_flags | e_fixedRotationFlag);
} else {
m_flags = (m_flags & ~(e_fixedRotationFlag));
};
ResetMassData();
}
public function GetLinearVelocity():b2Vec2{
return (m_linearVelocity);
}
public function Split(callback:Function):b2Body{
var prev:b2Fixture;
var next:b2Fixture;
var linearVelocity:b2Vec2 = GetLinearVelocity().Copy();
var angularVelocity:Number = GetAngularVelocity();
var center:b2Vec2 = GetWorldCenter();
var body1:b2Body = this;
var body2:b2Body = m_world.CreateBody(GetDefinition());
var f:b2Fixture = body1.m_fixtureList;
while (f) {
if (callback(f)){
next = f.m_next;
if (prev){
prev.m_next = next;
} else {
body1.m_fixtureList = next;
};
body1.m_fixtureCount--;
f.m_next = body2.m_fixtureList;
body2.m_fixtureList = f;
body2.m_fixtureCount++;
f.m_body = body2;
f = next;
} else {
prev = f;
f = f.m_next;
};
};
body1.ResetMassData();
body2.ResetMassData();
var center1:b2Vec2 = body1.GetWorldCenter();
var center2:b2Vec2 = body2.GetWorldCenter();
var velocity1:b2Vec2 = b2Math.AddVV(linearVelocity, b2Math.CrossFV(angularVelocity, b2Math.SubtractVV(center1, center)));
var velocity2:b2Vec2 = b2Math.AddVV(linearVelocity, b2Math.CrossFV(angularVelocity, b2Math.SubtractVV(center2, center)));
body1.SetLinearVelocity(velocity1);
body2.SetLinearVelocity(velocity2);
body1.SetAngularVelocity(angularVelocity);
body2.SetAngularVelocity(angularVelocity);
body1.SynchronizeFixtures();
body2.SynchronizeFixtures();
return (body2);
}
public function SetLinearDamping(linearDamping:Number):void{
m_linearDamping = linearDamping;
}
public function GetWorld():b2World{
return (m_world);
}
public function ApplyTorque(torque:Number):void{
if (m_type != b2_dynamicBody){
return;
};
if (IsAwake() == false){
SetAwake(true);
};
m_torque = (m_torque + torque);
}
}
}//package Box2D.Dynamics
Section 130
//b2BodyDef (Box2D.Dynamics.b2BodyDef)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
public class b2BodyDef {
public var angularDamping:Number;
public var bullet:Boolean;
public var awake:Boolean;
public var active:Boolean;
public var allowSleep:Boolean;
public var angle:Number;
public var userData;
public var fixedRotation:Boolean;
public var linearDamping:Number;
public var angularVelocity:Number;
public var linearVelocity:b2Vec2;
public var position:b2Vec2;
public var inertiaScale:Number;
public var type:uint;
public function b2BodyDef(){
position = new b2Vec2();
linearVelocity = new b2Vec2();
super();
userData = null;
position.Set(0, 0);
angle = 0;
linearVelocity.Set(0, 0);
angularVelocity = 0;
linearDamping = 0;
angularDamping = 0;
allowSleep = true;
awake = true;
fixedRotation = false;
bullet = false;
type = b2Body.b2_staticBody;
active = true;
inertiaScale = 1;
}
}
}//package Box2D.Dynamics
Section 131
//b2ContactFilter (Box2D.Dynamics.b2ContactFilter)
package Box2D.Dynamics {
import Box2D.Common.*;
public class b2ContactFilter {
b2internal static var b2_defaultFilter:b2ContactFilter = new (b2ContactFilter);
;
public function b2ContactFilter(){
super();
}
public function ShouldCollide(fixtureA:b2Fixture, fixtureB:b2Fixture):Boolean{
var filter1:b2FilterData = fixtureA.GetFilterData();
var filter2:b2FilterData = fixtureB.GetFilterData();
if ((((filter1.groupIndex == filter2.groupIndex)) && (!((filter1.groupIndex == 0))))){
return ((filter1.groupIndex > 0));
};
var collide:Boolean = ((!(((filter1.maskBits & filter2.categoryBits) == 0))) && (!(((filter1.categoryBits & filter2.maskBits) == 0))));
return (collide);
}
public function RayCollide(userData, fixture:b2Fixture):Boolean{
if (!userData){
return (true);
};
return (ShouldCollide((userData as b2Fixture), fixture));
}
}
}//package Box2D.Dynamics
Section 132
//b2ContactImpulse (Box2D.Dynamics.b2ContactImpulse)
package Box2D.Dynamics {
import Box2D.Common.*;
public class b2ContactImpulse {
public var tangentImpulses:Array;
public var normalImpulses:Array;
public function b2ContactImpulse(){
normalImpulses = new Array(b2Settings.b2_maxManifoldPoints);
tangentImpulses = new Array(b2Settings.b2_maxManifoldPoints);
super();
}
}
}//package Box2D.Dynamics
Section 133
//b2ContactListener (Box2D.Dynamics.b2ContactListener)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2ContactListener {
b2internal static var b2_defaultListener:b2ContactListener = new (b2ContactListener);
;
public function b2ContactListener(){
super();
}
public function PreSolve(contact:b2Contact, oldManifold:b2Manifold):void{
}
public function EndContact(contact:b2Contact):void{
}
public function PostSolve(contact:b2Contact, impulse:b2ContactImpulse):void{
}
public function BeginContact(contact:b2Contact):void{
}
}
}//package Box2D.Dynamics
Section 134
//b2ContactManager (Box2D.Dynamics.b2ContactManager)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2ContactManager {
b2internal var m_world:b2World;
b2internal var m_contactCount:int;
b2internal var m_contactFactory:b2ContactFactory;
b2internal var m_contactFilter:b2ContactFilter;
b2internal var m_broadPhase:IBroadPhase;
b2internal var m_contactList:b2Contact;
b2internal var m_contactListener:b2ContactListener;
b2internal var m_allocator;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2ContactManager(){
super();
m_world = null;
m_contactCount = 0;
m_contactFilter = b2ContactFilter.b2_defaultFilter;
m_contactListener = b2ContactListener.b2_defaultListener;
m_contactFactory = new b2ContactFactory(m_allocator);
m_broadPhase = new b2DynamicTreeBroadPhase();
}
public function FindNewContacts():void{
m_broadPhase.UpdatePairs(AddPair);
}
public function Destroy(c:b2Contact):void{
var fixtureA:b2Fixture = c.GetFixtureA();
var fixtureB:b2Fixture = c.GetFixtureB();
var bodyA:b2Body = fixtureA.GetBody();
var bodyB:b2Body = fixtureB.GetBody();
if (c.IsTouching()){
m_contactListener.EndContact(c);
};
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.m_nodeA.prev){
c.m_nodeA.prev.next = c.m_nodeA.next;
};
if (c.m_nodeA.next){
c.m_nodeA.next.prev = c.m_nodeA.prev;
};
if (c.m_nodeA == bodyA.m_contactList){
bodyA.m_contactList = c.m_nodeA.next;
};
if (c.m_nodeB.prev){
c.m_nodeB.prev.next = c.m_nodeB.next;
};
if (c.m_nodeB.next){
c.m_nodeB.next.prev = c.m_nodeB.prev;
};
if (c.m_nodeB == bodyB.m_contactList){
bodyB.m_contactList = c.m_nodeB.next;
};
m_contactFactory.Destroy(c);
m_contactCount--;
}
public function AddPair(proxyUserDataA, proxyUserDataB):void{
var fA:b2Fixture;
var fB:b2Fixture;
var fixtureA:b2Fixture = (proxyUserDataA as b2Fixture);
var fixtureB:b2Fixture = (proxyUserDataB as b2Fixture);
var bodyA:b2Body = fixtureA.GetBody();
var bodyB:b2Body = fixtureB.GetBody();
if (bodyA == bodyB){
return;
};
var edge:b2ContactEdge = bodyB.GetContactList();
while (edge) {
if (edge.other == bodyA){
fA = edge.contact.GetFixtureA();
fB = edge.contact.GetFixtureB();
if ((((fA == fixtureA)) && ((fB == fixtureB)))){
return;
};
if ((((fA == fixtureB)) && ((fB == fixtureA)))){
return;
};
};
edge = edge.next;
};
if (bodyB.ShouldCollide(bodyA) == false){
return;
};
if (m_contactFilter.ShouldCollide(fixtureA, fixtureB) == false){
return;
};
var c:b2Contact = m_contactFactory.Create(fixtureA, fixtureB);
fixtureA = c.GetFixtureA();
fixtureB = c.GetFixtureB();
bodyA = fixtureA.m_body;
bodyB = fixtureB.m_body;
c.m_prev = null;
c.m_next = m_world.m_contactList;
if (m_world.m_contactList != null){
m_world.m_contactList.m_prev = c;
};
m_world.m_contactList = c;
c.m_nodeA.contact = c;
c.m_nodeA.other = bodyB;
c.m_nodeA.prev = null;
c.m_nodeA.next = bodyA.m_contactList;
if (bodyA.m_contactList != null){
bodyA.m_contactList.prev = c.m_nodeA;
};
bodyA.m_contactList = c.m_nodeA;
c.m_nodeB.contact = c;
c.m_nodeB.other = bodyA;
c.m_nodeB.prev = null;
c.m_nodeB.next = bodyB.m_contactList;
if (bodyB.m_contactList != null){
bodyB.m_contactList.prev = c.m_nodeB;
};
bodyB.m_contactList = c.m_nodeB;
m_world.m_contactCount++;
}
public function Collide():void{
var fixtureA:b2Fixture;
var fixtureB:b2Fixture;
var bodyA:b2Body;
var bodyB:b2Body;
var proxyA:*;
var proxyB:*;
var overlap:Boolean;
var cNuke:b2Contact;
var c:b2Contact = m_world.m_contactList;
while (c) {
fixtureA = c.GetFixtureA();
fixtureB = c.GetFixtureB();
bodyA = fixtureA.GetBody();
bodyB = fixtureB.GetBody();
if ((((bodyA.IsAwake() == false)) && ((bodyB.IsAwake() == false)))){
c = c.GetNext();
} else {
if ((c.m_flags & b2Contact.e_filterFlag)){
if (bodyB.ShouldCollide(bodyA) == false){
cNuke = c;
c = cNuke.GetNext();
Destroy(cNuke);
continue;
};
if (m_contactFilter.ShouldCollide(fixtureA, fixtureB) == false){
cNuke = c;
c = cNuke.GetNext();
Destroy(cNuke);
continue;
};
c.m_flags = (c.m_flags & ~(b2Contact.e_filterFlag));
};
proxyA = fixtureA.m_proxy;
proxyB = fixtureB.m_proxy;
overlap = m_broadPhase.TestOverlap(proxyA, proxyB);
if (overlap == false){
cNuke = c;
c = cNuke.GetNext();
Destroy(cNuke);
} else {
c.Update(m_contactListener);
c = c.GetNext();
};
};
};
}
}
}//package Box2D.Dynamics
Section 135
//b2DebugDraw (Box2D.Dynamics.b2DebugDraw)
package Box2D.Dynamics {
import flash.display.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2DebugDraw {
private var m_xformScale:Number;// = 1
private var m_fillAlpha:Number;// = 1
private var m_alpha:Number;// = 1
private var m_lineThickness:Number;// = 1
private var m_drawFlags:uint;
b2internal var m_sprite:Sprite;
private var m_drawScale:Number;// = 1
public static var e_centerOfMassBit:uint = 16;
public static var e_shapeBit:uint = 1;
public static var e_aabbBit:uint = 4;
public static var e_controllerBit:uint = 32;
public static var e_pairBit:uint = 8;
public static var e_jointBit:uint = 2;
public function b2DebugDraw(){
super();
m_drawFlags = 0;
}
public function SetDrawScale(drawScale:Number):void{
m_drawScale = drawScale;
}
public function GetFillAlpha():Number{
return (m_fillAlpha);
}
public function GetAlpha():Number{
return (m_alpha);
}
public function GetLineThickness():Number{
return (m_lineThickness);
}
public function GetDrawScale():Number{
return (m_drawScale);
}
public function DrawSolidPolygon(vertices:Array, vertexCount:int, color:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, color.color, m_alpha);
m_sprite.graphics.moveTo((vertices[0].x * m_drawScale), (vertices[0].y * m_drawScale));
m_sprite.graphics.beginFill(color.color, m_fillAlpha);
var i = 1;
while (i < vertexCount) {
m_sprite.graphics.lineTo((vertices[i].x * m_drawScale), (vertices[i].y * m_drawScale));
i++;
};
m_sprite.graphics.lineTo((vertices[0].x * m_drawScale), (vertices[0].y * m_drawScale));
m_sprite.graphics.endFill();
}
public function DrawCircle(center:b2Vec2, radius:Number, color:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, color.color, m_alpha);
m_sprite.graphics.drawCircle((center.x * m_drawScale), (center.y * m_drawScale), (radius * m_drawScale));
}
public function DrawSolidCircle(center:b2Vec2, radius:Number, axis:b2Vec2, color:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, color.color, m_alpha);
m_sprite.graphics.moveTo(0, 0);
m_sprite.graphics.beginFill(color.color, m_fillAlpha);
m_sprite.graphics.drawCircle((center.x * m_drawScale), (center.y * m_drawScale), (radius * m_drawScale));
m_sprite.graphics.endFill();
m_sprite.graphics.moveTo((center.x * m_drawScale), (center.y * m_drawScale));
m_sprite.graphics.lineTo(((center.x + (axis.x * radius)) * m_drawScale), ((center.y + (axis.y * radius)) * m_drawScale));
}
public function ClearFlags(flags:uint):void{
m_drawFlags = (m_drawFlags & ~(flags));
}
public function GetSprite():Sprite{
return (m_sprite);
}
public function GetXFormScale():Number{
return (m_xformScale);
}
public function SetFlags(flags:uint):void{
m_drawFlags = flags;
}
public function SetSprite(sprite:Sprite):void{
m_sprite = sprite;
}
public function DrawTransform(xf:b2Transform):void{
m_sprite.graphics.lineStyle(m_lineThickness, 0xFF0000, m_alpha);
m_sprite.graphics.moveTo((xf.position.x * m_drawScale), (xf.position.y * m_drawScale));
m_sprite.graphics.lineTo(((xf.position.x + (m_xformScale * xf.R.col1.x)) * m_drawScale), ((xf.position.y + (m_xformScale * xf.R.col1.y)) * m_drawScale));
m_sprite.graphics.lineStyle(m_lineThickness, 0xFF00, m_alpha);
m_sprite.graphics.moveTo((xf.position.x * m_drawScale), (xf.position.y * m_drawScale));
m_sprite.graphics.lineTo(((xf.position.x + (m_xformScale * xf.R.col2.x)) * m_drawScale), ((xf.position.y + (m_xformScale * xf.R.col2.y)) * m_drawScale));
}
public function AppendFlags(flags:uint):void{
m_drawFlags = (m_drawFlags | flags);
}
public function DrawSegment(p1:b2Vec2, p2:b2Vec2, color:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, color.color, m_alpha);
m_sprite.graphics.moveTo((p1.x * m_drawScale), (p1.y * m_drawScale));
m_sprite.graphics.lineTo((p2.x * m_drawScale), (p2.y * m_drawScale));
}
public function SetXFormScale(xformScale:Number):void{
m_xformScale = xformScale;
}
public function GetFlags():uint{
return (m_drawFlags);
}
public function DrawPolygon(vertices:Array, vertexCount:int, color:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, color.color, m_alpha);
m_sprite.graphics.moveTo((vertices[0].x * m_drawScale), (vertices[0].y * m_drawScale));
var i = 1;
while (i < vertexCount) {
m_sprite.graphics.lineTo((vertices[i].x * m_drawScale), (vertices[i].y * m_drawScale));
i++;
};
m_sprite.graphics.lineTo((vertices[0].x * m_drawScale), (vertices[0].y * m_drawScale));
}
public function SetFillAlpha(alpha:Number):void{
m_fillAlpha = alpha;
}
public function SetAlpha(alpha:Number):void{
m_alpha = alpha;
}
public function SetLineThickness(lineThickness:Number):void{
m_lineThickness = lineThickness;
}
}
}//package Box2D.Dynamics
Section 136
//b2DestructionListener (Box2D.Dynamics.b2DestructionListener)
package Box2D.Dynamics {
import Box2D.Dynamics.Joints.*;
public class b2DestructionListener {
public function b2DestructionListener(){
super();
}
public function SayGoodbyeFixture(fixture:b2Fixture):void{
}
public function SayGoodbyeJoint(joint:b2Joint):void{
}
}
}//package Box2D.Dynamics
Section 137
//b2FilterData (Box2D.Dynamics.b2FilterData)
package Box2D.Dynamics {
public class b2FilterData {
public var maskBits:uint;// = 0xFFFF
public var groupIndex:int;// = 0
public var categoryBits:uint;// = 1
public function b2FilterData(){
super();
}
public function Copy():b2FilterData{
var copy:b2FilterData = new b2FilterData();
copy.categoryBits = categoryBits;
copy.maskBits = maskBits;
copy.groupIndex = groupIndex;
return (copy);
}
}
}//package Box2D.Dynamics
Section 138
//b2Fixture (Box2D.Dynamics.b2Fixture)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2Fixture {
b2internal var m_next:b2Fixture;
b2internal var m_shape:b2Shape;
b2internal var m_restitution:Number;
b2internal var m_friction:Number;
b2internal var m_proxy;
b2internal var m_filter:b2FilterData;
b2internal var m_density:Number;
private var m_massData:b2MassData;
b2internal var m_isSensor:Boolean;
b2internal var m_userData;
b2internal var m_aabb:b2AABB;
b2internal var m_body:b2Body;
public function b2Fixture(){
m_filter = new b2FilterData();
super();
m_aabb = new b2AABB();
m_userData = null;
m_body = null;
m_next = null;
m_shape = null;
m_density = 0;
m_friction = 0;
m_restitution = 0;
}
public function TestPoint(p:b2Vec2):Boolean{
return (m_shape.TestPoint(m_body.GetTransform(), p));
}
public function SetDensity(density:Number):void{
m_density = density;
}
public function SetRestitution(restitution:Number):void{
m_restitution = restitution;
}
public function GetNext():b2Fixture{
return (m_next);
}
public function GetShape():b2Shape{
return (m_shape);
}
public function GetFriction():Number{
return (m_friction);
}
public function GetDensity():Number{
return (m_density);
}
public function GetMassData(massData:b2MassData=null):b2MassData{
if (massData == null){
massData = new b2MassData();
};
m_shape.ComputeMass(massData, m_density);
return (massData);
}
public function GetAABB():b2AABB{
return (m_aabb);
}
public function GetType():int{
return (m_shape.GetType());
}
public function GetFilterData():b2FilterData{
return (m_filter.Copy());
}
b2internal function Destroy():void{
m_shape = null;
}
public function GetRestitution():Number{
return (m_restitution);
}
public function SetFriction(friction:Number):void{
m_friction = friction;
}
b2internal function Create(body:b2Body, xf:b2Transform, def:b2FixtureDef):void{
m_userData = def.userData;
m_friction = def.friction;
m_restitution = def.restitution;
m_body = body;
m_next = null;
m_filter = def.filter.Copy();
m_isSensor = def.isSensor;
m_shape = def.shape.Copy();
m_density = def.density;
}
public function IsSensor():Boolean{
return (m_isSensor);
}
public function RayCast(output:b2RayCastOutput, input:b2RayCastInput):Boolean{
return (m_shape.RayCast(output, input, m_body.GetTransform()));
}
public function GetUserData(){
return (m_userData);
}
b2internal function Synchronize(broadPhase:IBroadPhase, transform1:b2Transform, transform2:b2Transform):void{
if (!m_proxy){
return;
};
var aabb1:b2AABB = new b2AABB();
var aabb2:b2AABB = new b2AABB();
m_shape.ComputeAABB(aabb1, transform1);
m_shape.ComputeAABB(aabb2, transform2);
m_aabb.Combine(aabb1, aabb2);
var displacement:b2Vec2 = b2Math.SubtractVV(transform2.position, transform1.position);
broadPhase.MoveProxy(m_proxy, m_aabb, displacement);
}
b2internal function CreateProxy(broadPhase:IBroadPhase, xf:b2Transform):void{
m_shape.ComputeAABB(m_aabb, xf);
m_proxy = broadPhase.CreateProxy(m_aabb, this);
}
public function SetFilterData(filter:b2FilterData):void{
var contact:b2Contact;
var fixtureA:b2Fixture;
var fixtureB:b2Fixture;
m_filter = filter.Copy();
if (m_body){
return;
};
var edge:b2ContactEdge = m_body.GetContactList();
while (edge) {
contact = edge.contact;
fixtureA = contact.GetFixtureA();
fixtureB = contact.GetFixtureB();
if ((((fixtureA == this)) || ((fixtureB == this)))){
contact.FlagForFiltering();
};
edge = edge.next;
};
}
b2internal function DestroyProxy(broadPhase:IBroadPhase):void{
if (m_proxy == null){
return;
};
broadPhase.DestroyProxy(m_proxy);
m_proxy = null;
}
public function SetUserData(data):void{
m_userData = data;
}
public function GetBody():b2Body{
return (m_body);
}
public function SetSensor(sensor:Boolean):void{
var contact:b2Contact;
var fixtureA:b2Fixture;
var fixtureB:b2Fixture;
if (m_isSensor == sensor){
return;
};
m_isSensor = sensor;
if (m_body == null){
return;
};
var edge:b2ContactEdge = m_body.GetContactList();
while (edge) {
contact = edge.contact;
fixtureA = contact.GetFixtureA();
fixtureB = contact.GetFixtureB();
if ((((fixtureA == this)) || ((fixtureB == this)))){
contact.SetSensor(((fixtureA.IsSensor()) || (fixtureB.IsSensor())));
};
edge = edge.next;
};
}
}
}//package Box2D.Dynamics
Section 139
//b2FixtureDef (Box2D.Dynamics.b2FixtureDef)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
public class b2FixtureDef {
public var shape:b2Shape;
public var isSensor:Boolean;
public var density:Number;
public var restitution:Number;
public var userData;
public var filter:b2FilterData;
public var friction:Number;
public function b2FixtureDef(){
filter = new b2FilterData();
super();
shape = null;
userData = null;
friction = 0.2;
restitution = 0;
density = 0;
filter.categoryBits = 1;
filter.maskBits = 0xFFFF;
filter.groupIndex = 0;
isSensor = false;
}
}
}//package Box2D.Dynamics
Section 140
//b2Island (Box2D.Dynamics.b2Island)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2Island {
private var m_contactSolver:b2ContactSolver;
private var m_listener:b2ContactListener;
private var m_bodyCapacity:int;
b2internal var m_bodies:Array;
b2internal var m_bodyCount:int;
b2internal var m_jointCapacity:int;
b2internal var m_contactCount:int;
b2internal var m_contacts:Array;
b2internal var m_contactCapacity:int;
b2internal var m_jointCount:int;
private var m_allocator;
b2internal var m_joints:Array;
private static var s_impulse:b2ContactImpulse = new b2ContactImpulse();
public function b2Island(){
super();
m_bodies = new Array();
m_contacts = new Array();
m_joints = new Array();
}
public function AddBody(body:b2Body):void{
body.m_islandIndex = m_bodyCount;
var _local2 = m_bodyCount++;
m_bodies[_local2] = body;
}
public function AddJoint(joint:b2Joint):void{
var _local2 = m_jointCount++;
m_joints[_local2] = joint;
}
public function Report(constraints:Array):void{
var c:b2Contact;
var cc:b2ContactConstraint;
var j:int;
if (m_listener == null){
return;
};
var i:int;
while (i < m_contactCount) {
c = m_contacts[i];
cc = constraints[i];
j = 0;
while (j < cc.pointCount) {
s_impulse.normalImpulses[j] = cc.points[j].normalImpulse;
s_impulse.tangentImpulses[j] = cc.points[j].tangentImpulse;
j++;
};
m_listener.PostSolve(c, s_impulse);
i++;
};
}
public function AddContact(contact:b2Contact):void{
var _local2 = m_contactCount++;
m_contacts[_local2] = contact;
}
public function Solve(step:b2TimeStep, gravity:b2Vec2, allowSleep:Boolean):void{
var i:int;
var j:int;
var b:b2Body;
var joint:b2Joint;
var translationX:Number;
var translationY:Number;
var rotation:Number;
var contactsOkay:Boolean;
var jointsOkay:Boolean;
var jointOkay:Boolean;
var minSleepTime:Number;
var linTolSqr:Number;
var angTolSqr:Number;
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
if (b.GetType() != b2Body.b2_dynamicBody){
} else {
b.m_linearVelocity.x = (b.m_linearVelocity.x + (step.dt * (gravity.x + (b.m_invMass * b.m_force.x))));
b.m_linearVelocity.y = (b.m_linearVelocity.y + (step.dt * (gravity.y + (b.m_invMass * b.m_force.y))));
b.m_angularVelocity = (b.m_angularVelocity + ((step.dt * b.m_invI) * b.m_torque));
b.m_linearVelocity.Multiply(b2Math.Clamp((1 - (step.dt * b.m_linearDamping)), 0, 1));
b.m_angularVelocity = (b.m_angularVelocity * b2Math.Clamp((1 - (step.dt * b.m_angularDamping)), 0, 1));
};
i++;
};
m_contactSolver.Initialize(step, m_contacts, m_contactCount, m_allocator);
var contactSolver:b2ContactSolver = m_contactSolver;
contactSolver.InitVelocityConstraints(step);
i = 0;
while (i < m_jointCount) {
joint = m_joints[i];
joint.InitVelocityConstraints(step);
i++;
};
i = 0;
while (i < step.velocityIterations) {
j = 0;
while (j < m_jointCount) {
joint = m_joints[j];
joint.SolveVelocityConstraints(step);
j++;
};
contactSolver.SolveVelocityConstraints();
i++;
};
i = 0;
while (i < m_jointCount) {
joint = m_joints[i];
joint.FinalizeVelocityConstraints();
i++;
};
contactSolver.FinalizeVelocityConstraints();
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
if (b.GetType() == b2Body.b2_staticBody){
} else {
translationX = (step.dt * b.m_linearVelocity.x);
translationY = (step.dt * b.m_linearVelocity.y);
if (((translationX * translationX) + (translationY * translationY)) > b2Settings.b2_maxTranslationSquared){
b.m_linearVelocity.Normalize();
b.m_linearVelocity.x = (b.m_linearVelocity.x * (b2Settings.b2_maxTranslation * step.inv_dt));
b.m_linearVelocity.y = (b.m_linearVelocity.y * (b2Settings.b2_maxTranslation * step.inv_dt));
};
rotation = (step.dt * b.m_angularVelocity);
if ((rotation * rotation) > b2Settings.b2_maxRotationSquared){
if (b.m_angularVelocity < 0){
b.m_angularVelocity = (-(b2Settings.b2_maxRotation) * step.inv_dt);
} else {
b.m_angularVelocity = (b2Settings.b2_maxRotation * step.inv_dt);
};
};
b.m_sweep.c0.SetV(b.m_sweep.c);
b.m_sweep.a0 = b.m_sweep.a;
b.m_sweep.c.x = (b.m_sweep.c.x + (step.dt * b.m_linearVelocity.x));
b.m_sweep.c.y = (b.m_sweep.c.y + (step.dt * b.m_linearVelocity.y));
b.m_sweep.a = (b.m_sweep.a + (step.dt * b.m_angularVelocity));
b.SynchronizeTransform();
};
i++;
};
i = 0;
while (i < step.positionIterations) {
contactsOkay = contactSolver.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
jointsOkay = true;
j = 0;
while (j < m_jointCount) {
joint = m_joints[j];
jointOkay = joint.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
jointsOkay = ((jointsOkay) && (jointOkay));
j++;
};
if (((contactsOkay) && (jointsOkay))){
break;
};
i++;
};
Report(contactSolver.m_constraints);
if (allowSleep){
minSleepTime = Number.MAX_VALUE;
linTolSqr = (b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance);
angTolSqr = (b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance);
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
if (b.GetType() == b2Body.b2_staticBody){
} 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.Dot(b.m_linearVelocity, b.m_linearVelocity) > linTolSqr)))){
b.m_sleepTime = 0;
minSleepTime = 0;
} else {
b.m_sleepTime = (b.m_sleepTime + step.dt);
minSleepTime = b2Math.Min(minSleepTime, b.m_sleepTime);
};
};
i++;
};
if (minSleepTime >= b2Settings.b2_timeToSleep){
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
b.SetAwake(false);
i++;
};
};
};
}
public function Clear():void{
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
}
public function SolveTOI(subStep:b2TimeStep):void{
var i:int;
var j:int;
var b:b2Body;
var translationX:Number;
var translationY:Number;
var rotation:Number;
var contactsOkay:Boolean;
var jointsOkay:Boolean;
var jointOkay:Boolean;
m_contactSolver.Initialize(subStep, m_contacts, m_contactCount, m_allocator);
var contactSolver:b2ContactSolver = m_contactSolver;
i = 0;
while (i < m_jointCount) {
m_joints[i].InitVelocityConstraints(subStep);
i++;
};
i = 0;
while (i < subStep.velocityIterations) {
contactSolver.SolveVelocityConstraints();
j = 0;
while (j < m_jointCount) {
m_joints[j].SolveVelocityConstraints(subStep);
j++;
};
i++;
};
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
if (b.GetType() == b2Body.b2_staticBody){
} else {
translationX = (subStep.dt * b.m_linearVelocity.x);
translationY = (subStep.dt * b.m_linearVelocity.y);
if (((translationX * translationX) + (translationY * translationY)) > b2Settings.b2_maxTranslationSquared){
b.m_linearVelocity.Normalize();
b.m_linearVelocity.x = (b.m_linearVelocity.x * (b2Settings.b2_maxTranslation * subStep.inv_dt));
b.m_linearVelocity.y = (b.m_linearVelocity.y * (b2Settings.b2_maxTranslation * subStep.inv_dt));
};
rotation = (subStep.dt * b.m_angularVelocity);
if ((rotation * rotation) > b2Settings.b2_maxRotationSquared){
if (b.m_angularVelocity < 0){
b.m_angularVelocity = (-(b2Settings.b2_maxRotation) * subStep.inv_dt);
} else {
b.m_angularVelocity = (b2Settings.b2_maxRotation * subStep.inv_dt);
};
};
b.m_sweep.c0.SetV(b.m_sweep.c);
b.m_sweep.a0 = b.m_sweep.a;
b.m_sweep.c.x = (b.m_sweep.c.x + (subStep.dt * b.m_linearVelocity.x));
b.m_sweep.c.y = (b.m_sweep.c.y + (subStep.dt * b.m_linearVelocity.y));
b.m_sweep.a = (b.m_sweep.a + (subStep.dt * b.m_angularVelocity));
b.SynchronizeTransform();
};
i++;
};
var k_toiBaumgarte:Number = 0.75;
i = 0;
while (i < subStep.positionIterations) {
contactsOkay = contactSolver.SolvePositionConstraints(k_toiBaumgarte);
jointsOkay = true;
j = 0;
while (j < m_jointCount) {
jointOkay = m_joints[j].SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
jointsOkay = ((jointsOkay) && (jointOkay));
j++;
};
if (((contactsOkay) && (jointsOkay))){
break;
};
i++;
};
Report(contactSolver.m_constraints);
}
public function Initialize(bodyCapacity:int, contactCapacity:int, jointCapacity:int, allocator, listener:b2ContactListener, contactSolver:b2ContactSolver):void{
var i:int;
m_bodyCapacity = bodyCapacity;
m_contactCapacity = contactCapacity;
m_jointCapacity = jointCapacity;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_allocator = allocator;
m_listener = listener;
m_contactSolver = contactSolver;
i = m_bodies.length;
while (i < bodyCapacity) {
m_bodies[i] = null;
i++;
};
i = m_contacts.length;
while (i < contactCapacity) {
m_contacts[i] = null;
i++;
};
i = m_joints.length;
while (i < jointCapacity) {
m_joints[i] = null;
i++;
};
}
}
}//package Box2D.Dynamics
Section 141
//b2TimeStep (Box2D.Dynamics.b2TimeStep)
package Box2D.Dynamics {
public class b2TimeStep {
public var warmStarting:Boolean;
public var inv_dt:Number;
public var dt:Number;
public var velocityIterations:int;
public var dtRatio:Number;
public var positionIterations:int;
public function b2TimeStep(){
super();
}
public function Set(step:b2TimeStep):void{
dt = step.dt;
inv_dt = step.inv_dt;
positionIterations = step.positionIterations;
velocityIterations = step.velocityIterations;
warmStarting = step.warmStarting;
}
}
}//package Box2D.Dynamics
Section 142
//b2World (Box2D.Dynamics.b2World)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Controllers.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
public class b2World {
private var m_inv_dt0:Number;
private var m_contactSolver:b2ContactSolver;
private var m_controllerList:b2Controller;
b2internal var m_contactList:b2Contact;
private var m_controllerCount:int;
private var m_allowSleep:Boolean;
private var m_island:b2Island;
b2internal var m_flags:int;
private var m_jointCount:int;
private var m_bodyCount:int;
private var s_stack:Array;
private var m_destructionListener:b2DestructionListener;
b2internal var m_groundBody:b2Body;
b2internal var m_contactCount:int;
private var m_debugDraw:b2DebugDraw;
b2internal var m_bodyList:b2Body;
private var m_jointList:b2Joint;
private var m_gravity:b2Vec2;
b2internal var m_contactManager:b2ContactManager;
public static const e_newFixture:int = 1;
public static const e_locked:int = 2;
private static var s_timestep:b2TimeStep = new b2TimeStep();
private static var s_queue:Array = new Array();
private static var s_timestep2:b2TimeStep = new b2TimeStep();
private static var s_backupA:b2Sweep = new b2Sweep();
private static var m_continuousPhysics:Boolean;
private static var m_warmStarting:Boolean;
private static var s_xf:b2Transform = new b2Transform();
private static var s_backupB:b2Sweep = new b2Sweep();
private static var s_jointColor:b2Color = new b2Color(0.5, 0.8, 0.8);
public function b2World(gravity:b2Vec2, doSleep:Boolean){
s_stack = new Array();
m_contactManager = new b2ContactManager();
m_contactSolver = new b2ContactSolver();
m_island = new b2Island();
super();
m_destructionListener = null;
m_debugDraw = null;
m_bodyList = null;
m_contactList = null;
m_jointList = null;
m_controllerList = null;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_controllerCount = 0;
m_warmStarting = true;
m_continuousPhysics = true;
m_allowSleep = doSleep;
m_gravity = gravity;
m_inv_dt0 = 0;
m_contactManager.m_world = this;
var bd:b2BodyDef = new b2BodyDef();
m_groundBody = CreateBody(bd);
}
b2internal function DrawJoint(joint:b2Joint):void{
var pulley:b2PulleyJoint;
var s1:b2Vec2;
var s2:b2Vec2;
var b1:b2Body = joint.GetBodyA();
var b2:b2Body = joint.GetBodyB();
var xf1:b2Transform = b1.m_xf;
var xf2:b2Transform = b2.m_xf;
var x1:b2Vec2 = xf1.position;
var x2:b2Vec2 = xf2.position;
var p1:b2Vec2 = joint.GetAnchorA();
var p2:b2Vec2 = joint.GetAnchorB();
var color:b2Color = s_jointColor;
switch (joint.m_type){
case b2Joint.e_distanceJoint:
m_debugDraw.DrawSegment(p1, p2, color);
break;
case b2Joint.e_pulleyJoint:
pulley = (joint as b2PulleyJoint);
s1 = pulley.GetGroundAnchorA();
s2 = pulley.GetGroundAnchorB();
m_debugDraw.DrawSegment(s1, p1, color);
m_debugDraw.DrawSegment(s2, p2, color);
m_debugDraw.DrawSegment(s1, s2, color);
break;
case b2Joint.e_mouseJoint:
m_debugDraw.DrawSegment(p1, p2, color);
break;
default:
if (b1 != m_groundBody){
m_debugDraw.DrawSegment(x1, p1, color);
};
m_debugDraw.DrawSegment(p1, p2, color);
if (b2 != m_groundBody){
m_debugDraw.DrawSegment(x2, p2, color);
};
};
}
public function RayCastAll(point1:b2Vec2, point2:b2Vec2):Array{
var result:Array;
var RayCastAllWrapper:Function;
var point1 = point1;
var point2 = point2;
RayCastAllWrapper = function (fixture:b2Fixture, point:b2Vec2, normal:b2Vec2, fraction:Number):Number{
result[result.length] = fixture;
return (1);
};
result = new Array();
RayCast(RayCastAllWrapper, point1, point2);
return (result);
}
public function QueryAABB(callback:Function, aabb:b2AABB):void{
var broadPhase:IBroadPhase;
var WorldQueryWrapper:Function;
var callback = callback;
var aabb = aabb;
WorldQueryWrapper = function (proxy):Boolean{
return (callback(broadPhase.GetUserData(proxy)));
};
broadPhase = m_contactManager.m_broadPhase;
broadPhase.Query(WorldQueryWrapper, aabb);
}
public function GetJointCount():int{
return (m_jointCount);
}
public function SetDebugDraw(debugDraw:b2DebugDraw):void{
m_debugDraw = debugDraw;
}
public function SetContinuousPhysics(flag:Boolean):void{
m_continuousPhysics = flag;
}
public function GetProxyCount():int{
return (m_contactManager.m_broadPhase.GetProxyCount());
}
public function DrawDebugData():void{
var i:int;
var b:b2Body;
var f:b2Fixture;
var s:b2Shape;
var j:b2Joint;
var bp:IBroadPhase;
var xf:b2Transform;
var c:b2Controller;
var contact:b2Contact;
var fixtureA:b2Fixture;
var fixtureB:b2Fixture;
var cA:b2Vec2;
var cB:b2Vec2;
var aabb:b2AABB;
if (m_debugDraw == null){
return;
};
m_debugDraw.m_sprite.graphics.clear();
var flags:uint = m_debugDraw.GetFlags();
var invQ:b2Vec2 = new b2Vec2();
var x1:b2Vec2 = new b2Vec2();
var x2:b2Vec2 = new b2Vec2();
var b1:b2AABB = new b2AABB();
var b2:b2AABB = new b2AABB();
var vs:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()];
var color:b2Color = new b2Color(0, 0, 0);
if ((flags & b2DebugDraw.e_shapeBit)){
b = m_bodyList;
while (b) {
xf = b.m_xf;
f = b.GetFixtureList();
while (f) {
s = f.GetShape();
if (b.IsActive() == false){
color.Set(0.5, 0.5, 0.3);
DrawShape(s, xf, color);
} else {
if (b.GetType() == b2Body.b2_staticBody){
color.Set(0.5, 0.9, 0.5);
DrawShape(s, xf, color);
} else {
if (b.GetType() == b2Body.b2_kinematicBody){
color.Set(0.5, 0.5, 0.9);
DrawShape(s, xf, color);
} else {
if (b.IsAwake() == false){
color.Set(0.6, 0.6, 0.6);
DrawShape(s, xf, color);
} else {
color.Set(0.9, 0.7, 0.7);
DrawShape(s, xf, color);
};
};
};
};
f = f.m_next;
};
b = b.m_next;
};
};
if ((flags & b2DebugDraw.e_jointBit)){
j = m_jointList;
while (j) {
DrawJoint(j);
j = j.m_next;
};
};
if ((flags & b2DebugDraw.e_controllerBit)){
c = m_controllerList;
while (c) {
c.Draw(m_debugDraw);
c = c.m_next;
};
};
if ((flags & b2DebugDraw.e_pairBit)){
color.Set(0.3, 0.9, 0.9);
contact = m_contactManager.m_contactList;
while (contact) {
fixtureA = contact.GetFixtureA();
fixtureB = contact.GetFixtureB();
cA = fixtureA.GetAABB().GetCenter();
cB = fixtureB.GetAABB().GetCenter();
m_debugDraw.DrawSegment(cA, cB, color);
contact = contact.GetNext();
};
};
if ((flags & b2DebugDraw.e_aabbBit)){
bp = m_contactManager.m_broadPhase;
vs = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()];
b = m_bodyList;
while (b) {
if (b.IsActive() == false){
} else {
f = b.GetFixtureList();
while (f) {
aabb = bp.GetFatAABB(f.m_proxy);
vs[0].Set(aabb.lowerBound.x, aabb.lowerBound.y);
vs[1].Set(aabb.upperBound.x, aabb.lowerBound.y);
vs[2].Set(aabb.upperBound.x, aabb.upperBound.y);
vs[3].Set(aabb.lowerBound.x, aabb.upperBound.y);
m_debugDraw.DrawPolygon(vs, 4, color);
f = f.GetNext();
};
};
b = b.GetNext();
};
};
if ((flags & b2DebugDraw.e_centerOfMassBit)){
b = m_bodyList;
while (b) {
xf = s_xf;
xf.R = b.m_xf.R;
xf.position = b.GetWorldCenter();
m_debugDraw.DrawTransform(xf);
b = b.m_next;
};
};
}
public function DestroyBody(b:b2Body):void{
var jn0:b2JointEdge;
var coe0:b2ControllerEdge;
var ce0:b2ContactEdge;
var f0:b2Fixture;
if (IsLocked() == true){
return;
};
var jn:b2JointEdge = b.m_jointList;
while (jn) {
jn0 = jn;
jn = jn.next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeJoint(jn0.joint);
};
DestroyJoint(jn0.joint);
};
var coe:b2ControllerEdge = b.m_controllerList;
while (coe) {
coe0 = coe;
coe = coe.nextController;
coe0.controller.RemoveBody(b);
};
var ce:b2ContactEdge = b.m_contactList;
while (ce) {
ce0 = ce;
ce = ce.next;
m_contactManager.Destroy(ce0.contact);
};
b.m_contactList = null;
var f:b2Fixture = b.m_fixtureList;
while (f) {
f0 = f;
f = f.m_next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeFixture(f0);
};
f0.DestroyProxy(m_contactManager.m_broadPhase);
f0.Destroy();
};
b.m_fixtureList = null;
b.m_fixtureCount = 0;
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;
};
m_bodyCount--;
}
b2internal function DrawShape(shape:b2Shape, xf:b2Transform, color:b2Color):void{
var circle:b2CircleShape;
var center:b2Vec2;
var radius:Number;
var axis:b2Vec2;
var i:int;
var poly:b2PolygonShape;
var vertexCount:int;
var localVertices:Array;
var vertices:Array;
var edge:b2EdgeShape;
switch (shape.m_type){
case b2Shape.e_circleShape:
circle = (shape as b2CircleShape);
center = b2Math.MulX(xf, circle.m_p);
radius = circle.m_radius;
axis = xf.R.col1;
m_debugDraw.DrawSolidCircle(center, radius, axis, color);
break;
case b2Shape.e_polygonShape:
poly = (shape as b2PolygonShape);
vertexCount = poly.GetVertexCount();
localVertices = poly.GetVertices();
vertices = new Array(vertexCount);
i = 0;
while (i < vertexCount) {
vertices[i] = b2Math.MulX(xf, localVertices[i]);
i++;
};
m_debugDraw.DrawSolidPolygon(vertices, vertexCount, color);
break;
case b2Shape.e_edgeShape:
edge = (shape as b2EdgeShape);
m_debugDraw.DrawSegment(b2Math.MulX(xf, edge.GetVertex1()), b2Math.MulX(xf, edge.GetVertex2()), color);
break;
};
}
public function GetGroundBody():b2Body{
return (m_groundBody);
}
public function DestroyController(controller:b2Controller):void{
controller.Clear();
if (controller.m_next){
controller.m_next.m_prev = controller.m_prev;
};
if (controller.m_prev){
controller.m_prev.m_next = controller.m_next;
};
if (controller == m_controllerList){
m_controllerList = controller.m_next;
};
m_controllerCount--;
}
b2internal function Solve(step:b2TimeStep):void{
var b:b2Body;
var stackCount:int;
var i:int;
var other:b2Body;
var ce:b2ContactEdge;
var jn:b2JointEdge;
var controller:b2Controller = m_controllerList;
while (controller) {
controller.Step(step);
controller = controller.m_next;
};
var island:b2Island = m_island;
island.Initialize(m_bodyCount, m_contactCount, m_jointCount, null, m_contactManager.m_contactListener, m_contactSolver);
b = m_bodyList;
while (b) {
b.m_flags = (b.m_flags & ~(b2Body.e_islandFlag));
b = b.m_next;
};
var c:b2Contact = m_contactList;
while (c) {
c.m_flags = (c.m_flags & ~(b2Contact.e_islandFlag));
c = c.m_next;
};
var j:b2Joint = m_jointList;
while (j) {
j.m_islandFlag = false;
j = j.m_next;
};
var stackSize:int = m_bodyCount;
var stack:Array = s_stack;
var seed:b2Body = m_bodyList;
while (seed) {
if ((seed.m_flags & b2Body.e_islandFlag)){
} else {
if ((((seed.IsAwake() == false)) || ((seed.IsActive() == false)))){
} else {
if (seed.GetType() == b2Body.b2_staticBody){
} else {
island.Clear();
stackCount = 0;
var _temp1 = stackCount;
stackCount = (stackCount + 1);
var _local15 = _temp1;
stack[_local15] = seed;
seed.m_flags = (seed.m_flags | b2Body.e_islandFlag);
while (stackCount > 0) {
--stackCount;
b = stack[stackCount];
island.AddBody(b);
if (b.IsAwake() == false){
b.SetAwake(true);
};
if (b.GetType() == b2Body.b2_staticBody){
} else {
ce = b.m_contactList;
while (ce) {
if ((ce.contact.m_flags & b2Contact.e_islandFlag)){
} else {
if ((((((ce.contact.IsSensor() == true)) || ((ce.contact.IsEnabled() == false)))) || ((ce.contact.IsTouching() == false)))){
} else {
island.AddContact(ce.contact);
ce.contact.m_flags = (ce.contact.m_flags | b2Contact.e_islandFlag);
other = ce.other;
if ((other.m_flags & b2Body.e_islandFlag)){
} else {
var _temp2 = stackCount;
stackCount = (stackCount + 1);
var _local16 = _temp2;
stack[_local16] = other;
other.m_flags = (other.m_flags | b2Body.e_islandFlag);
};
};
};
ce = ce.next;
};
jn = b.m_jointList;
while (jn) {
if (jn.joint.m_islandFlag == true){
} else {
other = jn.other;
if (other.IsActive() == false){
} else {
island.AddJoint(jn.joint);
jn.joint.m_islandFlag = true;
if ((other.m_flags & b2Body.e_islandFlag)){
} else {
var _temp3 = stackCount;
stackCount = (stackCount + 1);
_local16 = _temp3;
stack[_local16] = other;
other.m_flags = (other.m_flags | b2Body.e_islandFlag);
};
};
};
jn = jn.next;
};
};
};
island.Solve(step, m_gravity, m_allowSleep);
i = 0;
while (i < island.m_bodyCount) {
b = island.m_bodies[i];
if (b.GetType() == b2Body.b2_staticBody){
b.m_flags = (b.m_flags & ~(b2Body.e_islandFlag));
};
i++;
};
};
};
};
seed = seed.m_next;
};
i = 0;
while (i < stack.length) {
if (!stack[i]){
break;
};
stack[i] = null;
i++;
};
b = m_bodyList;
while (b) {
if ((((b.IsAwake() == false)) || ((b.IsActive() == false)))){
} else {
if (b.GetType() == b2Body.b2_staticBody){
} else {
b.SynchronizeFixtures();
};
};
b = b.m_next;
};
m_contactManager.FindNewContacts();
}
public function SetGravity(gravity:b2Vec2):void{
m_gravity = gravity;
}
public function SetContactFilter(filter:b2ContactFilter):void{
m_contactManager.m_contactFilter = filter;
}
b2internal function SolveTOI(step:b2TimeStep):void{
var b:b2Body;
var fA:b2Fixture;
var fB:b2Fixture;
var bA:b2Body;
var bB:b2Body;
var cEdge:b2ContactEdge;
var j:b2Joint;
var c:b2Contact;
var minContact:b2Contact;
var minTOI:Number;
var seed:b2Body;
var queueStart:int;
var queueSize:int;
var subStep:b2TimeStep;
var i:int;
var toi:Number;
var t0:Number;
var jEdge:b2JointEdge;
var other:b2Body;
var island:b2Island = m_island;
island.Initialize(m_bodyCount, b2Settings.b2_maxTOIContactsPerIsland, b2Settings.b2_maxTOIJointsPerIsland, null, m_contactManager.m_contactListener, m_contactSolver);
var queue:Array = s_queue;
b = m_bodyList;
while (b) {
b.m_flags = (b.m_flags & ~(b2Body.e_islandFlag));
b.m_sweep.t0 = 0;
b = b.m_next;
};
c = m_contactList;
while (c) {
c.m_flags = (c.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
c = c.m_next;
};
j = m_jointList;
while (j) {
j.m_islandFlag = false;
j = j.m_next;
};
while (true) {
minContact = null;
minTOI = 1;
c = m_contactList;
for (;c;(c = c.m_next)) {
if ((((((c.IsSensor() == true)) || ((c.IsEnabled() == false)))) || ((c.IsContinuous() == false)))){
} else {
toi = 1;
if ((c.m_flags & b2Contact.e_toiFlag)){
toi = c.m_toi;
} else {
fA = c.m_fixtureA;
fB = c.m_fixtureB;
bA = fA.m_body;
bB = fB.m_body;
if (((((!((bA.GetType() == b2Body.b2_dynamicBody))) || ((bA.IsAwake() == false)))) && (((!((bB.GetType() == b2Body.b2_dynamicBody))) || ((bB.IsAwake() == false)))))){
continue;
};
t0 = bA.m_sweep.t0;
if (bA.m_sweep.t0 < bB.m_sweep.t0){
t0 = bB.m_sweep.t0;
bA.m_sweep.Advance(t0);
} else {
if (bB.m_sweep.t0 < bA.m_sweep.t0){
t0 = bA.m_sweep.t0;
bB.m_sweep.Advance(t0);
};
};
toi = c.ComputeTOI(bA.m_sweep, bB.m_sweep);
b2Settings.b2Assert((((0 <= toi)) && ((toi <= 1))));
if ((((toi > 0)) && ((toi < 1)))){
toi = (((1 - toi) * t0) + toi);
if (toi > 1){
toi = 1;
};
};
c.m_toi = toi;
c.m_flags = (c.m_flags | b2Contact.e_toiFlag);
};
if ((((Number.MIN_VALUE < toi)) && ((toi < minTOI)))){
minContact = c;
minTOI = toi;
};
};
};
if ((((minContact == null)) || (((1 - (100 * Number.MIN_VALUE)) < minTOI)))){
break;
};
fA = minContact.m_fixtureA;
fB = minContact.m_fixtureB;
bA = fA.m_body;
bB = fB.m_body;
s_backupA.Set(bA.m_sweep);
s_backupB.Set(bB.m_sweep);
bA.Advance(minTOI);
bB.Advance(minTOI);
minContact.Update(m_contactManager.m_contactListener);
minContact.m_flags = (minContact.m_flags & ~(b2Contact.e_toiFlag));
if ((((minContact.IsSensor() == true)) || ((minContact.IsEnabled() == false)))){
bA.m_sweep.Set(s_backupA);
bB.m_sweep.Set(s_backupB);
bA.SynchronizeTransform();
bB.SynchronizeTransform();
} else {
if (minContact.IsTouching() == false){
} else {
seed = bA;
if (seed.GetType() != b2Body.b2_dynamicBody){
seed = bB;
};
island.Clear();
queueStart = 0;
queueSize = 0;
var _temp1 = queueSize;
queueSize = (queueSize + 1);
queue[(queueStart + _temp1)] = seed;
seed.m_flags = (seed.m_flags | b2Body.e_islandFlag);
while (queueSize > 0) {
var _temp2 = queueStart;
queueStart = (queueStart + 1);
b = queue[_temp2];
queueSize--;
island.AddBody(b);
if (b.IsAwake() == false){
b.SetAwake(true);
};
if (b.GetType() != b2Body.b2_dynamicBody){
} else {
cEdge = b.m_contactList;
while (cEdge) {
if (island.m_contactCount == island.m_contactCapacity){
break;
};
if ((cEdge.contact.m_flags & b2Contact.e_islandFlag)){
} else {
if ((((((cEdge.contact.IsSensor() == true)) || ((cEdge.contact.IsEnabled() == false)))) || ((cEdge.contact.IsTouching() == false)))){
} else {
island.AddContact(cEdge.contact);
cEdge.contact.m_flags = (cEdge.contact.m_flags | b2Contact.e_islandFlag);
other = cEdge.other;
if ((other.m_flags & b2Body.e_islandFlag)){
} else {
if (other.GetType() != b2Body.b2_staticBody){
other.Advance(minTOI);
other.SetAwake(true);
};
queue[(queueStart + queueSize)] = other;
queueSize++;
other.m_flags = (other.m_flags | b2Body.e_islandFlag);
};
};
};
cEdge = cEdge.next;
};
jEdge = b.m_jointList;
while (jEdge) {
if (island.m_jointCount == island.m_jointCapacity){
} else {
if (jEdge.joint.m_islandFlag == true){
} else {
other = jEdge.other;
if (other.IsActive() == false){
} else {
island.AddJoint(jEdge.joint);
jEdge.joint.m_islandFlag = true;
if ((other.m_flags & b2Body.e_islandFlag)){
} else {
if (other.GetType() != b2Body.b2_staticBody){
other.Advance(minTOI);
other.SetAwake(true);
};
queue[(queueStart + queueSize)] = other;
queueSize++;
other.m_flags = (other.m_flags | b2Body.e_islandFlag);
};
};
};
};
jEdge = jEdge.next;
};
};
};
subStep = s_timestep;
subStep.warmStarting = false;
subStep.dt = ((1 - minTOI) * step.dt);
subStep.inv_dt = (1 / subStep.dt);
subStep.dtRatio = 0;
subStep.velocityIterations = step.velocityIterations;
subStep.positionIterations = step.positionIterations;
island.SolveTOI(subStep);
i = 0;
while (i < island.m_bodyCount) {
b = island.m_bodies[i];
b.m_flags = (b.m_flags & ~(b2Body.e_islandFlag));
if (b.IsAwake() == false){
} else {
if (b.GetType() != b2Body.b2_dynamicBody){
} else {
b.SynchronizeFixtures();
cEdge = b.m_contactList;
while (cEdge) {
cEdge.contact.m_flags = (cEdge.contact.m_flags & ~(b2Contact.e_toiFlag));
cEdge = cEdge.next;
};
};
};
i++;
};
i = 0;
while (i < island.m_contactCount) {
c = island.m_contacts[i];
c.m_flags = (c.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
i++;
};
i = 0;
while (i < island.m_jointCount) {
j = island.m_joints[i];
j.m_islandFlag = false;
i++;
};
m_contactManager.FindNewContacts();
};
};
};
}
public function GetJointList():b2Joint{
return (m_jointList);
}
public function GetContactCount():int{
return (m_contactCount);
}
public function GetBodyList():b2Body{
return (m_bodyList);
}
public function GetGravity():b2Vec2{
return (m_gravity);
}
public function RayCastOne(point1:b2Vec2, point2:b2Vec2):b2Fixture{
var result:b2Fixture;
var RayCastOneWrapper:Function;
var point1 = point1;
var point2 = point2;
RayCastOneWrapper = function (fixture:b2Fixture, point:b2Vec2, normal:b2Vec2, fraction:Number):Number{
result = fixture;
return (fraction);
};
RayCast(RayCastOneWrapper, point1, point2);
return (result);
}
public function Validate():void{
m_contactManager.m_broadPhase.Validate();
}
public function SetWarmStarting(flag:Boolean):void{
m_warmStarting = flag;
}
public function QueryPoint(callback:Function, p:b2Vec2):void{
var broadPhase:IBroadPhase;
var WorldQueryWrapper:Function;
var callback = callback;
var p = p;
WorldQueryWrapper = function (proxy):Boolean{
var fixture:b2Fixture = (broadPhase.GetUserData(proxy) as b2Fixture);
if (fixture.TestPoint(p)){
return (callback(fixture));
};
return (true);
};
broadPhase = m_contactManager.m_broadPhase;
var aabb:b2AABB = new b2AABB();
aabb.lowerBound.Set((p.x - b2Settings.b2_linearSlop), (p.y - b2Settings.b2_linearSlop));
aabb.upperBound.Set((p.x + b2Settings.b2_linearSlop), (p.y + b2Settings.b2_linearSlop));
broadPhase.Query(WorldQueryWrapper, aabb);
}
public function CreateJoint(def:b2JointDef):b2Joint{
var edge:b2ContactEdge;
var j:b2Joint = b2Joint.Create(def, null);
j.m_prev = null;
j.m_next = m_jointList;
if (m_jointList){
m_jointList.m_prev = j;
};
m_jointList = j;
m_jointCount++;
j.m_edgeA.joint = j;
j.m_edgeA.other = j.m_bodyB;
j.m_edgeA.prev = null;
j.m_edgeA.next = j.m_bodyA.m_jointList;
if (j.m_bodyA.m_jointList){
j.m_bodyA.m_jointList.prev = j.m_edgeA;
};
j.m_bodyA.m_jointList = j.m_edgeA;
j.m_edgeB.joint = j;
j.m_edgeB.other = j.m_bodyA;
j.m_edgeB.prev = null;
j.m_edgeB.next = j.m_bodyB.m_jointList;
if (j.m_bodyB.m_jointList){
j.m_bodyB.m_jointList.prev = j.m_edgeB;
};
j.m_bodyB.m_jointList = j.m_edgeB;
var bodyA:b2Body = def.bodyA;
var bodyB:b2Body = def.bodyB;
if (def.collideConnected == false){
edge = bodyB.GetContactList();
while (edge) {
if (edge.other == bodyA){
edge.contact.FlagForFiltering();
};
edge = edge.next;
};
};
return (j);
}
public function GetContactList():b2Contact{
return (m_contactList);
}
public function DestroyJoint(j:b2Joint):void{
var edge:b2ContactEdge;
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 bodyA:b2Body = j.m_bodyA;
var bodyB:b2Body = j.m_bodyB;
bodyA.SetAwake(true);
bodyB.SetAwake(true);
if (j.m_edgeA.prev){
j.m_edgeA.prev.next = j.m_edgeA.next;
};
if (j.m_edgeA.next){
j.m_edgeA.next.prev = j.m_edgeA.prev;
};
if (j.m_edgeA == bodyA.m_jointList){
bodyA.m_jointList = j.m_edgeA.next;
};
j.m_edgeA.prev = null;
j.m_edgeA.next = null;
if (j.m_edgeB.prev){
j.m_edgeB.prev.next = j.m_edgeB.next;
};
if (j.m_edgeB.next){
j.m_edgeB.next.prev = j.m_edgeB.prev;
};
if (j.m_edgeB == bodyB.m_jointList){
bodyB.m_jointList = j.m_edgeB.next;
};
j.m_edgeB.prev = null;
j.m_edgeB.next = null;
b2Joint.Destroy(j, null);
m_jointCount--;
if (collideConnected == false){
edge = bodyB.GetContactList();
while (edge) {
if (edge.other == bodyA){
edge.contact.FlagForFiltering();
};
edge = edge.next;
};
};
}
public function SetContactListener(listener:b2ContactListener):void{
m_contactManager.m_contactListener = listener;
}
public function CreateController(controller:b2Controller):b2Controller{
if (controller.m_world != this){
throw (new Error("Controller can only be a member of one world"));
};
controller.m_next = m_controllerList;
controller.m_prev = null;
if (m_controllerList){
m_controllerList.m_prev = controller;
};
m_controllerList = controller;
m_controllerCount++;
controller.m_world = this;
return (controller);
}
public function QueryShape(callback:Function, shape:b2Shape, transform:b2Transform=null):void{
var broadPhase:IBroadPhase;
var WorldQueryWrapper:Function;
var callback = callback;
var shape = shape;
var transform = transform;
WorldQueryWrapper = function (proxy):Boolean{
var fixture:b2Fixture = (broadPhase.GetUserData(proxy) as b2Fixture);
if (b2Shape.TestOverlap(shape, transform, fixture.GetShape(), fixture.GetBody().GetTransform())){
return (callback(fixture));
};
return (true);
};
if (transform == null){
transform = new b2Transform();
transform.SetIdentity();
};
broadPhase = m_contactManager.m_broadPhase;
var aabb:b2AABB = new b2AABB();
shape.ComputeAABB(aabb, transform);
broadPhase.Query(WorldQueryWrapper, aabb);
}
public function CreateBody(def:b2BodyDef):b2Body{
if (IsLocked() == true){
return (null);
};
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 RemoveController(c:b2Controller):void{
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 (m_controllerList == c){
m_controllerList = c.m_next;
};
m_controllerCount--;
}
public function SetDestructionListener(listener:b2DestructionListener):void{
m_destructionListener = listener;
}
public function RayCast(callback:Function, point1:b2Vec2, point2:b2Vec2):void{
var broadPhase:IBroadPhase;
var output:b2RayCastOutput;
var RayCastWrapper:Function;
var callback = callback;
var point1 = point1;
var point2 = point2;
RayCastWrapper = function (input:b2RayCastInput, proxy):Number{
var fraction:Number;
var point:b2Vec2;
var userData:* = broadPhase.GetUserData(proxy);
var fixture:b2Fixture = (userData as b2Fixture);
var hit:Boolean = fixture.RayCast(output, input);
if (hit){
fraction = output.fraction;
point = new b2Vec2((((1 - fraction) * point1.x) + (fraction * point2.x)), (((1 - fraction) * point1.y) + (fraction * point2.y)));
return (callback(fixture, point, output.normal, fraction));
};
return (input.maxFraction);
};
broadPhase = m_contactManager.m_broadPhase;
output = new b2RayCastOutput();
var input:b2RayCastInput = new b2RayCastInput(point1, point2);
broadPhase.RayCast(RayCastWrapper, input);
}
public function Step(dt:Number, velocityIterations:int, positionIterations:int):void{
if ((m_flags & e_newFixture)){
m_contactManager.FindNewContacts();
m_flags = (m_flags & ~(e_newFixture));
};
m_flags = (m_flags | e_locked);
var step:b2TimeStep = s_timestep2;
step.dt = dt;
step.velocityIterations = velocityIterations;
step.positionIterations = positionIterations;
if (dt > 0){
step.inv_dt = (1 / dt);
} else {
step.inv_dt = 0;
};
step.dtRatio = (m_inv_dt0 * dt);
step.warmStarting = m_warmStarting;
m_contactManager.Collide();
if (step.dt > 0){
Solve(step);
};
if (((m_continuousPhysics) && ((step.dt > 0)))){
SolveTOI(step);
};
if (step.dt > 0){
m_inv_dt0 = step.inv_dt;
};
m_flags = (m_flags & ~(e_locked));
}
public function IsLocked():Boolean{
return (((m_flags & e_locked) > 0));
}
public function ClearForces():void{
var body:b2Body = m_bodyList;
while (body) {
body.m_force.SetZero();
body.m_torque = 0;
body = body.m_next;
};
}
public function GetBodyCount():int{
return (m_bodyCount);
}
public function SetBroadPhase(broadPhase:IBroadPhase):void{
var f:b2Fixture;
var oldBroadPhase:IBroadPhase = m_contactManager.m_broadPhase;
m_contactManager.m_broadPhase = broadPhase;
var b:b2Body = m_bodyList;
while (b) {
f = b.m_fixtureList;
while (f) {
f.m_proxy = broadPhase.CreateProxy(oldBroadPhase.GetFatAABB(f.m_proxy), f);
f = f.m_next;
};
b = b.m_next;
};
}
public function AddController(c:b2Controller):b2Controller{
c.m_next = m_controllerList;
c.m_prev = null;
m_controllerList = c;
c.m_world = this;
m_controllerCount++;
return (c);
}
}
}//package Box2D.Dynamics
Section 143
//CampaignInfo (com.google.analytics.campaign.CampaignInfo)
package com.google.analytics.campaign {
import com.google.analytics.utils.*;
public class CampaignInfo {
private var _new:Boolean;
private var _empty:Boolean;
public function CampaignInfo(empty:Boolean=true, newCampaign:Boolean=false){
super();
_empty = empty;
_new = newCampaign;
}
public function toURLString():String{
var v:Variables = toVariables();
return (v.toString());
}
public function isNew():Boolean{
return (_new);
}
public function get utmcn():String{
return ("1");
}
public function isEmpty():Boolean{
return (_empty);
}
public function toVariables():Variables{
var variables:Variables = new Variables();
variables.URIencode = true;
if (((!(isEmpty())) && (isNew()))){
variables.utmcn = utmcn;
};
if (((!(isEmpty())) && (!(isNew())))){
variables.utmcr = utmcr;
};
return (variables);
}
public function get utmcr():String{
return ("1");
}
}
}//package com.google.analytics.campaign
Section 144
//CampaignKey (com.google.analytics.campaign.CampaignKey)
package com.google.analytics.campaign {
public class CampaignKey {
public var UCMD:String;// = "utm_medium"
public var UCID:String;// = "utm_id"
public var UCTR:String;// = "utm_term"
public var UCSR:String;// = "utm_source"
public var UCNO:String;// = "utm_nooverride"
public var UCCN:String;// = "utm_campaign"
public var UGCLID:String;// = "gclid"
public var UCCT:String;// = "utm_content"
public function CampaignKey(){
super();
}
}
}//package com.google.analytics.campaign
Section 145
//CampaignManager (com.google.analytics.campaign.CampaignManager)
package com.google.analytics.campaign {
import com.google.analytics.core.*;
import com.google.analytics.v4.*;
import com.google.analytics.debug.*;
import com.google.analytics.utils.*;
public class CampaignManager {
private var _config:Configuration;
private var _domainHash:Number;
private var _debug:DebugConfiguration;
private var _timeStamp:Number;
private var _referrer:String;
private var _buffer:Buffer;
public static const trackingDelimiter:String = "|";
public function CampaignManager(config:Configuration, debug:DebugConfiguration, buffer:Buffer, domainHash:Number, referrer:String, timeStamp:Number){
super();
_config = config;
_debug = debug;
_buffer = buffer;
_domainHash = domainHash;
_referrer = referrer;
_timeStamp = timeStamp;
}
public function getCampaignInformation(search:String, noSessionInformation:Boolean):CampaignInfo{
var campaignTracker:CampaignTracker;
var oldTracker:CampaignTracker;
var sessionCount:int;
var campInfo:CampaignInfo = new CampaignInfo();
var duplicateCampaign:Boolean;
var campNoOverride:Boolean;
var responseCount:int;
if (((_config.allowLinker) && (_buffer.isGenuine()))){
if (!_buffer.hasUTMZ()){
return (campInfo);
};
};
campaignTracker = getTrackerFromSearchString(search);
if (isValid(campaignTracker)){
campNoOverride = hasNoOverride(search);
if (((campNoOverride) && (!(_buffer.hasUTMZ())))){
return (campInfo);
};
};
if (!isValid(campaignTracker)){
campaignTracker = getOrganicCampaign();
if (((!(_buffer.hasUTMZ())) && (isIgnoredKeyword(campaignTracker)))){
return (campInfo);
};
};
if (((!(isValid(campaignTracker))) && (noSessionInformation))){
campaignTracker = getReferrerCampaign();
if (((!(_buffer.hasUTMZ())) && (isIgnoredReferral(campaignTracker)))){
return (campInfo);
};
};
if (!isValid(campaignTracker)){
if (((!(_buffer.hasUTMZ())) && (noSessionInformation))){
campaignTracker = getDirectCampaign();
};
};
if (!isValid(campaignTracker)){
return (campInfo);
};
if (((_buffer.hasUTMZ()) && (!(_buffer.utmz.isEmpty())))){
oldTracker = new CampaignTracker();
oldTracker.fromTrackerString(_buffer.utmz.campaignTracking);
duplicateCampaign = (oldTracker.toTrackerString() == campaignTracker.toTrackerString());
responseCount = _buffer.utmz.responseCount;
};
if (((!(duplicateCampaign)) || (noSessionInformation))){
sessionCount = _buffer.utma.sessionCount;
responseCount++;
if (sessionCount == 0){
sessionCount = 1;
};
_buffer.utmz.domainHash = _domainHash;
_buffer.utmz.campaignCreation = _timeStamp;
_buffer.utmz.campaignSessions = sessionCount;
_buffer.utmz.responseCount = responseCount;
_buffer.utmz.campaignTracking = campaignTracker.toTrackerString();
_debug.info(_buffer.utmz.toString(), VisualDebugMode.geek);
campInfo = new CampaignInfo(false, true);
} else {
campInfo = new CampaignInfo(false, false);
};
return (campInfo);
}
public function hasNoOverride(search:String):Boolean{
var key:CampaignKey = _config.campaignKey;
if (search == ""){
return (false);
};
var variables:Variables = new Variables(search);
var value:String = "";
if (variables.hasOwnProperty(key.UCNO)){
value = variables[key.UCNO];
switch (value){
case "1":
return (true);
case "":
case "0":
default:
return (false);
};
};
return (false);
}
public function getTrackerFromSearchString(search:String):CampaignTracker{
var organicCampaign:CampaignTracker = getOrganicCampaign();
var camp:CampaignTracker = new CampaignTracker();
var key:CampaignKey = _config.campaignKey;
if (search == ""){
return (camp);
};
var variables:Variables = new Variables(search);
if (variables.hasOwnProperty(key.UCID)){
camp.id = variables[key.UCID];
};
if (variables.hasOwnProperty(key.UCSR)){
camp.source = variables[key.UCSR];
};
if (variables.hasOwnProperty(key.UGCLID)){
camp.clickId = variables[key.UGCLID];
};
if (variables.hasOwnProperty(key.UCCN)){
camp.name = variables[key.UCCN];
} else {
camp.name = "(not set)";
};
if (variables.hasOwnProperty(key.UCMD)){
camp.medium = variables[key.UCMD];
} else {
camp.medium = "(not set)";
};
if (variables.hasOwnProperty(key.UCTR)){
camp.term = variables[key.UCTR];
} else {
if (((organicCampaign) && (!((organicCampaign.term == ""))))){
camp.term = organicCampaign.term;
};
};
if (variables.hasOwnProperty(key.UCCT)){
camp.content = variables[key.UCCT];
};
return (camp);
}
public function getOrganicCampaign():CampaignTracker{
var camp:CampaignTracker;
var tmp:Array;
var currentOrganicSource:OrganicReferrer;
var keyword:String;
if (((isInvalidReferrer(_referrer)) || (isFromGoogleCSE(_referrer, _config)))){
return (camp);
};
var ref:URL = new URL(_referrer);
var name:String = "";
if (ref.hostName != ""){
if (ref.hostName.indexOf(".") > -1){
tmp = ref.hostName.split(".");
switch (tmp.length){
case 2:
name = tmp[0];
break;
case 3:
name = tmp[1];
break;
};
};
};
if (_config.organic.match(name)){
currentOrganicSource = _config.organic.getReferrerByName(name);
keyword = _config.organic.getKeywordValue(currentOrganicSource, ref.search);
camp = new CampaignTracker();
camp.source = currentOrganicSource.engine;
camp.name = "(organic)";
camp.medium = "organic";
camp.term = keyword;
};
return (camp);
}
public function getDirectCampaign():CampaignTracker{
var camp:CampaignTracker = new CampaignTracker();
camp.source = "(direct)";
camp.name = "(direct)";
camp.medium = "(none)";
return (camp);
}
public function isIgnoredKeyword(tracker:CampaignTracker):Boolean{
if (((tracker) && ((tracker.medium == "organic")))){
return (_config.organic.isIgnoredKeyword(tracker.term));
};
return (false);
}
public function isIgnoredReferral(tracker:CampaignTracker):Boolean{
if (((tracker) && ((tracker.medium == "referral")))){
return (_config.organic.isIgnoredReferral(tracker.source));
};
return (false);
}
public function isValid(tracker:CampaignTracker):Boolean{
if (((tracker) && (tracker.isValid()))){
return (true);
};
return (false);
}
public function getReferrerCampaign():CampaignTracker{
var camp:CampaignTracker;
if (((isInvalidReferrer(_referrer)) || (isFromGoogleCSE(_referrer, _config)))){
return (camp);
};
var ref:URL = new URL(_referrer);
var hostname:String = ref.hostName;
var content:String = ref.path;
if (hostname.indexOf("www.") == 0){
hostname = hostname.substr(4);
};
camp = new CampaignTracker();
camp.source = hostname;
camp.name = "(referral)";
camp.medium = "referral";
camp.content = content;
return (camp);
}
public static function isInvalidReferrer(referrer:String):Boolean{
var url:URL;
if ((((((referrer == "")) || ((referrer == "-")))) || ((referrer == "0")))){
return (true);
};
if (referrer.indexOf("://") > -1){
url = new URL(referrer);
if ((((url.protocol == Protocols.file)) || ((url.protocol == Protocols.none)))){
return (true);
};
};
return (false);
}
public static function isFromGoogleCSE(referrer:String, config:Configuration):Boolean{
var url:URL = new URL(referrer);
if (url.hostName.indexOf(config.google) > -1){
if (url.search.indexOf((config.googleSearchParam + "=")) > -1){
if (url.path == ("/" + config.googleCsePath)){
return (true);
};
};
};
return (false);
}
}
}//package com.google.analytics.campaign
Section 146
//CampaignTracker (com.google.analytics.campaign.CampaignTracker)
package com.google.analytics.campaign {
import com.google.analytics.utils.*;
public class CampaignTracker {
public var content:String;
public var source:String;
public var clickId:String;
public var name:String;
public var term:String;
public var medium:String;
public var id:String;
public function CampaignTracker(id:String="", source:String="", clickId:String="", name:String="", medium:String="", term:String="", content:String=""){
super();
this.id = id;
this.source = source;
this.clickId = clickId;
this.name = name;
this.medium = medium;
this.term = term;
this.content = content;
}
public function isValid():Boolean{
if (((((!((id == ""))) || (!((source == ""))))) || (!((clickId == ""))))){
return (true);
};
return (false);
}
public function toTrackerString():String{
var data:Array = [];
_addIfNotEmpty(data, "utmcsr=", source);
_addIfNotEmpty(data, "utmccn=", name);
_addIfNotEmpty(data, "utmcmd=", medium);
_addIfNotEmpty(data, "utmctr=", term);
_addIfNotEmpty(data, "utmcct=", content);
_addIfNotEmpty(data, "utmcid=", id);
_addIfNotEmpty(data, "utmgclid=", clickId);
return (data.join(CampaignManager.trackingDelimiter));
}
private function _addIfNotEmpty(arr:Array, field:String, value:String):void{
if (value != ""){
value = value.split("+").join("%20");
value = value.split(" ").join("%20");
arr.push((field + value));
};
}
public function fromTrackerString(tracker:String):void{
var data:String = tracker.split(CampaignManager.trackingDelimiter).join("&");
var vars:Variables = new Variables(data);
if (vars.hasOwnProperty("utmcid")){
this.id = vars["utmcid"];
};
if (vars.hasOwnProperty("utmcsr")){
this.source = vars["utmcsr"];
};
if (vars.hasOwnProperty("utmccn")){
this.name = vars["utmccn"];
};
if (vars.hasOwnProperty("utmcmd")){
this.medium = vars["utmcmd"];
};
if (vars.hasOwnProperty("utmctr")){
this.term = vars["utmctr"];
};
if (vars.hasOwnProperty("utmcct")){
this.content = vars["utmcct"];
};
if (vars.hasOwnProperty("utmgclid")){
this.clickId = vars["utmgclid"];
};
}
}
}//package com.google.analytics.campaign
Section 147
//BrowserInfo (com.google.analytics.core.BrowserInfo)
package com.google.analytics.core {
import com.google.analytics.v4.*;
import com.google.analytics.utils.*;
public class BrowserInfo {
private var _config:Configuration;
private var _info:Environment;
public function BrowserInfo(config:Configuration, info:Environment){
super();
_config = config;
_info = info;
}
public function get utmul():String{
return (_info.language.toLowerCase());
}
public function get utmje():String{
return ("0");
}
public function toURLString():String{
var v:Variables = toVariables();
return (v.toString());
}
public function get utmsr():String{
return (((_info.screenWidth + "x") + _info.screenHeight));
}
public function get utmfl():String{
var v:Version;
if (_config.detectFlash){
v = _info.flashVersion;
return (((((v.major + ".") + v.minor) + " r") + v.build));
};
return ("-");
}
public function get utmcs():String{
return (_info.languageEncoding);
}
public function toVariables():Variables{
var variables:Variables = new Variables();
variables.URIencode = true;
variables.utmcs = utmcs;
variables.utmsr = utmsr;
variables.utmsc = utmsc;
variables.utmul = utmul;
variables.utmje = utmje;
variables.utmfl = utmfl;
return (variables);
}
public function get utmsc():String{
return ((_info.screenColorDepth + "-bit"));
}
}
}//package com.google.analytics.core
Section 148
//Buffer (com.google.analytics.core.Buffer)
package com.google.analytics.core {
import flash.events.*;
import com.google.analytics.v4.*;
import com.google.analytics.debug.*;
import flash.net.*;
import com.google.analytics.data.*;
public dynamic class Buffer {
private var _SO:SharedObject;
private var _OBJ:Object;
private var _utma:UTMA;
private var _utmb:UTMB;
private var _utmc:UTMC;
private var _debug:DebugConfiguration;
private var _utmk:UTMK;
private var _config:Configuration;
private var _utmv:UTMV;
private var _utmz:UTMZ;
private var _volatile:Boolean;
public function Buffer(config:Configuration, debug:DebugConfiguration, volatile:Boolean=false, data:Object=null){
var saveSO:Boolean;
var prop:String;
super();
_config = config;
_debug = debug;
UTMB.defaultTimespan = _config.sessionTimeout;
UTMZ.defaultTimespan = _config.conversionTimeout;
if (!volatile){
_SO = SharedObject.getLocal(_config.cookieName, _config.cookiePath);
saveSO = false;
if (_SO.data.utma){
if (!hasUTMA()){
_createUMTA();
};
_utma.fromSharedObject(_SO.data.utma);
if (_debug.verbose){
_debug.info(("found: " + _utma.toString(true)), VisualDebugMode.geek);
};
if (_utma.isExpired()){
if (_debug.verbose){
_debug.warning("UTMA has expired", VisualDebugMode.advanced);
};
_clearUTMA();
saveSO = true;
};
};
if (_SO.data.utmb){
if (!hasUTMB()){
_createUMTB();
};
_utmb.fromSharedObject(_SO.data.utmb);
if (_debug.verbose){
_debug.info(("found: " + _utmb.toString(true)), VisualDebugMode.geek);
};
if (_utmb.isExpired()){
if (_debug.verbose){
_debug.warning("UTMB has expired", VisualDebugMode.advanced);
};
_clearUTMB();
saveSO = true;
};
};
if (_SO.data.utmc){
delete _SO.data.utmc;
saveSO = true;
};
if (_SO.data.utmk){
if (!hasUTMK()){
_createUMTK();
};
_utmk.fromSharedObject(_SO.data.utmk);
if (_debug.verbose){
_debug.info(("found: " + _utmk.toString()), VisualDebugMode.geek);
};
};
if (_SO.data.utmv){
if (!hasUTMV()){
_createUMTV();
};
_utmv.fromSharedObject(_SO.data.utmv);
if (_debug.verbose){
_debug.info(("found: " + _utmv.toString(true)), VisualDebugMode.geek);
};
if (_utmv.isExpired()){
if (_debug.verbose){
_debug.warning("UTMV has expired", VisualDebugMode.advanced);
};
_clearUTMV();
saveSO = true;
};
};
if (_SO.data.utmz){
if (!hasUTMZ()){
_createUMTZ();
};
_utmz.fromSharedObject(_SO.data.utmz);
if (_debug.verbose){
_debug.info(("found: " + _utmz.toString(true)), VisualDebugMode.geek);
};
if (_utmz.isExpired()){
if (_debug.verbose){
_debug.warning("UTMZ has expired", VisualDebugMode.advanced);
};
_clearUTMZ();
saveSO = true;
};
};
if (saveSO){
save();
};
} else {
_OBJ = new Object();
if (data){
for (prop in data) {
_OBJ[prop] = data[prop];
};
};
};
_volatile = volatile;
}
public function clearCookies():void{
utma.reset();
utmb.reset();
utmc.reset();
utmz.reset();
utmv.reset();
utmk.reset();
}
public function save():void{
var flushStatus:String;
if (!isVolatile()){
flushStatus = null;
flushStatus = _SO.flush();
//unresolved jump
var _slot1 = e;
_debug.warning("Error...Could not write SharedObject to disk");
switch (flushStatus){
case SharedObjectFlushStatus.PENDING:
_debug.info("Requesting permission to save object...");
_SO.addEventListener(NetStatusEvent.NET_STATUS, _onFlushStatus);
break;
case SharedObjectFlushStatus.FLUSHED:
_debug.info("Value flushed to disk.");
break;
};
};
}
public function get utmv():UTMV{
if (!hasUTMV()){
_createUMTV();
};
return (_utmv);
}
public function get utmz():UTMZ{
if (!hasUTMZ()){
_createUMTZ();
};
return (_utmz);
}
public function hasUTMA():Boolean{
if (_utma){
return (true);
};
return (false);
}
public function hasUTMB():Boolean{
if (_utmb){
return (true);
};
return (false);
}
public function hasUTMC():Boolean{
if (_utmc){
return (true);
};
return (false);
}
public function isGenuine():Boolean{
if (!hasUTMK()){
return (true);
};
return ((utmk.hash == generateCookiesHash()));
}
public function resetCurrentSession():void{
_clearUTMB();
_clearUTMC();
save();
}
public function hasUTMK():Boolean{
if (_utmk){
return (true);
};
return (false);
}
public function generateCookiesHash():Number{
var value:String = "";
value = (value + utma.valueOf());
value = (value + utmb.valueOf());
value = (value + utmc.valueOf());
value = (value + utmz.valueOf());
value = (value + utmv.valueOf());
return (Utils.generateHash(value));
}
private function _createUMTB():void{
_utmb = new UTMB();
_utmb.proxy = this;
}
private function _createUMTC():void{
_utmc = new UTMC();
}
private function _createUMTA():void{
_utma = new UTMA();
_utma.proxy = this;
}
public function hasUTMV():Boolean{
if (_utmv){
return (true);
};
return (false);
}
private function _createUMTK():void{
_utmk = new UTMK();
_utmk.proxy = this;
}
public function hasUTMZ():Boolean{
if (_utmz){
return (true);
};
return (false);
}
private function _createUMTV():void{
_utmv = new UTMV();
_utmv.proxy = this;
}
private function _onFlushStatus(event:NetStatusEvent):void{
_debug.info("User closed permission dialog...");
switch (event.info.code){
case "SharedObject.Flush.Success":
_debug.info("User granted permission -- value saved.");
break;
case "SharedObject.Flush.Failed":
_debug.info("User denied permission -- value not saved.");
break;
};
_SO.removeEventListener(NetStatusEvent.NET_STATUS, _onFlushStatus);
}
private function _createUMTZ():void{
_utmz = new UTMZ();
_utmz.proxy = this;
}
public function updateUTMA(timestamp:Number):void{
if (_debug.verbose){
_debug.info((("updateUTMA( " + timestamp) + " )"), VisualDebugMode.advanced);
};
if (!utma.isEmpty()){
if (isNaN(utma.sessionCount)){
utma.sessionCount = 1;
} else {
utma.sessionCount = (utma.sessionCount + 1);
};
utma.lastTime = utma.currentTime;
utma.currentTime = timestamp;
};
}
private function _clearUTMA():void{
_utma = null;
if (!isVolatile()){
_SO.data.utma = null;
delete _SO.data.utma;
};
}
private function _clearUTMC():void{
_utmc = null;
}
private function _clearUTMB():void{
_utmb = null;
if (!isVolatile()){
_SO.data.utmb = null;
delete _SO.data.utmb;
};
}
public function update(name:String, value):void{
if (isVolatile()){
_OBJ[name] = value;
} else {
_SO.data[name] = value;
};
}
private function _clearUTMZ():void{
_utmz = null;
if (!isVolatile()){
_SO.data.utmz = null;
delete _SO.data.utmz;
};
}
private function _clearUTMV():void{
_utmv = null;
if (!isVolatile()){
_SO.data.utmv = null;
delete _SO.data.utmv;
};
}
public function isVolatile():Boolean{
return (_volatile);
}
public function get utma():UTMA{
if (!hasUTMA()){
_createUMTA();
};
return (_utma);
}
public function get utmb():UTMB{
if (!hasUTMB()){
_createUMTB();
};
return (_utmb);
}
public function get utmc():UTMC{
if (!hasUTMC()){
_createUMTC();
};
return (_utmc);
}
public function get utmk():UTMK{
if (!hasUTMK()){
_createUMTK();
};
return (_utmk);
}
}
}//package com.google.analytics.core
Section 149
//DocumentInfo (com.google.analytics.core.DocumentInfo)
package com.google.analytics.core {
import com.google.analytics.v4.*;
import com.google.analytics.external.*;
import com.google.analytics.utils.*;
public class DocumentInfo {
private var _pageURL:String;
private var _utmr:String;
private var _config:Configuration;
private var _adSense:AdSenseGlobals;
private var _info:Environment;
public function DocumentInfo(config:Configuration, info:Environment, formatedReferrer:String, pageURL:String=null, adSense:AdSenseGlobals=null){
super();
_config = config;
_info = info;
_utmr = formatedReferrer;
_pageURL = pageURL;
_adSense = adSense;
}
public function get utmr():String{
if (!_utmr){
return ("-");
};
return (_utmr);
}
public function toURLString():String{
var v:Variables = toVariables();
return (v.toString());
}
private function _renderPageURL(pageURL:String=""):String{
var pathname:String = _info.locationPath;
var search:String = _info.locationSearch;
if (((!(pageURL)) || ((pageURL == "")))){
pageURL = (pathname + unescape(search));
};
return (pageURL);
}
public function get utmp():String{
return (_renderPageURL(_pageURL));
}
public function get utmhid():String{
return (String(_generateHitId()));
}
private function _generateHitId():Number{
var hid:Number;
if (((_adSense.hid) && (!((_adSense.hid == ""))))){
hid = Number(_adSense.hid);
} else {
hid = Math.round((Math.random() * 2147483647));
_adSense.hid = String(hid);
};
return (hid);
}
public function toVariables():Variables{
var variables:Variables = new Variables();
variables.URIencode = true;
if (((_config.detectTitle) && (!((utmdt == ""))))){
variables.utmdt = utmdt;
};
variables.utmhid = utmhid;
variables.utmr = utmr;
variables.utmp = utmp;
return (variables);
}
public function get utmdt():String{
return (_info.documentTitle);
}
}
}//package com.google.analytics.core
Section 150
//Domain (com.google.analytics.core.Domain)
package com.google.analytics.core {
import com.google.analytics.debug.*;
public class Domain {
private var _mode:DomainNameMode;
private var _debug:DebugConfiguration;
private var _name:String;
public function Domain(mode:DomainNameMode=null, name:String="", debug:DebugConfiguration=null){
super();
_debug = debug;
if (mode == null){
mode = DomainNameMode.auto;
};
_mode = mode;
if (mode == DomainNameMode.custom){
this.name = name;
} else {
_name = name;
};
}
public function get mode():DomainNameMode{
return (_mode);
}
public function set mode(value:DomainNameMode):void{
_mode = value;
if (_mode == DomainNameMode.none){
_name = "";
};
}
public function get name():String{
return (_name);
}
public function set name(value:String):void{
if (((!((value.charAt(0) == "."))) && (_debug))){
_debug.warning(("missing leading period \".\", cookie will only be accessible on " + value), VisualDebugMode.geek);
};
_name = value;
}
}
}//package com.google.analytics.core
Section 151
//DomainNameMode (com.google.analytics.core.DomainNameMode)
package com.google.analytics.core {
public class DomainNameMode {
private var _value:int;
private var _name:String;
public static const custom:DomainNameMode = new DomainNameMode(2, "custom");
;
public static const none:DomainNameMode = new DomainNameMode(0, "none");
;
public static const auto:DomainNameMode = new DomainNameMode(1, "auto");
;
public function DomainNameMode(value:int=0, name:String=""){
super();
_value = value;
_name = name;
}
public function valueOf():int{
return (_value);
}
public function toString():String{
return (_name);
}
}
}//package com.google.analytics.core
Section 152
//EventInfo (com.google.analytics.core.EventInfo)
package com.google.analytics.core {
import com.google.analytics.utils.*;
import com.google.analytics.data.*;
public class EventInfo {
private var _ext10:X10;
private var _isEventHit:Boolean;
private var _x10:X10;
public function EventInfo(isEventHit:Boolean, xObject:X10, extObject:X10=null){
super();
_isEventHit = isEventHit;
_x10 = xObject;
_ext10 = extObject;
}
public function toURLString():String{
var v:Variables = toVariables();
return (v.toString());
}
public function get utmt():String{
return ("event");
}
public function get utme():String{
return (_x10.renderMergedUrlString(_ext10));
}
public function toVariables():Variables{
var variables:Variables = new Variables();
variables.URIencode = true;
if (_isEventHit){
variables.utmt = utmt;
};
variables.utme = utme;
return (variables);
}
}
}//package com.google.analytics.core
Section 153
//EventTracker (com.google.analytics.core.EventTracker)
package com.google.analytics.core {
import com.google.analytics.v4.*;
public class EventTracker {
private var _parent:GoogleAnalyticsAPI;
public var name:String;
public function EventTracker(name:String, parent:GoogleAnalyticsAPI){
super();
this.name = name;
_parent = parent;
}
public function trackEvent(action:String, label:String=null, value:Number=NaN):Boolean{
return (_parent.trackEvent(name, action, label, value));
}
}
}//package com.google.analytics.core
Section 154
//ga_internal (com.google.analytics.core.ga_internal)
package com.google.analytics.core {
public namespace ga_internal;
}//package com.google.analytics.core
Section 155
//GIFRequest (com.google.analytics.core.GIFRequest)
package com.google.analytics.core {
import flash.events.*;
import flash.display.*;
import com.google.analytics.v4.*;
import com.google.analytics.debug.*;
import flash.net.*;
import com.google.analytics.utils.*;
import flash.system.*;
public class GIFRequest {
private var _info:Environment;
private var _count:int;
private var _utmac:String;
private var _alertcount:int;
private var _debug:DebugConfiguration;
private var _lastRequest:URLRequest;
private var _buffer:Buffer;
private var _config:Configuration;
private var _requests:Array;
public function GIFRequest(config:Configuration, debug:DebugConfiguration, buffer:Buffer, info:Environment){
super();
_config = config;
_debug = debug;
_buffer = buffer;
_info = info;
_count = 0;
_alertcount = 0;
_requests = [];
}
public function get utmn():String{
return ((Utils.generate32bitRandom() as String));
}
public function onIOError(event:IOErrorEvent):void{
var url:String = _lastRequest.url;
var id:String = String((_requests.length - 1));
var msg = (("Gif Request #" + id) + " failed");
if (_debug.GIFRequests){
if (!_debug.verbose){
if (url.indexOf("?") > -1){
url = url.split("?")[0];
};
url = _shortenURL(url);
};
if (int(_debug.mode) > int(VisualDebugMode.basic)){
msg = (msg + ((" \"" + url) + "\" does not exists or is unreachable"));
};
_debug.failure(msg);
} else {
_debug.warning(msg);
};
_removeListeners(event.target);
}
public function send(account:String, variables:Variables=null, force:Boolean=false, rateLimit:Boolean=false):void{
var localPath:String;
var localImage:URLRequest;
var remoteImage:URLRequest;
_utmac = account;
if (!variables){
variables = new Variables();
};
variables.URIencode = false;
variables.pre = ["utmwv", "utmn", "utmhn", "utmt", "utme", "utmcs", "utmsr", "utmsc", "utmul", "utmje", "utmfl", "utmdt", "utmhid", "utmr", "utmp"];
variables.post = ["utmcc"];
if (_debug.verbose){
_debug.info(((("tracking: " + _buffer.utmb.trackCount) + "/") + _config.trackingLimitPerSession), VisualDebugMode.geek);
};
if ((((_buffer.utmb.trackCount < _config.trackingLimitPerSession)) || (force))){
if (rateLimit){
updateToken();
};
if (((((force) || (!(rateLimit)))) || ((_buffer.utmb.token >= 1)))){
if (((!(force)) && (rateLimit))){
_buffer.utmb.token = (_buffer.utmb.token - 1);
};
_buffer.utmb.trackCount = (_buffer.utmb.trackCount + 1);
if (_debug.verbose){
_debug.info(_buffer.utmb.toString(), VisualDebugMode.geek);
};
variables.utmwv = utmwv;
variables.utmn = Utils.generate32bitRandom();
if (_info.domainName != ""){
variables.utmhn = _info.domainName;
};
if (_config.sampleRate < 1){
variables.utmsp = (_config.sampleRate * 100);
};
if ((((_config.serverMode == ServerOperationMode.local)) || ((_config.serverMode == ServerOperationMode.both)))){
localPath = _info.locationSWFPath;
if (localPath.lastIndexOf("/") > 0){
localPath = localPath.substring(0, localPath.lastIndexOf("/"));
};
localImage = new URLRequest();
if (_config.localGIFpath.indexOf("http") == 0){
localImage.url = _config.localGIFpath;
} else {
localImage.url = (localPath + _config.localGIFpath);
};
localImage.url = (localImage.url + ("?" + variables.toString()));
if (((_debug.active) && (_debug.GIFRequests))){
_debugSend(localImage);
} else {
sendRequest(localImage);
};
};
if ((((_config.serverMode == ServerOperationMode.remote)) || ((_config.serverMode == ServerOperationMode.both)))){
remoteImage = new URLRequest();
if (_info.protocol == Protocols.HTTPS){
remoteImage.url = _config.secureRemoteGIFpath;
} else {
if (_info.protocol == Protocols.HTTP){
remoteImage.url = _config.remoteGIFpath;
} else {
remoteImage.url = _config.remoteGIFpath;
};
};
variables.utmac = utmac;
variables.utmcc = encodeURIComponent(utmcc);
remoteImage.url = (remoteImage.url + ("?" + variables.toString()));
if (((_debug.active) && (_debug.GIFRequests))){
_debugSend(remoteImage);
} else {
sendRequest(remoteImage);
};
};
};
};
}
public function onSecurityError(event:SecurityErrorEvent):void{
if (_debug.GIFRequests){
_debug.failure(event.text);
};
}
public function get utmsp():String{
return (((_config.sampleRate * 100) as String));
}
public function get utmcc():String{
var cookies:Array = [];
if (_buffer.hasUTMA()){
cookies.push((_buffer.utma.toURLString() + ";"));
};
if (_buffer.hasUTMZ()){
cookies.push((_buffer.utmz.toURLString() + ";"));
};
if (_buffer.hasUTMV()){
cookies.push((_buffer.utmv.toURLString() + ";"));
};
return (cookies.join("+"));
}
public function get utmac():String{
return (_utmac);
}
public function get utmwv():String{
return (_config.version);
}
public function sendRequest(request:URLRequest):void{
var request = request;
var loader:Loader = new Loader();
loader.name = String(_count++);
var context:LoaderContext = new LoaderContext(false);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
_lastRequest = request;
_requests[loader.name] = new RequestObject(request);
loader.load(request, context);
//unresolved jump
var _slot1 = e;
_debug.failure("\"Loader.load()\" could not instanciate Gif Request");
}
private function _removeListeners(target:Object):void{
target.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
target.removeEventListener(Event.COMPLETE, onComplete);
}
public function updateToken():void{
var tokenDelta:Number;
var timestamp:Number = new Date().getTime();
tokenDelta = ((timestamp - _buffer.utmb.lastTime) * (_config.tokenRate / 1000));
if (_debug.verbose){
_debug.info(("tokenDelta: " + tokenDelta), VisualDebugMode.geek);
};
if (tokenDelta >= 1){
_buffer.utmb.token = Math.min(Math.floor((_buffer.utmb.token + tokenDelta)), _config.bucketCapacity);
_buffer.utmb.lastTime = timestamp;
if (_debug.verbose){
_debug.info(_buffer.utmb.toString(), VisualDebugMode.geek);
};
};
}
public function get utmhn():String{
return (_info.domainName);
}
private function _shortenURL(url:String):String{
var paths:Array;
if (url.length > 60){
paths = url.split("/");
while (url.length > 60) {
paths.shift();
url = ("../" + paths.join("/"));
};
};
return (url);
}
private function _debugSend(request:URLRequest):void{
var _local3:String;
var data:String = "";
switch (_debug.mode){
case VisualDebugMode.geek:
data = ((("Gif Request #" + _alertcount) + ":\n") + request.url);
break;
case VisualDebugMode.advanced:
_local3 = request.url;
if (_local3.indexOf("?") > -1){
_local3 = _local3.split("?")[0];
};
_local3 = _shortenURL(_local3);
data = (((("Send Gif Request #" + _alertcount) + ":\n") + _local3) + " ?");
break;
case VisualDebugMode.basic:
default:
data = (((("Send " + _config.serverMode.toString()) + " Gif Request #") + _alertcount) + " ?");
};
_debug.alertGifRequest(data, request, this);
_alertcount++;
}
public function onComplete(event:Event):void{
var id:String = event.target.loader.name;
_requests[id].complete();
var msg = (("Gif Request #" + id) + " sent");
var url:String = _requests[id].request.url;
if (_debug.GIFRequests){
if (!_debug.verbose){
if (url.indexOf("?") > -1){
url = url.split("?")[0];
};
url = _shortenURL(url);
};
if (int(_debug.mode) > int(VisualDebugMode.basic)){
msg = (msg + ((" to \"" + url) + "\""));
};
_debug.success(msg);
} else {
_debug.info(msg);
};
_removeListeners(event.target);
}
}
}//package com.google.analytics.core
Section 156
//IdleTimer (com.google.analytics.core.IdleTimer)
package com.google.analytics.core {
import flash.events.*;
import flash.display.*;
import com.google.analytics.v4.*;
import com.google.analytics.debug.*;
import flash.utils.*;
public class IdleTimer {
private var _stage:Stage;
private var _loop:Timer;
private var _lastMove:int;
private var _inactivity:Number;
private var _debug:DebugConfiguration;
private var _session:Timer;
private var _buffer:Buffer;
public function IdleTimer(config:Configuration, debug:DebugConfiguration, display:DisplayObject, buffer:Buffer){
super();
var delay:Number = config.idleLoop;
var inactivity:Number = config.idleTimeout;
var sessionTimeout:Number = config.sessionTimeout;
_loop = new Timer((delay * 1000));
_session = new Timer((sessionTimeout * 1000), 1);
_debug = debug;
_stage = display.stage;
_buffer = buffer;
_lastMove = getTimer();
_inactivity = (inactivity * 1000);
_loop.addEventListener(TimerEvent.TIMER, checkForIdle);
_session.addEventListener(TimerEvent.TIMER_COMPLETE, endSession);
_stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
_debug.info(((((("delay: " + delay) + "sec , inactivity: ") + inactivity) + "sec, sessionTimeout: ") + sessionTimeout), VisualDebugMode.geek);
_loop.start();
}
private function onMouseMove(event:MouseEvent):void{
_lastMove = getTimer();
if (_session.running){
_debug.info("session timer reset", VisualDebugMode.geek);
_session.reset();
};
}
public function endSession(event:TimerEvent):void{
_session.removeEventListener(TimerEvent.TIMER_COMPLETE, endSession);
_debug.info("session timer end session", VisualDebugMode.geek);
_session.reset();
_buffer.resetCurrentSession();
_debug.info(_buffer.utmb.toString(), VisualDebugMode.geek);
_debug.info(_buffer.utmc.toString(), VisualDebugMode.geek);
_session.addEventListener(TimerEvent.TIMER_COMPLETE, endSession);
}
public function checkForIdle(event:TimerEvent):void{
var current:int = getTimer();
if ((current - _lastMove) >= _inactivity){
if (!_session.running){
_debug.info("session timer start", VisualDebugMode.geek);
_session.start();
};
};
}
}
}//package com.google.analytics.core
Section 157
//Organic (com.google.analytics.core.Organic)
package com.google.analytics.core {
import com.google.analytics.utils.*;
public class Organic {
private var _sourcesCache:Array;
private var _sourcesEngine:Array;
private var _ignoredKeywords:Array;
private var _ignoredReferralsCache:Object;
private var _ignoredReferrals:Array;
private var _ignoredKeywordsCache:Object;
private var _sources:Array;
public static var throwErrors:Boolean = false;
public function Organic(){
super();
_sources = [];
_sourcesCache = [];
_sourcesEngine = [];
_ignoredReferrals = [];
_ignoredReferralsCache = {};
_ignoredKeywords = [];
_ignoredKeywordsCache = {};
}
public function isIgnoredKeyword(keyword:String):Boolean{
if (_ignoredKeywordsCache.hasOwnProperty(keyword)){
return (true);
};
return (false);
}
public function getKeywordValue(or:OrganicReferrer, path:String):String{
var keyword:String = or.keyword;
return (getKeywordValueFromPath(keyword, path));
}
public function isIgnoredReferral(referrer:String):Boolean{
if (_ignoredReferralsCache.hasOwnProperty(referrer)){
return (true);
};
return (false);
}
public function clear():void{
clearEngines();
clearIgnoredReferrals();
clearIgnoredKeywords();
}
public function get count():int{
return (_sources.length);
}
public function get ignoredKeywordsCount():int{
return (_ignoredKeywords.length);
}
public function match(name:String):Boolean{
if (name == ""){
return (false);
};
name = name.toLowerCase();
if (_sourcesEngine[name] != undefined){
return (true);
};
return (false);
}
public function clearIgnoredKeywords():void{
_ignoredKeywords = [];
_ignoredKeywordsCache = {};
}
public function addSource(engine:String, keyword:String):void{
var orgref:OrganicReferrer = new OrganicReferrer(engine, keyword);
if (_sourcesCache[orgref.toString()] == undefined){
_sources.push(orgref);
_sourcesCache[orgref.toString()] = (_sources.length - 1);
if (_sourcesEngine[orgref.engine] == undefined){
_sourcesEngine[orgref.engine] = [(_sources.length - 1)];
} else {
_sourcesEngine[orgref.engine].push((_sources.length - 1));
};
} else {
if (throwErrors){
throw (new Error((orgref.toString() + " already exists, we don't add it.")));
};
};
}
public function clearEngines():void{
_sources = [];
_sourcesCache = [];
_sourcesEngine = [];
}
public function get ignoredReferralsCount():int{
return (_ignoredReferrals.length);
}
public function addIgnoredReferral(referrer:String):void{
if (_ignoredReferralsCache[referrer] == undefined){
_ignoredReferrals.push(referrer);
_ignoredReferralsCache[referrer] = (_ignoredReferrals.length - 1);
} else {
if (throwErrors){
throw (new Error((("\"" + referrer) + "\" already exists, we don't add it.")));
};
};
}
public function clearIgnoredReferrals():void{
_ignoredReferrals = [];
_ignoredReferralsCache = {};
}
public function getReferrerByName(name:String):OrganicReferrer{
var index:int;
if (match(name)){
index = _sourcesEngine[name][0];
return (_sources[index]);
};
return (null);
}
public function addIgnoredKeyword(keyword:String):void{
if (_ignoredKeywordsCache[keyword] == undefined){
_ignoredKeywords.push(keyword);
_ignoredKeywordsCache[keyword] = (_ignoredKeywords.length - 1);
} else {
if (throwErrors){
throw (new Error((("\"" + keyword) + "\" already exists, we don't add it.")));
};
};
}
public function get sources():Array{
return (_sources);
}
public static function getKeywordValueFromPath(keyword:String, path:String):String{
var value:String;
var vars:Variables;
if (path.indexOf((keyword + "=")) > -1){
if (path.charAt(0) == "?"){
path = path.substr(1);
};
path = path.split("+").join("%20");
vars = new Variables(path);
value = vars[keyword];
};
return (value);
}
}
}//package com.google.analytics.core
Section 158
//OrganicReferrer (com.google.analytics.core.OrganicReferrer)
package com.google.analytics.core {
public class OrganicReferrer {
private var _engine:String;
private var _keyword:String;
public function OrganicReferrer(engine:String, keyword:String){
super();
this.engine = engine;
this.keyword = keyword;
}
public function get keyword():String{
return (_keyword);
}
public function get engine():String{
return (_engine);
}
public function set engine(value:String):void{
_engine = value.toLowerCase();
}
public function toString():String{
return (((engine + "?") + keyword));
}
public function set keyword(value:String):void{
_keyword = value.toLowerCase();
}
}
}//package com.google.analytics.core
Section 159
//RequestObject (com.google.analytics.core.RequestObject)
package com.google.analytics.core {
import flash.net.*;
import flash.utils.*;
public class RequestObject {
public var start:int;
public var end:int;
public var request:URLRequest;
public function RequestObject(request:URLRequest){
super();
start = getTimer();
this.request = request;
}
public function hasCompleted():Boolean{
return ((end > 0));
}
public function toString():String{
var data:Array = [];
data.push((("duration: " + duration) + "ms"));
data.push(("url: " + request.url));
return ((("{ " + data.join(", ")) + " }"));
}
public function complete():void{
end = getTimer();
}
public function get duration():int{
if (!hasCompleted()){
return (0);
};
return ((end - start));
}
}
}//package com.google.analytics.core
Section 160
//ServerOperationMode (com.google.analytics.core.ServerOperationMode)
package com.google.analytics.core {
public class ServerOperationMode {
private var _value:int;
private var _name:String;
public static const both:ServerOperationMode = new ServerOperationMode(2, "both");
;
public static const remote:ServerOperationMode = new ServerOperationMode(1, "remote");
;
public static const local:ServerOperationMode = new ServerOperationMode(0, "local");
;
public function ServerOperationMode(value:int=0, name:String=""){
super();
_value = value;
_name = name;
}
public function valueOf():int{
return (_value);
}
public function toString():String{
return (_name);
}
}
}//package com.google.analytics.core
Section 161
//TrackerCache (com.google.analytics.core.TrackerCache)
package com.google.analytics.core {
import com.google.analytics.v4.*;
import flash.errors.*;
public class TrackerCache implements GoogleAnalyticsAPI {
public var tracker:GoogleAnalyticsAPI;
private var _ar:Array;
public static var CACHE_THROW_ERROR:Boolean;
public function TrackerCache(tracker:GoogleAnalyticsAPI=null){
super();
this.tracker = tracker;
_ar = [];
}
public function size():uint{
return (_ar.length);
}
public function flush():void{
var o:Object;
var name:String;
var args:Array;
var l:int;
var i:int;
if (tracker == null){
return;
};
if (size() > 0){
l = _ar.length;
while (i < l) {
o = _ar.shift();
name = (o.name as String);
args = (o.args as Array);
if (((!((name == null))) && ((name in tracker)))){
(tracker[name] as Function).apply(tracker, args);
};
i++;
};
};
}
public function enqueue(name:String, ... _args):Boolean{
if (name == null){
return (false);
};
_ar.push({name:name, args:_args});
return (true);
}
public function link(targetUrl:String, useHash:Boolean=false):void{
enqueue("link", targetUrl, useHash);
}
public function addOrganic(newOrganicEngine:String, newOrganicKeyword:String):void{
enqueue("addOrganic", newOrganicEngine, newOrganicKeyword);
}
public function setAllowLinker(enable:Boolean):void{
enqueue("setAllowLinker", enable);
}
public function trackEvent(category:String, action:String, label:String=null, value:Number=NaN):Boolean{
enqueue("trackEvent", category, action, label, value);
return (true);
}
public function getClientInfo():Boolean{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getClientInfo' method for the moment."));
};
return (false);
}
public function trackTrans():void{
enqueue("trackTrans");
}
public function trackPageview(pageURL:String=""):void{
enqueue("trackPageview", pageURL);
}
public function setClientInfo(enable:Boolean):void{
enqueue("setClientInfo", enable);
}
public function linkByPost(formObject:Object, useHash:Boolean=false):void{
enqueue("linkByPost", formObject, useHash);
}
public function setCookieTimeout(newDefaultTimeout:int):void{
enqueue("setCookieTimeout", newDefaultTimeout);
}
public function isEmpty():Boolean{
return ((_ar.length == 0));
}
public function getDetectTitle():Boolean{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getDetectTitle' method for the moment."));
};
return (false);
}
public function resetSession():void{
enqueue("resetSession");
}
public function setDetectFlash(enable:Boolean):void{
enqueue("setDetectFlash", enable);
}
public function clear():void{
_ar = [];
}
public function setCampNameKey(newCampNameKey:String):void{
enqueue("setCampNameKey", newCampNameKey);
}
public function addItem(item:String, sku:String, name:String, category:String, price:Number, quantity:int):void{
enqueue("addItem", item, sku, name, category, price, quantity);
}
public function createEventTracker(objName:String):EventTracker{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'createEventTracker' method for the moment."));
};
return (null);
}
public function setVar(newVal:String):void{
enqueue("setVar", newVal);
}
public function clearIgnoredOrganic():void{
enqueue("clearIgnoredOrganic");
}
public function setDomainName(newDomainName:String):void{
enqueue("setDomainName", newDomainName);
}
public function setCampSourceKey(newCampSrcKey:String):void{
enqueue("setCampSourceKey", newCampSrcKey);
}
public function addTrans(orderId:String, affiliation:String, total:Number, tax:Number, shipping:Number, city:String, state:String, country:String):Object{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'addTrans' method for the moment."));
};
return (null);
}
public function setCampContentKey(newCampContentKey:String):void{
enqueue("setCampContentKey", newCampContentKey);
}
public function setLocalServerMode():void{
enqueue("setLocalServerMode");
}
public function getLocalGifPath():String{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getLocalGifPath' method for the moment."));
};
return ("");
}
public function setAllowAnchor(enable:Boolean):void{
enqueue("setAllowAnchor", enable);
}
public function clearIgnoredRef():void{
enqueue("clearIgnoredRef");
}
public function setLocalGifPath(newLocalGifPath:String):void{
enqueue("setLocalGifPath", newLocalGifPath);
}
public function getVersion():String{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getVersion' method for the moment."));
};
return ("");
}
public function setCookiePath(newCookiePath:String):void{
enqueue("setCookiePath", newCookiePath);
}
public function setSampleRate(newRate:Number):void{
enqueue("setSampleRate", newRate);
}
public function setDetectTitle(enable:Boolean):void{
enqueue("setDetectTitle", enable);
}
public function setAllowHash(enable:Boolean):void{
enqueue("setAllowHash", enable);
}
public function addIgnoredOrganic(newIgnoredOrganicKeyword:String):void{
enqueue("addIgnoredOrganic", newIgnoredOrganicKeyword);
}
public function setCampNOKey(newCampNOKey:String):void{
enqueue("setCampNOKey", newCampNOKey);
}
public function getServiceMode():ServerOperationMode{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getServiceMode' method for the moment."));
};
return (null);
}
public function setLocalRemoteServerMode():void{
enqueue("setLocalRemoteServerMode");
}
public function cookiePathCopy(newPath:String):void{
enqueue("cookiePathCopy", newPath);
}
public function getDetectFlash():Boolean{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getDetectFlash' method for the moment."));
};
return (false);
}
public function setCampaignTrack(enable:Boolean):void{
enqueue("setCampaignTrack", enable);
}
public function clearOrganic():void{
enqueue("clearOrganic");
}
public function setCampTermKey(newCampTermKey:String):void{
enqueue("setCampTermKey", newCampTermKey);
}
public function addIgnoredRef(newIgnoredReferrer:String):void{
enqueue("addIgnoredRef", newIgnoredReferrer);
}
public function setCampMediumKey(newCampMedKey:String):void{
enqueue("setCampMediumKey", newCampMedKey);
}
public function setSessionTimeout(newTimeout:int):void{
enqueue("setSessionTimeout", newTimeout);
}
public function setRemoteServerMode():void{
enqueue("setRemoteServerMode");
}
public function element(){
return (_ar[0]);
}
public function getAccount():String{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getAccount' method for the moment."));
};
return ("");
}
}
}//package com.google.analytics.core
Section 162
//TrackerMode (com.google.analytics.core.TrackerMode)
package com.google.analytics.core {
public class TrackerMode {
public static const BRIDGE:String = "Bridge";
public static const AS3:String = "AS3";
public function TrackerMode(){
super();
}
}
}//package com.google.analytics.core
Section 163
//Utils (com.google.analytics.core.Utils)
package com.google.analytics.core {
public class Utils {
public function Utils(){
super();
}
public static function trim(raw:String, everything:Boolean=false):String{
var i:int;
var iLeft:int;
var iRight:int;
if (raw == ""){
return ("");
};
var whitespaces:Array = [" ", "\n", "\r", "\t"];
var str:String = raw;
if (everything){
i = 0;
while ((((i < whitespaces.length)) && ((str.indexOf(whitespaces[i]) > -1)))) {
str = str.split(whitespaces[i]).join("");
i++;
};
} else {
iLeft = 0;
while ((((iLeft < str.length)) && ((whitespaces.indexOf(str.charAt(iLeft)) > -1)))) {
iLeft++;
};
str = str.substr(iLeft);
iRight = (str.length - 1);
while ((((iRight >= 0)) && ((whitespaces.indexOf(str.charAt(iRight)) > -1)))) {
iRight--;
};
str = str.substring(0, (iRight + 1));
};
return (str);
}
public static function generateHash(input:String):int{
var pos:int;
var current:int;
var hash = 1;
var leftMost7:int;
if (((!((input == null))) && (!((input == ""))))){
hash = 0;
pos = (input.length - 1);
while (pos >= 0) {
current = input.charCodeAt(pos);
hash = ((((hash << 6) & 268435455) + current) + (current << 14));
leftMost7 = (hash & 266338304);
if (leftMost7 != 0){
hash = (hash ^ (leftMost7 >> 21));
};
pos--;
};
};
return (hash);
}
public static function generate32bitRandom():int{
return (Math.round((Math.random() * 2147483647)));
}
public static function validateAccount(account:String):Boolean{
var rel:RegExp = /^UA-[0-9]*-[0-9]*$/;
return (rel.test(account));
}
}
}//package com.google.analytics.core
Section 164
//Cookie (com.google.analytics.data.Cookie)
package com.google.analytics.data {
public interface Cookie {
function fromSharedObject(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/data;Cookie.as:Object):void;
function toURLString():String;
function get creation():Date;
function toSharedObject():Object;
function isExpired():Boolean;
function set creation(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/data;Cookie.as:Date):void;
function set expiration(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/data;Cookie.as:Date):void;
function get expiration():Date;
}
}//package com.google.analytics.data
Section 165
//UTMA (com.google.analytics.data.UTMA)
package com.google.analytics.data {
import com.google.analytics.utils.*;
public class UTMA extends UTMCookie {
private var _sessionId:Number;
private var _domainHash:Number;
private var _firstTime:Number;
private var _currentTime:Number;
private var _lastTime:Number;
private var _sessionCount:Number;
public function UTMA(domainHash:Number=NaN, sessionId:Number=NaN, firstTime:Number=NaN, lastTime:Number=NaN, currentTime:Number=NaN, sessionCount:Number=NaN){
super("utma", "__utma", ["domainHash", "sessionId", "firstTime", "lastTime", "currentTime", "sessionCount"], (Timespan.twoyears * 1000));
this.domainHash = domainHash;
this.sessionId = sessionId;
this.firstTime = firstTime;
this.lastTime = lastTime;
this.currentTime = currentTime;
this.sessionCount = sessionCount;
}
public function get lastTime():Number{
return (_lastTime);
}
public function set lastTime(value:Number):void{
_lastTime = value;
update();
}
public function set currentTime(value:Number):void{
_currentTime = value;
update();
}
public function get sessionId():Number{
return (_sessionId);
}
public function get sessionCount():Number{
return (_sessionCount);
}
public function get firstTime():Number{
return (_firstTime);
}
public function get currentTime():Number{
return (_currentTime);
}
public function set domainHash(value:Number):void{
_domainHash = value;
update();
}
public function set sessionId(value:Number):void{
_sessionId = value;
update();
}
public function set sessionCount(value:Number):void{
_sessionCount = value;
update();
}
public function get domainHash():Number{
return (_domainHash);
}
public function set firstTime(value:Number):void{
_firstTime = value;
update();
}
}
}//package com.google.analytics.data
Section 166
//UTMB (com.google.analytics.data.UTMB)
package com.google.analytics.data {
import com.google.analytics.utils.*;
public class UTMB extends UTMCookie {
private var _trackCount:Number;
private var _lastTime:Number;
private var _domainHash:Number;
private var _token:Number;
public static var defaultTimespan:Number = Timespan.thirtyminutes;
public function UTMB(domainHash:Number=NaN, trackCount:Number=NaN, token:Number=NaN, lastTime:Number=NaN){
super("utmb", "__utmb", ["domainHash", "trackCount", "token", "lastTime"], (defaultTimespan * 1000));
this.domainHash = domainHash;
this.trackCount = trackCount;
this.token = token;
this.lastTime = lastTime;
}
public function set token(value:Number):void{
_token = value;
update();
}
public function set trackCount(value:Number):void{
_trackCount = value;
update();
}
public function get lastTime():Number{
return (_lastTime);
}
public function set domainHash(value:Number):void{
_domainHash = value;
update();
}
public function set lastTime(value:Number):void{
_lastTime = value;
update();
}
public function get domainHash():Number{
return (_domainHash);
}
public function get token():Number{
return (_token);
}
public function get trackCount():Number{
return (_trackCount);
}
}
}//package com.google.analytics.data
Section 167
//UTMC (com.google.analytics.data.UTMC)
package com.google.analytics.data {
public class UTMC extends UTMCookie {
private var _domainHash:Number;
public function UTMC(domainHash:Number=NaN){
super("utmc", "__utmc", ["domainHash"]);
this.domainHash = domainHash;
}
public function get domainHash():Number{
return (_domainHash);
}
public function set domainHash(value:Number):void{
_domainHash = value;
update();
}
}
}//package com.google.analytics.data
Section 168
//UTMCookie (com.google.analytics.data.UTMCookie)
package com.google.analytics.data {
import com.google.analytics.core.*;
public class UTMCookie implements Cookie {
protected var inURL:String;
protected var name:String;
private var _creation:Date;
private var _expiration:Date;
public var proxy:Buffer;
protected var fields:Array;
private var _timespan:Number;
public function UTMCookie(name:String, inURL:String, fields:Array, timespan:Number=0){
super();
this.name = name;
this.inURL = inURL;
this.fields = fields;
_timestamp(timespan);
}
public function isEmpty():Boolean{
var field:String;
var empty:int;
var i:int;
while (i < fields.length) {
field = fields[i];
if ((((this[field] is Number)) && (isNaN(this[field])))){
empty++;
} else {
if ((((this[field] is String)) && ((this[field] == "")))){
empty++;
};
};
i++;
};
if (empty == fields.length){
return (true);
};
return (false);
}
public function resetTimestamp(timespan:Number=NaN):void{
if (!isNaN(timespan)){
_timespan = timespan;
};
_creation = null;
_expiration = null;
_timestamp(_timespan);
}
protected function update():void{
resetTimestamp();
if (proxy){
proxy.update(name, toSharedObject());
};
}
public function reset():void{
var field:String;
var i:int;
while (i < fields.length) {
field = fields[i];
if ((this[field] is Number)){
this[field] = NaN;
} else {
if ((this[field] is String)){
this[field] = "";
};
};
i++;
};
resetTimestamp();
update();
}
public function fromSharedObject(data:Object):void{
var field:String;
var len:int = fields.length;
var i:int;
while (i < len) {
field = fields[i];
if (data[field]){
this[field] = data[field];
};
i++;
};
if (data.creation){
this.creation = data.creation;
};
if (data.expiration){
this.expiration = data.expiration;
};
}
private function _timestamp(timespan:Number):void{
creation = new Date();
_timespan = timespan;
if (timespan > 0){
expiration = new Date((creation.valueOf() + timespan));
};
}
public function isExpired():Boolean{
var current:Date = new Date();
var diff:Number = (expiration.valueOf() - current.valueOf());
if (diff <= 0){
return (true);
};
return (false);
}
public function set expiration(value:Date):void{
_expiration = value;
}
public function get creation():Date{
return (_creation);
}
public function valueOf():String{
var field:String;
var value:*;
var data:Array = [];
var i:int;
while (i < fields.length) {
field = fields[i];
value = this[field];
if ((value is String)){
if (value == ""){
value = "-";
data.push(value);
} else {
data.push(value);
};
} else {
if ((value is Number)){
if (value == 0){
data.push(value);
} else {
if (isNaN(value)){
value = "-";
data.push(value);
} else {
data.push(value);
};
};
};
};
i++;
};
return (("" + data.join(".")));
}
public function toURLString():String{
return (((inURL + "=") + valueOf()));
}
public function get expiration():Date{
if (_expiration){
return (_expiration);
};
return (new Date((new Date().valueOf() + 1000)));
}
public function toSharedObject():Object{
var field:String;
var value:*;
var data:Object = {};
var i:int;
for (;i < fields.length;i++) {
field = fields[i];
value = this[field];
if ((value is String)){
data[field] = value;
} else {
if (value == 0){
data[field] = value;
} else {
if (isNaN(value)){
continue;
} else {
data[field] = value;
};
};
};
};
data.creation = creation;
data.expiration = expiration;
return (data);
}
public function toString(showTimestamp:Boolean=false):String{
var field:String;
var value:*;
var data:Array = [];
var len:int = fields.length;
var i:int;
for (;i < len;i++) {
field = fields[i];
value = this[field];
if ((value is String)){
data.push((((field + ": \"") + value) + "\""));
} else {
if (value == 0){
data.push(((field + ": ") + value));
} else {
if (isNaN(value)){
continue;
} else {
data.push(((field + ": ") + value));
};
};
};
};
var str = (((name.toUpperCase() + " {") + data.join(", ")) + "}");
if (showTimestamp){
str = (str + (((" creation:" + creation) + ", expiration:") + expiration));
};
return (str);
}
public function set creation(value:Date):void{
_creation = value;
}
}
}//package com.google.analytics.data
Section 169
//UTMK (com.google.analytics.data.UTMK)
package com.google.analytics.data {
public class UTMK extends UTMCookie {
private var _hash:Number;
public function UTMK(hash:Number=NaN){
super("utmk", "__utmk", ["hash"]);
this.hash = hash;
}
public function set hash(value:Number):void{
_hash = value;
update();
}
public function get hash():Number{
return (_hash);
}
}
}//package com.google.analytics.data
Section 170
//UTMV (com.google.analytics.data.UTMV)
package com.google.analytics.data {
import com.google.analytics.utils.*;
public class UTMV extends UTMCookie {
private var _domainHash:Number;
private var _value:String;
public function UTMV(domainHash:Number=NaN, value:String=""){
super("utmv", "__utmv", ["domainHash", "value"], (Timespan.twoyears * 1000));
this.domainHash = domainHash;
this.value = value;
}
override public function toURLString():String{
return (((inURL + "=") + encodeURI(valueOf())));
}
public function get value():String{
return (_value);
}
public function get domainHash():Number{
return (_domainHash);
}
public function set domainHash(value:Number):void{
_domainHash = value;
update();
}
public function set value(value:String):void{
_value = value;
update();
}
}
}//package com.google.analytics.data
Section 171
//UTMZ (com.google.analytics.data.UTMZ)
package com.google.analytics.data {
import com.google.analytics.utils.*;
public class UTMZ extends UTMCookie {
private var _campaignTracking:String;
private var _campaignCreation:Number;
private var _responseCount:Number;
private var _domainHash:Number;
private var _campaignSessions:Number;
public static var defaultTimespan:Number = Timespan.sixmonths;
public function UTMZ(domainHash:Number=NaN, campaignCreation:Number=NaN, campaignSessions:Number=NaN, responseCount:Number=NaN, campaignTracking:String=""){
super("utmz", "__utmz", ["domainHash", "campaignCreation", "campaignSessions", "responseCount", "campaignTracking"], (defaultTimespan * 1000));
this.domainHash = domainHash;
this.campaignCreation = campaignCreation;
this.campaignSessions = campaignSessions;
this.responseCount = responseCount;
this.campaignTracking = campaignTracking;
}
public function set responseCount(value:Number):void{
_responseCount = value;
update();
}
public function set domainHash(value:Number):void{
_domainHash = value;
update();
}
public function set campaignCreation(value:Number):void{
_campaignCreation = value;
update();
}
public function get campaignTracking():String{
return (_campaignTracking);
}
public function get campaignSessions():Number{
return (_campaignSessions);
}
public function get domainHash():Number{
return (_domainHash);
}
public function get responseCount():Number{
return (_responseCount);
}
public function get campaignCreation():Number{
return (_campaignCreation);
}
public function set campaignSessions(value:Number):void{
_campaignSessions = value;
update();
}
public function set campaignTracking(value:String):void{
_campaignTracking = value;
update();
}
}
}//package com.google.analytics.data
Section 172
//X10 (com.google.analytics.data.X10)
package com.google.analytics.data {
public class X10 {
private var _delimEnd:String;// = ")"
private var _minimum:int;
private var _delimSet:String;// = "*"
private var _escapeChar:String;// = "'"
private var _delimBegin:String;// = "("
private var _delimNumValue:String;// = "!"
private var _key:String;// = "k"
private var _set:Array;
private var _hasData:int;
private var _escapeCharMap:Object;
private var _projectData:Object;
private var _value:String;// = "v"
public function X10(){
_set = [_key, _value];
super();
_projectData = {};
_escapeCharMap = {};
_escapeCharMap[_escapeChar] = "'0";
_escapeCharMap[_delimEnd] = "'1";
_escapeCharMap[_delimSet] = "'2";
_escapeCharMap[_delimNumValue] = "'3";
_minimum = 1;
}
private function _setInternal(projectId:Number, type:String, num:Number, value:String):void{
if (!hasProject(projectId)){
_projectData[projectId] = {};
};
if (_projectData[projectId][type] == undefined){
_projectData[projectId][type] = [];
};
_projectData[projectId][type][num] = value;
_hasData = (_hasData + 1);
}
private function _renderProject(project:Object):String{
var i:int;
var data:Array;
var result:String = "";
var needTypeQualifier:Boolean;
var l:int = _set.length;
i = 0;
while (i < l) {
data = project[_set[i]];
if (data){
if (needTypeQualifier){
result = (result + _set[i]);
};
result = (result + _renderDataType(data));
needTypeQualifier = false;
} else {
needTypeQualifier = true;
};
i++;
};
return (result);
}
public function hasProject(projectId:Number):Boolean{
return (_projectData[projectId]);
}
public function clearKey(projectId:Number):void{
_clearInternal(projectId, _key);
}
private function _renderDataType(data:Array):String{
var str:String;
var i:int;
var result:Array = [];
i = 0;
while (i < data.length) {
if (data[i] != undefined){
str = "";
if (((!((i == _minimum))) && ((data[(i - 1)] == undefined)))){
str = (str + i.toString());
str = (str + _delimNumValue);
};
str = (str + _escapeExtensibleValue(data[i]));
result.push(str);
};
i++;
};
return (((_delimBegin + result.join(_delimSet)) + _delimEnd));
}
public function getKey(projectId:Number, num:Number):String{
return ((_getInternal(projectId, _key, num) as String));
}
public function hasData():Boolean{
return ((_hasData > 0));
}
public function renderMergedUrlString(extObject:X10=null):String{
var projectId:String;
if (!extObject){
return (renderUrlString());
};
var result:Array = [extObject.renderUrlString()];
for (projectId in _projectData) {
if (((hasProject(Number(projectId))) && (!(extObject.hasProject(Number(projectId)))))){
result.push((projectId + _renderProject(_projectData[projectId])));
};
};
return (result.join(""));
}
public function setValue(projectId:Number, num:Number, value:Number):Boolean{
if (((((!((Math.round(value) == value))) || (isNaN(value)))) || ((value == Infinity)))){
return (false);
};
_setInternal(projectId, _value, num, value.toString());
return (true);
}
public function renderUrlString():String{
var projectId:String;
var result:Array = [];
for (projectId in _projectData) {
if (hasProject(Number(projectId))){
result.push((projectId + _renderProject(_projectData[projectId])));
};
};
return (result.join(""));
}
private function _getInternal(projectId:Number, type:String, num:Number):Object{
if (((hasProject(projectId)) && (!((_projectData[projectId][type] == undefined))))){
return (_projectData[projectId][type][num]);
};
return (undefined);
}
public function setKey(projectId:Number, num:Number, value:String):Boolean{
_setInternal(projectId, _key, num, value);
return (true);
}
public function clearValue(projectId:Number):void{
_clearInternal(projectId, _value);
}
private function _clearInternal(projectId:Number, type:String):void{
var isEmpty:Boolean;
var i:int;
var l:int;
if (((hasProject(projectId)) && (!((_projectData[projectId][type] == undefined))))){
_projectData[projectId][type] = undefined;
isEmpty = true;
l = _set.length;
i = 0;
while (i < l) {
if (_projectData[projectId][_set[i]] != undefined){
isEmpty = false;
break;
};
i++;
};
if (isEmpty){
_projectData[projectId] = undefined;
_hasData = (_hasData - 1);
};
};
}
public function getValue(projectId:Number, num:Number){
var value:* = _getInternal(projectId, _value, num);
if (value == null){
return (null);
};
return (Number(value));
}
private function _escapeExtensibleValue(value:String):String{
var i:int;
var c:String;
var escaped:String;
var result:String = "";
i = 0;
while (i < value.length) {
c = value.charAt(i);
escaped = _escapeCharMap[c];
if (escaped){
result = (result + escaped);
} else {
result = (result + c);
};
i++;
};
return (result);
}
}
}//package com.google.analytics.data
Section 173
//_Style (com.google.analytics.debug._Style)
package com.google.analytics.debug {
import flash.net.*;
import flash.text.*;
public class _Style {
public var failureColor:uint;
public var borderColor:uint;
public var backgroundColor:uint;
private var _sheet:StyleSheet;
public var roundedCorner:uint;
public var warningColor:uint;
public var infoColor:uint;
public var alertColor:uint;
public var successColor:uint;
private var _loader:URLLoader;
private var _defaultSheet:String;
public function _Style(){
super();
_sheet = new StyleSheet();
_loader = new URLLoader();
_init();
}
private function _parseSheet(data:String):void{
_sheet.parseCSS(data);
}
public function get sheet():StyleSheet{
return (_sheet);
}
private function _init():void{
_defaultSheet = "";
_defaultSheet = (_defaultSheet + "a{text-decoration: underline;}\n");
_defaultSheet = (_defaultSheet + ".uiLabel{color: #000000;font-family: Arial;font-size: 12;margin-left: 2;margin-right: 2;}\n");
_defaultSheet = (_defaultSheet + ".uiWarning{color: #ffffff;font-family: Arial;font-size: 14;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + ".uiAlert{color: #ffffff;font-family: Arial;font-size: 14;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + ".uiInfo{color: #000000;font-family: Arial;font-size: 14;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + ".uiSuccess{color: #ffffff;font-family: Arial;font-size: 12;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + ".uiFailure{color: #ffffff;font-family: Arial;font-size: 12;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + ".uiAlertAction{color: #ffffff;text-align: center;font-family: Arial;font-size: 12;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + ".uiAlertTitle{color: #ffffff;font-family: Arial;font-size: 16;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + "\n");
roundedCorner = 6;
backgroundColor = 0xCCCCCC;
borderColor = 0x555555;
infoColor = 16777113;
alertColor = 0xFFCC00;
warningColor = 0xCC0000;
successColor = 0xFF00;
failureColor = 0xFF0000;
_parseSheet(_defaultSheet);
}
}
}//package com.google.analytics.debug
Section 174
//Alert (com.google.analytics.debug.Alert)
package com.google.analytics.debug {
import flash.events.*;
public class Alert extends Label {
public var autoClose:Boolean;// = true
public var actionOnNextLine:Boolean;// = true
private var _actions:Array;
public function Alert(text:String, actions:Array, tag:String="uiAlert", color:uint=0, alignement:Align=null, stickToEdge:Boolean=false, actionOnNextLine:Boolean=true){
if (color == 0){
color = Style.alertColor;
};
if (alignement == null){
alignement = Align.center;
};
super(text, tag, color, alignement, stickToEdge);
this.selectable = true;
super.mouseChildren = true;
this.buttonMode = true;
this.mouseEnabled = true;
this.useHandCursor = true;
this.actionOnNextLine = actionOnNextLine;
_actions = [];
var i:int;
while (i < actions.length) {
actions[i].container = this;
_actions.push(actions[i]);
i++;
};
}
private function _defineActions():void{
var action:AlertAction;
var str:String = "";
if (actionOnNextLine){
str = (str + "\n");
} else {
str = (str + " |");
};
str = (str + " ");
var actions:Array = [];
var i:int;
while (i < _actions.length) {
action = _actions[i];
actions.push((((("<a href=\"event:" + action.activator) + "\">") + action.name) + "</a>"));
i++;
};
str = (str + actions.join(" | "));
appendText(str, "uiAlertAction");
}
protected function isValidAction(action:String):Boolean{
var i:int;
while (i < _actions.length) {
if (action == _actions[i].activator){
return (true);
};
i++;
};
return (false);
}
override protected function layout():void{
super.layout();
_defineActions();
}
protected function getAction(name:String):AlertAction{
var i:int;
while (i < _actions.length) {
if (name == _actions[i].activator){
return (_actions[i]);
};
i++;
};
return (null);
}
protected function spaces(num:int):String{
var str:String = "";
var spc:String = " ";
var i:int;
while (i < (num + 1)) {
str = (str + spc);
i++;
};
return (str);
}
override public function onLink(event:TextEvent):void{
var action:AlertAction;
if (isValidAction(event.text)){
action = getAction(event.text);
if (action){
action.execute();
};
};
if (autoClose){
close();
};
}
public function close():void{
if (parent != null){
parent.removeChild(this);
};
}
}
}//package com.google.analytics.debug
Section 175
//AlertAction (com.google.analytics.debug.AlertAction)
package com.google.analytics.debug {
public class AlertAction {
public var container:Alert;
private var _callback;
public var activator:String;
public var name:String;
public function AlertAction(name:String, activator:String, callback){
super();
this.name = name;
this.activator = activator;
_callback = callback;
}
public function execute():void{
if (_callback){
if ((_callback is Function)){
(_callback as Function)();
} else {
if ((_callback is String)){
var _local1 = container;
_local1[_callback]();
};
};
};
}
}
}//package com.google.analytics.debug
Section 176
//Align (com.google.analytics.debug.Align)
package com.google.analytics.debug {
public class Align {
private var _value:int;
private var _name:String;
public static const bottomRight:Align = new Align(18, "bottomRight");
;
public static const right:Align = new Align(16, "right");
;
public static const left:Align = new Align(32, "left");
;
public static const topRight:Align = new Align(17, "topRight");
;
public static const bottom:Align = new Align(2, "bottom");
;
public static const bottomLeft:Align = new Align(34, "bottomLeft");
;
public static const topLeft:Align = new Align(33, "topLeft");
;
public static const center:Align = new Align(0x0100, "center");
;
public static const none:Align = new Align(0, "none");
;
public static const top:Align = new Align(1, "top");
;
public function Align(value:int=0, name:String=""){
super();
_value = value;
_name = name;
}
public function valueOf():int{
return (_value);
}
public function toString():String{
return (_name);
}
}
}//package com.google.analytics.debug
Section 177
//Background (com.google.analytics.debug.Background)
package com.google.analytics.debug {
import flash.display.*;
public class Background {
public function Background(){
super();
}
public static function drawRounded(target, g:Graphics, width:uint=0, height:uint=0):void{
var W:uint;
var H:uint;
var R:uint = Style.roundedCorner;
if ((((width > 0)) && ((height > 0)))){
W = width;
H = height;
} else {
W = target.width;
H = target.height;
};
if (((target.stickToEdge) && (!((target.alignement == Align.none))))){
switch (target.alignement){
case Align.top:
g.drawRoundRectComplex(0, 0, W, H, 0, 0, R, R);
break;
case Align.topLeft:
g.drawRoundRectComplex(0, 0, W, H, 0, 0, 0, R);
break;
case Align.topRight:
g.drawRoundRectComplex(0, 0, W, H, 0, 0, R, 0);
break;
case Align.bottom:
g.drawRoundRectComplex(0, 0, W, H, R, R, 0, 0);
break;
case Align.bottomLeft:
g.drawRoundRectComplex(0, 0, W, H, 0, R, 0, 0);
break;
case Align.bottomRight:
g.drawRoundRectComplex(0, 0, W, H, R, 0, 0, 0);
break;
case Align.left:
g.drawRoundRectComplex(0, 0, W, H, 0, R, 0, R);
break;
case Align.right:
g.drawRoundRectComplex(0, 0, W, H, R, 0, R, 0);
break;
case Align.center:
g.drawRoundRect(0, 0, W, H, R, R);
break;
};
} else {
g.drawRoundRect(0, 0, W, H, R, R);
};
}
}
}//package com.google.analytics.debug
Section 178
//Debug (com.google.analytics.debug.Debug)
package com.google.analytics.debug {
import flash.events.*;
import flash.ui.*;
public class Debug extends Label {
private var _lines:Array;
private var _preferredForcedWidth:uint;// = 540
private var _linediff:int;// = 0
public var maxLines:uint;// = 16
public static var count:uint = 0;
public function Debug(color:uint=0, alignement:Align=null, stickToEdge:Boolean=false){
if (alignement == null){
alignement = Align.bottom;
};
super("", "uiLabel", color, alignement, stickToEdge);
this.name = ("Debug" + count++);
_lines = [];
selectable = true;
addEventListener(KeyboardEvent.KEY_DOWN, onKey);
}
public function writeBold(message:String):void{
write(message, true);
}
private function _getLinesToDisplay(direction:int=0):Array{
var lines:Array;
var start:uint;
var end:uint;
if ((_lines.length - 1) > maxLines){
if ((_linediff <= 0)){
_linediff = (_linediff + direction);
} else {
if ((((_linediff > 0)) && ((direction < 0)))){
_linediff = (_linediff + direction);
};
};
start = ((_lines.length - maxLines) + _linediff);
end = (start + maxLines);
lines = _lines.slice(start, end);
} else {
lines = _lines;
};
return (lines);
}
private function onKey(event:KeyboardEvent=null):void{
var lines:Array;
switch (event.keyCode){
case Keyboard.DOWN:
lines = _getLinesToDisplay(1);
break;
case Keyboard.UP:
lines = _getLinesToDisplay(-1);
break;
default:
lines = null;
};
if (lines == null){
return;
};
text = lines.join("\n");
}
override public function get forcedWidth():uint{
if (this.parent){
if (UISprite(this.parent).forcedWidth > _preferredForcedWidth){
return (_preferredForcedWidth);
};
return (UISprite(this.parent).forcedWidth);
} else {
};
return (!NULL!);
}
public function write(message:String, bold:Boolean=false):void{
var inputLines:Array;
if (message.indexOf("") > -1){
inputLines = message.split("\n");
} else {
inputLines = [message];
};
var pre:String = "";
var post:String = "";
if (bold){
pre = "<b>";
post = "</b>";
};
var i:int;
while (i < inputLines.length) {
_lines.push(((pre + inputLines[i]) + post));
i++;
};
var lines:Array = _getLinesToDisplay();
text = lines.join("\n");
}
public function close():void{
dispose();
}
override protected function dispose():void{
removeEventListener(KeyboardEvent.KEY_DOWN, onKey);
super.dispose();
}
}
}//package com.google.analytics.debug
Section 179
//DebugConfiguration (com.google.analytics.debug.DebugConfiguration)
package com.google.analytics.debug {
import com.google.analytics.core.*;
import flash.net.*;
import flash.utils.*;
import flash.ui.*;
public class DebugConfiguration {
public var showHideKey:Number;
private var _mode:VisualDebugMode;
private var _verbose:Boolean;// = false
public var destroyKey:Number;
public var GIFRequests:Boolean;// = false
public var showInfos:Boolean;// = true
public var infoTimeout:Number;// = 1000
public var minimizedOnStart:Boolean;// = false
private var _active:Boolean;// = false
public var traceOutput:Boolean;// = false
public var layout:ILayout;
public var warningTimeout:Number;// = 1500
public var javascript:Boolean;// = false
public var showWarnings:Boolean;// = true
private var _visualInitialized:Boolean;// = false
public function DebugConfiguration(){
_mode = VisualDebugMode.basic;
showHideKey = Keyboard.SPACE;
destroyKey = Keyboard.BACKSPACE;
super();
}
public function get verbose():Boolean{
return (_verbose);
}
public function set verbose(value:Boolean):void{
_verbose = value;
}
public function set mode(value):void{
if ((value is String)){
switch (value){
case "geek":
value = VisualDebugMode.geek;
break;
case "advanced":
value = VisualDebugMode.advanced;
break;
case "basic":
default:
value = VisualDebugMode.basic;
};
};
_mode = value;
}
public function success(message:String):void{
if (layout){
layout.createSuccessAlert(message);
};
if (traceOutput){
trace((("[+] " + message) + " !!"));
};
}
public function get active():Boolean{
return (_active);
}
private function _initializeVisual():void{
if (layout){
layout.init();
_visualInitialized = true;
};
}
private function _destroyVisual():void{
if (((layout) && (_visualInitialized))){
layout.destroy();
};
}
public function warning(message:String, mode:VisualDebugMode=null):void{
if (_filter(mode)){
return;
};
if (((layout) && (showWarnings))){
layout.createWarning(message);
};
if (traceOutput){
trace((("## " + message) + " ##"));
};
}
private function _filter(mode:VisualDebugMode=null):Boolean{
return (((mode) && ((int(mode) >= int(this.mode)))));
}
public function failure(message:String):void{
if (layout){
layout.createFailureAlert(message);
};
if (traceOutput){
trace((("[-] " + message) + " !!"));
};
}
public function get mode(){
return (_mode);
}
public function set active(value:Boolean):void{
_active = value;
if (_active){
_initializeVisual();
} else {
_destroyVisual();
};
}
protected function trace(message:String):void{
var msgs:Array;
var j:int;
var messages:Array = [];
var pre0:String = "";
var pre1:String = "";
if (this.mode == VisualDebugMode.geek){
pre0 = (getTimer() + " - ");
pre1 = (new Array(pre0.length).join(" ") + " ");
};
if (message.indexOf("\n") > -1){
msgs = message.split("\n");
j = 0;
while (j < msgs.length) {
if (msgs[j] == ""){
} else {
if (j == 0){
messages.push((pre0 + msgs[j]));
} else {
messages.push((pre1 + msgs[j]));
};
};
j++;
};
} else {
messages.push((pre0 + message));
};
var len:int = messages.length;
var i:int;
while (i < len) {
trace(messages[i]);
i++;
};
}
public function alert(message:String):void{
if (layout){
layout.createAlert(message);
};
if (traceOutput){
trace((("!! " + message) + " !!"));
};
}
public function info(message:String, mode:VisualDebugMode=null):void{
if (_filter(mode)){
return;
};
if (((layout) && (showInfos))){
layout.createInfo(message);
};
if (traceOutput){
trace(message);
};
}
public function alertGifRequest(message:String, request:URLRequest, ref:GIFRequest):void{
if (layout){
layout.createGIFRequestAlert(message, request, ref);
};
if (traceOutput){
trace(((">> " + message) + " <<"));
};
}
}
}//package com.google.analytics.debug
Section 180
//FailureAlert (com.google.analytics.debug.FailureAlert)
package com.google.analytics.debug {
public class FailureAlert extends Alert {
public function FailureAlert(debug:DebugConfiguration, text:String, actions:Array){
var alignement:Align = Align.bottomLeft;
var stickToEdge:Boolean;
var actionOnNextLine:Boolean;
if (debug.verbose){
text = ((("<u><span class=\"uiAlertTitle\">Failure</span>" + spaces(18)) + "</u>\n\n") + text);
alignement = Align.center;
stickToEdge = false;
actionOnNextLine = true;
};
super(text, actions, "uiFailure", Style.failureColor, alignement, stickToEdge, actionOnNextLine);
}
}
}//package com.google.analytics.debug
Section 181
//GIFRequestAlert (com.google.analytics.debug.GIFRequestAlert)
package com.google.analytics.debug {
public class GIFRequestAlert extends Alert {
public function GIFRequestAlert(text:String, actions:Array){
super(text, actions);
}
}
}//package com.google.analytics.debug
Section 182
//ILayout (com.google.analytics.debug.ILayout)
package com.google.analytics.debug {
import flash.display.*;
import com.google.analytics.core.*;
import flash.net.*;
public interface ILayout {
function createAlert(:String):void;
function addToStage(:DisplayObject):void;
function createGIFRequestAlert(_arg1:String, _arg2:URLRequest, _arg3:GIFRequest):void;
function createWarning(:String):void;
function createPanel(_arg1:String, _arg2:uint, _arg3:uint):void;
function createInfo(:String):void;
function createFailureAlert(:String):void;
function addToPanel(_arg1:String, _arg2:DisplayObject):void;
function init():void;
function createSuccessAlert(:String):void;
function createVisualDebug():void;
function destroy():void;
function bringToFront(:DisplayObject):void;
function isAvailable():Boolean;
}
}//package com.google.analytics.debug
Section 183
//Info (com.google.analytics.debug.Info)
package com.google.analytics.debug {
import flash.events.*;
import flash.utils.*;
public class Info extends Label {
private var _timer:Timer;
public function Info(text:String="", timeout:uint=3000){
super(text, "uiInfo", Style.infoColor, Align.top, true);
if (timeout > 0){
_timer = new Timer(timeout, 1);
_timer.start();
_timer.addEventListener(TimerEvent.TIMER_COMPLETE, onComplete, false, 0, true);
};
}
public function close():void{
if (parent != null){
parent.removeChild(this);
};
}
override public function onLink(event:TextEvent):void{
switch (event.text){
case "hide":
close();
break;
};
}
public function onComplete(event:TimerEvent):void{
close();
}
}
}//package com.google.analytics.debug
Section 184
//Label (com.google.analytics.debug.Label)
package com.google.analytics.debug {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class Label extends UISprite {
private var _color:uint;
private var _background:Shape;
private var _textField:TextField;
public var stickToEdge:Boolean;
private var _text:String;
protected var selectable:Boolean;
private var _tag:String;
public static var count:uint = 0;
public function Label(text:String="", tag:String="uiLabel", color:uint=0, alignement:Align=null, stickToEdge:Boolean=false){
super();
this.name = ("Label" + count++);
selectable = false;
_background = new Shape();
_textField = new TextField();
_text = text;
_tag = tag;
if (alignement == null){
alignement = Align.none;
};
this.alignement = alignement;
this.stickToEdge = stickToEdge;
if (color == 0){
color = Style.backgroundColor;
};
_color = color;
_textField.addEventListener(TextEvent.LINK, onLink);
}
public function get tag():String{
return (_tag);
}
private function _draw():void{
var g:Graphics = _background.graphics;
g.clear();
g.beginFill(_color);
var W:uint = _textField.width;
var H:uint = _textField.height;
if (forcedWidth > 0){
W = forcedWidth;
};
Background.drawRounded(this, g, W, H);
g.endFill();
}
public function get text():String{
return (_textField.text);
}
public function appendText(value:String, newtag:String=""):void{
if (value == ""){
return;
};
if (newtag == ""){
newtag = tag;
};
_textField.htmlText = (_textField.htmlText + (((("<span class=\"" + newtag) + "\">") + value) + "</span>"));
_text = (_text + value);
_draw();
resize();
}
public function set text(value:String):void{
if (value == ""){
value = _text;
};
_textField.htmlText = (((("<span class=\"" + tag) + "\">") + value) + "</span>");
_text = value;
_draw();
resize();
}
override protected function layout():void{
_textField.type = TextFieldType.DYNAMIC;
_textField.autoSize = TextFieldAutoSize.LEFT;
_textField.background = false;
_textField.selectable = selectable;
_textField.multiline = true;
_textField.styleSheet = Style.sheet;
this.text = _text;
addChild(_background);
addChild(_textField);
}
public function set tag(value:String):void{
_tag = value;
text = "";
}
public function onLink(event:TextEvent):void{
}
override protected function dispose():void{
_textField.removeEventListener(TextEvent.LINK, onLink);
super.dispose();
}
}
}//package com.google.analytics.debug
Section 185
//Layout (com.google.analytics.debug.Layout)
package com.google.analytics.debug {
import flash.events.*;
import com.google.analytics.*;
import flash.display.*;
import com.google.analytics.core.*;
import flash.net.*;
public class Layout implements ILayout {
private var _display:DisplayObject;
private var _infoQueue:Array;
private var _maxCharPerLine:int;// = 85
private var _hasInfo:Boolean;
private var _warningQueue:Array;
private var _hasDebug:Boolean;
private var _hasWarning:Boolean;
private var _mainPanel:Panel;
private var _GRAlertQueue:Array;
private var _debug:DebugConfiguration;
public var visualDebug:Debug;
private var _hasGRAlert:Boolean;
public function Layout(debug:DebugConfiguration, display:DisplayObject){
super();
_display = display;
_debug = debug;
_hasWarning = false;
_hasInfo = false;
_hasDebug = false;
_hasGRAlert = false;
_warningQueue = [];
_infoQueue = [];
_GRAlertQueue = [];
}
private function onKey(event:KeyboardEvent=null):void{
switch (event.keyCode){
case _debug.showHideKey:
_mainPanel.visible = !(_mainPanel.visible);
break;
case _debug.destroyKey:
destroy();
break;
};
}
public function createWarning(message:String):void{
if (((_hasWarning) || (!(isAvailable())))){
_warningQueue.push(message);
return;
};
message = _filterMaxChars(message);
_hasWarning = true;
var w:Warning = new Warning(message, _debug.warningTimeout);
addToPanel("analytics", w);
w.addEventListener(Event.REMOVED_FROM_STAGE, _clearWarning, false, 0, true);
if (_hasDebug){
visualDebug.writeBold(message);
};
}
public function bringToFront(visual:DisplayObject):void{
_display.stage.setChildIndex(visual, (_display.stage.numChildren - 1));
}
public function createFailureAlert(message:String):void{
var actionClose:AlertAction;
if (_debug.verbose){
message = _filterMaxChars(message);
actionClose = new AlertAction("Close", "close", "close");
} else {
actionClose = new AlertAction("X", "close", "close");
};
var fa:Alert = new FailureAlert(_debug, message, [actionClose]);
addToPanel("analytics", fa);
if (_hasDebug){
if (_debug.verbose){
message = message.split("\n").join("");
message = _filterMaxChars(message, 66);
};
visualDebug.writeBold(message);
};
}
public function init():void{
var spaces = 10;
var W:uint = (_display.stage.stageWidth - (spaces * 2));
var H:uint = (_display.stage.stageHeight - (spaces * 2));
var mp:Panel = new Panel("analytics", W, H);
mp.alignement = Align.top;
mp.stickToEdge = false;
mp.title = ("Google Analytics v" + GATracker.version);
_mainPanel = mp;
addToStage(mp);
bringToFront(mp);
if (_debug.minimizedOnStart){
_mainPanel.onToggle();
};
createVisualDebug();
_display.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKey, false, 0, true);
}
public function addToPanel(name:String, visual:DisplayObject):void{
var panel:Panel;
var d:DisplayObject = _display.stage.getChildByName(name);
if (d){
panel = (d as Panel);
panel.addData(visual);
} else {
trace((("panel \"" + name) + "\" not found"));
};
}
private function _clearInfo(event:Event):void{
_hasInfo = false;
if (_infoQueue.length > 0){
createInfo(_infoQueue.shift());
};
}
private function _filterMaxChars(message:String, maxCharPerLine:int=0):String{
var line:String;
var CRLF:String = "\n";
var output:Array = [];
var lines:Array = message.split(CRLF);
if (maxCharPerLine == 0){
maxCharPerLine = _maxCharPerLine;
};
var i:int;
while (i < lines.length) {
line = lines[i];
while (line.length > maxCharPerLine) {
output.push(line.substr(0, maxCharPerLine));
line = line.substring(maxCharPerLine);
};
output.push(line);
i++;
};
return (output.join(CRLF));
}
private function _clearGRAlert(event:Event):void{
_hasGRAlert = false;
if (_GRAlertQueue.length > 0){
createGIFRequestAlert.apply(this, _GRAlertQueue.shift());
};
}
public function createSuccessAlert(message:String):void{
var actionClose:AlertAction;
if (_debug.verbose){
message = _filterMaxChars(message);
actionClose = new AlertAction("Close", "close", "close");
} else {
actionClose = new AlertAction("X", "close", "close");
};
var sa:Alert = new SuccessAlert(_debug, message, [actionClose]);
addToPanel("analytics", sa);
if (_hasDebug){
if (_debug.verbose){
message = message.split("\n").join("");
message = _filterMaxChars(message, 66);
};
visualDebug.writeBold(message);
};
}
public function isAvailable():Boolean{
return (!((_display.stage == null)));
}
public function createAlert(message:String):void{
message = _filterMaxChars(message);
var a:Alert = new Alert(message, [new AlertAction("Close", "close", "close")]);
addToPanel("analytics", a);
if (_hasDebug){
visualDebug.writeBold(message);
};
}
public function createInfo(message:String):void{
if (((_hasInfo) || (!(isAvailable())))){
_infoQueue.push(message);
return;
};
message = _filterMaxChars(message);
_hasInfo = true;
var i:Info = new Info(message, _debug.infoTimeout);
addToPanel("analytics", i);
i.addEventListener(Event.REMOVED_FROM_STAGE, _clearInfo, false, 0, true);
if (_hasDebug){
visualDebug.write(message);
};
}
public function createGIFRequestAlert(message:String, request:URLRequest, ref:GIFRequest):void{
var message = message;
var request = request;
var ref = ref;
if (_hasGRAlert){
_GRAlertQueue.push([message, request, ref]);
return;
};
_hasGRAlert = true;
var f:Function = function ():void{
ref.sendRequest(request);
};
message = _filterMaxChars(message);
var gra:GIFRequestAlert = new GIFRequestAlert(message, [new AlertAction("OK", "ok", f), new AlertAction("Cancel", "cancel", "close")]);
addToPanel("analytics", gra);
gra.addEventListener(Event.REMOVED_FROM_STAGE, _clearGRAlert, false, 0, true);
if (_hasDebug){
if (_debug.verbose){
message = message.split("\n").join("");
message = _filterMaxChars(message, 66);
};
visualDebug.write(message);
};
}
public function createVisualDebug():void{
if (!visualDebug){
visualDebug = new Debug();
visualDebug.alignement = Align.bottom;
visualDebug.stickToEdge = true;
addToPanel("analytics", visualDebug);
_hasDebug = true;
};
}
public function addToStage(visual:DisplayObject):void{
_display.stage.addChild(visual);
}
private function _clearWarning(event:Event):void{
_hasWarning = false;
if (_warningQueue.length > 0){
createWarning(_warningQueue.shift());
};
}
public function createPanel(name:String, width:uint, height:uint):void{
var p:Panel = new Panel(name, width, height);
p.alignement = Align.center;
p.stickToEdge = false;
addToStage(p);
bringToFront(p);
}
public function destroy():void{
_mainPanel.close();
_debug.layout = null;
}
}
}//package com.google.analytics.debug
Section 186
//Margin (com.google.analytics.debug.Margin)
package com.google.analytics.debug {
public class Margin {
public var top:int;
public var left:int;
public var bottom:int;
public var right:int;
public function Margin(top:int=0, bottom:int=0, left:int=0, right:int=0){
super();
this.top = top;
this.bottom = bottom;
this.left = left;
this.right = right;
}
}
}//package com.google.analytics.debug
Section 187
//Panel (com.google.analytics.debug.Panel)
package com.google.analytics.debug {
import flash.events.*;
import flash.display.*;
public class Panel extends UISprite {
private var _savedH:uint;
private var _data:UISprite;
private var _mask:Sprite;
private var _background:Shape;
private var _savedW:uint;
private var _stickToEdge:Boolean;
private var _border:Shape;
private var _borderColor:uint;
protected var baseAlpha:Number;
private var _backgroundColor:uint;
private var _title:Label;
private var _colapsed:Boolean;
private var _name:String;
public function Panel(name:String, width:uint, height:uint, backgroundColor:uint=0, borderColor:uint=0, baseAlpha:Number=0.3, alignement:Align=null, stickToEdge:Boolean=false){
super();
_name = name;
this.name = name;
this.mouseEnabled = false;
_colapsed = false;
forcedWidth = width;
forcedHeight = height;
this.baseAlpha = baseAlpha;
_background = new Shape();
_data = new UISprite();
_data.forcedWidth = width;
_data.forcedHeight = height;
_data.mouseEnabled = false;
_title = new Label(name, "uiLabel", 0xFFFFFF, Align.topLeft, stickToEdge);
_title.buttonMode = true;
_title.margin.top = 0.6;
_title.margin.left = 0.6;
_title.addEventListener(MouseEvent.CLICK, onToggle);
_title.mouseChildren = false;
_border = new Shape();
_mask = new Sprite();
_mask.useHandCursor = false;
_mask.mouseEnabled = false;
_mask.mouseChildren = false;
if (alignement == null){
alignement = Align.none;
};
this.alignement = alignement;
this.stickToEdge = stickToEdge;
if (backgroundColor == 0){
backgroundColor = Style.backgroundColor;
};
_backgroundColor = backgroundColor;
if (borderColor == 0){
borderColor = Style.borderColor;
};
_borderColor = borderColor;
}
public function get stickToEdge():Boolean{
return (_stickToEdge);
}
public function onToggle(event:MouseEvent=null):void{
if (_colapsed){
_data.visible = true;
} else {
_data.visible = false;
};
_colapsed = !(_colapsed);
_update();
resize();
}
public function set stickToEdge(value:Boolean):void{
_stickToEdge = value;
_title.stickToEdge = value;
}
override protected function dispose():void{
_title.removeEventListener(MouseEvent.CLICK, onToggle);
super.dispose();
}
private function _draw():void{
var W:uint;
var H:uint;
if (((_savedW) && (_savedH))){
forcedWidth = _savedW;
forcedHeight = _savedH;
};
if (!_colapsed){
W = forcedWidth;
H = forcedHeight;
} else {
W = _title.width;
H = _title.height;
_savedW = forcedWidth;
_savedH = forcedHeight;
forcedWidth = W;
forcedHeight = H;
};
var g0:Graphics = _background.graphics;
g0.clear();
g0.beginFill(_backgroundColor);
Background.drawRounded(this, g0, W, H);
g0.endFill();
var g01:Graphics = _data.graphics;
g01.clear();
g01.beginFill(_backgroundColor, 0);
Background.drawRounded(this, g01, W, H);
g01.endFill();
var g1:Graphics = _border.graphics;
g1.clear();
g1.lineStyle(0.1, _borderColor);
Background.drawRounded(this, g1, W, H);
g1.endFill();
var g2:Graphics = _mask.graphics;
g2.clear();
g2.beginFill(_backgroundColor);
Background.drawRounded(this, g2, (W + 1), (H + 1));
g2.endFill();
}
public function get title():String{
return (_title.text);
}
private function _update():void{
_draw();
if (baseAlpha < 1){
_background.alpha = baseAlpha;
_border.alpha = baseAlpha;
};
}
public function addData(child:DisplayObject):void{
_data.addChild(child);
}
override protected function layout():void{
_update();
addChild(_background);
addChild(_data);
addChild(_title);
addChild(_border);
addChild(_mask);
mask = _mask;
}
public function set title(value:String):void{
_title.text = value;
}
public function close():void{
dispose();
if (parent != null){
parent.removeChild(this);
};
}
}
}//package com.google.analytics.debug
Section 188
//Style (com.google.analytics.debug.Style)
package com.google.analytics.debug {
public const Style:_Style = new _Style();
}//package com.google.analytics.debug
Section 189
//SuccessAlert (com.google.analytics.debug.SuccessAlert)
package com.google.analytics.debug {
public class SuccessAlert extends Alert {
public function SuccessAlert(debug:DebugConfiguration, text:String, actions:Array){
var alignement:Align = Align.bottomLeft;
var stickToEdge:Boolean;
var actionOnNextLine:Boolean;
if (debug.verbose){
text = ((("<u><span class=\"uiAlertTitle\">Success</span>" + spaces(18)) + "</u>\n\n") + text);
alignement = Align.center;
stickToEdge = false;
actionOnNextLine = true;
};
super(text, actions, "uiSuccess", Style.successColor, alignement, stickToEdge, actionOnNextLine);
}
}
}//package com.google.analytics.debug
Section 190
//UISprite (com.google.analytics.debug.UISprite)
package com.google.analytics.debug {
import flash.events.*;
import flash.display.*;
public class UISprite extends Sprite {
private var _forcedWidth:uint;
public var margin:Margin;
protected var alignTarget:DisplayObject;
protected var listenResize:Boolean;
public var alignement:Align;
private var _forcedHeight:uint;
public function UISprite(alignTarget:DisplayObject=null){
super();
listenResize = false;
alignement = Align.none;
this.alignTarget = alignTarget;
margin = new Margin();
addEventListener(Event.ADDED_TO_STAGE, _onAddedToStage);
addEventListener(Event.REMOVED_FROM_STAGE, _onRemovedFromStage);
}
public function get forcedHeight():uint{
if (_forcedHeight){
return (_forcedHeight);
};
return (height);
}
private function _onAddedToStage(event:Event):void{
layout();
resize();
}
protected function dispose():void{
var d:DisplayObject;
var i:int;
while (i < numChildren) {
d = getChildAt(i);
if (d){
removeChild(d);
};
i++;
};
}
public function set forcedHeight(value:uint):void{
_forcedHeight = value;
}
public function set forcedWidth(value:uint):void{
_forcedWidth = value;
}
protected function layout():void{
}
public function get forcedWidth():uint{
if (_forcedWidth){
return (_forcedWidth);
};
return (width);
}
public function alignTo(alignement:Align, target:DisplayObject=null):void{
var H:uint;
var W:uint;
var X:uint;
var Y:uint;
var t:UISprite;
if (target == null){
if ((parent is Stage)){
target = this.stage;
} else {
target = parent;
};
};
if (target == this.stage){
if (this.stage == null){
return;
};
H = this.stage.stageHeight;
W = this.stage.stageWidth;
X = 0;
Y = 0;
} else {
t = (target as UISprite);
if (t.forcedHeight){
H = t.forcedHeight;
} else {
H = t.height;
};
if (t.forcedWidth){
W = t.forcedWidth;
} else {
W = t.width;
};
X = 0;
Y = 0;
};
switch (alignement){
case Align.top:
x = ((W / 2) - (forcedWidth / 2));
y = (Y + margin.top);
break;
case Align.bottom:
x = ((W / 2) - (forcedWidth / 2));
y = (((Y + H) - forcedHeight) - margin.bottom);
break;
case Align.left:
x = (X + margin.left);
y = ((H / 2) - (forcedHeight / 2));
break;
case Align.right:
x = (((X + W) - forcedWidth) - margin.right);
y = ((H / 2) - (forcedHeight / 2));
break;
case Align.center:
x = ((W / 2) - (forcedWidth / 2));
y = ((H / 2) - (forcedHeight / 2));
break;
case Align.topLeft:
x = (X + margin.left);
y = (Y + margin.top);
break;
case Align.topRight:
x = (((X + W) - forcedWidth) - margin.right);
y = (Y + margin.top);
break;
case Align.bottomLeft:
x = (X + margin.left);
y = (((Y + H) - forcedHeight) - margin.bottom);
break;
case Align.bottomRight:
x = (((X + W) - forcedWidth) - margin.right);
y = (((Y + H) - forcedHeight) - margin.bottom);
break;
};
if (((!(listenResize)) && (!((alignement == Align.none))))){
target.addEventListener(Event.RESIZE, onResize, false, 0, true);
listenResize = true;
};
this.alignement = alignement;
this.alignTarget = target;
}
private function _onRemovedFromStage(event:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, _onAddedToStage);
removeEventListener(Event.REMOVED_FROM_STAGE, _onRemovedFromStage);
dispose();
}
public function resize():void{
if (alignement != Align.none){
alignTo(alignement, alignTarget);
};
}
protected function onResize(event:Event):void{
resize();
}
}
}//package com.google.analytics.debug
Section 191
//Warning (com.google.analytics.debug.Warning)
package com.google.analytics.debug {
import flash.events.*;
import flash.utils.*;
public class Warning extends Label {
private var _timer:Timer;
public function Warning(text:String="", timeout:uint=3000){
super(text, "uiWarning", Style.warningColor, Align.top, false);
margin.top = 32;
if (timeout > 0){
_timer = new Timer(timeout, 1);
_timer.start();
_timer.addEventListener(TimerEvent.TIMER_COMPLETE, onComplete, false, 0, true);
};
}
public function close():void{
if (parent != null){
parent.removeChild(this);
};
}
override public function onLink(event:TextEvent):void{
switch (event.text){
case "hide":
close();
break;
};
}
public function onComplete(event:TimerEvent):void{
close();
}
}
}//package com.google.analytics.debug
Section 192
//VisualDebugMode (com.google.analytics.debug.VisualDebugMode)
package com.google.analytics.debug {
public class VisualDebugMode {
private var _value:int;
private var _name:String;
public static const advanced:VisualDebugMode = new VisualDebugMode(1, "advanced");
;
public static const geek:VisualDebugMode = new VisualDebugMode(2, "geek");
;
public static const basic:VisualDebugMode = new VisualDebugMode(0, "basic");
;
public function VisualDebugMode(value:int=0, name:String=""){
super();
_value = value;
_name = name;
}
public function valueOf():int{
return (_value);
}
public function toString():String{
return (_name);
}
}
}//package com.google.analytics.debug
Section 193
//AnalyticsEvent (com.google.analytics.events.AnalyticsEvent)
package com.google.analytics.events {
import flash.events.*;
import com.google.analytics.*;
public class AnalyticsEvent extends Event {
public var tracker:AnalyticsTracker;
public static const READY:String = "ready";
public function AnalyticsEvent(type:String, tracker:AnalyticsTracker, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
this.tracker = tracker;
}
override public function clone():Event{
return (new AnalyticsEvent(type, tracker, bubbles, cancelable));
}
}
}//package com.google.analytics.events
Section 194
//AdSenseGlobals (com.google.analytics.external.AdSenseGlobals)
package com.google.analytics.external {
import com.google.analytics.debug.*;
public class AdSenseGlobals extends JavascriptProxy {
private var _gaGlobalVerified:Boolean;// = false
public static var gaGlobal_js:XML = <script>
<![CDATA[
function()
{
try
{
gaGlobal
}
catch(e)
{
gaGlobal = {} ;
}
}
]]>
</script>
;
public function AdSenseGlobals(debug:DebugConfiguration){
super(debug);
}
public function set vid(value:String):void{
if (!isAvailable()){
return;
};
_verify();
setProperty("gaGlobal.vid", value);
}
public function get hid():String{
if (!isAvailable()){
return (null);
};
_verify();
return (getProperty("gaGlobal.hid"));
}
public function set hid(value:String):void{
if (!isAvailable()){
return;
};
_verify();
setProperty("gaGlobal.hid", value);
}
public function get dh():String{
if (!isAvailable()){
return (null);
};
_verify();
return (getProperty("gaGlobal.dh"));
}
public function get sid():String{
if (!isAvailable()){
return (null);
};
_verify();
return (getProperty("gaGlobal.sid"));
}
public function get vid():String{
if (!isAvailable()){
return (null);
};
_verify();
return (getProperty("gaGlobal.vid"));
}
private function _verify():void{
if (!_gaGlobalVerified){
executeBlock(gaGlobal_js);
_gaGlobalVerified = true;
};
}
public function set sid(value:String):void{
if (!isAvailable()){
return;
};
_verify();
setProperty("gaGlobal.sid", value);
}
public function get gaGlobal():Object{
if (!isAvailable()){
return (null);
};
_verify();
return (getProperty("gaGlobal"));
}
}
}//package com.google.analytics.external
Section 195
//HTMLDOM (com.google.analytics.external.HTMLDOM)
package com.google.analytics.external {
import com.google.analytics.debug.*;
public class HTMLDOM extends JavascriptProxy {
private var _referrer:String;
private var _language:String;
private var _host:String;
private var _pathname:String;
private var _location:String;
private var _search:String;
private var _characterSet:String;
private var _title:String;
private var _protocol:String;
private var _colorDepth:String;
public static var cache_properties_js:XML = <script>
<![CDATA[
function()
{
var obj = {};
obj.host = document.location.host;
obj.language = navigator.language ? navigator.language : navigator.browserLanguage;
obj.characterSet = document.characterSet ? document.characterSet : document.charset;
obj.colorDepth = window.screen.colorDepth;
obj.location = document.location.toString();
obj.pathname = document.location.pathname;
obj.protocol = document.location.protocol;
obj.search = document.location.search;
obj.referrer = document.referrer;
obj.title = document.title;
return obj;
}
]]>
</script>
;
public function HTMLDOM(debug:DebugConfiguration){
super(debug);
}
public function get search():String{
if (_search){
return (_search);
};
if (!isAvailable()){
return (null);
};
_search = getProperty("document.location.search");
return (_search);
}
public function get location():String{
if (_location){
return (_location);
};
if (!isAvailable()){
return (null);
};
_location = getPropertyString("document.location");
return (_location);
}
public function get pathname():String{
if (_pathname){
return (_pathname);
};
if (!isAvailable()){
return (null);
};
_pathname = getProperty("document.location.pathname");
return (_pathname);
}
public function cacheProperties():void{
if (!isAvailable()){
return;
};
var obj:Object = call(cache_properties_js);
if (obj){
_host = obj.host;
_language = obj.language;
_characterSet = obj.characterSet;
_colorDepth = obj.colorDepth;
_location = obj.location;
_pathname = obj.pathname;
_protocol = obj.protocol;
_search = obj.search;
_referrer = obj.referrer;
_title = obj.title;
};
}
public function get language():String{
if (_language){
return (_language);
};
if (!isAvailable()){
return (null);
};
var lang:String = getProperty("navigator.language");
if (lang == null){
lang = getProperty("navigator.browserLanguage");
};
_language = lang;
return (_language);
}
public function get colorDepth():String{
if (_colorDepth){
return (_colorDepth);
};
if (!isAvailable()){
return (null);
};
_colorDepth = getProperty("window.screen.colorDepth");
return (_colorDepth);
}
public function get referrer():String{
if (_referrer){
return (_referrer);
};
if (!isAvailable()){
return (null);
};
_referrer = getProperty("document.referrer");
return (_referrer);
}
public function get protocol():String{
if (_protocol){
return (_protocol);
};
if (!isAvailable()){
return (null);
};
_protocol = getProperty("document.location.protocol");
return (_protocol);
}
public function get host():String{
if (_host){
return (_host);
};
if (!isAvailable()){
return (null);
};
_host = getProperty("document.location.host");
return (_host);
}
public function get characterSet():String{
if (_characterSet){
return (_characterSet);
};
if (!isAvailable()){
return (null);
};
var cs:String = getProperty("document.characterSet");
if (cs == null){
cs = getProperty("document.charset");
};
_characterSet = cs;
return (_characterSet);
}
public function get title():String{
if (_title){
return (_title);
};
if (!isAvailable()){
return (null);
};
_title = getProperty("document.title");
return (_title);
}
}
}//package com.google.analytics.external
Section 196
//JavascriptProxy (com.google.analytics.external.JavascriptProxy)
package com.google.analytics.external {
import com.google.analytics.debug.*;
import flash.system.*;
import flash.external.*;
public class JavascriptProxy {
private var _notAvailableWarning:Boolean;// = true
private var _debug:DebugConfiguration;
public static var setProperty_js:XML = <script>
<![CDATA[
function( path , value )
{
var paths;
var prop;
if( path.indexOf(".") > 0 )
{
paths = path.split(".");
prop = paths.pop() ;
}
else
{
paths = [];
prop = path;
}
var target = window ;
var len = paths.length ;
for( var i = 0 ; i < len ; i++ )
{
target = target[ paths[i] ] ;
}
target[ prop ] = value ;
}
]]>
</script>
;
public static var hasProperty_js:XML = <script>
<![CDATA[
function( path )
{
var paths;
if( path.indexOf(".") > 0 )
{
paths = path.split(".");
}
else
{
paths = [path];
}
var target = window ;
var len = paths.length ;
for( var i = 0 ; i < len ; i++ )
{
target = target[ paths[i] ] ;
}
if( target )
{
return true;
}
else
{
return false;
}
}
]]>
</script>
;
public static var setPropertyRef_js:XML = <script>
<![CDATA[
function( path , target )
{
var paths;
var prop;
if( path.indexOf(".") > 0 )
{
paths = path.split(".");
prop = paths.pop() ;
}
else
{
paths = [];
prop = path;
}
alert( "paths:"+paths.length+", prop:"+prop );
var targets;
var name;
if( target.indexOf(".") > 0 )
{
targets = target.split(".");
name = targets.pop();
}
else
{
targets = [];
name = target;
}
alert( "targets:"+targets.length+", name:"+name );
var root = window;
var len = paths.length;
for( var i = 0 ; i < len ; i++ )
{
root = root[ paths[i] ] ;
}
var ref = window;
var depth = targets.length;
for( var j = 0 ; j < depth ; j++ )
{
ref = ref[ targets[j] ] ;
}
root[ prop ] = ref[name] ;
}
]]>
</script>
;
public function JavascriptProxy(debug:DebugConfiguration){
super();
_debug = debug;
}
public function getProperty(name:String){
return (call((name + ".valueOf")));
}
public function hasProperty(path:String):Boolean{
return (call(hasProperty_js, path));
}
public function setProperty(path:String, value):void{
call(setProperty_js, path, value);
}
public function executeBlock(data:String):void{
var data = data;
if (isAvailable()){
ExternalInterface.call(data);
//unresolved jump
var _slot1 = e;
if (_debug.javascript){
_debug.warning("ExternalInterface is not allowed.\nEnsure that allowScriptAccess is set to \"always\" in the Flash embed HTML.");
};
//unresolved jump
var _slot1 = e;
if (_debug.javascript){
_debug.warning(("ExternalInterface failed to make the call\nreason: " + _slot1.message));
};
};
}
public function getPropertyString(name:String):String{
return (call((name + ".toString")));
}
public function setPropertyByReference(path:String, target:String):void{
call(setPropertyRef_js, path, target);
}
public function call(functionName:String, ... _args){
var output:String;
var functionName = functionName;
var args = _args;
if (isAvailable()){
if (((_debug.javascript) && (_debug.verbose))){
output = "";
output = ("Flash->JS: " + functionName);
output = (output + "( ");
if (args.length > 0){
output = (output + args.join(","));
};
output = (output + " )");
_debug.info(output);
};
args.unshift(functionName);
return (ExternalInterface.call.apply(ExternalInterface, args));
//unresolved jump
var _slot1 = e;
if (_debug.javascript){
_debug.warning("ExternalInterface is not allowed.\nEnsure that allowScriptAccess is set to \"always\" in the Flash embed HTML.");
};
//unresolved jump
var _slot1 = e;
if (_debug.javascript){
_debug.warning(("ExternalInterface failed to make the call\nreason: " + _slot1.message));
};
};
return (null);
}
public function isAvailable():Boolean{
var available:Boolean = ExternalInterface.available;
if (((available) && ((Capabilities.playerType == "External")))){
available = false;
};
if (((((!(available)) && (_debug.javascript))) && (_notAvailableWarning))){
_debug.warning("ExternalInterface is not available.");
_notAvailableWarning = false;
};
return (available);
}
}
}//package com.google.analytics.external
Section 197
//Environment (com.google.analytics.utils.Environment)
package com.google.analytics.utils {
import com.google.analytics.debug.*;
import com.google.analytics.external.*;
import flash.system.*;
public class Environment {
private var _dom:HTMLDOM;
private var _appName:String;
private var _debug:DebugConfiguration;
private var _appVersion:Version;
private var _url:String;
private var _protocol:Protocols;
private var _userAgent:UserAgent;
public function Environment(url:String="", app:String="", version:String="", debug:DebugConfiguration=null, dom:HTMLDOM=null){
var v:Version;
super();
if (app == ""){
if (isAIR()){
app = "AIR";
} else {
app = "Flash";
};
};
if (version == ""){
v = flashVersion;
} else {
v = Version.fromString(version);
};
_url = url;
_appName = app;
_appVersion = v;
_debug = debug;
_dom = dom;
}
public function isAIR():Boolean{
return ((((playerType == "Desktop")) && ((Security.sandboxType.toString() == "application"))));
}
public function get screenWidth():Number{
return (Capabilities.screenResolutionX);
}
public function get playerType():String{
return (Capabilities.playerType);
}
public function get locationSearch():String{
var _search:String = _dom.search;
if (_search){
return (_search);
};
return ("");
}
public function get protocol():Protocols{
if (!_protocol){
_findProtocol();
};
return (_protocol);
}
public function get flashVersion():Version{
var v:Version = Version.fromString(Capabilities.version.split(" ")[1], ",");
return (v);
}
public function get userAgent():UserAgent{
if (!_userAgent){
_userAgent = new UserAgent(this, appName, appVersion.toString(4));
};
return (_userAgent);
}
public function get languageEncoding():String{
var _charset:String;
if (System.useCodePage){
_charset = _dom.characterSet;
if (_charset){
return (_charset);
};
return ("-");
};
return ("UTF-8");
}
public function get appName():String{
return (_appName);
}
public function get screenColorDepth():String{
var color:String;
switch (Capabilities.screenColor){
case "bw":
color = "1";
break;
case "gray":
color = "2";
break;
case "color":
default:
color = "24";
};
var _colorDepth:String = _dom.colorDepth;
if (_colorDepth){
color = _colorDepth;
};
return (color);
}
private function _findProtocol():void{
var URL:String;
var test:String;
var p:Protocols = Protocols.none;
if (_url != ""){
URL = _url.toLowerCase();
test = URL.substr(0, 5);
switch (test){
case "file:":
p = Protocols.file;
break;
case "http:":
p = Protocols.HTTP;
break;
case "https":
if (URL.charAt(5) == ":"){
p = Protocols.HTTPS;
};
break;
default:
_protocol = Protocols.none;
};
};
var _proto:String = _dom.protocol;
var proto:String = (p.toString() + ":").toLowerCase();
if (((((_proto) && (!((_proto == proto))))) && (_debug))){
_debug.warning(((("Protocol mismatch: SWF=" + proto) + ", DOM=") + _proto));
};
_protocol = p;
}
public function get locationSWFPath():String{
return (_url);
}
public function get platform():String{
var p:String = Capabilities.manufacturer;
return (p.split("Adobe ")[1]);
}
public function get operatingSystem():String{
return (Capabilities.os);
}
public function set appName(value:String):void{
_appName = value;
userAgent.applicationProduct = value;
}
function set url(value:String):void{
_url = value;
}
public function get referrer():String{
var _referrer:String = _dom.referrer;
if (_referrer){
return (_referrer);
};
if (protocol == Protocols.file){
return ("localhost");
};
return ("");
}
public function isInHTML():Boolean{
return ((Capabilities.playerType == "PlugIn"));
}
public function get language():String{
var _lang:String = _dom.language;
var lang:String = Capabilities.language;
if (_lang){
if ((((_lang.length > lang.length)) && ((_lang.substr(0, lang.length) == lang)))){
lang = _lang;
};
};
return (lang);
}
public function get domainName():String{
var URL:String;
var str:String;
var end:int;
if ((((protocol == Protocols.HTTP)) || ((protocol == Protocols.HTTPS)))){
URL = _url.toLowerCase();
if (protocol == Protocols.HTTP){
str = URL.split("http://").join("");
} else {
if (protocol == Protocols.HTTPS){
str = URL.split("https://").join("");
};
};
end = str.indexOf("/");
if (end > -1){
str = str.substring(0, end);
};
return (str);
};
if (protocol == Protocols.file){
return ("localhost");
};
return ("");
}
public function set userAgent(custom:UserAgent):void{
_userAgent = custom;
}
public function set appVersion(value:Version):void{
_appVersion = value;
userAgent.applicationVersion = value.toString(4);
}
public function get screenHeight():Number{
return (Capabilities.screenResolutionY);
}
public function get locationPath():String{
var _pathname:String = _dom.pathname;
if (_pathname){
return (_pathname);
};
return ("");
}
public function get documentTitle():String{
var _title:String = _dom.title;
if (_title){
return (_title);
};
return ("");
}
public function get appVersion():Version{
return (_appVersion);
}
}
}//package com.google.analytics.utils
Section 198
//Protocols (com.google.analytics.utils.Protocols)
package com.google.analytics.utils {
public class Protocols {
private var _value:int;
private var _name:String;
public static const none:Protocols = new Protocols(0, "none");
;
public static const HTTPS:Protocols = new Protocols(3, "HTTPS");
;
public static const file:Protocols = new Protocols(1, "file");
;
public static const HTTP:Protocols = new Protocols(2, "HTTP");
;
public function Protocols(value:int=0, name:String=""){
super();
_value = value;
_name = name;
}
public function valueOf():int{
return (_value);
}
public function toString():String{
return (_name);
}
}
}//package com.google.analytics.utils
Section 199
//Timespan (com.google.analytics.utils.Timespan)
package com.google.analytics.utils {
public class Timespan {
public static var sixmonths:Number = 15768000;
public static var twoyears:Number = 63072000;
public static var thirtyminutes:Number = 1800;
public function Timespan(){
super();
}
}
}//package com.google.analytics.utils
Section 200
//URL (com.google.analytics.utils.URL)
package com.google.analytics.utils {
public class URL {
private var _url:String;
public function URL(url:String=""){
super();
_url = url.toLowerCase();
}
public function get domain():String{
var parts:Array;
if (((!((hostName == ""))) && ((hostName.indexOf(".") > -1)))){
parts = hostName.split(".");
switch (parts.length){
case 2:
return (hostName);
case 3:
if (parts[1] == "co"){
return (hostName);
};
parts.shift();
return (parts.join("."));
case 4:
parts.shift();
return (parts.join("."));
};
};
return ("");
}
public function get path():String{
var _path:String = _url;
if (_path.indexOf("://") > -1){
_path = _path.split("://")[1];
};
if (_path.indexOf(hostName) == 0){
_path = _path.substr(hostName.length);
};
if (_path.indexOf("?") > -1){
_path = _path.split("?")[0];
};
if (_path.charAt(0) != "/"){
_path = ("/" + _path);
};
return (_path);
}
public function get protocol():Protocols{
var proto:String = _url.split("://")[0];
switch (proto){
case "file":
return (Protocols.file);
case "http":
return (Protocols.HTTP);
case "https":
return (Protocols.HTTPS);
default:
return (Protocols.none);
};
}
public function get hostName():String{
var hostname:String = _url;
if (hostname.indexOf("://") > -1){
hostname = hostname.split("://")[1];
};
if (hostname.indexOf("/") > -1){
hostname = hostname.split("/")[0];
};
if (hostname.indexOf("?") > -1){
hostname = hostname.split("?")[0];
};
if ((((protocol == Protocols.file)) || ((protocol == Protocols.none)))){
return ("");
};
return (hostname);
}
public function get subDomain():String{
if (((!((domain == ""))) && (!((domain == hostName))))){
return (hostName.split(("." + domain)).join(""));
};
return ("");
}
public function get search():String{
var _search:String = _url;
if (_search.indexOf("://") > -1){
_search = _search.split("://")[1];
};
if (_search.indexOf(hostName) == 0){
_search = _search.substr(hostName.length);
};
if (_search.indexOf("?") > -1){
_search = _search.split("?")[1];
} else {
_search = "";
};
return (_search);
}
}
}//package com.google.analytics.utils
Section 201
//UserAgent (com.google.analytics.utils.UserAgent)
package com.google.analytics.utils {
import com.google.analytics.core.*;
import flash.system.*;
public class UserAgent {
private var _localInfo:Environment;
private var _applicationProduct:String;
private var _version:Version;
public static var minimal:Boolean = false;
public function UserAgent(localInfo:Environment, product:String="", version:String=""){
super();
_localInfo = localInfo;
applicationProduct = product;
_version = Version.fromString(version);
}
public function get tamarinProductToken():String{
if (UserAgent.minimal){
return ("");
};
if (System.vmVersion){
return (("Tamarin/" + Utils.trim(System.vmVersion, true)));
};
return ("");
}
public function get applicationVersion():String{
return (_version.toString(2));
}
public function get vendorProductToken():String{
var vp:String = "";
if (_localInfo.isAIR()){
vp = (vp + "AIR");
} else {
vp = (vp + "FlashPlayer");
};
vp = (vp + "/");
vp = (vp + _version.toString(3));
return (vp);
}
public function toString():String{
var UA:String = "";
UA = (UA + applicationProductToken);
if (applicationComment != ""){
UA = (UA + (" " + applicationComment));
};
if (tamarinProductToken != ""){
UA = (UA + (" " + tamarinProductToken));
};
if (vendorProductToken != ""){
UA = (UA + (" " + vendorProductToken));
};
return (UA);
}
public function get applicationComment():String{
var comment:Array = [];
comment.push(_localInfo.platform);
comment.push(_localInfo.playerType);
if (!UserAgent.minimal){
comment.push(_localInfo.operatingSystem);
comment.push(_localInfo.language);
};
if (Capabilities.isDebugger){
comment.push("DEBUG");
};
if (comment.length > 0){
return ((("(" + comment.join("; ")) + ")"));
};
return ("");
}
public function set applicationVersion(value:String):void{
_version = Version.fromString(value);
}
public function get applicationProductToken():String{
var token:String = applicationProduct;
if (applicationVersion != ""){
token = (token + ("/" + applicationVersion));
};
return (token);
}
public function set applicationProduct(value:String):void{
_applicationProduct = value;
}
public function get applicationProduct():String{
return (_applicationProduct);
}
}
}//package com.google.analytics.utils
Section 202
//Variables (com.google.analytics.utils.Variables)
package com.google.analytics.utils {
import flash.net.*;
public dynamic class Variables {
public var post:Array;
public var URIencode:Boolean;
public var pre:Array;
public var sort:Boolean;// = true
public function Variables(source:String=null, pre:Array=null, post:Array=null){
pre = [];
post = [];
super();
if (source){
decode(source);
};
if (pre){
this.pre = pre;
};
if (post){
this.post = post;
};
}
private function _join(vars:Variables):void{
var prop:String;
if (!vars){
return;
};
for (prop in vars) {
this[prop] = vars[prop];
};
}
public function join(... _args):void{
var l:int = _args.length;
var i:int;
while (i < l) {
if (!(_args[i] is Variables)){
} else {
_join(_args[i]);
};
i++;
};
}
public function toString():String{
var value:String;
var p:String;
var component:String;
var i:int;
var j:int;
var priority:String;
var last:String;
var data:Array = [];
for (p in this) {
value = this[p];
if (URIencode){
value = encodeURI(value);
};
data.push(((p + "=") + value));
};
if (sort){
data.sort();
};
if (pre.length > 0){
pre.reverse();
i = 0;
while (i < pre.length) {
priority = pre[i];
j = 0;
while (j < data.length) {
component = data[j];
if (component.indexOf(priority) == 0){
data.unshift(data.splice(j, 1)[0]);
};
j++;
};
i++;
};
pre.reverse();
};
if (post.length > 0){
i = 0;
while (i < post.length) {
last = post[i];
j = 0;
while (j < data.length) {
component = data[j];
if (component.indexOf(last) == 0){
data.push(data.splice(j, 1)[0]);
};
j++;
};
i++;
};
};
return (data.join("&"));
}
public function decode(source:String):void{
var data:Array;
var prop:String;
var name:String;
var value:String;
var tmp:Array;
if (source == ""){
return;
};
if (source.indexOf("&") > -1){
data = source.split("&");
} else {
data = [source];
};
var i:int;
while (i < data.length) {
prop = data[i];
if (prop.indexOf("=") > -1){
tmp = prop.split("=");
name = tmp[0];
value = decodeURI(tmp[1]);
this[name] = value;
};
i++;
};
}
public function toURLVariables():URLVariables{
var p:String;
var urlvars:URLVariables = new URLVariables();
for (p in this) {
urlvars[p] = this[p];
};
return (urlvars);
}
}
}//package com.google.analytics.utils
Section 203
//Version (com.google.analytics.utils.Version)
package com.google.analytics.utils {
public class Version {
private var _revision:uint;
private var _maxBuild:uint;// = 0xFF
private var _maxMinor:uint;// = 15
private var _maxMajor:uint;// = 15
private var _separator:String;// = "."
private var _maxRevision:uint;// = 0xFFFF
private var _build:uint;
private var _major:uint;
private var _minor:uint;
public function Version(major:uint=0, minor:uint=0, build:uint=0, revision:uint=0){
var v:Version;
super();
if ((((((((major > _maxMajor)) && ((minor == 0)))) && ((build == 0)))) && ((revision == 0)))){
v = Version.fromNumber(major);
major = v.major;
minor = v.minor;
build = v.build;
revision = v.revision;
};
this.major = major;
this.minor = minor;
this.build = build;
this.revision = revision;
}
public function toString(fields:int=0):String{
var arr:Array;
if ((((fields <= 0)) || ((fields > 4)))){
fields = getFields();
};
switch (fields){
case 1:
arr = [major];
break;
case 2:
arr = [major, minor];
break;
case 3:
arr = [major, minor, build];
break;
case 4:
default:
arr = [major, minor, build, revision];
};
return (arr.join(_separator));
}
public function set revision(value:uint):void{
_revision = Math.min(value, _maxRevision);
}
public function get revision():uint{
return (_revision);
}
public function set build(value:uint):void{
_build = Math.min(value, _maxBuild);
}
public function set minor(value:uint):void{
_minor = Math.min(value, _maxMinor);
}
public function get build():uint{
return (_build);
}
public function set major(value:uint):void{
_major = Math.min(value, _maxMajor);
}
public function get minor():uint{
return (_minor);
}
private function getFields():int{
var f = 4;
if (revision == 0){
f--;
};
if ((((f == 3)) && ((build == 0)))){
f--;
};
if ((((f == 2)) && ((minor == 0)))){
f--;
};
return (f);
}
public function valueOf():uint{
return (((((major << 28) | (minor << 24)) | (build << 16)) | revision));
}
public function get major():uint{
return (_major);
}
public function equals(o):Boolean{
if (!(o is Version)){
return (false);
};
if ((((((((o.major == major)) && ((o.minor == minor)))) && ((o.build == build)))) && ((o.revision == revision)))){
return (true);
};
return (false);
}
public static function fromString(value:String="", separator:String="."):Version{
var values:Array;
var v:Version = new (Version);
if ((((value == "")) || ((value == null)))){
return (v);
};
if (value.indexOf(separator) > -1){
values = value.split(separator);
v.major = parseInt(values[0]);
v.minor = parseInt(values[1]);
v.build = parseInt(values[2]);
v.revision = parseInt(values[3]);
} else {
v.major = parseInt(value);
};
return (v);
}
public static function fromNumber(value:Number=0):Version{
var v:Version = new (Version);
if (((((((((((isNaN(value)) || ((value == 0)))) || ((value < 0)))) || ((value == Number.MAX_VALUE)))) || ((value == Number.POSITIVE_INFINITY)))) || ((value == Number.NEGATIVE_INFINITY)))){
return (v);
};
v.major = (value >>> 28);
v.minor = ((value & 251658240) >>> 24);
v.build = ((value & 0xFF0000) >>> 16);
v.revision = (value & 0xFFFF);
return (v);
}
}
}//package com.google.analytics.utils
Section 204
//Bridge (com.google.analytics.v4.Bridge)
package com.google.analytics.v4 {
import com.google.analytics.core.*;
import com.google.analytics.debug.*;
import com.google.analytics.external.*;
public class Bridge implements GoogleAnalyticsAPI {
private var _debug:DebugConfiguration;
private var _proxy:JavascriptProxy;
private var _jsContainer:String;// = "_GATracker"
private var _hasGATracker:Boolean;// = false
private var _account:String;
private static var _linkTrackingObject_js:XML = <script>
<![CDATA[
function( container , target )
{
var targets ;
var name ;
if( target.indexOf(".") > 0 )
{
targets = target.split(".");
name = targets.pop();
}
else
{
targets = [];
name = target;
}
var ref = window;
var depth = targets.length;
for( var j = 0 ; j < depth ; j++ )
{
ref = ref[ targets[j] ] ;
}
window[container][target] = ref[name] ;
}
]]>
</script>
;
private static var _createTrackingObject_js:XML = <script>
<![CDATA[
function( acct )
{
_GATracker[acct] = _gat._getTracker(acct);
}
]]>
</script>
;
private static var _injectTrackingObject_js:XML = <script>
<![CDATA[
function()
{
try
{
_GATracker
}
catch(e)
{
_GATracker = {};
}
}
]]>
</script>
;
private static var _checkGAJS_js:XML = <script>
<![CDATA[
function()
{
if( _gat && _gat._getTracker )
{
return true;
}
return false;
}
]]>
</script>
;
private static var _checkValidTrackingObject_js:XML = <script>
<![CDATA[
function(acct)
{
if( _GATracker[acct] && (_GATracker[acct]._getAccount) )
{
return true ;
}
else
{
return false;
}
}
]]>
</script>
;
public function Bridge(account:String, debug:DebugConfiguration, jsproxy:JavascriptProxy){
var msg0:String;
var msg1:String;
var msg2:String;
super();
_account = account;
_debug = debug;
_proxy = jsproxy;
if (!_checkGAJS()){
msg0 = "";
msg0 = (msg0 + "ga.js not found, be sure to check if\n");
msg0 = (msg0 + "<script src=\"http://www.google-analytics.com/ga.js\"></script>\n");
msg0 = (msg0 + "is included in the HTML.");
_debug.warning(msg0);
throw (new Error(msg0));
};
if (!_hasGATracker){
if (((_debug.javascript) && (_debug.verbose))){
msg1 = "";
msg1 = (msg1 + "The Google Analytics tracking code was not found on the container page\n");
msg1 = (msg1 + "we create it");
_debug.info(msg1, VisualDebugMode.advanced);
};
_injectTrackingObject();
};
if (Utils.validateAccount(account)){
_createTrackingObject(account);
} else {
if (_checkTrackingObject(account)){
_linkTrackingObject(account);
} else {
msg2 = "";
msg2 = (msg2 + (("JS Object \"" + account) + "\" doesn't exist in DOM\n"));
msg2 = (msg2 + "Bridge object not created.");
_debug.warning(msg2);
throw (new Error(msg2));
};
};
}
public function link(targetUrl:String, useHash:Boolean=false):void{
_debug.info((((("link( " + targetUrl) + ", ") + useHash) + " )"));
_call("_link", targetUrl, useHash);
}
public function addOrganic(newOrganicEngine:String, newOrganicKeyword:String):void{
_debug.info((("addOrganic( " + [newOrganicEngine, newOrganicKeyword].join(", ")) + " )"));
_call("_addOrganic", newOrganicEngine);
}
public function setAllowLinker(enable:Boolean):void{
_debug.info((("setAllowLinker( " + enable) + " )"));
_call("_setAllowLinker", enable);
}
private function _linkTrackingObject(path:String):void{
_proxy.call(_linkTrackingObject_js, _jsContainer, path);
}
public function trackEvent(category:String, action:String, label:String=null, value:Number=NaN):Boolean{
var param = 2;
if (((label) && (!((label == ""))))){
param = 3;
};
if ((((param == 3)) && (!(isNaN(value))))){
param = 4;
};
switch (param){
case 4:
_debug.info((("trackEvent( " + [category, action, label, value].join(", ")) + " )"));
return (_call("_trackEvent", category, action, label, value));
case 3:
_debug.info((("trackEvent( " + [category, action, label].join(", ")) + " )"));
return (_call("_trackEvent", category, action, label));
case 2:
default:
_debug.info((("trackEvent( " + [category, action].join(", ")) + " )"));
return (_call("_trackEvent", category, action));
};
}
public function setClientInfo(enable:Boolean):void{
_debug.info((("setClientInfo( " + enable) + " )"));
_call("_setClientInfo", enable);
}
public function trackTrans():void{
_debug.info("trackTrans()");
_call("_trackTrans");
}
public function setCookieTimeout(newDefaultTimeout:int):void{
_debug.info((("setCookieTimeout( " + newDefaultTimeout) + " )"));
_call("_setCookieTimeout", newDefaultTimeout);
}
public function trackPageview(pageURL:String=""):void{
_debug.info((("trackPageview( " + pageURL) + " )"));
_call("_trackPageview", pageURL);
}
public function getClientInfo():Boolean{
_debug.info("getClientInfo()");
return (_call("_getClientInfo"));
}
private function _checkValidTrackingObject(account:String):Boolean{
return (_proxy.call(_checkValidTrackingObject_js, account));
}
private function _checkGAJS():Boolean{
return (_proxy.call(_checkGAJS_js));
}
public function linkByPost(formObject:Object, useHash:Boolean=false):void{
_debug.warning((((("linkByPost( " + formObject) + ", ") + useHash) + " ) not implemented"));
}
private function _call(functionName:String, ... _args){
_args.unshift(((((("window." + _jsContainer) + "[\"") + _account) + "\"].") + functionName));
return (_proxy.call.apply(_proxy, _args));
}
public function hasGAJS():Boolean{
return (_checkGAJS());
}
private function _checkTrackingObject(account:String):Boolean{
var hasObj:Boolean = _proxy.hasProperty(account);
var isTracker:Boolean = _proxy.hasProperty((account + "._getAccount"));
return (((hasObj) && (isTracker)));
}
public function resetSession():void{
_debug.warning("resetSession() not implemented");
}
public function getDetectTitle():Boolean{
_debug.info("getDetectTitle()");
return (_call("_getDetectTitle"));
}
public function setCampNameKey(newCampNameKey:String):void{
_debug.info((("setCampNameKey( " + newCampNameKey) + " )"));
_call("_setCampNameKey", newCampNameKey);
}
public function setDetectFlash(enable:Boolean):void{
_debug.info((("setDetectFlash( " + enable) + " )"));
_call("_setDetectFlash", enable);
}
public function createEventTracker(objName:String):EventTracker{
_debug.info((("createEventTracker( " + objName) + " )"));
return (new EventTracker(objName, this));
}
public function addItem(item:String, sku:String, name:String, category:String, price:Number, quantity:int):void{
_debug.info((("addItem( " + [item, sku, name, category, price, quantity].join(", ")) + " )"));
_call("_addItem", item, sku, name, category, price, quantity);
}
public function clearIgnoredOrganic():void{
_debug.info("clearIgnoredOrganic()");
_call("_clearIgnoreOrganic");
}
public function setVar(newVal:String):void{
_debug.info((("setVar( " + newVal) + " )"));
_call("_setVar", newVal);
}
public function setDomainName(newDomainName:String):void{
_debug.info((("setDomainName( " + newDomainName) + " )"));
_call("_setDomainName", newDomainName);
}
public function hasTrackingAccount(account:String):Boolean{
if (Utils.validateAccount(account)){
return (_checkValidTrackingObject(account));
};
return (_checkTrackingObject(account));
}
public function setCampSourceKey(newCampSrcKey:String):void{
_debug.info((("setCampSourceKey( " + newCampSrcKey) + " )"));
_call("_setCampSourceKey", newCampSrcKey);
}
public function addTrans(orderId:String, affiliation:String, total:Number, tax:Number, shipping:Number, city:String, state:String, country:String):Object{
_debug.info((("addTrans( " + [orderId, affiliation, total, tax, shipping, city, state, country].join(", ")) + " )"));
_call("_addTrans", orderId, affiliation, total, tax, shipping, city, state, country);
return (null);
}
public function setCampContentKey(newCampContentKey:String):void{
_debug.info((("setCampContentKey( " + newCampContentKey) + " )"));
_call("_setCampContentKey", newCampContentKey);
}
public function setLocalServerMode():void{
_debug.info("setLocalServerMode()");
_call("_setLocalServerMode");
}
public function getLocalGifPath():String{
_debug.info("getLocalGifPath()");
return (_call("_getLocalGifPath"));
}
public function clearIgnoredRef():void{
_debug.info("clearIgnoredRef()");
_call("_clearIgnoreRef");
}
public function setAllowAnchor(enable:Boolean):void{
_debug.info((("setAllowAnchor( " + enable) + " )"));
_call("_setAllowAnchor", enable);
}
public function setLocalGifPath(newLocalGifPath:String):void{
_debug.info((("setLocalGifPath( " + newLocalGifPath) + " )"));
_call("_setLocalGifPath", newLocalGifPath);
}
public function getVersion():String{
_debug.info("getVersion()");
return (_call("_getVersion"));
}
private function _injectTrackingObject():void{
_proxy.executeBlock(_injectTrackingObject_js);
_hasGATracker = true;
}
public function setCookiePath(newCookiePath:String):void{
_debug.info((("setCookiePath( " + newCookiePath) + " )"));
_call("_setCookiePath", newCookiePath);
}
public function setSampleRate(newRate:Number):void{
_debug.info((("setSampleRate( " + newRate) + " )"));
_call("_setSampleRate", newRate);
}
public function setAllowHash(enable:Boolean):void{
_debug.info((("setAllowHash( " + enable) + " )"));
_call("_setAllowHash", enable);
}
public function addIgnoredOrganic(newIgnoredOrganicKeyword:String):void{
_debug.info((("addIgnoredOrganic( " + newIgnoredOrganicKeyword) + " )"));
_call("_addIgnoredOrganic", newIgnoredOrganicKeyword);
}
public function setCampNOKey(newCampNOKey:String):void{
_debug.info((("setCampNOKey( " + newCampNOKey) + " )"));
_call("_setCampNOKey", newCampNOKey);
}
public function cookiePathCopy(newPath:String):void{
_debug.info((("cookiePathCopy( " + newPath) + " )"));
_call("_cookiePathCopy", newPath);
}
public function setLocalRemoteServerMode():void{
_debug.info("setLocalRemoteServerMode()");
_call("_setLocalRemoteServerMode");
}
public function getServiceMode():ServerOperationMode{
_debug.info("getServiceMode()");
return (_call("_getServiceMode"));
}
public function setDetectTitle(enable:Boolean):void{
_debug.info((("setDetectTitle( " + enable) + " )"));
_call("_setDetectTitle", enable);
}
private function _createTrackingObject(account:String):void{
_proxy.call(_createTrackingObject_js, account);
}
public function setCampaignTrack(enable:Boolean):void{
_debug.info((("setCampaignTrack( " + enable) + " )"));
_call("_setCampaignTrack", enable);
}
public function clearOrganic():void{
_debug.info("clearOrganic()");
_call("_clearOrganic");
}
public function setCampTermKey(newCampTermKey:String):void{
_debug.info((("setCampTermKey( " + newCampTermKey) + " )"));
_call("_setCampTermKey", newCampTermKey);
}
public function getDetectFlash():Boolean{
_debug.info("getDetectFlash()");
return (_call("_getDetectFlash"));
}
public function setCampMediumKey(newCampMedKey:String):void{
_debug.info((("setCampMediumKey( " + newCampMedKey) + " )"));
_call("_setCampMediumKey", newCampMedKey);
}
public function addIgnoredRef(newIgnoredReferrer:String):void{
_debug.info((("addIgnoredRef( " + newIgnoredReferrer) + " )"));
_call("_addIgnoredRef", newIgnoredReferrer);
}
public function setSessionTimeout(newTimeout:int):void{
_debug.info((("setSessionTimeout( " + newTimeout) + " )"));
_call("_setSessionTimeout", newTimeout);
}
public function setRemoteServerMode():void{
_debug.info("setRemoteServerMode()");
_call("_setRemoteServerMode");
}
public function getAccount():String{
_debug.info("getAccount()");
return (_call("_getAccount"));
}
}
}//package com.google.analytics.v4
Section 205
//Configuration (com.google.analytics.v4.Configuration)
package com.google.analytics.v4 {
import com.google.analytics.core.*;
import com.google.analytics.debug.*;
import com.google.analytics.utils.*;
import com.google.analytics.campaign.*;
public class Configuration {
public var serverMode:ServerOperationMode;
public var detectFlash:Boolean;// = true
public var hasSiteOverlay:Boolean;// = false
public var allowLocalTracking:Boolean;// = true
public var secureRemoteGIFpath:String;// = "https://ssl.google-analytics.com/__utm.gif"
private var _version:String;// = "4.3as"
public var allowDomainHash:Boolean;// = true
public var detectClientInfo:Boolean;// = true
public var idleLoop:Number;// = 30
public var isTrackOutboundSubdomains:Boolean;// = false
public var cookiePath:String;// = "/"
public var transactionFieldDelim:String;// = "|"
private var _organic:Organic;
private var _cookieName:String;// = "analytics"
public var campaignKey:CampaignKey;
public var google:String;// = "google"
public var googleCsePath:String;// = "cse"
public var bucketCapacity:Number;// = 10
private var _sampleRate:Number;// = 1
public var remoteGIFpath:String;// = "http://www.google-analytics.com/__utm.gif"
public var googleSearchParam:String;// = "q"
public var allowLinker:Boolean;// = false
public var maxOutboundLinkExamined:Number;// = 1000
private var _debug:DebugConfiguration;
public var allowAnchor:Boolean;// = false
private var _domain:Domain;
private var _trackingLimitPerSession:int;// = 500
public var tokenCliff:int;// = 10
public var sessionTimeout:Number;
public var idleTimeout:Number;// = 60
public var campaignTracking:Boolean;// = true
public var domainName:String;// = ""
public var detectTitle:Boolean;// = true
public var tokenRate:Number;// = 0.2
public var conversionTimeout:Number;
public var localGIFpath:String;// = "/__utm.gif"
public function Configuration(debug:DebugConfiguration=null){
_organic = new Organic();
conversionTimeout = Timespan.sixmonths;
sessionTimeout = Timespan.thirtyminutes;
campaignKey = new CampaignKey();
serverMode = ServerOperationMode.remote;
super();
_debug = debug;
_domain = new Domain(DomainNameMode.auto, "", _debug);
serverMode = ServerOperationMode.remote;
_initOrganicSources();
}
public function get organic():Organic{
return (_organic);
}
public function get cookieName():String{
return (_cookieName);
}
public function get trackingLimitPerSession():int{
return (_trackingLimitPerSession);
}
private function _initOrganicSources():void{
addOrganicSource(google, googleSearchParam);
addOrganicSource("yahoo", "p");
addOrganicSource("msn", "q");
addOrganicSource("aol", "query");
addOrganicSource("aol", "encquery");
addOrganicSource("lycos", "query");
addOrganicSource("ask", "q");
addOrganicSource("altavista", "q");
addOrganicSource("netscape", "query");
addOrganicSource("cnn", "query");
addOrganicSource("looksmart", "qt");
addOrganicSource("about", "terms");
addOrganicSource("mamma", "query");
addOrganicSource("alltheweb", "q");
addOrganicSource("gigablast", "q");
addOrganicSource("voila", "rdata");
addOrganicSource("virgilio", "qs");
addOrganicSource("live", "q");
addOrganicSource("baidu", "wd");
addOrganicSource("alice", "qs");
addOrganicSource("yandex", "text");
addOrganicSource("najdi", "q");
addOrganicSource("aol", "q");
addOrganicSource("club-internet", "q");
addOrganicSource("mama", "query");
addOrganicSource("seznam", "q");
addOrganicSource("search", "q");
addOrganicSource("wp", "szukaj");
addOrganicSource("onet", "qt");
addOrganicSource("netsprint", "q");
addOrganicSource("google.interia", "q");
addOrganicSource("szukacz", "q");
addOrganicSource("yam", "k");
addOrganicSource("pchome", "q");
addOrganicSource("kvasir", "searchExpr");
addOrganicSource("sesam", "q");
addOrganicSource("ozu", "q");
addOrganicSource("terra", "query");
addOrganicSource("nostrum", "query");
addOrganicSource("mynet", "q");
addOrganicSource("ekolay", "q");
addOrganicSource("search.ilse", "search_for");
}
public function get sampleRate():Number{
return (_sampleRate);
}
public function addOrganicSource(engine:String, keyword:String):void{
var engine = engine;
var keyword = keyword;
_organic.addSource(engine, keyword);
//unresolved jump
var _slot1 = e;
if (((_debug) && (_debug.active))){
_debug.warning(_slot1.message);
};
}
public function get domain():Domain{
return (_domain);
}
public function set sampleRate(value:Number):void{
if (value <= 0){
value = 0.1;
};
if (value > 1){
value = 1;
};
value = Number(value.toFixed(2));
_sampleRate = value;
}
public function get version():String{
return (_version);
}
}
}//package com.google.analytics.v4
Section 206
//GoogleAnalyticsAPI (com.google.analytics.v4.GoogleAnalyticsAPI)
package com.google.analytics.v4 {
import com.google.analytics.core.*;
public interface GoogleAnalyticsAPI {
function setCampSourceKey(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String):void;
function getServiceMode():ServerOperationMode;
function resetSession():void;
function setLocalServerMode():void;
function setCampContentKey(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String):void;
function addOrganic(_arg1:String, _arg2:String):void;
function setDetectFlash(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:Boolean):void;
function addTrans(_arg1:String, _arg2:String, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:String, _arg7:String, _arg8:String):Object;
function trackEvent(_arg1:String, _arg2:String, _arg3:String=null, _arg4:Number=NaN):Boolean;
function setCampTermKey(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String):void;
function setCampNameKey(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String):void;
function addIgnoredOrganic(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String):void;
function addItem(_arg1:String, _arg2:String, _arg3:String, _arg4:String, _arg5:Number, _arg6:int):void;
function setAllowLinker(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:Boolean):void;
function getClientInfo():Boolean;
function getDetectFlash():Boolean;
function setCampaignTrack(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:Boolean):void;
function createEventTracker(void:String):EventTracker;
function setCookieTimeout(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:int):void;
function setAllowAnchor(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:Boolean):void;
function trackTrans():void;
function clearOrganic():void;
function trackPageview(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String=""):void;
function setLocalGifPath(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String):void;
function getVersion():String;
function getLocalGifPath():String;
function setVar(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String):void;
function clearIgnoredOrganic():void;
function setCampMediumKey(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String):void;
function addIgnoredRef(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String):void;
function setClientInfo(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:Boolean):void;
function setCookiePath(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String):void;
function setSampleRate(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:Number):void;
function setSessionTimeout(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:int):void;
function setRemoteServerMode():void;
function clearIgnoredRef():void;
function setDomainName(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String):void;
function setDetectTitle(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:Boolean):void;
function setAllowHash(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:Boolean):void;
function getAccount():String;
function linkByPost(_arg1:Object, _arg2:Boolean=false):void;
function link(_arg1:String, _arg2:Boolean=false):void;
function setCampNOKey(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String):void;
function setLocalRemoteServerMode():void;
function cookiePathCopy(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics/v4;GoogleAnalyticsAPI.as:String):void;
function getDetectTitle():Boolean;
}
}//package com.google.analytics.v4
Section 207
//Tracker (com.google.analytics.v4.Tracker)
package com.google.analytics.v4 {
import com.google.analytics.core.*;
import com.google.analytics.debug.*;
import com.google.analytics.external.*;
import com.google.analytics.utils.*;
import com.google.analytics.data.*;
import com.google.analytics.campaign.*;
public class Tracker implements GoogleAnalyticsAPI {
private const EVENT_TRACKER_LABEL_KEY_NUM:int = 3;
private const EVENT_TRACKER_VALUE_VALUE_NUM:int = 1;
private const EVENT_TRACKER_PROJECT_ID:int = 5;
private const EVENT_TRACKER_OBJECT_NAME_KEY_NUM:int = 1;
private const EVENT_TRACKER_TYPE_KEY_NUM:int = 2;
private var _adSense:AdSenseGlobals;
private var _eventTracker:X10;
private var _noSessionInformation:Boolean;// = false
private var _browserInfo:BrowserInfo;
private var _debug:DebugConfiguration;
private var _isNewVisitor:Boolean;// = false
private var _buffer:Buffer;
private var _config:Configuration;
private var _x10Module:X10;
private var _campaign:CampaignManager;
private var _formatedReferrer:String;
private var _timeStamp:Number;
private var _info:Environment;
private var _domainHash:Number;
private var _campaignInfo:CampaignInfo;
private var _gifRequest:GIFRequest;
private var _hasInitData:Boolean;// = false
private var _account:String;
public function Tracker(account:String, config:Configuration, debug:DebugConfiguration, info:Environment, buffer:Buffer, gifRequest:GIFRequest, adSense:AdSenseGlobals){
var msg:String;
super();
_account = account;
_config = config;
_debug = debug;
_info = info;
_buffer = buffer;
_gifRequest = gifRequest;
_adSense = adSense;
if (!Utils.validateAccount(account)){
msg = (("Account \"" + account) + "\" is not valid.");
_debug.warning(msg);
throw (new Error(msg));
};
_initData();
}
private function _doTracking():Boolean{
if (((((!((_info.protocol == Protocols.file))) && (!((_info.protocol == Protocols.none))))) && (_isNotGoogleSearch()))){
return (true);
};
if (_config.allowLocalTracking){
return (true);
};
return (false);
}
public function addOrganic(newOrganicEngine:String, newOrganicKeyword:String):void{
_debug.info((("addOrganic( " + [newOrganicEngine, newOrganicKeyword].join(", ")) + " )"));
_config.organic.addSource(newOrganicEngine, newOrganicKeyword);
}
public function setAllowLinker(enable:Boolean):void{
_config.allowLinker = enable;
_debug.info((("setAllowLinker( " + _config.allowLinker) + " )"));
}
public function trackEvent(category:String, action:String, label:String=null, value:Number=NaN):Boolean{
var success:Boolean;
var params = 2;
if (((!((category == ""))) && (!((action == ""))))){
_eventTracker.clearKey(EVENT_TRACKER_PROJECT_ID);
_eventTracker.clearValue(EVENT_TRACKER_PROJECT_ID);
success = _eventTracker.setKey(EVENT_TRACKER_PROJECT_ID, EVENT_TRACKER_OBJECT_NAME_KEY_NUM, category);
success = _eventTracker.setKey(EVENT_TRACKER_PROJECT_ID, EVENT_TRACKER_TYPE_KEY_NUM, action);
if (((label) && (!((label == ""))))){
success = _eventTracker.setKey(EVENT_TRACKER_PROJECT_ID, EVENT_TRACKER_LABEL_KEY_NUM, label);
params = 3;
if (!isNaN(value)){
success = _eventTracker.setValue(EVENT_TRACKER_PROJECT_ID, EVENT_TRACKER_VALUE_VALUE_NUM, value);
params = 4;
};
};
if (success){
_debug.info(((("valid event tracking call\ncategory: " + category) + "\naction: ") + action), VisualDebugMode.geek);
_sendXEvent(_eventTracker);
};
} else {
_debug.warning(((("event tracking call is not valid, failed!\ncategory: " + category) + "\naction: ") + action), VisualDebugMode.geek);
success = false;
};
switch (params){
case 4:
_debug.info((("trackEvent( " + [category, action, label, value].join(", ")) + " )"));
break;
case 3:
_debug.info((("trackEvent( " + [category, action, label].join(", ")) + " )"));
break;
case 2:
default:
_debug.info((("trackEvent( " + [category, action].join(", ")) + " )"));
};
return (success);
}
public function trackPageview(pageURL:String=""):void{
_debug.info((("trackPageview( " + pageURL) + " )"));
if (_doTracking()){
_initData();
_trackMetrics(pageURL);
_noSessionInformation = false;
} else {
_debug.warning((("trackPageview( " + pageURL) + " ) failed"));
};
}
public function setCookieTimeout(newDefaultTimeout:int):void{
_config.conversionTimeout = newDefaultTimeout;
_debug.info((("setCookieTimeout( " + _config.conversionTimeout) + " )"));
}
public function trackTrans():void{
_debug.warning("trackTrans() not implemented");
}
public function setClientInfo(enable:Boolean):void{
_config.detectClientInfo = enable;
_debug.info((("setClientInfo( " + _config.detectClientInfo) + " )"));
}
public function linkByPost(formObject:Object, useHash:Boolean=false):void{
_debug.warning((("linkByPost( " + [formObject, useHash].join(", ")) + " ) not implemented"));
}
private function _initData():void{
var data0:String;
var data:String;
if (!_hasInitData){
_updateDomainName();
_domainHash = _getDomainHash();
_timeStamp = Math.round((new Date().getTime() / 1000));
if (_debug.verbose){
data0 = "";
data0 = (data0 + "_initData 0");
data0 = (data0 + ("\ndomain name: " + _config.domainName));
data0 = (data0 + ("\ndomain hash: " + _domainHash));
data0 = (data0 + (((("\ntimestamp: " + _timeStamp) + " (") + new Date((_timeStamp * 1000))) + ")"));
_debug.info(data0, VisualDebugMode.geek);
};
};
if (_doTracking()){
_handleCookie();
};
if (!_hasInitData){
if (_doTracking()){
_formatedReferrer = _formatReferrer();
_browserInfo = new BrowserInfo(_config, _info);
_debug.info(("browserInfo: " + _browserInfo.toURLString()), VisualDebugMode.advanced);
if (_config.campaignTracking){
_campaign = new CampaignManager(_config, _debug, _buffer, _domainHash, _formatedReferrer, _timeStamp);
_campaignInfo = _campaign.getCampaignInformation(_info.locationSearch, _noSessionInformation);
_debug.info(("campaignInfo: " + _campaignInfo.toURLString()), VisualDebugMode.advanced);
};
};
_x10Module = new X10();
_eventTracker = new X10();
_hasInitData = true;
};
if (_config.hasSiteOverlay){
_debug.warning("Site Overlay is not supported");
};
if (_debug.verbose){
data = "";
data = (data + "_initData (misc)");
data = (data + ("\nflash version: " + _info.flashVersion.toString(4)));
data = (data + ("\nprotocol: " + _info.protocol));
data = (data + (("\ndefault domain name (auto): \"" + _info.domainName) + "\""));
data = (data + ("\nlanguage: " + _info.language));
data = (data + ("\ndomain hash: " + _getDomainHash()));
data = (data + ("\nuser-agent: " + _info.userAgent));
_debug.info(data, VisualDebugMode.geek);
};
}
public function getDetectTitle():Boolean{
_debug.info("getDetectTitle()");
return (_config.detectTitle);
}
public function resetSession():void{
_debug.info("resetSession()");
_buffer.resetCurrentSession();
}
public function getClientInfo():Boolean{
_debug.info("getClientInfo()");
return (_config.detectClientInfo);
}
private function _sendXEvent(opt_xObj:X10=null):void{
var searchVariables:Variables;
var eventInfo:EventInfo;
var eventvars:Variables;
var generalvars:Variables;
_initData();
if (_takeSample()){
searchVariables = new Variables();
searchVariables.URIencode = true;
eventInfo = new EventInfo(true, _x10Module, opt_xObj);
eventvars = eventInfo.toVariables();
generalvars = _renderMetricsSearchVariables();
searchVariables.join(eventvars, generalvars);
_gifRequest.send(_account, searchVariables, false, true);
};
}
public function setDetectFlash(enable:Boolean):void{
_config.detectFlash = enable;
_debug.info((("setDetectFlash( " + _config.detectFlash) + " )"));
}
public function setCampNameKey(newCampNameKey:String):void{
_config.campaignKey.UCCN = newCampNameKey;
var msg = (("setCampNameKey( " + _config.campaignKey.UCCN) + " )");
if (_debug.mode == VisualDebugMode.geek){
_debug.info((msg + " [UCCN]"));
} else {
_debug.info(msg);
};
}
private function _formatReferrer():String{
var domainName:String;
var ref:URL;
var dom:URL;
var referrer:String = _info.referrer;
if ((((referrer == "")) || ((referrer == "localhost")))){
referrer = "-";
} else {
domainName = _info.domainName;
ref = new URL(referrer);
dom = new URL(("http://" + domainName));
if (ref.hostName == domainName){
return ("-");
};
if (dom.domain == ref.domain){
if (dom.subDomain != ref.subDomain){
referrer = "0";
};
};
if ((((referrer.charAt(0) == "[")) && (referrer.charAt((referrer.length - 1))))){
referrer = "-";
};
};
_debug.info(("formated referrer: " + referrer), VisualDebugMode.advanced);
return (referrer);
}
private function _visitCode():Number{
if (_debug.verbose){
_debug.info(("visitCode: " + _buffer.utma.sessionId), VisualDebugMode.geek);
};
return (_buffer.utma.sessionId);
}
public function createEventTracker(objName:String):EventTracker{
_debug.info((("createEventTracker( " + objName) + " )"));
return (new EventTracker(objName, this));
}
public function addItem(item:String, sku:String, name:String, category:String, price:Number, quantity:int):void{
_debug.warning((("addItem( " + [item, sku, name, category, price, quantity].join(", ")) + " ) not implemented"));
}
public function clearIgnoredOrganic():void{
_debug.info("clearIgnoredOrganic()");
_config.organic.clearIgnoredKeywords();
}
public function setVar(newVal:String):void{
var variables:Variables;
if (((!((newVal == ""))) && (_isNotGoogleSearch()))){
_initData();
_buffer.utmv.domainHash = _domainHash;
_buffer.utmv.value = newVal;
if (_debug.verbose){
_debug.info(_buffer.utmv.toString(), VisualDebugMode.geek);
};
_debug.info((("setVar( " + newVal) + " )"));
if (_takeSample()){
variables = new Variables();
variables.utmt = "var";
_gifRequest.send(_account, variables);
};
} else {
_debug.warning((("setVar \"" + newVal) + "\" is ignored"));
};
}
public function setDomainName(newDomainName:String):void{
if (newDomainName == "auto"){
_config.domain.mode = DomainNameMode.auto;
} else {
if (newDomainName == "none"){
_config.domain.mode = DomainNameMode.none;
} else {
_config.domain.mode = DomainNameMode.custom;
_config.domain.name = newDomainName;
};
};
_updateDomainName();
_debug.info((("setDomainName( " + _config.domainName) + " )"));
}
private function _updateDomainName():void{
var domainName:String;
if (_config.domain.mode == DomainNameMode.auto){
domainName = _info.domainName;
if (domainName.substring(0, 4) == "www."){
domainName = domainName.substring(4);
};
_config.domain.name = domainName;
};
_config.domainName = _config.domain.name.toLowerCase();
_debug.info(("domain name: " + _config.domainName), VisualDebugMode.advanced);
}
public function addTrans(orderId:String, affiliation:String, total:Number, tax:Number, shipping:Number, city:String, state:String, country:String):Object{
_debug.warning((("addTrans( " + [orderId, affiliation, total, tax, shipping, city, state, country].join(", ")) + " ) not implemented"));
return (null);
}
private function _renderMetricsSearchVariables(pageURL:String=""):Variables{
var campvars:Variables;
var variables:Variables = new Variables();
variables.URIencode = true;
var docInfo:DocumentInfo = new DocumentInfo(_config, _info, _formatedReferrer, pageURL, _adSense);
_debug.info(("docInfo: " + docInfo.toURLString()), VisualDebugMode.geek);
if (_config.campaignTracking){
campvars = _campaignInfo.toVariables();
};
var browservars:Variables = _browserInfo.toVariables();
variables.join(docInfo.toVariables(), browservars, campvars);
return (variables);
}
public function setCampContentKey(newCampContentKey:String):void{
_config.campaignKey.UCCT = newCampContentKey;
var msg = (("setCampContentKey( " + _config.campaignKey.UCCT) + " )");
if (_debug.mode == VisualDebugMode.geek){
_debug.info((msg + " [UCCT]"));
} else {
_debug.info(msg);
};
}
private function _handleCookie():void{
var data0:String;
var data1:String;
var vid:Array;
var data2:String;
if (_config.allowLinker){
};
if (((_buffer.hasUTMA()) && (!(_buffer.utma.isEmpty())))){
if (((!(_buffer.hasUTMB())) || (!(_buffer.hasUTMC())))){
_buffer.updateUTMA(_timeStamp);
_noSessionInformation = true;
};
if (_debug.verbose){
_debug.info(("from cookie " + _buffer.utma.toString()), VisualDebugMode.geek);
};
} else {
_debug.info("create a new utma", VisualDebugMode.advanced);
_buffer.utma.domainHash = _domainHash;
_buffer.utma.sessionId = _getUniqueSessionId();
_buffer.utma.firstTime = _timeStamp;
_buffer.utma.lastTime = _timeStamp;
_buffer.utma.currentTime = _timeStamp;
_buffer.utma.sessionCount = 1;
if (_debug.verbose){
_debug.info(_buffer.utma.toString(), VisualDebugMode.geek);
};
_noSessionInformation = true;
_isNewVisitor = true;
};
if (((_adSense.gaGlobal) && ((_adSense.dh == String(_domainHash))))){
if (_adSense.sid){
_buffer.utma.currentTime = Number(_adSense.sid);
if (_debug.verbose){
data0 = "";
data0 = (data0 + "AdSense sid found\n");
data0 = (data0 + (((("Override currentTime(" + _buffer.utma.currentTime) + ") from AdSense sid(") + Number(_adSense.sid)) + ")"));
_debug.info(data0, VisualDebugMode.geek);
};
};
if (_isNewVisitor){
if (_adSense.sid){
_buffer.utma.lastTime = Number(_adSense.sid);
if (_debug.verbose){
data1 = "";
data1 = (data1 + "AdSense sid found (new visitor)\n");
data1 = (data1 + (((("Override lastTime(" + _buffer.utma.lastTime) + ") from AdSense sid(") + Number(_adSense.sid)) + ")"));
_debug.info(data1, VisualDebugMode.geek);
};
};
if (_adSense.vid){
vid = _adSense.vid.split(".");
_buffer.utma.sessionId = Number(vid[0]);
_buffer.utma.firstTime = Number(vid[1]);
if (_debug.verbose){
data2 = "";
data2 = (data2 + "AdSense vid found (new visitor)\n");
data2 = (data2 + (((("Override sessionId(" + _buffer.utma.sessionId) + ") from AdSense vid(") + Number(vid[0])) + ")\n"));
data2 = (data2 + (((("Override firstTime(" + _buffer.utma.firstTime) + ") from AdSense vid(") + Number(vid[1])) + ")"));
_debug.info(data2, VisualDebugMode.geek);
};
};
if (_debug.verbose){
_debug.info(("AdSense modified : " + _buffer.utma.toString()), VisualDebugMode.geek);
};
};
};
_buffer.utmb.domainHash = _domainHash;
if (isNaN(_buffer.utmb.trackCount)){
_buffer.utmb.trackCount = 0;
};
if (isNaN(_buffer.utmb.token)){
_buffer.utmb.token = _config.tokenCliff;
};
if (isNaN(_buffer.utmb.lastTime)){
_buffer.utmb.lastTime = _buffer.utma.currentTime;
};
_buffer.utmc.domainHash = _domainHash;
if (_debug.verbose){
_debug.info(_buffer.utmb.toString(), VisualDebugMode.advanced);
_debug.info(_buffer.utmc.toString(), VisualDebugMode.advanced);
};
}
public function setLocalServerMode():void{
_config.serverMode = ServerOperationMode.local;
_debug.info("setLocalServerMode()");
}
public function clearIgnoredRef():void{
_debug.info("clearIgnoredRef()");
_config.organic.clearIgnoredReferrals();
}
public function setCampSourceKey(newCampSrcKey:String):void{
_config.campaignKey.UCSR = newCampSrcKey;
var msg = (("setCampSourceKey( " + _config.campaignKey.UCSR) + " )");
if (_debug.mode == VisualDebugMode.geek){
_debug.info((msg + " [UCSR]"));
} else {
_debug.info(msg);
};
}
public function getLocalGifPath():String{
_debug.info("getLocalGifPath()");
return (_config.localGIFpath);
}
public function setLocalGifPath(newLocalGifPath:String):void{
_config.localGIFpath = newLocalGifPath;
_debug.info((("setLocalGifPath( " + _config.localGIFpath) + " )"));
}
public function getVersion():String{
_debug.info("getVersion()");
return (_config.version);
}
public function setAllowAnchor(enable:Boolean):void{
_config.allowAnchor = enable;
_debug.info((("setAllowAnchor( " + _config.allowAnchor) + " )"));
}
private function _isNotGoogleSearch():Boolean{
var domainName:String = _config.domainName;
var g0 = (domainName.indexOf("www.google.") < 0);
var g1 = (domainName.indexOf(".google.") < 0);
var g2 = (domainName.indexOf("google.") < 0);
var g4 = (domainName.indexOf("google.org") > -1);
return (((((((((g0) || (g1))) || (g2))) || (!((_config.cookiePath == "/"))))) || (g4)));
}
public function setSampleRate(newRate:Number):void{
if (newRate < 0){
_debug.warning("sample rate can not be negative, ignoring value.");
} else {
_config.sampleRate = newRate;
};
_debug.info((("setSampleRate( " + _config.sampleRate) + " )"));
}
private function _takeSample():Boolean{
if (_debug.verbose){
_debug.info((((("takeSample: (" + (_visitCode() % 10000)) + ") < (") + (_config.sampleRate * 10000)) + ")"), VisualDebugMode.geek);
};
return (((_visitCode() % 10000) < (_config.sampleRate * 10000)));
}
public function setCookiePath(newCookiePath:String):void{
_config.cookiePath = newCookiePath;
_debug.info((("setCookiePath( " + _config.cookiePath) + " )"));
}
public function setAllowHash(enable:Boolean):void{
_config.allowDomainHash = enable;
_debug.info((("setAllowHash( " + _config.allowDomainHash) + " )"));
}
private function _generateUserDataHash():Number{
var hash:String = "";
hash = (hash + _info.appName);
hash = (hash + _info.appVersion);
hash = (hash + _info.language);
hash = (hash + _info.platform);
hash = (hash + _info.userAgent.toString());
hash = (hash + (((_info.screenWidth + "x") + _info.screenHeight) + _info.screenColorDepth));
hash = (hash + _info.referrer);
return (Utils.generateHash(hash));
}
public function setCampNOKey(newCampNOKey:String):void{
_config.campaignKey.UCNO = newCampNOKey;
var msg = (("setCampNOKey( " + _config.campaignKey.UCNO) + " )");
if (_debug.mode == VisualDebugMode.geek){
_debug.info((msg + " [UCNO]"));
} else {
_debug.info(msg);
};
}
public function addIgnoredOrganic(newIgnoredOrganicKeyword:String):void{
_debug.info((("addIgnoredOrganic( " + newIgnoredOrganicKeyword) + " )"));
_config.organic.addIgnoredKeyword(newIgnoredOrganicKeyword);
}
public function setLocalRemoteServerMode():void{
_config.serverMode = ServerOperationMode.both;
_debug.info("setLocalRemoteServerMode()");
}
public function cookiePathCopy(newPath:String):void{
_debug.warning((("cookiePathCopy( " + newPath) + " ) not implemented"));
}
public function setDetectTitle(enable:Boolean):void{
_config.detectTitle = enable;
_debug.info((("setDetectTitle( " + _config.detectTitle) + " )"));
}
public function setCampTermKey(newCampTermKey:String):void{
_config.campaignKey.UCTR = newCampTermKey;
var msg = (("setCampTermKey( " + _config.campaignKey.UCTR) + " )");
if (_debug.mode == VisualDebugMode.geek){
_debug.info((msg + " [UCTR]"));
} else {
_debug.info(msg);
};
}
public function getServiceMode():ServerOperationMode{
_debug.info("getServiceMode()");
return (_config.serverMode);
}
private function _trackMetrics(pageURL:String=""):void{
var searchVariables:Variables;
var x10vars:Variables;
var generalvars:Variables;
var eventInfo:EventInfo;
if (_takeSample()){
searchVariables = new Variables();
searchVariables.URIencode = true;
if (((_x10Module) && (_x10Module.hasData()))){
eventInfo = new EventInfo(false, _x10Module);
x10vars = eventInfo.toVariables();
};
generalvars = _renderMetricsSearchVariables(pageURL);
searchVariables.join(x10vars, generalvars);
_gifRequest.send(_account, searchVariables);
};
}
public function setCampaignTrack(enable:Boolean):void{
_config.campaignTracking = enable;
_debug.info((("setCampaignTrack( " + _config.campaignTracking) + " )"));
}
public function addIgnoredRef(newIgnoredReferrer:String):void{
_debug.info((("addIgnoredRef( " + newIgnoredReferrer) + " )"));
_config.organic.addIgnoredReferral(newIgnoredReferrer);
}
public function clearOrganic():void{
_debug.info("clearOrganic()");
_config.organic.clearEngines();
}
public function getDetectFlash():Boolean{
_debug.info("getDetectFlash()");
return (_config.detectFlash);
}
public function setCampMediumKey(newCampMedKey:String):void{
_config.campaignKey.UCMD = newCampMedKey;
var msg = (("setCampMediumKey( " + _config.campaignKey.UCMD) + " )");
if (_debug.mode == VisualDebugMode.geek){
_debug.info((msg + " [UCMD]"));
} else {
_debug.info(msg);
};
}
private function _getUniqueSessionId():Number{
var sessionID:Number = ((Utils.generate32bitRandom() ^ _generateUserDataHash()) * 2147483647);
_debug.info(("Session ID: " + sessionID), VisualDebugMode.geek);
return (sessionID);
}
private function _getDomainHash():Number{
if (((((!(_config.domainName)) || ((_config.domainName == "")))) || ((_config.domain.mode == DomainNameMode.none)))){
_config.domainName = "";
return (1);
};
_updateDomainName();
if (_config.allowDomainHash){
return (Utils.generateHash(_config.domainName));
};
return (1);
}
public function setSessionTimeout(newTimeout:int):void{
_config.sessionTimeout = newTimeout;
_debug.info((("setSessionTimeout( " + _config.sessionTimeout) + " )"));
}
public function getAccount():String{
_debug.info("getAccount()");
return (_account);
}
public function link(targetUrl:String, useHash:Boolean=false):void{
_debug.warning((("link( " + [targetUrl, useHash].join(", ")) + " ) not implemented"));
}
public function setRemoteServerMode():void{
_config.serverMode = ServerOperationMode.remote;
_debug.info("setRemoteServerMode()");
}
}
}//package com.google.analytics.v4
Section 208
//AnalyticsTracker (com.google.analytics.AnalyticsTracker)
package com.google.analytics {
import flash.events.*;
import com.google.analytics.v4.*;
import com.google.analytics.debug.*;
public interface AnalyticsTracker extends GoogleAnalyticsAPI, IEventDispatcher {
function set account(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics;AnalyticsTracker.as:String):void;
function get config():Configuration;
function get mode():String;
function set config(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics;AnalyticsTracker.as:Configuration):void;
function set mode(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics;AnalyticsTracker.as:String):void;
function set debug(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics;AnalyticsTracker.as:DebugConfiguration):void;
function get visualDebug():Boolean;
function get account():String;
function set visualDebug(/buRRRn/projects/GAforFlash/GA_AS3/build/tmp;com/google/analytics;AnalyticsTracker.as:Boolean):void;
function isReady():Boolean;
function get debug():DebugConfiguration;
}
}//package com.google.analytics
Section 209
//API (com.google.analytics.API)
package com.google.analytics {
import com.google.analytics.utils.*;
public class API {
public static var version:Version = new Version();
public function API(){
super();
}
version.major = 1;
version.minor = 0;
version.build = 1;
version.revision = "$Rev: 319 $ ".split(" ")[1];
}
}//package com.google.analytics
Section 210
//GATracker (com.google.analytics.GATracker)
package com.google.analytics {
import flash.events.*;
import flash.display.*;
import com.google.analytics.core.*;
import com.google.analytics.v4.*;
import com.google.analytics.debug.*;
import com.google.analytics.external.*;
import com.google.analytics.utils.*;
import com.google.analytics.events.*;
public class GATracker implements AnalyticsTracker {
private var _adSense:AdSenseGlobals;
private var _env:Environment;
private var _visualDebug:Boolean;
private var _idleTimer:IdleTimer;
private var _debug:DebugConfiguration;
private var _buffer:Buffer;
private var _config:Configuration;
private var _mode:String;
private var _display:DisplayObject;
private var _jsproxy:JavascriptProxy;
private var _dom:HTMLDOM;
private var _eventDispatcher:EventDispatcher;
private var _ready:Boolean;// = false
private var _gifRequest:GIFRequest;
private var _account:String;
private var _tracker:GoogleAnalyticsAPI;
public static var version:Version = API.version;
public static var autobuild:Boolean = true;
public function GATracker(display:DisplayObject, account:String, mode:String="AS3", visualDebug:Boolean=false, config:Configuration=null, debug:DebugConfiguration=null){
super();
_display = display;
_eventDispatcher = new EventDispatcher(this);
_tracker = new TrackerCache();
this.account = account;
this.mode = mode;
this.visualDebug = visualDebug;
if (!debug){
this.debug = new DebugConfiguration();
};
if (!config){
this.config = new Configuration(debug);
};
if (autobuild){
_factory();
};
}
public function link(targetUrl:String, useHash:Boolean=false):void{
_tracker.link(targetUrl, useHash);
}
public function addOrganic(Layout:String, Layout:String):void{
_tracker.addOrganic(Layout, Layout);
}
public function setAllowLinker(enable:Boolean):void{
_tracker.setAllowLinker(enable);
}
public function trackEvent(TrackerCache:String, TrackerCache:String, TrackerCache:String=null, TrackerCache:Number=NaN):Boolean{
return (_tracker.trackEvent(TrackerCache, TrackerCache, TrackerCache, TrackerCache));
}
public function setCookieTimeout(newDefaultTimeout:int):void{
_tracker.setCookieTimeout(newDefaultTimeout);
}
public function trackTrans():void{
_tracker.trackTrans();
}
public function getClientInfo():Boolean{
return (_tracker.getClientInfo());
}
public function trackPageview(pageURL:String=""):void{
_tracker.trackPageview(pageURL);
}
public function setClientInfo(Layout:Boolean):void{
_tracker.setClientInfo(Layout);
}
public function get account():String{
return (_account);
}
public function linkByPost(formObject:Object, useHash:Boolean=false):void{
_tracker.linkByPost(formObject, useHash);
}
public function getDetectTitle():Boolean{
return (_tracker.getDetectTitle());
}
public function dispatchEvent(event:Event):Boolean{
return (_eventDispatcher.dispatchEvent(event));
}
public function get config():Configuration{
return (_config);
}
public function set mode(value:String):void{
_mode = value;
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void{
_eventDispatcher.removeEventListener(type, listener, useCapture);
}
public function setDetectFlash(Layout:Boolean):void{
_tracker.setDetectFlash(Layout);
}
public function resetSession():void{
_tracker.resetSession();
}
public function setCampNameKey(newCampNameKey:String):void{
_tracker.setCampNameKey(newCampNameKey);
}
public function get debug():DebugConfiguration{
return (_debug);
}
public function addItem(item:String, sku:String, name:String, category:String, price:Number, quantity:int):void{
_tracker.addItem(item, sku, name, category, price, quantity);
}
private function _bridgeFactory():GoogleAnalyticsAPI{
debug.info(((("GATracker (Bridge) v" + version) + "\naccount: ") + account));
return (new Bridge(account, _debug, _jsproxy));
}
public function clearIgnoredOrganic():void{
_tracker.clearIgnoredOrganic();
}
public function set account(value:String):void{
_account = value;
}
public function setVar(newVal:String):void{
_tracker.setVar(newVal);
}
public function build():void{
if (!isReady()){
_factory();
};
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{
_eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
}
public function setDomainName(newDomainName:String):void{
_tracker.setDomainName(newDomainName);
}
public function createEventTracker(listener:String):EventTracker{
return (_tracker.createEventTracker(listener));
}
public function setCampSourceKey(newCampSrcKey:String):void{
_tracker.setCampSourceKey(newCampSrcKey);
}
public function set config(value:Configuration):void{
_config = value;
}
public function addTrans(orderId:String, affiliation:String, total:Number, tax:Number, shipping:Number, city:String, state:String, country:String):Object{
return (_tracker.addTrans(orderId, affiliation, total, tax, shipping, city, state, country));
}
public function setCampContentKey(newCampContentKey:String):void{
_tracker.setCampContentKey(newCampContentKey);
}
public function willTrigger(type:String):Boolean{
return (_eventDispatcher.willTrigger(type));
}
public function setLocalServerMode():void{
_tracker.setLocalServerMode();
}
public function getLocalGifPath():String{
return (_tracker.getLocalGifPath());
}
public function setAllowAnchor(enable:Boolean):void{
_tracker.setAllowAnchor(enable);
}
public function clearIgnoredRef():void{
_tracker.clearIgnoredRef();
}
public function isReady():Boolean{
return (_ready);
}
public function get mode():String{
return (_mode);
}
public function set debug(value:DebugConfiguration):void{
_debug = value;
}
public function setLocalGifPath(Layout:String):void{
_tracker.setLocalGifPath(Layout);
}
public function getVersion():String{
return (_tracker.getVersion());
}
public function setSampleRate(newRate:Number):void{
_tracker.setSampleRate(newRate);
}
public function setCookiePath(newCookiePath:String):void{
_tracker.setCookiePath(newCookiePath);
}
public function setAllowHash(enable:Boolean):void{
_tracker.setAllowHash(enable);
}
public function addIgnoredOrganic(Layout:String):void{
_tracker.addIgnoredOrganic(Layout);
}
public function setLocalRemoteServerMode():void{
_tracker.setLocalRemoteServerMode();
}
public function cookiePathCopy(newPath:String):void{
_tracker.cookiePathCopy(newPath);
}
private function _factory():void{
var activeTracker:GoogleAnalyticsAPI;
_jsproxy = new JavascriptProxy(debug);
if (visualDebug){
debug.layout = new Layout(debug, _display);
debug.active = visualDebug;
};
var cache:TrackerCache = (_tracker as TrackerCache);
switch (mode){
case TrackerMode.BRIDGE:
activeTracker = _bridgeFactory();
break;
case TrackerMode.AS3:
default:
activeTracker = _trackerFactory();
};
if (!cache.isEmpty()){
cache.tracker = activeTracker;
cache.flush();
};
_tracker = activeTracker;
_ready = true;
dispatchEvent(new AnalyticsEvent(AnalyticsEvent.READY, this));
}
public function setCampTermKey(newCampTermKey:String):void{
_tracker.setCampTermKey(newCampTermKey);
}
private function _trackerFactory():GoogleAnalyticsAPI{
debug.info(((("GATracker (AS3) v" + version) + "\naccount: ") + account));
_adSense = new AdSenseGlobals(debug);
_dom = new HTMLDOM(debug);
_dom.cacheProperties();
_env = new Environment("", "", "", debug, _dom);
_buffer = new Buffer(config, debug, false);
_gifRequest = new GIFRequest(config, debug, _buffer, _env);
_idleTimer = new IdleTimer(config, debug, _display, _buffer);
_env.url = _display.stage.loaderInfo.url;
return (new Tracker(account, config, debug, _env, _buffer, _gifRequest, _adSense));
}
public function setCampNOKey(newCampNOKey:String):void{
_tracker.setCampNOKey(newCampNOKey);
}
public function setDetectTitle(Layout:Boolean):void{
_tracker.setDetectTitle(Layout);
}
public function getServiceMode():ServerOperationMode{
return (_tracker.getServiceMode());
}
public function clearOrganic():void{
_tracker.clearOrganic();
}
public function setCampaignTrack(enable:Boolean):void{
_tracker.setCampaignTrack(enable);
}
public function addIgnoredRef(Layout:String):void{
_tracker.addIgnoredRef(Layout);
}
public function set visualDebug(value:Boolean):void{
_visualDebug = value;
}
public function setCampMediumKey(newCampMedKey:String):void{
_tracker.setCampMediumKey(newCampMedKey);
}
public function getDetectFlash():Boolean{
return (_tracker.getDetectFlash());
}
public function get visualDebug():Boolean{
return (_visualDebug);
}
public function hasEventListener(type:String):Boolean{
return (_eventDispatcher.hasEventListener(type));
}
public function getAccount():String{
return (_tracker.getAccount());
}
public function setSessionTimeout(newTimeout:int):void{
_tracker.setSessionTimeout(newTimeout);
}
public function setRemoteServerMode():void{
_tracker.setRemoteServerMode();
}
}
var _local1:* = ServerOperationMode;
return (_local1);
}//package com.google.analytics
Section 211
//PropTween (com.greensock.core.PropTween)
package com.greensock.core {
public class PropTween {
public var priority:int;
public var start:Number;
public var prevNode:PropTween;
public var change:Number;
public var target:Object;
public var name:String;
public var property:String;
public var nextNode:PropTween;
public var isPlugin:Boolean;
public function PropTween(target:Object, property:String, start:Number, change:Number, name:String, isPlugin:Boolean, nextNode:PropTween=null, priority:int=0){
super();
this.target = target;
this.property = property;
this.start = start;
this.change = change;
this.name = name;
this.isPlugin = isPlugin;
if (nextNode){
nextNode.prevNode = this;
this.nextNode = nextNode;
};
this.priority = priority;
}
}
}//package com.greensock.core
Section 212
//SimpleTimeline (com.greensock.core.SimpleTimeline)
package com.greensock.core {
public class SimpleTimeline extends TweenCore {
public var autoRemoveChildren:Boolean;
protected var _lastChild:TweenCore;
protected var _firstChild:TweenCore;
public function SimpleTimeline(vars:Object=null){
super(0, vars);
}
override public function renderTime(time:Number, suppressEvents:Boolean=false, force:Boolean=false):void{
var dur:Number;
var next:TweenCore;
var tween:TweenCore = _firstChild;
this.cachedTotalTime = time;
this.cachedTime = time;
while (tween) {
next = tween.nextNode;
if (((tween.active) || ((((((time >= tween.cachedStartTime)) && (!(tween.cachedPaused)))) && (!(tween.gc)))))){
if (!tween.cachedReversed){
tween.renderTime(((time - tween.cachedStartTime) * tween.cachedTimeScale), suppressEvents, false);
} else {
dur = (tween.cacheIsDirty) ? tween.totalDuration : tween.cachedTotalDuration;
tween.renderTime((dur - ((time - tween.cachedStartTime) * tween.cachedTimeScale)), suppressEvents, false);
};
};
tween = next;
};
}
public function addChild(tween:TweenCore):void{
if (((!(tween.cachedOrphan)) && (tween.timeline))){
tween.timeline.remove(tween, true);
};
tween.timeline = this;
if (tween.gc){
tween.setEnabled(true, true);
};
if (_firstChild){
_firstChild.prevNode = tween;
};
tween.nextNode = _firstChild;
_firstChild = tween;
tween.prevNode = null;
tween.cachedOrphan = false;
}
public function remove(tween:TweenCore, skipDisable:Boolean=false):void{
if (tween.cachedOrphan){
return;
};
if (!skipDisable){
tween.setEnabled(false, true);
};
if (tween.nextNode){
tween.nextNode.prevNode = tween.prevNode;
} else {
if (_lastChild == tween){
_lastChild = tween.prevNode;
};
};
if (tween.prevNode){
tween.prevNode.nextNode = tween.nextNode;
} else {
if (_firstChild == tween){
_firstChild = tween.nextNode;
};
};
tween.cachedOrphan = true;
}
public function get rawTime():Number{
return (this.cachedTotalTime);
}
}
}//package com.greensock.core
Section 213
//TweenCore (com.greensock.core.TweenCore)
package com.greensock.core {
import com.greensock.*;
public class TweenCore {
public var initted:Boolean;
protected var _hasUpdate:Boolean;
public var active:Boolean;
protected var _delay:Number;
public var cachedTime:Number;
public var cachedReversed:Boolean;
public var nextNode:TweenCore;
protected var _rawPrevTime:Number;// = -1
public var vars:Object;
public var cachedTotalTime:Number;
public var data;
public var timeline:SimpleTimeline;
public var cachedOrphan:Boolean;
public var cachedStartTime:Number;
public var prevNode:TweenCore;
public var cachedDuration:Number;
public var gc:Boolean;
protected var _pauseTime:Number;
public var cacheIsDirty:Boolean;
public var cachedPaused:Boolean;
public var cachedTimeScale:Number;
public var cachedTotalDuration:Number;
public static const version:Number = 1.382;
protected static var _classInitted:Boolean;
public function TweenCore(duration:Number=0, vars:Object=null){
super();
this.vars = ((vars)!=null) ? vars : {};
this.cachedDuration = (this.cachedTotalDuration = duration);
_delay = (this.vars.delay) ? Number(this.vars.delay) : 0;
this.cachedTimeScale = (this.vars.timeScale) ? Number(this.vars.timeScale) : 1;
this.active = Boolean((((((duration == 0)) && ((_delay == 0)))) && (!((this.vars.immediateRender == false)))));
this.cachedTotalTime = (this.cachedTime = 0);
this.data = this.vars.data;
if (!_classInitted){
if (isNaN(TweenLite.rootFrame)){
TweenLite.initClass();
_classInitted = true;
} else {
return;
};
};
var tl:SimpleTimeline = ((this.vars.timeline is SimpleTimeline)) ? this.vars.timeline : (this.vars.useFrames) ? TweenLite.rootFramesTimeline : TweenLite.rootTimeline;
this.cachedStartTime = (tl.cachedTotalTime + _delay);
tl.addChild(this);
if (this.vars.reversed){
this.cachedReversed = true;
};
if (this.vars.paused){
this.paused = true;
};
}
public function renderTime(time:Number, suppressEvents:Boolean=false, force:Boolean=false):void{
}
public function get delay():Number{
return (_delay);
}
public function restart(includeDelay:Boolean=false, suppressEvents:Boolean=true):void{
this.reversed = false;
this.paused = false;
this.setTotalTime((includeDelay) ? -(_delay) : 0, suppressEvents);
}
public function get duration():Number{
return (this.cachedDuration);
}
public function set reversed(b:Boolean):void{
if (b != this.cachedReversed){
this.cachedReversed = b;
setTotalTime(this.cachedTotalTime, true);
};
}
public function set startTime(n:Number):void{
var adjust:Boolean = Boolean(((!((this.timeline == null))) && (((!((n == this.cachedStartTime))) || (this.gc)))));
this.cachedStartTime = n;
if (adjust){
this.timeline.addChild(this);
};
}
public function set delay(n:Number):void{
this.startTime = (this.startTime + (n - _delay));
_delay = n;
}
public function resume():void{
this.paused = false;
}
public function get paused():Boolean{
return (this.cachedPaused);
}
public function play():void{
this.reversed = false;
this.paused = false;
}
public function set duration(n:Number):void{
this.cachedDuration = (this.cachedTotalDuration = n);
setDirtyCache(false);
}
public function invalidate():void{
}
public function complete(skipRender:Boolean=false, suppressEvents:Boolean=false):void{
if (!skipRender){
renderTime(this.totalDuration, suppressEvents, false);
return;
};
if (this.timeline.autoRemoveChildren){
this.setEnabled(false, false);
} else {
this.active = false;
};
if (!suppressEvents){
if (((((this.vars.onComplete) && ((this.cachedTotalTime == this.cachedTotalDuration)))) && (!(this.cachedReversed)))){
this.vars.onComplete.apply(null, this.vars.onCompleteParams);
} else {
if (((((this.cachedReversed) && ((this.cachedTotalTime == 0)))) && (this.vars.onReverseComplete))){
this.vars.onReverseComplete.apply(null, this.vars.onReverseCompleteParams);
};
};
};
}
public function get reversed():Boolean{
return (this.cachedReversed);
}
public function get totalTime():Number{
return (this.cachedTotalTime);
}
public function get startTime():Number{
return (this.cachedStartTime);
}
public function set currentTime(n:Number):void{
setTotalTime(n, false);
}
protected function setDirtyCache(includeSelf:Boolean=true):void{
var tween:TweenCore = (includeSelf) ? this : this.timeline;
while (tween) {
tween.cacheIsDirty = true;
tween = tween.timeline;
};
}
public function reverse(forceResume:Boolean=true):void{
this.reversed = true;
if (forceResume){
this.paused = false;
} else {
if (this.gc){
this.setEnabled(true, false);
};
};
}
public function set paused(b:Boolean):void{
if (((!((b == this.cachedPaused))) && (this.timeline))){
if (b){
_pauseTime = this.timeline.rawTime;
} else {
this.cachedStartTime = (this.cachedStartTime + (this.timeline.rawTime - _pauseTime));
_pauseTime = NaN;
setDirtyCache(false);
};
this.cachedPaused = b;
this.active = Boolean(((((!(this.cachedPaused)) && ((this.cachedTotalTime > 0)))) && ((this.cachedTotalTime < this.cachedTotalDuration))));
};
if (((!(b)) && (this.gc))){
this.setTotalTime(this.cachedTotalTime, false);
this.setEnabled(true, false);
};
}
public function kill():void{
setEnabled(false, false);
}
public function set totalTime(n:Number):void{
setTotalTime(n, false);
}
public function get currentTime():Number{
return (this.cachedTime);
}
protected function setTotalTime(time:Number, suppressEvents:Boolean=false):void{
var tlTime:Number;
var dur:Number;
if (this.timeline){
tlTime = (((_pauseTime) || ((_pauseTime == 0)))) ? _pauseTime : this.timeline.cachedTotalTime;
if (this.cachedReversed){
dur = (this.cacheIsDirty) ? this.totalDuration : this.cachedTotalDuration;
this.cachedStartTime = (tlTime - ((dur - time) / this.cachedTimeScale));
} else {
this.cachedStartTime = (tlTime - (time / this.cachedTimeScale));
};
if (!this.timeline.cacheIsDirty){
setDirtyCache(false);
};
if (this.cachedTotalTime != time){
renderTime(time, suppressEvents, false);
};
};
}
public function pause():void{
this.paused = true;
}
public function set totalDuration(n:Number):void{
this.duration = n;
}
public function get totalDuration():Number{
return (this.cachedTotalDuration);
}
public function setEnabled(enabled:Boolean, ignoreTimeline:Boolean=false):Boolean{
this.gc = !(enabled);
if (enabled){
this.active = Boolean(((((!(this.cachedPaused)) && ((this.cachedTotalTime > 0)))) && ((this.cachedTotalTime < this.cachedTotalDuration))));
if (((!(ignoreTimeline)) && (this.cachedOrphan))){
this.timeline.addChild(this);
};
} else {
this.active = false;
if (((!(ignoreTimeline)) && (!(this.cachedOrphan)))){
this.timeline.remove(this, true);
};
};
return (false);
}
}
}//package com.greensock.core
Section 214
//TransformEvent (com.greensock.events.TransformEvent)
package com.greensock.events {
import flash.events.*;
public class TransformEvent extends Event {
public var items:Array;
public var mouseEvent:MouseEvent;
public static const FINISH_INTERACTIVE_SCALE:String = "tmFinishInteractiveScale";
public static const START_INTERACTIVE_SCALE:String = "tmStartInteractiveScale";
public static const UPDATE:String = "tmUpdate";
public static const START_INTERACTIVE_MOVE:String = "tmStartInteractiveMove";
public static const DEPTH_CHANGE:String = "tmDepthChange";
public static const ROLL_OUT_SELECTED:String = "tmRollOutSelected";
public static const MOVE:String = "tmMove";
public static const SEIZE_CURSOR:String = "tmSeizeCursor";
public static const START_INTERACTIVE_ROTATE:String = "tmStartInteractiveRotate";
public static const CLICK_OFF:String = "tmClickOff";
public static const ROTATE:String = "tmRotate";
public static const DESTROY:String = "tmDestroy";
public static const SELECTION_CHANGE:String = "tmSelectionChange";
public static const ROLL_OVER_SELECTED:String = "tmRollOverSelected";
public static const DOUBLE_CLICK:String = "tmDoubleClick";
public static const SCALE:String = "tmScale";
public static const DELETE:String = "tmDelete";
public static const RELEASE_CURSOR:String = "tmReleaseCursor";
public static const FINISH_INTERACTIVE_MOVE:String = "tmFinishInteractiveMove";
public static const FINISH_INTERACTIVE_ROTATE:String = "tmFinishInteractiveRotate";
public static const MOUSE_DOWN:String = "tmMouseDown";
public static const SELECT_MOUSE_UP:String = "tmSelectMouseUp";
public static const SELECT:String = "tmSelect";
public static const DESELECT:String = "tmDeselect";
public static const SELECT_MOUSE_DOWN:String = "tmSelectMouseDown";
public function TransformEvent($type:String, $items:Array, $mouseEvent:MouseEvent=null, $bubbles:Boolean=false, $cancelable:Boolean=false){
super($type, $bubbles, $cancelable);
this.items = $items;
this.mouseEvent = $mouseEvent;
}
override public function clone():Event{
return (new TransformEvent(this.type, this.items, this.mouseEvent, this.bubbles, this.cancelable));
}
}
}//package com.greensock.events
Section 215
//TweenEvent (com.greensock.events.TweenEvent)
package com.greensock.events {
import flash.events.*;
public class TweenEvent extends Event {
public static const COMPLETE:String = "complete";
public static const START:String = "start";
public static const UPDATE:String = "change";
public static const REVERSE_COMPLETE:String = "reverseComplete";
public static const INIT:String = "init";
public static const VERSION:Number = 1.1;
public static const REPEAT:String = "repeat";
public function TweenEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
}
override public function clone():Event{
return (new TweenEvent(this.type, this.bubbles, this.cancelable));
}
}
}//package com.greensock.events
Section 216
//AutoAlphaPlugin (com.greensock.plugins.AutoAlphaPlugin)
package com.greensock.plugins {
import com.greensock.*;
public class AutoAlphaPlugin extends TweenPlugin {
protected var _target:Object;
protected var _ignoreVisible:Boolean;
public static const API:Number = 1;
public function AutoAlphaPlugin(){
super();
this.propName = "autoAlpha";
this.overwriteProps = ["alpha", "visible"];
}
override public function killProps(lookup:Object):void{
super.killProps(lookup);
_ignoreVisible = Boolean(("visible" in lookup));
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
_target = target;
addTween(target, "alpha", target.alpha, value, "alpha");
return (true);
}
override public function set changeFactor(n:Number):void{
updateTweens(n);
if (!_ignoreVisible){
_target.visible = Boolean(!((_target.alpha == 0)));
};
}
}
}//package com.greensock.plugins
Section 217
//BevelFilterPlugin (com.greensock.plugins.BevelFilterPlugin)
package com.greensock.plugins {
import com.greensock.*;
import flash.filters.*;
public class BevelFilterPlugin extends FilterPlugin {
public static const API:Number = 1;
private static var _propNames:Array = ["distance", "angle", "highlightColor", "highlightAlpha", "shadowColor", "shadowAlpha", "blurX", "blurY", "strength", "quality"];
public function BevelFilterPlugin(){
super();
this.propName = "bevelFilter";
this.overwriteProps = ["bevelFilter"];
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
_target = target;
_type = BevelFilter;
initFilter(value, new BevelFilter(0, 0, 0xFFFFFF, 0.5, 0, 0.5, 2, 2, 0, ((value.quality) || (2))), _propNames);
return (true);
}
}
}//package com.greensock.plugins
Section 218
//BezierPlugin (com.greensock.plugins.BezierPlugin)
package com.greensock.plugins {
import com.greensock.*;
public class BezierPlugin extends TweenPlugin {
protected var _future:Object;
protected var _orient:Boolean;
protected var _orientData:Array;
protected var _target:Object;
protected var _beziers:Object;
public static const API:Number = 1;
protected static const _RAD2DEG:Number = 57.2957795130823;
public function BezierPlugin(){
_future = {};
super();
this.propName = "bezier";
this.overwriteProps = [];
}
override public function killProps(lookup:Object):void{
var p:String;
for (p in _beziers) {
if ((p in lookup)){
delete _beziers[p];
};
};
super.killProps(lookup);
}
protected function init(tween:TweenLite, beziers:Array, through:Boolean):void{
var i:int;
var p:String;
var killVarsLookup:Object;
_target = tween.target;
var enumerables:Object = ((tween.vars.isTV)==true) ? tween.vars.exposedVars : tween.vars;
if (enumerables.orientToBezier == true){
_orientData = [["x", "y", "rotation", 0, 0.01]];
_orient = true;
} else {
if ((enumerables.orientToBezier is Array)){
_orientData = enumerables.orientToBezier;
_orient = true;
};
};
var props:Object = {};
i = 0;
while (i < beziers.length) {
for (p in beziers[i]) {
if (props[p] == undefined){
props[p] = [tween.target[p]];
};
if (typeof(beziers[i][p]) == "number"){
props[p].push(beziers[i][p]);
} else {
props[p].push((tween.target[p] + Number(beziers[i][p])));
};
};
i++;
};
for (p in props) {
this.overwriteProps[this.overwriteProps.length] = p;
if (enumerables[p] != undefined){
if (typeof(enumerables[p]) == "number"){
props[p].push(enumerables[p]);
} else {
props[p].push((tween.target[p] + Number(enumerables[p])));
};
killVarsLookup = {};
killVarsLookup[p] = true;
tween.killVars(killVarsLookup, false);
delete enumerables[p];
};
};
_beziers = parseBeziers(props, through);
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
if (!(value is Array)){
return (false);
};
init(tween, (value as Array), false);
return (true);
}
override public function set changeFactor(n:Number):void{
var i:int;
var p:String;
var b:Object;
var t:Number;
var segments:uint;
var val:Number;
var curVals:Object;
var dx:Number;
var dy:Number;
var cotb:Array;
var toAdd:Number;
var oldTarget:Object;
var oldRound:Boolean;
_changeFactor = n;
if (n == 1){
for (p in _beziers) {
i = (_beziers[p].length - 1);
_target[p] = _beziers[p][i][2];
};
} else {
for (p in _beziers) {
segments = _beziers[p].length;
if (n < 0){
i = 0;
} else {
if (n >= 1){
i = (segments - 1);
} else {
i = int((segments * n));
};
};
t = ((n - (i * (1 / segments))) * segments);
b = _beziers[p][i];
if (this.round){
val = (b[0] + (t * (((2 * (1 - t)) * (b[1] - b[0])) + (t * (b[2] - b[0])))));
_target[p] = ((val)>0) ? int((val + 0.5)) : int((val - 0.5));
} else {
_target[p] = (b[0] + (t * (((2 * (1 - t)) * (b[1] - b[0])) + (t * (b[2] - b[0])))));
};
};
};
if (_orient){
i = _orientData.length;
curVals = {};
while (i--) {
cotb = _orientData[i];
curVals[cotb[0]] = _target[cotb[0]];
curVals[cotb[1]] = _target[cotb[1]];
};
oldTarget = _target;
oldRound = this.round;
_target = _future;
this.round = false;
_orient = false;
i = _orientData.length;
while (i--) {
cotb = _orientData[i];
this.changeFactor = (n + ((cotb[4]) || (0.01)));
toAdd = ((cotb[3]) || (0));
dx = (_future[cotb[0]] - curVals[cotb[0]]);
dy = (_future[cotb[1]] - curVals[cotb[1]]);
oldTarget[cotb[2]] = ((Math.atan2(dy, dx) * _RAD2DEG) + toAdd);
};
_target = oldTarget;
this.round = oldRound;
_orient = true;
};
}
public static function parseBeziers(props:Object, through:Boolean=false):Object{
var i:int;
var a:Array;
var b:Object;
var p:String;
var all:Object = {};
if (through){
for (p in props) {
a = props[p];
b = [];
all[p] = b;
if (a.length > 2){
b[b.length] = [a[0], (a[1] - ((a[2] - a[0]) / 4)), a[1]];
i = 1;
while (i < (a.length - 1)) {
b[b.length] = [a[i], (a[i] + (a[i] - b[(i - 1)][1])), a[(i + 1)]];
i++;
};
} else {
b[b.length] = [a[0], ((a[0] + a[1]) / 2), a[1]];
};
};
} else {
for (p in props) {
a = props[p];
b = [];
all[p] = b;
if (a.length > 3){
b[b.length] = [a[0], a[1], ((a[1] + a[2]) / 2)];
i = 2;
while (i < (a.length - 2)) {
b[b.length] = [b[(i - 2)][2], a[i], ((a[i] + a[(i + 1)]) / 2)];
i++;
};
b[b.length] = [b[(b.length - 1)][2], a[(a.length - 2)], a[(a.length - 1)]];
} else {
if (a.length == 3){
b[b.length] = [a[0], a[1], a[2]];
} else {
if (a.length == 2){
b[b.length] = [a[0], ((a[0] + a[1]) / 2), a[1]];
};
};
};
};
};
return (all);
}
}
}//package com.greensock.plugins
Section 219
//BezierThroughPlugin (com.greensock.plugins.BezierThroughPlugin)
package com.greensock.plugins {
import com.greensock.*;
public class BezierThroughPlugin extends BezierPlugin {
public static const API:Number = 1;
public function BezierThroughPlugin(){
super();
this.propName = "bezierThrough";
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
if (!(value is Array)){
return (false);
};
init(tween, (value as Array), true);
return (true);
}
}
}//package com.greensock.plugins
Section 220
//BlurFilterPlugin (com.greensock.plugins.BlurFilterPlugin)
package com.greensock.plugins {
import com.greensock.*;
import flash.filters.*;
public class BlurFilterPlugin extends FilterPlugin {
public static const API:Number = 1;
private static var _propNames:Array = ["blurX", "blurY", "quality"];
public function BlurFilterPlugin(){
super();
this.propName = "blurFilter";
this.overwriteProps = ["blurFilter"];
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
_target = target;
_type = BlurFilter;
initFilter(value, new BlurFilter(0, 0, ((value.quality) || (2))), _propNames);
return (true);
}
}
}//package com.greensock.plugins
Section 221
//ColorMatrixFilterPlugin (com.greensock.plugins.ColorMatrixFilterPlugin)
package com.greensock.plugins {
import com.greensock.*;
import flash.filters.*;
public class ColorMatrixFilterPlugin extends FilterPlugin {
protected var _matrix:Array;
protected var _matrixTween:EndArrayPlugin;
public static const API:Number = 1;
private static var _propNames:Array = [];
protected static var _lumG:Number = 0.71516;
protected static var _lumR:Number = 0.212671;
protected static var _idMatrix:Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
protected static var _lumB:Number = 0.072169;
public function ColorMatrixFilterPlugin(){
super();
this.propName = "colorMatrixFilter";
this.overwriteProps = ["colorMatrixFilter"];
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
_target = target;
_type = ColorMatrixFilter;
var cmf:Object = value;
initFilter({remove:value.remove, index:value.index, addFilter:value.addFilter}, new ColorMatrixFilter(_idMatrix.slice()), _propNames);
_matrix = ColorMatrixFilter(_filter).matrix;
var endMatrix:Array = [];
if (((!((cmf.matrix == null))) && ((cmf.matrix is Array)))){
endMatrix = cmf.matrix;
} else {
if (cmf.relative == true){
endMatrix = _matrix.slice();
} else {
endMatrix = _idMatrix.slice();
};
endMatrix = setBrightness(endMatrix, cmf.brightness);
endMatrix = setContrast(endMatrix, cmf.contrast);
endMatrix = setHue(endMatrix, cmf.hue);
endMatrix = setSaturation(endMatrix, cmf.saturation);
endMatrix = setThreshold(endMatrix, cmf.threshold);
if (!isNaN(cmf.colorize)){
endMatrix = colorize(endMatrix, cmf.colorize, cmf.amount);
};
};
_matrixTween = new EndArrayPlugin();
_matrixTween.init(_matrix, endMatrix);
return (true);
}
override public function set changeFactor(n:Number):void{
_matrixTween.changeFactor = n;
ColorMatrixFilter(_filter).matrix = _matrix;
super.changeFactor = n;
}
public static function setSaturation(m:Array, n:Number):Array{
if (isNaN(n)){
return (m);
};
var inv:Number = (1 - n);
var r:Number = (inv * _lumR);
var g:Number = (inv * _lumG);
var b:Number = (inv * _lumB);
var temp:Array = [(r + n), g, b, 0, 0, r, (g + n), b, 0, 0, r, g, (b + n), 0, 0, 0, 0, 0, 1, 0];
return (applyMatrix(temp, m));
}
public static function setHue(m:Array, n:Number):Array{
if (isNaN(n)){
return (m);
};
n = (n * (Math.PI / 180));
var c:Number = Math.cos(n);
var s:Number = Math.sin(n);
var temp:Array = [((_lumR + (c * (1 - _lumR))) + (s * -(_lumR))), ((_lumG + (c * -(_lumG))) + (s * -(_lumG))), ((_lumB + (c * -(_lumB))) + (s * (1 - _lumB))), 0, 0, ((_lumR + (c * -(_lumR))) + (s * 0.143)), ((_lumG + (c * (1 - _lumG))) + (s * 0.14)), ((_lumB + (c * -(_lumB))) + (s * -0.283)), 0, 0, ((_lumR + (c * -(_lumR))) + (s * -((1 - _lumR)))), ((_lumG + (c * -(_lumG))) + (s * _lumG)), ((_lumB + (c * (1 - _lumB))) + (s * _lumB)), 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1];
return (applyMatrix(temp, m));
}
public static function setContrast(m:Array, n:Number):Array{
if (isNaN(n)){
return (m);
};
n = (n + 0.01);
var temp:Array = [n, 0, 0, 0, (128 * (1 - n)), 0, n, 0, 0, (128 * (1 - n)), 0, 0, n, 0, (128 * (1 - n)), 0, 0, 0, 1, 0];
return (applyMatrix(temp, m));
}
public static function applyMatrix(m:Array, m2:Array):Array{
var y:int;
var x:int;
if (((!((m is Array))) || (!((m2 is Array))))){
return (m2);
};
var temp:Array = [];
var i:int;
var z:int;
y = 0;
while (y < 4) {
x = 0;
while (x < 5) {
if (x == 4){
z = m[(i + 4)];
} else {
z = 0;
};
temp[(i + x)] = (((((m[i] * m2[x]) + (m[(i + 1)] * m2[(x + 5)])) + (m[(i + 2)] * m2[(x + 10)])) + (m[(i + 3)] * m2[(x + 15)])) + z);
x++;
};
i = (i + 5);
y++;
};
return (temp);
}
public static function setThreshold(m:Array, n:Number):Array{
if (isNaN(n)){
return (m);
};
var temp:Array = [(_lumR * 0x0100), (_lumG * 0x0100), (_lumB * 0x0100), 0, (-256 * n), (_lumR * 0x0100), (_lumG * 0x0100), (_lumB * 0x0100), 0, (-256 * n), (_lumR * 0x0100), (_lumG * 0x0100), (_lumB * 0x0100), 0, (-256 * n), 0, 0, 0, 1, 0];
return (applyMatrix(temp, m));
}
public static function colorize(m:Array, color:Number, amount:Number=1):Array{
if (isNaN(color)){
return (m);
};
if (isNaN(amount)){
amount = 1;
};
var r:Number = (((color >> 16) & 0xFF) / 0xFF);
var g:Number = (((color >> 8) & 0xFF) / 0xFF);
var b:Number = ((color & 0xFF) / 0xFF);
var inv:Number = (1 - amount);
var temp:Array = [(inv + ((amount * r) * _lumR)), ((amount * r) * _lumG), ((amount * r) * _lumB), 0, 0, ((amount * g) * _lumR), (inv + ((amount * g) * _lumG)), ((amount * g) * _lumB), 0, 0, ((amount * b) * _lumR), ((amount * b) * _lumG), (inv + ((amount * b) * _lumB)), 0, 0, 0, 0, 0, 1, 0];
return (applyMatrix(temp, m));
}
public static function setBrightness(m:Array, n:Number):Array{
if (isNaN(n)){
return (m);
};
n = ((n * 100) - 100);
return (applyMatrix([1, 0, 0, 0, n, 0, 1, 0, 0, n, 0, 0, 1, 0, n, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], m));
}
}
}//package com.greensock.plugins
Section 222
//ColorTransformPlugin (com.greensock.plugins.ColorTransformPlugin)
package com.greensock.plugins {
import flash.display.*;
import com.greensock.*;
import flash.geom.*;
public class ColorTransformPlugin extends TintPlugin {
public static const API:Number = 1;
public function ColorTransformPlugin(){
super();
this.propName = "colorTransform";
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
var p:String;
var ratio:Number;
if (!(target is DisplayObject)){
return (false);
};
var end:ColorTransform = target.transform.colorTransform;
for (p in value) {
if ((((p == "tint")) || ((p == "color")))){
if (value[p] != null){
end.color = int(value[p]);
};
} else {
if ((((((p == "tintAmount")) || ((p == "exposure")))) || ((p == "brightness")))){
} else {
end[p] = value[p];
};
};
};
if (!isNaN(value.tintAmount)){
ratio = (value.tintAmount / (1 - (((end.redMultiplier + end.greenMultiplier) + end.blueMultiplier) / 3)));
end.redOffset = (end.redOffset * ratio);
end.greenOffset = (end.greenOffset * ratio);
end.blueOffset = (end.blueOffset * ratio);
end.redMultiplier = (end.greenMultiplier = (end.blueMultiplier = (1 - value.tintAmount)));
} else {
if (!isNaN(value.exposure)){
end.redOffset = (end.greenOffset = (end.blueOffset = (0xFF * (value.exposure - 1))));
end.redMultiplier = (end.greenMultiplier = (end.blueMultiplier = 1));
} else {
if (!isNaN(value.brightness)){
end.redOffset = (end.greenOffset = (end.blueOffset = Math.max(0, ((value.brightness - 1) * 0xFF))));
end.redMultiplier = (end.greenMultiplier = (end.blueMultiplier = (1 - Math.abs((value.brightness - 1)))));
};
};
};
_ignoreAlpha = Boolean(((!((tween.vars.alpha == undefined))) && ((value.alphaMultiplier == undefined))));
init((target as DisplayObject), end);
return (true);
}
}
}//package com.greensock.plugins
Section 223
//DropShadowFilterPlugin (com.greensock.plugins.DropShadowFilterPlugin)
package com.greensock.plugins {
import com.greensock.*;
import flash.filters.*;
public class DropShadowFilterPlugin extends FilterPlugin {
public static const API:Number = 1;
private static var _propNames:Array = ["distance", "angle", "color", "alpha", "blurX", "blurY", "strength", "quality", "inner", "knockout", "hideObject"];
public function DropShadowFilterPlugin(){
super();
this.propName = "dropShadowFilter";
this.overwriteProps = ["dropShadowFilter"];
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
_target = target;
_type = DropShadowFilter;
initFilter(value, new DropShadowFilter(0, 45, 0, 0, 0, 0, 1, ((value.quality) || (2)), value.inner, value.knockout, value.hideObject), _propNames);
return (true);
}
}
}//package com.greensock.plugins
Section 224
//EndArrayPlugin (com.greensock.plugins.EndArrayPlugin)
package com.greensock.plugins {
import com.greensock.*;
public class EndArrayPlugin extends TweenPlugin {
protected var _a:Array;
protected var _info:Array;
public static const API:Number = 1;
public function EndArrayPlugin(){
_info = [];
super();
this.propName = "endArray";
this.overwriteProps = ["endArray"];
}
public function init(start:Array, end:Array):void{
_a = start;
var i:int = end.length;
while (i--) {
if (((!((start[i] == end[i]))) && (!((start[i] == null))))){
_info[_info.length] = new ArrayTweenInfo(i, _a[i], (end[i] - _a[i]));
};
};
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
if (((!((target is Array))) || (!((value is Array))))){
return (false);
};
init((target as Array), value);
return (true);
}
override public function set changeFactor(n:Number):void{
var ti:ArrayTweenInfo;
var val:Number;
var i:int = _info.length;
if (this.round){
while (i--) {
ti = _info[i];
val = (ti.start + (ti.change * n));
_a[ti.index] = ((val)>0) ? int((val + 0.5)) : int((val - 0.5));
};
} else {
while (i--) {
ti = _info[i];
_a[ti.index] = (ti.start + (ti.change * n));
};
};
}
}
}//package com.greensock.plugins
class ArrayTweenInfo {
public var change:Number;
public var start:Number;
public var index:uint;
private function ArrayTweenInfo(index:uint, start:Number, change:Number){
super();
this.index = index;
this.start = start;
this.change = change;
}
}
Section 225
//FilterPlugin (com.greensock.plugins.FilterPlugin)
package com.greensock.plugins {
import com.greensock.core.*;
import flash.filters.*;
public class FilterPlugin extends TweenPlugin {
protected var _remove:Boolean;
protected var _target:Object;
protected var _index:int;
protected var _filter:BitmapFilter;
protected var _type:Class;
public static const VERSION:Number = 2.03;
public static const API:Number = 1;
public function FilterPlugin(){
super();
}
public function onCompleteTween():void{
var filters:Array;
var i:int;
if (_remove){
filters = _target.filters;
if (!(filters[_index] is _type)){
i = filters.length;
while (i--) {
if ((filters[i] is _type)){
filters.splice(i, 1);
break;
};
};
} else {
filters.splice(_index, 1);
};
_target.filters = filters;
};
}
protected function initFilter(props:Object, defaultFilter:BitmapFilter, propNames:Array):void{
var p:String;
var i:int;
var colorTween:HexColorsPlugin;
var filters:Array = _target.filters;
var extras:Object = ((props is BitmapFilter)) ? {} : props;
_index = -1;
if (extras.index != null){
_index = extras.index;
} else {
i = filters.length;
while (i--) {
if ((filters[i] is _type)){
_index = i;
break;
};
};
};
if ((((((_index == -1)) || ((filters[_index] == null)))) || ((extras.addFilter == true)))){
_index = ((extras.index)!=null) ? extras.index : filters.length;
filters[_index] = defaultFilter;
_target.filters = filters;
};
_filter = filters[_index];
if (extras.remove == true){
_remove = true;
this.onComplete = onCompleteTween;
};
i = propNames.length;
while (i--) {
p = propNames[i];
if ((((p in props)) && (!((_filter[p] == props[p]))))){
if ((((((p == "color")) || ((p == "highlightColor")))) || ((p == "shadowColor")))){
colorTween = new HexColorsPlugin();
colorTween.initColor(_filter, p, _filter[p], props[p]);
_tweens[_tweens.length] = new PropTween(colorTween, "changeFactor", 0, 1, p, false);
} else {
if ((((((((p == "quality")) || ((p == "inner")))) || ((p == "knockout")))) || ((p == "hideObject")))){
_filter[p] = props[p];
} else {
addTween(_filter, p, _filter[p], props[p], p);
};
};
};
};
}
override public function set changeFactor(n:Number):void{
var ti:PropTween;
var i:int = _tweens.length;
var filters:Array = _target.filters;
while (i--) {
ti = _tweens[i];
ti.target[ti.property] = (ti.start + (ti.change * n));
};
if (!(filters[_index] is _type)){
i = (_index = filters.length);
while (i--) {
if ((filters[i] is _type)){
_index = i;
break;
};
};
};
filters[_index] = _filter;
_target.filters = filters;
}
}
}//package com.greensock.plugins
Section 226
//FrameLabelPlugin (com.greensock.plugins.FrameLabelPlugin)
package com.greensock.plugins {
import flash.display.*;
import com.greensock.*;
public class FrameLabelPlugin extends FramePlugin {
public static const API:Number = 1;
public function FrameLabelPlugin(){
super();
this.propName = "frameLabel";
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
if ((!(tween.target) is MovieClip)){
return (false);
};
_target = (target as MovieClip);
this.frame = _target.currentFrame;
var labels:Array = _target.currentLabels;
var label:String = value;
var endFrame:int = _target.currentFrame;
var i:int = labels.length;
while (i--) {
if (labels[i].name == label){
endFrame = labels[i].frame;
break;
};
};
if (this.frame != endFrame){
addTween(this, "frame", this.frame, endFrame, "frame");
};
return (true);
}
}
}//package com.greensock.plugins
Section 227
//FramePlugin (com.greensock.plugins.FramePlugin)
package com.greensock.plugins {
import flash.display.*;
import com.greensock.*;
public class FramePlugin extends TweenPlugin {
protected var _target:MovieClip;
public var frame:int;
public static const API:Number = 1;
public function FramePlugin(){
super();
this.propName = "frame";
this.overwriteProps = ["frame", "frameLabel"];
this.round = true;
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
if (((!((target is MovieClip))) || (isNaN(value)))){
return (false);
};
_target = (target as MovieClip);
this.frame = _target.currentFrame;
addTween(this, "frame", this.frame, value, "frame");
return (true);
}
override public function set changeFactor(n:Number):void{
updateTweens(n);
_target.gotoAndStop(this.frame);
}
}
}//package com.greensock.plugins
Section 228
//GlowFilterPlugin (com.greensock.plugins.GlowFilterPlugin)
package com.greensock.plugins {
import com.greensock.*;
import flash.filters.*;
public class GlowFilterPlugin extends FilterPlugin {
public static const API:Number = 1;
private static var _propNames:Array = ["color", "alpha", "blurX", "blurY", "strength", "quality", "inner", "knockout"];
public function GlowFilterPlugin(){
super();
this.propName = "glowFilter";
this.overwriteProps = ["glowFilter"];
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
_target = target;
_type = GlowFilter;
initFilter(value, new GlowFilter(0xFFFFFF, 0, 0, 0, ((value.strength) || (1)), ((value.quality) || (2)), value.inner, value.knockout), _propNames);
return (true);
}
}
}//package com.greensock.plugins
Section 229
//HexColorsPlugin (com.greensock.plugins.HexColorsPlugin)
package com.greensock.plugins {
import com.greensock.*;
public class HexColorsPlugin extends TweenPlugin {
protected var _colors:Array;
public static const API:Number = 1;
public function HexColorsPlugin(){
super();
this.propName = "hexColors";
this.overwriteProps = [];
_colors = [];
}
override public function killProps(lookup:Object):void{
var i:int = (_colors.length - 1);
while (i > -1) {
if (lookup[_colors[i][1]] != undefined){
_colors.splice(i, 1);
};
i--;
};
super.killProps(lookup);
}
public function initColor(target:Object, propName:String, start:uint, end:uint):void{
var r:Number;
var g:Number;
var b:Number;
if (start != end){
r = (start >> 16);
g = ((start >> 8) & 0xFF);
b = (start & 0xFF);
_colors[_colors.length] = [target, propName, r, ((end >> 16) - r), g, (((end >> 8) & 0xFF) - g), b, ((end & 0xFF) - b)];
this.overwriteProps[this.overwriteProps.length] = propName;
};
}
override public function set changeFactor(n:Number):void{
var a:Array;
var i:int = _colors.length;
while (--i > -1) {
a = _colors[i];
a[0][a[1]] = ((((a[2] + (n * a[3])) << 16) | ((a[4] + (n * a[5])) << 8)) | (a[6] + (n * a[7])));
};
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
var p:String;
for (p in value) {
initColor(target, p, uint(target[p]), uint(value[p]));
};
return (true);
}
}
}//package com.greensock.plugins
Section 230
//RemoveTintPlugin (com.greensock.plugins.RemoveTintPlugin)
package com.greensock.plugins {
public class RemoveTintPlugin extends TintPlugin {
public static const API:Number = 1;
public function RemoveTintPlugin(){
super();
this.propName = "removeTint";
}
}
}//package com.greensock.plugins
Section 231
//RoundPropsPlugin (com.greensock.plugins.RoundPropsPlugin)
package com.greensock.plugins {
public class RoundPropsPlugin extends TweenPlugin {
public static const API:Number = 1;
public function RoundPropsPlugin(){
super();
this.propName = "roundProps";
this.overwriteProps = [];
this.round = true;
}
public function add(object:Object, propName:String, start:Number, change:Number):void{
addTween(object, propName, start, (start + change), propName);
this.overwriteProps[this.overwriteProps.length] = propName;
}
}
}//package com.greensock.plugins
Section 232
//ShortRotationPlugin (com.greensock.plugins.ShortRotationPlugin)
package com.greensock.plugins {
import com.greensock.*;
public class ShortRotationPlugin extends TweenPlugin {
public static const API:Number = 1;
public function ShortRotationPlugin(){
super();
this.propName = "shortRotation";
this.overwriteProps = [];
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
var p:String;
if (typeof(value) == "number"){
return (false);
};
for (p in value) {
initRotation(target, p, target[p], ((typeof(value[p]))=="number") ? Number(value[p]) : (target[p] + Number(value[p])));
};
return (true);
}
public function initRotation(target:Object, propName:String, start:Number, end:Number):void{
var dif:Number = ((end - start) % 360);
if (dif != (dif % 180)){
dif = ((dif)<0) ? (dif + 360) : (dif - 360);
};
addTween(target, propName, start, (start + dif), propName);
this.overwriteProps[this.overwriteProps.length] = propName;
}
}
}//package com.greensock.plugins
Section 233
//TintPlugin (com.greensock.plugins.TintPlugin)
package com.greensock.plugins {
import flash.display.*;
import com.greensock.*;
import com.greensock.core.*;
import flash.geom.*;
public class TintPlugin extends TweenPlugin {
protected var _ct:ColorTransform;
protected var _transform:Transform;
protected var _ignoreAlpha:Boolean;
public static const API:Number = 1;
protected static var _props:Array = ["redMultiplier", "greenMultiplier", "blueMultiplier", "alphaMultiplier", "redOffset", "greenOffset", "blueOffset", "alphaOffset"];
public function TintPlugin(){
super();
this.propName = "tint";
this.overwriteProps = ["tint"];
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
if (!(target is DisplayObject)){
return (false);
};
var end:ColorTransform = new ColorTransform();
if (((!((value == null))) && (!((tween.vars.removeTint == true))))){
end.color = uint(value);
};
_ignoreAlpha = true;
init((target as DisplayObject), end);
return (true);
}
override public function set changeFactor(n:Number):void{
var ct:ColorTransform;
updateTweens(n);
if (_ignoreAlpha){
ct = _transform.colorTransform;
_ct.alphaMultiplier = ct.alphaMultiplier;
_ct.alphaOffset = ct.alphaOffset;
};
_transform.colorTransform = _ct;
}
public function init(target:DisplayObject, end:ColorTransform):void{
var p:String;
_transform = target.transform;
_ct = _transform.colorTransform;
var i:int = _props.length;
while (i--) {
p = _props[i];
if (_ct[p] != end[p]){
_tweens[_tweens.length] = new PropTween(_ct, p, _ct[p], (end[p] - _ct[p]), "tint", false);
};
};
}
}
}//package com.greensock.plugins
Section 234
//TweenPlugin (com.greensock.plugins.TweenPlugin)
package com.greensock.plugins {
import com.greensock.*;
import com.greensock.core.*;
public class TweenPlugin {
public var activeDisable:Boolean;
protected var _changeFactor:Number;// = 0
protected var _tweens:Array;
public var onDisable:Function;
public var propName:String;
public var round:Boolean;
public var onEnable:Function;
public var priority:int;// = 0
public var overwriteProps:Array;
public var onComplete:Function;
public static const VERSION:Number = 1.31;
public static const API:Number = 1;
public function TweenPlugin(){
_tweens = [];
super();
}
protected function updateTweens(changeFactor:Number):void{
var pt:PropTween;
var val:Number;
var i:int = _tweens.length;
if (this.round){
while (i--) {
pt = _tweens[i];
val = (pt.start + (pt.change * changeFactor));
pt.target[pt.property] = ((val)>0) ? int((val + 0.5)) : int((val - 0.5));
};
} else {
while (i--) {
pt = _tweens[i];
pt.target[pt.property] = (pt.start + (pt.change * changeFactor));
};
};
}
protected function addTween(object:Object, propName:String, start:Number, end, overwriteProp:String=null):void{
var change:Number;
if (end != null){
change = ((typeof(end))=="number") ? (Number(end) - start) : Number(end);
if (change != 0){
_tweens[_tweens.length] = new PropTween(object, propName, start, change, ((overwriteProp) || (propName)), false);
};
};
}
public function get changeFactor():Number{
return (_changeFactor);
}
public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
addTween(target, this.propName, target[this.propName], value, this.propName);
return (true);
}
public function killProps(lookup:Object):void{
var i:int = this.overwriteProps.length;
while (i--) {
if ((this.overwriteProps[i] in lookup)){
this.overwriteProps.splice(i, 1);
};
};
i = _tweens.length;
while (i--) {
if ((PropTween(_tweens[i]).name in lookup)){
_tweens.splice(i, 1);
};
};
}
public function set changeFactor(n:Number):void{
updateTweens(n);
_changeFactor = n;
}
public static function activate(plugins:Array):Boolean{
var instance:Object;
TweenLite.onPluginEvent = TweenPlugin.onTweenEvent;
var i:int = plugins.length;
while (i--) {
if (plugins[i].hasOwnProperty("API")){
instance = new ((plugins[i] as Class));
TweenLite.plugins[instance.propName] = plugins[i];
};
};
return (true);
}
private static function onTweenEvent(type:String, tween:TweenLite):Boolean{
var changed:Boolean;
var tweens:Array;
var i:int;
var pt:PropTween = tween.cachedPT1;
if (type == "onInit"){
tweens = [];
while (pt) {
tweens[tweens.length] = pt;
pt = pt.nextNode;
};
tweens.sortOn("priority", (Array.NUMERIC | Array.DESCENDING));
i = tweens.length;
while (i--) {
PropTween(tweens[i]).nextNode = tweens[(i + 1)];
PropTween(tweens[i]).prevNode = tweens[(i - 1)];
};
tween.cachedPT1 = tweens[0];
} else {
while (pt) {
if (((pt.isPlugin) && (pt.target[type]))){
if (pt.target.activeDisable){
changed = true;
};
var _local7 = pt.target;
_local7[type]();
};
pt = pt.nextNode;
};
};
return (changed);
}
}
}//package com.greensock.plugins
Section 235
//VisiblePlugin (com.greensock.plugins.VisiblePlugin)
package com.greensock.plugins {
import com.greensock.*;
public class VisiblePlugin extends TweenPlugin {
protected var _target:Object;
protected var _initVal:Boolean;
protected var _visible:Boolean;
protected var _tween:TweenLite;
public static const API:Number = 1;
public function VisiblePlugin(){
super();
this.propName = "visible";
this.overwriteProps = ["visible"];
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
_target = target;
_tween = tween;
_initVal = _target.visible;
_visible = Boolean(value);
return (true);
}
override public function set changeFactor(n:Number):void{
if ((((n == 1)) && ((((_tween.cachedDuration == _tween.cachedTime)) || ((_tween.cachedTime == 0)))))){
_target.visible = _visible;
} else {
_target.visible = _initVal;
};
}
}
}//package com.greensock.plugins
Section 236
//VolumePlugin (com.greensock.plugins.VolumePlugin)
package com.greensock.plugins {
import com.greensock.*;
import flash.media.*;
public class VolumePlugin extends TweenPlugin {
protected var _target:Object;
protected var _st:SoundTransform;
public static const API:Number = 1;
public function VolumePlugin(){
super();
this.propName = "volume";
this.overwriteProps = ["volume"];
}
override public function onInitTween(target:Object, value, tween:TweenLite):Boolean{
if (((isNaN(value)) || (!(target.hasOwnProperty("soundTransform"))))){
return (false);
};
_target = target;
_st = _target.soundTransform;
addTween(_st, "volume", _st.volume, value, "volume");
return (true);
}
override public function set changeFactor(n:Number):void{
updateTweens(n);
_target.soundTransform = _st;
}
}
}//package com.greensock.plugins
Section 237
//MatrixTools (com.greensock.transform.utils.MatrixTools)
package com.greensock.transform.utils {
import flash.geom.*;
public class MatrixTools {
private static const VERSION:Number = 1;
public function MatrixTools(){
super();
}
public static function getSkew($m:Matrix):Number{
return (Math.atan2($m.c, $m.d));
}
public static function getScaleX($m:Matrix):Number{
var sx:Number = Math.sqrt((($m.a * $m.a) + ($m.b * $m.b)));
if (((($m.a < 0)) && (($m.d > 0)))){
return (-(sx));
};
return (sx);
}
public static function getScaleY($m:Matrix):Number{
var sy:Number = Math.sqrt((($m.c * $m.c) + ($m.d * $m.d)));
if (((($m.d < 0)) && (($m.a > 0)))){
return (-(sy));
};
return (sy);
}
public static function scaleMatrix($m:Matrix, $sx:Number, $sy:Number, $angle:Number, $skew:Number):void{
var cosAngle:Number = Math.cos($angle);
var sinAngle:Number = Math.sin($angle);
var cosSkew:Number = Math.cos($skew);
var sinSkew:Number = Math.sin($skew);
var a:Number = (((cosAngle * $m.a) + (sinAngle * $m.b)) * $sx);
var b:Number = (((cosAngle * $m.b) - (sinAngle * $m.a)) * $sy);
var c:Number = (((cosSkew * $m.c) - (sinSkew * $m.d)) * $sx);
var d:Number = (((cosSkew * $m.d) + (sinSkew * $m.c)) * $sy);
$m.a = ((cosAngle * a) - (sinAngle * b));
$m.b = ((cosAngle * b) + (sinAngle * a));
$m.c = ((cosSkew * c) + (sinSkew * d));
$m.d = ((cosSkew * d) - (sinSkew * c));
}
public static function setSkewX($m:Matrix, $skewX:Number):void{
var sy:Number = Math.sqrt((($m.c * $m.c) + ($m.d * $m.d)));
$m.c = (-(sy) * Math.sin($skewX));
$m.d = (sy * Math.cos($skewX));
}
public static function setSkewY($m:Matrix, $skewY:Number):void{
var sx:Number = Math.sqrt((($m.a * $m.a) + ($m.b * $m.b)));
$m.a = (sx * Math.cos($skewY));
$m.b = (sx * Math.sin($skewY));
}
public static function getDirectionX($m:Matrix):Number{
var sx:Number = Math.sqrt((($m.a * $m.a) + ($m.b * $m.b)));
if ($m.a < 0){
return (-(sx));
};
return (sx);
}
public static function getDirectionY($m:Matrix):Number{
var sy:Number = Math.sqrt((($m.c * $m.c) + ($m.d * $m.d)));
if ($m.d < 0){
return (-(sy));
};
return (sy);
}
public static function getFlashAngle($m:Matrix):Number{
var a:Number = Math.atan2($m.b, $m.a);
if ((((a < 0)) && ((($m.a * $m.d) < 0)))){
a = ((a - Math.PI) % Math.PI);
};
return (a);
}
public static function getAngle($m:Matrix):Number{
var a:Number = Math.atan2($m.b, $m.a);
if (((($m.a < 0)) && (($m.d >= 0)))){
return (((a)<=0) ? (a + Math.PI) : (a - Math.PI));
//unresolved jump
};
return (a);
}
}
}//package com.greensock.transform.utils
Section 238
//TransformItem (com.greensock.transform.TransformItem)
package com.greensock.transform {
import flash.events.*;
import flash.display.*;
import com.greensock.events.*;
import flash.geom.*;
import flash.utils.*;
import flash.text.*;
import com.greensock.transform.utils.*;
public class TransformItem extends EventDispatcher {
protected var _enabled:Boolean;
protected var _dispatchMoveEvents:Boolean;
protected var _targetObject:DisplayObject;
protected var _constrainScale:Boolean;
protected var _origin:Point;
protected var _frameCount:uint;// = 0
protected var _cornerAngleBL:Number;
protected var _cornerAngleBR:Number;
protected var _lockPosition:Boolean;
protected var _maxScaleY:Number;
protected var _maxScaleX:Number;
protected var _hasSelectableText:Boolean;
protected var _isFlex:Boolean;
protected var _lockScale:Boolean;
protected var _dispatchScaleEvents:Boolean;
protected var _proxy:InteractiveObject;
protected var _cornerAngleTL:Number;
protected var _cornerAngleTR:Number;
protected var _scaleMode:String;
protected var _allowDelete:Boolean;
protected var _lockRotation:Boolean;
protected var _target:DisplayObject;
protected var _localOrigin:Point;
protected var _baseRect:Rectangle;
protected var _offset:Point;
protected var _minScaleX:Number;
protected var _minScaleY:Number;
protected var _createdManager:TransformManager;
protected var _dispatchRotateEvents:Boolean;
protected var _bounds:Rectangle;
protected var _selected:Boolean;
protected var _stage:Stage;
protected static const _RAD2DEG:Number = 57.2957795130823;
public static const VERSION:Number = 1.91;
protected static const _DEG2RAD:Number = 0.0174532925199433;
protected static var _proxyCount:uint = 0;
public function TransformItem($targetObject:DisplayObject, $vars:Object){
super();
if (TransformManager.VERSION < 1.87){
trace("TransformManager Error: You have an outdated TransformManager-related class file. You may need to clear your ASO files. Please make sure you're using the latest version of TransformManager, TransformItem, and TransformItemTF, available from www.greensock.com.");
};
init($targetObject, $vars);
}
public function destroy():void{
this.enabled = false;
this.selected = false;
dispatchEvent(new TransformEvent(TransformEvent.DESTROY, [this]));
}
public function get hasScaleLimits():Boolean{
return (((((((!((_minScaleX == -(Infinity)))) || (!((_minScaleY == -(Infinity)))))) || (!((_maxScaleX == Infinity))))) || (!((_maxScaleY == Infinity)))));
}
public function get scaleMode():String{
return (_scaleMode);
}
public function setScaleConstraints($minScaleX:Number, $maxScaleX:Number, $minScaleY:Number, $maxScaleY:Number):void{
this.minScaleX = $minScaleX;
this.maxScaleX = $maxScaleX;
this.minScaleY = $minScaleY;
this.maxScaleY = $maxScaleY;
}
protected function init($targetObject:DisplayObject, $vars:Object):void{
var $targetObject = $targetObject;
var $vars = $vars;
_isFlex = Boolean(getDefinitionByName("mx.managers.SystemManager"));
//unresolved jump
var _slot1 = $e;
_isFlex = false;
_targetObject = $targetObject;
_baseRect = _targetObject.getBounds(_targetObject);
_allowDelete = setDefault($vars.allowDelete, false);
_constrainScale = setDefault($vars.constrainScale, false);
_lockScale = setDefault($vars.lockScale, false);
_lockRotation = setDefault($vars.lockRotation, false);
_lockPosition = setDefault($vars.lockPosition, false);
_hasSelectableText = setDefault($vars.hasSelectableText, ((_targetObject is TextField)) ? true : false);
this.scaleMode = setDefault($vars.scaleMode, (_hasSelectableText) ? TransformManager.SCALE_WIDTH_AND_HEIGHT : TransformManager.SCALE_NORMAL);
this.minScaleX = setDefault($vars.minScaleX, -(Infinity));
this.minScaleY = setDefault($vars.minScaleY, -(Infinity));
this.maxScaleX = setDefault($vars.maxScaleX, Infinity);
this.maxScaleY = setDefault($vars.maxScaleY, Infinity);
this.origin = new Point(_targetObject.x, _targetObject.y);
if ($vars.manager == undefined){
$vars.items = [this];
_createdManager = new TransformManager($vars);
};
if (_targetObject.stage != null){
_stage = _targetObject.stage;
} else {
_targetObject.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage, false, 0, true);
};
_selected = false;
this.bounds = $vars.bounds;
_enabled = !(Boolean($vars.enabled));
this.enabled = !(_enabled);
}
public function get constrainScale():Boolean{
return (_constrainScale);
}
public function set scaleMode($s:String):void{
if ($s != TransformManager.SCALE_NORMAL){
createProxy();
} else {
removeProxy();
};
_scaleMode = $s;
}
protected function onRollOverItem($e:MouseEvent):void{
if (_selected){
dispatchEvent(new TransformEvent(TransformEvent.ROLL_OVER_SELECTED, [this], $e));
};
}
public function set constrainScale($b:Boolean):void{
_constrainScale = $b;
}
public function get height():Number{
var s:Sprite;
var h:Number;
if (_targetObject.parent != null){
return (_targetObject.getBounds(_targetObject.parent).height);
};
s = new Sprite();
s.addChild(_targetObject);
h = _targetObject.getBounds(s).height;
s.removeChild(_targetObject);
return (h);
}
public function get origin():Point{
return (_origin);
}
public function get targetObject():DisplayObject{
return (_targetObject);
}
public function set selected($b:Boolean):void{
if ($b != _selected){
_selected = $b;
if ($b){
if (_targetObject.parent == null){
return;
};
if (_targetObject.hasOwnProperty("setStyle")){
(_targetObject as Object).setStyle("focusThickness", 0);
};
dispatchEvent(new TransformEvent(TransformEvent.SELECT, [this]));
} else {
dispatchEvent(new TransformEvent(TransformEvent.DESELECT, [this]));
};
};
}
protected function setCornerAngles():void{
if (_bounds != null){
_cornerAngleTL = TransformManager.positiveAngle(Math.atan2((_bounds.y - _origin.y), (_bounds.x - _origin.x)));
_cornerAngleTR = TransformManager.positiveAngle(Math.atan2((_bounds.y - _origin.y), (_bounds.right - _origin.x)));
_cornerAngleBR = TransformManager.positiveAngle(Math.atan2((_bounds.bottom - _origin.y), (_bounds.right - _origin.x)));
_cornerAngleBL = TransformManager.positiveAngle(Math.atan2((_bounds.bottom - _origin.y), (_bounds.x - _origin.x)));
};
}
public function set minScale($n:Number):void{
this.minScaleX = (this.minScaleY = $n);
}
public function get minScaleX():Number{
return (_minScaleX);
}
public function get enabled():Boolean{
return (_enabled);
}
public function scale($sx:Number, $sy:Number, $angle:Number=0, $checkBounds:Boolean=true, $dispatchEvent:Boolean=true):void{
if (!_lockScale){
scaleRotated($sx, $sy, $angle, -($angle), $checkBounds, $dispatchEvent);
};
}
public function get innerCenter():Point{
var r:Rectangle = _targetObject.getBounds(_targetObject);
return (new Point((r.x + (r.width / 2)), (r.y + (r.height / 2))));
}
public function set origin($p:Point):void{
_origin = $p;
if (((!((_proxy == null))) && (!((_proxy.parent == null))))){
_localOrigin = _proxy.globalToLocal(_proxy.parent.localToGlobal($p));
} else {
if (_targetObject.parent != null){
_localOrigin = _targetObject.globalToLocal(_targetObject.parent.localToGlobal($p));
};
};
setCornerAngles();
}
public function get scaleX():Number{
return (MatrixTools.getScaleX(_targetObject.transform.matrix));
}
protected function removeProxy():void{
if (_proxy != null){
if (_proxy.parent != null){
_proxy.parent.removeChild(_proxy);
};
_proxy = null;
};
_target = _targetObject;
}
public function set height($n:Number):void{
var o:Point = this.origin;
this.origin = this.center;
scale(1, ($n / this.height), 0, true, true);
this.origin = o;
}
public function get scaleY():Number{
return (MatrixTools.getScaleY(_targetObject.transform.matrix));
}
protected function onMouseUp($e:MouseEvent):void{
_stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
if (((!(_hasSelectableText)) && (_selected))){
dispatchEvent(new TransformEvent(TransformEvent.SELECT_MOUSE_UP, [this], $e));
};
}
public function rotate($angle:Number, $checkBounds:Boolean=true, $dispatchEvent:Boolean=true):void{
var m:Matrix;
var safe:Object;
var p:Point;
if (!_lockRotation){
if ((($checkBounds) && (!((_bounds == null))))){
safe = {angle:$angle};
rotateCheck(safe);
$angle = safe.angle;
};
m = _targetObject.transform.matrix;
m.rotate($angle);
_targetObject.transform.matrix = m;
if (_proxy != null){
m = _proxy.transform.matrix;
m.rotate($angle);
_proxy.transform.matrix = m;
};
reposition();
if (_target == _proxy){
p = _proxy.parent.globalToLocal(_proxy.localToGlobal(_offset));
_targetObject.x = p.x;
_targetObject.y = p.y;
};
if ((((($dispatchEvent) && (_dispatchRotateEvents))) && (!(($angle == 0))))){
dispatchEvent(new TransformEvent(TransformEvent.ROTATE, [this]));
};
};
}
protected function reposition():void{
var p:Point = _target.parent.globalToLocal(_target.localToGlobal(_localOrigin));
_target.x = (_target.x + (_origin.x - p.x));
_target.y = (_target.y + (_origin.y - p.y));
}
public function get allowDelete():Boolean{
return (_allowDelete);
}
override public function addEventListener($type:String, $listener:Function, $useCapture:Boolean=false, $priority:int=0, $useWeakReference:Boolean=false):void{
if ($type == TransformEvent.MOVE){
_dispatchMoveEvents = true;
} else {
if ($type == TransformEvent.SCALE){
_dispatchScaleEvents = true;
} else {
if ($type == TransformEvent.ROTATE){
_dispatchRotateEvents = true;
};
};
};
super.addEventListener($type, $listener, $useCapture, $priority, $useWeakReference);
}
public function rotateCheck($safe:Object):void{
var originalAngle:Number;
var original:Matrix;
var m:Matrix;
var inc:Number;
var i:uint;
if (_lockRotation){
$safe.angle = 0;
} else {
if (((!((_bounds == null))) && (!(($safe.angle == 0))))){
originalAngle = (_target.rotation * _DEG2RAD);
original = _target.transform.matrix;
m = original.clone();
m.rotate($safe.angle);
_target.transform.matrix = m;
reposition();
if (!_bounds.containsRect(_target.getBounds(_target.parent))){
m = original.clone();
inc = _DEG2RAD;
if (TransformManager.acuteAngle($safe.angle) < 0){
inc = (inc * -1);
};
i = 1;
while (i < 360) {
m.rotate(inc);
_target.transform.matrix = m;
reposition();
if (!_bounds.containsRect(_target.getBounds(_target.parent))){
$safe.angle = ((i - 1) * inc);
break;
};
i++;
};
};
_target.transform.matrix = original;
};
};
}
public function get minScaleY():Number{
return (_minScaleY);
}
public function onPressDelete($e:Event=null, $allowSelectableTextDelete:Boolean=false):Boolean{
if (((((_enabled) && (_allowDelete))) && ((((_hasSelectableText == false)) || ($allowSelectableTextDelete))))){
deleteObject();
return (true);
};
return (false);
}
public function set bounds($r:Rectangle):void{
_bounds = $r;
setCornerAngles();
fitInsideBounds(true, false, null);
}
public function get lockPosition():Boolean{
return (_lockPosition);
}
public function get x():Number{
return (_targetObject.x);
}
public function get y():Number{
return (_targetObject.y);
}
protected function autoCalibrateProxy($e:Event=null):void{
if (_frameCount >= 3){
_targetObject.removeEventListener(Event.ENTER_FRAME, autoCalibrateProxy);
if (_targetObject.parent){
_targetObject.parent.addChild(_proxy);
};
_target = _proxy;
calibrateProxy();
_frameCount = 0;
} else {
_frameCount++;
};
}
public function get rotation():Number{
return ((MatrixTools.getAngle(_targetObject.transform.matrix) * _RAD2DEG));
}
public function get alpha():Number{
return (_targetObject.alpha);
}
public function set minScaleX($n:Number):void{
if ($n == 0){
$n = ((_targetObject.getBounds(_targetObject).width) || (500));
_minScaleX = (1 / $n);
} else {
_minScaleX = $n;
};
if (_targetObject.scaleX < _minScaleX){
_targetObject.scaleX = _minScaleX;
};
if (_selected){
dispatchEvent(new TransformEvent(TransformEvent.UPDATE, [this]));
};
}
protected function iterateStretchX($safe:Object, $angle:Number, $skew:Number):void{
var original:Matrix;
var i:uint;
var loops:uint;
var base:uint;
var m:Matrix;
var inc:Number;
if (_lockScale){
$safe.sx = ($safe.sy = 1);
} else {
if (((!((_bounds == null))) && (!(($safe.sx == 1))))){
original = _target.transform.matrix;
m = new Matrix();
inc = 0.01;
if ($safe.sx < 1){
inc = -0.01;
};
if ($safe.sx > 0){
loops = (Math.abs((($safe.sx - 1) / inc)) + 1);
base = 1;
} else {
base = 0;
loops = (($safe.sx / inc) + 1);
};
i = 1;
while (i <= loops) {
m.a = original.a;
m.b = original.b;
m.c = original.c;
m.d = original.d;
MatrixTools.scaleMatrix(m, (base + (i * inc)), 1, $angle, $skew);
_target.transform.matrix = m;
reposition();
if (!_bounds.containsRect(_target.getBounds(_target.parent))){
if (!((($safe.sx < 1)) && (($safe.sx > 0)))){
$safe.sx = (base + ((i - 1) * inc));
};
break;
};
i++;
};
};
};
}
public function fitInsideBounds(move:Boolean=true, updateFirst:Boolean=true, customBounds:Rectangle=null):void{
var bounds:Rectangle;
var xMin:Number;
var yMin:Number;
var w:Number;
var h:Number;
var ratio:Number;
var prevOrigin:Point;
var dx:Number;
var dy:Number;
var xMax:Number;
var yMax:Number;
if (updateFirst){
this.update(null);
};
var mBounds:Rectangle = ((customBounds)!=null) ? customBounds : _bounds;
if (((_target.parent) && (!((mBounds == null))))){
bounds = _target.getBounds(_target.parent);
if (((!(mBounds.containsRect(bounds))) && (!((bounds.width == 0))))){
xMin = (move) ? mBounds.x : bounds.x;
yMin = (move) ? mBounds.y : bounds.y;
w = Math.min(bounds.width, (mBounds.width - (xMin - mBounds.x)));
h = Math.min(bounds.height, (mBounds.height - (yMin - mBounds.y)));
ratio = Math.min((w / bounds.width), (h / bounds.height));
if (ratio < 0){
ratio = 0;
};
if (ratio < 1){
prevOrigin = _origin;
this.origin = new Point(bounds.x, bounds.y);
this.scale(ratio, ratio, 0, false, true);
this.origin = prevOrigin;
} else {
ratio = 1;
};
if (move){
dx = 0;
dy = 0;
xMax = (mBounds.x + (mBounds.width - (bounds.width * ratio)));
if (bounds.x > xMax){
dx = (xMax - bounds.x);
} else {
if (bounds.x < mBounds.x){
dx = (mBounds.x - bounds.x);
};
};
yMax = (mBounds.y + (mBounds.height - (bounds.height * ratio)));
if (bounds.y > yMax){
dy = (yMax - bounds.y);
} else {
if (bounds.y < mBounds.y){
dy = (mBounds.y - bounds.y);
};
};
this.move(dx, dy, false, true);
};
};
};
}
public function set width($n:Number):void{
var o:Point = this.origin;
this.origin = this.center;
scale(($n / this.width), 1, 0, true, true);
this.origin = o;
}
public function set lockRotation($b:Boolean):void{
_lockRotation = $b;
}
public function get center():Point{
if (_targetObject.parent != null){
return (_targetObject.parent.globalToLocal(_targetObject.localToGlobal(this.innerCenter)));
};
return (this.innerCenter);
}
public function set scaleX($n:Number):void{
var o:Point = this.origin;
this.origin = this.center;
var m:Matrix = _targetObject.transform.matrix;
scaleRotated(($n / MatrixTools.getScaleX(m)), 1, (_targetObject.rotation * _DEG2RAD), Math.atan2(m.c, m.d), true, true);
this.origin = o;
}
protected function iterateStretchY($safe:Object, $angle:Number, $skew:Number):void{
var original:Matrix;
var i:uint;
var loops:uint;
var base:uint;
var m:Matrix;
var inc:Number;
if (_lockScale){
$safe.sx = ($safe.sy = 1);
} else {
if (((!((_bounds == null))) && (!(($safe.sy == 1))))){
original = _target.transform.matrix;
m = new Matrix();
inc = 0.01;
if ($safe.sy < 1){
inc = -0.01;
};
if ($safe.sx > 0){
loops = (Math.abs((($safe.sy - 1) / inc)) + 1);
base = 1;
} else {
base = 0;
loops = (($safe.sy / inc) + 1);
};
i = 1;
while (i <= loops) {
m.a = original.a;
m.b = original.b;
m.c = original.c;
m.d = original.d;
MatrixTools.scaleMatrix(m, 1, (base + (i * inc)), $angle, $skew);
_target.transform.matrix = m;
reposition();
if (!_bounds.containsRect(_target.getBounds(_target.parent))){
if (!((($safe.sy < 1)) && (($safe.sy > 0)))){
$safe.sy = (base + ((i - 1) * inc));
};
break;
};
i++;
};
};
};
}
protected function onAddedToStage($e:Event):void{
var $e = $e;
_stage = _targetObject.stage;
_isFlex = Boolean(getDefinitionByName("mx.managers.SystemManager"));
//unresolved jump
var _slot1 = $e;
_isFlex = false;
if (_proxy != null){
_targetObject.parent.addChild(_proxy);
};
_targetObject.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
public function set enabled($b:Boolean):void{
if ($b != _enabled){
_enabled = $b;
this.selected = false;
if ($b){
_targetObject.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
_targetObject.addEventListener(MouseEvent.ROLL_OVER, onRollOverItem);
_targetObject.addEventListener(MouseEvent.ROLL_OUT, onRollOutItem);
} else {
_targetObject.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
_targetObject.removeEventListener(MouseEvent.ROLL_OVER, onRollOverItem);
_targetObject.removeEventListener(MouseEvent.ROLL_OUT, onRollOutItem);
if (_stage != null){
_stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
};
};
};
}
public function set scaleY($n:Number):void{
var o:Point = this.origin;
this.origin = this.center;
var m:Matrix = _targetObject.transform.matrix;
scaleRotated(1, ($n / MatrixTools.getScaleY(m)), (_targetObject.rotation * _DEG2RAD), Math.atan2(m.c, m.d), true, true);
this.origin = o;
}
public function get selected():Boolean{
return (_selected);
}
public function set maxScaleX($n:Number):void{
if ($n == 0){
$n = ((_targetObject.getBounds(_targetObject).width) || (0.005));
_maxScaleX = (0 - (1 / $n));
} else {
_maxScaleX = $n;
};
if (_targetObject.scaleX > _maxScaleX){
_targetObject.scaleX = _maxScaleX;
};
if (_selected){
dispatchEvent(new TransformEvent(TransformEvent.UPDATE, [this]));
};
}
public function set maxScale($n:Number):void{
this.maxScaleX = (this.maxScaleY = $n);
}
public function get bounds():Rectangle{
return (_bounds);
}
public function set hasSelectableText($b:Boolean):void{
if ($b){
this.scaleMode = TransformManager.SCALE_WIDTH_AND_HEIGHT;
this.allowDelete = false;
};
_hasSelectableText = $b;
}
public function set minScaleY($n:Number):void{
if ($n == 0){
$n = ((_targetObject.getBounds(_targetObject).height) || (500));
_minScaleY = (1 / $n);
} else {
_minScaleY = $n;
};
if (_targetObject.scaleY < _minScaleY){
_targetObject.scaleY = _minScaleY;
};
if (_selected){
dispatchEvent(new TransformEvent(TransformEvent.UPDATE, [this]));
};
}
public function moveCheck($x:Number, $y:Number, $safe:Object):void{
var r:Rectangle;
if (_lockPosition){
$safe.x = ($safe.y = 0);
} else {
if (_bounds != null){
r = _targetObject.getBounds(_targetObject.parent);
r.offset($x, $y);
if (!_bounds.containsRect(r)){
if (_bounds.right < r.right){
$x = ($x + (_bounds.right - r.right));
$safe.x = int(Math.min($safe.x, $x));
} else {
if (_bounds.left > r.left){
$x = ($x + (_bounds.left - r.left));
$safe.x = int(Math.max($safe.x, $x));
};
};
if (_bounds.top > r.top){
$y = ($y + (_bounds.top - r.top));
$safe.y = int(Math.max($safe.y, $y));
} else {
if (_bounds.bottom < r.bottom){
$y = ($y + (_bounds.bottom - r.bottom));
$safe.y = int(Math.min($safe.y, $y));
};
};
};
};
};
}
public function scaleRotated($sx:Number, $sy:Number, $angle:Number, $skew:Number, $checkBounds:Boolean=true, $dispatchEvent:Boolean=true):void{
var m:Matrix;
var safe:Object;
var w:Number;
var h:Number;
var p:Point;
if (!_lockScale){
m = _target.transform.matrix;
if (((!(($angle == -($skew)))) && ((Math.abs((($angle + $skew) % (Math.PI - 0.01))) < 0.01)))){
$skew = -($angle);
};
if ((($checkBounds) && (!((_bounds == null))))){
safe = {sx:$sx, sy:$sy};
scaleCheck(safe, $angle, $skew);
$sx = safe.sx;
$sy = safe.sy;
};
MatrixTools.scaleMatrix(m, $sx, $sy, $angle, $skew);
if (_scaleMode == "scaleNormal"){
_targetObject.transform.matrix = m;
reposition();
} else {
_proxy.transform.matrix = m;
reposition();
w = (Math.sqrt(((m.a * m.a) + (m.b * m.b))) * _baseRect.width);
h = (Math.sqrt(((m.d * m.d) + (m.c * m.c))) * _baseRect.height);
p = _targetObject.parent.globalToLocal(_proxy.localToGlobal(_offset));
_targetObject.width = w;
_targetObject.height = h;
_targetObject.rotation = _proxy.rotation;
_targetObject.x = p.x;
_targetObject.y = p.y;
};
if ((((($dispatchEvent) && (_dispatchScaleEvents))) && (((!(($sx == 1))) || (!(($sy == 1))))))){
dispatchEvent(new TransformEvent(TransformEvent.SCALE, [this]));
};
};
}
public function set alpha($n:Number):void{
_targetObject.alpha = $n;
}
public function set lockScale($b:Boolean):void{
_lockScale = $b;
}
public function get width():Number{
var s:Sprite;
var w:Number;
if (_targetObject.parent != null){
return (_targetObject.getBounds(_targetObject.parent).width);
};
s = new Sprite();
s.addChild(_targetObject);
w = _targetObject.getBounds(s).width;
s.removeChild(_targetObject);
return (w);
}
protected function onMouseDown($e:MouseEvent):void{
if (_hasSelectableText){
dispatchEvent(new TransformEvent(TransformEvent.MOUSE_DOWN, [this]));
} else {
_stage = _targetObject.stage;
_stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
dispatchEvent(new TransformEvent(TransformEvent.MOUSE_DOWN, [this], $e));
if (_selected){
dispatchEvent(new TransformEvent(TransformEvent.SELECT_MOUSE_DOWN, [this], $e));
};
};
}
public function update($e:Event=null):void{
_baseRect = _targetObject.getBounds(_targetObject);
setCornerAngles();
if (_proxy != null){
calibrateProxy();
};
dispatchEvent(new TransformEvent(TransformEvent.UPDATE, [this]));
}
public function deleteObject():void{
this.selected = false;
if (_targetObject.parent){
_targetObject.parent.removeChild(_targetObject);
};
removeProxy();
dispatchEvent(new TransformEvent(TransformEvent.DELETE, [this]));
}
public function get lockRotation():Boolean{
return (_lockRotation);
}
public function move($x:Number, $y:Number, $checkBounds:Boolean=true, $dispatchEvent:Boolean=true):void{
var safe:Object;
if (!_lockPosition){
if ((($checkBounds) && (!((_bounds == null))))){
safe = {x:$x, y:$y};
moveCheck($x, $y, safe);
$x = safe.x;
$y = safe.y;
};
_target.x = (_target.x + $x);
_target.y = (_target.y + $y);
_origin.x = (_origin.x + $x);
_origin.y = (_origin.y + $y);
if (_target != _targetObject){
_targetObject.x = (_targetObject.x + $x);
_targetObject.y = (_targetObject.y + $y);
};
if ((((($dispatchEvent) && (_dispatchMoveEvents))) && (((!(($x == 0))) || (!(($y == 0))))))){
dispatchEvent(new TransformEvent(TransformEvent.MOVE, [this]));
};
};
}
protected function createProxy():void{
var tf:TextField;
var isEmpty:Boolean;
var format:TextFormat;
var altFormat:TextFormat;
var metrics:TextLineMetrics;
removeProxy();
if (_hasSelectableText){
_proxy = (_isFlex) ? new (getDefinitionByName("mx.core.UITextField")) : new TextField();
} else {
_proxy = (_isFlex) ? new (getDefinitionByName("mx.core.UIComponent")) : new Sprite();
};
_proxyCount++;
_proxy.name = ("__tmProxy" + _proxyCount);
_proxy.visible = false;
_target = _proxy;
_targetObject.parent.addChild(_proxy);
//unresolved jump
var _slot1 = $e;
_target = _targetObject;
_targetObject.addEventListener(Event.ENTER_FRAME, autoCalibrateProxy);
_offset = new Point(0, 0);
if ((_targetObject is TextField)){
tf = (_targetObject as TextField);
isEmpty = false;
if (tf.text == ""){
tf.text = "Y";
isEmpty = true;
};
format = tf.getTextFormat(0, 1);
altFormat = tf.getTextFormat(0, 1);
altFormat.align = "left";
tf.setTextFormat(altFormat, 0, 1);
metrics = tf.getLineMetrics(0);
if (metrics.x == 0){
_offset = new Point(-2, -2);
};
tf.setTextFormat(format, 0, 1);
if (isEmpty){
tf.text = "";
};
};
calibrateProxy();
}
public function get maxScaleY():Number{
return (_maxScaleY);
}
public function set allowDelete($b:Boolean):void{
if ($b != _allowDelete){
_allowDelete = $b;
if (_createdManager != null){
_createdManager.allowDelete = $b;
};
};
}
public function get maxScaleX():Number{
return (_maxScaleX);
}
public function get hasSelectableText():Boolean{
return (_hasSelectableText);
}
public function get lockScale():Boolean{
return (_lockScale);
}
protected function onRollOutItem($e:MouseEvent):void{
if (_selected){
dispatchEvent(new TransformEvent(TransformEvent.ROLL_OUT_SELECTED, [this], $e));
};
}
protected function calibrateProxy():void{
var r:Rectangle;
var g:Graphics;
var m:Matrix = _targetObject.transform.matrix;
_targetObject.transform.matrix = new Matrix();
if (!_hasSelectableText){
r = _targetObject.getBounds(_targetObject);
g = (_proxy as Sprite).graphics;
g.clear();
g.beginFill(0xFF0000, 0);
g.drawRect(r.x, r.y, _targetObject.width, _targetObject.height);
g.endFill();
};
_proxy.width = (_baseRect.width = _targetObject.width);
_proxy.height = (_baseRect.height = _targetObject.height);
_proxy.transform.matrix = (_targetObject.transform.matrix = m);
}
public function set lockPosition($b:Boolean):void{
_lockPosition = $b;
}
public function set maxScaleY($n:Number):void{
if ($n == 0){
$n = ((_targetObject.getBounds(_targetObject).height) || (0.005));
_maxScaleY = (0 - (1 / $n));
} else {
_maxScaleY = $n;
};
if (_targetObject.scaleY > _maxScaleY){
_targetObject.scaleY = _maxScaleY;
};
if (_selected){
dispatchEvent(new TransformEvent(TransformEvent.UPDATE, [this]));
};
}
public function scaleCheck($safe:Object, $angle:Number, $skew:Number):void{
var sx:Number;
var sy:Number;
var original:Matrix;
var originalScaleX:Number;
var originalScaleY:Number;
var originalAngle:Number;
var m:Matrix;
var angleDif:Number;
var skewDif:Number;
var ratio:Number;
var i:int;
var corner:Point;
var cornerAngle:Number;
var oldLength:Number;
var newLength:Number;
var dx:Number;
var dy:Number;
var minScale:Number;
var r:Rectangle;
var corners:Array;
if (_lockScale){
$safe.sx = ($safe.sy = 1);
} else {
original = _target.transform.matrix;
originalScaleX = MatrixTools.getScaleX(original);
originalScaleY = MatrixTools.getScaleY(original);
originalAngle = MatrixTools.getAngle(original);
m = original.clone();
MatrixTools.scaleMatrix(m, $safe.sx, $safe.sy, $angle, $skew);
if (this.hasScaleLimits){
angleDif = ($angle - originalAngle);
skewDif = ($skew - MatrixTools.getSkew(original));
if ((((((angleDif == 0)) && ((skewDif < 0.0001)))) && ((skewDif > -0.0001)))){
sx = MatrixTools.getScaleX(m);
sy = MatrixTools.getScaleY(m);
if (Math.abs((originalAngle - MatrixTools.getAngle(m))) > (Math.PI * 0.51)){
sx = -(sx);
sy = -(sy);
};
ratio = (originalScaleX / originalScaleY);
if (sx > _maxScaleX){
$safe.sx = (_maxScaleX / originalScaleX);
if (_constrainScale){
sy = ($safe.sx / ratio);
$safe.sy = sy;
if (($safe.sx * $safe.sy) < 0){
sy = -(sy);
$safe.sy = sy;
};
};
} else {
if (sx < _minScaleX){
$safe.sx = (_minScaleX / originalScaleX);
if (_constrainScale){
sy = ($safe.sx / ratio);
$safe.sy = sy;
if (($safe.sx * $safe.sy) < 0){
sy = -(sy);
$safe.sy = sy;
};
};
};
};
if (sy > _maxScaleY){
$safe.sy = (_maxScaleY / originalScaleY);
if (_constrainScale){
$safe.sx = ($safe.sy * ratio);
if (($safe.sx * $safe.sy) < 0){
$safe.sx = ($safe.sx * -1);
};
};
} else {
if (sy < _minScaleY){
$safe.sy = (_minScaleY / originalScaleY);
if (_constrainScale){
$safe.sx = ($safe.sy * ratio);
if (($safe.sx * $safe.sy) < 0){
$safe.sx = ($safe.sx * -1);
};
};
};
};
m = original.clone();
MatrixTools.scaleMatrix(m, $safe.sx, $safe.sy, $angle, $skew);
} else {
sx = MatrixTools.getScaleX(m);
sy = MatrixTools.getScaleY(m);
if ((((((((sx > _maxScaleX)) || ((sx < _minScaleX)))) || ((sy > _maxScaleY)))) || ((sy < _minScaleY)))){
$safe.sx = ($safe.sy = 1);
return;
};
};
};
_target.transform.matrix = m;
reposition();
if (_bounds != null){
if (!_bounds.containsRect(_target.getBounds(_target.parent))){
if ($safe.sy == 1){
_target.transform.matrix = original;
iterateStretchX($safe, $angle, $skew);
} else {
if ($safe.sx == 1){
_target.transform.matrix = original;
iterateStretchY($safe, $angle, $skew);
} else {
minScale = 1;
r = _target.getBounds(_target);
corners = [new Point(r.x, r.y), new Point(r.right, r.y), new Point(r.right, r.bottom), new Point(r.x, r.bottom)];
i = (corners.length - 1);
while (i > -1) {
corner = _target.parent.globalToLocal(_target.localToGlobal(corners[i]));
if (!(((Math.abs((corner.x - _origin.x)) < 1)) && ((Math.abs((corner.y - _origin.y)) < 1)))){
cornerAngle = TransformManager.positiveAngle(Math.atan2((corner.y - _origin.y), (corner.x - _origin.x)));
dx = (_origin.x - corner.x);
dy = (_origin.y - corner.y);
oldLength = Math.sqrt(((dx * dx) + (dy * dy)));
if ((((cornerAngle < _cornerAngleBR)) || ((((cornerAngle > _cornerAngleTR)) && (!((_cornerAngleTR == 0))))))){
dx = (_bounds.right - _origin.x);
newLength = ((((dx < 1)) && (((((_cornerAngleBR - cornerAngle) < 0.01)) || (((cornerAngle - _cornerAngleTR) < 0.01)))))) ? 0 : (dx / Math.cos(cornerAngle));
} else {
if (cornerAngle <= _cornerAngleBL){
dy = (_bounds.bottom - _origin.y);
newLength = (((_cornerAngleBL - cornerAngle))<0.01) ? 0 : (dy / Math.sin(cornerAngle));
} else {
if (cornerAngle < _cornerAngleTL){
dx = (_origin.x - _bounds.x);
newLength = (dx / Math.cos(cornerAngle));
} else {
dy = (_origin.y - _bounds.y);
newLength = (dy / Math.sin(cornerAngle));
};
};
};
if (newLength != 0){
minScale = Math.min(minScale, (Math.abs(newLength) / oldLength));
};
};
i--;
};
m = _target.transform.matrix;
if (((((($safe.sx < 0)) && ((((_origin.x == _bounds.x)) || ((_origin.x == _bounds.right)))))) || (((($safe.sy < 0)) && ((((_origin.y == _bounds.y)) || ((_origin.y == _bounds.bottom)))))))){
$safe.sx = 1;
$safe.sy = 1;
} else {
$safe.sx = ((MatrixTools.getDirectionX(m) * minScale) / MatrixTools.getDirectionX(original));
$safe.sy = ((MatrixTools.getDirectionY(m) * minScale) / MatrixTools.getDirectionY(original));
};
};
};
};
};
_target.transform.matrix = original;
};
}
public function set x($n:Number):void{
move(($n - _targetObject.x), 0, true, true);
}
public function set y($n:Number):void{
move(0, ($n - _targetObject.y), true, true);
}
public function set rotation($n:Number):void{
var o:Point = this.origin;
this.origin = this.center;
rotate((($n * _DEG2RAD) - MatrixTools.getAngle(_targetObject.transform.matrix)), true, true);
this.origin = o;
}
protected static function setDefault($value, $default){
if ($value == undefined){
return ($default);
};
return ($value);
}
}
}//package com.greensock.transform
Section 239
//TransformManager (com.greensock.transform.TransformManager)
package com.greensock.transform {
import flash.events.*;
import flash.display.*;
import com.greensock.events.*;
import flash.geom.*;
import flash.utils.*;
import flash.text.*;
import com.greensock.transform.utils.*;
import flash.ui.*;
public class TransformManager extends EventDispatcher {
private var _lockCursor:Boolean;
private var _ignoredObjects:Array;
private var _prevScaleY:Number;// = 0
private var _enabled:Boolean;
private var _handles:Array;
private var _selection:Sprite;
private var _prevScaleX:Number;// = 0
private var _constrainScale:Boolean;
private var _origin:Point;
private var _onUnlockParam:Event;
private var _lineColor:uint;
private var _handleColor:uint;
private var _lastClickTime:uint;// = 0
private var _selConstrainScale:Boolean;
private var _allowDelete:Boolean;
private var _multiSelectMode:Boolean;
private var _selHasTextFields:Boolean;
private var _selLockPosition:Boolean;
private var _items:Array;
private var _dispatchRotateEvents:Boolean;
private var _allowMultiSelect:Boolean;
private var _dispatchMoveEvents:Boolean;
private var _selLockRotation:Boolean;
private var _arrowKeysMove:Boolean;
private var _paddingForRotation:Number;
private var _scaleFromCenter:Boolean;
private var _forceSelectionToFront:Boolean;
private var _lockPosition:Boolean;
private var _edges:Sprite;
private var _isTransforming:Boolean;
private var _lockScale:Boolean;
private var _onUnlock:Function;
private var _dummyBox:Sprite;
private var _ignoreEvents:Boolean;
private var _autoDeselect:Boolean;
private var _dispatchScaleEvents:Boolean;
private var _isFlex:Boolean;
private var _selHasScaleLimits:Boolean;
private var _selLockScale:Boolean;
private var _hideCenterHandle:Boolean;
private var _lockRotation:Boolean;
private var _parent:DisplayObjectContainer;
private var _initted:Boolean;
private var _lockOrigin:Boolean;
private var _bounds:Rectangle;
private var _handlesDict:Dictionary;
private var _trackingInfo:Object;
private var _selectedItems:Array;
private var _handleSize:Number;
private var _stage:Stage;
public static const VERSION:Number = 1.916;
public static const SCALE_NORMAL:String = "scaleNormal";
public static const SCALE_WIDTH_AND_HEIGHT:String = "scaleWidthAndHeight";
private static const _DEG2RAD:Number = 0.0174532925199433;
private static const _RAD2DEG:Number = 57.2957795130823;
public static var scaleCursor:Shape;
private static var _keyListenerInits:Dictionary = new Dictionary();
private static var _keysDown:Object;
public static var moveCursor:Shape;
private static var _keyDispatcher:EventDispatcher = new EventDispatcher();
private static var _tempDeselectedItem:TransformItem;
public static var rotationCursor:Shape;
private static var _cursorManager:TransformManager;
private static var _currentCursor:Shape;
public function TransformManager($vars:Object=null){
super();
if (TransformItem.VERSION < 1.87){
throw (new Error("TransformManager Error: You have an outdated TransformManager-related class file. You may need to clear your ASO files. Please make sure you're using the latest version of TransformManager and TransformItem, available from www.greensock.com."));
};
if ($vars == null){
$vars = {};
};
init($vars);
}
private function updateScale($x:Boolean=true, $y:Boolean=true):void{
var newScaleX:Number;
var newScaleY:Number;
var xFactor:Number;
var yFactor:Number;
var angleDif:Number;
var ti:Object = _trackingInfo;
var mx:Number = (_parent.mouseX - ti.mouseOffsetX);
var my:Number = (_parent.mouseY - ti.mouseOffsetY);
if (_bounds != null){
if (mx >= _bounds.right){
mx = (_bounds.right - 0.02);
} else {
if (mx <= _bounds.left){
mx = (_bounds.left + 0.02);
};
};
if (my >= _bounds.bottom){
my = (_bounds.bottom - 0.02);
} else {
if (my <= _bounds.top){
my = (_bounds.top + 0.02);
};
};
};
var dx:Number = (mx - _origin.x);
var dy:Number = (_origin.y - my);
var d:Number = Math.sqrt(((dx * dx) + (dy * dy)));
var angleToMouse:Number = Math.atan2(dy, dx);
var constrain:Boolean = ((_selConstrainScale) || (isKeyDown(Keyboard.SHIFT)));
if (constrain){
angleDif = (((angleToMouse - ti.angleToMouse) + (Math.PI * 3.5)) % (Math.PI * 2));
if (angleDif < Math.PI){
d = (d * -1);
};
newScaleX = (d * ti.scaleRatioXConst);
newScaleY = (d * ti.scaleRatioYConst);
} else {
angleToMouse = (angleToMouse + ti.angle);
newScaleX = ((ti.scaleRatioX * Math.cos(angleToMouse)) * d);
newScaleY = ((ti.scaleRatioY * Math.sin(angleToMouse)) * d);
};
if ((((($x) || (constrain))) && ((((newScaleX > 0.001)) || ((newScaleX < -0.001)))))){
xFactor = (newScaleX / _prevScaleX);
} else {
xFactor = 1;
};
if ((((($y) || (constrain))) && ((((newScaleY > 0.001)) || ((newScaleY < -0.001)))))){
yFactor = (newScaleY / _prevScaleY);
} else {
yFactor = 1;
};
scaleSelection(xFactor, yFactor);
}
public function destroy():void{
deselectAll();
_keyDispatcher.removeEventListener("pressDelete", onPressDelete);
_keyDispatcher.removeEventListener("pressArrowKey", onPressArrowKey);
_keyDispatcher.removeEventListener("pressMultiSelectKey", onPressMultiSelectKey);
_keyDispatcher.removeEventListener("releaseMultiSelectKey", onReleaseMultiSelectKey);
if (_stage != null){
_stage.removeEventListener(Event.DEACTIVATE, onReleaseMultiSelectKey);
};
removeParentListeners();
var i:int = (_items.length - 1);
while (i > -1) {
_items[i].destroy();
i--;
};
dispatchEvent(new TransformEvent(TransformEvent.DESTROY, _items.slice()));
}
public function get constrainScale():Boolean{
return (_constrainScale);
}
private function onPressScale($e:MouseEvent):void{
if (((!(_selLockScale)) && (((!(_selHasTextFields)) || ((_selectedItems.length == 1)))))){
_isTransforming = true;
setScaleOrigin(($e.target as Sprite));
captureScaleTrackingInfo(($e.target as Sprite));
_stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveScale, false, 0, true);
_stage.addEventListener(MouseEvent.MOUSE_UP, onReleaseScale, false, 0, true);
lockCursor();
onMouseMoveScale();
};
}
private function initScaleCursor():void{
var ln:Number;
var s:Graphics;
var clr:uint;
var lw:uint;
var i:uint;
if (scaleCursor == null){
ln = 9;
scaleCursor = new Shape();
s = scaleCursor.graphics;
i = 0;
while (i < 2) {
if (i == 0){
clr = 0xFFFFFF;
lw = 5;
} else {
clr = 0;
lw = 2;
};
s.lineStyle(lw, clr, 1, false, null, "square", "miter", 3);
s.beginFill(clr, 1);
s.moveTo(-(ln), 0);
s.lineTo((2 - ln), -1.5);
s.lineTo((2 - ln), 1.5);
s.lineTo(-(ln), 0);
s.endFill();
s.moveTo((2 - ln), 0);
s.lineTo(-3, 0);
s.moveTo(-(ln), 0);
s.beginFill(clr, 1);
s.moveTo(ln, 0);
s.lineTo((ln - 2), -1.5);
s.lineTo((ln - 2), 1.5);
s.lineTo(ln, 0);
s.endFill();
s.moveTo(3, 0);
s.lineTo((ln - 2), 0);
s.moveTo(3, 0);
i++;
};
_stage.addChild(scaleCursor);
scaleCursor.visible = false;
};
}
public function set arrowKeysMove($b:Boolean):void{
_arrowKeysMove = $b;
}
private function onPressRotate($e:MouseEvent):void{
var mdx:Number;
var mdy:Number;
var angleToMouse:Number;
var angle:Number;
if (!_selLockRotation){
_isTransforming = true;
centerOrigin();
mdx = (_parent.mouseX - _origin.x);
mdy = (_origin.y - _parent.mouseY);
angleToMouse = Math.atan2(mdy, mdx);
angle = (_dummyBox.rotation * _DEG2RAD);
_trackingInfo = {angleToMouse:positiveAngle(angleToMouse), angle:angle, mouseX:_parent.mouseX, mouseY:_parent.mouseY, rotation:_dummyBox.rotation, handle:$e.target, rotated:false};
_stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveRotate, false, 0, true);
_stage.addEventListener(MouseEvent.MOUSE_UP, onReleaseRotate, false, 0, true);
lockCursor();
onMouseMoveRotate();
};
}
private function onRollOutSelectedItem($e:TransformEvent):void{
swapCursorOut(null);
}
public function deleteSelection($e:Event=null):void{
var item:TransformItem;
var deletedItems:Array = [];
var i:int = (_selectedItems.length - 1);
while (i > -1) {
item = _selectedItems[i];
item.deleteObject();
deletedItems.push(item);
i--;
};
if (deletedItems.length != 0){
dispatchEvent(new TransformEvent(TransformEvent.DELETE, deletedItems));
};
}
public function selectItems($items:Array, $addToSelection:Boolean=false):Array{
var i:uint;
var j:uint;
var item:TransformItem;
var selectedItem:TransformItem;
var found:Boolean;
var validItems:Array = [];
_ignoreEvents = true;
i = 0;
while (i < $items.length) {
item = findObject($items[i]);
if (item != null){
validItems.push(item);
};
i++;
};
if (!$addToSelection){
i = 0;
while (i < _selectedItems.length) {
selectedItem = _selectedItems[i];
found = false;
j = 0;
while (j < validItems.length) {
if (validItems[j] == selectedItem){
found = true;
break;
};
j++;
};
if (!found){
selectedItem.selected = false;
};
i++;
};
};
var previousMode:Boolean = _multiSelectMode;
_multiSelectMode = true;
i = 0;
while (i < validItems.length) {
validItems[i].selected = true;
i++;
};
_multiSelectMode = previousMode;
_ignoreEvents = false;
dispatchEvent(new TransformEvent(TransformEvent.SELECTION_CHANGE, validItems));
return (validItems);
}
public function set constrainScale($b:Boolean):void{
_constrainScale = $b;
updateItemProp("constrainScale", $b);
calibrateConstraints();
}
private function setOrigin($p:Point):void{
var local:Point;
var bounds:Rectangle;
var i:int;
if (!_lockOrigin){
_lockOrigin = true;
_origin = $p;
local = _dummyBox.globalToLocal(_parent.localToGlobal($p));
bounds = _dummyBox.getBounds(_dummyBox);
_dummyBox.graphics.clear();
_dummyBox.graphics.beginFill(26367, 1);
_dummyBox.graphics.drawRect((bounds.x - local.x), (bounds.y - local.y), bounds.width, bounds.height);
_dummyBox.graphics.endFill();
_dummyBox.x = _origin.x;
_dummyBox.y = _origin.y;
enforceSafetyZone();
i = (_selectedItems.length - 1);
while (i > -1) {
_selectedItems[i].origin = _origin;
i--;
};
plotHandles();
renderSelection();
_lockOrigin = false;
};
}
private function onMouseMoveStretchV($e:MouseEvent=null):void{
if (((!(_trackingInfo.scaled)) && (!(($e == null))))){
_trackingInfo.scaled = true;
dispatchInteractiveEvent(TransformEvent.START_INTERACTIVE_SCALE);
};
updateScale(false, true);
if ($e != null){
$e.updateAfterEvent();
};
}
public function selectItem($item, $addToSelection:Boolean=false):TransformItem{
var previousMode:Boolean;
var item:TransformItem = findObject($item);
if (item == null){
trace("TransformManager Error: selectItem() and selectItems() only work with objects that have a TransformItem associated with them. Make sure you create one by calling TransformManager.addItem() before attempting to select it.");
} else {
if (!item.selected){
previousMode = _multiSelectMode;
_multiSelectMode = $addToSelection;
_ignoreEvents = true;
item.selected = true;
_ignoreEvents = false;
_multiSelectMode = previousMode;
dispatchEvent(new TransformEvent(TransformEvent.SELECTION_CHANGE, [item]));
};
};
return (item);
}
public function flipSelectionVertical():void{
if (((_enabled) && (!((_selectedItems.length == 0))))){
scaleSelection(1, -1);
};
}
public function get targetObjects():Array{
var a:Array = [];
var i:uint;
while (i < _items.length) {
a.push(_items[i].targetObject);
i++;
};
return (a);
}
private function createHandle($name:String, $type:String, $cursorRotation:Number, $flipRotation:Number=0, $oppositeName:String=null):Object{
var onPress:Function;
var r:Sprite;
var h:Sprite = new Sprite();
h.name = $name;
var s:Sprite = new Sprite();
s.name = "scaleHandle";
var handle:Object = {handle:h, scaleHandle:s, type:$type, name:$name, oppositeName:$oppositeName, flipRotation:$flipRotation, cursorRotation:$cursorRotation};
_handlesDict[s] = handle;
if ($type != "center"){
if ($type == "stretchH"){
onPress = onPressStretchH;
} else {
if ($type == "stretchV"){
onPress = onPressStretchV;
} else {
onPress = onPressScale;
r = new Sprite();
r.name = "rotationHandle";
r.addEventListener(MouseEvent.MOUSE_DOWN, onPressRotate, false, 0, true);
h.addChild(r);
_handlesDict[r] = handle;
handle.rotationHandle = r;
};
};
s.addEventListener(MouseEvent.MOUSE_DOWN, onPress, false, 0, true);
} else {
s.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownSelection, false, 0, true);
};
h.addChild(s);
_selection.addChild(h);
_handles.push(handle);
return (handle);
}
public function get handleSize():Number{
return (_handleSize);
}
public function get selectionX():Number{
return (_dummyBox.x);
}
override public function addEventListener($type:String, $listener:Function, $useCapture:Boolean=false, $priority:int=0, $useWeakReference:Boolean=false):void{
if ($type == TransformEvent.MOVE){
_dispatchMoveEvents = true;
} else {
if ($type == TransformEvent.SCALE){
_dispatchScaleEvents = true;
} else {
if ($type == TransformEvent.ROTATE){
_dispatchRotateEvents = true;
};
};
};
super.addEventListener($type, $listener, $useCapture, $priority, $useWeakReference);
}
private function findObject($item):TransformItem{
if (($item is DisplayObject)){
return (getItem($item));
};
if (($item is TransformItem)){
return ($item);
};
return (null);
}
public function set selectionRotation($n:Number):void{
rotateSelection((($n - this.selectionRotation) * _DEG2RAD));
}
private function onRollOverSelectedItem($e:TransformEvent):void{
if (((!(_selLockPosition)) && (!($e.items[0].hasSelectableText)))){
if (_lockCursor){
_onUnlock = onRollOverSelectedItem;
_onUnlockParam = $e;
} else {
swapCursorIn(moveCursor, null);
};
};
}
public function get handleFillColor():uint{
return (_handleColor);
}
protected function lockCursor():void{
_lockCursor = true;
_onUnlock = null;
_onUnlockParam = null;
}
private function initSelection():void{
_selection = (_isFlex) ? new (getDefinitionByName("mx.core.UIComponent")) : new Sprite();
_selection.name = "__selection_mc";
_edges = new Sprite();
_edges.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownSelection, false, 0, true);
_selection.addChild(_edges);
_dummyBox = (_isFlex) ? new (getDefinitionByName("mx.core.UIComponent")) : new Sprite();
_dummyBox.name = "__dummyBox_mc";
_dummyBox.visible = false;
_handles = [];
createHandle("c", "center", 0, 0, null);
createHandle("t", "stretchV", 90, 0, "b");
createHandle("r", "stretchH", 0, 0, "l");
createHandle("b", "stretchV", -90, 0, "t");
createHandle("l", "stretchH", 180, 0, "r");
createHandle("tl", "corner", -135, -90, "br");
createHandle("tr", "corner", -45, 90, "bl");
createHandle("br", "corner", 45, -90, "tl");
createHandle("bl", "corner", 135, 90, "tr");
redrawHandles();
setCursorListeners(true);
}
public function get selectionY():Number{
return (_dummyBox.y);
}
public function get allowDelete():Boolean{
return (_allowDelete);
}
protected function onPressDelete($e:Event=null):void{
var deletedItems:Array;
var item:TransformItem;
var multiple:Boolean;
var i:int;
if (((_enabled) && (_allowDelete))){
deletedItems = [];
multiple = Boolean((_selectedItems.length > 1));
i = _selectedItems.length;
while (i--) {
item = _selectedItems[i];
if (item.onPressDelete($e, multiple)){
deletedItems[deletedItems.length] = item;
};
};
if (deletedItems.length > 0){
dispatchEvent(new TransformEvent(TransformEvent.DELETE, deletedItems));
};
};
}
public function rotateSelection($angle:Number, $dispatchEvents:Boolean=true):void{
var i:int;
var m:Matrix;
var m2:Matrix;
var safe:Object;
if (!_selLockRotation){
m = _dummyBox.transform.matrix;
m2 = m.clone();
m.tx = (m.ty = 0);
m.rotate($angle);
m.tx = _origin.x;
m.ty = _origin.y;
_dummyBox.transform.matrix = m;
safe = {angle:$angle};
if (((!((_bounds == null))) && (!(_bounds.containsRect(_dummyBox.getBounds(_parent)))))){
i = (_selectedItems.length - 1);
while (i > -1) {
_selectedItems[i].rotateCheck(safe);
i--;
};
m2.tx = (m2.ty = 0);
m2.rotate(safe.angle);
m2.tx = _origin.x;
m2.ty = _origin.y;
_dummyBox.transform.matrix = m2;
};
_ignoreEvents = true;
i = (_selectedItems.length - 1);
while (i > -1) {
_selectedItems[i].rotate(safe.angle, false, $dispatchEvents);
i--;
};
_ignoreEvents = false;
renderSelection();
if (((((_dispatchRotateEvents) && ($dispatchEvents))) && (!(((safe.angle % (Math.PI * 2)) == 0))))){
dispatchEvent(new TransformEvent(TransformEvent.ROTATE, _selectedItems.slice()));
};
};
}
public function get forceSelectionToFront():Boolean{
return (_forceSelectionToFront);
}
private function checkForDeselect($e:MouseEvent=null):void{
var i:int;
var x:Number;
var y:Number;
var deselectedItem:TransformItem;
if (((!((_selectedItems.length == 0))) && (!((_parent == null))))){
i = _selectedItems.length;
x = $e.stageX;
y = $e.stageY;
deselectedItem = _tempDeselectedItem;
_tempDeselectedItem = null;
if (_selection.hitTestPoint(x, y, true)){
return;
};
if (deselectedItem){
if (deselectedItem.targetObject.hitTestPoint(x, y, true)){
return;
};
};
while (i--) {
if (_selectedItems[i].targetObject.hitTestPoint(x, y, true)){
return;
};
};
i = _ignoredObjects.length;
while (i--) {
if (_ignoredObjects[i].hitTestPoint(x, y, true)){
return;
};
};
if (_autoDeselect){
deselectAll();
} else {
dispatchEvent(new TransformEvent(TransformEvent.CLICK_OFF, _selectedItems.slice(), $e));
};
};
}
public function set enabled($b:Boolean):void{
_enabled = $b;
updateItemProp("enabled", $b);
if (!$b){
swapCursorOut();
removeParentListeners();
};
}
public function set hideCenterHandle($b:Boolean):void{
_hideCenterHandle = $b;
redrawHandles();
}
public function get allowMultiSelect():Boolean{
return (_allowMultiSelect);
}
public function removeIgnoredObject($object:DisplayObject):void{
var i:uint;
while (i < _ignoredObjects.length) {
if (_ignoredObjects[i] == $object){
_ignoredObjects.splice(i, 1);
};
i++;
};
}
public function set handleSize($n:Number):void{
_handleSize = $n;
redrawHandles();
}
protected function onTargetAddedToStage($e:Event):void{
initParent($e.target.parent);
}
public function set selectionX($n:Number):void{
_dummyBox.x = $n;
}
private function onMouseMoveScale($e:MouseEvent=null):void{
if (((!(_trackingInfo.scaled)) && (!(($e == null))))){
_trackingInfo.scaled = true;
dispatchInteractiveEvent(TransformEvent.START_INTERACTIVE_SCALE);
};
updateScale(true, true);
if ($e != null){
$e.updateAfterEvent();
};
}
private function renderSelection():void{
var m:Matrix;
var rotation:Number;
var flip:Boolean;
var p:Point;
var finishPoint:Point;
var i:int;
if (_initted){
m = _dummyBox.transform.matrix;
_selection.graphics.clear();
_selection.graphics.lineStyle(1, _lineColor, 1, false, "none");
_edges.graphics.clear();
_edges.graphics.lineStyle(10, 0xFF0000, 0, false, "none");
rotation = _dummyBox.rotation;
flip = false;
if ((MatrixTools.getDirectionX(m) * MatrixTools.getDirectionY(m)) < 0){
flip = true;
};
i = (_handles.length - 1);
while (i > -1) {
p = m.transformPoint(_handles[i].point);
_handles[i].handle.x = p.x;
_handles[i].handle.y = p.y;
_handles[i].handle.rotation = rotation;
if (flip){
_handles[i].handle.rotation = (_handles[i].handle.rotation + _handles[i].flipRotation);
};
if (i == 8){
_selection.graphics.moveTo(p.x, p.y);
_edges.graphics.moveTo(p.x, p.y);
finishPoint = p;
} else {
if (i > 4){
_selection.graphics.lineTo(p.x, p.y);
_edges.graphics.lineTo(p.x, p.y);
};
};
i--;
};
_selection.graphics.lineTo(finishPoint.x, finishPoint.y);
_edges.graphics.lineTo(finishPoint.x, finishPoint.y);
};
}
public function exportSettingsXML():XML{
var settings:XML = <settings></settings>
;
settings.@allowDelete = uint(this.allowDelete);
settings.@allowMultiSelect = uint(this.allowMultiSelect);
settings.@autoDeselect = uint(this.autoDeselect);
settings.@constrainScale = uint(this.constrainScale);
settings.@lockScale = uint(this.lockScale);
settings.@scaleFromCenter = uint(this.scaleFromCenter);
settings.@lockRotation = uint(this.lockRotation);
settings.@lockPosition = uint(this.lockPosition);
settings.@arrowKeysMove = uint(this.arrowKeysMove);
settings.@forceSelectionToFront = uint(this.forceSelectionToFront);
settings.@lineColor = this.lineColor;
settings.@handleColor = this.handleFillColor;
settings.@handleSize = this.handleSize;
settings.@paddingForRotation = this.paddingForRotation;
settings.@hideCenterHandle = uint(this.hideCenterHandle);
settings.@hasBounds = ((_bounds)==null) ? 0 : 1;
if (_bounds != null){
settings.@boundsX = _bounds.x;
settings.@boundsY = _bounds.y;
settings.@boundsWidth = _bounds.width;
settings.@boundsHeight = _bounds.height;
};
return (settings);
}
public function set selectionY($n:Number):void{
_dummyBox.y = $n;
}
private function onReleaseRotate($e:MouseEvent):void{
if (!_selLockRotation){
_stage.removeEventListener(MouseEvent.MOUSE_UP, onReleaseRotate);
_stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveRotate);
unlockCursor();
_isTransforming = false;
if (_trackingInfo.rotated){
dispatchInteractiveEvent(TransformEvent.FINISH_INTERACTIVE_ROTATE);
};
};
}
private function onMouseDownSelection($e:MouseEvent):void{
_stage.addEventListener(MouseEvent.MOUSE_UP, onReleaseMove, false, 0, true);
onPressMove($e);
}
public function set allowDelete($b:Boolean):void{
_allowDelete = $b;
updateItemProp("allowDelete", $b);
}
protected function mouseIsOverSelection($ignoreSelectableTextItems:Boolean=false):Boolean{
var i:int;
if ((((_selectedItems.length == 0)) || ((_stage == null)))){
return (false);
};
if (_selection.hitTestPoint(_stage.mouseX, _stage.mouseY, true)){
return (true);
};
i = (_selectedItems.length - 1);
while (i > -1) {
if (((_selectedItems[i].targetObject.hitTestPoint(_stage.mouseX, _stage.mouseY, true)) && (!(((_selectedItems[i].hasSelectableText) && ($ignoreSelectableTextItems)))))){
return (true);
};
i--;
};
return (false);
}
public function applySettingsXML(xml:XML):void{
this.allowDelete = Boolean(uint(xml.@allowDelete));
this.allowMultiSelect = Boolean(uint(xml.@allowMultiSelect));
this.autoDeselect = Boolean(uint(xml.@autoDeselect));
this.constrainScale = Boolean(uint(xml.@constrainScale));
this.lockScale = Boolean(uint(xml.@lockScale));
this.scaleFromCenter = Boolean(uint(xml.@scaleFromCenter));
this.lockRotation = Boolean(uint(xml.@lockRotation));
this.lockPosition = Boolean(uint(xml.@lockPosition));
this.arrowKeysMove = Boolean(uint(xml.@arrowKeysMove));
this.forceSelectionToFront = Boolean(uint(xml.@forceSelectionToFront));
this.lineColor = uint(xml.@lineColor);
this.handleFillColor = uint(xml.@handleColor);
this.handleSize = Number(xml.@handleSize);
this.paddingForRotation = Number(xml.@paddingForRotation);
this.hideCenterHandle = Boolean(uint(xml.@hideCenterHandle));
if (Boolean(uint(xml.@hasBounds))){
this.bounds = new Rectangle(Number(xml.@boundsX), Number(xml.@boundsY), Number(xml.@boundsWidth), Number(xml.@boundsHeight));
};
}
public function set handleFillColor($n:uint):void{
_handleColor = $n;
redrawHandles();
}
public function set forceSelectionToFront($b:Boolean):void{
_forceSelectionToFront = $b;
}
public function exportFullXML():XML{
var i:int;
var xmlItems:XML = <items></items>
;
var l:uint = _items.length;
i = 0;
while (i < l) {
xmlItems.appendChild(exportItemXML(_items[i].targetObject));
i++;
};
var settings:XML = exportSettingsXML();
var xml:XML = <transformManager></transformManager>
;
xml.appendChild(settings);
xml.appendChild(xmlItems);
return (xml);
}
public function get bounds():Rectangle{
return (_bounds);
}
public function applyItemXML(xml:XML, defaultParent:DisplayObjectContainer=null, placeholderColor:uint=0xCCCCCC):DisplayObject{
var i:int;
var g:Graphics;
var parent:DisplayObjectContainer = ((_parent) || (defaultParent));
var mc:DisplayObject = parent.getChildByName(xml.@name);
if (mc == null){
i = _items.length;
while (i--) {
if (TransformItem(_items[i]).targetObject.name == xml.@name){
mc = TransformItem(_items[i]).targetObject;
break;
};
};
};
if (mc == null){
mc = (_isFlex) ? new (getDefinitionByName("mx.core.UIComponent")) : new Sprite();
mc.name = xml.@name;
g = (mc as Sprite).graphics;
g.beginFill(placeholderColor, 1);
g.drawRect(Number(xml.@xOffset), Number(xml.@yOffset), Number(xml.@rawWidth), Number(xml.@rawHeight));
g.endFill();
parent.addChild(mc);
};
if (xml.@scaleMode == TransformManager.SCALE_WIDTH_AND_HEIGHT){
mc.width = Number(xml.@rawWidth);
mc.height = Number(xml.@rawHeight);
};
mc.transform.matrix = new Matrix(Number(xml.@a), Number(xml.@b), Number(xml.@c), Number(xml.@d), Number(xml.@tx), Number(xml.@ty));
if ((((parent.numChildren > xml.@level)) && ((mc.parent == parent)))){
parent.setChildIndex(mc, xml.@level);
};
var item:TransformItem = this.addItem(mc, xml.@scaleMode, Boolean(uint(xml.@hasSelectableText)));
item.minScaleX = Number(xml.@minScaleX);
item.maxScaleX = Number(xml.@maxScaleX);
item.minScaleY = Number(xml.@minScaleY);
item.maxScaleY = Number(xml.@maxScaleY);
return (mc);
}
private function onUpdateItem($e:TransformEvent):void{
if (!_ignoreEvents){
if ($e.type == TransformEvent.UPDATE){
calibrateConstraints();
};
if ((($e.target.selected) && (!(_isTransforming)))){
updateSelection(true);
dispatchEvent(new TransformEvent(TransformEvent.UPDATE, [$e.target]));
};
};
}
public function moveSelection($x:Number, $y:Number, $dispatchEvents:Boolean=true):void{
var safe:Object;
var m:Matrix;
var i:int;
if (!_selLockPosition){
safe = {x:$x, y:$y};
m = _dummyBox.transform.matrix;
_dummyBox.x = (_dummyBox.x + $x);
_dummyBox.y = (_dummyBox.y + $y);
if (((!((_bounds == null))) && (!(_bounds.containsRect(_dummyBox.getBounds(_parent)))))){
i = (_selectedItems.length - 1);
while (i > -1) {
_selectedItems[i].moveCheck($x, $y, safe);
i--;
};
m.translate(safe.x, safe.y);
_dummyBox.transform.matrix = m;
};
_ignoreEvents = true;
i = (_selectedItems.length - 1);
while (i > -1) {
_selectedItems[i].move(safe.x, safe.y, false, $dispatchEvents);
i--;
};
_ignoreEvents = false;
_origin.x = _dummyBox.x;
_origin.y = _dummyBox.y;
renderSelection();
if (((((_dispatchMoveEvents) && ($dispatchEvents))) && (((!((safe.x == 0))) || (!((safe.y == 0))))))){
dispatchEvent(new TransformEvent(TransformEvent.MOVE, _selectedItems.slice()));
};
};
}
public function updateSelection($centerOrigin:Boolean=true):void{
var r:Rectangle;
var ti:TransformItem;
var t:DisplayObject;
var m:Matrix;
if (!_initted){
} else {
if (_selectedItems.length != 0){
if (_dummyBox.parent != _parent){
_parent.addChild(_dummyBox);
};
_dummyBox.transform.matrix = new Matrix();
_dummyBox.graphics.clear();
_dummyBox.graphics.beginFill(26367, 1);
if (_selectedItems.length == 1){
ti = _selectedItems[0];
t = ti.targetObject;
if (t.width != 0){
m = t.transform.matrix;
t.transform.matrix = new Matrix();
r = t.getBounds(t);
_dummyBox.graphics.drawRect(r.x, r.y, t.width, t.height);
_dummyBox.transform.matrix = (t.transform.matrix = m);
} else {
r = t.getBounds(t);
_dummyBox.graphics.drawRect(r.x, r.y, r.width, r.height);
_dummyBox.transform.matrix = t.transform.matrix;
};
} else {
r = getSelectionRect();
_dummyBox.graphics.drawRect(r.x, r.y, r.width, r.height);
};
_dummyBox.graphics.endFill();
if ((($centerOrigin) || ((_origin == null)))){
centerOrigin();
} else {
setOrigin(_origin);
};
if (_selection.parent != _parent){
_parent.addChild(_selection);
};
renderSelection();
bringToFront(_selection);
} else {
if (_parent != null){
if (_selection.parent == _parent){
_parent.removeChild(_selection);
};
if (_dummyBox.parent == _parent){
_parent.removeChild(_dummyBox);
};
};
};
};
}
private function setCursorListeners($on:Boolean=true):void{
var s:Sprite;
var r:Sprite;
var i:int;
i = (_handles.length - 1);
while (i > -1) {
s = _handles[i].handle.getChildByName("scaleHandle");
r = _handles[i].handle.getChildByName("rotationHandle");
if (_handles[i].handle.name != "c"){
if ($on){
s.addEventListener(MouseEvent.ROLL_OVER, onRollOverScale, false, 0, true);
s.addEventListener(MouseEvent.ROLL_OUT, swapCursorOut, false, 0, true);
if (r != null){
r.addEventListener(MouseEvent.ROLL_OVER, onRollOverRotate, false, 0, true);
r.addEventListener(MouseEvent.ROLL_OUT, swapCursorOut, false, 0, true);
};
} else {
s.removeEventListener(MouseEvent.ROLL_OVER, onRollOverScale);
s.removeEventListener(MouseEvent.ROLL_OUT, swapCursorOut);
if (r != null){
r.removeEventListener(MouseEvent.ROLL_OVER, onRollOverRotate);
r.removeEventListener(MouseEvent.ROLL_OUT, swapCursorOut);
};
};
} else {
if ($on){
s.addEventListener(MouseEvent.ROLL_OVER, onRollOverMove, false, 0, true);
s.addEventListener(MouseEvent.ROLL_OUT, swapCursorOut, false, 0, true);
} else {
s.removeEventListener(MouseEvent.ROLL_OVER, onRollOverMove);
s.removeEventListener(MouseEvent.ROLL_OUT, swapCursorOut);
};
};
i--;
};
if ($on){
_edges.addEventListener(MouseEvent.ROLL_OVER, onRollOverMove, false, 0, true);
_edges.addEventListener(MouseEvent.ROLL_OUT, swapCursorOut, false, 0, true);
} else {
_edges.removeEventListener(MouseEvent.ROLL_OVER, onRollOverMove);
_edges.removeEventListener(MouseEvent.ROLL_OUT, swapCursorOut);
};
}
private function moveSelectionDepth(direction:int=1):void{
var curDepths:Array;
var i:int;
var newDepths:Array;
var hitGap:Boolean;
if (((((((((_enabled) && (!((_selectedItems.length == 0))))) && (!((_parent == null))))) && (_parent.contains(_dummyBox)))) && (_parent.contains(_selection)))){
curDepths = [];
i = (_items.length - 1);
while (i > -1) {
if (_items[i].targetObject.parent == _parent){
curDepths.push({depth:_parent.getChildIndex(_items[i].targetObject), item:_items[i]});
};
i--;
};
curDepths.sortOn("depth", Array.NUMERIC);
newDepths = [];
hitGap = false;
if (direction == -1){
newDepths.push(curDepths[0].item.targetObject);
if (!curDepths[0].item.selected){
hitGap = true;
};
i = 1;
while (i < curDepths.length) {
if (((curDepths[i].item.selected) && (hitGap))){
newDepths.splice(-1, 0, curDepths[i].item.targetObject);
} else {
newDepths.push(curDepths[i].item.targetObject);
if (((!(curDepths[i].item.selected)) && (!(hitGap)))){
hitGap = true;
};
};
i++;
};
} else {
newDepths.push(curDepths[(curDepths.length - 1)].item.targetObject);
if (!curDepths[(curDepths.length - 1)].item.selected){
hitGap = true;
};
i = (curDepths.length - 2);
while (i > -1) {
if (((curDepths[i].item.selected) && (hitGap))){
newDepths.splice(1, 0, curDepths[i].item.targetObject);
} else {
newDepths.unshift(curDepths[i].item.targetObject);
if (((!(curDepths[i].item.selected)) && (!(hitGap)))){
hitGap = true;
};
};
i--;
};
};
i = 0;
while (i < newDepths.length) {
_parent.setChildIndex(newDepths[i], curDepths[i].depth);
i++;
};
dispatchEvent(new TransformEvent(TransformEvent.DEPTH_CHANGE, _items.slice()));
};
}
private function onDestroyItem($e:TransformEvent):void{
removeItem($e.target);
}
public function get paddingForRotation():Number{
return (_paddingForRotation);
}
public function set selectedTargetObjects($a:Array):void{
selectItems($a, false);
}
public function getSelectionCenter():Point{
var bounds:Rectangle = _dummyBox.getBounds(_dummyBox);
return (_parent.globalToLocal(_dummyBox.localToGlobal(new Point((bounds.x + (bounds.width / 2)), (bounds.y + (bounds.height / 2))))));
}
public function get lockScale():Boolean{
return (_lockScale);
}
public function set lockPosition($b:Boolean):void{
_lockPosition = $b;
updateItemProp("lockPosition", $b);
calibrateConstraints();
}
private function calibrateConstraints():void{
_selConstrainScale = _constrainScale;
_selLockScale = _lockScale;
_selLockRotation = _lockRotation;
_selLockPosition = _lockPosition;
_selHasTextFields = (_selHasScaleLimits = false);
var i:int = (_selectedItems.length - 1);
while (i > -1) {
if (_selectedItems[i].constrainScale){
_selConstrainScale = true;
};
if (_selectedItems[i].lockScale){
_selLockScale = true;
};
if (_selectedItems[i].lockRotation){
_selLockRotation = true;
};
if (_selectedItems[i].lockPosition){
_selLockPosition = true;
};
if (_selectedItems[i].scaleMode != SCALE_NORMAL){
_selHasTextFields = true;
};
if (_selectedItems[i].hasScaleLimits){
_selHasScaleLimits = true;
};
i--;
};
}
private function onDeselectItem($e:TransformEvent):void{
var i:int = (_selectedItems.length - 1);
while (i > -1) {
if (_selectedItems[i] == $e.target){
_selectedItems.splice(i, 1);
updateSelection();
if (!_ignoreEvents){
dispatchEvent(new TransformEvent(TransformEvent.SELECTION_CHANGE, [($e.target as TransformItem)]));
};
if (!mouseIsOverSelection(true)){
swapCursorOut();
};
if (((_lockCursor) && ((_selectedItems.length == 0)))){
unlockCursor();
};
return;
};
i--;
};
}
public function get selectionScaleX():Number{
return (MatrixTools.getScaleX(_dummyBox.transform.matrix));
}
public function get selectionScaleY():Number{
return (MatrixTools.getScaleY(_dummyBox.transform.matrix));
}
private function updateItemProp($prop:String, $value):void{
var i:int = (_items.length - 1);
while (i > -1) {
_items[i][$prop] = $value;
i--;
};
}
private function onReleaseScale($e:MouseEvent):void{
if (!_selLockScale){
_stage.removeEventListener(MouseEvent.MOUSE_UP, onReleaseScale);
_stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveScale);
unlockCursor();
centerOrigin();
_isTransforming = false;
if (_trackingInfo.scaled){
dispatchInteractiveEvent(TransformEvent.FINISH_INTERACTIVE_SCALE);
};
};
}
public function get isShowingCustomCursor():Boolean{
return (Boolean(!((_currentCursor == null))));
}
private function onMouseDownItem($e:TransformEvent):void{
if (isKeyDown(Keyboard.CONTROL)){
$e.target.selected = !($e.target.selected);
if (!$e.target.selected){
_tempDeselectedItem = ($e.target as TransformItem);
};
} else {
$e.target.selected = true;
};
if (!$e.target.hasSelectableText){
_stage.stageFocusRect = false;
_stage.focus = $e.target.targetObject;
};
}
public function get arrowKeysMove():Boolean{
return (_arrowKeysMove);
}
protected function init($vars:Object):void{
_allowDelete = setDefault($vars.allowDelete, false);
_allowMultiSelect = setDefault($vars.allowMultiSelect, true);
_autoDeselect = setDefault($vars.autoDeselect, true);
_constrainScale = setDefault($vars.constrainScale, false);
_lockScale = setDefault($vars.lockScale, false);
_scaleFromCenter = setDefault($vars.scaleFromCenter, false);
_lockRotation = setDefault($vars.lockRotation, false);
_lockPosition = setDefault($vars.lockPosition, false);
_arrowKeysMove = setDefault($vars.arrowKeysMove, false);
_forceSelectionToFront = setDefault($vars.forceSelectionToFront, true);
_lineColor = setDefault($vars.lineColor, 3381759);
_handleColor = setDefault($vars.handleFillColor, 0xFFFFFF);
_handleSize = setDefault($vars.handleSize, 8);
_paddingForRotation = setDefault($vars.paddingForRotation, 12);
_hideCenterHandle = setDefault($vars.hideCenterHandle, false);
_multiSelectMode = (_ignoreEvents = false);
_bounds = $vars.bounds;
_enabled = true;
_keyDispatcher.addEventListener("pressDelete", onPressDelete, false, 0, true);
_keyDispatcher.addEventListener("pressArrowKey", onPressArrowKey, false, 0, true);
_keyDispatcher.addEventListener("pressMultiSelectKey", onPressMultiSelectKey, false, 0, true);
_keyDispatcher.addEventListener("releaseMultiSelectKey", onReleaseMultiSelectKey, false, 0, true);
_items = (($vars.items) || ([]));
_selectedItems = [];
this.ignoredObjects = (($vars.ignoredObjects) || ([]));
_handles = [];
_handlesDict = new Dictionary();
if ($vars.targetObjects != undefined){
addItems($vars.targetObjects);
};
}
public function set scaleFromCenter($b:Boolean):void{
_scaleFromCenter = $b;
}
public function set allowMultiSelect($b:Boolean):void{
_allowMultiSelect = $b;
if (!$b){
_multiSelectMode = false;
};
}
private function onReleaseMove($e:Event):void{
var clickTime:uint = getTimer();
if ((clickTime - _lastClickTime) < 500){
dispatchEvent(new TransformEvent(TransformEvent.DOUBLE_CLICK, _selectedItems.slice()));
};
_lastClickTime = clickTime;
if (!_selLockPosition){
_stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveMove);
_stage.removeEventListener(MouseEvent.MOUSE_UP, onReleaseMove);
unlockCursor();
_isTransforming = false;
if (_trackingInfo.moved){
dispatchInteractiveEvent(TransformEvent.FINISH_INTERACTIVE_MOVE);
};
};
}
public function set autoDeselect($b:Boolean):void{
_autoDeselect = $b;
}
private function enforceSafetyZone():void{
var locks:Array;
var prevLockPosition:Boolean;
var prevLockScale:Boolean;
var b:Rectangle;
var recordLocks:Function = function ():Array{
var a:Array = [];
var i:int = (_selectedItems.length - 1);
while (i > -1) {
a[i] = {position:_selectedItems[i].lockPosition, scale:_selectedItems[i].lockScale};
i--;
};
return (a);
};
var restoreLocks:Function = function ($a:Array):void{
var i:int = ($a.length - 1);
while (i > -1) {
_selectedItems[i].lockPosition = $a[i].position;
_selectedItems[i].lockScale = $a[i].scale;
i--;
};
};
var shiftSelection:Function = function ($x:Number, $y:Number):void{
_dummyBox.x = (_dummyBox.x + $x);
_dummyBox.y = (_dummyBox.y + $y);
var i:int = (_selectedItems.length - 1);
while (i > -1) {
_selectedItems[i].move($x, $y, false, false);
i--;
};
_origin.x = (_origin.x + $x);
_origin.y = (_origin.y + $y);
};
var shiftSelectionScale:Function = function ($scale:Number):void{
var i:int;
var o:Point = _origin.clone();
_origin.x = (_bounds.x + (_bounds.width / 2));
_origin.y = (_bounds.y + (_bounds.height / 2));
i = (_selectedItems.length - 1);
while (i > -1) {
_selectedItems[i].origin = _origin;
i--;
};
scaleSelection($scale, $scale, false);
_origin.x = o.x;
_origin.y = o.y;
i = (_selectedItems.length - 1);
while (i > -1) {
_selectedItems[i].origin = _origin;
i--;
};
updateSelection();
};
if (_bounds != null){
prevLockPosition = _selLockPosition;
prevLockScale = _selLockScale;
_selLockPosition = false;
_selLockScale = false;
if (!_bounds.containsPoint(_origin)){
locks = recordLocks();
if (_bounds.left > _origin.x){
shiftSelection((_bounds.left - _origin.x), 0);
} else {
if (_bounds.right < _origin.x){
shiftSelection((_bounds.right - _origin.x), 0);
};
};
if (_bounds.top > _origin.y){
shiftSelection(0, (_bounds.top - _origin.y));
} else {
if (_bounds.bottom < _origin.y){
shiftSelection(0, (_bounds.bottom - _origin.y));
};
};
};
if (_selectedItems.length != 0){
if (locks == null){
locks = recordLocks();
};
if (_handles[0].point == null){
plotHandles();
};
b = getSelectionRect();
if ((_bounds.width - b.width) < 0.2){
shiftSelectionScale((1 - (0.22 / b.width)));
};
b = getSelectionRect();
if ((_bounds.height - b.height) < 0.2){
shiftSelectionScale((1 - (0.22 / b.height)));
};
if (Math.abs((b.top - _bounds.top)) < 0.1){
shiftSelection(0, 0.1);
};
if (Math.abs((b.bottom - _bounds.bottom)) < 0.1){
shiftSelection(0, -0.1);
};
if (Math.abs((b.left - _bounds.left)) < 0.1){
shiftSelection(0.1, 0);
};
if (Math.abs((b.right - _bounds.right)) < 0.1){
shiftSelection(-0.1, 0);
};
};
if (locks != null){
restoreLocks(locks);
};
_selLockPosition = prevLockPosition;
_selLockScale = prevLockScale;
};
}
public function flipSelectionHorizontal():void{
if (((_enabled) && (!((_selectedItems.length == 0))))){
scaleSelection(-1, 1);
};
}
public function getSelectionBounds(targetCoordinateSpace:DisplayObject=null):Rectangle{
if (((_parent.contains(_dummyBox)) && (!((_selectedItems.length == 0))))){
if (targetCoordinateSpace){
return (_dummyBox.getBounds(targetCoordinateSpace));
};
return (_dummyBox.getBounds(_parent));
//unresolved jump
};
return (null);
}
public function set paddingForRotation($n:Number):void{
_paddingForRotation = $n;
redrawHandles();
}
private function plotHandles():void{
var r:Rectangle = _dummyBox.getBounds(_dummyBox);
_handles[0].point = new Point((r.x + (r.width / 2)), (r.y + (r.height / 2)));
_handles[1].point = new Point((r.x + (r.width / 2)), r.y);
_handles[2].point = new Point((r.x + r.width), (r.y + (r.height / 2)));
_handles[3].point = new Point((r.x + (r.width / 2)), (r.y + r.height));
_handles[4].point = new Point(r.x, (r.y + (r.height / 2)));
_handles[5].point = new Point(r.x, r.y);
_handles[6].point = new Point((r.x + r.width), r.y);
_handles[7].point = new Point((r.x + r.width), (r.y + r.height));
_handles[8].point = new Point(r.x, (r.y + r.height));
}
private function onReleaseStretchH($e:MouseEvent):void{
if (!_selLockScale){
_stage.removeEventListener(MouseEvent.MOUSE_UP, onReleaseStretchH);
_stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveStretchH);
unlockCursor();
centerOrigin();
_isTransforming = false;
if (_trackingInfo.scaled){
dispatchInteractiveEvent(TransformEvent.FINISH_INTERACTIVE_SCALE);
};
};
}
public function getUnrotatedSelectionWidth():Number{
var bounds:Rectangle = _dummyBox.getBounds(_dummyBox);
return ((bounds.width * MatrixTools.getScaleX(_dummyBox.transform.matrix)));
}
private function onReleaseStretchV($e:MouseEvent):void{
if (!_selLockScale){
_stage.removeEventListener(MouseEvent.MOUSE_UP, onReleaseStretchV);
_stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveStretchV);
unlockCursor();
centerOrigin();
_isTransforming = false;
if (_trackingInfo.scaled){
dispatchInteractiveEvent(TransformEvent.FINISH_INTERACTIVE_SCALE);
};
};
}
private function onRollOverScale($e:MouseEvent):void{
if (((!(_selLockScale)) && (((!(_selHasTextFields)) || ((_selectedItems.length == 1)))))){
if (_lockCursor){
_onUnlock = onRollOverScale;
_onUnlockParam = $e;
} else {
swapCursorIn(scaleCursor, _handlesDict[$e.target]);
};
};
}
public function get hideCenterHandle():Boolean{
return (_hideCenterHandle);
}
public function get selectionRotation():Number{
return (_dummyBox.rotation);
}
public function removeAllItems():void{
var item:TransformItem;
var i:int = (_items.length - 1);
while (i > -1) {
item = _items[i];
item.selected = false;
item.removeEventListener(TransformEvent.SELECT, onSelectItem);
item.removeEventListener(TransformEvent.DESELECT, onDeselectItem);
item.removeEventListener(TransformEvent.MOUSE_DOWN, onMouseDownItem);
item.removeEventListener(TransformEvent.SELECT_MOUSE_DOWN, onPressMove);
item.removeEventListener(TransformEvent.SELECT_MOUSE_UP, onReleaseMove);
item.removeEventListener(TransformEvent.UPDATE, onUpdateItem);
item.removeEventListener(TransformEvent.SCALE, onUpdateItem);
item.removeEventListener(TransformEvent.ROTATE, onUpdateItem);
item.removeEventListener(TransformEvent.MOVE, onUpdateItem);
item.removeEventListener(TransformEvent.ROLL_OVER_SELECTED, onRollOverSelectedItem);
item.removeEventListener(TransformEvent.ROLL_OUT_SELECTED, onRollOutSelectedItem);
item.removeEventListener(TransformEvent.DESTROY, onDestroyItem);
_items.splice(i, 1);
item.destroy();
i--;
};
}
public function get enabled():Boolean{
return (_enabled);
}
public function addItem($targetObject:DisplayObject, $scaleMode:String="scaleNormal", $hasSelectableText:Boolean=false):TransformItem{
if (((($targetObject == _dummyBox)) || (($targetObject == _selection)))){
return (null);
};
var props:Array = ["constrainScale", "scaleFromCenter", "lockScale", "lockRotation", "lockPosition", "autoDeselect", "allowDelete", "bounds", "enabled", "forceSelectionToFront"];
var newVars:Object = {manager:this};
var i:uint;
while (i < props.length) {
newVars[props[i]] = this[props[i]];
i++;
};
var existingItem:TransformItem = getItem($targetObject);
if (existingItem != null){
existingItem.update(null);
return (existingItem);
};
newVars.scaleMode = (($targetObject is TextField)) ? SCALE_WIDTH_AND_HEIGHT : $scaleMode;
newVars.hasSelectableText = (($targetObject is TextField)) ? true : $hasSelectableText;
var newItem = new TransformItem($targetObject, newVars);
newItem.addEventListener(TransformEvent.SELECT, onSelectItem);
newItem.addEventListener(TransformEvent.DESELECT, onDeselectItem);
newItem.addEventListener(TransformEvent.MOUSE_DOWN, onMouseDownItem);
newItem.addEventListener(TransformEvent.SELECT_MOUSE_DOWN, onPressMove);
newItem.addEventListener(TransformEvent.SELECT_MOUSE_UP, onReleaseMove);
newItem.addEventListener(TransformEvent.UPDATE, onUpdateItem);
newItem.addEventListener(TransformEvent.SCALE, onUpdateItem);
newItem.addEventListener(TransformEvent.ROTATE, onUpdateItem);
newItem.addEventListener(TransformEvent.MOVE, onUpdateItem);
newItem.addEventListener(TransformEvent.ROLL_OVER_SELECTED, onRollOverSelectedItem);
newItem.addEventListener(TransformEvent.ROLL_OUT_SELECTED, onRollOutSelectedItem);
newItem.addEventListener(TransformEvent.DESTROY, onDestroyItem);
_items.push(newItem);
if (!_initted){
if ($targetObject.parent == null){
$targetObject.addEventListener(Event.ADDED_TO_STAGE, onTargetAddedToStage, false, 0, true);
} else {
initParent($targetObject.parent);
};
};
return (newItem);
}
private function setScaleOrigin($pressedHandle:Sprite):void{
var h:DisplayObject;
bringToFront($pressedHandle.parent);
if (_scaleFromCenter){
centerOrigin();
} else {
h = _selection.getChildByName(_handlesDict[$pressedHandle].oppositeName);
setOrigin(new Point(h.x, h.y));
};
}
private function onPressArrowKey($e:KeyboardEvent=null):void{
var moveAmount:int;
if (((((((_arrowKeysMove) && (_enabled))) && (!((_selectedItems.length == 0))))) && (!((_stage.focus is TextField))))){
moveAmount = (isKeyDown(Keyboard.SHIFT)) ? 10 : 1;
dispatchInteractiveEvent(TransformEvent.START_INTERACTIVE_MOVE);
switch ($e.keyCode){
case Keyboard.UP:
moveSelection(0, -(moveAmount));
break;
case Keyboard.DOWN:
moveSelection(0, moveAmount);
break;
case Keyboard.LEFT:
moveSelection(-(moveAmount), 0);
break;
case Keyboard.RIGHT:
moveSelection(moveAmount, 0);
break;
};
dispatchInteractiveEvent(TransformEvent.FINISH_INTERACTIVE_MOVE);
};
}
private function redrawHandles():void{
var i:uint;
var s:Sprite;
var r:Sprite;
var handleName:String;
var rx:Number;
var ry:Number;
var halfH:Number = (_handleSize / 2);
i = 0;
while (i < _handles.length) {
s = _handles[i].scaleHandle;
handleName = _handles[i].name;
s.graphics.clear();
s.graphics.lineStyle(1, _lineColor, 1, false, "none");
s.graphics.beginFill(_handleColor, 1);
s.graphics.drawRect((0 - (_handleSize / 2)), (0 - (_handleSize / 2)), _handleSize, _handleSize);
s.graphics.endFill();
if (_handles[i].type == "corner"){
r = _handles[i].rotationHandle;
if (handleName == "tl"){
ry = (-(halfH) - _paddingForRotation);
rx = ry;
} else {
if (handleName == "tr"){
rx = -(halfH);
ry = (-(halfH) - _paddingForRotation);
} else {
if (handleName == "br"){
ry = -(halfH);
rx = ry;
} else {
rx = (-(halfH) - _paddingForRotation);
ry = -(halfH);
};
};
};
r.graphics.clear();
r.graphics.lineStyle(0, _lineColor, 0);
r.graphics.beginFill(0xFF0000, 0);
r.graphics.drawRect(rx, ry, (_handleSize + _paddingForRotation), (_handleSize + _paddingForRotation));
r.graphics.endFill();
} else {
if (_handles[i].type == "center"){
s.visible = !(_hideCenterHandle);
};
};
i++;
};
}
private function onPressMultiSelectKey($e:Event=null):void{
if (((_allowMultiSelect) && (!(_multiSelectMode)))){
_multiSelectMode = true;
};
}
private function onMouseMoveMove($e:MouseEvent=null):void{
if (((!(_trackingInfo.moved)) && (!(($e == null))))){
_trackingInfo.moved = true;
dispatchInteractiveEvent(TransformEvent.START_INTERACTIVE_MOVE);
};
var x:Number = int((_parent.mouseX - (_dummyBox.x + _trackingInfo.offsetX)));
var y:Number = int((_parent.mouseY - (_dummyBox.y + _trackingInfo.offsetY)));
var totalX:Number = (_parent.mouseX - _trackingInfo.mouseX);
var totalY:Number = (_parent.mouseY - _trackingInfo.mouseY);
if (!isKeyDown(Keyboard.SHIFT)){
moveSelection(x, y);
} else {
if (Math.abs(totalX) > Math.abs(totalY)){
moveSelection(x, (_trackingInfo.y - _dummyBox.y));
} else {
moveSelection((_trackingInfo.x - _dummyBox.x), y);
};
};
if ($e != null){
$e.updateAfterEvent();
};
}
private function onSelectItem($e:TransformEvent):void{
var i:int;
var previousIgnore:Boolean = _ignoreEvents;
_ignoreEvents = true;
var changed:Array = [($e.target as TransformItem)];
if (!_multiSelectMode){
i = (_selectedItems.length - 1);
while (i > -1) {
changed.push(_selectedItems[i]);
_selectedItems[i].selected = false;
_selectedItems.splice(i, 1);
i--;
};
};
_selectedItems.push($e.target);
if (_initted){
if (_forceSelectionToFront){
i = (_selectedItems.length - 1);
while (i > -1) {
bringToFront(_selectedItems[i].targetObject);
i--;
};
};
calibrateConstraints();
updateSelection();
if (mouseIsOverSelection(true)){
onRollOverSelectedItem($e);
};
};
_ignoreEvents = previousIgnore;
if (!_ignoreEvents){
dispatchEvent(new TransformEvent(TransformEvent.SELECTION_CHANGE, changed));
};
}
public function get selectedTargetObjects():Array{
var a:Array = [];
var i:uint;
while (i < _selectedItems.length) {
a.push(_selectedItems[i].targetObject);
i++;
};
return (a);
}
public function deselectItem($item):TransformItem{
var item:TransformItem = findObject($item);
if (item != null){
item.selected = false;
};
return (item);
}
protected function dispatchInteractiveEvent(type:String):void{
dispatchEvent(new TransformEvent(type, _selectedItems.slice()));
var i:int = _selectedItems.length;
while (--i > -1) {
TransformItem(_selectedItems[i]).dispatchEvent(new TransformEvent(type, [_selectedItems[i]]));
};
}
public function get lockPosition():Boolean{
return (_lockPosition);
}
private function onMouseMoveRotate($e:MouseEvent=null):void{
var angleIncrement:Number;
var ti:Object = _trackingInfo;
if (((!(ti.rotated)) && (!(($e == null))))){
_trackingInfo.rotated = true;
dispatchInteractiveEvent(TransformEvent.START_INTERACTIVE_ROTATE);
};
var dx:Number = (_parent.mouseX - _origin.x);
var dy:Number = (_origin.y - _parent.mouseY);
var angleToMouse:Number = Math.atan2(dy, dx);
var angleDifference:Number = (ti.angleToMouse - Math.atan2(dy, dx));
var newAngle:Number = (angleDifference + ti.angle);
if (isKeyDown(Keyboard.SHIFT)){
angleIncrement = (Math.PI * 0.25);
newAngle = (Math.round((newAngle / angleIncrement)) * angleIncrement);
};
newAngle = (newAngle - (_dummyBox.rotation * _DEG2RAD));
if (Math.abs(newAngle) > (0.25 * _DEG2RAD)){
rotateSelection((newAngle % (Math.PI * 2)));
};
if ($e != null){
$e.updateAfterEvent();
};
}
public function getUnrotatedSelectionHeight():Number{
var bounds:Rectangle = _dummyBox.getBounds(_dummyBox);
return ((bounds.height * MatrixTools.getScaleY(_dummyBox.transform.matrix)));
}
public function getSelectionBoundsWithHandles(targetCoordinateSpace:DisplayObject=null):Rectangle{
if (((_parent.contains(_selection)) && (!((_selectedItems.length == 0))))){
if (targetCoordinateSpace){
return (_selection.getBounds(targetCoordinateSpace));
};
return (_selection.getBounds(_parent));
//unresolved jump
};
return (null);
}
public function getItem($targetObject:DisplayObject):TransformItem{
var i:int = (_items.length - 1);
while (i > -1) {
if (_items[i].targetObject == $targetObject){
return (_items[i]);
};
i--;
};
return (null);
}
public function moveSelectionDepthUp():void{
moveSelectionDepth(1);
}
public function get autoDeselect():Boolean{
return (_autoDeselect);
}
private function onRollOverRotate($e:MouseEvent):void{
if (!_selLockRotation){
if (_lockCursor){
_onUnlock = onRollOverRotate;
_onUnlockParam = $e;
} else {
swapCursorIn(rotationCursor, _handlesDict[$e.target]);
};
};
}
public function scaleSelection($sx:Number, $sy:Number, $dispatchEvents:Boolean=true):void{
var i:int;
var m:Matrix;
var m2:Matrix;
var angle:Number;
var skew:Number;
var safe:Object;
if (((!(_selLockScale)) && (((!(_selHasTextFields)) || ((((((_selectedItems.length == 1)) && (($sx > 0)))) && (($sy > 0)))))))){
m = _dummyBox.transform.matrix;
m2 = m.clone();
angle = MatrixTools.getAngle(m);
skew = MatrixTools.getSkew(m);
if (((!((angle == -(skew)))) && ((Math.abs(((angle + skew) % (Math.PI - 0.01))) < 0.01)))){
skew = -(angle);
};
MatrixTools.scaleMatrix(m, $sx, $sy, angle, skew);
_dummyBox.transform.matrix = m;
safe = {sx:$sx, sy:$sy};
if (((_selHasScaleLimits) || (((!((_bounds == null))) && (!(_bounds.containsRect(_dummyBox.getBounds(_parent)))))))){
i = (_selectedItems.length - 1);
while (i > -1) {
_selectedItems[i].scaleCheck(safe, angle, skew);
i--;
};
MatrixTools.scaleMatrix(m2, safe.sx, safe.sy, angle, skew);
_dummyBox.transform.matrix = m2;
};
_ignoreEvents = true;
i = (_selectedItems.length - 1);
while (i > -1) {
_selectedItems[i].scaleRotated(safe.sx, safe.sy, angle, skew, false, $dispatchEvents);
i--;
};
_ignoreEvents = false;
_prevScaleX = (_prevScaleX * safe.sx);
_prevScaleY = (_prevScaleY * safe.sy);
renderSelection();
if (((((_dispatchScaleEvents) && ($dispatchEvents))) && (((!((safe.sx == 1))) || (!((safe.sy == 1))))))){
dispatchEvent(new TransformEvent(TransformEvent.SCALE, _selectedItems.slice()));
};
};
}
public function addIgnoredObject($object:DisplayObject):void{
var i:uint;
while (i < _ignoredObjects.length) {
if (_ignoredObjects[i] == $object){
return;
};
i++;
};
removeItem($object);
_ignoredObjects.push($object);
}
private function removeParentListeners():void{
if (((!((_parent == null))) && (!((_stage == null))))){
_stage.removeEventListener(MouseEvent.MOUSE_UP, onReleaseMove);
_stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveMove);
_stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveRotate);
_stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveScale);
};
}
private function onPressMove($e:Event):void{
if (!_selLockPosition){
_isTransforming = true;
_trackingInfo = {moved:false, offsetX:(_parent.mouseX - _dummyBox.x), offsetY:(_parent.mouseY - _dummyBox.y), x:_dummyBox.x, y:_dummyBox.y, mouseX:_parent.mouseX, mouseY:_parent.mouseY};
_stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveMove, false, 0, true);
swapCursorIn(moveCursor, null);
lockCursor();
onMouseMoveMove();
};
}
public function set bounds($r:Rectangle):void{
_bounds = $r;
updateItemProp("bounds", $r);
}
public function get scaleFromCenter():Boolean{
return (_scaleFromCenter);
}
public function moveSelectionDepthDown():void{
moveSelectionDepth(-1);
}
public function addItems($targetObjects:Array, $scaleMode:String="scaleNormal", $hasSelectableText:Boolean=false):Array{
var a:Array = [];
var i:uint;
while (i < $targetObjects.length) {
a.push(addItem($targetObjects[i], $scaleMode, $hasSelectableText));
i++;
};
return (a);
}
public function set lockRotation($b:Boolean):void{
_lockRotation = $b;
updateItemProp("lockRotation", $b);
calibrateConstraints();
}
public function deselectAll():void{
var oldItems:Array = _selectedItems.slice();
_ignoreEvents = true;
var i:int = (_selectedItems.length - 1);
while (i > -1) {
_selectedItems[i].selected = false;
i--;
};
_ignoreEvents = false;
dispatchEvent(new TransformEvent(TransformEvent.SELECTION_CHANGE, oldItems));
}
public function set lineColor($n:uint):void{
_lineColor = $n;
redrawHandles();
updateSelection();
}
private function onPressStretchH($e:MouseEvent):void{
if (!_selLockScale){
_isTransforming = true;
setScaleOrigin(($e.target as Sprite));
captureScaleTrackingInfo(($e.target as Sprite));
_stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveStretchH, false, 0, true);
_stage.addEventListener(MouseEvent.MOUSE_UP, onReleaseStretchH, false, 0, true);
lockCursor();
onMouseMoveStretchH();
};
}
private function initRotationCursor():void{
var aw:Number;
var sb:Number;
var r:Graphics;
var clr:uint;
var lw:uint;
var i:uint;
if (rotationCursor == null){
aw = 2;
sb = 6;
rotationCursor = new Shape();
r = rotationCursor.graphics;
i = 0;
while (i < 2) {
if (i == 0){
clr = 0xFFFFFF;
lw = 5;
} else {
clr = 0;
lw = 2;
};
r.lineStyle(lw, clr, 1, false, null, "square", "miter", 3);
r.beginFill(clr, 1);
r.moveTo(0, -(sb));
r.lineTo(0, (-(sb) - aw));
r.lineTo(aw, (-(sb) - aw));
r.lineTo(0, -(sb));
r.endFill();
r.beginFill(clr, 1);
r.moveTo(0, sb);
r.lineTo(0, (sb + aw));
r.lineTo(aw, (sb + aw));
r.lineTo(0, sb);
r.endFill();
r.lineStyle(lw, clr, 1, false, null, "none", "miter", 3);
r.moveTo((aw / 2), (-(sb) - (aw / 2)));
r.curveTo((aw * 4.5), 0, (aw / 2), (sb + (aw / 2)));
r.moveTo(0, 0);
i++;
};
_stage.addChild(rotationCursor);
rotationCursor.visible = false;
};
}
public function exportItemXML(targetObject:DisplayObject):XML{
var xml:XML = <item></item>
;
var item:TransformItem = getItem(targetObject);
var m:Matrix = targetObject.transform.matrix;
var bounds:Rectangle = targetObject.getBounds(targetObject);
xml.@name = targetObject.name;
xml.@level = ((targetObject.parent)!=null) ? targetObject.parent.getChildIndex(targetObject) : 0;
xml.@a = m.a;
xml.@b = m.b;
xml.@c = m.c;
xml.@d = m.d;
xml.@tx = m.tx;
xml.@ty = m.ty;
xml.@xOffset = bounds.x;
xml.@yOffset = bounds.y;
xml.@rawWidth = bounds.width;
xml.@rawHeight = bounds.height;
xml.@scaleMode = ((item)!=null) ? item.scaleMode : TransformManager.SCALE_NORMAL;
xml.@hasSelectableText = ((item)!=null) ? uint(item.hasSelectableText) : 0;
xml.@minScaleX = ((item)!=null) ? item.minScaleX : -(Infinity);
xml.@maxScaleX = ((item)!=null) ? item.maxScaleX : Infinity;
xml.@minScaleY = ((item)!=null) ? item.minScaleY : -(Infinity);
xml.@maxScaleY = ((item)!=null) ? item.maxScaleY : Infinity;
return (xml);
}
private function onPressStretchV($e:MouseEvent):void{
if (!_selLockScale){
_isTransforming = true;
setScaleOrigin(($e.target as Sprite));
captureScaleTrackingInfo(($e.target as Sprite));
_stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveStretchV, false, 0, true);
_stage.addEventListener(MouseEvent.MOUSE_UP, onReleaseStretchV, false, 0, true);
lockCursor();
onMouseMoveStretchV();
};
}
public function removeItem($item):void{
var i:int;
var item:TransformItem = findObject($item);
if (item != null){
item.selected = false;
item.removeEventListener(TransformEvent.SELECT, onSelectItem);
item.removeEventListener(TransformEvent.DESELECT, onDeselectItem);
item.removeEventListener(TransformEvent.MOUSE_DOWN, onMouseDownItem);
item.removeEventListener(TransformEvent.SELECT_MOUSE_DOWN, onPressMove);
item.removeEventListener(TransformEvent.SELECT_MOUSE_UP, onReleaseMove);
item.removeEventListener(TransformEvent.UPDATE, onUpdateItem);
item.removeEventListener(TransformEvent.SCALE, onUpdateItem);
item.removeEventListener(TransformEvent.ROTATE, onUpdateItem);
item.removeEventListener(TransformEvent.MOVE, onUpdateItem);
item.removeEventListener(TransformEvent.ROLL_OVER_SELECTED, onRollOverSelectedItem);
item.removeEventListener(TransformEvent.ROLL_OUT_SELECTED, onRollOutSelectedItem);
item.removeEventListener(TransformEvent.DESTROY, onDestroyItem);
i = (_items.length - 1);
while (i > -1) {
if (item == _items[i]){
_items.splice(i, 1);
item.destroy();
break;
};
i--;
};
};
}
protected function unlockCursor():void{
_lockCursor = false;
if (_onUnlock != null){
_onUnlock(_onUnlockParam);
};
}
private function initMoveCursor():void{
var ln:Number;
var s:Graphics;
var clr:uint;
var lw:uint;
var i:uint;
if (moveCursor == null){
ln = 10;
moveCursor = new Shape();
s = moveCursor.graphics;
i = 0;
while (i < 2) {
if (i == 0){
clr = 0xFFFFFF;
lw = 5;
} else {
clr = 0;
lw = 2;
};
s.lineStyle(lw, clr, 1, false, null, "square", "miter", 3);
s.beginFill(clr, 1);
s.moveTo(-(ln), 0);
s.lineTo((2 - ln), -1.5);
s.lineTo((2 - ln), 1.5);
s.lineTo(-(ln), 0);
s.endFill();
s.beginFill(clr, 1);
s.moveTo((2 - ln), 0);
s.lineTo(ln, 0);
s.moveTo(ln, 0);
s.lineTo((ln - 2), -1.5);
s.lineTo((ln - 2), 1.5);
s.lineTo(ln, 0);
s.endFill();
s.beginFill(clr, 1);
s.moveTo(0, -(ln));
s.lineTo(-1.5, (2 - ln));
s.lineTo(1.5, (2 - ln));
s.lineTo(0, -(ln));
s.endFill();
s.beginFill(clr, 1);
s.moveTo(0, (2 - ln));
s.lineTo(0, ln);
s.moveTo(0, ln);
s.lineTo(-1.5, (ln - 2));
s.lineTo(1.5, (ln - 2));
s.lineTo(0, ln);
s.endFill();
i++;
};
_stage.addChild(moveCursor);
moveCursor.visible = false;
};
}
private function snapCursor($e:MouseEvent=null):void{
_currentCursor.x = _currentCursor.stage.mouseX;
_currentCursor.y = _currentCursor.stage.mouseY;
if ($e != null){
$e.updateAfterEvent();
};
}
public function applyFullXML(xml:XML, defaultParent:DisplayObjectContainer, placeholderColor:uint=0xCCCCCC):Array{
var node:XML;
var mc:DisplayObject;
var isMissing:Boolean;
var numChildren:uint;
var i:int;
applySettingsXML(xml.settings[0]);
var parent:DisplayObjectContainer = ((_parent) || (defaultParent));
var missing:Array = [];
var all:Array = [];
var list:XMLList = xml.items[0].item;
for each (node in list) {
isMissing = Boolean((parent.getChildByName(xml.@name) == null));
mc = applyItemXML(node, parent, placeholderColor);
all.push({level:Number(node.@level), mc:mc, node:node});
if (isMissing){
missing.push(mc);
};
};
all.sortOn("level", (Array.NUMERIC | Array.DESCENDING));
numChildren = parent.numChildren;
i = all.length;
while (i--) {
if ((((all[i].level < numChildren)) && ((all[i].mc.parent == parent)))){
parent.setChildIndex(all[i].mc, all[i].level);
};
};
return (missing);
}
private function swapCursorOut($e:Event=null):void{
if (_currentCursor != null){
if (_lockCursor){
_onUnlock = swapCursorOut;
_onUnlockParam = $e;
} else {
_stage.removeEventListener(MouseEvent.MOUSE_MOVE, snapCursor);
if (_cursorManager == this){
Mouse.show();
_currentCursor.visible = false;
_currentCursor = null;
if (!this.mouseIsOverSelection(false)){
dispatchEvent(new TransformEvent(TransformEvent.RELEASE_CURSOR, _selectedItems.slice()));
};
};
};
};
}
public function get items():Array{
return (_items);
}
public function set selectedItems($a:Array):void{
selectItems($a, false);
}
public function set lockScale($b:Boolean):void{
_lockScale = $b;
updateItemProp("lockScale", $b);
calibrateConstraints();
}
protected function initStage($e:Event=null):void{
var i:int;
_parent.removeEventListener(Event.ADDED_TO_STAGE, initStage);
_stage = _parent.stage;
initKeyListeners(_stage);
_stage.addEventListener(MouseEvent.MOUSE_DOWN, checkForDeselect, false, 0, true);
_stage.addEventListener(Event.DEACTIVATE, onReleaseMultiSelectKey, false, 0, true);
initSelection();
initScaleCursor();
initMoveCursor();
initRotationCursor();
_initted = true;
if (_selectedItems.length != 0){
if (_forceSelectionToFront){
i = (_selectedItems.length - 1);
while (i > -1) {
bringToFront(_selectedItems[i].targetObject);
i--;
};
};
calibrateConstraints();
updateSelection();
};
}
public function get lineColor():uint{
return (_lineColor);
}
private function onReleaseMultiSelectKey($e:Event=null):void{
if (((_multiSelectMode) && (_allowMultiSelect))){
_multiSelectMode = false;
};
}
public function set ignoredObjects($a:Array):void{
_ignoredObjects = [];
var i:uint;
while (i < $a.length) {
if (($a[i] is DisplayObject)){
_ignoredObjects.push($a[i]);
} else {
trace((("TRANSFORMMANAGER WARNING: An attempt was made to add " + $a[i]) + " to the ignoredObjects Array but it is NOT a DisplayObject, so it was not added."));
};
i++;
};
}
private function swapCursorIn($cursor:Shape, $handle:Object):void{
var hadCursorControl:Boolean;
var parentRotation:Number;
if (_currentCursor != $cursor){
if (_currentCursor != null){
hadCursorControl = true;
swapCursorOut(null);
};
_currentCursor = $cursor;
_cursorManager = this;
Mouse.hide();
_stage.addChild(_currentCursor);
_stage.addEventListener(MouseEvent.MOUSE_MOVE, snapCursor);
parentRotation = (MatrixTools.getAngle(_parent.transform.concatenatedMatrix) * _RAD2DEG);
if ($handle != null){
_currentCursor.rotation = (($handle.handle.rotation + $handle.cursorRotation) + parentRotation);
};
_currentCursor.visible = true;
bringToFront(_currentCursor);
snapCursor();
if (!hadCursorControl){
dispatchEvent(new TransformEvent(TransformEvent.SEIZE_CURSOR, _selectedItems.slice()));
};
};
}
private function captureScaleTrackingInfo($handle:Sprite):void{
var handlePoint:Point = _parent.globalToLocal($handle.localToGlobal(new Point(0, 0)));
var mdx:Number = (handlePoint.x - _origin.x);
var mdy:Number = (_origin.y - handlePoint.y);
var distanceToMouse:Number = Math.sqrt(((mdx * mdx) + (mdy * mdy)));
var angleToMouse:Number = Math.atan2(mdy, mdx);
var m:Matrix = _dummyBox.transform.matrix;
var angle:Number = MatrixTools.getAngle(m);
var skew:Number = MatrixTools.getSkew(m);
var correctedAngle:Number = (angleToMouse + angle);
var scaleX:Number = (_prevScaleX = MatrixTools.getScaleX(m));
var scaleY:Number = (_prevScaleY = MatrixTools.getScaleY(m));
_trackingInfo = {scaleRatioX:(scaleX / (Math.cos(correctedAngle) * distanceToMouse)), scaleRatioY:(scaleY / (Math.sin(correctedAngle) * distanceToMouse)), scaleRatioXConst:(scaleX / distanceToMouse), scaleRatioYConst:(scaleY / distanceToMouse), angleToMouse:positiveAngle(angleToMouse), angle:angle, skew:skew, mouseX:_parent.mouseX, mouseY:_parent.mouseY, scaleX:scaleX, scaleY:scaleY, mouseOffsetX:(_parent.mouseX - handlePoint.x), mouseOffsetY:(_parent.mouseY - handlePoint.y), handle:$handle, scaled:false};
}
protected function initParent($parent:DisplayObjectContainer):void{
var i:int;
var $parent = $parent;
if (((!(_initted)) && ((_parent == null)))){
_isFlex = Boolean(getDefinitionByName("mx.managers.SystemManager"));
//unresolved jump
var _slot1 = $e;
_isFlex = false;
_parent = $parent;
i = (_items.length - 1);
while (i > -1) {
_items[i].targetObject.removeEventListener(Event.ADDED_TO_STAGE, onTargetAddedToStage);
i = (i - 1);
};
if (_parent.stage == null){
_parent.addEventListener(Event.ADDED_TO_STAGE, initStage, false, 0, true);
} else {
initStage();
};
};
}
public function centerOrigin():void{
setOrigin(getSelectionCenter());
}
private function getSelectionRect():Rectangle{
if (_selectedItems.length == 0){
return (new Rectangle());
};
var i:int = (_selectedItems.length - 1);
var b:Rectangle = _selectedItems[i].targetObject.getBounds(_parent);
while (i--) {
b = b.union(_selectedItems[i].targetObject.getBounds(_parent));
};
return (b);
}
public function isSelected($item):Boolean{
var item:TransformItem = findObject($item);
if (item != null){
return (item.selected);
};
return (false);
}
public function get ignoredObjects():Array{
return (_ignoredObjects.slice());
}
public function get lockRotation():Boolean{
return (_lockRotation);
}
public function get selectedItems():Array{
return (_selectedItems);
}
private function onRollOverMove($e:Event=null):void{
if (!_selLockPosition){
if (_lockCursor){
_onUnlock = onRollOverMove;
_onUnlockParam = $e;
} else {
swapCursorIn(moveCursor, null);
};
};
}
public function set selectionScaleX($n:Number):void{
scaleSelection(($n / this.selectionScaleX), 1);
}
public function set selectionScaleY($n:Number):void{
scaleSelection(1, ($n / this.selectionScaleY));
}
private function onMouseMoveStretchH($e:MouseEvent=null):void{
if (((!(_trackingInfo.scaled)) && (!(($e == null))))){
_trackingInfo.scaled = true;
dispatchInteractiveEvent(TransformEvent.START_INTERACTIVE_SCALE);
};
updateScale(true, false);
if ($e != null){
$e.updateAfterEvent();
};
}
private static function setDefault($value, $default){
if ($value == undefined){
return ($default);
};
return ($value);
}
private static function initKeyListeners($stage:DisplayObjectContainer):void{
if (!($stage in _keyListenerInits)){
_keysDown = {};
$stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPress);
$stage.addEventListener(KeyboardEvent.KEY_UP, onKeyRelease);
$stage.addEventListener(Event.DEACTIVATE, clearKeys);
_keyListenerInits[$stage] = $stage;
};
}
private static function clearKeys($e:Event):void{
_keysDown = {};
}
private static function onKeyPress($e:KeyboardEvent):void{
var kbe:KeyboardEvent;
_keysDown[$e.keyCode] = true;
if (((($e.keyCode == Keyboard.DELETE)) || (($e.keyCode == Keyboard.BACKSPACE)))){
_keyDispatcher.dispatchEvent(new KeyboardEvent("pressDelete"));
} else {
if (((($e.keyCode == Keyboard.SHIFT)) || (($e.keyCode == Keyboard.CONTROL)))){
_keyDispatcher.dispatchEvent(new KeyboardEvent("pressMultiSelectKey"));
} else {
if (((((((($e.keyCode == Keyboard.UP)) || (($e.keyCode == Keyboard.DOWN)))) || (($e.keyCode == Keyboard.LEFT)))) || (($e.keyCode == Keyboard.RIGHT)))){
kbe = new KeyboardEvent("pressArrowKey", true, false, $e.charCode, $e.keyCode, $e.keyLocation, $e.ctrlKey, $e.altKey, $e.shiftKey);
_keyDispatcher.dispatchEvent(kbe);
};
};
};
}
private static function onKeyRelease($e:KeyboardEvent):void{
if (((($e.keyCode == Keyboard.SHIFT)) || (($e.keyCode == Keyboard.CONTROL)))){
_keyDispatcher.dispatchEvent(new KeyboardEvent("releaseMultiSelectKey"));
};
delete _keysDown[$e.keyCode];
}
public static function isKeyDown($keyCode:uint):Boolean{
if (_keysDown == null){
throw (new Error("Key class has yet been initialized."));
};
return (Boolean(($keyCode in _keysDown)));
}
public static function positiveAngle($a:Number):Number{
var revolution:Number = (Math.PI * 2);
return (((($a % revolution) + revolution) % revolution));
}
public static function acuteAngle($a:Number):Number{
if ($a != ($a % Math.PI)){
$a = ($a % (Math.PI * 2));
if ($a < -(Math.PI)){
return ((Math.PI + ($a % Math.PI)));
};
if ($a > Math.PI){
return ((-(Math.PI) + ($a % Math.PI)));
};
};
return ($a);
}
private static function bringToFront($o:DisplayObject):void{
if ($o.parent != null){
$o.parent.setChildIndex($o, ($o.parent.numChildren - 1));
};
}
}
}//package com.greensock.transform
Section 240
//OverwriteManager (com.greensock.OverwriteManager)
package com.greensock {
import com.greensock.core.*;
public class OverwriteManager {
public static const ALL_ONSTART:int = 4;
public static const CONCURRENT:int = 3;
public static const ALL_IMMEDIATE:int = 1;
public static const PREEXISTING:int = 5;
public static const AUTO:int = 2;
public static const version:Number = 6.02;
public static const NONE:int = 0;
public static var enabled:Boolean;
public static var mode:int;
public function OverwriteManager(){
super();
}
public static function getGlobalPaused(tween:TweenCore):Boolean{
while (tween) {
if (tween.cachedPaused){
return (true);
};
tween = tween.timeline;
};
return (false);
}
public static function init(defaultMode:int=2):int{
if (TweenLite.version < 11.1){
throw (new Error("Warning: Your TweenLite class needs to be updated to work with OverwriteManager (or you may need to clear your ASO files). Please download and install the latest version from http://www.tweenlite.com."));
};
TweenLite.overwriteManager = OverwriteManager;
mode = defaultMode;
enabled = true;
return (mode);
}
public static function manageOverwrites(tween:TweenLite, props:Object, targetTweens:Array, mode:uint):Boolean{
var i:int;
var changed:Boolean;
var curTween:TweenLite;
var l:uint;
var combinedTimeScale:Number;
var combinedStartTime:Number;
var cousin:TweenCore;
var cousinStartTime:Number;
var timeline:SimpleTimeline;
if (mode >= 4){
l = targetTweens.length;
i = 0;
while (i < l) {
curTween = targetTweens[i];
if (curTween != tween){
if (curTween.setEnabled(false, false)){
changed = true;
};
} else {
if (mode == 5){
break;
};
};
i++;
};
return (changed);
};
var startTime:Number = (tween.cachedStartTime + 1E-10);
var overlaps:Array = [];
var cousins:Array = [];
var cCount:uint;
var oCount:uint;
i = targetTweens.length;
while (--i > -1) {
curTween = targetTweens[i];
if ((((curTween == tween)) || (curTween.gc))){
} else {
if (curTween.timeline != tween.timeline){
if (!getGlobalPaused(curTween)){
var _temp1 = cCount;
cCount = (cCount + 1);
var _local19 = _temp1;
cousins[_local19] = curTween;
};
} else {
if ((((((curTween.cachedStartTime <= startTime)) && ((((curTween.cachedStartTime + curTween.totalDuration) + 1E-10) > startTime)))) && (!(getGlobalPaused(curTween))))){
var _temp2 = oCount;
oCount = (oCount + 1);
_local19 = _temp2;
overlaps[_local19] = curTween;
};
};
};
};
if (cCount != 0){
combinedTimeScale = tween.cachedTimeScale;
combinedStartTime = startTime;
timeline = tween.timeline;
while (timeline) {
combinedTimeScale = (combinedTimeScale * timeline.cachedTimeScale);
combinedStartTime = (combinedStartTime + timeline.cachedStartTime);
timeline = timeline.timeline;
};
startTime = (combinedTimeScale * combinedStartTime);
i = cCount;
while (--i > -1) {
cousin = cousins[i];
combinedTimeScale = cousin.cachedTimeScale;
combinedStartTime = cousin.cachedStartTime;
timeline = cousin.timeline;
while (timeline) {
combinedTimeScale = (combinedTimeScale * timeline.cachedTimeScale);
combinedStartTime = (combinedStartTime + timeline.cachedStartTime);
timeline = timeline.timeline;
};
cousinStartTime = (combinedTimeScale * combinedStartTime);
if ((((cousinStartTime <= startTime)) && ((((((cousinStartTime + (cousin.totalDuration * combinedTimeScale)) + 1E-10) > startTime)) || ((cousin.cachedDuration == 0)))))){
var _temp3 = oCount;
oCount = (oCount + 1);
_local19 = _temp3;
overlaps[_local19] = cousin;
};
};
};
if (oCount == 0){
return (changed);
};
i = oCount;
if (mode == 2){
while (--i > -1) {
curTween = overlaps[i];
if (curTween.killVars(props)){
changed = true;
};
if ((((curTween.cachedPT1 == null)) && (curTween.initted))){
curTween.setEnabled(false, false);
};
};
} else {
while (--i > -1) {
if (TweenLite(overlaps[i]).setEnabled(false, false)){
changed = true;
};
};
};
return (changed);
}
}
}//package com.greensock
Section 241
//TweenLite (com.greensock.TweenLite)
package com.greensock {
import flash.events.*;
import flash.display.*;
import com.greensock.core.*;
import flash.utils.*;
import com.greensock.plugins.*;
public class TweenLite extends TweenCore {
protected var _hasPlugins:Boolean;
public var propTweenLookup:Object;
public var cachedPT1:PropTween;
protected var _overwrite:uint;
protected var _ease:Function;
public var target:Object;
public var ratio:Number;// = 0
protected var _overwrittenProps:Object;
protected var _notifyPluginsOfEnabled:Boolean;
public static const version:Number = 11.36;
public static var rootTimeline:SimpleTimeline;
public static var fastEaseLookup:Dictionary = new Dictionary(false);
public static var onPluginEvent:Function;
public static var rootFramesTimeline:SimpleTimeline;
public static var defaultEase:Function = TweenLite.easeOut;
public static var plugins:Object = {};
public static var masterList:Dictionary = new Dictionary(false);
public static var overwriteManager:Object;
public static var rootFrame:Number;
public static var killDelayedCallsTo:Function = TweenLite.killTweensOf;
private static var _shape:Shape = new Shape();
protected static var _reservedProps:Object = {ease:1, delay:1, overwrite:1, onComplete:1, onCompleteParams:1, useFrames:1, runBackwards:1, startAt:1, onUpdate:1, onUpdateParams:1, roundProps:1, onStart:1, onStartParams:1, onInit:1, onInitParams:1, onReverseComplete:1, onReverseCompleteParams:1, onRepeat:1, onRepeatParams:1, proxiedEase:1, easeParams:1, yoyo:1, onCompleteListener:1, onUpdateListener:1, onStartListener:1, onReverseCompleteListener:1, onRepeatListener:1, orientToBezier:1, timeScale:1, immediateRender:1, repeat:1, repeatDelay:1, timeline:1, data:1, paused:1};
public function TweenLite(target:Object, duration:Number, vars:Object){
var sibling:TweenLite;
super(duration, vars);
this.target = target;
if ((((this.target is TweenCore)) && (this.vars.timeScale))){
this.cachedTimeScale = 1;
};
propTweenLookup = {};
_ease = defaultEase;
_overwrite = (((!((Number(vars.overwrite) > -1))) || (((!(overwriteManager.enabled)) && ((vars.overwrite > 1)))))) ? overwriteManager.mode : int(vars.overwrite);
var a:Array = masterList[target];
if (!a){
masterList[target] = [this];
} else {
if (_overwrite == 1){
for each (sibling in a) {
if (!sibling.gc){
sibling.setEnabled(false, false);
};
};
masterList[target] = [this];
} else {
a[a.length] = this;
};
};
if (((this.active) || (this.vars.immediateRender))){
renderTime(0, false, true);
};
}
protected function easeProxy(t:Number, b:Number, c:Number, d:Number):Number{
return (this.vars.proxiedEase.apply(null, arguments.concat(this.vars.easeParams)));
}
override public function renderTime(time:Number, suppressEvents:Boolean=false, force:Boolean=false):void{
var isComplete:Boolean;
var prevTime:Number = this.cachedTime;
if (time >= this.cachedDuration){
this.cachedTotalTime = (this.cachedTime = this.cachedDuration);
this.ratio = 1;
isComplete = true;
if (this.cachedDuration == 0){
if ((((((time == 0)) || ((_rawPrevTime < 0)))) && (!((_rawPrevTime == time))))){
force = true;
};
_rawPrevTime = time;
};
} else {
if (time <= 0){
this.cachedTotalTime = (this.cachedTime = (this.ratio = 0));
if (time < 0){
this.active = false;
if (this.cachedDuration == 0){
if (_rawPrevTime > 0){
force = true;
isComplete = true;
};
_rawPrevTime = time;
};
};
if (((this.cachedReversed) && (!((prevTime == 0))))){
isComplete = true;
};
} else {
this.cachedTotalTime = (this.cachedTime = time);
this.ratio = _ease(time, 0, 1, this.cachedDuration);
};
};
if ((((this.cachedTime == prevTime)) && (!(force)))){
return;
};
if (!this.initted){
init();
if (((!(isComplete)) && (this.cachedTime))){
this.ratio = _ease(this.cachedTime, 0, 1, this.cachedDuration);
};
};
if (((!(this.active)) && (!(this.cachedPaused)))){
this.active = true;
};
if ((((((((prevTime == 0)) && (this.vars.onStart))) && (!((this.cachedTime == 0))))) && (!(suppressEvents)))){
this.vars.onStart.apply(null, this.vars.onStartParams);
};
var pt:PropTween = this.cachedPT1;
while (pt) {
pt.target[pt.property] = (pt.start + (this.ratio * pt.change));
pt = pt.nextNode;
};
if (((_hasUpdate) && (!(suppressEvents)))){
this.vars.onUpdate.apply(null, this.vars.onUpdateParams);
};
if (isComplete){
if (((_hasPlugins) && (this.cachedPT1))){
onPluginEvent("onComplete", this);
};
complete(true, suppressEvents);
};
}
override public function setEnabled(enabled:Boolean, ignoreTimeline:Boolean=false):Boolean{
var a:Array;
if (enabled){
a = TweenLite.masterList[this.target];
if (!a){
TweenLite.masterList[this.target] = [this];
} else {
a[a.length] = this;
};
};
super.setEnabled(enabled, ignoreTimeline);
if (((_notifyPluginsOfEnabled) && (this.cachedPT1))){
return (onPluginEvent((enabled) ? "onEnable" : "onDisable", this));
};
return (false);
}
protected function init():void{
var p:String;
var i:int;
var plugin:*;
var prioritize:Boolean;
var siblings:Array;
var pt:PropTween;
if (this.vars.onInit){
this.vars.onInit.apply(null, this.vars.onInitParams);
};
if (typeof(this.vars.ease) == "function"){
_ease = this.vars.ease;
};
if (this.vars.easeParams){
this.vars.proxiedEase = _ease;
_ease = easeProxy;
};
this.cachedPT1 = null;
this.propTweenLookup = {};
for (p in this.vars) {
if ((((p in _reservedProps)) && (!((((p == "timeScale")) && ((this.target is TweenCore))))))){
} else {
if ((((p in plugins)) && (new ((plugins[p] as Class)).onInitTween(this.target, this.vars[p], this)))){
this.cachedPT1 = new PropTween(plugin, "changeFactor", 0, 1, ((plugin.overwriteProps.length)==1) ? plugin.overwriteProps[0] : "_MULTIPLE_", true, this.cachedPT1);
if (this.cachedPT1.name == "_MULTIPLE_"){
i = plugin.overwriteProps.length;
while (--i > -1) {
this.propTweenLookup[plugin.overwriteProps[i]] = this.cachedPT1;
};
} else {
this.propTweenLookup[this.cachedPT1.name] = this.cachedPT1;
};
if (plugin.priority){
this.cachedPT1.priority = plugin.priority;
prioritize = true;
};
if (((plugin.onDisable) || (plugin.onEnable))){
_notifyPluginsOfEnabled = true;
};
_hasPlugins = true;
} else {
this.cachedPT1 = new PropTween(this.target, p, Number(this.target[p]), ((typeof(this.vars[p]))=="number") ? (Number(this.vars[p]) - this.target[p]) : Number(this.vars[p]), p, false, this.cachedPT1);
this.propTweenLookup[p] = this.cachedPT1;
};
};
};
if (prioritize){
onPluginEvent("onInit", this);
};
if (this.vars.runBackwards){
pt = this.cachedPT1;
while (pt) {
pt.start = (pt.start + pt.change);
pt.change = -(pt.change);
pt = pt.nextNode;
};
};
_hasUpdate = Boolean(!((this.vars.onUpdate == null)));
if (_overwrittenProps){
killVars(_overwrittenProps);
if (this.cachedPT1 == null){
this.setEnabled(false, false);
};
};
if ((((((((_overwrite > 1)) && (this.cachedPT1))) && (masterList[this.target]))) && ((siblings.length > 1)))){
if (overwriteManager.manageOverwrites(this, this.propTweenLookup, siblings, _overwrite)){
init();
};
};
this.initted = true;
}
public function killVars(vars:Object, permanent:Boolean=true):Boolean{
var p:String;
var pt:PropTween;
var changed:Boolean;
if (_overwrittenProps == null){
_overwrittenProps = {};
};
for (p in vars) {
if ((p in propTweenLookup)){
pt = propTweenLookup[p];
if (((pt.isPlugin) && ((pt.name == "_MULTIPLE_")))){
pt.target.killProps(vars);
if (pt.target.overwriteProps.length == 0){
pt.name = "";
};
};
if (pt.name != "_MULTIPLE_"){
if (pt.nextNode){
pt.nextNode.prevNode = pt.prevNode;
};
if (pt.prevNode){
pt.prevNode.nextNode = pt.nextNode;
} else {
if (this.cachedPT1 == pt){
this.cachedPT1 = pt.nextNode;
};
};
if (((pt.isPlugin) && (pt.target.onDisable))){
pt.target.onDisable();
if (pt.target.activeDisable){
changed = true;
};
};
delete propTweenLookup[p];
};
};
if (((permanent) && (!((vars == _overwrittenProps))))){
_overwrittenProps[p] = 1;
};
};
return (changed);
}
override public function invalidate():void{
if (((_notifyPluginsOfEnabled) && (this.cachedPT1))){
onPluginEvent("onDisable", this);
};
this.cachedPT1 = null;
_overwrittenProps = null;
_hasUpdate = (this.initted = (this.active = (_notifyPluginsOfEnabled = false)));
this.propTweenLookup = {};
}
public static function initClass():void{
rootFrame = 0;
rootTimeline = new SimpleTimeline(null);
rootFramesTimeline = new SimpleTimeline(null);
rootTimeline.cachedStartTime = (getTimer() * 0.001);
rootFramesTimeline.cachedStartTime = rootFrame;
rootTimeline.autoRemoveChildren = true;
rootFramesTimeline.autoRemoveChildren = true;
_shape.addEventListener(Event.ENTER_FRAME, updateAll, false, 0, true);
if (overwriteManager == null){
overwriteManager = {mode:1, enabled:false};
};
}
public static function killTweensOf(target:Object, complete:Boolean=false, vars:Object=null):void{
var a:Array;
var i:int;
var tween:TweenLite;
if ((target in masterList)){
a = masterList[target];
i = a.length;
while (--i > -1) {
tween = a[i];
if (!tween.gc){
if (complete){
tween.complete(false, false);
};
if (vars != null){
tween.killVars(vars);
};
if ((((vars == null)) || ((((tween.cachedPT1 == null)) && (tween.initted))))){
tween.setEnabled(false, false);
};
};
};
if (vars == null){
delete masterList[target];
};
};
}
public static function from(target:Object, duration:Number, vars:Object):TweenLite{
vars.runBackwards = true;
if (!("immediateRender" in vars)){
vars.immediateRender = true;
};
return (new TweenLite(target, duration, vars));
}
protected static function easeOut(t:Number, b:Number, c:Number, d:Number):Number{
t = (1 - (t / d));
return ((1 - (t * t)));
}
public static function delayedCall(delay:Number, onComplete:Function, onCompleteParams:Array=null, useFrames:Boolean=false):TweenLite{
return (new TweenLite(onComplete, 0, {delay:delay, onComplete:onComplete, onCompleteParams:onCompleteParams, immediateRender:false, useFrames:useFrames, overwrite:0}));
}
protected static function updateAll(e:Event=null):void{
var ml:Dictionary;
var tgt:Object;
var a:Array;
var i:int;
rootTimeline.renderTime((((getTimer() * 0.001) - rootTimeline.cachedStartTime) * rootTimeline.cachedTimeScale), false, false);
rootFrame++;
rootFramesTimeline.renderTime(((rootFrame - rootFramesTimeline.cachedStartTime) * rootFramesTimeline.cachedTimeScale), false, false);
if (!(rootFrame % 60)){
ml = masterList;
for (tgt in ml) {
a = ml[tgt];
i = a.length;
while (--i > -1) {
if (TweenLite(a[i]).gc){
a.splice(i, 1);
};
};
if (a.length == 0){
delete ml[tgt];
};
};
};
}
public static function to(target:Object, duration:Number, vars:Object):TweenLite{
return (new TweenLite(target, duration, vars));
}
}
}//package com.greensock
Section 242
//TweenMax (com.greensock.TweenMax)
package com.greensock {
import flash.events.*;
import flash.display.*;
import com.greensock.events.*;
import com.greensock.core.*;
import flash.utils.*;
import com.greensock.plugins.*;
public class TweenMax extends TweenLite implements IEventDispatcher {
protected var _cyclesComplete:uint;// = 0
protected var _dispatcher:EventDispatcher;
protected var _hasUpdateListener:Boolean;
protected var _easeType:uint;
protected var _repeatDelay:Number;// = 0
public var yoyo:Boolean;
protected var _easePower:uint;
protected var _repeat:int;// = 0
public static const version:Number = 11.37;
private static var _overwriteMode:int = (OverwriteManager.enabled) ? OverwriteManager.mode : OverwriteManager.init(2);
;
public static var killTweensOf:Function = TweenLite.killTweensOf;
public static var killDelayedCallsTo:Function = TweenLite.killTweensOf;
public function TweenMax(target:Object, duration:Number, vars:Object){
super(target, duration, vars);
if (TweenLite.version < 11.2){
throw (new Error("TweenMax error! Please update your TweenLite class or try deleting your ASO files. TweenMax requires a more recent version. Download updates at http://www.TweenMax.com."));
};
this.yoyo = Boolean(this.vars.yoyo);
_repeat = (this.vars.repeat) ? int(this.vars.repeat) : 0;
_repeatDelay = (this.vars.repeatDelay) ? Number(this.vars.repeatDelay) : 0;
this.cacheIsDirty = true;
if (((((((((((this.vars.onCompleteListener) || (this.vars.onInitListener))) || (this.vars.onUpdateListener))) || (this.vars.onStartListener))) || (this.vars.onRepeatListener))) || (this.vars.onReverseCompleteListener))){
initDispatcher();
if ((((duration == 0)) && ((_delay == 0)))){
_dispatcher.dispatchEvent(new TweenEvent(TweenEvent.UPDATE));
_dispatcher.dispatchEvent(new TweenEvent(TweenEvent.COMPLETE));
};
};
if (((this.vars.timeScale) && (!((this.target is TweenCore))))){
this.cachedTimeScale = this.vars.timeScale;
};
}
public function dispatchEvent(e:Event):Boolean{
return (((_dispatcher)==null) ? false : _dispatcher.dispatchEvent(e));
}
public function set timeScale(n:Number):void{
if (n == 0){
n = 0.0001;
};
var tlTime:Number = (((_pauseTime) || ((_pauseTime == 0)))) ? _pauseTime : this.timeline.cachedTotalTime;
this.cachedStartTime = (tlTime - (((tlTime - this.cachedStartTime) * this.cachedTimeScale) / n));
this.cachedTimeScale = n;
setDirtyCache(false);
}
override public function renderTime(time:Number, suppressEvents:Boolean=false, force:Boolean=false):void{
var isComplete:Boolean;
var repeated:Boolean;
var setRatio:Boolean;
var cycleDuration:Number;
var prevCycles:int;
var power:int;
var val:Number;
var totalDur:Number = (this.cacheIsDirty) ? this.totalDuration : this.cachedTotalDuration;
var prevTime:Number = this.cachedTime;
if (time >= totalDur){
this.cachedTotalTime = totalDur;
this.cachedTime = this.cachedDuration;
this.ratio = 1;
isComplete = true;
if (this.cachedDuration == 0){
if ((((((time == 0)) || ((_rawPrevTime < 0)))) && (!((_rawPrevTime == time))))){
force = true;
};
_rawPrevTime = time;
};
} else {
if (time <= 0){
if (time < 0){
this.active = false;
if (this.cachedDuration == 0){
if (_rawPrevTime > 0){
force = true;
isComplete = true;
};
_rawPrevTime = time;
};
};
this.cachedTotalTime = (this.cachedTime = (this.ratio = 0));
if (((this.cachedReversed) && (!((prevTime == 0))))){
isComplete = true;
};
} else {
this.cachedTotalTime = (this.cachedTime = time);
setRatio = true;
};
};
if (_repeat != 0){
cycleDuration = (this.cachedDuration + _repeatDelay);
if (isComplete){
if (((this.yoyo) && ((_repeat % 2)))){
this.cachedTime = (this.ratio = 0);
};
} else {
if (time > 0){
prevCycles = _cyclesComplete;
_cyclesComplete = int((this.cachedTotalTime / cycleDuration));
if (_cyclesComplete == (this.cachedTotalTime / cycleDuration)){
_cyclesComplete--;
};
if (prevCycles != _cyclesComplete){
repeated = true;
};
this.cachedTime = (((this.cachedTotalTime / cycleDuration) - _cyclesComplete) * cycleDuration);
if (((this.yoyo) && ((_cyclesComplete % 2)))){
this.cachedTime = (this.cachedDuration - this.cachedTime);
} else {
if (this.cachedTime >= this.cachedDuration){
this.cachedTime = this.cachedDuration;
this.ratio = 1;
setRatio = false;
};
};
if (this.cachedTime <= 0){
this.cachedTime = (this.ratio = 0);
setRatio = false;
};
};
};
};
if ((((prevTime == this.cachedTime)) && (!(force)))){
return;
};
if (!this.initted){
init();
};
if (((!(this.active)) && (!(this.cachedPaused)))){
this.active = true;
};
if (setRatio){
if (_easeType){
power = _easePower;
val = (this.cachedTime / this.cachedDuration);
if (_easeType == 2){
val = (1 - val);
this.ratio = val;
while (--power > -1) {
this.ratio = (val * this.ratio);
};
this.ratio = (1 - this.ratio);
} else {
if (_easeType == 1){
this.ratio = val;
while (--power > -1) {
this.ratio = (val * this.ratio);
};
} else {
if (val < 0.5){
val = (val * 2);
this.ratio = val;
while (--power > -1) {
this.ratio = (val * this.ratio);
};
this.ratio = (this.ratio * 0.5);
} else {
val = ((1 - val) * 2);
this.ratio = val;
while (--power > -1) {
this.ratio = (val * this.ratio);
};
this.ratio = (1 - (0.5 * this.ratio));
};
};
};
} else {
this.ratio = _ease(this.cachedTime, 0, 1, this.cachedDuration);
};
};
if ((((((prevTime == 0)) && (!((this.cachedTotalTime == 0))))) && (!(suppressEvents)))){
if (this.vars.onStart){
this.vars.onStart.apply(null, this.vars.onStartParams);
};
if (_dispatcher){
_dispatcher.dispatchEvent(new TweenEvent(TweenEvent.START));
};
};
var pt:PropTween = this.cachedPT1;
while (pt) {
pt.target[pt.property] = (pt.start + (this.ratio * pt.change));
pt = pt.nextNode;
};
if (((_hasUpdate) && (!(suppressEvents)))){
this.vars.onUpdate.apply(null, this.vars.onUpdateParams);
};
if (((_hasUpdateListener) && (!(suppressEvents)))){
_dispatcher.dispatchEvent(new TweenEvent(TweenEvent.UPDATE));
};
if (isComplete){
if (((_hasPlugins) && (this.cachedPT1))){
onPluginEvent("onComplete", this);
};
complete(true, suppressEvents);
} else {
if (((repeated) && (!(suppressEvents)))){
if (this.vars.onRepeat){
this.vars.onRepeat.apply(null, this.vars.onRepeatParams);
};
if (_dispatcher){
_dispatcher.dispatchEvent(new TweenEvent(TweenEvent.REPEAT));
};
};
};
}
override public function set totalDuration(n:Number):void{
if (_repeat == -1){
return;
};
this.duration = ((n - (_repeat * _repeatDelay)) / (_repeat + 1));
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{
if (_dispatcher == null){
initDispatcher();
};
if (type == TweenEvent.UPDATE){
_hasUpdateListener = true;
};
_dispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
}
protected function insertPropTween(target:Object, property:String, start:Number, end, name:String, isPlugin:Boolean, nextNode:PropTween):PropTween{
var op:Array;
var i:int;
var pt:PropTween = new PropTween(target, property, start, ((typeof(end))=="number") ? (end - start) : Number(end), name, isPlugin, nextNode);
if (((isPlugin) && ((name == "_MULTIPLE_")))){
op = target.overwriteProps;
i = op.length;
while (--i > -1) {
this.propTweenLookup[op[i]] = pt;
};
} else {
this.propTweenLookup[name] = pt;
};
return (pt);
}
override protected function init():void{
var startTween:TweenMax;
var prop:String;
var multiProps:String;
var rp:Array;
var plugin:Object;
var ptPlugin:PropTween;
var pt:PropTween;
var i:int;
if (this.vars.startAt){
this.vars.startAt.overwrite = 0;
this.vars.startAt.immediateRender = true;
startTween = new TweenMax(this.target, 0, this.vars.startAt);
};
if (_dispatcher){
_dispatcher.dispatchEvent(new TweenEvent(TweenEvent.INIT));
};
super.init();
if ((_ease in fastEaseLookup)){
_easeType = fastEaseLookup[_ease][0];
_easePower = fastEaseLookup[_ease][1];
};
if (((!((this.vars.roundProps == null))) && (("roundProps" in TweenLite.plugins)))){
rp = this.vars.roundProps;
i = rp.length;
while (--i > -1) {
prop = rp[i];
pt = this.cachedPT1;
while (pt) {
if (pt.name == prop){
if (pt.isPlugin){
pt.target.round = true;
} else {
if (plugin == null){
plugin = new TweenLite.plugins.roundProps();
plugin.add(pt.target, prop, pt.start, pt.change);
_hasPlugins = true;
ptPlugin = insertPropTween(plugin, "changeFactor", 0, 1, "_MULTIPLE_", true, this.cachedPT1);
this.cachedPT1 = ptPlugin;
} else {
plugin.add(pt.target, prop, pt.start, pt.change);
};
this.removePropTween(pt);
this.propTweenLookup[prop] = ptPlugin;
};
} else {
if (((((pt.isPlugin) && ((pt.name == "_MULTIPLE_")))) && (!(pt.target.round)))){
multiProps = ((" " + pt.target.overwriteProps.join(" ")) + " ");
if (multiProps.indexOf(((" " + prop) + " ")) != -1){
pt.target.round = true;
};
};
};
pt = pt.nextNode;
};
};
};
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void{
if (_dispatcher){
_dispatcher.removeEventListener(type, listener, useCapture);
};
}
public function setDestination(property:String, value, adjustStartValues:Boolean=true):void{
var vars:Object = {};
vars[property] = value;
updateTo(vars, !(adjustStartValues));
}
public function willTrigger(type:String):Boolean{
return (((_dispatcher)==null) ? false : _dispatcher.willTrigger(type));
}
public function hasEventListener(type:String):Boolean{
return (((_dispatcher)==null) ? false : _dispatcher.hasEventListener(type));
}
protected function initDispatcher():void{
if (_dispatcher == null){
_dispatcher = new EventDispatcher(this);
};
if ((this.vars.onInitListener is Function)){
_dispatcher.addEventListener(TweenEvent.INIT, this.vars.onInitListener, false, 0, true);
};
if ((this.vars.onStartListener is Function)){
_dispatcher.addEventListener(TweenEvent.START, this.vars.onStartListener, false, 0, true);
};
if ((this.vars.onUpdateListener is Function)){
_dispatcher.addEventListener(TweenEvent.UPDATE, this.vars.onUpdateListener, false, 0, true);
_hasUpdateListener = true;
};
if ((this.vars.onCompleteListener is Function)){
_dispatcher.addEventListener(TweenEvent.COMPLETE, this.vars.onCompleteListener, false, 0, true);
};
if ((this.vars.onRepeatListener is Function)){
_dispatcher.addEventListener(TweenEvent.REPEAT, this.vars.onRepeatListener, false, 0, true);
};
if ((this.vars.onReverseCompleteListener is Function)){
_dispatcher.addEventListener(TweenEvent.REVERSE_COMPLETE, this.vars.onReverseCompleteListener, false, 0, true);
};
}
public function set currentProgress(n:Number):void{
if (_cyclesComplete == 0){
setTotalTime((this.duration * n), false);
} else {
setTotalTime(((this.duration * n) + (_cyclesComplete * this.cachedDuration)), false);
};
}
public function get totalProgress():Number{
return ((this.cachedTotalTime / this.totalDuration));
}
public function set totalProgress(n:Number):void{
setTotalTime((this.totalDuration * n), false);
}
protected function removePropTween(propTween:PropTween):Boolean{
if (propTween.nextNode){
propTween.nextNode.prevNode = propTween.prevNode;
};
if (propTween.prevNode){
propTween.prevNode.nextNode = propTween.nextNode;
} else {
if (this.cachedPT1 == propTween){
this.cachedPT1 = propTween.nextNode;
};
};
if (((propTween.isPlugin) && (propTween.target.onDisable))){
propTween.target.onDisable();
if (propTween.target.activeDisable){
return (true);
};
};
return (false);
}
public function get currentProgress():Number{
return ((this.cachedTime / this.duration));
}
public function get repeat():int{
return (_repeat);
}
public function updateTo(vars:Object, resetDuration:Boolean=false):void{
var p:String;
var inv:Number;
var pt:PropTween;
var endValue:Number;
var curRatio:Number = this.ratio;
if (((((resetDuration) && (!((this.timeline == null))))) && ((this.cachedStartTime < this.timeline.cachedTime)))){
this.cachedStartTime = this.timeline.cachedTime;
this.setDirtyCache(false);
if (this.gc){
this.setEnabled(true, false);
} else {
this.timeline.addChild(this);
};
};
for (p in vars) {
this.vars[p] = vars[p];
};
if (this.initted){
this.initted = false;
if (!resetDuration){
init();
if (((((!(resetDuration)) && ((this.cachedTime > 0)))) && ((this.cachedTime < this.cachedDuration)))){
inv = (1 / (1 - curRatio));
pt = this.cachedPT1;
while (pt) {
endValue = (pt.start + pt.change);
pt.change = (pt.change * inv);
pt.start = (endValue - pt.change);
pt = pt.nextNode;
};
};
};
};
}
override public function set currentTime(n:Number):void{
if (_cyclesComplete == 0){
} else {
if (((this.yoyo) && (((_cyclesComplete % 2) == 1)))){
n = ((this.duration - n) + (_cyclesComplete * (this.cachedDuration + _repeatDelay)));
} else {
n = (n + (_cyclesComplete * (this.duration + _repeatDelay)));
};
};
setTotalTime(n, false);
}
public function get repeatDelay():Number{
return (_repeatDelay);
}
public function killProperties(names:Array):void{
var v:Object = {};
var i:int = names.length;
while (--i > -1) {
v[names[i]] = true;
};
killVars(v);
}
public function set repeatDelay(n:Number):void{
_repeatDelay = n;
setDirtyCache(true);
}
public function set repeat(n:int):void{
_repeat = n;
setDirtyCache(true);
}
override public function complete(skipRender:Boolean=false, suppressEvents:Boolean=false):void{
super.complete(skipRender, suppressEvents);
if (((!(suppressEvents)) && (_dispatcher))){
if ((((this.cachedTotalTime == this.cachedTotalDuration)) && (!(this.cachedReversed)))){
_dispatcher.dispatchEvent(new TweenEvent(TweenEvent.COMPLETE));
} else {
if (((this.cachedReversed) && ((this.cachedTotalTime == 0)))){
_dispatcher.dispatchEvent(new TweenEvent(TweenEvent.REVERSE_COMPLETE));
};
};
};
}
override public function invalidate():void{
this.yoyo = Boolean((this.vars.yoyo == true));
_repeat = (this.vars.repeat) ? Number(this.vars.repeat) : 0;
_repeatDelay = (this.vars.repeatDelay) ? Number(this.vars.repeatDelay) : 0;
_hasUpdateListener = false;
if (((((!((this.vars.onCompleteListener == null))) || (!((this.vars.onUpdateListener == null))))) || (!((this.vars.onStartListener == null))))){
initDispatcher();
};
setDirtyCache(true);
super.invalidate();
}
public function get timeScale():Number{
return (this.cachedTimeScale);
}
override public function get totalDuration():Number{
if (this.cacheIsDirty){
this.cachedTotalDuration = ((_repeat)==-1) ? 999999999999 : ((this.cachedDuration * (_repeat + 1)) + (_repeatDelay * _repeat));
this.cacheIsDirty = false;
};
return (this.cachedTotalDuration);
}
public static function set globalTimeScale(n:Number):void{
if (n == 0){
n = 0.0001;
};
if (TweenLite.rootTimeline == null){
TweenLite.to({}, 0, {});
};
var tl:SimpleTimeline = TweenLite.rootTimeline;
var curTime:Number = (getTimer() * 0.001);
tl.cachedStartTime = (curTime - (((curTime - tl.cachedStartTime) * tl.cachedTimeScale) / n));
tl = TweenLite.rootFramesTimeline;
curTime = TweenLite.rootFrame;
tl.cachedStartTime = (curTime - (((curTime - tl.cachedStartTime) * tl.cachedTimeScale) / n));
TweenLite.rootFramesTimeline.cachedTimeScale = (TweenLite.rootTimeline.cachedTimeScale = n);
}
public static function fromTo(target:Object, duration:Number, fromVars:Object, toVars:Object):TweenMax{
toVars.startAt = fromVars;
if (fromVars.immediateRender){
toVars.immediateRender = true;
};
return (new TweenMax(target, duration, toVars));
}
public static function allFromTo(targets:Array, duration:Number, fromVars:Object, toVars:Object, stagger:Number=0, onCompleteAll:Function=null, onCompleteAllParams:Array=null):Array{
toVars.startAt = fromVars;
if (fromVars.immediateRender){
toVars.immediateRender = true;
};
return (allTo(targets, duration, toVars, stagger, onCompleteAll, onCompleteAllParams));
}
public static function pauseAll(tweens:Boolean=true, delayedCalls:Boolean=true):void{
changePause(true, tweens, delayedCalls);
}
public static function getTweensOf(target:Object):Array{
var i:int;
var cnt:uint;
var a:Array = masterList[target];
var toReturn:Array = [];
if (a){
i = a.length;
cnt = 0;
while (--i > -1) {
if (!a[i].gc){
var _temp1 = cnt;
cnt = (cnt + 1);
var _local6 = _temp1;
toReturn[_local6] = a[i];
};
};
};
return (toReturn);
}
public static function get globalTimeScale():Number{
return (((TweenLite.rootTimeline)==null) ? 1 : TweenLite.rootTimeline.cachedTimeScale);
}
public static function killChildTweensOf(parent:DisplayObjectContainer, complete:Boolean=false):void{
var curTarget:Object;
var curParent:DisplayObjectContainer;
var a:Array = getAllTweens();
var i:int = a.length;
while (--i > -1) {
curTarget = a[i].target;
if ((curTarget is DisplayObject)){
curParent = curTarget.parent;
while (curParent) {
if (curParent == parent){
if (complete){
a[i].complete(false);
} else {
a[i].setEnabled(false, false);
};
};
curParent = curParent.parent;
};
};
};
}
public static function delayedCall(delay:Number, onComplete:Function, onCompleteParams:Array=null, useFrames:Boolean=false):TweenMax{
return (new TweenMax(onComplete, 0, {delay:delay, onComplete:onComplete, onCompleteParams:onCompleteParams, immediateRender:false, useFrames:useFrames, overwrite:0}));
}
public static function isTweening(target:Object):Boolean{
var tween:TweenLite;
var a:Array = getTweensOf(target);
var i:int = a.length;
while (--i > -1) {
tween = a[i];
if (((tween.active) || ((((tween.cachedStartTime == tween.timeline.cachedTime)) && (tween.timeline.active))))){
return (true);
};
};
return (false);
}
public static function killAll(complete:Boolean=false, tweens:Boolean=true, delayedCalls:Boolean=true):void{
var isDC:Boolean;
var a:Array = getAllTweens();
var i:int = a.length;
while (--i > -1) {
isDC = (a[i].target == a[i].vars.onComplete);
if ((((isDC == delayedCalls)) || (!((isDC == tweens))))){
if (complete){
a[i].complete(false);
} else {
a[i].setEnabled(false, false);
};
};
};
}
private static function changePause(pause:Boolean, tweens:Boolean=true, delayedCalls:Boolean=false):void{
var isDC:Boolean;
var a:Array = getAllTweens();
var i:int = a.length;
while (--i > -1) {
isDC = (TweenLite(a[i]).target == TweenLite(a[i]).vars.onComplete);
if ((((isDC == delayedCalls)) || (!((isDC == tweens))))){
TweenCore(a[i]).paused = pause;
};
};
}
public static function from(target:Object, duration:Number, vars:Object):TweenMax{
vars.runBackwards = true;
if (!("immediateRender" in vars)){
vars.immediateRender = true;
};
return (new TweenMax(target, duration, vars));
}
public static function allFrom(targets:Array, duration:Number, vars:Object, stagger:Number=0, onCompleteAll:Function=null, onCompleteAllParams:Array=null):Array{
vars.runBackwards = true;
if (!("immediateRender" in vars)){
vars.immediateRender = true;
};
return (allTo(targets, duration, vars, stagger, onCompleteAll, onCompleteAllParams));
}
public static function getAllTweens():Array{
var a:Array;
var i:int;
var ml:Dictionary = masterList;
var cnt:uint;
var toReturn:Array = [];
for each (a in ml) {
i = a.length;
while (--i > -1) {
if (!TweenLite(a[i]).gc){
var _temp1 = cnt;
cnt = (cnt + 1);
var _local8 = _temp1;
toReturn[_local8] = a[i];
};
};
};
return (toReturn);
}
public static function resumeAll(tweens:Boolean=true, delayedCalls:Boolean=true):void{
changePause(false, tweens, delayedCalls);
}
public static function to(target:Object, duration:Number, vars:Object):TweenMax{
return (new TweenMax(target, duration, vars));
}
public static function allTo(targets:Array, duration:Number, vars:Object, stagger:Number=0, onCompleteAll:Function=null, onCompleteAllParams:Array=null):Array{
var i:int;
var varsDup:Object;
var p:String;
var onCompleteProxy:Function;
var onCompleteParamsProxy:Array;
var targets = targets;
var duration = duration;
var vars = vars;
var stagger = stagger;
var onCompleteAll = onCompleteAll;
var onCompleteAllParams = onCompleteAllParams;
var l:uint = targets.length;
var a:Array = [];
var curDelay:Number = (("delay" in vars)) ? Number(vars.delay) : 0;
onCompleteProxy = vars.onComplete;
onCompleteParamsProxy = vars.onCompleteParams;
var lastIndex:int = ((stagger)<=0) ? 0 : (l - 1);
i = 0;
while (i < l) {
varsDup = {};
for (p in vars) {
varsDup[p] = vars[p];
};
varsDup.delay = curDelay;
if ((((i == lastIndex)) && (!((onCompleteAll == null))))){
varsDup.onComplete = function ():void{
if (onCompleteProxy != null){
onCompleteProxy.apply(null, onCompleteParamsProxy);
};
onCompleteAll.apply(null, onCompleteAllParams);
};
};
a[a.length] = new TweenMax(targets[i], duration, varsDup);
curDelay = (curDelay + stagger);
i = (i + 1);
};
return (a);
}
TweenPlugin.activate([AutoAlphaPlugin, EndArrayPlugin, FramePlugin, RemoveTintPlugin, TintPlugin, VisiblePlugin, VolumePlugin, BevelFilterPlugin, BezierPlugin, BezierThroughPlugin, BlurFilterPlugin, ColorMatrixFilterPlugin, ColorTransformPlugin, DropShadowFilterPlugin, FrameLabelPlugin, GlowFilterPlugin, HexColorsPlugin, RoundPropsPlugin, ShortRotationPlugin, {}]);
}
}//package com.greensock
Section 243
//GameTracking (com.soapcreative.net.tracking.GameTracking)
package com.soapcreative.net.tracking {
import flash.utils.*;
import flash.errors.*;
public class GameTracking {
public static const VERSION:String = "1.0.1";
private static var _started:Boolean;
private static var _level:int;
private static var _initialized:Boolean = false;
private static var _failed:Boolean;
private static var _time:int;
private static var _playing:Boolean;
public function GameTracking(){
super();
throw (new ArgumentError("GameTracking should be implemented as a static class"));
}
public static function get started():Boolean{
return (_started);
}
public static function trackLanguage(language:String="en"):void{
GoogleTracking.pageView("locale", language);
}
private static function getLevelString(level:int):String{
return (("level" + ((level < 10)) ? ("0" + level) : level));
}
public static function trackIndex():void{
if (GoogleTracking.api == null){
throw (new IllegalOperationError("GoogleTracking must be initialized before using GameTracking"));
};
GoogleTracking.pageView("index");
GoogleTracking.trackEvent("game", "index");
_level = 0;
_initialized = true;
_started = (_playing = false);
recordTime();
}
private static function trackLevelBegin(level:int, type:String):void{
GoogleTracking.pageView(getLevelString(level), type);
GoogleTracking.trackEvent(getLevelString(level), type);
}
public static function startLevel(level:int, isReplay:Boolean=false):void{
checkCondition(_started, "startGame must be called prior to startLevel");
_level = level;
if (isReplay == true){
if ((((_playing == true)) && ((_failed == true)))){
trackLevelBegin(_level, "replay");
};
} else {
trackLevelBegin(_level, "start");
};
recordTime();
_failed = false;
_playing = true;
}
public static function get level():int{
return (_level);
}
public static function trackScore(score:int):void{
trackMiscellaneous("score", score);
}
public static function trackSubmitScore(score:int):void{
GoogleTracking.trackEvent("game", "score", score);
}
public static function levelFail():void{
checkCondition(_playing, "startLevel must be called prior to levelFail");
_failed = true;
trackLevelEnd(_level, "fail");
}
public static function clearTime():void{
_time = 0;
}
public static function getElapsedSeconds():Number{
var elapsed:Number = (getElapsedTime() / 1000);
return (Number(elapsed.toFixed(2)));
}
public static function levelComplete():void{
checkCondition(_playing, "startLevel must be called prior to levelComplete");
_failed = false;
trackLevelEnd(_level, "complete");
}
public static function getElapsedTime():int{
return ((getTimer() - _time));
}
public static function trackMiscellaneous(name:String, value:Number=NaN):void{
GoogleTracking.trackEvent("misc", name, value);
}
public static function trackAchievement(achievement:String):void{
GoogleTracking.trackEvent("achievement", achievement);
}
public static function trackLink(name:String="clientSite"):void{
GoogleTracking.trackEvent("linkOut", name);
}
private static function trackLevelEnd(level:int, type:String):void{
GoogleTracking.trackEvent(getLevelString(level), type, getElapsedSeconds());
clearTime();
}
public static function get playing():Boolean{
return (_playing);
}
public static function levelQuit():void{
checkCondition(_playing, "startLevel must be called prior to levelQuit");
_playing = false;
trackLevelEnd(_level, "quit");
}
public static function startGame():void{
checkCondition(_initialized, "trackIndex must be called prior to startGame");
if (_started == false){
GoogleTracking.pageView("start");
GoogleTracking.trackEvent("game", "start");
} else {
GoogleTracking.trackEvent("game", "restart");
};
_started = true;
_failed = (_playing = false);
}
public static function trackLoaded():void{
GoogleTracking.trackEvent("game", "load", int(getElapsedSeconds()));
GoogleTracking.pageView("main");
clearTime();
}
private static function checkCondition(comparison:Boolean, error:String):void{
if (comparison == false){
throw (new IllegalOperationError(error));
};
}
public static function trackPage(page:String):void{
GoogleTracking.trackEvent("menu", page);
}
public static function get failed():Boolean{
return (_failed);
}
public static function recordTime():void{
_time = getTimer();
}
}
}//package com.soapcreative.net.tracking
Section 244
//GoogleTracking (com.soapcreative.net.tracking.GoogleTracking)
package com.soapcreative.net.tracking {
import com.google.analytics.*;
import flash.display.*;
import flash.errors.*;
public class GoogleTracking {
public static const AS3_MODE:String = "AS3";
public static const VERSION:String = "1.0.0";
public static const BRIDGE_MODE:String = "Bridge";
public static var track:Boolean;
private static var _project:String;
private static var _api:GATracker;
public function GoogleTracking():void{
super();
throw (new ArgumentError("GoogleTracking should be implemented as a static class"));
}
public static function pageView(... _args):void{
var rest = _args;
var event:String = rest.join("/");
if (track == true){
_api.trackPageview(((_project + "/") + event));
} else {
trace((((("[GoogleTracking] - TRACKING PAGE VIEW (" + _project) + "/") + event) + ")"));
};
//unresolved jump
var _slot1 = error;
throw (new IllegalOperationError("GoogleTracking has not been initialized"));
}
public static function trackEvent(action:String, label:String=null, value:Number=NaN):Boolean{
var action = action;
var label = label;
var value = value;
var success:Boolean;
if (track == true){
success = _api.trackEvent(_project, action, label, value);
} else {
success = true;
trace((((((("[GoogleTracking] - TRACKING EVENT (" + action) + ", ") + label) + ", ") + value) + ")"));
};
//unresolved jump
var _slot1 = error;
throw (new IllegalOperationError("GoogleTracking has not been initialized"));
return (success);
}
public static function initialize(displayObject:DisplayObject, account:String, project:String, track:Boolean=true, debug:Boolean=false, mode:String="AS3"):GATracker{
_api = new GATracker(displayObject, account, mode, debug);
_project = project;
GoogleTracking.track = track;
return (_api);
}
public static function get api():GATracker{
return (_api);
}
}
}//package com.soapcreative.net.tracking
Section 245
//IAudioManagerUI (core.component.base.iface.IAudioManagerUI)
package core.component.base.iface {
public interface IAudioManagerUI {
function set isSoundOn(/Users/adam/Projects/juicy-fruit-flavor-fling/branches/no_miniclip/src;core/component/base/iface;IAudioManagerUI.as:Boolean):void;
function get isSoundOn():Boolean;
}
}//package core.component.base.iface
Section 246
//IDestroyable (core.component.base.iface.IDestroyable)
package core.component.base.iface {
public interface IDestroyable {
function destroy():void;
}
}//package core.component.base.iface
Section 247
//AudioManager (core.component.base.AudioManager)
package core.component.base {
import flash.events.*;
import core.component.base.iface.*;
import flash.media.*;
public class AudioManager {
protected var m_currentSoundState:Number;
private var m_soundChannels:Array;
private var m_dataProvider:Object;
private var m_audioInterface:IAudioManagerUI;
protected static const SOUND_STATE_PLAYING:Number = 0;
protected static const SOUND_STATE_PAUSED:Number = 1;
protected static const SOUND_STATE_MUTED:Number = 3;
protected static const SOUND_STATE_STOPPED:Number = 2;
public function AudioManager(a_dataProvider:Object, a_audioInterface:IAudioManagerUI=null){
super();
m_currentSoundState = SOUND_STATE_PLAYING;
m_audioInterface = a_audioInterface;
m_dataProvider = a_dataProvider;
m_soundChannels = new Array();
}
public function pauseAudio():void{
m_currentSoundState = SOUND_STATE_PAUSED;
var i:Number = 0;
while (i < m_soundChannels.length) {
m_soundChannels[i]["position"] = m_soundChannels[i]["channel"].position;
m_soundChannels[i]["channel"].stop();
i++;
};
}
public function stopAudio():void{
var soundChannel:Object;
m_currentSoundState = SOUND_STATE_STOPPED;
while (m_soundChannels.length > 0) {
soundChannel = m_soundChannels.pop();
soundChannel["channel"].stop();
};
}
public function unmuteAudio():void{
var unmuteTransform:SoundTransform = new SoundTransform(1);
m_currentSoundState = SOUND_STATE_PLAYING;
var i:Number = 0;
while (i < m_soundChannels.length) {
m_soundChannels[i]["channel"].soundTransform = unmuteTransform;
i++;
};
}
public function set audioInterface(value:IAudioManagerUI):void{
m_audioInterface = value;
}
public function resumeAudio():void{
var soundName:String;
var startTime:Number;
var loopCount:Number;
m_currentSoundState = SOUND_STATE_PLAYING;
var i:Number = 0;
while (i < m_soundChannels.length) {
soundName = m_soundChannels[i]["name"];
startTime = m_soundChannels[i]["position"];
loopCount = m_soundChannels[i]["loopCount"];
m_soundChannels[i]["channel"] = m_dataProvider[soundName].play(startTime, loopCount);
i++;
};
}
public function playSound(a_sound:String, a_startTime:Number=0, a_loopCount:Number=1):void{
var soundChannel:SoundChannel;
var a_sound = a_sound;
var a_startTime = a_startTime;
var a_loopCount = a_loopCount;
if (((!(m_audioInterface)) || (((!(m_audioInterface.isSoundOn)) && (!((m_currentSoundState == SOUND_STATE_MUTED))))))){
return;
};
soundChannel = m_dataProvider[a_sound].play(a_startTime, a_loopCount);
if (m_currentSoundState == SOUND_STATE_MUTED){
soundChannel.soundTransform = new SoundTransform(0);
};
soundChannel.addEventListener(Event.SOUND_COMPLETE, resolveSoundComplete);
m_soundChannels.push({name:a_sound, channel:soundChannel, position:a_startTime, loopCount:a_loopCount});
//unresolved jump
var _slot1 = e;
trace((("Oops, " + a_sound) + " isn't in the data provider!"));
}
private function resolveSoundComplete(a_event:Event):void{
var i:Number = 0;
while (i < m_soundChannels.length) {
if (a_event.target == m_soundChannels[i]["channel"]){
m_soundChannels.splice(i, 1);
};
i++;
};
}
public function muteAudio():void{
var muteTransform:SoundTransform = new SoundTransform(0);
m_currentSoundState = SOUND_STATE_MUTED;
var i:Number = 0;
while (i < m_soundChannels.length) {
m_soundChannels[i]["channel"].soundTransform = muteTransform;
i++;
};
}
}
}//package core.component.base
Section 248
//ParticleDataProvider (core.component.base.ParticleDataProvider)
package core.component.base {
import flash.geom.*;
public class ParticleDataProvider {
private var m_impulseMaximum:Number;
private var m_scaleMinimum:Number;
private var m_scaleMaximum:Number;
private var m_tint:Number;
private var m_emissionRate:Number;
private var m_linearDamping:Number;
private var m_angleMinimum:Number;
private var m_rotationMinimum:Number;
private var m_angleMaximum:Number;
private var m_impulseMinimum:Number;
private var m_rotationMaximum:Number;
private var m_gravity:Point;
private var m_particleSprite:Class;
private var m_lifeSpan:Number;
public function ParticleDataProvider(a_dataProvider:Object=null){
super();
if (a_dataProvider){
particleSprite = a_dataProvider.particleSprite;
emissionRate = a_dataProvider.emissionRate;
angleMinimum = a_dataProvider.angleMinimum;
angleMaximum = a_dataProvider.angleMaximum;
impulseMinimum = a_dataProvider.impulseMinimum;
impulseMaximum = a_dataProvider.impulseMaximum;
linearDamping = a_dataProvider.linearDamping;
gravity = a_dataProvider.gravity;
lifeSpan = a_dataProvider.lifeSpan;
scaleMinimum = a_dataProvider.scaleMinimum;
scaleMaximum = a_dataProvider.scaleMaximum;
rotationMinimum = a_dataProvider.rotationMinimum;
rotationMaximum = a_dataProvider.rotationMaximum;
};
}
public function get particleSprite():Class{
return (m_particleSprite);
}
public function get emissionRate():Number{
return (m_emissionRate);
}
public function set rotationMaximum(a_value:Number):void{
m_rotationMaximum = a_value;
}
public function set emissionRate(a_value:Number):void{
m_emissionRate = a_value;
}
public function get scaleMaximum():Number{
return (m_scaleMaximum);
}
public function set gravity(a_value:Point):void{
m_gravity = a_value;
}
public function get linearDamping():Number{
return (m_linearDamping);
}
public function set tint(a_value:Number):void{
m_tint = a_value;
}
public function set angleMaximum(a_value:Number):void{
m_angleMaximum = a_value;
}
public function get rotationMinimum():Number{
return (m_rotationMinimum);
}
public function set impulseMinimum(a_value:Number):void{
m_impulseMinimum = a_value;
}
public function set linearDamping(a_value:Number):void{
m_linearDamping = a_value;
}
public function get angleMinimum():Number{
return (m_angleMinimum);
}
public function get rotationMaximum():Number{
return (m_rotationMaximum);
}
public function set scaleMinimum(a_value:Number):void{
m_scaleMinimum = a_value;
}
public function set lifeSpan(a_value:Number):void{
m_lifeSpan = a_value;
}
public function get gravity():Point{
return (m_gravity);
}
public function get angleMaximum():Number{
return (m_angleMaximum);
}
public function set particleSprite(a_value:Class):void{
m_particleSprite = a_value;
}
public function get impulseMinimum():Number{
return (m_impulseMinimum);
}
public function set rotationMinimum(a_value:Number):void{
m_rotationMinimum = a_value;
}
public function get scaleMinimum():Number{
return (m_scaleMinimum);
}
public function set impulseMaximum(a_value:Number):void{
m_impulseMaximum = a_value;
}
public function get lifeSpan():Number{
return (m_lifeSpan);
}
public function get impulseMaximum():Number{
return (m_impulseMaximum);
}
public function set scaleMaximum(a_value:Number):void{
m_scaleMaximum = a_value;
}
public function set angleMinimum(a_value:Number):void{
m_angleMinimum = a_value;
}
public function get tint():Number{
return (m_tint);
}
}
}//package core.component.base
Section 249
//ParticleEmitter (core.component.base.ParticleEmitter)
package core.component.base {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
public class ParticleEmitter extends Sprite {
private var m_particleData:ParticleDataProvider;
private var m_shouldStop:Boolean;
private var m_particlesToEmit:Number;
private var m_particlePool:Array;
private var m_previousTime:Number;
public function ParticleEmitter(a_x:Number, a_y:Number, a_dataProvider:ParticleDataProvider=null){
super();
x = a_x;
y = a_y;
m_previousTime = getTimer();
m_particleData = a_dataProvider;
m_particlePool = new Array();
m_shouldStop = false;
if (m_particleData){
m_particlesToEmit = m_particleData.emissionRate;
} else {
m_particlesToEmit = 0;
};
}
public function set particleData(a_value:ParticleDataProvider):void{
m_particleData = a_value;
}
private function resolveEnterFrame(a_event:Event):void{
if (!m_particleData){
return;
};
var currentTime:Number = getTimer();
var deltaTime:Number = (currentTime - m_previousTime);
m_previousTime = currentTime;
deltaTime = (deltaTime / 1000);
if (m_particlePool.length > 0){
updateParticles(deltaTime);
};
if (!m_shouldStop){
pushParticles(deltaTime);
};
}
private function updateParticles(a_sElapsed:Number):void{
var magnitude:Number;
var particle:Object;
var direction:Point = new Point();
for each (particle in m_particlePool) {
particle.lifeSpan = (particle.lifeSpan - a_sElapsed);
if (particle.lifeSpan <= 0){
m_particlePool.splice(m_particlePool.indexOf(particle), 1);
removeChild(particle.sprite);
if (((m_shouldStop) && ((m_particlePool.length == 0)))){
removeEventListener(Event.ENTER_FRAME, resolveEnterFrame);
if (parent){
parent.removeChild(this);
};
};
} else {
if (m_particleData.linearDamping != 0){
magnitude = particle.velocity.length;
direction = particle.velocity.clone();
direction.normalize(1);
magnitude = Math.max(0, (magnitude - (m_particleData.linearDamping * magnitude)));
particle.velocity.x = (direction.x * magnitude);
particle.velocity.y = (direction.y * magnitude);
};
if ((((Math.abs(m_particleData.gravity.x) > 0)) || ((Math.abs(m_particleData.gravity.y) > 0)))){
particle.velocity.x = (particle.velocity.x + (m_particleData.gravity.x * a_sElapsed));
particle.velocity.y = (particle.velocity.y + (m_particleData.gravity.y * a_sElapsed));
};
particle.sprite.x = (particle.sprite.x + (particle.velocity.x * a_sElapsed));
particle.sprite.y = (particle.sprite.y + (particle.velocity.y * a_sElapsed));
};
};
}
public function get particleData():ParticleDataProvider{
return (m_particleData);
}
public function start():void{
addEventListener(Event.ENTER_FRAME, resolveEnterFrame);
}
private function pushParticles(a_sElapsed:Number):void{
var angle:Number;
var impulse:Number;
var scale:Number;
var rotation:Number;
var transform:ColorTransform;
m_particlesToEmit = (m_particlesToEmit + (m_particleData.emissionRate * a_sElapsed));
if (m_particlesToEmit < 1){
return;
};
var particleToAdd:Object = new Object();
var velocity:Point = new Point();
while (uint(m_particlesToEmit) > 0) {
particleToAdd = new Object();
particleToAdd.sprite = new m_particleData.particleSprite();
if (m_particleData.tint){
transform = (particleToAdd.sprite as MovieClip).transform.colorTransform;
transform.color = m_particleData.tint;
(particleToAdd.sprite as MovieClip).transform.colorTransform = transform;
};
scale = (Math.random() * (m_particleData.scaleMaximum - m_particleData.scaleMinimum));
scale = (scale + m_particleData.scaleMinimum);
particleToAdd.sprite.width = (particleToAdd.sprite.width * scale);
particleToAdd.sprite.height = (particleToAdd.sprite.height * scale);
rotation = (Math.random() * (m_particleData.rotationMaximum - m_particleData.rotationMinimum));
rotation = (rotation + m_particleData.rotationMinimum);
rotation = (rotation * (180 / Math.PI));
particleToAdd.sprite.rotation = rotation;
angle = (Math.random() * (m_particleData.angleMaximum - m_particleData.angleMinimum));
angle = (angle + m_particleData.angleMinimum);
impulse = (Math.random() * (m_particleData.impulseMaximum - m_particleData.impulseMinimum));
impulse = (impulse + m_particleData.impulseMinimum);
velocity.x = (Math.sin(angle) * (impulse * a_sElapsed));
velocity.y = (Math.cos(angle) * (impulse * a_sElapsed));
particleToAdd.velocity = velocity.clone();
particleToAdd.lifeSpan = m_particleData.lifeSpan;
m_particlePool.push(particleToAdd);
addChild(particleToAdd.sprite);
m_particlesToEmit--;
};
}
public function stop():void{
m_shouldStop = true;
}
}
}//package core.component.base
Section 250
//Preloader (core.component.base.Preloader)
package core.component.base {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class Preloader extends MovieClip {
protected var m_bytesLoadedRatio:Number;
public function Preloader(){
super();
addEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
protected function resolveEnterFrame(a_event:Event):void{
if (framesLoaded == totalFrames){
removeEventListener(Event.ENTER_FRAME, resolveEnterFrame);
nextFrame();
instantiateGame();
} else {
m_bytesLoadedRatio = (root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal);
m_bytesLoadedRatio = Math.min(m_bytesLoadedRatio, 1);
};
}
protected function get className():String{
return ("");
}
protected function instantiateGame():void{
var mainClass:Class = (getDefinitionByName(className) as Class);
if (mainClass){
addChild(new (mainClass));
};
}
private function resolveAddedToStage(a_event:Event):void{
stop();
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
addEventListener(Event.ENTER_FRAME, resolveEnterFrame);
removeEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
}
}//package core.component.base
Section 251
//StateEvent (core.component.base.StateEvent)
package core.component.base {
import flash.events.*;
public class StateEvent extends Event {
public static const STATE_EVENT_CHANGE:String = "stateEventChange";
public function StateEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
}
}
}//package core.component.base
Section 252
//StateManager (core.component.base.StateManager)
package core.component.base {
import flash.display.*;
import core.component.base.iface.*;
import flash.utils.*;
public class StateManager extends Sprite {
protected var m_transitionXML:XMLList;
protected var m_currentStateID:String;
protected var m_stateXML:XMLList;
private static const StateXML:Class = StateManager_StateXML;
protected static var m_stateFileXML:XML = XML(new StateXML());
public function StateManager(){
super();
m_currentStateID = "";
m_stateXML = m_stateFileXML.states;
m_transitionXML = m_stateFileXML.transitions;
addEventListener(StateEvent.STATE_EVENT_CHANGE, resolveStateEvent);
}
public function get currentStateID():String{
return (m_currentStateID);
}
protected function resolveStateEvent(a_event:StateEvent):void{
var relevantTransition:XMLList;
var relevantState:XMLList;
var newChild:DisplayObject;
var currentClassDefinition:Class;
var shouldRemoveCurrentChild:Boolean;
var shouldAddCurrentClass:Boolean;
var currentChild:DisplayObject;
var attribute:XML;
var i:Number;
var childToAdd:XML;
var childToCheck:XML;
var j:Number;
var a_event = a_event;
relevantTransition = m_transitionXML.transition.(((@event == a_event.type)) && ((@current == m_currentStateID)));
relevantState = m_stateXML.state.(@id == relevantTransition.@destination);
m_currentStateID = relevantTransition.@destination;
i = (numChildren - 1);
while (i >= 0) {
shouldRemoveCurrentChild = true;
currentChild = getChildAt(i);
for each (childToCheck in relevantState.children()) {
currentClassDefinition = (getDefinitionByName(childToCheck.name().toString()) as Class);
if ((currentChild is currentClassDefinition)){
for each (attribute in childToCheck.attributes()) {
if (attribute.valueOf().toXMLString() == "false"){
currentChild[attribute.localName().toString()] = false;
} else {
currentChild[attribute.localName().toString()] = attribute.valueOf().toXMLString();
};
};
shouldRemoveCurrentChild = false;
};
};
if (shouldRemoveCurrentChild){
if ((currentChild is IDestroyable)){
(currentChild as IDestroyable).destroy();
};
removeChild(currentChild);
};
i = (i - 1);
};
for each (childToAdd in relevantState.children()) {
currentClassDefinition = (getDefinitionByName(childToAdd.name().toString()) as Class);
shouldAddCurrentClass = true;
j = 0;
while (j < numChildren) {
if ((getChildAt(j) is currentClassDefinition)){
shouldAddCurrentClass = false;
break;
};
j = (j + 1);
};
if (shouldAddCurrentClass){
newChild = new (currentClassDefinition);
for each (attribute in childToAdd.attributes()) {
if (attribute.valueOf().toXMLString() == "false"){
newChild[attribute.localName().toString()] = false;
} else {
newChild[attribute.localName().toString()] = attribute.valueOf().toXMLString();
};
};
addChild(newChild);
};
};
}
}
}//package core.component.base
Section 253
//StateManager_StateXML (core.component.base.StateManager_StateXML)
package core.component.base {
import mx.core.*;
public class StateManager_StateXML extends ByteArrayAsset {
}
}//package core.component.base
Section 254
//JFFFAudioManagerDataProvider (core.component.custom.JFFFAudioManagerDataProvider)
package core.component.custom {
import flash.media.*;
public final class JFFFAudioManagerDataProvider {
public var stretch:Sound;
public var alien:Sound;
public var warp:Sound;
public var trampoleen:Sound;
public var pop:Sound;
public var bigToken:Sound;
public var fling:Sound;
public var music:Sound;
public var fail:Sound;
public var balloon:Sound;
public var buttonClick:Sound;
public var smallToken:Sound;
private static const MusicMusic:Class = JFFFAudioManagerDataProvider_MusicMusic;
private static const SFXFail:Class = JFFFAudioManagerDataProvider_SFXFail;
private static const SFXAlien:Class = JFFFAudioManagerDataProvider_SFXAlien;
private static const SFXBalloon:Class = JFFFAudioManagerDataProvider_SFXBalloon;
private static const SFXPop:Class = JFFFAudioManagerDataProvider_SFXPop;
private static const SFXWarp:Class = JFFFAudioManagerDataProvider_SFXWarp;
private static const SFXStretch:Class = JFFFAudioManagerDataProvider_SFXStretch;
private static const SFXTrampoleen:Class = JFFFAudioManagerDataProvider_SFXTrampoleen;
private static const SFXButtonClick:Class = JFFFAudioManagerDataProvider_SFXButtonClick;
private static const SFXFling:Class = JFFFAudioManagerDataProvider_SFXFling;
private static const SFXToken1:Class = JFFFAudioManagerDataProvider_SFXToken1;
private static const SFXToken2:Class = JFFFAudioManagerDataProvider_SFXToken2;
public function JFFFAudioManagerDataProvider(){
music = new MusicMusic();
buttonClick = new SFXButtonClick();
smallToken = new SFXToken1();
bigToken = new SFXToken2();
fail = new SFXFail();
alien = new SFXAlien();
warp = new SFXWarp();
stretch = new SFXStretch();
fling = new SFXFling();
balloon = new SFXBalloon();
pop = new SFXPop();
trampoleen = new SFXTrampoleen();
super();
}
}
}//package core.component.custom
Section 255
//JFFFAudioManagerDataProvider_MusicMusic (core.component.custom.JFFFAudioManagerDataProvider_MusicMusic)
package core.component.custom {
import mx.core.*;
public class JFFFAudioManagerDataProvider_MusicMusic extends SoundAsset {
}
}//package core.component.custom
Section 256
//JFFFAudioManagerDataProvider_SFXAlien (core.component.custom.JFFFAudioManagerDataProvider_SFXAlien)
package core.component.custom {
import mx.core.*;
public class JFFFAudioManagerDataProvider_SFXAlien extends SoundAsset {
}
}//package core.component.custom
Section 257
//JFFFAudioManagerDataProvider_SFXBalloon (core.component.custom.JFFFAudioManagerDataProvider_SFXBalloon)
package core.component.custom {
import mx.core.*;
public class JFFFAudioManagerDataProvider_SFXBalloon extends SoundAsset {
}
}//package core.component.custom
Section 258
//JFFFAudioManagerDataProvider_SFXButtonClick (core.component.custom.JFFFAudioManagerDataProvider_SFXButtonClick)
package core.component.custom {
import mx.core.*;
public class JFFFAudioManagerDataProvider_SFXButtonClick extends SoundAsset {
}
}//package core.component.custom
Section 259
//JFFFAudioManagerDataProvider_SFXFail (core.component.custom.JFFFAudioManagerDataProvider_SFXFail)
package core.component.custom {
import mx.core.*;
public class JFFFAudioManagerDataProvider_SFXFail extends SoundAsset {
}
}//package core.component.custom
Section 260
//JFFFAudioManagerDataProvider_SFXFling (core.component.custom.JFFFAudioManagerDataProvider_SFXFling)
package core.component.custom {
import mx.core.*;
public class JFFFAudioManagerDataProvider_SFXFling extends SoundAsset {
}
}//package core.component.custom
Section 261
//JFFFAudioManagerDataProvider_SFXPop (core.component.custom.JFFFAudioManagerDataProvider_SFXPop)
package core.component.custom {
import mx.core.*;
public class JFFFAudioManagerDataProvider_SFXPop extends SoundAsset {
}
}//package core.component.custom
Section 262
//JFFFAudioManagerDataProvider_SFXStretch (core.component.custom.JFFFAudioManagerDataProvider_SFXStretch)
package core.component.custom {
import mx.core.*;
public class JFFFAudioManagerDataProvider_SFXStretch extends SoundAsset {
}
}//package core.component.custom
Section 263
//JFFFAudioManagerDataProvider_SFXToken1 (core.component.custom.JFFFAudioManagerDataProvider_SFXToken1)
package core.component.custom {
import mx.core.*;
public class JFFFAudioManagerDataProvider_SFXToken1 extends SoundAsset {
}
}//package core.component.custom
Section 264
//JFFFAudioManagerDataProvider_SFXToken2 (core.component.custom.JFFFAudioManagerDataProvider_SFXToken2)
package core.component.custom {
import mx.core.*;
public class JFFFAudioManagerDataProvider_SFXToken2 extends SoundAsset {
}
}//package core.component.custom
Section 265
//JFFFAudioManagerDataProvider_SFXTrampoleen (core.component.custom.JFFFAudioManagerDataProvider_SFXTrampoleen)
package core.component.custom {
import mx.core.*;
public class JFFFAudioManagerDataProvider_SFXTrampoleen extends SoundAsset {
}
}//package core.component.custom
Section 266
//JFFFAudioManagerDataProvider_SFXWarp (core.component.custom.JFFFAudioManagerDataProvider_SFXWarp)
package core.component.custom {
import mx.core.*;
public class JFFFAudioManagerDataProvider_SFXWarp extends SoundAsset {
}
}//package core.component.custom
Section 267
//JFFFPreloader (core.component.custom.JFFFPreloader)
package core.component.custom {
import flash.events.*;
import core.component.base.*;
import fla.ui.canvas.*;
import com.soapcreative.net.tracking.*;
public class JFFFPreloader extends Preloader {
private var _view:Preloader;
private static const ANALYTICS_PROJECT_NAME:String = "Juicy Fruit Flavor Fling";
private static const ANALYTICS_ACCOUNT:String = "UA-6368558-43";
public function JFFFPreloader(){
super();
_view = new Preloader();
addChild(_view);
GoogleTracking.initialize(stage, ANALYTICS_ACCOUNT, ANALYTICS_PROJECT_NAME, true);
GameTracking.trackIndex();
}
override protected function resolveEnterFrame(a_event:Event):void{
super.resolveEnterFrame(a_event);
_view.percentage.text = (int((m_bytesLoadedRatio * 100)).toString() + "%");
}
override protected function get className():String{
return ("JuicyFruitFlavorFling");
}
}
}//package core.component.custom
Section 268
//JFFFStateEvent (core.component.custom.JFFFStateEvent)
package core.component.custom {
import core.component.base.*;
public class JFFFStateEvent extends StateEvent {
private var m_level:Number;
public static const STATE_EVENT_PAUSE:String = "stateEventPause";
public static const STATE_EVENT_LEVEL_OUT_OF_TIME:String = "stateEventLevelOutOfTime";
public static const STATE_EVENT_PLAY:String = "stateEventPlay";
public static const STATE_EVENT_LEVEL_SELECT:String = "stateEventLevelSelect";
public static const STATE_EVENT_GAME_COMPLETE:String = "stateEventGameComplete";
public static const STATE_EVENT_EDIT:String = "stateEventEdit";
public static const STATE_EVENT_HOME:String = "stateEventHome";
public static const STATE_EVENT_LEVEL_FAIL:String = "stateEventLevelFail";
public static const STATE_EVENT_SCORES:String = "stateEventScores";
public static const STATE_EVENT_FIRST_PLAY:String = "stateEventFirstPlay";
public static const STATE_EVENT_HOW_TO:String = "stateEventHowTo";
public static const STATE_EVENT_LEVEL_COMPLETE:String = "stateEventLevelComplete";
public function JFFFStateEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, a_level:Number=0){
super(type, bubbles, cancelable);
m_level = a_level;
}
public function get level():Number{
return (m_level);
}
}
}//package core.component.custom
Section 269
//JFFFStateManager (core.component.custom.JFFFStateManager)
package core.component.custom {
import core.component.base.*;
public class JFFFStateManager extends StateManager {
public function JFFFStateManager(){
super();
addEventListener(JFFFStateEvent.STATE_EVENT_HOME, resolveStateEvent);
addEventListener(JFFFStateEvent.STATE_EVENT_FIRST_PLAY, resolveStateEvent);
addEventListener(JFFFStateEvent.STATE_EVENT_PLAY, resolveStateEvent);
addEventListener(JFFFStateEvent.STATE_EVENT_HOW_TO, resolveStateEvent);
addEventListener(JFFFStateEvent.STATE_EVENT_LEVEL_SELECT, resolveStateEvent);
addEventListener(JFFFStateEvent.STATE_EVENT_SCORES, resolveStateEvent);
addEventListener(JFFFStateEvent.STATE_EVENT_LEVEL_FAIL, resolveStateEvent);
addEventListener(JFFFStateEvent.STATE_EVENT_LEVEL_OUT_OF_TIME, resolveStateEvent);
addEventListener(JFFFStateEvent.STATE_EVENT_LEVEL_COMPLETE, resolveStateEvent);
addEventListener(JFFFStateEvent.STATE_EVENT_GAME_COMPLETE, resolveStateEvent);
addEventListener(JFFFStateEvent.STATE_EVENT_PAUSE, resolveStateEvent);
addEventListener(JFFFStateEvent.STATE_EVENT_EDIT, resolveStateEvent);
}
}
}//package core.component.custom
Section 270
//TokenAnim (fla.anim.TokenAnim)
package fla.anim {
import flash.display.*;
import fla.game.component.*;
public dynamic class TokenAnim extends MovieClip {
public var type:TokenType;
}
}//package fla.anim
Section 271
//Anchor (fla.game.component.Anchor)
package fla.game.component {
import flash.display.*;
public dynamic class Anchor extends MovieClip {
public function Anchor(){
addFrameScript(0, this.frame1, 11, this.frame12);
}
function frame1(){
stop();
}
function frame12(){
stop();
}
}
}//package fla.game.component
Section 272
//BigStar (fla.game.component.BigStar)
package fla.game.component {
import flash.display.*;
public dynamic class BigStar extends MovieClip {
}
}//package fla.game.component
Section 273
//ColorToken (fla.game.component.ColorToken)
package fla.game.component {
import flash.display.*;
public dynamic class ColorToken extends MovieClip {
}
}//package fla.game.component
Section 274
//ElectricityNodes (fla.game.component.ElectricityNodes)
package fla.game.component {
import flash.display.*;
public dynamic class ElectricityNodes extends MovieClip {
}
}//package fla.game.component
Section 275
//ElectrifiedSurface (fla.game.component.ElectrifiedSurface)
package fla.game.component {
import flash.display.*;
public dynamic class ElectrifiedSurface extends MovieClip {
public var nodes:ElectricityNodes;
public var electricity:MovieClip;
}
}//package fla.game.component
Section 276
//ExtraLife (fla.game.component.ExtraLife)
package fla.game.component {
import flash.display.*;
public dynamic class ExtraLife extends MovieClip {
}
}//package fla.game.component
Section 277
//GameBackground (fla.game.component.GameBackground)
package fla.game.component {
import flash.display.*;
public dynamic class GameBackground extends MovieClip {
}
}//package fla.game.component
Section 278
//GreenParticle (fla.game.component.GreenParticle)
package fla.game.component {
import flash.display.*;
public dynamic class GreenParticle extends MovieClip {
}
}//package fla.game.component
Section 279
//MovingAnchor (fla.game.component.MovingAnchor)
package fla.game.component {
import flash.display.*;
public dynamic class MovingAnchor extends MovieClip {
public var anchor:Anchor;
public function MovingAnchor(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package fla.game.component
Section 280
//Player (fla.game.component.Player)
package fla.game.component {
import flash.events.*;
import flash.display.*;
public dynamic class Player extends MovieClip {
public function Player(){
addFrameScript(14, this.frame15, 51, this.frame52, 139, this.frame140);
}
function frame140(){
stop();
dispatchEvent(new Event(Event.COMPLETE));
}
function frame15(){
stop();
}
function frame52(){
gotoAndPlay("electrocuted");
}
}
}//package fla.game.component
Section 281
//Point (fla.game.component.Point)
package fla.game.component {
import flash.display.*;
public dynamic class Point extends MovieClip {
}
}//package fla.game.component
Section 282
//PurpleParticle (fla.game.component.PurpleParticle)
package fla.game.component {
import flash.display.*;
public dynamic class PurpleParticle extends MovieClip {
}
}//package fla.game.component
Section 283
//RedParticle (fla.game.component.RedParticle)
package fla.game.component {
import flash.display.*;
public dynamic class RedParticle extends MovieClip {
}
}//package fla.game.component
Section 284
//RotatingSurface (fla.game.component.RotatingSurface)
package fla.game.component {
import flash.display.*;
public dynamic class RotatingSurface extends MovieClip {
}
}//package fla.game.component
Section 285
//Springboard (fla.game.component.Springboard)
package fla.game.component {
import flash.display.*;
public dynamic class Springboard extends MovieClip {
public function Springboard(){
addFrameScript(0, this.frame1, 9, this.frame10);
}
function frame10(){
stop();
}
function frame1(){
stop();
}
}
}//package fla.game.component
Section 286
//Star (fla.game.component.Star)
package fla.game.component {
import flash.display.*;
import fla.anim.*;
public dynamic class Star extends MovieClip {
public var anim:TokenAnim;
public function Star(){
addFrameScript(36, this.frame37);
}
function frame37(){
gotoAndPlay(1);
}
}
}//package fla.game.component
Section 287
//Surface (fla.game.component.Surface)
package fla.game.component {
import flash.display.*;
public dynamic class Surface extends MovieClip {
}
}//package fla.game.component
Section 288
//TeleportSurface (fla.game.component.TeleportSurface)
package fla.game.component {
import flash.display.*;
public dynamic class TeleportSurface extends MovieClip {
}
}//package fla.game.component
Section 289
//TimedAnchor (fla.game.component.TimedAnchor)
package fla.game.component {
import flash.display.*;
public dynamic class TimedAnchor extends MovieClip {
public var anchor:Anchor;
public var balloon:MovieClip;
public function TimedAnchor(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package fla.game.component
Section 290
//TokenType (fla.game.component.TokenType)
package fla.game.component {
import flash.display.*;
public dynamic class TokenType extends MovieClip {
public function TokenType(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3, 3, this.frame4, 4, this.frame5, 5, this.frame6, 6, this.frame7, 7, this.frame8);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
function frame4(){
stop();
}
function frame5(){
stop();
}
function frame6(){
stop();
}
function frame7(){
stop();
}
function frame8(){
stop();
}
}
}//package fla.game.component
Section 291
//Tongue (fla.game.component.Tongue)
package fla.game.component {
import flash.display.*;
public dynamic class Tongue extends MovieClip {
}
}//package fla.game.component
Section 292
//UFO (fla.game.component.UFO)
package fla.game.component {
import flash.display.*;
public dynamic class UFO extends MovieClip {
public var ufo:UFORepresentation;
public var beam:MovieClip;
}
}//package fla.game.component
Section 293
//UFORepresentation (fla.game.component.UFORepresentation)
package fla.game.component {
import flash.display.*;
public dynamic class UFORepresentation extends MovieClip {
}
}//package fla.game.component
Section 294
//YellowParticle (fla.game.component.YellowParticle)
package fla.game.component {
import flash.display.*;
public dynamic class YellowParticle extends MovieClip {
}
}//package fla.game.component
Section 295
//Cloud (fla.game.splat.Cloud)
package fla.game.splat {
import flash.display.*;
public dynamic class Cloud extends MovieClip {
}
}//package fla.game.splat
Section 296
//Cloud2 (fla.game.splat.Cloud2)
package fla.game.splat {
import flash.display.*;
public dynamic class Cloud2 extends MovieClip {
}
}//package fla.game.splat
Section 297
//Crazy (fla.game.splat.Crazy)
package fla.game.splat {
import flash.display.*;
public dynamic class Crazy extends MovieClip {
}
}//package fla.game.splat
Section 298
//DiscoBall (fla.game.splat.DiscoBall)
package fla.game.splat {
import flash.display.*;
public dynamic class DiscoBall extends MovieClip {
}
}//package fla.game.splat
Section 299
//Pipes (fla.game.splat.Pipes)
package fla.game.splat {
import flash.display.*;
public dynamic class Pipes extends MovieClip {
}
}//package fla.game.splat
Section 300
//Pipes2 (fla.game.splat.Pipes2)
package fla.game.splat {
import flash.display.*;
public dynamic class Pipes2 extends MovieClip {
}
}//package fla.game.splat
Section 301
//Pipes3 (fla.game.splat.Pipes3)
package fla.game.splat {
import flash.display.*;
public dynamic class Pipes3 extends MovieClip {
}
}//package fla.game.splat
Section 302
//Planet (fla.game.splat.Planet)
package fla.game.splat {
import flash.display.*;
public dynamic class Planet extends MovieClip {
}
}//package fla.game.splat
Section 303
//Planet2 (fla.game.splat.Planet2)
package fla.game.splat {
import flash.display.*;
public dynamic class Planet2 extends MovieClip {
}
}//package fla.game.splat
Section 304
//Target (fla.game.splat.Target)
package fla.game.splat {
import flash.display.*;
public dynamic class Target extends MovieClip {
}
}//package fla.game.splat
Section 305
//TutorialAttachCollide (fla.game.splat.TutorialAttachCollide)
package fla.game.splat {
import flash.display.*;
public dynamic class TutorialAttachCollide extends MovieClip {
}
}//package fla.game.splat
Section 306
//TutorialClickDrag (fla.game.splat.TutorialClickDrag)
package fla.game.splat {
import flash.display.*;
public dynamic class TutorialClickDrag extends MovieClip {
}
}//package fla.game.splat
Section 307
//TutorialCollect (fla.game.splat.TutorialCollect)
package fla.game.splat {
import flash.display.*;
public dynamic class TutorialCollect extends MovieClip {
}
}//package fla.game.splat
Section 308
//TutorialPressHold (fla.game.splat.TutorialPressHold)
package fla.game.splat {
import flash.display.*;
public dynamic class TutorialPressHold extends MovieClip {
}
}//package fla.game.splat
Section 309
//ElectrifiedSurfaceRep (fla.game.ui.ElectrifiedSurfaceRep)
package fla.game.ui {
import flash.display.*;
public dynamic class ElectrifiedSurfaceRep extends MovieClip {
}
}//package fla.game.ui
Section 310
//SpringboardRep (fla.game.ui.SpringboardRep)
package fla.game.ui {
import flash.display.*;
public dynamic class SpringboardRep extends MovieClip {
}
}//package fla.game.ui
Section 311
//TokenRep (fla.game.ui.TokenRep)
package fla.game.ui {
import flash.display.*;
public dynamic class TokenRep extends MovieClip {
}
}//package fla.game.ui
Section 312
//ApplicationHUD (fla.ui.canvas.ApplicationHUD)
package fla.ui.canvas {
import flash.display.*;
import fla.ui.game.*;
import fla.ui.custom.*;
public dynamic class ApplicationHUD extends MovieClip {
public var soundButton:MovieClip;
public var tokenCounter:TokenCounter;
public var level:CurrentLevel;
public var jfLinkButton:MovieClip;
public var pauseButton:MovieClip;
public var homeButton:MovieClip;
public var gameTimer:GameTimer;
public var lifeBar:LifeBar;
public var scoreBar:Score;
public var gameLogo:MovieClip;
}
}//package fla.ui.canvas
Section 313
//EditHUD (fla.ui.canvas.EditHUD)
package fla.ui.canvas {
import flash.display.*;
public dynamic class EditHUD extends MovieClip {
public var homeButton:MovieClip;
}
}//package fla.ui.canvas
Section 314
//GameComplete (fla.ui.canvas.GameComplete)
package fla.ui.canvas {
import flash.display.*;
import flash.text.*;
import fla.ui.effect.*;
public dynamic class GameComplete extends MovieClip {
public var totalTokens:TextField;
public var surveyButton:MovieClip;
public var totalScore:TextField;
public var background:GameCompleteRainSymbol;
public function GameComplete(){
addFrameScript(0, this.frame1);
}
function frame1(){
stop();
}
}
}//package fla.ui.canvas
Section 315
//HowToPlay (fla.ui.canvas.HowToPlay)
package fla.ui.canvas {
import flash.display.*;
public dynamic class HowToPlay extends MovieClip {
public var nextButton:MovieClip;
public var prevButton:MovieClip;
public var playButton:MovieClip;
public function HowToPlay(){
addFrameScript(0, this.frame1, 1, this.frame2, 2, this.frame3, 3, this.frame4);
}
function frame4(){
stop();
}
function frame1(){
stop();
}
function frame2(){
stop();
}
function frame3(){
stop();
}
}
}//package fla.ui.canvas
Section 316
//LevelComplete (fla.ui.canvas.LevelComplete)
package fla.ui.canvas {
import flash.display.*;
import flash.text.*;
public dynamic class LevelComplete extends MovieClip {
public var bonusItems:TextField;
public var playButton:MovieClip;
public var surveyButton:MovieClip;
public var levelScore:TextField;
public var timeLeft:TextField;
public var totalScore:TextField;
}
}//package fla.ui.canvas
Section 317
//LevelEdit (fla.ui.canvas.LevelEdit)
package fla.ui.canvas {
import flash.display.*;
import flash.text.*;
public dynamic class LevelEdit extends MovieClip {
public var editForce:TextField;
public var viewXMLButton:MovieClip;
public var objectPane:MovieClip;
public var editY:TextField;
public var editHeight:TextField;
public var editValue:TextField;
public var editLifeSpan:TextField;
public var editHitRadius:TextField;
public var editWidth:TextField;
public var editSpeed:TextField;
public var testButton:MovieClip;
public var editBlinkTime:TextField;
public var editRotation:TextField;
public var editRotationRate:TextField;
public var editX:TextField;
public var editDestinationX:TextField;
public var editDestinationY:TextField;
public var editColor:TextField;
}
}//package fla.ui.canvas
Section 318
//LevelFail (fla.ui.canvas.LevelFail)
package fla.ui.canvas {
import flash.display.*;
public dynamic class LevelFail extends MovieClip {
public var restartButton:MovieClip;
public var quitButton:MovieClip;
public function LevelFail(){
addFrameScript(0, this.frame1, 1, this.frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package fla.ui.canvas
Section 319
//LevelSelect (fla.ui.canvas.LevelSelect)
package fla.ui.canvas {
import flash.display.*;
public dynamic class LevelSelect extends MovieClip {
public var level2Button:MovieClip;
public var level3Button:MovieClip;
public var level18Button:MovieClip;
public var level7Button:MovieClip;
public var level8Button:MovieClip;
public var nextButton:MovieClip;
public var level19Button:MovieClip;
public var level9Button:MovieClip;
public var level13Button:MovieClip;
public var level5Button:MovieClip;
public var level20Button:MovieClip;
public var level4Button:MovieClip;
public var level6Button:MovieClip;
public var prevButton:MovieClip;
public var level10Button:MovieClip;
public var level11Button:MovieClip;
public var level12Button:MovieClip;
public var level14Button:MovieClip;
public var level15Button:MovieClip;
public var level16Button:MovieClip;
public var level17Button:MovieClip;
public var level1Button:MovieClip;
}
}//package fla.ui.canvas
Section 320
//Pause (fla.ui.canvas.Pause)
package fla.ui.canvas {
import flash.display.*;
public dynamic class Pause extends MovieClip {
public var retryButton:MovieClip;
public var resumeButton:MovieClip;
}
}//package fla.ui.canvas
Section 321
//Preloader (fla.ui.canvas.Preloader)
package fla.ui.canvas {
import flash.display.*;
import flash.text.*;
public dynamic class Preloader extends MovieClip {
public var percentage:TextField;
}
}//package fla.ui.canvas
Section 322
//QuitConfirmation (fla.ui.canvas.QuitConfirmation)
package fla.ui.canvas {
import flash.display.*;
public dynamic class QuitConfirmation extends MovieClip {
public var yesButton:MovieClip;
public var noButton:MovieClip;
}
}//package fla.ui.canvas
Section 323
//TitleScreen (fla.ui.canvas.TitleScreen)
package fla.ui.canvas {
import flash.display.*;
public dynamic class TitleScreen extends MovieClip {
public var howToPlayButton:MovieClip;
public var editButton:MovieClip;
public var playButton:MovieClip;
}
}//package fla.ui.canvas
Section 324
//XMLView (fla.ui.canvas.XMLView)
package fla.ui.canvas {
import flash.display.*;
import flash.text.*;
public dynamic class XMLView extends MovieClip {
public var backButton:MovieClip;
public var xml:TextField;
}
}//package fla.ui.canvas
Section 325
//Score (fla.ui.custom.Score)
package fla.ui.custom {
import flash.display.*;
import flash.text.*;
public dynamic class Score extends MovieClip {
public var scoreText:TextField;
}
}//package fla.ui.custom
Section 326
//GameCompleteRainSymbol (fla.ui.effect.GameCompleteRainSymbol)
package fla.ui.effect {
import flash.display.*;
public dynamic class GameCompleteRainSymbol extends MovieClip {
}
}//package fla.ui.effect
Section 327
//CurrentLevel (fla.ui.game.CurrentLevel)
package fla.ui.game {
import flash.display.*;
import flash.text.*;
public dynamic class CurrentLevel extends MovieClip {
public var levelNumber:TextField;
}
}//package fla.ui.game
Section 328
//GameTimer (fla.ui.game.GameTimer)
package fla.ui.game {
import flash.display.*;
import flash.text.*;
public dynamic class GameTimer extends MovieClip {
public var time:TextField;
}
}//package fla.ui.game
Section 329
//LifeBar (fla.ui.game.LifeBar)
package fla.ui.game {
import flash.display.*;
import flash.text.*;
public dynamic class LifeBar extends MovieClip {
public var count:TextField;
}
}//package fla.ui.game
Section 330
//TokenCounter (fla.ui.game.TokenCounter)
package fla.ui.game {
import flash.display.*;
import flash.text.*;
public dynamic class TokenCounter extends MovieClip {
public var count:TextField;
}
}//package fla.ui.game
Section 331
//IAnchor (game.component.control.iface.IAnchor)
package game.component.control.iface {
import flash.display.*;
import Box2D.Common.Math.*;
public interface IAnchor {
function playAttach():void;
function updatePosition(/Users/adam/Projects/juicy-fruit-flavor-fling/branches/no_miniclip/src;game/component/control/iface;IAnchor.as:b2Vec2):void;
function getDisplayObject():DisplayObject;
function playDetach():void;
}
}//package game.component.control.iface
Section 332
//IElectrifiedSurface (game.component.control.iface.IElectrifiedSurface)
package game.component.control.iface {
public interface IElectrifiedSurface extends ISurface {
function hide():void;
function show():void;
}
}//package game.component.control.iface
Section 333
//IMovingAnchor (game.component.control.iface.IMovingAnchor)
package game.component.control.iface {
import Box2D.Common.Math.*;
public interface IMovingAnchor extends IAnchor {
function get scale():Number;
function getAnchorPosition():b2Vec2;
function set scale(:Number):void;
}
}//package game.component.control.iface
Section 334
//IPlayer (game.component.control.iface.IPlayer)
package game.component.control.iface {
import flash.display.*;
import Box2D.Common.Math.*;
public interface IPlayer {
function updatePosition(/Users/adam/Projects/juicy-fruit-flavor-fling/branches/no_miniclip/src;game/component/control/iface;IPlayer.as:b2Vec2):void;
function getDisplayObject():DisplayObject;
function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void;
function pointTo(/Users/adam/Projects/juicy-fruit-flavor-fling/branches/no_miniclip/src;game/component/control/iface;IPlayer.as:b2Vec2):void;
function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void;
}
}//package game.component.control.iface
Section 335
//IPlayerJoint (game.component.control.iface.IPlayerJoint)
package game.component.control.iface {
import flash.display.*;
import Box2D.Common.Math.*;
public interface IPlayerJoint {
function hide():void;
function getViewDisplayObject():DisplayObject;
function updatePosition(:b2Vec2):void;
function pointTo(:b2Vec2):void;
function show():void;
}
}//package game.component.control.iface
Section 336
//IPlayerPath (game.component.control.iface.IPlayerPath)
package game.component.control.iface {
import flash.display.*;
import Box2D.Common.Math.*;
public interface IPlayerPath {
function updatePosition(/Users/adam/Projects/juicy-fruit-flavor-fling/branches/no_miniclip/src;game/component/control/iface;IPlayerPath.as:b2Vec2):void;
function addPointAt(_arg1:Number, _arg2:Number):void;
function getViewDisplayObject():DisplayObject;
function clearAllPoints():void;
}
}//package game.component.control.iface
Section 337
//ISurface (game.component.control.iface.ISurface)
package game.component.control.iface {
import flash.display.*;
import Box2D.Common.Math.*;
public interface ISurface {
function updatePosition(/Users/adam/Projects/juicy-fruit-flavor-fling/branches/no_miniclip/src;game/component/control/iface;ISurface.as:b2Vec2):void;
function get rotation():Number;
function get width():Number;
function updateRotation(/Users/adam/Projects/juicy-fruit-flavor-fling/branches/no_miniclip/src;game/component/control/iface;ISurface.as:Number):void;
function getDisplayObject():DisplayObject;
function set width(/Users/adam/Projects/juicy-fruit-flavor-fling/branches/no_miniclip/src;game/component/control/iface;ISurface.as:Number):void;
function set height(/Users/adam/Projects/juicy-fruit-flavor-fling/branches/no_miniclip/src;game/component/control/iface;ISurface.as:Number):void;
function get height():Number;
}
}//package game.component.control.iface
Section 338
//ITimedAnchor (game.component.control.iface.ITimedAnchor)
package game.component.control.iface {
public interface ITimedAnchor extends IAnchor {
function fadeTo(:Number):void;
}
}//package game.component.control.iface
Section 339
//IToken (game.component.control.iface.IToken)
package game.component.control.iface {
import flash.display.*;
import Box2D.Common.Math.*;
public interface IToken {
function updatePosition(/Users/adam/Projects/juicy-fruit-flavor-fling/branches/no_miniclip/src;game/component/control/iface;IToken.as:b2Vec2):void;
function getDisplayObject():DisplayObject;
}
}//package game.component.control.iface
Section 340
//IUFO (game.component.control.iface.IUFO)
package game.component.control.iface {
import flash.display.*;
import Box2D.Common.Math.*;
public interface IUFO {
function hideBeam():void;
function updatePosition(/Users/adam/Projects/juicy-fruit-flavor-fling/branches/no_miniclip/src;game/component/control/iface;IUFO.as:b2Vec2):void;
function getDisplayObject():DisplayObject;
function showBeam():void;
function set height(/Users/adam/Projects/juicy-fruit-flavor-fling/branches/no_miniclip/src;game/component/control/iface;IUFO.as:Number):void;
}
}//package game.component.control.iface
Section 341
//AnchorControl (game.component.control.AnchorControl)
package game.component.control {
import flash.display.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import game.component.model.*;
public class AnchorControl extends AnchorModel implements IGameComponent {
private var m_view:IAnchor;
public function AnchorControl(a_view:IAnchor, a_x:Number, a_y:Number, a_hitRadius:Number, a_physicsWorld:b2World, a_worldScale:Number){
super(a_x, a_y, a_hitRadius, a_physicsWorld, a_worldScale);
m_view = a_view;
var position:b2Vec2 = m_rigidBody.GetPosition();
m_view.updatePosition(b2Vec2.Make((position.x * m_worldScale), (position.y * m_worldScale)));
}
public function update(a_msElapsed:Number):void{
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getDisplayObject());
}
public function playDetach():void{
m_view.playDetach();
}
public function playAttach():void{
m_view.playAttach();
}
public function destroy():void{
m_rigidBody.DestroyFixture(m_fixture);
m_physicsWorld.DestroyBody(m_rigidBody);
}
public function get rigidBody():b2Body{
return (m_rigidBody);
}
}
}//package game.component.control
Section 342
//BigTokenControl (game.component.control.BigTokenControl)
package game.component.control {
import Box2D.Dynamics.*;
import game.component.control.iface.*;
public class BigTokenControl extends TokenControl {
public function BigTokenControl(a_view:IToken, a_x:Number, a_y:Number, a_physicsWorld:b2World, a_worldScale:Number, a_pointValue:Number){
super(a_view, a_x, a_y, a_physicsWorld, a_worldScale, a_pointValue);
m_view.getDisplayObject().rotation = 0;
}
override public function update(a_msElapsed:Number):void{
}
}
}//package game.component.control
Section 343
//ColorTokenControl (game.component.control.ColorTokenControl)
package game.component.control {
import flash.display.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import game.component.model.*;
public class ColorTokenControl extends ColorTokenModel implements IGameComponent {
private var m_view:IToken;
public function ColorTokenControl(a_view:IToken, a_x:Number, a_y:Number, a_physicsWorld:b2World, a_worldScale:Number, a_color:Number){
super(a_x, a_y, a_physicsWorld, a_worldScale, a_color);
m_view = a_view;
var position:b2Vec2 = m_rigidBody.GetPosition().Copy();
position.Multiply(m_worldScale);
m_view.updatePosition(position);
}
public function update(a_msElapsed:Number):void{
}
public function destroy():void{
m_rigidBody.DestroyFixture(m_fixture);
m_physicsWorld.DestroyBody(m_rigidBody);
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getDisplayObject());
}
public function get color():Number{
return (m_color);
}
}
}//package game.component.control
Section 344
//ElectrifiedSurfaceControl (game.component.control.ElectrifiedSurfaceControl)
package game.component.control {
import flash.events.*;
import flash.display.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import game.component.model.*;
public class ElectrifiedSurfaceControl extends ElectrifiedSurfaceModel implements IGameComponent {
private var m_view:IElectrifiedSurface;
private static const ANIMATION_HACK_HEIGHT:Number = 23.4;
private static const ANIMATION_HACK_WIDTH:Number = 159;
public function ElectrifiedSurfaceControl(a_view:IElectrifiedSurface, a_x:Number, a_y:Number, a_rotation:Number, a_blinkCycle:Number, a_physicsWorld:b2World, a_worldScale:Number){
super(a_x, a_y, ANIMATION_HACK_WIDTH, ANIMATION_HACK_HEIGHT, a_rotation, a_blinkCycle, a_physicsWorld, a_worldScale);
m_view = a_view;
var position:b2Vec2 = m_rigidBody.GetPosition().Copy();
position.Multiply(m_worldScale);
m_view.updatePosition(position);
m_view.updateRotation(a_rotation);
m_blinkTimer.addEventListener(TimerEvent.TIMER, resolveBlinkTimer);
m_view.getDisplayObject().addEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
private function resolveBlinkTimer(a_event:TimerEvent):void{
m_isElectrified = !(m_isElectrified);
m_rigidBody.SetActive(m_isElectrified);
if (m_isElectrified){
m_view.show();
} else {
m_view.hide();
};
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getDisplayObject());
}
public function update(a_msElapsed:Number):void{
}
public function destroy():void{
m_blinkTimer.removeEventListener(TimerEvent.TIMER, resolveBlinkTimer);
m_blinkTimer.stop();
m_rigidBody.DestroyFixture(m_fixture);
m_physicsWorld.DestroyBody(m_rigidBody);
}
private function resolveAddedToStage(a_event:Event):void{
m_blinkTimer.start();
m_view.getDisplayObject().removeEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
}
}//package game.component.control
Section 345
//ExtraLifeTokenControl (game.component.control.ExtraLifeTokenControl)
package game.component.control {
import Box2D.Dynamics.*;
import game.component.control.iface.*;
public class ExtraLifeTokenControl extends TokenControl {
public function ExtraLifeTokenControl(a_view:IToken, a_x:Number, a_y:Number, a_physicsWorld:b2World, a_worldScale:Number){
super(a_view, a_x, a_y, a_physicsWorld, a_worldScale, 0);
m_view.getDisplayObject().rotation = 0;
}
override public function update(a_msElapsed:Number):void{
}
}
}//package game.component.control
Section 346
//MovingAnchorControl (game.component.control.MovingAnchorControl)
package game.component.control {
import flash.display.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import game.component.model.*;
public class MovingAnchorControl extends MovingAnchorModel implements IGameComponent {
private var m_view:IMovingAnchor;
public function MovingAnchorControl(a_view:IMovingAnchor, a_x:Number, a_y:Number, a_moveX:Number, a_moveY:Number, a_speed:Number, a_hitRadius:Number, a_physicsWorld:b2World, a_worldScale:Number){
super(a_x, a_y, a_moveX, a_moveY, a_speed, a_hitRadius, a_physicsWorld, a_worldScale);
m_view = a_view;
var position:b2Vec2 = m_rigidBody.GetPosition();
m_view.updatePosition(b2Vec2.Make((position.x * m_worldScale), (position.y * m_worldScale)));
m_view.scale = ((m_rigidBody.GetPosition().x < m_rallyPoints[m_currentRallyPoint].x)) ? -1 : 1;
var anotherB2Hack:b2Vec2 = m_view.getAnchorPosition().Copy();
anotherB2Hack.Multiply((1 / m_worldScale));
m_rigidBody.GetPosition().Add(anotherB2Hack);
}
public function update(a_msElapsed:Number):void{
var moveDirection:b2Vec2 = m_rallyPoints[m_currentRallyPoint].Copy();
moveDirection.Subtract(m_rigidBody.GetPosition());
moveDirection.Normalize();
moveDirection.Multiply(((m_speed * a_msElapsed) / 1000));
m_rigidBody.SetPosition(b2Vec2.Make((m_rigidBody.GetPosition().x + moveDirection.x), (m_rigidBody.GetPosition().y + moveDirection.y)));
m_view.updatePosition(b2Vec2.Make(((m_rigidBody.GetPosition().x * m_worldScale) - m_view.getAnchorPosition().x), ((m_rigidBody.GetPosition().y * m_worldScale) - m_view.getAnchorPosition().y)));
if (Math.abs((m_rigidBody.GetPosition().x - m_rallyPoints[m_currentRallyPoint].x)) <= 0.1){
m_view.scale = -(m_view.scale);
m_currentRallyPoint = ((m_currentRallyPoint == 0)) ? 1 : 0;
};
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getDisplayObject());
}
public function playDetach():void{
m_view.playDetach();
}
public function playAttach():void{
m_view.playAttach();
}
public function destroy():void{
m_rigidBody.DestroyFixture(m_fixture);
m_physicsWorld.DestroyBody(m_rigidBody);
}
public function get rigidBody():b2Body{
return (m_rigidBody);
}
}
}//package game.component.control
Section 347
//PlayerControl (game.component.control.PlayerControl)
package game.component.control {
import flash.events.*;
import flash.display.*;
import Box2D.Common.Math.*;
import com.greensock.events.*;
import com.greensock.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import fla.game.component.*;
import game.component.model.*;
public class PlayerControl extends PlayerModel implements IGameComponent {
private var m_cachedMoveX:Number;
private var m_cachedMoveY:Number;
private var m_view:IPlayer;
public function PlayerControl(a_view:IPlayer, a_x:Number, a_y:Number, a_canvas:DisplayObjectContainer, a_physicsWorld:b2World, a_worldScale:Number, a_joint:PlayerJointControl=null){
super(a_x, a_y, a_canvas, a_physicsWorld, a_worldScale, a_joint);
m_view = a_view;
(m_view.getDisplayObject() as MovieClip).gotoAndStop("static");
m_view.updatePosition(b2Vec2.Make(a_x, a_y));
m_view.getDisplayObject().addEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
public function get forceToDetach():Number{
return (FORCE_TO_DETACH);
}
public function set isTweening(a_value:Boolean):void{
m_isTweening = a_value;
}
public function get flinging():Boolean{
return (m_flinging);
}
public function update(a_msElapsed:Number):void{
var position:b2Vec2;
var x:Number;
var y:Number;
var distanceFromAttached:b2Vec2;
if (m_tongueJoint){
if (m_tongueJoint.attachedBody){
m_view.pointTo(b2Vec2.Make((m_tongueJoint.attachedBody.GetPosition().x * m_worldScale), (m_tongueJoint.attachedBody.GetPosition().y * m_worldScale)));
};
if (((((m_tongueJoint.attachedBody) && ((m_tongueJoint.attachedBody.GetUserData() is MovingAnchorControl)))) && (m_clientControlled))){
x = (((m_cachedMoveX - m_canvas.x) / m_worldScale) + m_grabOffset.x);
y = (((m_cachedMoveY - m_canvas.y) / m_worldScale) + m_grabOffset.y);
m_rigidBody.SetPosition(b2Vec2.Make(x, y));
distanceFromAttached = m_rigidBody.GetPosition().Copy();
distanceFromAttached.Subtract(m_tongueJoint.attachedBody.GetPosition());
if (distanceFromAttached.Length() > MAX_PULL_LENGTH){
distanceFromAttached.Normalize();
distanceFromAttached.Multiply(MAX_PULL_LENGTH);
distanceFromAttached.Add(m_tongueJoint.attachedBody.GetPosition());
m_rigidBody.SetPosition(distanceFromAttached);
};
};
m_rigidBody.ApplyForce(m_tongueJoint.springForce, m_rigidBody.GetPosition());
position = m_rigidBody.GetPosition().Copy();
position.Multiply(m_worldScale);
if (!m_isTweening){
m_view.updatePosition(position);
};
};
}
private function resolveMouseMove(a_event:MouseEvent):void{
m_cachedMoveX = a_event.stageX;
m_cachedMoveY = a_event.stageY;
var x:Number = (((a_event.stageX - m_canvas.x) / m_worldScale) + m_grabOffset.x);
var y:Number = (((a_event.stageY - m_canvas.y) / m_worldScale) + m_grabOffset.y);
m_rigidBody.SetPosition(b2Vec2.Make(x, y));
var distanceFromAttached:b2Vec2 = m_rigidBody.GetPosition().Copy();
distanceFromAttached.Subtract(m_tongueJoint.attachedBody.GetPosition());
if (distanceFromAttached.Length() > MAX_PULL_LENGTH){
distanceFromAttached.Normalize();
distanceFromAttached.Multiply(MAX_PULL_LENGTH);
distanceFromAttached.Add(m_tongueJoint.attachedBody.GetPosition());
m_rigidBody.SetPosition(distanceFromAttached);
};
}
public function set tongueJoint(value:PlayerJointControl):void{
m_tongueJoint = value;
}
private function resolveMouseUp(a_event:MouseEvent):void{
m_clientControlled = false;
m_rigidBody.SetLinearDamping(0);
if (m_tongueJoint.springForce.Length() > FORCE_TO_DETACH){
m_tongueJoint.detach();
m_flinging = true;
m_inputEnabled = false;
};
m_rigidBody.ApplyForce(m_tongueJoint.springForce, m_rigidBody.GetPosition());
if (m_view.getDisplayObject().stage.hasEventListener(MouseEvent.MOUSE_MOVE)){
m_view.getDisplayObject().stage.removeEventListener(MouseEvent.MOUSE_MOVE, resolveMouseMove);
};
if (m_view.getDisplayObject().stage.hasEventListener(MouseEvent.MOUSE_UP)){
m_view.getDisplayObject().stage.removeEventListener(MouseEvent.MOUSE_UP, resolveMouseUp);
};
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getDisplayObject());
}
public function get inputEnabled():Boolean{
return (m_inputEnabled);
}
public function set flinging(value:Boolean):void{
m_flinging = value;
}
private function resolveMouseDown(a_event:MouseEvent):void{
if (!m_inputEnabled){
return;
};
m_cachedMoveX = a_event.stageX;
m_cachedMoveY = a_event.stageY;
m_clientControlled = true;
m_rigidBody.SetLinearDamping(1000);
m_grabOffset = b2Vec2.Make((m_rigidBody.GetPosition().x - ((a_event.stageX - m_canvas.x) / m_worldScale)), (m_rigidBody.GetPosition().y - ((a_event.stageY - m_canvas.y) / m_worldScale)));
if (((m_view.getDisplayObject()) && (m_view.getDisplayObject().stage))){
m_view.getDisplayObject().stage.addEventListener(MouseEvent.MOUSE_MOVE, resolveMouseMove);
m_view.getDisplayObject().stage.addEventListener(MouseEvent.MOUSE_UP, resolveMouseUp);
};
}
public function removeClientControl():void{
m_clientControlled = false;
m_rigidBody.SetLinearDamping(0);
m_view.getDisplayObject().stage.removeEventListener(MouseEvent.MOUSE_MOVE, resolveMouseMove);
m_view.getDisplayObject().stage.removeEventListener(MouseEvent.MOUSE_UP, resolveMouseUp);
}
public function get rigidBody():b2Body{
return (m_rigidBody);
}
public function set inputEnabled(a_value:Boolean):void{
m_inputEnabled = a_value;
}
private function resolveAddedToStage(a_event:Event):void{
m_view.getDisplayObject().parent.addEventListener(MouseEvent.MOUSE_DOWN, resolveMouseDown, true);
m_view.getDisplayObject().removeEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
public function get tongueJoint():PlayerJointControl{
return (m_tongueJoint);
}
public function get clientControlled():Boolean{
return (m_clientControlled);
}
public function destroy():void{
m_rigidBody.DestroyFixture(m_fixture);
m_physicsWorld.DestroyBody(m_rigidBody);
m_tongueJoint.destroy();
m_view.removeEventListener(MouseEvent.MOUSE_DOWN, resolveMouseDown);
}
public function hackChangePlayerPosition(a_position:b2Vec2):void{
var closure:Function;
var a_position = a_position;
m_rigidBody.SetLinearVelocity(b2Vec2.Make(0, 0));
m_rigidBody.SetActive(false);
(m_view.getDisplayObject() as Player).gotoAndPlay("teleport");
closure = function (a_event:Event):void{
var tween:TweenMax;
var closure2:Function;
var a_event = a_event;
m_view.getDisplayObject().removeEventListener(Event.COMPLETE, closure);
m_rigidBody.SetPosition(a_position);
(m_view.getDisplayObject() as Player).gotoAndStop("static");
m_view.getDisplayObject().scaleX = 0;
m_view.getDisplayObject().scaleY = 0;
tween = new TweenMax(m_view.getDisplayObject(), 1, {scaleX:1, scaleY:1});
closure2 = function (a_event:Event):void{
m_rigidBody.SetActive(true);
tween.removeEventListener(TweenEvent.COMPLETE, closure2);
};
tween.addEventListener(TweenEvent.COMPLETE, closure2);
};
m_view.getDisplayObject().addEventListener(Event.COMPLETE, closure);
}
}
}//package game.component.control
Section 348
//PlayerJointControl (game.component.control.PlayerJointControl)
package game.component.control {
import flash.display.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import game.component.model.*;
public class PlayerJointControl extends PlayerJointModel implements IGameComponent {
private var m_shouldPlayStretch:Boolean;
private var m_view:IPlayerJoint;
public function PlayerJointControl(a_view:IPlayerJoint, a_playerBody:b2Body, a_physicsWorld:b2World){
super(a_playerBody, a_physicsWorld);
m_view = a_view;
m_shouldPlayStretch = true;
}
public function attachTo(a_body:b2Body):void{
m_attachedBody = a_body;
}
public function destroy():void{
}
public function get attachedBody():b2Body{
return (m_attachedBody);
}
public function update(a_msElapsed:Number):void{
var damping:b2Vec2;
var springLength:b2Vec2;
if (!m_attachedBody){
m_view.hide();
m_springForce = b2Vec2.Make(0, 0);
return;
};
m_view.show();
m_view.updatePosition(m_playerBody.GetPosition());
m_view.pointTo(m_attachedBody.GetPosition());
m_springForce = m_attachedBody.GetPosition().Copy();
m_springForce.Subtract(m_playerBody.GetPosition());
if (m_springForce.Length() > SPRING_LENGTH){
if (((m_shouldPlayStretch) && ((m_playerBody.GetUserData() as PlayerControl).clientControlled))){
JuicyFruitFlavorFling.instance.sfxManager.playSound("stretch");
m_shouldPlayStretch = false;
};
damping = m_playerBody.GetLinearVelocity().Copy();
springLength = m_springForce.Copy();
springLength.Normalize();
springLength.Multiply(SPRING_LENGTH);
m_springForce.Subtract(springLength);
m_springForce.Multiply(SPRING_CONSTANT);
damping.Multiply(SPRING_DAMPING);
m_springForce.Subtract(damping);
} else {
if (!m_shouldPlayStretch){
m_shouldPlayStretch = true;
};
};
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getViewDisplayObject());
}
public function detach():void{
m_attachedBody = null;
}
public function get springForce():b2Vec2{
return (m_springForce);
}
}
}//package game.component.control
Section 349
//PlayerPathControl (game.component.control.PlayerPathControl)
package game.component.control {
import flash.display.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import game.component.model.*;
public class PlayerPathControl extends PlayerPathModel implements IGameComponent {
private var m_view:IPlayerPath;
public function PlayerPathControl(a_view:IPlayerPath, a_step:Number, a_stepCount:Number, a_player:PlayerControl, a_world:b2World, a_worldScale:Number){
super(a_step, a_stepCount, a_player, a_world, a_worldScale);
m_view = a_view;
}
public function update(a_msElapsed:Number):void{
var endPosition:b2Vec2;
var gravitationalOffset:b2Vec2;
var velocityOffset:b2Vec2;
m_view.clearAllPoints();
m_view.updatePosition(b2Vec2.Make((m_player.rigidBody.GetPosition().x * m_worldScale), (m_player.rigidBody.GetPosition().y * m_worldScale)));
if (((!(m_player.clientControlled)) || ((m_player.tongueJoint.springForce.Length() < m_player.forceToDetach)))){
return;
};
var velocity:b2Vec2 = m_player.tongueJoint.springForce.Copy();
velocity.Multiply((1 / m_player.rigidBody.GetMass()));
var i:Number = 0;
while (i <= m_stepCount) {
velocityOffset = velocity.Copy();
velocityOffset.Multiply((m_step * i));
gravitationalOffset = m_world.GetGravity().Copy();
gravitationalOffset.Multiply(212);
gravitationalOffset.Multiply(Math.pow((m_step * i), 2));
endPosition = b2Vec2.Make(0, 0);
endPosition.Add(velocityOffset);
endPosition.Add(gravitationalOffset);
m_view.addPointAt((endPosition.x * m_worldScale), (endPosition.y * m_worldScale));
i++;
};
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getViewDisplayObject());
}
public function destroy():void{
}
}
}//package game.component.control
Section 350
//RotatingSurfaceControl (game.component.control.RotatingSurfaceControl)
package game.component.control {
import flash.display.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import game.component.model.*;
public class RotatingSurfaceControl extends RotatingSurfaceModel implements IGameComponent {
private var m_view:ISurface;
public function RotatingSurfaceControl(a_view:ISurface, a_x:Number, a_y:Number, a_width:Number, a_height:Number, a_rotationRate:Number, a_physicsWorld:b2World, a_worldScale:Number){
super(a_x, a_y, a_width, a_height, a_rotationRate, a_physicsWorld, a_worldScale);
m_view = a_view;
m_view.width = a_width;
m_view.height = a_height;
var position:b2Vec2 = m_rigidBody.GetPosition().Copy();
position.Multiply(m_worldScale);
m_view.updatePosition(position);
}
public function update(a_msElapsed:Number):void{
var rotation:Number = (((m_view.rotation * Math.PI) / 180) + (m_rotationRate * (a_msElapsed / 1000)));
m_view.updateRotation(rotation);
m_rigidBody.SetAngle(rotation);
}
public function destroy():void{
m_rigidBody.DestroyFixture(m_fixture);
m_physicsWorld.DestroyBody(m_rigidBody);
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getDisplayObject());
}
}
}//package game.component.control
Section 351
//SpringboardControl (game.component.control.SpringboardControl)
package game.component.control {
import flash.display.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import game.component.model.*;
public class SpringboardControl extends SpringboardModel implements IGameComponent {
private var m_view:ISurface;
public function SpringboardControl(a_view:ISurface, a_x:Number, a_y:Number, a_rotation:Number, a_physicsWorld:b2World, a_worldScale:Number, a_bonusForce:Number){
m_view = a_view;
super(a_x, a_y, m_view.width, m_view.height, a_rotation, a_physicsWorld, a_worldScale, a_bonusForce);
var position:b2Vec2 = m_rigidBody.GetPosition().Copy();
position.Multiply(m_worldScale);
m_view.updatePosition(position);
m_view.updateRotation(a_rotation);
}
public function update(a_msElapsed:Number):void{
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getDisplayObject());
}
public function destroy():void{
m_rigidBody.DestroyFixture(m_fixture);
m_physicsWorld.DestroyBody(m_rigidBody);
}
public function playBounce():void{
(m_view.getDisplayObject() as MovieClip).gotoAndPlay("bounce");
}
public function get bonusForce():Number{
return (m_bonusForce);
}
}
}//package game.component.control
Section 352
//SurfaceControl (game.component.control.SurfaceControl)
package game.component.control {
import flash.display.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import game.component.model.*;
public class SurfaceControl extends SurfaceModel implements IGameComponent {
private var m_view:ISurface;
public function SurfaceControl(a_view:ISurface, a_x:Number, a_y:Number, a_width:Number, a_height:Number, a_rotation:Number, a_physicsWorld:b2World, a_worldScale:Number){
super(a_x, a_y, a_width, a_height, a_rotation, a_physicsWorld, a_worldScale);
m_view = a_view;
m_view.width = a_width;
m_view.height = a_height;
var position:b2Vec2 = m_rigidBody.GetPosition().Copy();
position.Multiply(m_worldScale);
m_view.updatePosition(position);
m_view.updateRotation(a_rotation);
}
public function update(a_msElapsed:Number):void{
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getDisplayObject());
}
public function destroy():void{
m_rigidBody.DestroyFixture(m_fixture);
m_physicsWorld.DestroyBody(m_rigidBody);
}
}
}//package game.component.control
Section 353
//TeleportSurfaceControl (game.component.control.TeleportSurfaceControl)
package game.component.control {
import flash.display.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import game.component.model.*;
public class TeleportSurfaceControl extends TeleportSurfaceModel implements IGameComponent {
private var m_rotation:Number;// = 0
private var m_view:ISurface;
private static const ROTATION_RATE:Number = 0.01;
public function TeleportSurfaceControl(a_view:ISurface, a_x:Number, a_y:Number, a_physicsWorld:b2World, a_worldScale:Number, a_destination:b2Vec2){
super(a_x, a_y, a_view.width, a_view.height, 0, a_physicsWorld, a_worldScale, a_destination);
m_view = a_view;
var position:b2Vec2 = m_rigidBody.GetPosition().Copy();
position.Multiply(m_worldScale);
m_view.updatePosition(position);
}
public function update(a_msElapsed:Number):void{
m_view.updateRotation((m_rotation = (m_rotation + ROTATION_RATE)));
}
public function destroy():void{
m_rigidBody.DestroyFixture(m_fixture);
m_physicsWorld.DestroyBody(m_rigidBody);
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getDisplayObject());
}
public function get destination():b2Vec2{
return (m_destination);
}
}
}//package game.component.control
Section 354
//TimedAnchorControl (game.component.control.TimedAnchorControl)
package game.component.control {
import game.manager.*;
import flash.events.*;
import flash.display.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import flash.utils.*;
import game.component.model.*;
public class TimedAnchorControl extends TimedAnchorModel implements IGameComponent {
private var m_timer:Timer;
private var m_view:ITimedAnchor;
public function TimedAnchorControl(a_view:ITimedAnchor, a_canvas:DisplayObjectContainer, a_x:Number, a_y:Number, a_hitRadius:Number, a_physicsWorld:b2World, a_worldScale:Number, a_lifeSpan:Number){
super(a_canvas, a_x, a_y, a_hitRadius, a_physicsWorld, a_worldScale, a_lifeSpan);
m_view = a_view;
var position:b2Vec2 = m_rigidBody.GetPosition().Copy();
position.Multiply(m_worldScale);
m_view.updatePosition(position);
m_timer = new Timer(100);
m_timer.addEventListener(TimerEvent.TIMER, resolveTimer);
}
private function resolveTimer(a_event:Event):void{
(m_view.getDisplayObject() as MovieClip).gotoAndStop(1);
m_view.getDisplayObject().visible = false;
m_timer.stop();
}
public function destroy():void{
m_rigidBody.DestroyFixture(m_fixture);
m_physicsWorld.DestroyBody(m_rigidBody);
}
public function get active():Boolean{
return (m_active);
}
public function playDetach():void{
m_view.playDetach();
}
public function set attached(a_value:Boolean):void{
m_attached = a_value;
}
public function set active(a_value:Boolean):void{
m_active = a_value;
}
public function update(a_msElapsed:Number):void{
if (m_attached){
m_lifeSpan = (m_lifeSpan - (a_msElapsed / 1000));
m_view.fadeTo((0.5 + ((1 - (m_lifeSpan / m_totalLifeSpan)) * 0.5)));
if (m_lifeSpan <= 0){
m_canvas.dispatchEvent(new GameEvent(GameEvent.ANCHOR_DESTROYED, false, false, this));
m_attached = false;
(m_view.getDisplayObject() as MovieClip).gotoAndStop(2);
m_timer.start();
};
};
}
public function get rigidBody():b2Body{
return (m_rigidBody);
}
public function resetLifeSpan():void{
m_lifeSpan = m_totalLifeSpan;
m_view.fadeTo(0.5);
(m_view.getDisplayObject() as MovieClip).gotoAndStop(1);
m_view.getDisplayObject().visible = true;
}
public function playAttach():void{
m_view.playAttach();
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getDisplayObject());
}
}
}//package game.component.control
Section 355
//TokenControl (game.component.control.TokenControl)
package game.component.control {
import flash.display.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import fla.game.component.*;
import game.component.model.*;
public class TokenControl extends TokenModel implements IGameComponent {
private var m_rotationDirection:Number;
private var m_rotation:Number;
protected var m_view:IToken;
private static const MAX_ROTATION:Number = 0.785398163397448;
private static const ROTATION_RATE:Number = 0.01;
public function TokenControl(a_view:IToken, a_x:Number, a_y:Number, a_physicsWorld:b2World, a_worldScale:Number, a_pointValue:Number){
super(a_x, a_y, a_physicsWorld, a_worldScale, a_pointValue);
m_view = a_view;
m_view.updatePosition(b2Vec2.Make((m_rigidBody.GetPosition().x * m_worldScale), (m_rigidBody.GetPosition().y * m_worldScale)));
m_rotation = (Math.random() * MAX_ROTATION);
m_view.getDisplayObject().rotation = ((m_rotation * 180) / Math.PI);
m_rotationDirection = 1;
}
public function get pointValue():Number{
return (m_pointValue);
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getDisplayObject());
}
public function get rigidBody():b2Body{
return (m_rigidBody);
}
public function update(a_msElapsed:Number):void{
if (Math.abs(m_rotation) >= MAX_ROTATION){
m_rotationDirection = -(m_rotationDirection);
};
m_rotation = (m_rotation + (m_rotationDirection * ROTATION_RATE));
m_view.getDisplayObject().rotation = ((m_rotation * 180) / Math.PI);
}
public function destroy():void{
m_rigidBody.DestroyFixture(m_fixture);
m_physicsWorld.DestroyBody(m_rigidBody);
}
public function getParticle():Class{
switch ((m_view.getDisplayObject() as Star).anim.type.currentFrame){
case 1:
case 6:
case 7:
case 8:
return (RedParticle);
case 2:
case 4:
return (YellowParticle);
case 3:
return (GreenParticle);
case 5:
return (PurpleParticle);
};
return (null);
}
}
}//package game.component.control
Section 356
//UFOControl (game.component.control.UFOControl)
package game.component.control {
import flash.events.*;
import flash.display.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import game.component.model.*;
public class UFOControl extends UFOModel implements IGameComponent {
private var m_view:IUFO;
public function UFOControl(a_view:IUFO, a_x:Number, a_y:Number, a_length:Number, a_blinkCycle:Number, a_physicsWorld:b2World, a_worldScale:Number){
super(a_x, a_y, a_length, a_blinkCycle, a_physicsWorld, a_worldScale);
m_view = a_view;
m_view.updatePosition(b2Vec2.Make(a_x, a_y));
m_view.height = a_length;
m_blinkTimer.addEventListener(TimerEvent.TIMER, resolveBlinkTimer);
m_view.getDisplayObject().addEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
public function get isBeamActive():Boolean{
return (m_isBeamActive);
}
public function get blinkCycle():Number{
return (m_blinkCycle);
}
public function getViewDisplayObject():DisplayObject{
return (m_view.getDisplayObject());
}
private function resolveAddedToStage(a_event:Event):void{
m_blinkTimer.start();
}
public function update(a_msElapsed:Number):void{
}
private function resolveBlinkTimer(a_event:TimerEvent):void{
m_isBeamActive = !(m_isBeamActive);
m_rigidBody.SetActive(m_isBeamActive);
if (m_isBeamActive){
m_view.showBeam();
} else {
m_view.hideBeam();
};
}
public function destroy():void{
m_rigidBody.DestroyFixture(m_fixture);
m_physicsWorld.DestroyBody(m_rigidBody);
}
public function getPosition():b2Vec2{
return (m_rigidBody.GetPosition());
}
}
}//package game.component.control
Section 357
//AnchorModel (game.component.model.AnchorModel)
package game.component.model {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class AnchorModel {
protected var m_fixture:b2Fixture;
protected var m_worldScale:Number;
protected var m_rigidBody:b2Body;
protected var m_physicsWorld:b2World;
private static const BODY_DENSITY:Number = 1;
public function AnchorModel(a_x:Number, a_y:Number, a_hitRadius:Number, a_physicsWorld:b2World, a_worldScale:Number){
var bodyDefinition:b2BodyDef;
super();
m_physicsWorld = a_physicsWorld;
m_worldScale = a_worldScale;
bodyDefinition = new b2BodyDef();
bodyDefinition.type = b2Body.b2_kinematicBody;
m_rigidBody = m_physicsWorld.CreateBody(bodyDefinition);
m_rigidBody.SetPosition(b2Vec2.Make((a_x / a_worldScale), (a_y / a_worldScale)));
m_rigidBody.SetUserData(this);
m_fixture = m_rigidBody.CreateFixture2(new b2CircleShape(a_hitRadius), BODY_DENSITY);
m_fixture.SetSensor(true);
}
}
}//package game.component.model
Section 358
//ColorTokenModel (game.component.model.ColorTokenModel)
package game.component.model {
import Box2D.Dynamics.*;
public class ColorTokenModel extends TokenModel {
protected var m_color:Number;
public function ColorTokenModel(a_x:Number, a_y:Number, a_physicsWorld:b2World, a_worldScale:Number, a_color:Number){
super(a_x, a_y, a_physicsWorld, a_worldScale, 0);
m_color = a_color;
}
}
}//package game.component.model
Section 359
//ElectrifiedSurfaceModel (game.component.model.ElectrifiedSurfaceModel)
package game.component.model {
import Box2D.Dynamics.*;
import flash.utils.*;
public class ElectrifiedSurfaceModel extends SurfaceModel {
protected var m_blinkCycle:Number;
protected var m_blinkTimer:Timer;
protected var m_isElectrified:Boolean;
public function ElectrifiedSurfaceModel(a_x:Number, a_y:Number, a_width:Number, a_height:Number, a_rotation:Number, a_blinkCycle:Number, a_physicsWorld:b2World, a_worldScale:Number){
super(a_x, a_y, a_width, a_height, a_rotation, a_physicsWorld, a_worldScale);
m_blinkCycle = a_blinkCycle;
m_blinkTimer = new Timer((m_blinkCycle * 1000));
m_isElectrified = true;
m_fixture.SetSensor(true);
}
}
}//package game.component.model
Section 360
//MovingAnchorModel (game.component.model.MovingAnchorModel)
package game.component.model {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class MovingAnchorModel extends AnchorModel {
protected var m_speed:Number;
protected var m_rallyPoints:Array;
protected var m_currentRallyPoint:Number;
public function MovingAnchorModel(a_x:Number, a_y:Number, a_moveX:Number, a_moveY:Number, a_speed:Number, a_hitRadius:Number, a_physicsWorld:b2World, a_worldScale:Number){
super(a_x, a_y, a_hitRadius, a_physicsWorld, a_worldScale);
m_rallyPoints = new Array(b2Vec2.Make((a_x / m_worldScale), (a_y / m_worldScale)), b2Vec2.Make((a_moveX / m_worldScale), (a_moveY / m_worldScale)));
m_currentRallyPoint = 1;
m_speed = a_speed;
}
}
}//package game.component.model
Section 361
//PlayerJointModel (game.component.model.PlayerJointModel)
package game.component.model {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class PlayerJointModel {
protected var m_playerBody:b2Body;
protected var m_attachedBody:b2Body;
protected var m_springForce:b2Vec2;
protected var m_physicsWorld:b2World;
protected static const SPRING_DAMPING:Number = 30;
protected static const SPRING_CONSTANT:Number = 500;
protected static const SPRING_LENGTH:Number = 2;
public function PlayerJointModel(a_playerBody:b2Body, a_physicsWorld:b2World){
super();
m_physicsWorld = a_physicsWorld;
m_playerBody = a_playerBody;
m_springForce = b2Vec2.Make(0, 0);
}
}
}//package game.component.model
Section 362
//PlayerModel (game.component.model.PlayerModel)
package game.component.model {
import flash.display.*;
import game.component.control.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class PlayerModel {
protected var m_rigidBody:b2Body;
protected var m_inputEnabled:Boolean;
protected var m_worldScale:Number;
protected var m_clientControlled:Boolean;
protected var m_grabOffset:b2Vec2;
protected var m_isTweening:Boolean;// = false
protected var m_tongueJoint:PlayerJointControl;
protected var m_fixture:b2Fixture;
protected var m_flinging:Boolean;
protected var m_canvas:DisplayObjectContainer;
protected var m_physicsWorld:b2World;
protected static const FORCE_TO_DETACH:Number = 500;
private static const BODY_CIRCLE_RADIUS:Number = 0.5;
protected static const MAX_PULL_LENGTH:Number = 4;
private static const BODY_DENSITY:Number = 2;
public function PlayerModel(a_x:Number, a_y:Number, a_canvas:DisplayObjectContainer, a_physicsWorld:b2World, a_worldScale:Number, a_tongue:PlayerJointControl){
var bodyDefinition:b2BodyDef;
super();
var massData:b2MassData = new b2MassData();
m_physicsWorld = a_physicsWorld;
m_worldScale = a_worldScale;
bodyDefinition = new b2BodyDef();
bodyDefinition.type = b2Body.b2_dynamicBody;
m_rigidBody = m_physicsWorld.CreateBody(bodyDefinition);
m_rigidBody.SetPosition(new b2Vec2((a_x / a_worldScale), (a_y / a_worldScale)));
m_rigidBody.SetUserData(this);
m_fixture = m_rigidBody.CreateFixture2(new b2CircleShape(BODY_CIRCLE_RADIUS), BODY_DENSITY);
m_tongueJoint = a_tongue;
m_canvas = a_canvas;
m_flinging = (m_clientControlled = (m_inputEnabled = false));
}
}
}//package game.component.model
Section 363
//PlayerPathModel (game.component.model.PlayerPathModel)
package game.component.model {
import game.component.control.*;
import Box2D.Dynamics.*;
public class PlayerPathModel {
protected var m_world:b2World;
protected var m_stepCount:Number;
protected var m_player:PlayerControl;
protected var m_worldScale:Number;
protected var m_step:Number;
public function PlayerPathModel(a_step:Number, a_stepCount:Number, a_player:PlayerControl, a_world:b2World, a_worldScale:Number){
super();
m_world = a_world;
m_worldScale = a_worldScale;
m_player = a_player;
m_step = (a_step / a_worldScale);
m_stepCount = a_stepCount;
}
}
}//package game.component.model
Section 364
//RotatingSurfaceModel (game.component.model.RotatingSurfaceModel)
package game.component.model {
import Box2D.Dynamics.*;
public class RotatingSurfaceModel extends SurfaceModel {
protected var m_rotationRate:Number;
public function RotatingSurfaceModel(a_x:Number, a_y:Number, a_width:Number, a_height:Number, a_rotationRate:Number, a_physicsWorld:b2World, a_worldScale:Number){
super(a_x, a_y, a_width, a_height, 0, a_physicsWorld, a_worldScale);
m_rotationRate = a_rotationRate;
}
}
}//package game.component.model
Section 365
//SpringboardModel (game.component.model.SpringboardModel)
package game.component.model {
import Box2D.Dynamics.*;
public class SpringboardModel extends SurfaceModel {
protected var m_bonusForce:Number;
public function SpringboardModel(a_x:Number, a_y:Number, a_width:Number, a_height:Number, a_rotation:Number, a_physicsWorld:b2World, a_worldScale:Number, a_bonusForce:Number){
super(a_x, a_y, a_width, a_height, a_rotation, a_physicsWorld, a_worldScale);
m_bonusForce = a_bonusForce;
m_fixture.SetRestitution(1);
}
}
}//package game.component.model
Section 366
//SurfaceModel (game.component.model.SurfaceModel)
package game.component.model {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class SurfaceModel {
protected var m_fixture:b2Fixture;
protected var m_worldScale:Number;
protected var m_rigidBody:b2Body;
protected var m_physicsWorld:b2World;
private static const BODY_DENSITY:Number = 1;
public function SurfaceModel(a_x:Number, a_y:Number, a_width:Number, a_height:Number, a_rotation:Number, a_physicsWorld:b2World, a_worldScale:Number){
super();
var bodyDefinition:b2BodyDef = new b2BodyDef();
bodyDefinition.type = b2Body.b2_kinematicBody;
m_physicsWorld = a_physicsWorld;
m_worldScale = a_worldScale;
m_rigidBody = m_physicsWorld.CreateBody(bodyDefinition);
m_rigidBody.SetPosition(b2Vec2.Make((a_x / m_worldScale), (a_y / m_worldScale)));
m_rigidBody.SetAngle(a_rotation);
m_rigidBody.SetUserData(this);
m_fixture = m_rigidBody.CreateFixture2(b2PolygonShape.AsBox((a_width / (m_worldScale * 2)), (a_height / (m_worldScale * 2))), BODY_DENSITY);
}
}
}//package game.component.model
Section 367
//TeleportSurfaceModel (game.component.model.TeleportSurfaceModel)
package game.component.model {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class TeleportSurfaceModel extends SurfaceModel {
protected var m_destination:b2Vec2;
public function TeleportSurfaceModel(a_x:Number, a_y:Number, a_width:Number, a_height:Number, a_rotation:Number, a_physicsWorld:b2World, a_worldScale:Number, a_destination:b2Vec2){
super(a_x, a_y, a_width, a_height, a_rotation, a_physicsWorld, a_worldScale);
m_destination = a_destination;
m_rigidBody.DestroyFixture(m_fixture);
m_fixture = m_rigidBody.CreateFixture2(new b2CircleShape((a_width / (a_worldScale * 4))), 1);
m_fixture.SetSensor(true);
}
}
}//package game.component.model
Section 368
//TimedAnchorModel (game.component.model.TimedAnchorModel)
package game.component.model {
import flash.display.*;
import Box2D.Dynamics.*;
public class TimedAnchorModel extends AnchorModel {
protected var m_active:Boolean;
protected var m_attached:Boolean;
protected var m_lifeSpan:Number;
protected var m_canvas:DisplayObjectContainer;
protected var m_totalLifeSpan:Number;
public function TimedAnchorModel(a_canvas:DisplayObjectContainer, a_x:Number, a_y:Number, a_hitRadius:Number, a_physicsWorld:b2World, a_worldScale:Number, a_lifeSpan:Number){
super(a_x, a_y, a_hitRadius, a_physicsWorld, a_worldScale);
m_canvas = a_canvas;
m_lifeSpan = (m_totalLifeSpan = a_lifeSpan);
m_attached = false;
m_active = true;
}
}
}//package game.component.model
Section 369
//TokenModel (game.component.model.TokenModel)
package game.component.model {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class TokenModel {
protected var m_pointValue:Number;
protected var m_fixture:b2Fixture;
protected var m_worldScale:Number;
protected var m_rigidBody:b2Body;
protected var m_physicsWorld:b2World;
private static const BODY_DENSITY:Number = 1;
private static const BODY_CIRCLE_RADIUS:Number = 1;
public function TokenModel(a_x:Number, a_y:Number, a_physicsWorld:b2World, a_worldScale:Number, a_pointValue:Number){
super();
var bodyDefinition:b2BodyDef = new b2BodyDef();
bodyDefinition.type = b2Body.b2_kinematicBody;
m_physicsWorld = a_physicsWorld;
m_worldScale = a_worldScale;
m_rigidBody = m_physicsWorld.CreateBody(bodyDefinition);
m_rigidBody.SetPosition(b2Vec2.Make((a_x / m_worldScale), (a_y / m_worldScale)));
m_rigidBody.SetUserData(this);
m_fixture = m_rigidBody.CreateFixture2(new b2CircleShape(BODY_CIRCLE_RADIUS), BODY_DENSITY);
m_fixture.SetSensor(true);
m_pointValue = a_pointValue;
}
}
}//package game.component.model
Section 370
//UFOModel (game.component.model.UFOModel)
package game.component.model {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import flash.utils.*;
public class UFOModel {
protected var m_rigidBody:b2Body;
protected var m_physicsWorld:b2World;
protected var m_worldScale:Number;
protected var m_isBeamActive:Boolean;
protected var m_fixture:b2Fixture;
protected var m_blinkTimer:Timer;
protected var m_blinkCycle:Number;
private static const BEAM_INDENT_TOP:Number = 40;
private static const BEAM_OFFSET:Number = 10;
private static const BEAM_WIDTH:Number = 84.5;
private static const BODY_DENSITY:Number = 1;
public function UFOModel(a_x:Number, a_y:Number, a_length:Number, a_blinkCycle:Number, a_physicsWorld:b2World, a_worldScale:Number){
super();
var bodyDefinition:b2BodyDef = new b2BodyDef();
bodyDefinition.type = b2Body.b2_staticBody;
m_physicsWorld = a_physicsWorld;
m_worldScale = a_worldScale;
m_rigidBody = m_physicsWorld.CreateBody(bodyDefinition);
m_rigidBody.SetPosition(b2Vec2.Make((a_x / m_worldScale), (a_y / m_worldScale)));
m_rigidBody.SetUserData(this);
var beamWidth:Number = (BEAM_WIDTH / m_worldScale);
var beamIndent:Number = (BEAM_INDENT_TOP / m_worldScale);
var beamOffset:Number = (BEAM_OFFSET / m_worldScale);
var beamVeritces:Array = new Array(b2Vec2.Make((beamIndent - (beamWidth / 2)), beamOffset), b2Vec2.Make(-((beamWidth / 2)), ((a_length / m_worldScale) + beamOffset)), b2Vec2.Make((beamWidth / 2), ((a_length / m_worldScale) + beamOffset)), b2Vec2.Make(((beamWidth / 2) - beamIndent), beamOffset));
var beamShape:b2PolygonShape = new b2PolygonShape();
beamShape.SetAsArray(beamVeritces, beamVeritces.length);
m_fixture = m_rigidBody.CreateFixture2(beamShape, BODY_DENSITY);
m_fixture.SetSensor(true);
m_blinkCycle = a_blinkCycle;
m_blinkTimer = new Timer((m_blinkCycle * 1000));
m_isBeamActive = false;
}
}
}//package game.component.model
Section 371
//AnchorView (game.component.view.AnchorView)
package game.component.view {
import flash.display.*;
import Box2D.Common.Math.*;
import game.component.control.iface.*;
public class AnchorView implements IAnchor {
private var m_anchorAsset:MovieClip;
public function AnchorView(a_anchorAsset:MovieClip){
super();
m_anchorAsset = a_anchorAsset;
}
public function playAttach():void{
m_anchorAsset.gotoAndPlay("attach");
}
public function updatePosition(a_position:b2Vec2):void{
m_anchorAsset.x = a_position.x;
m_anchorAsset.y = a_position.y;
}
public function playDetach():void{
m_anchorAsset.gotoAndPlay("detach");
}
public function getDisplayObject():DisplayObject{
return (m_anchorAsset);
}
}
}//package game.component.view
Section 372
//ElectrifiedSurfaceView (game.component.view.ElectrifiedSurfaceView)
package game.component.view {
import game.component.control.iface.*;
import fla.game.component.*;
import ui.canvas.model.*;
public class ElectrifiedSurfaceView extends SurfaceView implements IElectrifiedSurface {
public function ElectrifiedSurfaceView(a_obstacleAsset:ElectrifiedSurface){
super(a_obstacleAsset);
a_obstacleAsset.filters = null;
a_obstacleAsset.nodes.filters = GameCanvasModel.filter;
}
public function hide():void{
(m_obstacleAsset as ElectrifiedSurface).electricity.visible = false;
}
public function show():void{
(m_obstacleAsset as ElectrifiedSurface).electricity.visible = true;
}
}
}//package game.component.view
Section 373
//MovingAnchorView (game.component.view.MovingAnchorView)
package game.component.view {
import flash.display.*;
import Box2D.Common.Math.*;
import game.component.control.iface.*;
import fla.game.component.*;
public class MovingAnchorView implements IMovingAnchor {
private var m_view:MovingAnchor;
private var m_scaleHack:Number;
public function MovingAnchorView(a_view:MovingAnchor){
super();
m_view = a_view;
}
public function playAttach():void{
m_view.anchor.gotoAndPlay("attach");
}
public function updatePosition(a_position:b2Vec2):void{
m_view.x = a_position.x;
m_view.y = a_position.y;
}
public function getAnchorPosition():b2Vec2{
return (b2Vec2.Make(m_view.anchor.x, m_view.anchor.y));
}
public function playDetach():void{
m_view.anchor.gotoAndPlay("detach");
}
public function get scale():Number{
return (m_scaleHack);
}
public function set scale(a_value:Number):void{
m_scaleHack = a_value;
if (a_value == -1){
m_view.gotoAndStop("right");
} else {
m_view.gotoAndStop("left");
};
}
public function getDisplayObject():DisplayObject{
return (m_view);
}
}
}//package game.component.view
Section 374
//PlayerJointView (game.component.view.PlayerJointView)
package game.component.view {
import flash.display.*;
import Box2D.Common.Math.*;
import game.component.control.iface.*;
import fla.game.component.*;
public class PlayerJointView implements IPlayerJoint {
private var m_worldScale:Number;
private var m_jointAsset:MovieClip;
private var m_hackHeight:Number;
public function PlayerJointView(a_jointAsset:MovieClip, a_worldScale:Number){
super();
m_jointAsset = a_jointAsset;
m_worldScale = a_worldScale;
m_hackHeight = (m_jointAsset as Tongue).height;
}
public function hide():void{
m_jointAsset.visible = false;
}
public function getViewDisplayObject():DisplayObject{
return (m_jointAsset);
}
public function pointTo(a_position:b2Vec2):void{
m_jointAsset.rotation = 0;
var desiredDirection:b2Vec2 = b2Vec2.Make(((m_jointAsset.x / m_worldScale) - a_position.x), (a_position.y - (m_jointAsset.y / m_worldScale)));
var currentDirection:b2Vec2 = b2Vec2.Make(Math.sin(((m_jointAsset.rotation * Math.PI) / 180)), Math.cos(((m_jointAsset.rotation * Math.PI) / 180)));
var angle:Number = (Math.atan2(currentDirection.y, currentDirection.x) - Math.atan2(desiredDirection.y, desiredDirection.x));
var distanceToPoint:b2Vec2 = a_position.Copy();
distanceToPoint.Subtract(b2Vec2.Make((m_jointAsset.x / m_worldScale), (m_jointAsset.y / m_worldScale)));
var dis:Number = ((distanceToPoint.Length() * m_worldScale) / m_hackHeight);
(m_jointAsset as Tongue).height = (distanceToPoint.Length() * m_worldScale);
m_jointAsset.rotation = ((angle * 180) / Math.PI);
}
public function updatePosition(a_position:b2Vec2):void{
m_jointAsset.x = (a_position.x * m_worldScale);
m_jointAsset.y = (a_position.y * m_worldScale);
}
public function show():void{
m_jointAsset.visible = true;
}
}
}//package game.component.view
Section 375
//PlayerPathView (game.component.view.PlayerPathView)
package game.component.view {
import flash.display.*;
import Box2D.Common.Math.*;
import game.component.control.iface.*;
public class PlayerPathView extends MovieClip implements IPlayerPath {
private var m_pointAssetClass:Class;
public function PlayerPathView(a_pointAssetClass:Class){
super();
m_pointAssetClass = a_pointAssetClass;
}
public function addPointAt(a_x:Number, a_y:Number):void{
var pointAsset:DisplayObject = new m_pointAssetClass();
pointAsset.x = a_x;
pointAsset.y = a_y;
addChild(pointAsset);
}
public function getViewDisplayObject():DisplayObject{
return (this);
}
public function clearAllPoints():void{
var i:Number = (numChildren - 1);
while (i >= 0) {
removeChild(getChildAt(i));
i--;
};
}
public function updatePosition(a_position:b2Vec2):void{
x = a_position.x;
y = a_position.y;
}
}
}//package game.component.view
Section 376
//PlayerView (game.component.view.PlayerView)
package game.component.view {
import flash.display.*;
import Box2D.Common.Math.*;
import game.component.control.iface.*;
public class PlayerView implements IPlayer {
private var m_playerAsset:MovieClip;
public function PlayerView(a_playerAsset:MovieClip){
super();
m_playerAsset = a_playerAsset;
}
public function getDisplayObject():DisplayObject{
return (m_playerAsset);
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void{
m_playerAsset.removeEventListener(type, listener, useCapture);
}
public function pointTo(a_position:b2Vec2):void{
var direction:b2Vec2 = b2Vec2.Make((a_position.x - m_playerAsset.x), (a_position.y - m_playerAsset.y));
direction.Normalize();
var rotation:Number = ((Math.acos(direction.y) * 180) / Math.PI);
rotation = ((m_playerAsset.x < a_position.x)) ? -(rotation) : rotation;
m_playerAsset.rotation = (rotation + 180);
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{
m_playerAsset.addEventListener(type, listener, useCapture, priority, useWeakReference);
}
public function updatePosition(a_position:b2Vec2):void{
m_playerAsset.x = a_position.x;
m_playerAsset.y = a_position.y;
}
}
}//package game.component.view
Section 377
//SurfaceView (game.component.view.SurfaceView)
package game.component.view {
import flash.display.*;
import Box2D.Common.Math.*;
import game.component.control.iface.*;
import ui.canvas.model.*;
public class SurfaceView implements ISurface {
protected var m_obstacleAsset:MovieClip;
public function SurfaceView(a_obstacleAsset:MovieClip){
super();
m_obstacleAsset = a_obstacleAsset;
m_obstacleAsset.filters = GameCanvasModel.filter;
}
public function get rotation():Number{
return (m_obstacleAsset.rotation);
}
public function get height():Number{
return (m_obstacleAsset.height);
}
public function getDisplayObject():DisplayObject{
return (m_obstacleAsset);
}
public function set width(a_value:Number):void{
m_obstacleAsset.width = a_value;
}
public function get width():Number{
return (m_obstacleAsset.width);
}
public function set height(a_value:Number):void{
m_obstacleAsset.height = a_value;
}
public function updatePosition(a_position:b2Vec2):void{
m_obstacleAsset.x = a_position.x;
m_obstacleAsset.y = a_position.y;
}
public function updateRotation(a_rotation:Number):void{
m_obstacleAsset.rotation = ((a_rotation * 180) / Math.PI);
}
}
}//package game.component.view
Section 378
//TimedAnchorView (game.component.view.TimedAnchorView)
package game.component.view {
import flash.display.*;
import Box2D.Common.Math.*;
import game.component.control.iface.*;
import fla.game.component.*;
public class TimedAnchorView implements ITimedAnchor {
private var m_anchorAsset:MovieClip;
private var y:Number;
public function TimedAnchorView(a_anchorAsset:MovieClip){
super();
m_anchorAsset = a_anchorAsset;
m_anchorAsset.gotoAndStop(1);
y = (m_anchorAsset as TimedAnchor).balloon.y;
}
public function updatePosition(a_position:b2Vec2):void{
m_anchorAsset.x = a_position.x;
m_anchorAsset.y = a_position.y;
}
public function playDetach():void{
m_anchorAsset.anchor.gotoAndPlay("detach");
}
public function playAttach():void{
m_anchorAsset.anchor.gotoAndPlay("attach");
}
public function fadeTo(a_alpha:Number):void{
(m_anchorAsset as TimedAnchor).balloon.scaleX = a_alpha;
(m_anchorAsset as TimedAnchor).balloon.scaleY = a_alpha;
}
public function getDisplayObject():DisplayObject{
return (m_anchorAsset);
}
}
}//package game.component.view
Section 379
//TokenView (game.component.view.TokenView)
package game.component.view {
import flash.display.*;
import Box2D.Common.Math.*;
import game.component.control.iface.*;
import fla.game.component.*;
import ui.canvas.model.*;
public class TokenView implements IToken {
private var m_tokenAsset:MovieClip;
public function TokenView(a_tokenAsset:MovieClip){
super();
m_tokenAsset = a_tokenAsset;
if ((m_tokenAsset is Star)){
(m_tokenAsset as Star).anim.type.gotoAndStop((1 + int((Math.random() * (m_tokenAsset as Star).anim.type.totalFrames))));
} else {
m_tokenAsset.filters = GameCanvasModel.filter;
};
}
public function updatePosition(a_position:b2Vec2):void{
m_tokenAsset.x = a_position.x;
m_tokenAsset.y = a_position.y;
}
public function getDisplayObject():DisplayObject{
return (m_tokenAsset);
}
}
}//package game.component.view
Section 380
//UFOView (game.component.view.UFOView)
package game.component.view {
import flash.display.*;
import Box2D.Common.Math.*;
import game.component.control.iface.*;
import fla.game.component.*;
import ui.canvas.model.*;
public class UFOView implements IUFO {
private var m_ufoAsset:UFO;
public function UFOView(a_ufoAsset:UFO){
super();
m_ufoAsset = a_ufoAsset;
m_ufoAsset.ufo.filters = GameCanvasModel.filter;
var i:Number = 1;
while (i <= 4) {
m_ufoAsset.beam[("layer" + i.toString())].stop();
i++;
};
}
public function showBeam():void{
var i:Number = 1;
while (i <= 4) {
m_ufoAsset.beam[("layer" + i.toString())].gotoAndPlay("beamOn");
i++;
};
}
public function set height(a_value:Number):void{
m_ufoAsset.beam.height = a_value;
}
public function updatePosition(a_position:b2Vec2):void{
m_ufoAsset.x = a_position.x;
m_ufoAsset.y = a_position.y;
}
public function hideBeam():void{
var i:Number = 1;
while (i <= 4) {
m_ufoAsset.beam[("layer" + i.toString())].gotoAndPlay("beamOff");
i++;
};
}
public function getDisplayObject():DisplayObject{
return (m_ufoAsset);
}
}
}//package game.component.view
Section 381
//IGameComponent (game.manager.iface.IGameComponent)
package game.manager.iface {
import flash.display.*;
import core.component.base.iface.*;
public interface IGameComponent extends IDestroyable {
function update(:Number):void;
function getViewDisplayObject():DisplayObject;
}
}//package game.manager.iface
Section 382
//GameBackgroundManager (game.manager.GameBackgroundManager)
package game.manager {
import flash.display.*;
import com.greensock.*;
public class GameBackgroundManager {
private var m_background:MovieClip;
private var m_canvas:DisplayObjectContainer;
private var m_maskPositions:Object;
private static const TWEEN_TIME:Number = 1;
public function GameBackgroundManager(a_background:MovieClip, a_canvas:DisplayObjectContainer, a_colors:Array){
var color:String;
super();
m_canvas = a_canvas;
m_background = a_background;
m_canvas.addChild(m_background);
m_maskPositions = new Object();
for each (color in a_colors) {
m_maskPositions[color] = {mask:m_background[color], x:m_background[color].x, y:m_background[color].y};
};
}
public function offsetBackground(a_x:Number, a_y:Number):void{
m_background.x = a_x;
m_background.y = a_y;
}
private function getColorMaskFrom(a_number:Number):String{
var colorString:String = a_number.toString(16).toUpperCase();
var i:Number = (6 - colorString.length);
while (i > 0) {
colorString = ("0" + colorString);
i--;
};
colorString = ("x" + colorString);
return (colorString);
}
public function resetAllMasks():void{
var color:Object;
TweenMax.killAll();
for (color in m_maskPositions) {
m_maskPositions[color]["mask"]["x"] = m_maskPositions[color].x;
m_maskPositions[color]["mask"]["y"] = m_maskPositions[color].y;
};
}
public function resetMask(a_color:Number):void{
var tweenX:Number;
var tweenY:Number;
var colorString:String = getColorMaskFrom(a_color);
if (m_maskPositions[colorString]){
tweenX = m_maskPositions[colorString].x;
tweenY = m_maskPositions[colorString].y;
TweenMax.to(m_maskPositions[colorString].mask, TWEEN_TIME, {x:tweenX, y:tweenY});
};
}
public function maskColor(a_color:Number):void{
var tweenX:Number;
var tweenY:Number;
var colorString:String = getColorMaskFrom(a_color);
if (m_maskPositions[colorString]){
tweenX = m_background.x;
tweenY = m_background.y;
TweenMax.to(m_maskPositions[colorString].mask, TWEEN_TIME, {x:tweenX, y:tweenY});
};
}
}
}//package game.manager
Section 383
//GameCameraManager (game.manager.GameCameraManager)
package game.manager {
import flash.display.*;
import flash.geom.*;
public class GameCameraManager {
private var m_screenHeight:Number;
private var m_screenWidth:Number;
private var m_trackedObject:DisplayObject;
private var m_transform:Matrix;
private static const EASING_VALUE:Number = 10;
public function GameCameraManager(a_trackedObject:DisplayObject, a_screenWidth:Number=0, a_screenHeight:Number=0){
super();
m_transform = new Matrix();
m_transform.identity();
m_trackedObject = a_trackedObject;
m_screenWidth = a_screenWidth;
m_screenHeight = a_screenHeight;
}
public function getTransformAt(a_distance:Number):Matrix{
if (a_distance == 0){
return (m_transform);
};
var fallOff:Number = (1 / Math.pow(a_distance, 2));
var transform:Matrix = m_transform.clone();
transform.tx = (transform.tx * fallOff);
transform.ty = (transform.ty * fallOff);
return (transform);
}
public function set screenHeight(a_value:Number):void{
m_screenHeight = a_value;
}
public function get trackedObject():DisplayObject{
return (m_trackedObject);
}
public function focusOnTarget():void{
m_transform.tx = ((m_screenWidth / 2) - m_trackedObject.x);
m_transform.ty = ((m_screenHeight / 2) - m_trackedObject.y);
}
public function set trackedObject(a_value:DisplayObject):void{
m_trackedObject = a_value;
}
public function update():void{
m_transform.tx = (m_transform.tx + ((((m_screenWidth / 2) - m_trackedObject.x) - m_transform.tx) / EASING_VALUE));
m_transform.ty = (m_transform.ty + ((((m_screenHeight / 2) - m_trackedObject.y) - m_transform.ty) / EASING_VALUE));
m_transform.ty = Math.max(0, m_transform.ty);
}
public function set screenWidth(a_value:Number):void{
m_screenWidth = a_value;
}
}
}//package game.manager
Section 384
//GameComponentManager (game.manager.GameComponentManager)
package game.manager {
import flash.display.*;
import game.manager.iface.*;
public class GameComponentManager {
private var m_collectedQueue:Array;
private var m_componentPool:Array;
private var m_removalQueue:Array;
public function GameComponentManager(){
super();
m_componentPool = new Array();
m_removalQueue = new Array();
m_collectedQueue = new Array();
}
public function clearCollected():Number{
var componentsClearedCount:Number = m_collectedQueue.length;
m_removalQueue = m_removalQueue.concat(m_collectedQueue);
m_collectedQueue.splice(0, m_collectedQueue.length);
return (componentsClearedCount);
}
public function getCollectedOfType(a_type:Class):Array{
var component:Object;
var typePool:Array = new Array();
for each (component in m_collectedQueue) {
if ((component is a_type)){
typePool.push(component);
};
};
return (typePool);
}
public function update(a_msElapsed:Number):void{
var component:IGameComponent;
var componentToRemoveIndex:Number = -1;
var i:Number = 0;
while (i < m_removalQueue.length) {
component = m_removalQueue[i];
m_removalQueue.splice(i, 1);
componentToRemoveIndex = m_componentPool.indexOf(component);
if (componentToRemoveIndex >= 0){
m_componentPool.splice(componentToRemoveIndex, 1);
};
componentToRemoveIndex = -1;
component.destroy();
if (((component.getViewDisplayObject()) && (component.getViewDisplayObject().parent))){
component.getViewDisplayObject().parent.removeChild(component.getViewDisplayObject());
};
i++;
};
for each (component in m_componentPool) {
component.update(a_msElapsed);
};
}
public function doesCollectedContain(a_component:IGameComponent):Boolean{
return ((m_collectedQueue.indexOf(a_component) >= 0));
}
public function addToCollected(a_component:IGameComponent):void{
m_collectedQueue.push(a_component);
if (((a_component.getViewDisplayObject()) && (a_component.getViewDisplayObject().parent))){
a_component.getViewDisplayObject().parent.removeChild(a_component.getViewDisplayObject());
};
m_componentPool.splice(m_componentPool.indexOf(a_component), 1);
}
public function destroyAllRegistered():void{
var component:IGameComponent;
for each (component in m_componentPool) {
if (((component.getViewDisplayObject()) && (component.getViewDisplayObject().parent))){
component.getViewDisplayObject().parent.removeChild(component.getViewDisplayObject());
};
component.destroy();
};
m_componentPool.splice(0, m_componentPool.length);
}
public function scheduleForRemoval(a_component:IGameComponent):void{
m_removalQueue.push(a_component);
}
public function addComponent(a_component:IGameComponent):void{
m_componentPool.push(a_component);
}
public function getComponentsOfType(a_type:Class):Array{
var component:Object;
var typePool:Array = new Array();
for each (component in m_componentPool) {
if ((component is a_type)){
typePool.push(component);
};
};
return (typePool);
}
public function instantiateCollected(a_toCanvas:DisplayObjectContainer):Number{
var componentsInstantiatedCount:Number = m_collectedQueue.length;
m_componentPool = m_componentPool.concat(m_collectedQueue);
var i:Number = 0;
while (i < m_collectedQueue.length) {
a_toCanvas.addChild((m_collectedQueue[i] as IGameComponent).getViewDisplayObject());
i++;
};
m_collectedQueue.splice(0, m_collectedQueue.length);
return (componentsInstantiatedCount);
}
}
}//package game.manager
Section 385
//GameContactListener (game.manager.GameContactListener)
package game.manager {
import ui.canvas.*;
import game.component.control.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Contacts.*;
import ui.canvas.model.*;
public class GameContactListener extends b2ContactListener {
private var m_responder:GameContactResponder;
private var m_canvas:GameCanvas;
public function GameContactListener(a_responder:GameContactResponder, a_canvas:GameCanvas){
super();
m_responder = a_responder;
m_canvas = a_canvas;
}
override public function EndContact(contact:b2Contact):void{
var player:PlayerControl;
var other:Object;
var typeA:Object = contact.GetFixtureA().GetBody().GetUserData();
var typeB:Object = contact.GetFixtureB().GetBody().GetUserData();
if ((typeA is PlayerControl)){
player = (typeA as PlayerControl);
other = typeB;
} else {
if ((typeB is PlayerControl)){
player = (typeB as PlayerControl);
other = typeA;
} else {
throw (new Error("Somehow the game reached an impossible state..."));
};
};
if ((other is UFOControl)){
m_responder.dispatchEvent(new GameEvent(GameEvent.CONTACT_END_UFO, false, false, other));
} else {
if ((other is ElectrifiedSurfaceControl)){
m_responder.dispatchEvent(new GameEvent(GameEvent.CONTACT_ELECTRIFIED_SURFACE_END, false, false, other));
};
};
}
override public function BeginContact(contact:b2Contact):void{
var player:PlayerControl;
var other:Object;
var forceVector:b2Vec2;
var dest:b2Vec2;
var typeA:Object = contact.GetFixtureA().GetBody().GetUserData();
var typeB:Object = contact.GetFixtureB().GetBody().GetUserData();
if ((typeA is PlayerControl)){
player = (typeA as PlayerControl);
other = typeB;
} else {
if ((typeB is PlayerControl)){
player = (typeB as PlayerControl);
other = typeA;
} else {
throw (new Error("Somehow the game reached an impossible state..."));
};
};
if ((((other is AnchorControl)) || ((other is MovingAnchorControl)))){
if (((player.tongueJoint.attachedBody) && (!(player.flinging)))){
return;
};
m_responder.dispatchEvent(new GameEvent(GameEvent.CONTACT_ANCHOR, false, false, other));
if (!player.flinging){
m_canvas.nearPlane.removeChild(player.getViewDisplayObject());
m_canvas.nearPlane.removeChild(player.tongueJoint.getViewDisplayObject());
m_canvas.nearPlane.addChildAt(player.getViewDisplayObject(), 0);
m_canvas.nearPlane.addChildAt(player.tongueJoint.getViewDisplayObject(), 1);
player.tongueJoint.attachTo(other.rigidBody);
player.inputEnabled = true;
} else {
m_canvas.nearPlane.removeChild(player.getViewDisplayObject());
m_canvas.nearPlane.removeChild(player.tongueJoint.getViewDisplayObject());
m_canvas.nearPlane.addChild(player.getViewDisplayObject());
m_canvas.nearPlane.addChild(player.tongueJoint.getViewDisplayObject());
player.flinging = false;
};
} else {
if ((other is TimedAnchorControl)){
if (!(other as TimedAnchorControl).active){
return;
};
if (((player.tongueJoint.attachedBody) && (!(player.flinging)))){
return;
};
m_responder.dispatchEvent(new GameEvent(GameEvent.CONTACT_TIMED_ANCHOR, false, false, other));
if (!player.flinging){
m_canvas.nearPlane.removeChild(player.getViewDisplayObject());
m_canvas.nearPlane.removeChild(player.tongueJoint.getViewDisplayObject());
m_canvas.nearPlane.addChildAt(player.getViewDisplayObject(), 0);
m_canvas.nearPlane.addChildAt(player.tongueJoint.getViewDisplayObject(), 1);
player.tongueJoint.attachTo((other as TimedAnchorControl).rigidBody);
(other as TimedAnchorControl).attached = true;
player.inputEnabled = true;
} else {
m_canvas.nearPlane.removeChild(player.getViewDisplayObject());
m_canvas.nearPlane.removeChild(player.tongueJoint.getViewDisplayObject());
m_canvas.nearPlane.addChild(player.getViewDisplayObject());
m_canvas.nearPlane.addChild(player.tongueJoint.getViewDisplayObject());
player.flinging = false;
(other as TimedAnchorControl).attached = false;
};
} else {
if ((other is ColorTokenControl)){
m_responder.dispatchEvent(new GameEvent(GameEvent.CONTACT_COLOR_TOKEN, false, false, other));
} else {
if ((other is ExtraLifeTokenControl)){
m_responder.dispatchEvent(new GameEvent(GameEvent.CONTACT_EXTRA_LIFE, false, false, other));
} else {
if ((other is BigTokenControl)){
m_responder.dispatchEvent(new GameEvent(GameEvent.CONTACT_BIG_TOKEN, false, false, other));
} else {
if ((other is TokenControl)){
m_responder.dispatchEvent(new GameEvent(GameEvent.CONTACT_TOKEN, false, false, other));
} else {
if ((other is UFOControl)){
m_responder.dispatchEvent(new GameEvent(GameEvent.CONTACT_UFO, false, false, other));
} else {
if ((other is SpringboardControl)){
forceVector = player.rigidBody.GetLinearVelocity();
forceVector.Normalize();
forceVector.Multiply((other as SpringboardControl).bonusForce);
player.rigidBody.ApplyForce(forceVector, player.rigidBody.GetPosition());
(other as SpringboardControl).playBounce();
JuicyFruitFlavorFling.instance.sfxManager.playSound("trampoleen");
} else {
if ((other is TeleportSurfaceControl)){
JuicyFruitFlavorFling.instance.sfxManager.playSound("warp");
dest = (other as TeleportSurfaceControl).destination.Copy();
dest.Multiply((1 / GameCanvasModel.PHYSICS_WORLD_SCALE));
GameCanvasModel.teleportPlayer = true;
GameCanvasModel.teleportPosition = dest;
} else {
if ((other is ElectrifiedSurfaceControl)){
m_responder.dispatchEvent(new GameEvent(GameEvent.CONTACT_ELECTRIFIED_SURFACE, false, false, other));
};
};
};
};
};
};
};
};
};
};
}
}
}//package game.manager
Section 386
//GameContactResponder (game.manager.GameContactResponder)
package game.manager {
import ui.canvas.*;
import flash.events.*;
import flash.display.*;
import game.component.control.*;
import Box2D.Common.Math.*;
import com.greensock.events.*;
import core.component.base.iface.*;
import com.greensock.*;
import game.manager.iface.*;
import core.component.custom.*;
import flash.utils.*;
import ui.canvas.model.*;
import com.soapcreative.net.tracking.*;
public class GameContactResponder extends EventDispatcher implements IDestroyable {
private var m_bodyPos:b2Vec2;
private var m_tokenTimer:Timer;
private var m_tweenY:TweenMax;
private var m_tweenX:TweenMax;
private var m_canvas:GameCanvas;
private static const PLAYER_SPAWN_Y_OFFSET:Number = -100;
private static const ANCHOR_CONTACT_CHECK_TOKEN_DELAY:Number = 1000;
public function GameContactResponder(a_canvas:GameCanvas){
super();
m_canvas = a_canvas;
m_tokenTimer = new Timer(ANCHOR_CONTACT_CHECK_TOKEN_DELAY, 1);
m_tokenTimer.addEventListener(TimerEvent.TIMER, resolveTokenTimer);
addEventListener(GameEvent.CONTACT_TOKEN, resolveContactToken);
addEventListener(GameEvent.CONTACT_ANCHOR, resolveContactAnchor);
addEventListener(GameEvent.CONTACT_TIMED_ANCHOR, resolveContactTimedAnchor);
addEventListener(GameEvent.CONTACT_BIG_TOKEN, resolveContactBigToken);
addEventListener(GameEvent.CONTACT_EXTRA_LIFE, resolveContactExtraLife);
addEventListener(GameEvent.CONTACT_COLOR_TOKEN, resolveContactColorToken);
addEventListener(GameEvent.CONTACT_UFO, resolveContactUFO);
addEventListener(GameEvent.CONTACT_END_UFO, resolveContactEndUFO);
addEventListener(GameEvent.CONTACT_ELECTRIFIED_SURFACE, resolveContactElectrifiedSurface);
addEventListener(GameEvent.CONTACT_ELECTRIFIED_SURFACE_END, resolveContactElectrifiedSurfaceEnd);
}
private function resolveTweenXUpdate(a_event:TweenEvent):void{
m_canvas.player.rigidBody.SetPosition(m_bodyPos);
m_canvas.player.getViewDisplayObject().x = (m_bodyPos.x * GameCanvasModel.PHYSICS_WORLD_SCALE);
}
private function resolveTweenYUpdate(a_event:TweenEvent):void{
m_canvas.player.rigidBody.SetPosition(m_bodyPos);
m_canvas.player.getViewDisplayObject().y = (m_bodyPos.y * GameCanvasModel.PHYSICS_WORLD_SCALE);
}
private function resolveContactToken(a_event:GameEvent):void{
if (!m_canvas.componentManager.doesCollectedContain((a_event.contactedObject as IGameComponent))){
m_canvas.addParticleEmitter((a_event.contactedObject as TokenControl).rigidBody.GetPosition(), (a_event.contactedObject as TokenControl).getParticle());
GameCanvasModel.scoreThisLevel = (GameCanvasModel.scoreThisLevel + a_event.contactedObject.pointValue);
JuicyFruitFlavorFling.instance.appHUD.scoreBar.score = (JuicyFruitFlavorFling.instance.appHUD.scoreBar.score + a_event.contactedObject.pointValue);
m_canvas.componentManager.addToCollected((a_event.contactedObject as IGameComponent));
JuicyFruitFlavorFling.instance.sfxManager.playSound("smallToken");
(m_canvas.player.getViewDisplayObject() as MovieClip).gotoAndPlay("static");
};
}
private function resolveContactElectrifiedSurfaceEnd(a_event:GameEvent):void{
m_canvas.player.rigidBody.SetLinearDamping(0);
(m_canvas.player.getViewDisplayObject() as MovieClip).gotoAndPlay("static");
}
private function resolveContactUFO(a_event:GameEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.playSound("alien", 0, int.MAX_VALUE);
var xTime:Number = (a_event.contactedObject as UFOControl).blinkCycle;
var yTime:Number = (xTime * 2);
m_bodyPos = m_canvas.player.rigidBody.GetPosition().Copy();
m_canvas.player.isTweening = true;
m_canvas.player.rigidBody.SetLinearDamping(1000);
m_tweenX = TweenMax.to(m_bodyPos, xTime, {x:(a_event.contactedObject as UFOControl).getPosition().x});
m_tweenY = TweenMax.to(m_bodyPos, yTime, {y:(a_event.contactedObject as UFOControl).getPosition().y});
m_tweenX.addEventListener(TweenEvent.UPDATE, resolveTweenXUpdate);
m_tweenY.addEventListener(TweenEvent.UPDATE, resolveTweenYUpdate);
}
private function resolveContactBigToken(a_event:GameEvent):void{
m_canvas.addParticleEmitter((a_event.contactedObject as BigTokenControl).rigidBody.GetPosition());
GameCanvasModel.scoreThisLevel = (GameCanvasModel.scoreThisLevel + a_event.contactedObject.pointValue);
JuicyFruitFlavorFling.instance.appHUD.scoreBar.score = (JuicyFruitFlavorFling.instance.appHUD.scoreBar.score + a_event.contactedObject.pointValue);
m_canvas.componentManager.scheduleForRemoval((a_event.contactedObject as IGameComponent));
JuicyFruitFlavorFling.instance.sfxManager.playSound("bigToken");
}
private function resolveContactColorToken(a_event:GameEvent):void{
var color:Number;
if (!m_canvas.componentManager.doesCollectedContain((a_event.contactedObject as IGameComponent))){
color = (a_event.contactedObject as ColorTokenControl).color;
m_canvas.backgroundManager.maskColor(color);
m_canvas.componentManager.addToCollected((a_event.contactedObject as IGameComponent));
JuicyFruitFlavorFling.instance.sfxManager.playSound("smallToken");
};
}
private function resolveContactEndUFO(a_event:GameEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.stopAudio();
m_tweenX.pause();
m_tweenY.pause();
m_tweenX.removeEventListener(TweenEvent.UPDATE, resolveTweenXUpdate);
m_tweenY.removeEventListener(TweenEvent.UPDATE, resolveTweenYUpdate);
m_canvas.player.rigidBody.SetLinearDamping(0);
m_canvas.player.rigidBody.SetPosition(m_bodyPos);
m_canvas.player.isTweening = false;
}
private function resolveContactTimedAnchor(a_event:GameEvent):void{
var tokenCount:Number;
if (!m_canvas.nearPlane.hasEventListener(GameEvent.ANCHOR_DESTROYED)){
m_canvas.nearPlane.addEventListener(GameEvent.ANCHOR_DESTROYED, resolveTimedAnchorDestroyed);
};
if (((!(m_canvas.player.flinging)) && (!(m_canvas.player.inputEnabled)))){
JuicyFruitFlavorFling.instance.sfxManager.playSound("balloon");
m_canvas.camera.trackedObject = (a_event.contactedObject as TimedAnchorControl).getViewDisplayObject();
(a_event.contactedObject as TimedAnchorControl).playAttach();
tokenCount = m_canvas.componentManager.clearCollected();
m_canvas.tokensLeft = (m_canvas.tokensLeft - tokenCount);
GameCanvasModel.tokensCollectedThisLevel = (GameCanvasModel.tokensCollectedThisLevel + tokenCount);
m_tokenTimer.start();
} else {
if (!m_canvas.player.tongueJoint.attachedBody){
(a_event.contactedObject as TimedAnchorControl).playDetach();
m_canvas.removeEventListener(GameEvent.ANCHOR_DESTROYED, resolveTimedAnchorDestroyed);
};
};
}
private function resolveContactElectrifiedSurface(a_event:GameEvent):void{
m_canvas.player.rigidBody.SetLinearDamping(int.MAX_VALUE);
(m_canvas.player.getViewDisplayObject() as MovieClip).gotoAndPlay("electrocuted");
}
private function resolveTokenTimer(a_event:TimerEvent):void{
if (m_canvas.tokensLeft == 0){
if (GameCanvasModel.currentLevel >= 0){
GameTracking.levelComplete();
};
m_canvas.player.inputEnabled = false;
GameCanvasModel.tokensCollectedThisGame = (GameCanvasModel.tokensCollectedThisGame + GameCanvasModel.tokensCollectedThisLevel);
if (GameCanvasModel.currentLevel == GameCanvasModel.MAX_LEVEL){
JuicyFruitFlavorFling.instance.scoreManager.setScore(GameCanvasModel.scoreThisLevel, GameCanvasModel.currentLevel);
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_GAME_COMPLETE));
} else {
JuicyFruitFlavorFling.instance.scoreManager.setScore(GameCanvasModel.scoreThisLevel, GameCanvasModel.currentLevel);
JuicyFruitFlavorFling.instance.appHUD.scoreBar.score = JuicyFruitFlavorFling.instance.scoreManager.getScore();
m_canvas.bufferLastLevel(Math.min(++GameCanvasModel.currentLevel, GameCanvasModel.MAX_LEVEL));
JuicyFruitFlavorFling.instance.appHUD.hide();
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_LEVEL_COMPLETE));
GameCanvasModel.scoreThisLevel = 0;
GameCanvasModel.tokensCollectedThisLevel = 0;
m_canvas.setLevelTime(0);
};
};
}
private function resolveContactAnchor(a_event:GameEvent):void{
var tokenCount:Number;
if (((!(m_canvas.player.flinging)) && (!(m_canvas.player.inputEnabled)))){
m_canvas.camera.trackedObject = a_event.contactedObject.getViewDisplayObject();
a_event.contactedObject.playAttach();
tokenCount = m_canvas.componentManager.clearCollected();
m_canvas.tokensLeft = (m_canvas.tokensLeft - tokenCount);
GameCanvasModel.tokensCollectedThisLevel = (GameCanvasModel.tokensCollectedThisLevel + tokenCount);
if ((a_event.contactedObject is AnchorControl)){
m_canvas.playerInitialPosition = a_event.contactedObject.rigidBody.GetPosition().Copy();
m_canvas.playerInitialPosition.y = (m_canvas.playerInitialPosition.y + (PLAYER_SPAWN_Y_OFFSET / GameCanvasModel.PHYSICS_WORLD_SCALE));
};
m_tokenTimer.start();
} else {
if (!m_canvas.player.tongueJoint.attachedBody){
a_event.contactedObject.playDetach();
};
};
}
private function resolveContactExtraLife(a_event:GameEvent):void{
m_canvas.addParticleEmitter((a_event.contactedObject as ExtraLifeTokenControl).rigidBody.GetPosition());
JuicyFruitFlavorFling.instance.appHUD.lifeBar.lives++;
m_canvas.componentManager.scheduleForRemoval((a_event.contactedObject as IGameComponent));
JuicyFruitFlavorFling.instance.sfxManager.playSound("bigToken");
}
public function resolveTimedAnchorDestroyed(a_event:GameEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.playSound("pop");
m_canvas.player.tongueJoint.detach();
m_canvas.player.inputEnabled = false;
m_canvas.player.removeClientControl();
m_canvas.camera.trackedObject = m_canvas.player.getViewDisplayObject();
(a_event.contactedObject as TimedAnchorControl).active = false;
m_canvas.removeEventListener(GameEvent.ANCHOR_DESTROYED, resolveTimedAnchorDestroyed);
}
public function destroy():void{
removeEventListener(GameEvent.CONTACT_TOKEN, resolveContactToken);
removeEventListener(GameEvent.CONTACT_ANCHOR, resolveContactAnchor);
removeEventListener(GameEvent.CONTACT_TIMED_ANCHOR, resolveContactTimedAnchor);
removeEventListener(GameEvent.CONTACT_BIG_TOKEN, resolveContactBigToken);
removeEventListener(GameEvent.CONTACT_EXTRA_LIFE, resolveContactExtraLife);
removeEventListener(GameEvent.CONTACT_COLOR_TOKEN, resolveContactColorToken);
removeEventListener(GameEvent.CONTACT_UFO, resolveContactUFO);
removeEventListener(GameEvent.CONTACT_END_UFO, resolveContactEndUFO);
removeEventListener(GameEvent.CONTACT_ELECTRIFIED_SURFACE, resolveContactElectrifiedSurface);
removeEventListener(GameEvent.CONTACT_ELECTRIFIED_SURFACE_END, resolveContactElectrifiedSurfaceEnd);
}
}
}//package game.manager
Section 387
//GameEvent (game.manager.GameEvent)
package game.manager {
import flash.events.*;
public class GameEvent extends Event {
private var m_contactedObject:Object;
public static const CONTACT_COLOR_TOKEN:String = "gameEventContactColorToken";
public static const CONTACT_EXTRA_LIFE:String = "gameEventContactExtraLife";
public static const ANCHOR_DESTROYED:String = "gameEventAnchorDestroyed";
public static const CONTACT_END_UFO:String = "gameEventContactEndUFO";
public static const CONTACT_ANCHOR:String = "gameEventContactAnchor";
public static const CONTACT_ELECTRIFIED_SURFACE_END:String = "gameEventContactElectrifiedSurfaceEnd";
public static const CONTACT_ELECTRIFIED_SURFACE:String = "gameEventContactElectrifiedSurface";
public static const CONTACT_TOKEN:String = "gameEventContactToken";
public static const CONTACT_BIG_TOKEN:String = "gameEventContactBigToken";
public static const CONTACT_TIMED_ANCHOR:String = "gameEventContactTimedAnchor";
public static const CONTACT_UFO:String = "gameEventContactUFO";
public function GameEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, a_contactedObject:Object=null){
super(type, bubbles, cancelable);
m_contactedObject = a_contactedObject;
}
public function get contactedObject():Object{
return (m_contactedObject);
}
}
}//package game.manager
Section 388
//GameLevelManager (game.manager.GameLevelManager)
package game.manager {
import ui.canvas.*;
import flash.display.*;
import game.component.control.*;
import Box2D.Common.Math.*;
import game.manager.iface.*;
import Box2D.Dynamics.*;
import game.component.control.iface.*;
import fla.game.component.*;
import ui.canvas.model.*;
import fla.game.splat.*;
import game.component.view.*;
public class GameLevelManager {
private var m_componentManager:GameComponentManager;
private var m_allTokenCount:Number;
private var m_physicsWorld:b2World;
private var m_bgY:Number;
private var m_lifeCount:Number;
private var m_worldScale:Number;
private var m_midCanvas:DisplayObjectContainer;
private var m_tokenCount:Number;
private var m_bgX:Number;
private var m_canvas:DisplayObjectContainer;
private var m_player:PlayerControl;
private static const LevelFileXML:Class = GameLevelManager_LevelFileXML;
private static var m_levelFileXML:XML = XML(new LevelFileXML());
public function GameLevelManager(a_canvas:DisplayObjectContainer, a_midCanvas:DisplayObjectContainer, a_componentManager:GameComponentManager, a_physicsWorld:b2World, a_worldScale:Number){
super();
m_canvas = a_canvas;
m_midCanvas = a_midCanvas;
m_componentManager = a_componentManager;
m_physicsWorld = a_physicsWorld;
m_worldScale = a_worldScale;
m_tokenCount = 0;
m_allTokenCount = 0;
}
public function get bgX():Number{
return (m_bgX);
}
public function get tokenCount():Number{
var tokens:Number = m_tokenCount;
m_tokenCount = 0;
return (tokens);
}
public function get allTokenCount():Number{
var tokens:Number = m_allTokenCount;
m_allTokenCount = 0;
return (tokens);
}
public function get player():PlayerControl{
return (m_player);
}
public function get lifeCount():Number{
return (m_lifeCount);
}
public function get bgY():Number{
return (m_bgY);
}
public function loadLevel(a_number:Number):void{
var relevantXML:XMLList;
var child:XML;
var view:MovieClip;
var controller:IGameComponent;
var x:Number;
var y:Number;
var a_number = a_number;
if (a_number > 0){
relevantXML = m_levelFileXML.level.(@id == a_number);
} else {
if (a_number == -1){
relevantXML = LevelEditCanvas.levelXML.level.(@id == a_number);
} else {
GameCanvasModel.currentLevel = -1;
relevantXML = LevelEditCanvas.levelXML.level.(@id == -1);
};
};
m_lifeCount = relevantXML.@lives;
m_bgX = relevantXML.@bgx;
m_bgY = relevantXML.@bgy;
for each (child in relevantXML.children()) {
x = child.@x;
y = child.@y;
switch (child.localName().toString()){
case "player":
view = new Player();
controller = new PlayerControl(new PlayerView(view), x, y, m_canvas, m_physicsWorld, m_worldScale);
m_player = (controller as PlayerControl);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
view = new Tongue();
controller = new PlayerJointControl(new PlayerJointView(view, m_worldScale), m_player.rigidBody, m_physicsWorld);
m_player.tongueJoint = (controller as PlayerJointControl);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
view = new PlayerPathView(Point);
controller = new PlayerPathControl((view as IPlayerPath), 0.1, 20, m_player, m_physicsWorld, m_worldScale);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
break;
case "anchor":
view = new Anchor();
controller = new AnchorControl(new AnchorView(view), x, y, child.@hitradius, m_physicsWorld, m_worldScale);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
break;
case "token":
view = new Star();
controller = new TokenControl(new TokenView(view), x, y, m_physicsWorld, m_worldScale, child.@value);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
m_tokenCount++;
m_allTokenCount++;
break;
case "surface":
view = new Surface();
controller = new SurfaceControl(new SurfaceView(view), x, y, child.@width, child.@height, child.@rotation, m_physicsWorld, m_worldScale);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
break;
case "springboard":
view = new Springboard();
controller = new SpringboardControl(new SurfaceView(view), x, y, child.@rotation, m_physicsWorld, m_worldScale, child.@bonusforce);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
break;
case "rotatingsurface":
view = new RotatingSurface();
controller = new RotatingSurfaceControl(new SurfaceView(view), x, y, child.@width, child.@height, child.@rotationrate, m_physicsWorld, m_worldScale);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
break;
case "bigtoken":
view = new BigStar();
controller = new BigTokenControl(new TokenView(view), x, y, m_physicsWorld, m_worldScale, child.@value);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
m_allTokenCount++;
break;
case "extralife":
view = new ExtraLife();
controller = new ExtraLifeTokenControl(new TokenView(view), x, y, m_physicsWorld, m_worldScale);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
m_allTokenCount++;
break;
case "colortoken":
view = new ColorToken();
controller = new ColorTokenControl(new TokenView(view), x, y, m_physicsWorld, m_worldScale, child.@color);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
m_tokenCount++;
m_allTokenCount++;
break;
case "timedanchor":
view = new TimedAnchor();
controller = new TimedAnchorControl(new TimedAnchorView(view), m_canvas, x, y, child.@hitradius, m_physicsWorld, m_worldScale, child.@lifespan);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
break;
case "teleportsurface":
view = new TeleportSurface();
controller = new TeleportSurfaceControl(new SurfaceView(view), x, y, m_physicsWorld, m_worldScale, b2Vec2.Make(child.@destinationx, child.@destinationy));
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
break;
case "ufo":
view = new UFO();
controller = new UFOControl(new UFOView((view as UFO)), x, y, child.@height, child.@blinkcycle, m_physicsWorld, m_worldScale);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
break;
case "electrifiedsurface":
view = new ElectrifiedSurface();
controller = new ElectrifiedSurfaceControl(new ElectrifiedSurfaceView((view as ElectrifiedSurface)), x, y, child.@rotation, child.@blinkcycle, m_physicsWorld, m_worldScale);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
break;
case "movinganchor":
view = new MovingAnchor();
controller = new MovingAnchorControl(new MovingAnchorView((view as MovingAnchor)), x, y, child.@destinationx, child.@destinationy, child.@speed, child.@hitradius, m_physicsWorld, m_worldScale);
m_canvas.addChild(view);
m_componentManager.addComponent(controller);
break;
case "targetsplat":
view = new Target();
view.x = x;
view.y = y;
m_canvas.addChild(view);
break;
case "mgcloudsplat":
view = new Cloud();
view.x = x;
view.y = y;
m_midCanvas.addChild(view);
break;
case "mgcloud2splat":
view = new Cloud2();
view.x = x;
view.y = y;
m_midCanvas.addChild(view);
break;
case "mgcrazysplat":
view = new Crazy();
view.x = x;
view.y = y;
m_midCanvas.addChild(view);
break;
case "mgdiscoballsplat":
view = new DiscoBall();
view.x = x;
view.y = y;
m_midCanvas.addChild(view);
break;
case "mgpipessplat":
view = new Pipes();
view.x = x;
view.y = y;
m_midCanvas.addChild(view);
break;
case "mgpipes2splat":
view = new Pipes2();
view.x = x;
view.y = y;
m_midCanvas.addChild(view);
break;
case "mgpipes3splat":
view = new Pipes3();
view.x = x;
view.y = y;
m_midCanvas.addChild(view);
break;
case "mgplanetsplat":
view = new Planet();
view.x = x;
view.y = y;
m_midCanvas.addChild(view);
break;
case "mgplanet2splat":
view = new Planet2();
view.x = x;
view.y = y;
m_midCanvas.addChild(view);
break;
case "tutorialattachcollide":
view = new TutorialAttachCollide();
view.x = x;
view.y = y;
m_canvas.addChild(view);
break;
case "tutorialclickdrag":
view = new TutorialClickDrag();
view.x = x;
view.y = y;
m_canvas.addChild(view);
break;
case "tutorialcollect":
view = new TutorialCollect();
view.x = x;
view.y = y;
m_canvas.addChild(view);
break;
case "tutorialpresshold":
view = new TutorialPressHold();
view.x = x;
view.y = y;
m_canvas.addChild(view);
break;
};
};
}
}
}//package game.manager
Section 389
//GameLevelManager_LevelFileXML (game.manager.GameLevelManager_LevelFileXML)
package game.manager {
import mx.core.*;
public class GameLevelManager_LevelFileXML extends ByteArrayAsset {
}
}//package game.manager
Section 390
//ScoreManager (game.manager.ScoreManager)
package game.manager {
import ui.canvas.model.*;
public class ScoreManager {
private var m_scores:Array;
public function ScoreManager(){
super();
m_scores = new Array(GameCanvasModel.MAX_LEVEL);
var i:Number = 0;
while (i < m_scores.length) {
m_scores[i] = 0;
i++;
};
}
public function setScore(a_score:Number, a_level:Number):void{
if (a_score > m_scores[(a_level - 1)]){
m_scores[(a_level - 1)] = a_score;
};
}
public function getAll():Array{
return (m_scores);
}
public function getScore(a_level:Number=0):Number{
if (a_level > 0){
return (m_scores[(a_level - 1)]);
};
var score:Number = 0;
var i:Number = 0;
while (i < m_scores.length) {
score = (score + m_scores[i]);
i++;
};
return (score);
}
public function setAll(a_scores:Array):void{
var i:Number = 0;
while ((((i < a_scores.length)) && ((i < m_scores.length)))) {
m_scores[i] = a_scores[i];
i++;
};
}
}
}//package game.manager
Section 391
//ByteArrayAsset (mx.core.ByteArrayAsset)
package mx.core {
import flash.utils.*;
public class ByteArrayAsset extends ByteArray implements IFlexAsset {
mx_internal static const VERSION:String = "3.2.0.3958";
public function ByteArrayAsset(){
super();
}
}
}//package mx.core
Section 392
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 393
//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 394
//SoundAsset (mx.core.SoundAsset)
package mx.core {
import flash.media.*;
public class SoundAsset extends Sound implements IFlexAsset {
mx_internal static const VERSION:String = "3.2.0.3958";
public function SoundAsset(){
super();
}
}
}//package mx.core
Section 395
//GameCanvasModel (ui.canvas.model.GameCanvasModel)
package ui.canvas.model {
import core.component.base.*;
import ui.canvas.*;
import game.manager.*;
import flash.display.*;
import game.component.control.*;
import Box2D.Common.Math.*;
import flash.geom.*;
import Box2D.Dynamics.*;
import flash.filters.*;
import fla.game.component.*;
import flash.utils.*;
public class GameCanvasModel extends Sprite {
protected var m_particleEmitterData:ParticleDataProvider;
protected var m_componentManager:GameComponentManager;
protected var m_midPlane:Sprite;
protected var m_originalObject:DisplayObject;
protected var m_levelBuffer:Bitmap;
protected var m_player:PlayerControl;
protected var m_panMousePoint:Point;
protected var m_farPlane:Sprite;
protected var m_playerInitialPosition:b2Vec2;
protected var m_levelManager:GameLevelManager;
protected var m_physicsWorld:b2World;
protected var m_levelTime:Number;// = 120000
protected var m_contactListener:GameContactListener;
protected var m_zoomPoint:Point;
protected var m_panDelta:Point;
protected var m_camera:GameCameraManager;
protected var m_shouldZoom:Boolean;
protected var m_nearPlane:Sprite;
protected var m_wasInputBeforeZoom:Boolean;
protected var m_panFarPlaneMin:Point;
protected var m_backgroundManager:GameBackgroundManager;
protected var m_tokensLeft:Number;
protected var m_contactResponder:GameContactResponder;
protected var m_panFarPlaneMax:Point;
protected var m_debugDraw:b2DebugDraw;
protected var m_panObject:Sprite;
protected var m_zoomScale:Number;
protected var m_previousTime:Number;
protected var m_particleEmitters:Array;
protected static const PARTICLE_EMITTER_LIFE_SPAN:Number = 0;
public static const PHYSICS_WORLD_SCALE:Number = 32;
protected static const ZOOM_PAD:Number = 200;
protected static const PHYSICS_GRAVITY_VECTOR:b2Vec2 = b2Vec2.Make(0, 39.24);
protected static const NEAR_PLANE_DISTANCE:Number = 1;
protected static const SCREEN_WIDTH:Number = 700;
protected static const MID_PLANE_DISTANCE:Number = 2;
protected static const PHYSICS_POSITION_CONSTRAINT:Number = 10;
protected static const MAX_LEVEL_TIME:Number = 120000;
public static const MAX_LEVEL:Number = 20;
protected static const PAN_BUFFER:Number = 5;
protected static const SCREEN_HEIGHT:Number = 500;
protected static const FAR_PLANE_DISTANCE:Number = 3;
protected static const PHYSICS_STEP:Number = 0;
protected static const PHYSICS_VELOCITY_CONSTRAINT:Number = 10;
protected static var m_tokensCollectedThisLevel:Number = 0;
public static var instance:GameCanvas;
protected static var m_currentLevel:Number;
protected static var m_scoreThisLevel:Number;
protected static var m_totalTokensThisLevel:Number = 0;
protected static var m_tokensCollectedThisGame:Number;
public static var teleportPlayer:Boolean;
public static var filter:Array = new Array(new DropShadowFilter(8, 45, 0, 0.5));
public static var teleportPosition:b2Vec2;
public function GameCanvasModel(){
super();
addChild((m_farPlane = new Sprite()));
addChild((m_midPlane = new Sprite()));
addChild((m_nearPlane = new Sprite()));
m_backgroundManager = new GameBackgroundManager((new GameBackground() as MovieClip), m_farPlane, new Array());
m_panFarPlaneMax = new Point((((m_farPlane.width - SCREEN_WIDTH) / 2) - PAN_BUFFER), ((((m_farPlane.height / 2) - SCREEN_HEIGHT) / 2) - PAN_BUFFER));
m_panFarPlaneMin = new Point(-(m_panFarPlaneMax.x), -(m_panFarPlaneMax.y));
m_panDelta = new Point();
m_debugDraw = new b2DebugDraw();
m_debugDraw.SetDrawScale(PHYSICS_WORLD_SCALE);
m_debugDraw.SetSprite(m_nearPlane);
m_debugDraw.SetFlags((b2DebugDraw.e_shapeBit | b2DebugDraw.e_centerOfMassBit));
m_previousTime = getTimer();
m_physicsWorld = new b2World(PHYSICS_GRAVITY_VECTOR, true);
m_physicsWorld.SetDebugDraw(m_debugDraw);
m_contactResponder = new GameContactResponder((this as GameCanvas));
m_contactListener = new GameContactListener(m_contactResponder, (this as GameCanvas));
m_physicsWorld.SetContactListener(m_contactListener);
m_componentManager = new GameComponentManager();
m_levelManager = new GameLevelManager(m_nearPlane, m_midPlane, m_componentManager, m_physicsWorld, PHYSICS_WORLD_SCALE);
m_particleEmitters = new Array();
m_particleEmitterData = new ParticleDataProvider();
m_particleEmitterData.emissionRate = 20;
m_particleEmitterData.lifeSpan = 0.5;
m_particleEmitterData.angleMinimum = 0;
m_particleEmitterData.angleMaximum = (2 * Math.PI);
m_particleEmitterData.impulseMinimum = 9000;
m_particleEmitterData.impulseMaximum = 13000;
m_particleEmitterData.linearDamping = 0.01;
m_particleEmitterData.gravity = new Point(PHYSICS_GRAVITY_VECTOR.x, (PHYSICS_GRAVITY_VECTOR.y * 2));
m_particleEmitterData.scaleMinimum = 0.5;
m_particleEmitterData.scaleMaximum = 1;
m_particleEmitterData.rotationMinimum = 0;
m_particleEmitterData.rotationMaximum = Math.PI;
m_particleEmitterData.particleSprite = YellowParticle;
m_panMousePoint = new Point();
m_scoreThisLevel = 0;
}
public function set tokensLeft(a_value:Number):void{
m_tokensLeft = a_value;
}
public function get nearPlane():Sprite{
return (m_nearPlane);
}
public function get camera():GameCameraManager{
return (m_camera);
}
public function setLevelTime(a_value:Number):void{
m_levelTime = MAX_LEVEL_TIME;
}
public function get tokensLeft():Number{
return (m_tokensLeft);
}
public function get backgroundManager():GameBackgroundManager{
return (m_backgroundManager);
}
public function set playerInitialPosition(a_value:b2Vec2):void{
m_playerInitialPosition = a_value;
}
public function get player():PlayerControl{
return (m_player);
}
public function get componentManager():GameComponentManager{
return (m_componentManager);
}
public function get levelTime():String{
var minutes:Number = int((m_levelTime / 60000));
var seconds:Number = (int((m_levelTime / 1000)) - (minutes * 60));
return (((minutes + ":") + ((seconds >= 10)) ? seconds : ("0" + seconds)));
}
public function get playerInitialPosition():b2Vec2{
return (m_playerInitialPosition);
}
public static function get currentLevel():Number{
return (m_currentLevel);
}
public static function get scoreThisLevel():Number{
return (m_scoreThisLevel);
}
public static function get tokensCollectedThisGame():Number{
return (m_tokensCollectedThisGame);
}
public static function set scoreThisLevel(a_value:Number):void{
m_scoreThisLevel = a_value;
}
public static function set currentLevel(a_value:Number):void{
m_currentLevel = a_value;
}
public static function set tokensCollectedThisGame(a_value:Number):void{
m_tokensCollectedThisGame = a_value;
}
public static function set tokensCollectedThisLevel(a_value:Number):void{
m_tokensCollectedThisLevel = a_value;
JuicyFruitFlavorFling.instance.appHUD.tokenCounter.count.text = ((a_value.toString() + "/") + m_totalTokensThisLevel.toString());
}
public static function get tokensCollectedThisLevel():Number{
return (m_tokensCollectedThisLevel);
}
}
}//package ui.canvas.model
Section 396
//ApplicationHUDCanvas (ui.canvas.ApplicationHUDCanvas)
package ui.canvas {
import flash.events.*;
import flash.display.*;
import ui.component.control.*;
import fla.ui.game.*;
import core.component.base.iface.*;
import com.greensock.*;
import core.component.custom.*;
import flash.net.*;
import fla.ui.canvas.*;
import ui.component.view.*;
import com.soapcreative.net.tracking.*;
public class ApplicationHUDCanvas extends Sprite implements IDestroyable {
private var m_soundButtonControl:SoundButtonControl;
private var m_lifeBar:LifeBarControl;
private var m_shouldDisableHighScores:Boolean;
private var m_flaApplicationHUD:ApplicationHUD;
private var m_scoreBar:ScoreBarControl;
private static const JF_URL:String = "http://www.facebook.com/#!/juicyfruit?ref=ts";
public function ApplicationHUDCanvas(){
super();
m_flaApplicationHUD = new ApplicationHUD();
m_flaApplicationHUD.mouseEnabled = (mouseEnabled = false);
addChild(m_flaApplicationHUD);
m_soundButtonControl = new SoundButtonControl(new SoundButtonView(m_flaApplicationHUD.soundButton));
m_lifeBar = new LifeBarControl(new LifeBarView(m_flaApplicationHUD.lifeBar));
m_scoreBar = new ScoreBarControl(new ScoreBarView(m_flaApplicationHUD.scoreBar));
m_flaApplicationHUD.homeButton.gotoAndStop("out");
m_flaApplicationHUD.pauseButton.gotoAndStop("out");
m_flaApplicationHUD.jfLinkButton.gotoAndStop("out");
m_flaApplicationHUD.homeButton.addEventListener(MouseEvent.CLICK, resolveHomeClick);
m_flaApplicationHUD.homeButton.addEventListener(MouseEvent.MOUSE_OVER, resolveHomeOver);
m_flaApplicationHUD.homeButton.addEventListener(MouseEvent.MOUSE_OUT, resolveHomeOut);
m_flaApplicationHUD.pauseButton.addEventListener(MouseEvent.CLICK, resolvePauseClick);
m_flaApplicationHUD.pauseButton.addEventListener(MouseEvent.MOUSE_OVER, resolvePauseOver);
m_flaApplicationHUD.pauseButton.addEventListener(MouseEvent.MOUSE_OUT, resolvePauseOut);
m_flaApplicationHUD.jfLinkButton.addEventListener(MouseEvent.CLICK, resolveLinkClick);
m_flaApplicationHUD.jfLinkButton.addEventListener(MouseEvent.MOUSE_OVER, resolveLinkOver);
m_flaApplicationHUD.jfLinkButton.addEventListener(MouseEvent.MOUSE_OUT, resolveLinkOut);
m_soundButtonControl.addEventListener(MouseEvent.CLICK, resolveAudioClick);
JuicyFruitFlavorFling.instance.musicManager.audioInterface = m_soundButtonControl;
JuicyFruitFlavorFling.instance.sfxManager.audioInterface = m_soundButtonControl;
}
public function set showTokenCounter(a_value:Boolean):void{
m_flaApplicationHUD.tokenCounter.visible = a_value;
}
private function resolveLinkOver(a_event:MouseEvent):void{
m_flaApplicationHUD.jfLinkButton.gotoAndStop("over");
}
public function get tokenCounter():TokenCounter{
return (m_flaApplicationHUD.tokenCounter);
}
public function get level():CurrentLevel{
return (m_flaApplicationHUD.level);
}
public function set showSoundButton(a_value:Boolean):void{
m_flaApplicationHUD.soundButton.visible = a_value;
}
public function hide():void{
m_flaApplicationHUD.visible = false;
}
public function get soundButtonControl():SoundButtonControl{
return (m_soundButtonControl);
}
public function set showLinkButton(a_value:Boolean):void{
m_flaApplicationHUD.jfLinkButton.visible = a_value;
}
private function resolvePauseOut(a_event:MouseEvent):void{
m_flaApplicationHUD.pauseButton.gotoAndStop("out");
}
public function set showLevel(a_value:Boolean):void{
m_flaApplicationHUD.level.visible = a_value;
}
public function set showPauseButton(a_value:Boolean):void{
m_flaApplicationHUD.pauseButton.visible = a_value;
}
public function set showHomeButton(a_value:Boolean):void{
m_flaApplicationHUD.homeButton.visible = a_value;
}
private function resolveHomeClick(a_event:MouseEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_HOME));
m_flaApplicationHUD.homeButton.gotoAndStop("out");
}
private function resolveAudioClick(a_event:MouseEvent):void{
if (m_soundButtonControl.isSoundOn){
JuicyFruitFlavorFling.instance.musicManager.resumeAudio();
} else {
JuicyFruitFlavorFling.instance.musicManager.pauseAudio();
};
if (m_soundButtonControl.isSoundOn){
JuicyFruitFlavorFling.instance.sfxManager.resumeAudio();
} else {
JuicyFruitFlavorFling.instance.sfxManager.pauseAudio();
};
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
}
private function resolveHomeOver(a_event:MouseEvent):void{
m_flaApplicationHUD.homeButton.gotoAndStop("over");
}
public function get scoreBar():ScoreBarControl{
return (m_scoreBar);
}
private function resolveLinkClick(a_event:MouseEvent):void{
var a_event = a_event;
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
try {
GameTracking.trackLink(JF_URL);
navigateToURL(new URLRequest(JF_URL), "_blank");
//unresolved jump
var _slot1 = e;
} finally {
m_flaApplicationHUD.jfLinkButton.gotoAndStop("out");
};
}
public function set showHighScoresButton(a_value:Boolean):void{
}
public function destroy():void{
m_soundButtonControl.destroy();
m_flaApplicationHUD.homeButton.removeEventListener(MouseEvent.CLICK, resolveHomeClick);
m_flaApplicationHUD.homeButton.removeEventListener(MouseEvent.MOUSE_OVER, resolveHomeOver);
m_flaApplicationHUD.homeButton.removeEventListener(MouseEvent.MOUSE_OUT, resolveHomeOut);
m_flaApplicationHUD.pauseButton.removeEventListener(MouseEvent.CLICK, resolvePauseClick);
m_flaApplicationHUD.pauseButton.removeEventListener(MouseEvent.MOUSE_OVER, resolvePauseOver);
m_flaApplicationHUD.pauseButton.removeEventListener(MouseEvent.MOUSE_OUT, resolvePauseOut);
m_flaApplicationHUD.jfLinkButton.removeEventListener(MouseEvent.CLICK, resolveLinkClick);
m_flaApplicationHUD.jfLinkButton.removeEventListener(MouseEvent.MOUSE_OVER, resolveLinkOver);
m_flaApplicationHUD.jfLinkButton.removeEventListener(MouseEvent.MOUSE_OUT, resolveLinkOut);
m_soundButtonControl.removeEventListener(MouseEvent.CLICK, resolveAudioClick);
}
private function resolveLinkOut(a_event:MouseEvent):void{
m_flaApplicationHUD.jfLinkButton.gotoAndStop("out");
}
private function resolveHomeOut(a_event:MouseEvent):void{
m_flaApplicationHUD.homeButton.gotoAndStop("out");
}
public function set showGameTimer(a_value:Boolean):void{
m_flaApplicationHUD.gameTimer.visible = a_value;
}
public function get gameTimer():GameTimer{
return (m_flaApplicationHUD.gameTimer);
}
public function set showLifeBar(a_value:Boolean):void{
m_flaApplicationHUD.lifeBar.visible = a_value;
}
private function resolvePauseOver(a_event:MouseEvent):void{
m_flaApplicationHUD.pauseButton.gotoAndStop("over");
}
public function get lifeBar():LifeBarControl{
return (m_lifeBar);
}
public function set showGameLogo(a_value:Boolean):void{
m_flaApplicationHUD.gameLogo.visible = a_value;
}
public function set showScoreBar(a_value:Boolean):void{
m_flaApplicationHUD.scoreBar.visible = a_value;
}
public function show():void{
m_flaApplicationHUD.visible = true;
}
private function resolvePauseClick(a_event:MouseEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_PAUSE));
m_flaApplicationHUD.pauseButton.gotoAndStop("out");
}
public function set shouldDisableHighScores(a_value:Boolean):void{
m_shouldDisableHighScores = a_value;
if (m_shouldDisableHighScores){
TweenMax.to(m_flaApplicationHUD.highScoresButton, 3, {alpha:0.5});
m_flaApplicationHUD.highScoresButton.gotoAndStop("out");
} else {
TweenMax.killAll();
m_flaApplicationHUD.highScoresButton.alpha = 1;
};
}
}
}//package ui.canvas
Section 397
//EditHUDCanvas (ui.canvas.EditHUDCanvas)
package ui.canvas {
import flash.events.*;
import flash.display.*;
import ui.component.control.*;
import core.component.base.iface.*;
import fla.ui.canvas.*;
import ui.component.view.*;
public class EditHUDCanvas extends Sprite implements IDestroyable {
private var m_flaApplicationHUD:EditHUD;
private var m_homeButtonControl:HomeButtonControl;
private var m_soundButtonControl:SoundButtonControl;
private static const JF_URL:String = "http://www.juicyfruit.com/";
public function EditHUDCanvas(){
super();
m_flaApplicationHUD = new EditHUD();
addChild(m_flaApplicationHUD);
m_homeButtonControl = new HomeButtonControl(new HomeButtonView(m_flaApplicationHUD.homeButton));
}
public function destroy():void{
m_homeButtonControl.destroy();
}
private function resolveAudioClick(a_event:MouseEvent):void{
if (m_soundButtonControl.isSoundOn){
JuicyFruitFlavorFling.instance.musicManager.resumeAudio();
} else {
JuicyFruitFlavorFling.instance.musicManager.pauseAudio();
};
if (m_soundButtonControl.isSoundOn){
JuicyFruitFlavorFling.instance.sfxManager.unmuteAudio();
} else {
JuicyFruitFlavorFling.instance.sfxManager.muteAudio();
};
}
}
}//package ui.canvas
Section 398
//GameCanvas (ui.canvas.GameCanvas)
package ui.canvas {
import core.component.base.*;
import game.manager.*;
import flash.events.*;
import flash.display.*;
import game.component.control.*;
import Box2D.Common.Math.*;
import core.component.base.iface.*;
import game.manager.iface.*;
import flash.geom.*;
import fla.game.component.*;
import core.component.custom.*;
import flash.utils.*;
import ui.canvas.model.*;
import flash.ui.*;
public class GameCanvas extends GameCanvasModel implements IDestroyable {
public function GameCanvas(){
super();
m_tokensCollectedThisLevel = (m_tokensCollectedThisGame = 0);
addEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
instance = this;
}
private function resolveEnterFrame(a_event:Event):void{
var particleEmitter:Object;
var zoomMatrix:Matrix;
var colorTokens:Array;
var colorToken:ColorTokenControl;
var pointTokens:Array;
var token:TokenControl;
var currentTime:Number = getTimer();
var deltaTime:Number = (currentTime - m_previousTime);
m_previousTime = currentTime;
if (JuicyFruitFlavorFling.instance.currentStateID != "game"){
return;
};
if (((m_levelBuffer) && (m_levelBuffer.parent))){
removeChild(m_levelBuffer);
JuicyFruitFlavorFling.instance.appHUD.show();
};
m_levelTime = (m_levelTime - deltaTime);
JuicyFruitFlavorFling.instance.appHUD.gameTimer.time.text = levelTime;
if (m_levelTime < 0){
JuicyFruitFlavorFling.instance.appHUD.hide();
bufferLastLevel(m_currentLevel);
JuicyFruitFlavorFling.instance.appHUD.show();
JuicyFruitFlavorFling.instance.appHUD.scoreBar.score = (JuicyFruitFlavorFling.instance.appHUD.scoreBar.score - m_scoreThisLevel);
m_scoreThisLevel = 0;
m_tokensCollectedThisLevel = 0;
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_LEVEL_OUT_OF_TIME));
m_levelTime = MAX_LEVEL_TIME;
};
if ((((m_tokensLeft == 0)) && (m_player.inputEnabled))){
m_player.inputEnabled = false;
};
if (m_player.flinging){
m_camera.trackedObject = m_player.getViewDisplayObject();
};
m_camera.update();
m_farPlane.transform.matrix = m_camera.getTransformAt(FAR_PLANE_DISTANCE);
m_midPlane.transform.matrix = m_camera.getTransformAt(MID_PLANE_DISTANCE);
m_nearPlane.transform.matrix = m_camera.getTransformAt(NEAR_PLANE_DISTANCE);
if ((((m_farPlane.x < m_panFarPlaneMin.x)) || ((m_farPlane.x > m_panFarPlaneMax.x)))){
m_farPlane.x = ((m_farPlane.x)<0) ? m_panFarPlaneMin.x : m_panFarPlaneMax.x;
};
if ((((m_farPlane.y < m_panFarPlaneMin.y)) || ((m_farPlane.y > m_panFarPlaneMax.y)))){
m_farPlane.y = ((m_farPlane.y)<0) ? m_panFarPlaneMin.y : m_panFarPlaneMax.y;
};
if (m_shouldZoom){
zoomMatrix = new Matrix();
zoomMatrix.tx = m_zoomPoint.x;
zoomMatrix.ty = m_zoomPoint.y;
zoomMatrix.a = m_zoomScale;
zoomMatrix.d = m_zoomScale;
m_nearPlane.transform.matrix = zoomMatrix;
if (m_player.inputEnabled){
m_wasInputBeforeZoom = m_player.inputEnabled;
m_player.inputEnabled = false;
};
return;
} else {
if (m_wasInputBeforeZoom){
m_player.inputEnabled = true;
m_wasInputBeforeZoom = false;
};
};
for each (particleEmitter in m_particleEmitters) {
particleEmitter.lifeSpan = (particleEmitter.lifeSpan - PHYSICS_STEP);
if (particleEmitter.lifeSpan < 0){
particleEmitter.emitter.stop();
m_particleEmitters.splice(m_particleEmitters.indexOf(particleEmitter), 1);
};
};
while (int((deltaTime / (PHYSICS_STEP * 1000))) > 0) {
updatePhysicalWorld((PHYSICS_STEP * 1000));
deltaTime = (deltaTime - (PHYSICS_STEP * 1000));
};
updatePhysicalWorld(deltaTime);
if (teleportPlayer){
m_player.hackChangePlayerPosition(teleportPosition);
teleportPlayer = false;
};
var playerPosition:b2Vec2 = m_player.rigidBody.GetPosition();
if (!m_player.clientControlled){
if ((playerPosition.y * PHYSICS_WORLD_SCALE) > SCREEN_HEIGHT){
JuicyFruitFlavorFling.instance.appHUD.lifeBar.subtractLife();
colorTokens = m_componentManager.getCollectedOfType(ColorTokenControl);
for each (colorToken in colorTokens) {
if (m_componentManager.doesCollectedContain((colorToken as IGameComponent))){
m_backgroundManager.resetMask(colorToken.color);
};
};
pointTokens = m_componentManager.getCollectedOfType(TokenControl);
for each (token in pointTokens) {
m_scoreThisLevel = (m_scoreThisLevel - token.pointValue);
JuicyFruitFlavorFling.instance.appHUD.scoreBar.score = (JuicyFruitFlavorFling.instance.appHUD.scoreBar.score - token.pointValue);
};
m_componentManager.instantiateCollected(m_nearPlane);
if (JuicyFruitFlavorFling.instance.appHUD.lifeBar.lives > 0){
resetLevel();
} else {
JuicyFruitFlavorFling.instance.appHUD.hide();
bufferLastLevel(m_currentLevel);
JuicyFruitFlavorFling.instance.appHUD.show();
JuicyFruitFlavorFling.instance.appHUD.scoreBar.score = (JuicyFruitFlavorFling.instance.appHUD.scoreBar.score - m_scoreThisLevel);
m_scoreThisLevel = 0;
m_tokensCollectedThisLevel = 0;
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_LEVEL_FAIL));
m_levelTime = MAX_LEVEL_TIME;
};
m_player.flinging = false;
};
};
}
public function addParticleEmitter(a_position:b2Vec2, a_particle:Class=null):void{
var particleEmitter:Object = new Object();
particleEmitter.emitter = new ParticleEmitter((a_position.x * PHYSICS_WORLD_SCALE), (a_position.y * PHYSICS_WORLD_SCALE), m_particleEmitterData);
particleEmitter.lifeSpan = PARTICLE_EMITTER_LIFE_SPAN;
if (a_particle != null){
particleEmitter.emitter.particleData.particleSprite = a_particle;
} else {
particleEmitter.emitter.particleData.particleSprite = YellowParticle;
};
particleEmitter.emitter.start();
m_nearPlane.addChild(particleEmitter.emitter);
m_particleEmitters.push(particleEmitter);
}
private function resolveMouseMove(a_event:MouseEvent):void{
if (m_shouldZoom){
return;
};
m_panDelta.x = (m_panMousePoint.x - a_event.stageX);
m_panDelta.y = (m_panMousePoint.y - a_event.stageY);
m_panObject.x = (m_panObject.x + m_panDelta.x);
m_panObject.y = (m_panObject.y + m_panDelta.y);
m_panMousePoint.x = a_event.stageX;
m_panMousePoint.y = a_event.stageY;
}
public function bufferLastLevel(a_newLevel:Number):void{
var bitmapData:BitmapData = new BitmapData(SCREEN_WIDTH, SCREEN_HEIGHT, false, 0);
bitmapData.draw(stage);
m_levelBuffer = new Bitmap(bitmapData);
m_currentLevel = a_newLevel;
loadLevel();
addChild(m_levelBuffer);
}
private function resolveAddedToStage(a_event:Event):void{
loadLevel();
stage.addEventListener(KeyboardEvent.KEY_DOWN, resolveKeyDown);
addEventListener(Event.ENTER_FRAME, resolveEnterFrame);
addEventListener(MouseEvent.MOUSE_DOWN, resolveMouseDown);
removeEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
private function updatePhysicalWorld(a_msElapsed:Number):void{
m_physicsWorld.Step(PHYSICS_STEP, PHYSICS_VELOCITY_CONSTRAINT, PHYSICS_POSITION_CONSTRAINT);
m_physicsWorld.ClearForces();
m_componentManager.update((PHYSICS_STEP * 1000));
}
private function resolveMouseUp(a_event:MouseEvent):void{
m_camera.trackedObject = m_originalObject;
m_panObject = null;
removeEventListener(MouseEvent.MOUSE_MOVE, resolveMouseMove);
stage.removeEventListener(MouseEvent.MOUSE_UP, resolveMouseUp);
}
private function resolveKeyDown(a_event:KeyboardEvent):void{
var minX:Number;
var maxX:Number;
var minY:Number;
var maxY:Number;
var child:DisplayObject;
var i:Number;
var ratioX:Number;
var ratioY:Number;
if ((((a_event.keyCode == Keyboard.SPACE)) && (!(m_shouldZoom)))){
m_shouldZoom = true;
minX = int.MAX_VALUE;
maxX = -(int.MAX_VALUE);
minY = int.MAX_VALUE;
maxY = -(int.MAX_VALUE);
i = 0;
while (i < m_nearPlane.numChildren) {
child = m_nearPlane.getChildAt(i);
minX = Math.min((child.x - (child.width / 2)), minX);
maxX = Math.max((child.x + (child.width / 2)), maxX);
minY = Math.min((child.y - (child.height / 2)), minY);
maxY = Math.max((child.y + (child.height / 2)), maxY);
i++;
};
minX = (minX - ZOOM_PAD);
maxX = (maxX + ZOOM_PAD);
minY = (minY - ZOOM_PAD);
maxY = (maxY + ZOOM_PAD);
ratioX = (SCREEN_WIDTH / (maxX - minX));
ratioY = (SCREEN_HEIGHT / (maxY - minY));
m_zoomScale = Math.min(ratioX, ratioY);
m_zoomScale = Math.min(m_zoomScale, 1);
m_zoomPoint = new Point(((SCREEN_WIDTH / 2) - ((minX + ((maxX - minX) / 2)) * m_zoomScale)), ((SCREEN_HEIGHT / 2) - ((minY + ((maxY - minY) / 2)) * m_zoomScale)));
stage.addEventListener(KeyboardEvent.KEY_UP, resolveKeyUp);
};
}
public function destroy():void{
m_contactResponder.destroy();
stage.removeEventListener(KeyboardEvent.KEY_DOWN, resolveKeyDown);
m_componentManager.destroyAllRegistered();
removeEventListener(Event.ENTER_FRAME, resolveEnterFrame);
removeEventListener(MouseEvent.MOUSE_DOWN, resolveMouseDown);
}
private function resolveMouseDown(a_event:MouseEvent):void{
if (((!((((((((a_event.target is Player)) || ((a_event.target is Tongue)))) || ((a_event.target is Anchor)))) || ((a_event.target is TimedAnchor))))) && (!(m_player.clientControlled)))){
m_panObject = new Sprite();
m_panObject.x = m_camera.trackedObject.x;
m_panObject.y = m_camera.trackedObject.y;
m_panMousePoint.x = a_event.stageX;
m_panMousePoint.y = a_event.stageY;
m_originalObject = m_camera.trackedObject;
m_camera.trackedObject = m_panObject;
addEventListener(MouseEvent.MOUSE_MOVE, resolveMouseMove);
stage.addEventListener(MouseEvent.MOUSE_UP, resolveMouseUp);
};
}
private function resetLevel():void{
var anchor:TimedAnchorControl;
m_player.rigidBody.SetPosition(b2Vec2.Make(m_playerInitialPosition.x, m_playerInitialPosition.y));
m_player.rigidBody.SetLinearVelocity(b2Vec2.Make(0, 0));
m_nearPlane.removeEventListener(GameEvent.ANCHOR_DESTROYED, m_contactResponder.resolveTimedAnchorDestroyed);
var anchors:Array = m_componentManager.getComponentsOfType(TimedAnchorControl);
for each (anchor in anchors) {
anchor.active = true;
anchor.resetLifeSpan();
};
}
private function resolveKeyUp(a_event:KeyboardEvent):void{
if (a_event.keyCode == Keyboard.SPACE){
m_shouldZoom = false;
stage.removeEventListener(KeyboardEvent.KEY_UP, resolveKeyUp);
};
}
public function loadLevel():void{
m_componentManager.destroyAllRegistered();
var i:Number = (m_nearPlane.numChildren - 1);
while (i >= 0) {
m_nearPlane.removeChildAt(i);
i--;
};
m_levelManager.loadLevel(m_currentLevel);
JuicyFruitFlavorFling.instance.levelAchieved = m_currentLevel;
JuicyFruitFlavorFling.instance.appHUD.lifeBar.maxLives = m_levelManager.lifeCount;
JuicyFruitFlavorFling.instance.appHUD.lifeBar.resetLives();
JuicyFruitFlavorFling.instance.appHUD.scoreBar.score = (JuicyFruitFlavorFling.instance.scoreManager.getScore() - JuicyFruitFlavorFling.instance.scoreManager.getScore(m_currentLevel));
m_player = m_levelManager.player;
m_camera = new GameCameraManager(m_player.getViewDisplayObject(), SCREEN_WIDTH, SCREEN_HEIGHT);
m_camera.focusOnTarget();
m_farPlane.transform.matrix = m_camera.getTransformAt(FAR_PLANE_DISTANCE);
m_nearPlane.transform.matrix = m_camera.getTransformAt(NEAR_PLANE_DISTANCE);
m_tokensLeft = (m_totalTokensThisLevel = m_levelManager.tokenCount);
m_playerInitialPosition = m_player.rigidBody.GetPosition().Copy();
m_backgroundManager.resetAllMasks();
m_backgroundManager.offsetBackground(m_levelManager.bgX, m_levelManager.bgY);
JuicyFruitFlavorFling.instance.appHUD.level.levelNumber.text = m_currentLevel.toString();
}
}
}//package ui.canvas
Section 399
//GameCompleteCanvas (ui.canvas.GameCompleteCanvas)
package ui.canvas {
import core.component.base.*;
import flash.events.*;
import flash.display.*;
import Box2D.Common.Math.*;
import ui.component.control.*;
import core.component.base.iface.*;
import flash.geom.*;
import fla.game.component.*;
import flash.net.*;
import flash.utils.*;
import ui.canvas.model.*;
import fla.ui.canvas.*;
import ui.*;
import com.soapcreative.net.tracking.*;
public class GameCompleteCanvas extends Sprite implements IDestroyable {
private var m_particleEmitterData:ParticleDataProvider;
private var m_submitScoreButton:StandardButtonControl;
private var m_canvasView:GameComplete;
private var m_emitters:Array;
private var m_timer:Timer;
private static const SURVEY_URL:String = "http://ar.voicefive.com/bmx3/projects/ban.htm";
private static const PHYSICS_GRAVITY_VECTOR:b2Vec2 = b2Vec2.Make(0, 39.24);
public function GameCompleteCanvas(){
super();
m_canvasView = new GameComplete();
addChild(m_canvasView);
m_canvasView.totalScore.text = JuicyFruitFlavorFling.instance.appHUD.scoreBar.score.toString();
m_canvasView.totalTokens.text = GameCanvasModel.tokensCollectedThisGame.toString();
m_emitters = new Array();
m_particleEmitterData = new ParticleDataProvider();
m_particleEmitterData.emissionRate = 20;
m_particleEmitterData.lifeSpan = 0.5;
m_particleEmitterData.angleMinimum = 0;
m_particleEmitterData.angleMaximum = (2 * Math.PI);
m_particleEmitterData.impulseMinimum = 9000;
m_particleEmitterData.impulseMaximum = 13000;
m_particleEmitterData.linearDamping = 0.01;
m_particleEmitterData.gravity = new Point(PHYSICS_GRAVITY_VECTOR.x, (PHYSICS_GRAVITY_VECTOR.y * 2));
m_particleEmitterData.scaleMinimum = 0.5;
m_particleEmitterData.scaleMaximum = 1;
m_particleEmitterData.rotationMinimum = 0;
m_particleEmitterData.rotationMaximum = Math.PI;
m_particleEmitterData.particleSprite = YellowParticle;
m_canvasView.surveyButton.addEventListener(MouseEvent.CLICK, resolveSurveyClick);
var rain:FruitRain = new FruitRain();
rain.addObstacle(m_canvasView.background);
rain.start();
addChild(rain);
m_timer = new Timer(33);
m_timer.addEventListener(TimerEvent.TIMER, resolveEnterFrame);
m_timer.start();
}
private function resolveEnterFrame(a_event:Event):void{
var o:Object;
var emitter:ParticleEmitter;
for each (o in m_emitters) {
o.t = (o.t - (33 / 1000));
if (o.t <= 0){
(o.e as ParticleEmitter).stop();
};
};
if (Math.random() > 0.9){
switch (int((Math.random() * 4))){
case 0:
m_particleEmitterData.particleSprite = YellowParticle;
break;
case 1:
m_particleEmitterData.particleSprite = PurpleParticle;
break;
case 2:
m_particleEmitterData.particleSprite = GreenParticle;
break;
default:
m_particleEmitterData.particleSprite = RedParticle;
break;
};
emitter = new ParticleEmitter((Math.random() * 700), (Math.random() * 500), m_particleEmitterData);
parent.addChildAt(emitter, parent.getChildIndex(JuicyFruitFlavorFling.instance.appHUD));
emitter.mouseChildren = false;
emitter.mouseEnabled = false;
emitter.start();
m_emitters.push({e:emitter, t:1.5});
};
}
private function resolveSurveyClick(a_event:MouseEvent):void{
var vars:URLVariables;
var request:URLRequest;
var a_event = a_event;
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
GameTracking.trackLink(SURVEY_URL);
vars = new URLVariables();
vars["pid"] = "p50354052";
vars["name"] = "miniclip";
request = new URLRequest(SURVEY_URL);
request.data = vars;
navigateToURL(request, "_blank");
//unresolved jump
var _slot1 = e;
}
public function destroy():void{
m_canvasView.surveyButton.removeEventListener(MouseEvent.CLICK, resolveSurveyClick);
}
}
}//package ui.canvas
Section 400
//HowToPlayCanvas (ui.canvas.HowToPlayCanvas)
package ui.canvas {
import flash.events.*;
import flash.display.*;
import core.component.base.iface.*;
import core.component.custom.*;
import ui.canvas.model.*;
import fla.ui.canvas.*;
import com.soapcreative.net.tracking.*;
public class HowToPlayCanvas extends Sprite implements IDestroyable {
private var m_canvasView:HowToPlay;
private static const ANALYTICS_TRACKING_NAME:String = "HowToPlay";
public function HowToPlayCanvas(){
super();
m_canvasView = new HowToPlay();
addChild(m_canvasView);
m_canvasView.nextButton.gotoAndStop("out");
m_canvasView.prevButton.gotoAndStop("out");
m_canvasView.playButton.gotoAndStop("out");
m_canvasView.nextButton.addEventListener(MouseEvent.CLICK, resolveNextClick);
m_canvasView.nextButton.addEventListener(MouseEvent.MOUSE_OVER, resolveNextOver);
m_canvasView.nextButton.addEventListener(MouseEvent.MOUSE_OUT, resolveNextOut);
m_canvasView.prevButton.addEventListener(MouseEvent.CLICK, resolvePrevClick);
m_canvasView.prevButton.addEventListener(MouseEvent.MOUSE_OVER, resolvePrevOver);
m_canvasView.prevButton.addEventListener(MouseEvent.MOUSE_OUT, resolvePrevOut);
m_canvasView.playButton.addEventListener(MouseEvent.CLICK, resolvePlayClick);
m_canvasView.playButton.addEventListener(MouseEvent.MOUSE_OVER, resolvePlayOver);
m_canvasView.playButton.addEventListener(MouseEvent.MOUSE_OUT, resolvePlayOut);
m_canvasView.prevButton.visible = false;
m_canvasView.playButton.visible = false;
addEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
public function destroy():void{
m_canvasView.nextButton.removeEventListener(MouseEvent.CLICK, resolveNextClick);
m_canvasView.nextButton.removeEventListener(MouseEvent.MOUSE_OVER, resolveNextOver);
m_canvasView.nextButton.removeEventListener(MouseEvent.MOUSE_OUT, resolveNextOut);
m_canvasView.prevButton.removeEventListener(MouseEvent.CLICK, resolvePrevClick);
m_canvasView.prevButton.removeEventListener(MouseEvent.MOUSE_OVER, resolvePrevOver);
m_canvasView.prevButton.removeEventListener(MouseEvent.MOUSE_OUT, resolvePrevOut);
m_canvasView.playButton.removeEventListener(MouseEvent.CLICK, resolvePlayClick);
m_canvasView.playButton.removeEventListener(MouseEvent.MOUSE_OVER, resolvePlayOver);
m_canvasView.playButton.removeEventListener(MouseEvent.MOUSE_OUT, resolvePlayOut);
}
private function resolveAddedToStage(a_event:Event):void{
GameTracking.trackPage(ANALYTICS_TRACKING_NAME);
removeEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
private function resolvePlayClick(a_event:MouseEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
if (JuicyFruitFlavorFling.instance.levelAchieved == 1){
GameTracking.startGame();
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_PLAY, false, false, 1));
GameTracking.startLevel(GameCanvasModel.currentLevel);
} else {
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_LEVEL_SELECT));
};
}
private function resolvePrevClick(a_event:MouseEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
m_canvasView.prevFrame();
m_canvasView.prevButton.visible = !((m_canvasView.currentFrame == 1));
m_canvasView.nextButton.visible = true;
m_canvasView.playButton.visible = false;
}
private function resolvePlayOut(a_event:MouseEvent):void{
m_canvasView.playButton.gotoAndStop("out");
}
private function resolvePrevOut(a_event:MouseEvent):void{
m_canvasView.prevButton.gotoAndStop("out");
}
private function resolveNextClick(a_event:MouseEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
m_canvasView.nextFrame();
m_canvasView.nextButton.visible = !((m_canvasView.currentFrame == 4));
m_canvasView.prevButton.visible = true;
m_canvasView.playButton.visible = (m_canvasView.currentFrame == 4);
}
private function resolvePrevOver(a_event:MouseEvent):void{
m_canvasView.prevButton.gotoAndStop("over");
}
private function resolvePlayOver(a_event:MouseEvent):void{
m_canvasView.playButton.gotoAndStop("over");
}
private function resolveNextOver(a_event:MouseEvent):void{
m_canvasView.nextButton.gotoAndStop("over");
}
private function resolveNextOut(a_event:MouseEvent):void{
m_canvasView.nextButton.gotoAndStop("out");
}
}
}//package ui.canvas
Section 401
//LevelCompleteCanvas (ui.canvas.LevelCompleteCanvas)
package ui.canvas {
import core.component.base.*;
import flash.events.*;
import flash.display.*;
import core.component.base.iface.*;
import flash.net.*;
import ui.canvas.model.*;
import fla.ui.canvas.*;
import com.soapcreative.net.tracking.*;
public class LevelCompleteCanvas extends Sprite implements IDestroyable {
private var m_canvasView:LevelComplete;
private static const SURVEY_URL:String = "http://ar.voicefive.com/bmx3/projects/ban.htm";
public function LevelCompleteCanvas(){
super();
m_canvasView = new LevelComplete();
addChild(m_canvasView);
m_canvasView.timeLeft.text = GameCanvasModel.instance.levelTime;
m_canvasView.levelScore.text = GameCanvasModel.scoreThisLevel.toString();
m_canvasView.bonusItems.text = GameCanvasModel.tokensCollectedThisLevel.toString();
m_canvasView.totalScore.text = JuicyFruitFlavorFling.instance.scoreManager.getScore().toString();
m_canvasView.playButton.addEventListener(MouseEvent.CLICK, resolveMouseClick);
m_canvasView.playButton.addEventListener(MouseEvent.MOUSE_OVER, resolveMouseOver);
m_canvasView.playButton.addEventListener(MouseEvent.MOUSE_OUT, resolveMouseOut);
m_canvasView.surveyButton.visible = (GameCanvasModel.currentLevel == 6);
m_canvasView.surveyButton.addEventListener(MouseEvent.CLICK, resolveSurveyClick);
}
private function resolveSurveyClick(a_event:MouseEvent):void{
var vars:URLVariables;
var request:URLRequest;
var a_event = a_event;
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
GameTracking.trackLink(SURVEY_URL);
vars = new URLVariables();
vars["pid"] = "p50354052";
vars["name"] = "miniclip";
request = new URLRequest(SURVEY_URL);
request.data = vars;
navigateToURL(request, "_blank");
//unresolved jump
var _slot1 = e;
}
private function resolveMouseOut(a_event:MouseEvent):void{
m_canvasView.playButton.gotoAndStop("out");
}
public function destroy():void{
m_canvasView.playButton.removeEventListener(MouseEvent.CLICK, resolveMouseClick);
m_canvasView.playButton.removeEventListener(MouseEvent.MOUSE_OVER, resolveMouseOver);
m_canvasView.playButton.removeEventListener(MouseEvent.MOUSE_OUT, resolveMouseOut);
m_canvasView.surveyButton.removeEventListener(MouseEvent.CLICK, resolveSurveyClick);
GameCanvasModel.instance.setLevelTime(0);
}
private function resolveMouseOver(a_event:MouseEvent):void{
m_canvasView.playButton.gotoAndStop("over");
}
private function resolveMouseClick(a_event:MouseEvent):void{
if (GameCanvasModel.currentLevel >= 0){
GameTracking.startLevel(GameCanvasModel.currentLevel);
};
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
JuicyFruitFlavorFling.instance.dispatchEvent(new StateEvent(StateEvent.STATE_EVENT_CHANGE));
}
}
}//package ui.canvas
Section 402
//LevelEditCanvas (ui.canvas.LevelEditCanvas)
package ui.canvas {
import flash.events.*;
import flash.display.*;
import com.greensock.events.*;
import ui.component.control.*;
import core.component.base.iface.*;
import flash.geom.*;
import com.greensock.transform.*;
import fla.game.component.*;
import core.component.custom.*;
import fla.ui.canvas.*;
import ui.component.misc.*;
import ui.component.view.*;
import flash.text.*;
import fla.game.splat.*;
import fla.game.ui.*;
import flash.ui.*;
public class LevelEditCanvas extends Sprite implements IDestroyable {
private var m_xmlViewCanvas:XMLView;
private var m_backButton:StandardButtonControl;
private var m_canExportLevel:Boolean;// = false
private var m_levelTransform:Matrix;
private var m_attributeToPropertyMap:Object;
private var m_levelCanvas:Sprite;
private var m_canvasView:LevelEdit;
private var m_viewXMLButton:StandardButtonControl;
private var m_tagNameToTypeAndPropertyMap:Object;
private var m_transformManager:TransformManager;
private var m_editObject:EditableObject;
private var m_testButton:StandardButtonControl;
private static const LIFE_REG_EX:RegExp = /[1-6]{1}/;
private static const DEFAULT_HEIGHT:Number = 20;
private static const DEFAULT_WIDTH:Number = 100;
private static const DEFAULT_SPEED:Number = 1;
private static const DEFAULT_UFO_HEIGHT:Number = 100;
private static const DEFAULT_LIFE_SPAN:Number = 10;
private static const NUMBER_REG_EX:RegExp = /[\-]?\d+/;
private static const SCALE_DOWN:Number = 0.95;
private static const DEFAULT_ROTATION:Number = 0;
private static const HIT_RADIUS_ALPHA:Number = 0.5;
private static const SCALE_UP:Number = 1.05;
private static const COLOR_REG_EX:RegExp = /0x[0-9a-fA-F]{6}/;
private static const DEFAULT_ROTATION_RATE:Number = 0.5;
private static const DEFAULT_COLOR:String = "0xFFFFFF";
private static const DEFAULT_DESTINATION_X:Number = 0;
private static const DEFAULT_DESTINATION_Y:Number = 0;
private static const RADIUS_REG_EX:RegExp = /[01]+\.?\d{0,3}/;
private static const DEFAULT_BLINK_CYCLE:Number = 2;
private static const DEFAULT_BONUS_FORCE:Number = 20;
private static const HIT_RADIUS_COLOR:uint = 0xFF00;
private static const DEFAULT_VALUE:Number = 10;
private static const DEFAULT_HIT_RADIUS:Number = 1;
private static const ROTATION_REG_EX:RegExp = /[0-3]+\.?\d{0,3}/;
private static var m_levelXML:XML;
public function LevelEditCanvas(){
var attribute:String;
super();
m_levelCanvas = new Sprite();
m_levelCanvas.graphics.beginFill(0x333333);
m_levelCanvas.graphics.drawRect(-4680, -5020, 10000, 10000);
addChild(m_levelCanvas);
m_canvasView = new LevelEdit();
addChild(m_canvasView);
m_attributeToPropertyMap = new Object();
m_attributeToPropertyMap["lives"] = m_canvasView.objectPane.lifeCount;
m_attributeToPropertyMap["bgx"] = m_canvasView.objectPane.bgx;
m_attributeToPropertyMap["bgy"] = m_canvasView.objectPane.bgy;
m_attributeToPropertyMap["x"] = m_canvasView.editX;
m_attributeToPropertyMap["y"] = m_canvasView.editY;
m_attributeToPropertyMap["width"] = m_canvasView.editWidth;
m_attributeToPropertyMap["height"] = m_canvasView.editHeight;
m_attributeToPropertyMap["color"] = m_canvasView.editColor;
m_attributeToPropertyMap["bonusforce"] = m_canvasView.editForce;
m_attributeToPropertyMap["lifespan"] = m_canvasView.editLifeSpan;
m_attributeToPropertyMap["rotation"] = m_canvasView.editRotation;
m_attributeToPropertyMap["value"] = m_canvasView.editValue;
m_attributeToPropertyMap["hitradius"] = m_canvasView.editHitRadius;
m_attributeToPropertyMap["rotationrate"] = m_canvasView.editRotationRate;
m_attributeToPropertyMap["destinationx"] = m_canvasView.editDestinationX;
m_attributeToPropertyMap["destinationy"] = m_canvasView.editDestinationY;
m_attributeToPropertyMap["blinkcycle"] = m_canvasView.editBlinkTime;
m_attributeToPropertyMap["speed"] = m_canvasView.editSpeed;
m_tagNameToTypeAndPropertyMap = new Object();
m_tagNameToTypeAndPropertyMap["anchor"] = {type:Anchor, property:m_canvasView.objectPane.anchor};
m_tagNameToTypeAndPropertyMap["bigtoken"] = {type:BigStar, property:m_canvasView.objectPane.bigToken};
m_tagNameToTypeAndPropertyMap["colortoken"] = {type:ColorToken, property:m_canvasView.objectPane.colorToken};
m_tagNameToTypeAndPropertyMap["extralife"] = {type:ExtraLife, property:m_canvasView.objectPane.extraLife};
m_tagNameToTypeAndPropertyMap["player"] = {type:Player, property:m_canvasView.objectPane.player};
m_tagNameToTypeAndPropertyMap["springboard"] = {type:SpringboardRep, property:m_canvasView.objectPane.springboard};
m_tagNameToTypeAndPropertyMap["token"] = {type:TokenRep, property:m_canvasView.objectPane.token};
m_tagNameToTypeAndPropertyMap["surface"] = {type:Surface, property:m_canvasView.objectPane.surface};
m_tagNameToTypeAndPropertyMap["timedanchor"] = {type:TimedAnchor, property:m_canvasView.objectPane.timedAnchor};
m_tagNameToTypeAndPropertyMap["rotatingsurface"] = {type:RotatingSurface, property:m_canvasView.objectPane.rotatingsurface};
m_tagNameToTypeAndPropertyMap["teleportsurface"] = {type:TeleportSurface, property:m_canvasView.objectPane.teleportsurface};
m_tagNameToTypeAndPropertyMap["ufo"] = {type:UFO, property:m_canvasView.objectPane.ufo};
m_tagNameToTypeAndPropertyMap["electrifiedsurface"] = {type:ElectrifiedSurfaceRep, property:m_canvasView.objectPane.electrifiedsurface};
m_tagNameToTypeAndPropertyMap["movinganchor"] = {type:MovingAnchor, property:m_canvasView.objectPane.movinganchor};
m_tagNameToTypeAndPropertyMap["targetsplat"] = {type:Target, property:m_canvasView.objectPane.target};
m_tagNameToTypeAndPropertyMap["mgcloudsplat"] = {type:Cloud, property:m_canvasView.objectPane.cloud};
m_tagNameToTypeAndPropertyMap["mgcloud2splat"] = {type:Cloud2, property:m_canvasView.objectPane.cloud2};
m_tagNameToTypeAndPropertyMap["mgcrazysplat"] = {type:Crazy, property:m_canvasView.objectPane.crazy};
m_tagNameToTypeAndPropertyMap["mgdiscoballsplat"] = {type:DiscoBall, property:m_canvasView.objectPane.discoball};
m_tagNameToTypeAndPropertyMap["mgpipessplat"] = {type:Pipes, property:m_canvasView.objectPane.pipes};
m_tagNameToTypeAndPropertyMap["mgpipes2splat"] = {type:Pipes2, property:m_canvasView.objectPane.pipes2};
m_tagNameToTypeAndPropertyMap["mgpipes3splat"] = {type:Pipes3, property:m_canvasView.objectPane.pipes3};
m_tagNameToTypeAndPropertyMap["mgplanetsplat"] = {type:Planet, property:m_canvasView.objectPane.planet};
m_tagNameToTypeAndPropertyMap["mgplanet2splat"] = {type:Pipes3, property:m_canvasView.objectPane.planet2};
m_tagNameToTypeAndPropertyMap["tutorialattachcollide"] = {type:TutorialAttachCollide, property:m_canvasView.objectPane.tutorialAttachCollide};
m_tagNameToTypeAndPropertyMap["tutorialclickdrag"] = {type:TutorialClickDrag, property:m_canvasView.objectPane.tutorialClickDrag};
m_tagNameToTypeAndPropertyMap["tutorialcollect"] = {type:TutorialCollect, property:m_canvasView.objectPane.tutorialCollect};
m_tagNameToTypeAndPropertyMap["tutorialpresshold"] = {type:TutorialPressHold, property:m_canvasView.objectPane.tutorialPressHold};
m_transformManager = new TransformManager({lockScale:true, lockRotation:true, allowDelete:true, allowMultiSelect:false});
m_transformManager.addEventListener(TransformEvent.SELECTION_CHANGE, resolveTransformManagerSelectionChange);
m_transformManager.addEventListener(TransformEvent.MOVE, resolveTransformManagerMove);
m_transformManager.addEventListener(TransformEvent.SCALE, resolveTransformManagerScale);
m_transformManager.addEventListener(TransformEvent.ROTATE, resolveTransformManagerRotate);
m_transformManager.addEventListener(TransformEvent.DELETE, resolveTransformManagerDelete);
if (!m_levelXML){
createXML();
} else {
createObjectsFromXML();
};
m_testButton = new StandardButtonControl(new StandardButtonView(m_canvasView.testButton));
m_testButton.addEventListener(MouseEvent.CLICK, resolveTestClick);
m_viewXMLButton = new StandardButtonControl(new StandardButtonView(m_canvasView.viewXMLButton));
m_viewXMLButton.addEventListener(MouseEvent.CLICK, resolveViewXMLClick);
addEventListener(MouseEvent.MOUSE_DOWN, resolveMouseDown);
addEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
for (attribute in m_attributeToPropertyMap) {
(m_attributeToPropertyMap[attribute] as TextField).addEventListener(Event.CHANGE, resolveTextChange);
};
for (attribute in m_tagNameToTypeAndPropertyMap) {
(m_tagNameToTypeAndPropertyMap[attribute].property as DisplayObject).addEventListener(MouseEvent.MOUSE_DOWN, resolveToolbarObjectMouseDown);
};
m_canvasView.objectPane.paneBG.addEventListener(MouseEvent.MOUSE_DOWN, resolveObjectPaneMouseDown);
m_levelTransform = m_levelCanvas.transform.matrix.clone();
setEditorPane();
}
private function resolveToolbarObjectMouseUp(a_event:MouseEvent):void{
var attribute:String;
var xml:XML;
var obj:DisplayObject;
for (attribute in m_tagNameToTypeAndPropertyMap) {
obj = (a_event.target as DisplayObject);
if ((obj is Anchor)){
if ((((obj.parent is MovingAnchor)) || ((obj.parent is TimedAnchor)))){
obj = obj.parent;
};
};
if ((((obj is m_tagNameToTypeAndPropertyMap[attribute].type)) || ((((attribute == "ufo")) && ((obj is UFORepresentation)))))){
break;
};
};
xml = <temp/>
;
xml.setName(attribute);
xml.@["x"] = getTransformedX(Number(a_event.stageX.toFixed(0)));
xml.@["y"] = getTransformedY(Number(a_event.stageY.toFixed(0)));
switch (attribute){
case "player":
m_canExportLevel = true;
break;
case "timedanchor":
xml.@["lifespan"] = DEFAULT_LIFE_SPAN;
case "anchor":
xml.@["hitradius"] = DEFAULT_HIT_RADIUS;
m_editObject.describeRadius(HIT_RADIUS_COLOR, HIT_RADIUS_ALPHA, xml.@hitradius);
break;
case "token":
case "bigtoken":
xml.@["value"] = DEFAULT_VALUE;
break;
case "colortoken":
xml.@["color"] = DEFAULT_COLOR;
break;
case "springboard":
xml.@["bonusforce"] = DEFAULT_BONUS_FORCE;
xml.@["rotation"] = DEFAULT_ROTATION;
break;
case "surface":
xml.@["width"] = DEFAULT_WIDTH;
xml.@["height"] = DEFAULT_HEIGHT;
xml.@["rotation"] = DEFAULT_ROTATION;
break;
case "teleportsurface":
xml.@["destinationx"] = DEFAULT_DESTINATION_X;
xml.@["destinationy"] = DEFAULT_DESTINATION_Y;
break;
case "rotatingsurface":
xml.@["width"] = DEFAULT_WIDTH;
xml.@["height"] = DEFAULT_HEIGHT;
xml.@["rotationrate"] = DEFAULT_ROTATION_RATE;
break;
case "ufo":
xml.@["height"] = DEFAULT_UFO_HEIGHT;
xml.@["blinkcycle"] = DEFAULT_BLINK_CYCLE;
break;
case "electrifiedsurface":
xml.@["rotation"] = DEFAULT_ROTATION;
xml.@["blinkcycle"] = DEFAULT_BLINK_CYCLE;
break;
case "movinganchor":
xml.@["speed"] = DEFAULT_SPEED;
xml.@["destinationx"] = DEFAULT_DESTINATION_X;
xml.@["destinationy"] = DEFAULT_DESTINATION_Y;
xml.@["hitradius"] = DEFAULT_HIT_RADIUS;
m_editObject.describeRadius(HIT_RADIUS_COLOR, HIT_RADIUS_ALPHA, xml.@hitradius);
break;
};
m_editObject.xml = xml;
m_editObject.stopDrag();
m_editObject.removeEventListener(MouseEvent.MOUSE_UP, resolveToolbarObjectMouseUp);
m_transformManager.addItem(m_editObject);
setEditorPane();
}
private function getTransformedX(a_fromValue:Number):Number{
return (((a_fromValue - m_levelTransform.tx) / m_levelTransform.a));
}
private function resolveTransformManagerSelectionChange(a_event:TransformEvent):void{
m_editObject = ((a_event.items[0] as TransformItem).targetObject as EditableObject);
var name:String = m_editObject.xml.name().toString();
m_transformManager.lockRotation = ((((!((name == "surface"))) && (!((name == "springboard"))))) && (!((name == "electrifiedsurface"))));
m_transformManager.lockScale = ((((((((((((m_transformManager.lockRotation) && (!((name == "anchor"))))) && (!((name == "movinganchor"))))) && (!((name == "timedanchor"))))) && (!((name == "rotatingsurface"))))) || ((name == "springboard")))) || ((name == "electrifiedsurface")));
m_transformManager.constrainScale = (((((name == "anchor")) || ((name == "timedanchor")))) || ((name == "movinganchor")));
m_transformManager.scaleFromCenter = m_transformManager.constrainScale;
setEditorPane();
}
private function resolveMouseDown(a_event:MouseEvent):void{
if (a_event.target == m_levelCanvas){
m_levelCanvas.startDrag();
stage.addEventListener(MouseEvent.MOUSE_UP, resolveMouseUp);
};
}
private function resolveViewXMLClick(a_event:MouseEvent):void{
createXML();
m_xmlViewCanvas = new XMLView();
m_xmlViewCanvas.xml.text = m_levelXML.toXMLString();
addChild(m_xmlViewCanvas);
m_backButton = new StandardButtonControl(new StandardButtonView(m_xmlViewCanvas.backButton));
m_backButton.addEventListener(MouseEvent.CLICK, resolveBackClick);
}
private function createXML():void{
m_levelXML = <levels>
<level id="-1">
</level>
</levels>
;
m_levelXML.level.@["lives"] = m_canvasView.objectPane.lifeCount.text.charAt();
m_levelXML.level.@["bgx"] = m_canvasView.objectPane.bgx.text;
m_levelXML.level.@["bgy"] = m_canvasView.objectPane.bgy.text;
var i:Number = 0;
while (i < m_levelCanvas.numChildren) {
m_levelXML.level.appendChild((m_levelCanvas.getChildAt(i) as EditableObject).xml);
i++;
};
}
private function resolveObjectPaneMouseUp(a_event:MouseEvent):void{
m_canvasView.objectPane.removeEventListener(MouseEvent.MOUSE_UP, resolveObjectPaneMouseUp);
m_canvasView.objectPane.stopDrag();
}
private function resolveTextChange(a_event:Event):void{
var regExToUse:RegExp;
var matches:Array;
var targetXML:*;
var xmlAttribute:String;
if ((a_event.target as TextField).text == ""){
return;
};
switch (a_event.target){
case m_canvasView.objectPane.lifeCount:
regExToUse = LIFE_REG_EX;
break;
case m_canvasView.editColor:
regExToUse = COLOR_REG_EX;
break;
case m_canvasView.editRotation:
case m_canvasView.editRotationRate:
regExToUse = ROTATION_REG_EX;
break;
case m_canvasView.editHitRadius:
regExToUse = RADIUS_REG_EX;
break;
default:
regExToUse = NUMBER_REG_EX;
break;
};
switch (a_event.target){
case m_canvasView.objectPane.lifeCount:
case m_canvasView.objectPane.bgx:
case m_canvasView.objectPane.bgy:
targetXML = m_levelXML.level;
break;
default:
targetXML = m_editObject.xml;
break;
};
for (xmlAttribute in m_attributeToPropertyMap) {
if (m_attributeToPropertyMap[xmlAttribute] == a_event.target){
break;
};
};
matches = (a_event.target as TextField).text.match(regExToUse);
if (((matches) && ((matches.length > 0)))){
targetXML.@[xmlAttribute] = matches[0];
switch (a_event.target){
case m_canvasView.editX:
m_editObject.x = Number(Number(matches[0]).toFixed(0));
break;
case m_canvasView.editY:
m_editObject.y = Number(Number(matches[0]).toFixed(0));
break;
case m_canvasView.editWidth:
m_editObject.width = Number(Number(matches[0]).toFixed(0));
break;
case m_canvasView.editHeight:
if (m_editObject.xml.name().toString() == "ufo"){
(m_editObject.sprite as UFO).beam.height = Number(Number(matches[0]).toFixed(0));
} else {
m_editObject.height = Number(Number(matches[0]).toFixed(0));
};
break;
case m_canvasView.editRotation:
m_editObject.rotation = Number(((matches[0] * 180) / Math.PI).toFixed(2));
break;
case m_canvasView.editHitRadius:
m_editObject.describeRadius(HIT_RADIUS_COLOR, HIT_RADIUS_ALPHA, Number(Number(matches[0]).toFixed(2)));
break;
};
} else {
(a_event.target as TextField).text = targetXML.@[xmlAttribute];
};
}
private function resolveTestClick(a_event:MouseEvent):void{
if (m_canExportLevel){
createXML();
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_PLAY, false, false, -1));
};
}
private function resolveBackClick(a_event:MouseEvent):void{
m_backButton.removeEventListener(MouseEvent.CLICK, resolveBackClick);
m_transformManager.removeAllItems();
m_canExportLevel = false;
var i:Number = (m_levelCanvas.numChildren - 1);
while (i >= 0) {
m_levelCanvas.removeChildAt(i);
i--;
};
m_levelXML = XML(m_xmlViewCanvas.xml.text);
createObjectsFromXML();
removeChild(m_xmlViewCanvas);
}
private function resolveObjectPaneMouseDown(a_event:MouseEvent):void{
m_canvasView.objectPane.addEventListener(MouseEvent.MOUSE_UP, resolveObjectPaneMouseUp);
m_canvasView.objectPane.startDrag(false, new Rectangle(0, 0, 0, ((m_canvasView.objectPane.height - stage.height) / 2)));
}
private function resolveKeyDown(a_event:KeyboardEvent):void{
m_levelTransform = m_levelCanvas.transform.matrix.clone();
if (a_event.keyCode == Keyboard.DOWN){
m_levelTransform.scale(SCALE_DOWN, SCALE_DOWN);
} else {
if (a_event.keyCode == Keyboard.UP){
m_levelTransform.scale(SCALE_UP, SCALE_UP);
};
};
m_levelCanvas.transform.matrix = m_levelTransform;
}
private function resolveTransformManagerScale(a_event:TransformEvent):void{
var scale:Number;
var name:String = m_editObject.xml.name().toString();
if ((((((((((name == "surface")) || ((name == "springboard")))) || ((name == "rotatingsurface")))) || ((name == "teleportsurface")))) || ((name == "electrifiedsurface")))){
m_editObject.xml.@width = m_editObject.width;
m_editObject.xml.@height = m_editObject.height;
} else {
scale = (a_event.items[0] as TransformItem).scaleX;
(a_event.items[0] as TransformItem).scaleX = 1;
(a_event.items[0] as TransformItem).scaleY = 1;
m_editObject.radius = (m_editObject.radius * scale);
m_editObject.describeRadius(HIT_RADIUS_COLOR, HIT_RADIUS_ALPHA);
m_editObject.xml.@hitradius = Number(m_editObject.radius.toFixed(2));
};
setEditorPane();
}
private function resolveMouseUp(a_event:MouseEvent):void{
m_levelCanvas.stopDrag();
m_levelTransform = m_levelCanvas.transform.matrix.clone();
stage.removeEventListener(MouseEvent.MOUSE_UP, resolveMouseUp);
}
private function resolveTransformManagerMove(a_event:TransformEvent):void{
m_editObject.xml.@x = Number(m_editObject.x.toFixed(0));
m_editObject.xml.@y = Number(m_editObject.y.toFixed(0));
setEditorPane();
}
public function destroy():void{
var attribute:String;
m_testButton.removeEventListener(MouseEvent.CLICK, resolveTestClick);
m_viewXMLButton.removeEventListener(MouseEvent.CLICK, resolveViewXMLClick);
m_transformManager.removeEventListener(TransformEvent.SELECTION_CHANGE, resolveTransformManagerSelectionChange);
m_transformManager.removeEventListener(TransformEvent.MOVE, resolveTransformManagerMove);
m_transformManager.removeEventListener(TransformEvent.SCALE, resolveTransformManagerScale);
m_transformManager.removeEventListener(TransformEvent.ROTATE, resolveTransformManagerRotate);
m_transformManager.removeEventListener(TransformEvent.DELETE, resolveTransformManagerDelete);
removeEventListener(MouseEvent.MOUSE_DOWN, resolveMouseDown);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, resolveKeyDown);
for (attribute in m_attributeToPropertyMap) {
(m_attributeToPropertyMap[attribute] as TextField).removeEventListener(Event.CHANGE, resolveTextChange);
};
for (attribute in m_tagNameToTypeAndPropertyMap) {
(m_tagNameToTypeAndPropertyMap[attribute].property as DisplayObject).removeEventListener(MouseEvent.MOUSE_DOWN, resolveToolbarObjectMouseDown);
};
m_canvasView.objectPane.removeEventListener(MouseEvent.MOUSE_DOWN, resolveObjectPaneMouseDown);
}
private function resolveTransformManagerRotate(a_event:TransformEvent):void{
m_editObject.xml.@rotation = Number(((m_editObject.rotation * Math.PI) / 180).toFixed(2));
setEditorPane();
}
private function createObjectsFromXML():void{
var node:XML;
var objectClass:Class;
var object:EditableObject;
for each (node in m_levelXML.level.(@id == -1).children()) {
if (node.name().toString() == "player"){
m_canExportLevel = true;
};
objectClass = m_tagNameToTypeAndPropertyMap[node.name().toString()].type;
object = new EditableObject(new (objectClass));
object.x = node.@x;
object.y = node.@y;
if (node.attribute("width").length() > 0){
object.width = node.@width;
};
if (node.attribute("height").length() > 0){
if (node.name().toString() == "ufo"){
(object.sprite as UFO).beam.height = node.@height;
} else {
object.height = node.@height;
};
};
if (node.attribute("rotation").length() > 0){
object.rotation = ((node.@rotation * 180) / Math.PI);
};
if (node.attribute("hitradius").length() > 0){
object.describeRadius(HIT_RADIUS_COLOR, HIT_RADIUS_ALPHA, node.@hitradius);
};
m_levelCanvas.addChild(object);
m_transformManager.addItem(object);
object.xml = node;
};
m_canvasView.objectPane.lifeCount.text = m_levelXML.level.(@id == -1).@lives;
}
private function setEditorPane():void{
var textField:TextField;
var xmlAttribute:String;
for (xmlAttribute in m_attributeToPropertyMap) {
if (((((!((xmlAttribute == "lives"))) && (!((xmlAttribute == "bgx"))))) && (!((xmlAttribute == "bgy"))))){
textField = (m_attributeToPropertyMap[xmlAttribute] as TextField);
textField.selectable = ((m_editObject) && ((m_editObject.xml.attribute(xmlAttribute).length() > 0)));
if (textField.selectable){
textField.text = m_editObject.xml.@[xmlAttribute];
} else {
textField.text = "";
};
};
};
}
private function resolveToolbarObjectMouseDown(a_event:MouseEvent):void{
var attribute:String;
if (m_transformManager.selectedItems.length > 0){
m_transformManager.deselectAll();
};
for (attribute in m_tagNameToTypeAndPropertyMap) {
if ((((a_event.target == m_tagNameToTypeAndPropertyMap[attribute].property)) || ((((attribute == "ufo")) && ((a_event.target is UFORepresentation)))))){
break;
};
};
m_editObject = new EditableObject(new m_tagNameToTypeAndPropertyMap[attribute].type());
m_editObject.x = getTransformedX(a_event.stageX);
m_editObject.y = getTransformedY(a_event.stageY);
m_levelCanvas.addChild(m_editObject);
m_editObject.startDrag();
m_editObject.addEventListener(MouseEvent.MOUSE_UP, resolveToolbarObjectMouseUp);
}
private function getTransformedY(a_fromValue:Number):Number{
return (((a_fromValue - m_levelTransform.ty) / m_levelTransform.d));
}
private function resolveAddedToStage(a_event:Event):void{
stage.addEventListener(KeyboardEvent.KEY_DOWN, resolveKeyDown);
removeEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
private function resolveTransformManagerDelete(a_event:TransformEvent):void{
if (m_editObject.xml.name().toString() == "player"){
m_canExportLevel = false;
};
m_editObject = null;
setEditorPane();
}
public static function get levelXML():XML{
return (m_levelXML);
}
}
}//package ui.canvas
Section 403
//LevelFailCanvas (ui.canvas.LevelFailCanvas)
package ui.canvas {
import flash.events.*;
import flash.display.*;
import ui.component.control.*;
import core.component.base.iface.*;
import core.component.custom.*;
import ui.canvas.model.*;
import fla.ui.canvas.*;
import com.soapcreative.net.tracking.*;
public class LevelFailCanvas extends Sprite implements IDestroyable {
private var m_levelSelectButton:StandardButtonControl;
private var m_outOfTime:Boolean;
private var m_retryButton:StandardButtonControl;
private var m_canvasView:LevelFail;
private var m_submitScoreButton:StandardButtonControl;
public function LevelFailCanvas(){
super();
m_canvasView = new LevelFail();
addChild(m_canvasView);
m_canvasView.restartButton.gotoAndStop("out");
m_canvasView.quitButton.gotoAndStop("out");
m_canvasView.quitButton.addEventListener(MouseEvent.CLICK, resolveQuitClick);
m_canvasView.quitButton.addEventListener(MouseEvent.MOUSE_OVER, resolveQuitOver);
m_canvasView.quitButton.addEventListener(MouseEvent.MOUSE_OUT, resolveQuitOut);
m_canvasView.restartButton.addEventListener(MouseEvent.CLICK, resolveRestartClick);
m_canvasView.restartButton.addEventListener(MouseEvent.MOUSE_OVER, resolveRestartOver);
m_canvasView.restartButton.addEventListener(MouseEvent.MOUSE_OUT, resolveRestartOut);
addEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
public function destroy():void{
m_canvasView.quitButton.removeEventListener(MouseEvent.CLICK, resolveQuitClick);
m_canvasView.quitButton.removeEventListener(MouseEvent.MOUSE_OVER, resolveQuitOver);
m_canvasView.quitButton.removeEventListener(MouseEvent.MOUSE_OUT, resolveQuitOut);
m_canvasView.restartButton.removeEventListener(MouseEvent.CLICK, resolveRestartClick);
m_canvasView.restartButton.removeEventListener(MouseEvent.MOUSE_OVER, resolveRestartOver);
m_canvasView.restartButton.removeEventListener(MouseEvent.MOUSE_OUT, resolveRestartOut);
GameCanvasModel.instance.setLevelTime(0);
}
public function set outOfTime(a_value:Boolean):void{
m_outOfTime = a_value;
}
private function resolveRestartClick(a_event:MouseEvent):void{
if (GameCanvasModel.currentLevel >= 0){
GameTracking.startLevel(GameCanvasModel.currentLevel, true);
};
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_PLAY, false, false, GameCanvasModel.currentLevel));
}
private function resolveRestartOut(a_event:MouseEvent):void{
m_canvasView.restartButton.gotoAndStop("out");
}
private function resolveQuitClick(a_event:MouseEvent):void{
if (GameCanvasModel.currentLevel >= 0){
GameTracking.levelQuit();
};
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_LEVEL_SELECT));
}
private function resolveQuitOver(a_event:MouseEvent):void{
m_canvasView.quitButton.gotoAndStop("over");
}
private function resolveQuitOut(a_event:MouseEvent):void{
m_canvasView.quitButton.gotoAndStop("out");
}
private function resolveAddedToStage(a_event:Event):void{
if (GameCanvasModel.currentLevel >= 0){
GameTracking.levelFail();
};
JuicyFruitFlavorFling.instance.sfxManager.playSound("fail");
m_canvasView.gotoAndStop((m_outOfTime) ? "outoftime" : "failed");
removeEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
private function resolveRestartOver(a_event:MouseEvent):void{
m_canvasView.restartButton.gotoAndStop("over");
}
}
}//package ui.canvas
Section 404
//LevelSelectCanvas (ui.canvas.LevelSelectCanvas)
package ui.canvas {
import flash.events.*;
import flash.display.*;
import ui.component.control.*;
import core.component.base.iface.*;
import fla.ui.canvas.*;
import ui.component.view.*;
public class LevelSelectCanvas extends Sprite implements IDestroyable {
private var m_level20Button:LevelSelectButtonControl;
private var m_level1Button:LevelSelectButtonControl;
private var m_level2Button:LevelSelectButtonControl;
private var m_level3Button:LevelSelectButtonControl;
private var m_level4Button:LevelSelectButtonControl;
private var m_level5Button:LevelSelectButtonControl;
private var m_level6Button:LevelSelectButtonControl;
private var m_level7Button:LevelSelectButtonControl;
private var m_level8Button:LevelSelectButtonControl;
private var m_level9Button:LevelSelectButtonControl;
private var m_level10Button:LevelSelectButtonControl;
private var m_level12Button:LevelSelectButtonControl;
private var m_level14Button:LevelSelectButtonControl;
private var m_level16Button:LevelSelectButtonControl;
private var m_level11Button:LevelSelectButtonControl;
private var m_level13Button:LevelSelectButtonControl;
private var m_canvasView:LevelSelect;
private var m_level17Button:LevelSelectButtonControl;
private var m_level19Button:LevelSelectButtonControl;
private var m_level15Button:LevelSelectButtonControl;
private var m_level18Button:LevelSelectButtonControl;
public function LevelSelectCanvas(){
super();
m_canvasView = new LevelSelect();
addChild(m_canvasView);
m_canvasView.prevButton.gotoAndStop("out");
m_canvasView.nextButton.gotoAndStop("out");
m_canvasView.nextButton.addEventListener(MouseEvent.CLICK, resolveNextClick);
m_canvasView.nextButton.addEventListener(MouseEvent.MOUSE_OVER, resolveNextOver);
m_canvasView.nextButton.addEventListener(MouseEvent.MOUSE_OUT, resolveNextOut);
m_canvasView.prevButton.addEventListener(MouseEvent.CLICK, resolvePrevClick);
m_canvasView.prevButton.addEventListener(MouseEvent.MOUSE_OVER, resolvePrevOver);
m_canvasView.prevButton.addEventListener(MouseEvent.MOUSE_OUT, resolvePrevOut);
m_canvasView.prevButton.visible = false;
var i:Number = 1;
while (i <= 20) {
this[(("m_level" + i.toString()) + "Button")] = new LevelSelectButtonControl(new LevelSelectButtonView(m_canvasView[(("level" + i.toString()) + "Button")]), i);
if (i > 10){
(m_canvasView[(("level" + i.toString()) + "Button")] as MovieClip).visible = false;
};
i++;
};
var k:Number = 1;
while (k <= 20) {
if (k > JuicyFruitFlavorFling.instance.levelAchieved){
this[(("m_level" + k.toString()) + "Button")].active = false;
(m_canvasView[(("level" + k.toString()) + "Button")] as MovieClip).gotoAndStop("locked");
} else {
this[(("m_level" + k.toString()) + "Button")].active = true;
};
k++;
};
}
public function destroy():void{
var i:Number = 1;
while (i <= 20) {
(this[(("m_level" + i.toString()) + "Button")] as LevelSelectButtonControl).destroy();
i++;
};
m_canvasView.nextButton.removeEventListener(MouseEvent.CLICK, resolveNextClick);
m_canvasView.nextButton.removeEventListener(MouseEvent.MOUSE_OVER, resolveNextOver);
m_canvasView.nextButton.removeEventListener(MouseEvent.MOUSE_OUT, resolveNextOut);
m_canvasView.prevButton.removeEventListener(MouseEvent.CLICK, resolvePrevClick);
m_canvasView.prevButton.removeEventListener(MouseEvent.MOUSE_OVER, resolvePrevOver);
m_canvasView.prevButton.removeEventListener(MouseEvent.MOUSE_OUT, resolvePrevOut);
}
private function resolveNextClick(a_event:MouseEvent):void{
var i:Number = 1;
while (i <= 20) {
m_canvasView[(("level" + i.toString()) + "Button")].visible = (i > 10);
i++;
};
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
m_canvasView.nextButton.visible = !((m_canvasView.prevButton.visible = true));
}
private function resolveNextOut(a_event:MouseEvent):void{
m_canvasView.nextButton.gotoAndStop("out");
}
private function resolveNextOver(a_event:MouseEvent):void{
m_canvasView.nextButton.gotoAndStop("over");
}
private function resolvePrevClick(a_event:MouseEvent):void{
var i:Number = 1;
while (i <= 20) {
m_canvasView[(("level" + i.toString()) + "Button")].visible = (i < 11);
i++;
};
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
m_canvasView.prevButton.visible = !((m_canvasView.nextButton.visible = true));
}
private function resolvePrevOver(a_event:MouseEvent):void{
m_canvasView.prevButton.gotoAndStop("over");
}
private function resolvePrevOut(a_event:MouseEvent):void{
m_canvasView.prevButton.gotoAndStop("out");
}
}
}//package ui.canvas
Section 405
//PauseCanvas (ui.canvas.PauseCanvas)
package ui.canvas {
import core.component.base.*;
import flash.events.*;
import flash.display.*;
import core.component.base.iface.*;
import ui.canvas.model.*;
import fla.ui.canvas.*;
import com.soapcreative.net.tracking.*;
public class PauseCanvas extends Sprite implements IDestroyable {
private var m_canvasView:Pause;
private var m_wasSoundOn:Boolean;
public function PauseCanvas(){
super();
m_canvasView = new Pause();
addChild(m_canvasView);
m_canvasView.resumeButton.gotoAndStop("out");
m_canvasView.retryButton.gotoAndStop("out");
m_canvasView.resumeButton.addEventListener(MouseEvent.CLICK, resolveResumeClick);
m_canvasView.resumeButton.addEventListener(MouseEvent.MOUSE_OVER, resolveResumeOver);
m_canvasView.resumeButton.addEventListener(MouseEvent.MOUSE_OUT, resolveResumeOut);
m_canvasView.retryButton.addEventListener(MouseEvent.CLICK, resolveRestartClick);
m_canvasView.retryButton.addEventListener(MouseEvent.MOUSE_OVER, resolveRetryOver);
m_canvasView.retryButton.addEventListener(MouseEvent.MOUSE_OUT, resolveRetryOut);
if ((m_wasSoundOn = JuicyFruitFlavorFling.instance.appHUD.soundButtonControl.isSoundOn)){
JuicyFruitFlavorFling.instance.musicManager.pauseAudio();
};
}
private function resolveRestartClick(a_event:MouseEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
(GameCanvasModel.instance as GameCanvas).loadLevel();
if (GameCanvasModel.currentLevel >= 0){
GameTracking.startLevel(GameCanvasModel.currentLevel, true);
};
JuicyFruitFlavorFling.instance.dispatchEvent(new StateEvent(StateEvent.STATE_EVENT_CHANGE));
}
private function resolveResumeOver(a_event:MouseEvent):void{
m_canvasView.resumeButton.gotoAndStop("over");
}
private function resolveRetryOver(a_event:MouseEvent):void{
m_canvasView.retryButton.gotoAndStop("over");
}
private function resolveRetryOut(a_event:MouseEvent):void{
m_canvasView.retryButton.gotoAndStop("out");
}
private function resolveResumeOut(a_event:MouseEvent):void{
m_canvasView.resumeButton.gotoAndStop("out");
}
private function resolveResumeClick(a_event:MouseEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
JuicyFruitFlavorFling.instance.dispatchEvent(new StateEvent(StateEvent.STATE_EVENT_CHANGE));
}
public function destroy():void{
if (m_wasSoundOn){
JuicyFruitFlavorFling.instance.musicManager.resumeAudio();
};
m_canvasView.resumeButton.removeEventListener(MouseEvent.CLICK, resolveResumeClick);
m_canvasView.retryButton.removeEventListener(MouseEvent.CLICK, resolveRestartClick);
}
}
}//package ui.canvas
Section 406
//QuitConfirmationCanvas (ui.canvas.QuitConfirmationCanvas)
package ui.canvas {
import core.component.base.*;
import flash.events.*;
import flash.display.*;
import core.component.base.iface.*;
import core.component.custom.*;
import ui.canvas.model.*;
import fla.ui.canvas.*;
import com.soapcreative.net.tracking.*;
public class QuitConfirmationCanvas extends Sprite implements IDestroyable {
private var m_canvasView:QuitConfirmation;
public function QuitConfirmationCanvas(){
super();
m_canvasView = new QuitConfirmation();
addChild(m_canvasView);
m_canvasView.yesButton.gotoAndStop("out");
m_canvasView.noButton.gotoAndStop("out");
m_canvasView.yesButton.addEventListener(MouseEvent.CLICK, resolveYesClick);
m_canvasView.yesButton.addEventListener(MouseEvent.MOUSE_OUT, resolveYesOut);
m_canvasView.yesButton.addEventListener(MouseEvent.MOUSE_OVER, resolveYesOver);
m_canvasView.noButton.addEventListener(MouseEvent.CLICK, resolveNoClick);
m_canvasView.noButton.addEventListener(MouseEvent.MOUSE_OVER, resolveNoOver);
m_canvasView.noButton.addEventListener(MouseEvent.MOUSE_OUT, resolveNoOut);
}
private function resolveNoOver(a_event:MouseEvent):void{
m_canvasView.noButton.gotoAndStop("over");
}
private function resolveYesOut(a_event:MouseEvent):void{
m_canvasView.yesButton.gotoAndStop("out");
}
private function resolveNoOut(a_event:MouseEvent):void{
m_canvasView.noButton.gotoAndStop("out");
}
public function destroy():void{
m_canvasView.yesButton.removeEventListener(MouseEvent.CLICK, resolveYesClick);
m_canvasView.yesButton.removeEventListener(MouseEvent.MOUSE_OUT, resolveYesOut);
m_canvasView.yesButton.removeEventListener(MouseEvent.MOUSE_OVER, resolveYesOver);
m_canvasView.noButton.removeEventListener(MouseEvent.CLICK, resolveNoClick);
m_canvasView.noButton.removeEventListener(MouseEvent.MOUSE_OVER, resolveNoOver);
m_canvasView.noButton.removeEventListener(MouseEvent.MOUSE_OUT, resolveNoOut);
}
private function resolveNoClick(a_event:MouseEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
JuicyFruitFlavorFling.instance.dispatchEvent(new StateEvent(StateEvent.STATE_EVENT_CHANGE));
}
private function resolveYesClick(a_event:MouseEvent):void{
if (GameCanvasModel.currentLevel >= 0){
GameTracking.levelQuit();
};
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_HOME));
}
private function resolveYesOver(a_event:MouseEvent):void{
m_canvasView.yesButton.gotoAndStop("over");
}
}
}//package ui.canvas
Section 407
//TitleScreenCanvas (ui.canvas.TitleScreenCanvas)
package ui.canvas {
import flash.events.*;
import flash.display.*;
import ui.component.control.*;
import core.component.base.iface.*;
import core.component.custom.*;
import ui.canvas.model.*;
import fla.ui.canvas.*;
import ui.component.view.*;
import ui.*;
import com.soapcreative.net.tracking.*;
public class TitleScreenCanvas extends Sprite implements IDestroyable {
private var m_editButton:StandardButtonControl;
private var m_canvasView:TitleScreen;
private static const ANALYTICS_TRACKING_NAME:String = "TitleScreenCanvas";
public function TitleScreenCanvas(){
super();
m_canvasView = new TitleScreen();
addChild(m_canvasView);
m_editButton = new StandardButtonControl(new StandardButtonView(m_canvasView.editButton));
m_canvasView.editButton.visible = false;
m_canvasView.playButton.gotoAndPlay("out");
m_canvasView.howToPlayButton.gotoAndStop("out");
m_canvasView.playButton.addEventListener(MouseEvent.MOUSE_OVER, resolvePlayOver);
m_canvasView.playButton.addEventListener(MouseEvent.MOUSE_OUT, resolvePlayOut);
m_canvasView.playButton.addEventListener(MouseEvent.CLICK, resolvePlayClick);
m_canvasView.howToPlayButton.addEventListener(MouseEvent.MOUSE_OUT, resolveHowToOut);
m_canvasView.howToPlayButton.addEventListener(MouseEvent.MOUSE_OVER, resolveHowToOver);
m_canvasView.howToPlayButton.addEventListener(MouseEvent.CLICK, resolveHowToClick);
m_editButton.addEventListener(MouseEvent.CLICK, resolveEditClick);
var rain:FruitRain = new FruitRain();
rain.addObstacle(m_canvasView.playButton);
rain.start();
addChild(rain);
}
public function destroy():void{
m_canvasView.playButton.removeEventListener(MouseEvent.MOUSE_OVER, resolvePlayOver);
m_canvasView.playButton.removeEventListener(MouseEvent.MOUSE_OUT, resolvePlayOut);
m_canvasView.playButton.removeEventListener(MouseEvent.CLICK, resolvePlayClick);
m_canvasView.howToPlayButton.removeEventListener(MouseEvent.MOUSE_OUT, resolveHowToOut);
m_canvasView.howToPlayButton.removeEventListener(MouseEvent.MOUSE_OVER, resolveHowToOver);
m_canvasView.howToPlayButton.removeEventListener(MouseEvent.CLICK, resolveHowToClick);
m_editButton.removeEventListener(MouseEvent.CLICK, resolveEditClick);
}
private function resolvePlayClick(a_event:MouseEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
if (JuicyFruitFlavorFling.instance.levelAchieved == 1){
GameTracking.startGame();
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_PLAY, false, false, 1));
GameTracking.startLevel(GameCanvasModel.currentLevel);
} else {
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_LEVEL_SELECT));
};
m_canvasView.playButton.gotoAndPlay("out");
}
private function resolveHowToClick(a_event:MouseEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_HOW_TO));
m_canvasView.howToPlayButton.gotoAndStop("out");
}
private function resolvePlayOut(a_event:MouseEvent):void{
m_canvasView.playButton.gotoAndPlay("out");
}
private function resolveHowToOut(a_event:MouseEvent):void{
m_canvasView.howToPlayButton.gotoAndStop("out");
}
private function resolveEditClick(a_event:MouseEvent):void{
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_EDIT));
}
private function resolvePlayOver(a_event:MouseEvent):void{
m_canvasView.playButton.gotoAndPlay("over");
}
private function resolveHowToOver(a_event:MouseEvent):void{
m_canvasView.howToPlayButton.gotoAndStop("over");
}
}
}//package ui.canvas
Section 408
//IHomeButton (ui.component.control.iface.IHomeButton)
package ui.component.control.iface {
public interface IHomeButton extends IStandardButton {
function hide():void;
function show():void;
}
}//package ui.component.control.iface
Section 409
//ILifeBar (ui.component.control.iface.ILifeBar)
package ui.component.control.iface {
public interface ILifeBar {
function setLives(:Number):void;
}
}//package ui.component.control.iface
Section 410
//IScoreBar (ui.component.control.iface.IScoreBar)
package ui.component.control.iface {
public interface IScoreBar {
function updateScore(:Number):void;
}
}//package ui.component.control.iface
Section 411
//ISoundButton (ui.component.control.iface.ISoundButton)
package ui.component.control.iface {
public interface ISoundButton extends IStandardButton {
function toggleSoundOn():void;
function toggleSoundOff():void;
}
}//package ui.component.control.iface
Section 412
//IStandardButton (ui.component.control.iface.IStandardButton)
package ui.component.control.iface {
import flash.events.*;
public interface IStandardButton extends IEventDispatcher {
function playOver():void;
function playOut():void;
}
}//package ui.component.control.iface
Section 413
//HomeButtonControl (ui.component.control.HomeButtonControl)
package ui.component.control {
import flash.events.*;
import core.component.base.iface.*;
import ui.component.control.iface.*;
import core.component.custom.*;
public class HomeButtonControl extends StandardButtonControl implements IDestroyable {
public function HomeButtonControl(a_view:IHomeButton){
super(a_view);
}
override public function destroy():void{
super.destroy();
}
public function hide():void{
(m_view as IHomeButton).hide();
}
public function show():void{
(m_view as IHomeButton).show();
}
override protected function resolveMouseClick(a_event:MouseEvent):void{
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(JFFFStateEvent.STATE_EVENT_HOME));
}
}
}//package ui.component.control
Section 414
//LevelSelectButtonControl (ui.component.control.LevelSelectButtonControl)
package ui.component.control {
import core.component.base.*;
import flash.events.*;
import ui.component.control.iface.*;
import core.component.custom.*;
import ui.canvas.model.*;
import com.soapcreative.net.tracking.*;
public class LevelSelectButtonControl extends StandardButtonControl {
private var m_level:Number;
private var m_active:Boolean;
public function LevelSelectButtonControl(a_view:IStandardButton, a_level:Number){
super(a_view);
m_level = a_level;
}
override protected function resolveMouseOut(a_event:MouseEvent):void{
if (m_active){
m_view.playOut();
};
}
public function set active(a_value:Boolean):void{
m_active = a_value;
}
override protected function resolveMouseOver(a_event:MouseEvent):void{
if (m_active){
m_view.playOver();
};
}
override protected function resolveMouseClick(a_event:MouseEvent):void{
if (m_active){
JuicyFruitFlavorFling.instance.sfxManager.playSound("buttonClick");
GameTracking.startGame();
JuicyFruitFlavorFling.instance.dispatchEvent(new JFFFStateEvent(StateEvent.STATE_EVENT_CHANGE, false, false, m_level));
GameTracking.startLevel(GameCanvasModel.currentLevel);
};
}
}
}//package ui.component.control
Section 415
//LifeBarControl (ui.component.control.LifeBarControl)
package ui.component.control {
import core.component.base.iface.*;
import ui.component.control.iface.*;
public class LifeBarControl implements IDestroyable {
private var m_lives:Number;
private var m_view:ILifeBar;
private var m_maxLives:Number;
private static const ABSOLUTE_MAX_LIVES:Number = 6;
public function LifeBarControl(a_view:ILifeBar, a_maxLives:Number=3){
super();
m_maxLives = a_maxLives;
m_view = a_view;
resetLives();
}
public function set maxLives(a_value:Number):void{
m_maxLives = Math.min(a_value, ABSOLUTE_MAX_LIVES);
}
public function get lives():Number{
return (m_lives);
}
public function set lives(a_value:Number):void{
m_lives = a_value;
m_view.setLives(m_lives);
}
public function subtractLife():void{
m_lives--;
m_view.setLives(m_lives);
}
public function resetLives():void{
m_lives = m_maxLives;
m_view.setLives(m_lives);
}
public function destroy():void{
}
}
}//package ui.component.control
Section 416
//ScoreBarControl (ui.component.control.ScoreBarControl)
package ui.component.control {
import core.component.base.iface.*;
import ui.component.control.iface.*;
public class ScoreBarControl implements IDestroyable {
private var m_score:Number;
private var m_view:IScoreBar;
public function ScoreBarControl(a_view:IScoreBar){
super();
m_view = a_view;
score = 0;
}
public function get score():Number{
return (m_score);
}
public function set score(a_value:Number):void{
m_score = a_value;
m_view.updateScore(m_score);
}
public function destroy():void{
}
}
}//package ui.component.control
Section 417
//SoundButtonControl (ui.component.control.SoundButtonControl)
package ui.component.control {
import flash.events.*;
import core.component.base.iface.*;
import ui.component.control.iface.*;
public class SoundButtonControl extends StandardButtonControl implements IDestroyable, IAudioManagerUI {
private var m_isSoundOn:Boolean;
public function SoundButtonControl(a_view:ISoundButton){
super(a_view);
isSoundOn = true;
}
override public function destroy():void{
super.destroy();
}
public function get isSoundOn():Boolean{
return (m_isSoundOn);
}
override protected function resolveMouseOut(a_event:MouseEvent):void{
m_view.playOut();
}
override protected function resolveMouseClick(a_event:MouseEvent):void{
isSoundOn = !(isSoundOn);
}
public function set isSoundOn(value:Boolean):void{
if ((m_isSoundOn = value)){
(m_view as ISoundButton).toggleSoundOn();
} else {
(m_view as ISoundButton).toggleSoundOff();
};
}
override protected function resolveMouseOver(a_event:MouseEvent):void{
m_view.playOver();
}
}
}//package ui.component.control
Section 418
//StandardButtonControl (ui.component.control.StandardButtonControl)
package ui.component.control {
import flash.events.*;
import core.component.base.iface.*;
import ui.component.control.iface.*;
public class StandardButtonControl implements IDestroyable, IEventDispatcher {
protected var m_view:IStandardButton;
public function StandardButtonControl(a_view:IStandardButton){
super();
m_view = a_view;
addEventListener(MouseEvent.CLICK, resolveMouseClick);
addEventListener(MouseEvent.MOUSE_OVER, resolveMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, resolveMouseOut);
}
public function dispatchEvent(event:Event):Boolean{
return (m_view.dispatchEvent(event));
}
protected function resolveMouseOut(a_event:MouseEvent):void{
m_view.playOut();
}
protected function resolveMouseOver(a_event:MouseEvent):void{
m_view.playOver();
}
public function willTrigger(type:String):Boolean{
return (m_view.willTrigger(type));
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{
m_view.addEventListener(type, listener, useCapture, priority, useWeakReference);
}
protected function resolveMouseClick(a_event:MouseEvent):void{
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void{
m_view.removeEventListener(type, listener, useCapture);
}
public function hasEventListener(type:String):Boolean{
return (m_view.hasEventListener(type));
}
public function destroy():void{
removeEventListener(MouseEvent.CLICK, resolveMouseClick);
removeEventListener(MouseEvent.MOUSE_OVER, resolveMouseOver);
removeEventListener(MouseEvent.MOUSE_OUT, resolveMouseOut);
}
}
}//package ui.component.control
Section 419
//EditableObject (ui.component.misc.EditableObject)
package ui.component.misc {
import flash.display.*;
import fla.game.component.*;
public class EditableObject extends Sprite {
private var m_radius:Number;// = 1
private var m_xml:XML;
private var m_sprite:Sprite;
private static const WORLD_SCALE:Number = 32;
public function EditableObject(a_viewSprite:Sprite){
super();
m_sprite = a_viewSprite;
addChild(m_sprite);
}
public function set radius(a_value:Number):void{
m_radius = a_value;
}
public function get sprite():Sprite{
return (m_sprite);
}
public function set xml(a_value:XML):void{
m_xml = a_value;
}
public function get radius():Number{
return (m_radius);
}
public function get xml():XML{
return (m_xml);
}
public function describeRadius(a_color:uint, a_alpha:Number, a_radius:Number=-1):void{
m_radius = ((a_radius)==-1) ? m_radius : a_radius;
graphics.clear();
graphics.beginFill(a_color, a_alpha);
if (((((xml) && (xml.name()))) && ((xml.name().toString() == "movinganchor")))){
graphics.drawCircle((m_sprite as MovingAnchor).anchor.x, (m_sprite as MovingAnchor).anchor.y, (m_radius * WORLD_SCALE));
} else {
graphics.drawCircle(0, 0, (m_radius * WORLD_SCALE));
};
graphics.endFill();
}
}
}//package ui.component.misc
Section 420
//HomeButtonView (ui.component.view.HomeButtonView)
package ui.component.view {
import flash.display.*;
import ui.component.control.iface.*;
public class HomeButtonView extends StandardButtonView implements IHomeButton {
public function HomeButtonView(a_buttonAsset:MovieClip){
super(a_buttonAsset);
}
public function hide():void{
m_buttonAsset.visible = false;
}
public function show():void{
m_buttonAsset.visible = true;
}
}
}//package ui.component.view
Section 421
//LevelSelectButtonView (ui.component.view.LevelSelectButtonView)
package ui.component.view {
import flash.display.*;
public class LevelSelectButtonView extends StandardButtonView {
public function LevelSelectButtonView(a_buttonAsset:MovieClip){
super(a_buttonAsset);
}
override public function playOver():void{
m_buttonAsset.gotoAndStop("over");
}
override public function playOut():void{
m_buttonAsset.gotoAndStop("out");
}
}
}//package ui.component.view
Section 422
//LifeBarView (ui.component.view.LifeBarView)
package ui.component.view {
import flash.display.*;
import fla.ui.game.*;
import ui.component.control.iface.*;
public class LifeBarView implements ILifeBar {
private var m_lifeAsset:MovieClip;
public function LifeBarView(a_lifeAsset:MovieClip){
super();
m_lifeAsset = a_lifeAsset;
}
public function setLives(a_lives:Number):void{
a_lives = Math.max(1, a_lives);
(m_lifeAsset as LifeBar).count.text = a_lives.toString();
}
}
}//package ui.component.view
Section 423
//ScoreBarView (ui.component.view.ScoreBarView)
package ui.component.view {
import flash.display.*;
import ui.component.control.iface.*;
import fla.ui.custom.*;
public class ScoreBarView implements IScoreBar {
private var m_scoreAsset:MovieClip;
public function ScoreBarView(a_scoreAsset:MovieClip){
super();
m_scoreAsset = a_scoreAsset;
}
public function updateScore(a_value:Number):void{
(m_scoreAsset as Score).scoreText.text = a_value.toString();
}
}
}//package ui.component.view
Section 424
//SoundButtonView (ui.component.view.SoundButtonView)
package ui.component.view {
import flash.display.*;
import ui.component.control.iface.*;
public class SoundButtonView extends StandardButtonView implements ISoundButton {
public function SoundButtonView(a_buttonAsset:MovieClip){
super(a_buttonAsset);
}
public function toggleSoundOn():void{
m_buttonAsset.prevFrame();
}
public function toggleSoundOff():void{
m_buttonAsset.nextFrame();
}
override public function playOver():void{
if ((((m_buttonAsset.currentFrame == 1)) || ((m_buttonAsset.currentFrame == 2)))){
m_buttonAsset.gotoAndStop((m_buttonAsset.currentFrame + 2));
};
}
override public function playOut():void{
if ((((m_buttonAsset.currentFrame == 3)) || ((m_buttonAsset.currentFrame == 4)))){
m_buttonAsset.gotoAndStop((m_buttonAsset.currentFrame - 2));
};
}
}
}//package ui.component.view
Section 425
//StandardButtonView (ui.component.view.StandardButtonView)
package ui.component.view {
import flash.events.*;
import flash.display.*;
import ui.component.control.iface.*;
public class StandardButtonView implements IStandardButton {
protected var m_buttonAsset:MovieClip;
public function StandardButtonView(a_buttonAsset:MovieClip){
super();
m_buttonAsset = a_buttonAsset;
m_buttonAsset.stop();
}
public function dispatchEvent(event:Event):Boolean{
return (m_buttonAsset.dispatchEvent(event));
}
public function playOut():void{
var currentFrame:Number = m_buttonAsset.currentFrame;
m_buttonAsset.gotoAndStop("mouseOut");
var framesPerAnimation:Number = (m_buttonAsset.currentFrame + 1);
var frame:Number = (framesPerAnimation - currentFrame);
frame = (frame + framesPerAnimation);
m_buttonAsset.gotoAndPlay(frame);
}
public function willTrigger(type:String):Boolean{
return (m_buttonAsset.willTrigger(type));
}
public function playOver():void{
var currentFrame:Number = m_buttonAsset.currentFrame;
m_buttonAsset.gotoAndStop("mouseOut");
var framesPerAnimation:Number = ((m_buttonAsset.currentFrame * 2) + 1);
var frame:Number = Math.max(2, (framesPerAnimation - currentFrame));
if (currentFrame == 1){
frame = 2;
};
m_buttonAsset.gotoAndPlay(frame);
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void{
m_buttonAsset.removeEventListener(type, listener, useCapture);
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{
m_buttonAsset.addEventListener(type, listener, useCapture, priority, useWeakReference);
}
public function hasEventListener(type:String):Boolean{
return (m_buttonAsset.hasEventListener(type));
}
}
}//package ui.component.view
Section 426
//FruitRain (ui.FruitRain)
package ui {
import flash.events.*;
import flash.display.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import fla.game.component.*;
import flash.utils.*;
import fla.ui.effect.*;
public class FruitRain extends Sprite {
private var m_world:b2World;
private var m_timer:Timer;
private var m_worldScale:Number;// = 32
public function FruitRain(){
super();
var dDraw:b2DebugDraw = new b2DebugDraw();
dDraw.SetSprite(this);
dDraw.SetDrawScale(m_worldScale);
dDraw.SetFlags(((b2DebugDraw.e_shapeBit | b2DebugDraw.e_controllerBit) | b2DebugDraw.e_centerOfMassBit));
m_world = new b2World(new b2Vec2(0, 9.8), true);
m_world.SetDebugDraw(dDraw);
m_timer = new Timer(int((1000 / 60)));
m_timer.addEventListener(TimerEvent.TIMER, resolveTimer);
}
public function stop():void{
m_timer.stop();
}
private function resolveTimer(event:TimerEvent):void{
var d:b2Body;
if (Math.random() > 0.95){
createDroplet();
};
m_world.Step((1 / 60), 10, 10);
var p:b2Body = m_world.GetBodyList();
while (p != null) {
if (p.GetUserData() != null){
(p.GetUserData() as TokenType).x = (p.GetPosition().x * m_worldScale);
(p.GetUserData() as TokenType).y = (p.GetPosition().y * m_worldScale);
};
if (((((((p.GetPosition().x * m_worldScale) > 700)) || ((p.GetPosition().x < 0)))) || (((p.GetPosition().y * m_worldScale) > 500)))){
d = p;
};
p = p.GetNext();
if (d){
removeChild(d.GetUserData());
d.SetUserData(null);
d.DestroyFixture(d.GetFixtureList());
m_world.DestroyBody(d);
d = null;
};
};
}
public function start():void{
m_timer.start();
}
private function createDroplet():void{
var fruit:TokenType = new TokenType();
fruit.gotoAndStop((int((Math.random() * 8)) + 1));
var body:b2Body = m_world.CreateBody(new b2BodyDef());
var fixture:b2Fixture = body.CreateFixture2(new b2CircleShape(((Math.max(fruit.width, fruit.height) / 2) / m_worldScale)));
fixture.SetRestitution(0.5);
fixture.SetFriction(0);
body.SetPosition(new b2Vec2(((Math.random() * 700) / m_worldScale), 0));
body.SetType(b2Body.b2_dynamicBody);
body.SetUserData(fruit);
addChild(fruit);
}
public function addObstacle(obstacle:DisplayObject):void{
var body:b2Body = m_world.CreateBody(new b2BodyDef());
body.SetType(b2Body.b2_staticBody);
var fixture:b2Fixture = body.CreateFixture2(b2PolygonShape.AsBox(((obstacle.width / 2) / m_worldScale), ((obstacle.height / 2) / m_worldScale)));
fixture.SetRestitution(0.5);
fixture.SetFriction(0.3);
if (!(obstacle is GameCompleteRainSymbol)){
body.SetPosition(new b2Vec2(((obstacle.x + (obstacle.width / 2)) / m_worldScale), ((obstacle.y + (obstacle.height / 2)) / m_worldScale)));
} else {
body.SetPosition(new b2Vec2((obstacle.x / m_worldScale), (obstacle.y / m_worldScale)));
};
}
}
}//package ui
Section 427
//BalloonHack (BalloonHack)
package {
import flash.display.*;
public dynamic class BalloonHack extends MovieClip {
}
}//package
Section 428
//JuicyFruitFlavorFling (JuicyFruitFlavorFling)
package {
import core.component.base.*;
import ui.canvas.*;
import game.manager.*;
import flash.events.*;
import flash.display.*;
import com.greensock.*;
import core.component.custom.*;
import flash.net.*;
import ui.canvas.model.*;
import com.soapcreative.net.tracking.*;
public class JuicyFruitFlavorFling extends JFFFStateManager {
private var m_appHUD:ApplicationHUDCanvas;
private var m_sfxManager:AudioManager;
private var m_levelAchieved:Number;// = 1
protected var m_scoreManager:ScoreManager;
private var m_sharedObject:SharedObject;
private var m_bufferBitmap:Bitmap;
private var m_musicManager:AudioManager;
private static const SHARED_OBJECT_ID:String = "JFFFStoredData";
private static var m_instance:JuicyFruitFlavorFling;
public function JuicyFruitFlavorFling(){
super();
if (m_instance){
throw (new Error("Only one instance allowed for this singleton class!"));
};
m_scoreManager = new ScoreManager();
m_instance = this;
addEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
public function get musicManager():AudioManager{
return (m_musicManager);
}
public function set levelAchieved(a_value:Number):void{
m_levelAchieved = Math.max(m_levelAchieved, a_value);
if (m_sharedObject){
m_sharedObject.data.levelAchieved = m_levelAchieved;
};
}
public function get sfxManager():AudioManager{
return (m_sfxManager);
}
public function get scoreManager():ScoreManager{
m_sharedObject.data.perLevelScores = m_scoreManager.getAll();
return (m_scoreManager);
}
override protected function resolveStateEvent(a_event:StateEvent):void{
var i:Number;
if ((((a_event is JFFFStateEvent)) && (((((a_event as JFFFStateEvent).level > 0)) || (((a_event as JFFFStateEvent).level == -1)))))){
GameCanvasModel.currentLevel = (a_event as JFFFStateEvent).level;
if (currentStateID == "paused"){
i = 0;
while (i < numChildren) {
if ((getChildAt(i) is GameCanvas)){
removeChild(getChildAt(i));
addChild(new GameCanvas());
break;
};
i++;
};
};
};
var buffer:BitmapData = new BitmapData(700, 500, false, 0);
buffer.draw(stage);
super.resolveStateEvent(a_event);
var k:Number = 0;
while (k < numChildren) {
if ((getChildAt(k) is ApplicationHUDCanvas)){
swapChildrenAt(k, (numChildren - 1));
break;
};
k++;
};
m_bufferBitmap = new Bitmap(buffer);
addChild(m_bufferBitmap);
TweenMax.to(m_bufferBitmap, 0.5, {alpha:0});
}
public function get levelAchieved():Number{
return (m_levelAchieved);
}
public function get appHUD():ApplicationHUDCanvas{
return (m_appHUD);
}
private function resolveAddedToStage(a_event:Event):void{
var score:Number;
GameTracking.trackLoaded();
m_musicManager = new AudioManager(new JFFFAudioManagerDataProvider());
m_sfxManager = new AudioManager(new JFFFAudioManagerDataProvider());
dispatchEvent(new StateEvent(StateEvent.STATE_EVENT_CHANGE));
m_musicManager.playSound("music", 0, int.MAX_VALUE);
m_sharedObject = SharedObject.getLocal(SHARED_OBJECT_ID);
if (((m_sharedObject.data.levelAchieved) && (m_sharedObject.data.perLevelScores))){
m_levelAchieved = m_sharedObject.data.levelAchieved;
if (m_appHUD){
for each (score in m_scoreManager.getAll()) {
m_appHUD.scoreBar.score = (m_appHUD.scoreBar.score + score);
};
};
};
removeEventListener(Event.ADDED_TO_STAGE, resolveAddedToStage);
}
override public function addChild(child:DisplayObject):DisplayObject{
var score:Number;
if ((child is ApplicationHUDCanvas)){
m_appHUD = (child as ApplicationHUDCanvas);
for each (score in m_scoreManager.getAll()) {
m_appHUD.scoreBar.score = (m_appHUD.scoreBar.score + score);
};
};
return (super.addChild(child));
}
public static function get instance():JuicyFruitFlavorFling{
if (!m_instance){
m_instance = new (JuicyFruitFlavorFling);
};
return (m_instance);
}
}
}//package