Section 1
//SceneContainer (de.popforge.revive.application.SceneContainer)
package de.popforge.revive.application {
import flash.events.*;
import flash.display.*;
import de.popforge.revive.member.*;
import de.popforge.revive.forces.*;
import de.popforge.revive.display.*;
public class SceneContainer extends Sprite {
protected var mShapeImage:Shape;
protected var mouseSpring:FixedSpring;
protected var mShape:Shape;
public var simulation:Simulation;
protected var iShape:Shape;
public static const WIDTH:uint = 0x0200;
public static const HEIGHT:uint = 0x0200;
public static const COLOR_IMMOVABLE:uint = 0x878787;
public static const COLOR_FORCE:uint = 13395507;
public static const COLOR_MOVABLE:uint = 0xABABAB;
protected static const MOUSE_CATCH_STRENGTH:Number = 0.5;
protected static const MOUSE_CATCH_DISTANCE2:Number = 256;
private static var instance:SceneContainer;
public function SceneContainer(){
instance = this;
iShape = new Shape();
mShape = new Shape();
mShapeImage = new Shape();
addChild(iShape);
addChild(mShape);
addChild(mShapeImage);
simulation = new Simulation();
addEventListener(Event.ADDED, onAdded);
addEventListener(Event.REMOVED, onRemoved);
}
private function onAdded(_arg1:Event):void{
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
}
protected function onMouseUp(_arg1:MouseEvent):void{
if (mouseSpring){
simulation.removeForce(mouseSpring);
mouseSpring = null;
};
}
protected function drawImmovables():void{
var _local1:IDrawAble;
iShape.graphics.lineStyle(0, COLOR_IMMOVABLE);
for each (_local1 in simulation.immovables) {
_local1.draw(iShape.graphics);
};
}
protected function onMouseDown(_arg1:MouseEvent):void{
var _local2:Movable;
var _local3:Number;
var _local4:Number;
for each (_local2 in simulation.movables) {
if ((((_local2 is MovableParticle)) || ((_local2 is MovableCircle)))){
_local3 = (MovableParticle(_local2).x - mouseX);
_local4 = (MovableParticle(_local2).y - mouseY);
if (((_local3 * _local3) + (_local4 * _local4)) < MOUSE_CATCH_DISTANCE2){
mouseSpring = new FixedSpring(mouseX, mouseY, MovableParticle(_local2), MOUSE_CATCH_STRENGTH, 0);
simulation.addForce(mouseSpring);
break;
};
};
};
}
protected function createStageBounds():void{
var _local1:ImmovableGate;
_local1 = new ImmovableGate(WIDTH, 0, 0, 0);
simulation.addImmovable(_local1);
_local1 = new ImmovableGate(0, HEIGHT, WIDTH, HEIGHT);
simulation.addImmovable(_local1);
_local1 = new ImmovableGate(0, 0, 0, HEIGHT);
simulation.addImmovable(_local1);
_local1 = new ImmovableGate(WIDTH, HEIGHT, WIDTH, 0);
simulation.addImmovable(_local1);
}
private function onRemoved(_arg1:Event):void{
stage.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
}
public function onEnterFrame(_arg1:Event):void{
var _local2:IDrawAble;
var _local3:Number;
var _local4:Number;
if (mouseSpring){
_local3 = (mouseSpring.movableParticle.x - mouseX);
_local4 = (mouseSpring.movableParticle.y - mouseY);
if (((_local3 * _local3) + (_local4 * _local4)) < (50 * 50)){
mouseSpring.x = mouseX;
mouseSpring.y = mouseY;
};
};
simulation.nextFrame();
simulation.nextFrame();
mShape.graphics.clear();
mShape.graphics.lineStyle(0, COLOR_MOVABLE);
for each (_local2 in simulation.movables) {
_local2.draw(mShape.graphics);
};
mShape.graphics.lineStyle(0, COLOR_FORCE);
for each (_local2 in simulation.forces) {
_local2.draw(mShape.graphics);
};
}
public static function debugStop():void{
instance.simulation.debugStop();
instance.onRemoved(null);
}
}
}//package de.popforge.revive.application
Section 2
//Simulation (de.popforge.revive.application.Simulation)
package de.popforge.revive.application {
import de.popforge.revive.member.*;
import de.popforge.revive.resolve.*;
import de.popforge.revive.geom.*;
import de.popforge.revive.forces.*;
import flash.utils.*;
public class Simulation {
public var movables:Array;
public var globalForce:Vector;
public var insertMovables:Array;
public var forces:Array;
public var immovables:Array;
private var pause:Boolean;// = false
public var globalDrag:Number;// = 0.0005
public static const MAX_FRAME_TIME:uint = 50;
public function Simulation(){
globalForce = new Vector(0, 0.01);
super();
forces = new Array();
movables = new Array();
insertMovables = new Array();
immovables = new Array();
}
public function nextFrame():void{
applyEnvirons();
resolve();
}
public function removeForce(_arg1:IForce):void{
var _local2:int = forces.length;
while (--_local2 > -1) {
if (forces[_local2] == _arg1){
forces.splice(_local2, 1);
break;
};
};
}
public function addMovable(_arg1:Movable):void{
removeMovable(_arg1);
movables.push(_arg1);
}
public function addForce(_arg1:IForce):void{
removeForce(_arg1);
forces.push(_arg1);
}
public function addInsertMovable(_arg1:Movable):void{
removeInsertMovable(_arg1);
insertMovables.push(_arg1);
}
public function removeInsertMovable(_arg1:Movable):void{
var _local2:int = insertMovables.length;
while (--_local2 > -1) {
if (insertMovables[_local2] == _arg1){
insertMovables.splice(_local2, 1);
break;
};
};
}
public function removeMovable(_arg1:Movable):void{
var _local2:int = movables.length;
while (--_local2 > -1) {
if (movables[_local2] == _arg1){
movables.splice(_local2, 1);
break;
};
};
}
private function getNearestDynamicIntersection(_arg1:Number):DynamicIntersection{
var _local2:Movable;
var _local3:IDynamicIntersectionTestAble;
var _local4:DynamicIntersection;
var _local5:DynamicIntersection;
var _local7:int;
var _local8:uint;
var _local6:int = movables.length;
while (--_local6 > -1) {
_local2 = movables[_local6];
_local8 = _local2.groupMask;
if ((_local2 is MovableCircle)){
_local7 = immovables.length;
while (--_local7 > -1) {
_local3 = immovables[_local7];
if ((_local8 & (_local3 as Immovable).groupMask) != 0){
_local4 = _local3.dIntersectMovableCircle((_local2 as MovableCircle), _arg1);
if (_local4){
if (_local4.dt < _arg1){
_arg1 = _local4.dt;
_local5 = _local4;
};
};
};
};
_local7 = _local6;
while (--_local7 > -1) {
_local3 = movables[_local7];
if ((_local8 & (_local3 as Movable).groupMask) != 0){
_local4 = _local3.dIntersectMovableCircle((_local2 as MovableCircle), _arg1);
if (_local4){
if (_local4.dt < _arg1){
_arg1 = _local4.dt;
_local5 = _local4;
};
};
};
};
} else {
if ((_local2 is MovableParticle)){
_local7 = immovables.length;
while (--_local7 > -1) {
_local3 = immovables[_local7];
if ((_local8 & (_local3 as Immovable).groupMask) != 0){
if ((_local3 is MyGate)){
_local4 = _local3.dIntersectMovableParticle((_local2 as MovableParticle), _arg1);
if (_local4){
if (_local4.dt < _arg1){
_arg1 = _local4.dt;
_local5 = _local4;
};
};
};
};
};
};
};
};
return (_local5);
}
public function removeImmovable(_arg1:Immovable):void{
var _local2:int = immovables.length;
while (--_local2 > -1) {
if (immovables[_local2] == _arg1){
immovables.splice(_local2, 1);
break;
};
};
}
private function resolve():void{
var _local1:Number;
var _local3:Movable;
var _local4:DynamicIntersection;
if (pause){
return;
};
var _local2:Number = 1;
var _local5:uint = getTimer();
while ((_local4 = getNearestDynamicIntersection(_local2))) {
if ((getTimer() - _local5) > MAX_FRAME_TIME){
return;
};
_local1 = _local4.dt;
_local2 = (_local2 - _local1);
for each (_local3 in movables) {
_local3.integrate(_local1);
};
for each (_local3 in insertMovables) {
_local3.integrate(_local1);
};
if (pause){
_local4.resolvable.resolveMovableParticle(MovableParticle(_local3));
return;
};
_local3 = _local4.movable;
if ((_local3 is MovableCircle)){
_local4.resolvable.resolveMovableCircle((_local3 as MovableCircle));
} else {
if ((_local3 is MovableParticle)){
_local4.resolvable.resolveMovableParticle((_local3 as MovableParticle));
} else {
if ((_local3 is MovableSegment)){
_local4.resolvable.resolveMovableSegment((_local3 as MovableSegment));
continue;
};
};
};
};
for each (_local3 in movables) {
_local3.integrate(_local2);
};
for each (_local3 in insertMovables) {
_local3.integrate(_local2);
};
}
public function addImmovable(_arg1:Immovable):void{
removeImmovable(_arg1);
immovables.push(_arg1);
}
public function debugStop():void{
pause = true;
}
private function applyEnvirons():void{
var _local1:Movable;
var _local2:IForce;
for each (_local1 in movables) {
_local1.applyGlobalEnvirons(globalForce, globalDrag);
};
for each (_local1 in insertMovables) {
_local1.applyGlobalEnvirons(globalForce, globalDrag);
};
for each (_local2 in forces) {
_local2.solve();
};
}
}
}//package de.popforge.revive.application
Section 3
//IDrawAble (de.popforge.revive.display.IDrawAble)
package de.popforge.revive.display {
import flash.display.*;
public interface IDrawAble {
function draw(_arg1:Graphics):void;
}
}//package de.popforge.revive.display
Section 4
//FixedSpring (de.popforge.revive.forces.FixedSpring)
package de.popforge.revive.forces {
import flash.display.*;
import de.popforge.revive.member.*;
import de.popforge.revive.display.*;
public class FixedSpring implements IForce, IDrawAble {
public var y:Number;
public var tension:Number;
public var x:Number;
public var restLength:Number;
public var movableParticle:MovableParticle;
public function FixedSpring(_arg1:Number, _arg2:Number, _arg3:MovableParticle, _arg4:Number=0.5, _arg5:Number=-1){
var _local6:Number;
var _local7:Number;
super();
this.x = _arg1;
this.y = _arg2;
this.movableParticle = _arg3;
this.tension = _arg4;
if (_arg5 == -1){
_local6 = (_arg3.x - _arg1);
_local7 = (_arg3.y - _arg2);
_arg5 = Math.sqrt(((_local6 * _local6) + (_local7 * _local7)));
};
this.restLength = _arg5;
}
public function draw(_arg1:Graphics):void{
_arg1.moveTo(x, y);
_arg1.lineTo(movableParticle.x, movableParticle.y);
_arg1.drawCircle(x, y, 4);
}
public function solve():void{
var _local1:Number = ((movableParticle.x + movableParticle.velocity.x) - x);
var _local2:Number = ((movableParticle.y + movableParticle.velocity.y) - y);
var _local3:Number = Math.sqrt(((_local1 * _local1) + (_local2 * _local2)));
var _local4:Number = ((tension * (_local3 - restLength)) / _local3);
movableParticle.velocity.x = (movableParticle.velocity.x - (_local1 * _local4));
movableParticle.velocity.y = (movableParticle.velocity.y - (_local2 * _local4));
}
}
}//package de.popforge.revive.forces
Section 5
//IForce (de.popforge.revive.forces.IForce)
package de.popforge.revive.forces {
public interface IForce {
function solve():void;
}
}//package de.popforge.revive.forces
Section 6
//Spring (de.popforge.revive.forces.Spring)
package de.popforge.revive.forces {
import flash.display.*;
import de.popforge.revive.member.*;
import de.popforge.revive.display.*;
public class Spring implements IForce, IDrawAble {
private var m0:MovableParticle;
private var tension:Number;
private var restLength:Number;
private var m1:MovableParticle;
public function Spring(_arg1:MovableParticle, _arg2:MovableParticle, _arg3:Number=0.5, _arg4:Number=-1){
var _local5:Number;
var _local6:Number;
super();
this.m0 = _arg1;
this.m1 = _arg2;
this.tension = _arg3;
if (_arg4 == -1){
_local5 = (_arg1.x - _arg2.x);
_local6 = (_arg1.y - _arg2.y);
_arg4 = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
};
this.restLength = _arg4;
}
public function draw(_arg1:Graphics):void{
_arg1.moveTo(m0.x, m0.y);
_arg1.lineTo(m1.x, m1.y);
}
public function solve():void{
var _local1:Number = ((m1.x + m1.velocity.x) - (m0.x + m0.velocity.x));
var _local2:Number = ((m1.y + m1.velocity.y) - (m0.y + m0.velocity.y));
var _local3:Number = Math.sqrt(((_local1 * _local1) + (_local2 * _local2)));
var _local4:Number = ((tension * (_local3 - restLength)) / _local3);
_local1 = (_local1 * _local4);
_local2 = (_local2 * _local4);
m0.velocity.x = (m0.velocity.x + _local1);
m0.velocity.y = (m0.velocity.y + _local2);
m1.velocity.x = (m1.velocity.x - _local1);
m1.velocity.y = (m1.velocity.y - _local2);
}
}
}//package de.popforge.revive.forces
Section 7
//BoundingBox (de.popforge.revive.geom.BoundingBox)
package de.popforge.revive.geom {
public class BoundingBox {
public var yMin:Number;
public var xMin:Number;
public var yMax:Number;
public var xMax:Number;
public function BoundingBox(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number){
this.xMin = _arg1;
this.yMin = _arg2;
this.xMax = _arg3;
this.yMax = _arg4;
}
public function intersect(_arg1:BoundingBox):Boolean{
if (xMin > _arg1.xMax){
return (false);
};
if (yMin > _arg1.yMax){
return (false);
};
if (xMax < _arg1.xMin){
return (false);
};
if (yMax < _arg1.yMin){
return (false);
};
return (true);
}
}
}//package de.popforge.revive.geom
Section 8
//Vector (de.popforge.revive.geom.Vector)
package de.popforge.revive.geom {
public class Vector {
public var x:Number;
public var y:Number;
public function Vector(_arg1:Number, _arg2:Number){
this.x = _arg1;
this.y = _arg2;
}
public function scale(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
}
public function length():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function unify():void{
var _local1:Number = length();
x = (x / _local1);
y = (y / _local1);
}
public function toString():String{
return (((("Vector x: " + x) + " y: ") + y));
}
public function clone():Vector{
return (new Vector(x, y));
}
}
}//package de.popforge.revive.geom
Section 9
//Immovable (de.popforge.revive.member.Immovable)
package de.popforge.revive.member {
import de.popforge.revive.geom.*;
public class Immovable {
public var groupMask:uint;
public var drag:Number;
public var elastic:Number;
public var bounds:BoundingBox;
static const MIN_REFLECTION:Number = 0.05;
static const EPLISON_DT:Number = -1E-7;
public function Immovable(){
groupMask = 1;
elastic = 0.5;
drag = 0.04;
}
public function setElastic(_arg1:Number):void{
if (_arg1 > 0){
this.elastic = _arg1;
};
}
public function getDrag():Number{
return (drag);
}
public function setDrag(_arg1:Number):void{
this.drag = _arg1;
}
public function getElastic():Number{
return (elastic);
}
}
}//package de.popforge.revive.member
Section 10
//ImmovableGate (de.popforge.revive.member.ImmovableGate)
package de.popforge.revive.member {
import flash.display.*;
import de.popforge.revive.resolve.*;
import de.popforge.revive.display.*;
public class ImmovableGate extends Immovable implements IDynamicIntersectionTestAble, IResolvable, IDrawAble {
private var x1:Number;
private var ny:Number;
private var nx:Number;
private var dx:Number;
private var dy:Number;
private var y0:Number;
private var y1:Number;
private var length:Number;
private var x0:Number;
public function ImmovableGate(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number){
this.x0 = _arg1;
this.y0 = _arg2;
this.x1 = _arg3;
this.y1 = _arg4;
precompute();
}
public function dIntersectMovableCircle(_arg1:MovableCircle, _arg2:Number):DynamicIntersection{
var _local3:Number = _arg1.velocity.x;
var _local4:Number = _arg1.velocity.y;
var _local5:Number = ((_local4 * dx) - (_local3 * dy));
if (_local5 <= 0){
return (null);
};
var _local6:Number = _arg1.r;
var _local7:Number = ((_arg1.x - x0) - (nx * _local6));
var _local8:Number = ((_arg1.y - y0) - (ny * _local6));
var _local9:Number = (((_local4 * _local7) - (_local3 * _local8)) / _local5);
if ((((_local9 < 0)) || ((_local9 > 1)))){
return (null);
};
var _local10:Number = (((dy * _local7) - (dx * _local8)) / _local5);
if ((((_local10 > EPLISON_DT)) && ((_local10 < 0)))){
_local10 = 0;
};
if ((((_local10 < 0)) || ((_local10 > _arg2)))){
return (null);
};
return (new DynamicIntersection(this, _arg1, _local10));
}
public function draw(_arg1:Graphics):void{
_arg1.moveTo(x0, y0);
_arg1.lineTo(x1, y1);
var _local2:Number = ((x0 + x1) / 2);
var _local3:Number = ((y0 + y1) / 2);
_arg1.moveTo((_local2 - (ny * 3)), (_local3 + (nx * 3)));
_arg1.lineTo((_local2 + (nx * 3)), (_local3 + (ny * 3)));
_arg1.lineTo((_local2 + (ny * 3)), (_local3 - (nx * 3)));
}
public function resolveMovableParticle(_arg1:MovableParticle):void{
var _local2:Number = ((1 + elastic) * ((nx * _arg1.velocity.x) + (ny * _arg1.velocity.y)));
_arg1.velocity.x = (_arg1.velocity.x - (nx * _local2));
_arg1.velocity.y = (_arg1.velocity.y - (ny * _local2));
_arg1.velocity.x = (_arg1.velocity.x - (_arg1.velocity.x * drag));
_arg1.velocity.y = (_arg1.velocity.y - (_arg1.velocity.y * drag));
}
public function resolveMovableCircle(_arg1:MovableCircle):void{
var _local2:Number = ((1 + elastic) * ((nx * _arg1.velocity.x) + (ny * _arg1.velocity.y)));
_arg1.velocity.x = (_arg1.velocity.x - (nx * _local2));
_arg1.velocity.y = (_arg1.velocity.y - (ny * _local2));
}
public function dIntersectMovableSegment(_arg1:MovableSegment, _arg2:Number):DynamicIntersection{
return (null);
}
public function resolveMovableSegment(_arg1:MovableSegment):void{
}
private function precompute():void{
dx = (x1 - x0);
dy = (y1 - y0);
length = Math.sqrt(((dx * dx) + (dy * dy)));
nx = (dy / length);
ny = (-(dx) / length);
}
public function dIntersectMovableParticle(_arg1:MovableParticle, _arg2:Number):DynamicIntersection{
var _local3:Number = _arg1.velocity.x;
var _local4:Number = _arg1.velocity.y;
var _local5:Number = ((_local4 * dx) - (_local3 * dy));
if (_local5 <= 0){
return (null);
};
var _local6:Number = (_arg1.x - x0);
var _local7:Number = (_arg1.y - y0);
var _local8:Number = (((_local4 * _local6) - (_local3 * _local7)) / _local5);
if ((((_local8 < 0)) || ((_local8 > 1)))){
return (null);
};
var _local9:Number = (((dy * _local6) - (dx * _local7)) / _local5);
if ((((_local9 > EPLISON_DT)) && ((_local9 < 0)))){
_local9 = 0;
};
if ((((_local9 < 0)) || ((_local9 > _arg2)))){
return (null);
};
return (new DynamicIntersection(this, _arg1, _local9));
}
}
}//package de.popforge.revive.member
Section 11
//ImmovablePoint (de.popforge.revive.member.ImmovablePoint)
package de.popforge.revive.member {
import flash.display.*;
import de.popforge.revive.resolve.*;
import de.popforge.revive.display.*;
public class ImmovablePoint extends Immovable implements IDynamicIntersectionTestAble, IResolvable, IDrawAble {
private var y:Number;
private var x:Number;
public function ImmovablePoint(_arg1:Number, _arg2:Number){
this.x = _arg1;
this.y = _arg2;
}
public function resolveMovableCircle(_arg1:MovableCircle):void{
var _local5:Number;
var _local2:Number = _arg1.r;
var _local3:Number = ((_arg1.x - x) / _local2);
var _local4:Number = ((_arg1.y - y) / _local2);
_local5 = ((1 + elastic) * ((_local3 * _arg1.velocity.x) + (_local4 * _arg1.velocity.y)));
if (_local5 > -(MIN_REFLECTION)){
_local5 = -(MIN_REFLECTION);
};
_arg1.velocity.x = (_arg1.velocity.x - (_local3 * _local5));
_arg1.velocity.y = (_arg1.velocity.y - (_local4 * _local5));
}
public function dIntersectMovableCircle(_arg1:MovableCircle, _arg2:Number):DynamicIntersection{
var _local3:Number = (x - _arg1.x);
var _local4:Number = (y - _arg1.y);
var _local5:Number = _arg1.velocity.x;
var _local6:Number = _arg1.velocity.y;
var _local7:Number = ((_local5 * _local5) + (_local6 * _local6));
var _local8:Number = ((_local3 * _local6) - (_local4 * _local5));
var _local9:Number = ((_local7 * (_arg1.r * _arg1.r)) - (_local8 * _local8));
if (_local9 < 0){
return (null);
};
var _local10:Number = (-(((Math.sqrt(_local9) - (_local4 * _local6)) - (_local3 * _local5))) / _local7);
if ((((_local10 > EPLISON_DT)) && ((_local10 < 0)))){
_local10 = 0;
};
if ((((_local10 < 0)) || ((_local10 > _arg2)))){
return (null);
};
return (new DynamicIntersection(this, _arg1, _local10));
}
public function draw(_arg1:Graphics):void{
_arg1.moveTo((x - 3), y);
_arg1.lineTo((x + 3), y);
_arg1.moveTo(x, (y - 3));
_arg1.lineTo(x, (y + 3));
}
public function resolveMovableParticle(_arg1:MovableParticle):void{
trace("Never expected, that particle intersect each other.");
}
public function resolveMovableSegment(_arg1:MovableSegment):void{
}
public function dIntersectMovableSegment(_arg1:MovableSegment, _arg2:Number):DynamicIntersection{
var _local3:Number = this.x;
var _local4:Number = this.y;
var _local5:Number = ((_local4 * _arg1.dx) - (_local3 * _arg1.dy));
if (_local5 <= 0){
return (null);
};
var _local6:Number = (this.x - _arg1.m0.x);
var _local7:Number = (this.y - _arg1.m0.y);
var _local8:Number = (((_local4 * _local6) - (_local3 * _local7)) / _local5);
if ((((_local8 < 0)) || ((_local8 > 1)))){
return (null);
};
var _local9:Number = (((_arg1.dy * _local6) - (_arg1.dx * _local7)) / _local5);
if ((((_local9 > EPLISON_DT)) && ((_local9 < 0)))){
_local9 = 0;
};
if ((((_local9 < 0)) || ((_local9 > _arg2)))){
return (null);
};
return (new DynamicIntersection(this, _arg1, _local9));
}
public function dIntersectMovableParticle(_arg1:MovableParticle, _arg2:Number):DynamicIntersection{
return (null);
}
}
}//package de.popforge.revive.member
Section 12
//Movable (de.popforge.revive.member.Movable)
package de.popforge.revive.member {
import de.popforge.revive.geom.*;
public class Movable {
public var groupMask:uint;
static const EPLISON_DT:Number = -1E-7;
public function Movable(){
groupMask = 1;
}
public function integrate(_arg1:Number):void{
}
public function applyGlobalEnvirons(_arg1:Vector, _arg2:Number):void{
}
}
}//package de.popforge.revive.member
Section 13
//MovableCircle (de.popforge.revive.member.MovableCircle)
package de.popforge.revive.member {
import flash.display.*;
import de.popforge.revive.resolve.*;
import de.popforge.revive.geom.*;
import de.popforge.revive.display.*;
public class MovableCircle extends MovableParticle implements IDynamicIntersectionTestAble, IResolvable, IDrawAble {
public var r:Number;
public function MovableCircle(_arg1:Number, _arg2:Number, _arg3:Number){
super(_arg1, _arg2);
this.r = _arg3;
}
override public function dIntersectMovableCircle(_arg1:MovableCircle, _arg2:Number):DynamicIntersection{
var _local3:Number = (x - _arg1.x);
var _local4:Number = (y - _arg1.y);
var _local5:Number = (r + _arg1.r);
var _local6:Number = ((r + _arg1.r) * _local5);
var _local7:Number = (_arg1.velocity.x - velocity.x);
var _local8:Number = (_arg1.velocity.y - velocity.y);
var _local9:Number = ((_local7 * _local7) + (_local8 * _local8));
if (_local9 == 0){
return (null);
};
var _local10:Number = ((_local3 * _local8) - (_local4 * _local7));
var _local11:Number = ((_local9 * _local6) - (_local10 * _local10));
if (_local11 < 0){
return (null);
};
var _local12:Number = (-(((Math.sqrt(_local11) - (_local4 * _local8)) - (_local3 * _local7))) / _local9);
if ((((_local12 > EPLISON_DT)) && ((_local12 < 0)))){
_local12 = 0;
};
if ((((_local12 < 0)) || ((_local12 > _arg2)))){
return (null);
};
return (new DynamicIntersection(this, _arg1, _local12));
}
override public function resolveMovableParticle(_arg1:MovableParticle):void{
var _local2:Number = ((x - _arg1.x) / r);
var _local3:Number = ((y - _arg1.y) / r);
var _local4:Vector = _arg1.velocity;
var _local5:Vector = velocity;
var _local6:Number = (((((_local4.x * _local2) + (_local4.y * _local3)) - (_local5.x * _local2)) - (_local5.y * _local3)) * 1);
if (_local6 < 0.0001){
_local6 = 0.0001;
};
_local2 = (_local2 * _local6);
_local3 = (_local3 * _local6);
_local4.x = (_local4.x - _local2);
_local4.y = (_local4.y - _local3);
_local5.x = (_local5.x + _local2);
_local5.y = (_local5.y + _local3);
}
override public function draw(_arg1:Graphics):void{
_arg1.drawCircle(x, y, Math.max(r, 3));
}
override public function resolveMovableCircle(_arg1:MovableCircle):void{
var _local2:Number = (r + _arg1.r);
var _local3:Number = ((x - _arg1.x) / _local2);
var _local4:Number = ((y - _arg1.y) / _local2);
var _local5:Vector = _arg1.velocity;
var _local6:Vector = velocity;
var _local7:Number = (((((_local5.x * _local3) + (_local5.y * _local4)) - (_local6.x * _local3)) - (_local6.y * _local4)) * 1);
if (_local7 < 0.0001){
_local7 = 0.0001;
};
_local3 = (_local3 * _local7);
_local4 = (_local4 * _local7);
_local5.x = (_local5.x - _local3);
_local5.y = (_local5.y - _local4);
_local6.x = (_local6.x + _local3);
_local6.y = (_local6.y + _local4);
}
override public function dIntersectMovableParticle(_arg1:MovableParticle, _arg2:Number):DynamicIntersection{
return (null);
}
}
}//package de.popforge.revive.member
Section 14
//MovableParticle (de.popforge.revive.member.MovableParticle)
package de.popforge.revive.member {
import flash.display.*;
import de.popforge.revive.resolve.*;
import de.popforge.revive.geom.*;
import de.popforge.revive.display.*;
public class MovableParticle extends Movable implements IDynamicIntersectionTestAble, IResolvable, IDrawAble {
public var y:Number;
public var x:Number;
public var velocity:Vector;
public function MovableParticle(_arg1:Number, _arg2:Number){
this.x = _arg1;
this.y = _arg2;
velocity = new Vector(0, 0);
}
public function resolveMovableCircle(_arg1:MovableCircle):void{
var _local2:Number = _arg1.r;
var _local3:Number = ((x - _arg1.x) / _local2);
var _local4:Number = ((y - _arg1.y) / _local2);
var _local5:Vector = _arg1.velocity;
var _local6:Vector = velocity;
var _local7:Number = (((((_local5.x * _local3) + (_local5.y * _local4)) - (_local6.x * _local3)) - (_local6.y * _local4)) * 1);
if (_local7 < 0.0001){
_local7 = 0.0001;
};
_local3 = (_local3 * _local7);
_local4 = (_local4 * _local7);
_local5.x = (_local5.x - _local3);
_local5.y = (_local5.y - _local4);
_local6.x = (_local6.x + _local3);
_local6.y = (_local6.y + _local4);
}
public function dIntersectMovableCircle(_arg1:MovableCircle, _arg2:Number):DynamicIntersection{
var _local3:Number = (x - _arg1.x);
var _local4:Number = (y - _arg1.y);
var _local5:Number = _arg1.r;
var _local6:Number = (_arg1.r * _local5);
var _local7:Number = (_arg1.velocity.x - velocity.x);
var _local8:Number = (_arg1.velocity.y - velocity.y);
var _local9:Number = ((_local7 * _local7) + (_local8 * _local8));
if (_local9 == 0){
return (null);
};
var _local10:Number = ((_local3 * _local8) - (_local4 * _local7));
var _local11:Number = ((_local9 * _local6) - (_local10 * _local10));
if (_local11 < 0){
return (null);
};
var _local12:Number = (-(((Math.sqrt(_local11) - (_local4 * _local8)) - (_local3 * _local7))) / _local9);
if ((((_local12 > EPLISON_DT)) && ((_local12 < 0)))){
_local12 = 0;
};
if ((((_local12 < 0)) || ((_local12 > _arg2)))){
return (null);
};
return (new DynamicIntersection(this, _arg1, _local12));
}
public function draw(_arg1:Graphics):void{
_arg1.drawCircle(x, y, 1);
}
public function dIntersectMovableSegment(_arg1:MovableSegment, _arg2:Number):DynamicIntersection{
return (_arg1.dIntersectMovableParticle(this, _arg2));
}
public function dIntersectMovableParticle(_arg1:MovableParticle, _arg2:Number):DynamicIntersection{
return (null);
}
public function resolveMovableSegment(_arg1:MovableSegment):void{
_arg1.resolveMovableParticle(this);
}
override public function applyGlobalEnvirons(_arg1:Vector, _arg2:Number):void{
velocity.x = (velocity.x + _arg1.x);
velocity.y = (velocity.y + _arg1.y);
velocity.x = (velocity.x - (velocity.x * _arg2));
velocity.y = (velocity.y - (velocity.y * _arg2));
}
override public function integrate(_arg1:Number):void{
x = (x + (velocity.x * _arg1));
y = (y + (velocity.y * _arg1));
}
public function resolveMovableParticle(_arg1:MovableParticle):void{
}
}
}//package de.popforge.revive.member
Section 15
//MovableSegment (de.popforge.revive.member.MovableSegment)
package de.popforge.revive.member {
import flash.display.*;
import de.popforge.revive.resolve.*;
import de.popforge.revive.display.*;
public class MovableSegment extends Movable implements IDynamicIntersectionTestAble, IResolvable, IDrawAble {
public var nx:Number;
public var ny:Number;
public var dy:Number;
public var dx:Number;
var m0:MovableParticle;
var m1:MovableParticle;
public var length:Number;
public function MovableSegment(_arg1:MovableParticle, _arg2:MovableParticle){
this.m0 = _arg1;
this.m1 = _arg2;
}
public function dIntersectMovableParticle(_arg1:MovableParticle, _arg2:Number):DynamicIntersection{
var _local3:Number = _arg1.x;
var _local4:Number = _arg1.y;
if ((((_arg1 == m0)) || ((_arg1 == m1)))){
return (null);
};
var _local5:Number = m0.x;
var _local6:Number = m0.y;
var _local7:Number = m1.x;
var _local8:Number = m1.y;
var _local9:Number = _arg1.velocity.x;
var _local10:Number = _arg1.velocity.y;
var _local11:Number = m0.velocity.x;
var _local12:Number = m0.velocity.y;
var _local13:Number = m1.velocity.x;
var _local14:Number = m1.velocity.y;
var _local15:Number = (((((2 * _local11) - (2 * _local9)) * _local14) + (((2 * _local9) - (2 * _local13)) * _local12)) + (((2 * _local13) - (2 * _local11)) * _local10));
if (_local15 == 0){
return (null);
};
var _local16:Number = (_local9 * _local9);
var _local17:Number = (_local11 * _local11);
var _local18:Number = (_local13 * _local13);
var _local19:Number = (_local10 * _local10);
var _local20:Number = (_local12 * _local12);
var _local21:Number = (_local14 * _local14);
var _local22:Number = (_local9 * _local11);
var _local23:Number = (_local10 * _local12);
var _local24:Number = (_local9 * _local13);
var _local25:Number = (_local9 - _local11);
var _local26:Number = (_local10 - _local12);
var _local27:Number = (_local9 - _local13);
var _local28:Number = (_local10 - _local14);
var _local29:Number = (_local11 - _local13);
var _local30:Number = (_local12 - _local14);
var _local31:Number = (_local9 + _local11);
var _local32:Number = (_local9 + _local13);
var _local33:Number = (_local11 + _local13);
var _local34:Number = ((((((((((((((_local17 - (2 * _local22)) + _local16) * _local8) * _local8) + (((((((2 * ((_local25 * _local13) + (_local22 - _local16))) * _local6) - ((2 * (((_local25 * _local13) + _local17) - _local22)) * _local4)) + ((2 * ((_local25 * _local12) - (_local25 * _local10))) * _local7)) + ((2 * (((_local25 * _local14) - ((2 * _local27) * _local12)) + ((_local31 - (2 * _local13)) * _local10))) * _local5)) + (((-2 * ((_local25 * _local14) + (((2 * _local13) - _local31) * _local12))) - ((4 * _local29) * _local10)) * _local3)) * _local8)) + ((((_local18 - (2 * _local24)) + _local16) * _local6) * _local6)) + ((((((2 * (((_local31 * _local13) - _local22) - _local18)) * _local4) + ((2 * (((_local27 * _local12) + ((_local32 - (2 * _local11)) * _local10)) - ((2 * _local25) * _local14))) * _local7)) + ((2 * ((_local27 * _local14) - (_local27 * _local10))) * _local5)) + ((2 * (((((_local13 - (2 * _local11)) + _local9) * _local14) - (_local27 * _local12)) + ((2 * _local29) * _local10))) * _local3)) * _local6)) + ((((_local18 - ((2 * _local11) * _local13)) + _local17) * _local4) * _local4)) + (((((2 * ((((2 * _local25) * _local14) + ((_local33 - (2 * _local9)) * _local12)) + (_local29 * _local10))) * _local7) + ((2 * (((((_local13 + _local11) - (2 * _local9)) * _local14) + ((2 * _local27) * _local12)) - (_local29 * _local10))) * _local5)) + ((2 * ((_local29 * _local14) - (_local29 * _local12))) * _local3)) * _local4)) + ((((_local20 - ((2 * _local10) * _local12)) + _local19) * _local7) * _local7)) + ((((2 * ((_local26 * _local14) + ((_local10 * _local12) - _local19))) * _local5) + ((2 * ((-(_local26) * _local14) - (_local20 - _local23))) * _local3)) * _local7)) + ((((_local21 - ((2 * _local10) * _local14)) + _local19) * _local5) * _local5)) - (((2 * ((_local21 - ((_local12 + _local10) * _local14)) + _local23)) * _local3) * _local5)) + ((((_local21 - ((2 * _local12) * _local14)) + _local20) * _local3) * _local3));
if (_local34 < 0){
return (null);
};
var _local35:Number = (-(((((((Math.sqrt(_local34) + (_local27 * _local6)) - (_local25 * _local8)) + (_local26 * _local7)) - (_local29 * _local4)) + (_local30 * _local3)) - (_local28 * _local5))) / _local15);
if ((((_local35 < 0)) || ((_local35 > _arg2)))){
return (null);
};
var _local36:Number = (m1.x - m0.x);
var _local37:Number = (m1.y - m0.y);
var _local38:Number = ((_arg1.x + (_arg1.velocity.x * _local35)) - m0.x);
var _local39:Number = ((_arg1.y + (_arg1.velocity.y * _local35)) - m0.y);
var _local40:Number = (((_local38 * _local36) + (_local39 * _local37)) / ((_local36 * _local36) + (_local37 * _local37)));
if ((((_local40 < 0)) || ((_local40 > 1)))){
return (null);
};
return (new DynamicIntersection(this, _arg1, _local35));
}
public function draw(_arg1:Graphics):void{
_arg1.moveTo(m0.x, m0.y);
_arg1.lineTo(m1.x, m1.y);
}
public function dIntersectMovableCircle(_arg1:MovableCircle, _arg2:Number):DynamicIntersection{
return (null);
}
public function resolveMovableParticle(_arg1:MovableParticle):void{
var _local2:Number = (m1.x - m0.x);
var _local3:Number = (m1.y - m0.y);
var _local4:Number = _local3;
var _local5:Number = -(_local2);
var _local6:Number = ((_local4 * _local4) + (_local5 * _local5));
var _local7:Number = ((((_arg1.x - m0.x) * _local2) + ((_arg1.y - m0.y) * _local3)) / _local6);
var _local8:Number = (1 - _local7);
_local6 = Math.sqrt(_local6);
_local4 = (_local4 / _local6);
_local5 = (_local5 / _local6);
var _local9:Number = ((m0.velocity.x * _local8) + (m1.velocity.x * _local7));
var _local10:Number = ((m0.velocity.y * _local8) + (m1.velocity.y * _local7));
var _local11:Number = (((((_local4 * _arg1.velocity.x) + (_local5 * _arg1.velocity.y)) - (_local4 * _local9)) - (_local5 * _local10)) * 1);
if (_local11 < 0.01){
_local11 = 0.01;
};
_arg1.velocity.x = (_arg1.velocity.x - (_local4 * _local11));
_arg1.velocity.y = (_arg1.velocity.y - (_local5 * _local11));
m0.velocity.x = (m0.velocity.x + ((_local4 * _local11) * _local8));
m0.velocity.y = (m0.velocity.y + ((_local5 * _local11) * _local8));
m1.velocity.x = (m1.velocity.x + ((_local4 * _local11) * _local7));
m1.velocity.y = (m1.velocity.y + ((_local5 * _local11) * _local7));
var _local12:Number = 0.1;
m0.velocity.x = (m0.velocity.x - (m0.velocity.x * _local12));
m0.velocity.y = (m0.velocity.y - (m0.velocity.y * _local12));
m1.velocity.x = (m1.velocity.x - (m1.velocity.x * _local12));
m1.velocity.y = (m1.velocity.y - (m1.velocity.y * _local12));
_arg1.velocity.x = (_arg1.velocity.x - (_arg1.velocity.x * _local12));
_arg1.velocity.y = (_arg1.velocity.y - (_arg1.velocity.y * _local12));
}
public function dIntersectMovableSegment(_arg1:MovableSegment, _arg2:Number):DynamicIntersection{
return (null);
}
public function resolveMovableCircle(_arg1:MovableCircle):void{
}
public function resolveMovableSegment(_arg1:MovableSegment):void{
}
private function precompute():void{
dx = (m1.x - m0.x);
dy = (m1.y - m0.y);
length = Math.sqrt(((dx * dx) + (dy * dy)));
nx = (dy / length);
ny = (-(dx) / length);
}
}
}//package de.popforge.revive.member
Section 16
//MovableSegmentParticle (de.popforge.revive.member.MovableSegmentParticle)
package de.popforge.revive.member {
public class MovableSegmentParticle extends MovableParticle {
public function MovableSegmentParticle(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package de.popforge.revive.member
Section 17
//MyGate (de.popforge.revive.member.MyGate)
package de.popforge.revive.member {
import flash.display.*;
import de.popforge.revive.resolve.*;
import de.popforge.revive.display.*;
public class MyGate extends Immovable implements IDynamicIntersectionTestAble, IResolvable, IDrawAble {
public var x1:Number;
private var ny:Number;
private var nx:Number;
private var dx:Number;
private var dy:Number;
public var y0:Number;
public var y1:Number;
private var length:Number;
public var x0:Number;
public function MyGate(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number){
this.x0 = _arg1;
this.y0 = _arg2;
this.x1 = _arg3;
this.y1 = _arg4;
precompute();
}
public function dIntersectMovableCircle(_arg1:MovableCircle, _arg2:Number):DynamicIntersection{
var _local3:Number = _arg1.velocity.x;
var _local4:Number = _arg1.velocity.y;
var _local5:Number = ((_local4 * dx) - (_local3 * dy));
if (_local5 <= 0){
return (null);
};
var _local6:Number = _arg1.r;
var _local7:Number = ((_arg1.x - x0) - (nx * _local6));
var _local8:Number = ((_arg1.y - y0) - (ny * _local6));
var _local9:Number = (((_local4 * _local7) - (_local3 * _local8)) / _local5);
if ((((_local9 < 0)) || ((_local9 > 1)))){
return (null);
};
var _local10:Number = (((dy * _local7) - (dx * _local8)) / _local5);
if ((((_local10 > EPLISON_DT)) && ((_local10 < 0)))){
_local10 = 0;
};
if ((((_local10 < 0)) || ((_local10 > _arg2)))){
return (null);
};
return (new DynamicIntersection(this, _arg1, _local10));
}
public function draw(_arg1:Graphics):void{
_arg1.moveTo(x0, y0);
_arg1.lineTo(x1, y1);
var _local2:Number = ((x0 + x1) / 2);
var _local3:Number = ((y0 + y1) / 2);
_arg1.moveTo((_local2 - (ny * 3)), (_local3 + (nx * 3)));
_arg1.lineTo((_local2 + (nx * 3)), (_local3 + (ny * 3)));
_arg1.lineTo((_local2 + (ny * 3)), (_local3 - (nx * 3)));
}
public function resolveMovableParticle(_arg1:MovableParticle):void{
var _local2:Number = ((1 + elastic) * ((nx * _arg1.velocity.x) + (ny * _arg1.velocity.y)));
_arg1.velocity.x = (_arg1.velocity.x - (nx * _local2));
_arg1.velocity.y = (_arg1.velocity.y - (ny * _local2));
_arg1.velocity.x = (_arg1.velocity.x - (_arg1.velocity.x * drag));
_arg1.velocity.y = (_arg1.velocity.y - (_arg1.velocity.y * drag));
}
public function resolveMovableCircle(_arg1:MovableCircle):void{
var _local2:Number = ((1 + elastic) * ((nx * _arg1.velocity.x) + (ny * _arg1.velocity.y)));
_arg1.velocity.x = (_arg1.velocity.x - (nx * _local2));
_arg1.velocity.y = (_arg1.velocity.y - (ny * _local2));
}
public function dIntersectMovableSegment(_arg1:MovableSegment, _arg2:Number):DynamicIntersection{
return (null);
}
public function resolveMovableSegment(_arg1:MovableSegment):void{
}
private function precompute():void{
dx = (x1 - x0);
dy = (y1 - y0);
length = Math.sqrt(((dx * dx) + (dy * dy)));
nx = (dy / length);
ny = (-(dx) / length);
}
public function dIntersectMovableParticle(_arg1:MovableParticle, _arg2:Number):DynamicIntersection{
var _local3:Number = _arg1.velocity.x;
var _local4:Number = _arg1.velocity.y;
var _local5:Number = ((_local4 * dx) - (_local3 * dy));
if (_local5 <= 0){
return (null);
};
var _local6:Number = (_arg1.x - x0);
var _local7:Number = (_arg1.y - y0);
var _local8:Number = (((_local4 * _local6) - (_local3 * _local7)) / _local5);
if ((((_local8 < 0)) || ((_local8 > 1)))){
return (null);
};
var _local9:Number = (((dy * _local6) - (dx * _local7)) / _local5);
if ((((_local9 > EPLISON_DT)) && ((_local9 < 0)))){
_local9 = 0;
};
if ((((_local9 < 0)) || ((_local9 > _arg2)))){
return (null);
};
return (new DynamicIntersection(this, _arg1, _local9));
}
}
}//package de.popforge.revive.member
Section 18
//DynamicIntersection (de.popforge.revive.resolve.DynamicIntersection)
package de.popforge.revive.resolve {
import de.popforge.revive.member.*;
public class DynamicIntersection {
public var dt:Number;
public var resolvable:IResolvable;
public var movable:Movable;
public function DynamicIntersection(_arg1:IResolvable, _arg2:Movable, _arg3:Number){
this.resolvable = _arg1;
this.movable = _arg2;
this.dt = _arg3;
}
}
}//package de.popforge.revive.resolve
Section 19
//IDynamicIntersectionTestAble (de.popforge.revive.resolve.IDynamicIntersectionTestAble)
package de.popforge.revive.resolve {
import de.popforge.revive.member.*;
public interface IDynamicIntersectionTestAble {
function dIntersectMovableSegment(_arg1:MovableSegment, _arg2:Number):DynamicIntersection;
function dIntersectMovableParticle(_arg1:MovableParticle, _arg2:Number):DynamicIntersection;
function dIntersectMovableCircle(_arg1:MovableCircle, _arg2:Number):DynamicIntersection;
}
}//package de.popforge.revive.resolve
Section 20
//IResolvable (de.popforge.revive.resolve.IResolvable)
package de.popforge.revive.resolve {
import de.popforge.revive.member.*;
public interface IResolvable {
function resolveMovableParticle(_arg1:MovableParticle):void;
function resolveMovableSegment(_arg1:MovableSegment):void;
function resolveMovableCircle(_arg1:MovableCircle):void;
}
}//package de.popforge.revive.resolve
Section 21
//DefaultTextFormat (de.popforge.surface.display.DefaultTextFormat)
package de.popforge.surface.display {
import flash.text.*;
public class DefaultTextFormat extends TextFormat {
public function DefaultTextFormat(){
color = 0x666666;
size = 10;
bold = true;
font = "Verdana";
}
}
}//package de.popforge.surface.display
Section 22
//FPSCounter (de.popforge.surface.display.FPSCounter)
package de.popforge.surface.display {
import flash.events.*;
import flash.text.*;
import flash.utils.*;
public class FPSCounter extends TextField {
private var ms:int;
private var fs:int;
public function FPSCounter(){
textColor = 0xCECECE;
autoSize = "left";
defaultTextFormat = new DefaultTextFormat();
ms = getTimer();
fs = 0;
addEventListener(Event.ADDED, onAdded);
addEventListener(Event.REMOVED, onRemoved);
}
private function onAdded(_arg1:Event):void{
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(_arg1:Event):void{
if ((getTimer() - 1000) > ms){
ms = getTimer();
text = fs.toString();
fs = 0;
} else {
fs++;
};
}
private function onRemoved(_arg1:Event):void{
stage.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
}//package de.popforge.surface.display
Section 23
//BitmapAsset (mx.core.BitmapAsset)
package mx.core {
import flash.display.*;
public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject {
mx_internal static const VERSION:String = "3.0.0.0";
public function BitmapAsset(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
public function get measuredWidth():Number{
if (bitmapData){
return (bitmapData.width);
};
return (0);
}
public function get measuredHeight():Number{
if (bitmapData){
return (bitmapData.height);
};
return (0);
}
public function setActualSize(_arg1:Number, _arg2:Number):void{
width = _arg1;
height = _arg2;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
}
}//package mx.core
Section 24
//FlexBitmap (mx.core.FlexBitmap)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexBitmap extends Bitmap {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexBitmap(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
var bitmapData = _arg1;
var pixelSnapping = _arg2;
var smoothing = _arg3;
super(bitmapData, pixelSnapping, smoothing);
try {
name = NameUtil.createUniqueName(this);
} catch(e:Error) {
};
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 25
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 26
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.accessibility.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get visible():Boolean;
function get rotation():Number;
function localToGlobal(_arg1:Point):Point;
function get name():String;
function set width(_arg1:Number):void;
function get measuredHeight():Number;
function get blendMode():String;
function get scale9Grid():Rectangle;
function set name(_arg1:String):void;
function set scaleX(_arg1:Number):void;
function set scaleY(_arg1:Number):void;
function get measuredWidth():Number;
function get accessibilityProperties():AccessibilityProperties;
function set scrollRect(_arg1:Rectangle):void;
function get cacheAsBitmap():Boolean;
function globalToLocal(_arg1:Point):Point;
function get height():Number;
function set blendMode(_arg1:String):void;
function get parent():DisplayObjectContainer;
function getBounds(_arg1:DisplayObject):Rectangle;
function get opaqueBackground():Object;
function set scale9Grid(_arg1:Rectangle):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set alpha(_arg1:Number):void;
function set accessibilityProperties(_arg1:AccessibilityProperties):void;
function get width():Number;
function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean;
function set cacheAsBitmap(_arg1:Boolean):void;
function get scaleX():Number;
function get scaleY():Number;
function get scrollRect():Rectangle;
function get mouseX():Number;
function get mouseY():Number;
function set height(_arg1:Number):void;
function set mask(_arg1:DisplayObject):void;
function getRect(_arg1:DisplayObject):Rectangle;
function get alpha():Number;
function set transform(_arg1:Transform):void;
function move(_arg1:Number, _arg2:Number):void;
function get loaderInfo():LoaderInfo;
function get root():DisplayObject;
function hitTestObject(_arg1:DisplayObject):Boolean;
function set opaqueBackground(_arg1:Object):void;
function set visible(_arg1:Boolean):void;
function get mask():DisplayObject;
function set x(_arg1:Number):void;
function set y(_arg1:Number):void;
function get transform():Transform;
function set filters(_arg1:Array):void;
function get x():Number;
function get y():Number;
function get filters():Array;
function set rotation(_arg1:Number):void;
function get stage():Stage;
}
}//package mx.core
Section 27
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(_arg1:Array):void;
function get isDocument():Boolean;
function set repeaters(_arg1:Array):void;
function initializeRepeaterArrays(_arg1:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(_arg1:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 28
//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 29
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import flash.display.*;
import mx.core.*;
import flash.utils.*;
public class NameUtil {
mx_internal static const VERSION:String = "3.0.0.0";
private static var counter:int = 0;
public static function displayObjectToString(_arg1:DisplayObject):String{
var _local2:String;
var _local4:String;
var _local5:Array;
var _local3:DisplayObject = _arg1;
while (_local3 != null) {
if (((((_local3.parent) && (_local3.stage))) && ((_local3.parent == _local3.stage)))){
break;
};
_local4 = _local3.name;
if ((_local3 is IRepeaterClient)){
_local5 = IRepeaterClient(_local3).instanceIndices;
if (_local5){
_local4 = (_local4 + (("[" + _local5.join("][")) + "]"));
};
};
_local2 = ((_local2 == null)) ? _local4 : ((_local4 + ".") + _local2);
_local3 = _local3.parent;
};
return (_local2);
}
public static function createUniqueName(_arg1:Object):String{
if (!_arg1){
return (null);
};
var _local2:String = getQualifiedClassName(_arg1);
var _local3:int = _local2.indexOf("::");
if (_local3 != -1){
_local2 = _local2.substr((_local3 + 2));
};
var _local4:int = _local2.charCodeAt((_local2.length - 1));
if ((((_local4 >= 48)) && ((_local4 <= 57)))){
_local2 = (_local2 + "_");
};
return ((_local2 + counter++));
}
}
}//package mx.utils
Section 30
//DanmenBody (scenes.DanmenBody)
package scenes {
import flash.events.*;
import flash.display.*;
import de.popforge.revive.member.*;
import de.popforge.revive.resolve.*;
import de.popforge.revive.geom.*;
import de.popforge.revive.forces.*;
import de.popforge.revive.application.*;
import flash.text.*;
import de.popforge.revive.display.*;
import flash.utils.*;
public class DanmenBody {
private var dataWeight:Array;
private var BASE_TENSION:Number;// = 0.2
private var dataThickness:Array;
private var BODY_TENSION:Number;// = 0.4
public var pointBaseArr:Array;
private var dataAllX:Array;
private var mSceneContainer:SceneContainer;
public var config_flg:Boolean;
private var center:Vector;
private var dataX:Array;
private var dataY:Array;
public var pointArr:Array;
private var dataAllY:Array;
public var drawArr:Array;
public static const COLOR_MOVABLE:uint = 0xABABAB;
public static const COLOR_IMMOVABLE:uint = 0x878787;
public static const COLOR_FORCE:uint = 13395507;
public function DanmenBody(_arg1:SceneContainer){
var _local2:uint;
var _local3:Array;
pointBaseArr = new Array();
pointArr = new Array();
drawArr = new Array();
dataAllX = new Array();
dataAllY = new Array();
super();
dataX = new Array(200, 302, 332, 360, 383, 404, 420, 411, 394, 350, 284, 253, 223, 183, 164, 162, 192, 226, 259, 323, 387, 411, 427, 440, 457, 465, 455, 436, 418, 405, 379, 358, 342, 324, 309, 292, 283, 266, 250, 233, 215, 202, 210, 175, 141, 116, 99, 96, 105, 128, 161, 189, 213, 219, 215, 215, 231, 241, 254, 271, 280, 295, 309, 327, 343, 361, 380, 401, 421, 440, 457, 462, 460, 437, 417, 390, 367, 346, 327, 316, 325, 352, 382, 406, 412, 405, 416, 437, 460, 460, 450, 435, 411);
dataY = new Array(50, 26, 29, 38, 51, 66, 83, 103, 100, 104, 116, 125, 124, 127, 143, 168, 179, 175, 165, 150, 135, 128, 117, 116, 130, 156, 175, 171, 178, 171, 185, 185, 192, 189, 198, 195, 206, 205, 214, 207, 214, 215, 232, 225, 230, 243, 265, 288, 314, 333, 341, 340, 327, 302, 276, 244, 245, 235, 228, 234, 227, 225, 213, 216, 207, 209, 200, 203, 195, 195, 187, 210, 235, 235, 236, 239, 245, 250, 266, 290, 312, 324, 316, 304, 275, 0xFF, 262, 260, 260, 276, 304, 329, 346);
dataWeight = new Array(1, 1, 0.8, 0.8, 0.8, 0.8, 0.5, 0.9, 0.2, 0.2, 0.2, 0.5, 0.2, 0.3, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.2, 0.3, 0.9, 0.5, 0.7, 0.7, 0.5, 0.2, 0.4, 0.2, 0.4, 0.2, 0.4, 0.2, 0.4, 0.2, 0.4, 0.2, 0.4, 0.2, 0.4, 0.2, 0.9, 0.7, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.7, 0.9, 0.2, 0.2, 0.4, 0.2, 0.4, 0.2, 0.4, 0.2, 0.4, 0.4, 0.2, 0.4, 0.2, 0.6, 0.7, 0.6, 0.8, 0.8, 0.8, 0.8, 0.7, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.8, 0.8, 0.8, 0.8, 0.7, 0.7, 0.7, 0.7);
dataThickness = new Array(26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26);
mSceneContainer = _arg1;
center = new Vector((SceneContainer.WIDTH / 2), (SceneContainer.HEIGHT / 2));
config_flg = false;
_local2 = 0;
while (_local2 < 2) {
_local3 = new Array();
pointBaseArr[_local2] = _local3;
_local3 = new Array();
pointArr[_local2] = _local3;
_local3 = new Array();
drawArr[_local2] = _local3;
_local2++;
};
createData();
}
public function createData():void{
var _local1:IForce;
var _local2:IForce;
var _local3:MovableParticle;
var _local4:MovableCircle;
var _local6:int;
var _local7:int;
var _local8:Number;
var _local9:Number;
var _local13:uint;
dataAllX[0] = dataX;
dataAllY[0] = dataY;
var _local5:uint = 10;
var _local10:uint = dataAllX[0].length;
_local6 = 0;
while (_local6 < _local10) {
if ((((_local6 >= 0)) && ((_local6 <= 22)))){
_local13 = 16;
} else {
if ((((_local6 >= 23)) && ((_local6 <= 26)))){
_local13 = 272;
} else {
if ((((_local6 >= 27)) && ((_local6 <= 71)))){
_local13 = 0x0100;
} else {
_local13 = 0x1000;
};
};
};
_local8 = dataAllX[0][_local6];
_local9 = dataAllY[0][_local6];
_local3 = new MovableParticle(_local8, _local9);
_local3.groupMask = _local13;
mSceneContainer.simulation.movables.push(_local3);
pointArr[0].push(_local3);
if (_local6 > 0){
_local2 = new Spring(_local3, pointArr[0][(pointArr[0].length - 2)], BODY_TENSION);
mSceneContainer.simulation.addForce(_local2);
};
_local1 = new FixedSpring(_local8, _local9, _local3, dataWeight[_local6]);
mSceneContainer.simulation.forces.push(_local1);
pointBaseArr[0].push(_local1);
_local6++;
};
_local6 = 0;
while (_local6 < pointArr[0].length) {
drawArr[0][_local6] = new Vector(pointArr[0][_local6].x, pointArr[0][_local6].y);
_local6++;
};
var _local11:Array = pointArr[0];
var _local12:Number = 0.5;
_local2 = new Spring(_local11[17], _local11[41], _local12);
mSceneContainer.simulation.addForce(_local2);
_local2 = new Spring(_local11[18], _local11[39], _local12);
mSceneContainer.simulation.addForce(_local2);
_local2 = new Spring(_local11[19], _local11[37], _local12);
mSceneContainer.simulation.addForce(_local2);
_local2 = new Spring(_local11[20], _local11[33], _local12);
mSceneContainer.simulation.addForce(_local2);
_local2 = new Spring(_local11[21], _local11[29], _local12);
mSceneContainer.simulation.addForce(_local2);
}
private function SplineStream(_arg1:Array, _arg2:int):Array{
var _local3:uint;
var _local4:uint;
var _local12:int;
var _local13:int;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local5:int = _arg1.length;
var _local6:Array = new Array();
var _local7:Array = new Array();
var _local8:Array = new Array();
var _local9:Array = new Array();
_local3 = 0;
while (_local3 < (_local5 - 1)) {
_local12 = (_arg1[0].x - _arg1[1].x);
_local13 = (_arg1[0].y - _arg1[1].y);
_local6[_local3] = Math.sqrt(((_local12 * _local12) + (_local13 * _local13)));
_local3++;
};
_local7[0] = [0, 1, 0.5];
_local8[0] = {x:((3 / (2 * _local6[0])) * (_arg1[1].x - _arg1[0].x)), y:((3 / (2 * _local6[0])) * (_arg1[1].y - _arg1[0].y))};
_local7[(_local5 - 1)] = [1, 2, 0];
_local8[(_local5 - 1)] = {x:((3 / _local6[(_local5 - 2)]) * (_arg1[(_local5 - 1)].x - _arg1[(_local5 - 2)].x)), y:((3 / _local6[(_local5 - 2)]) * (_arg1[(_local5 - 1)].y - _arg1[(_local5 - 2)].y))};
_local3 = 1;
while (_local3 < (_local5 - 1)) {
_local14 = _local6[(_local3 - 1)];
_local15 = _local6[_local3];
_local7[_local3] = [_local15, (2 * (_local15 + _local14)), _local14];
_local8[_local3] = {x:(((3 * ((_local14 * _local14) * (_arg1[(_local3 + 1)].x - _arg1[_local3].x))) + (((3 * _local15) * _local15) * (_arg1[_local3].x - _arg1[(_local3 - 1)].x))) / (_local15 * _local14)), y:(((3 * ((_local14 * _local14) * (_arg1[(_local3 + 1)].y - _arg1[_local3].y))) + (((3 * _local15) * _local15) * (_arg1[_local3].y - _arg1[(_local3 - 1)].y))) / (_local15 * _local14))};
_local3++;
};
_local3 = 1;
while (_local3 < _local5) {
_local16 = (_local7[(_local3 - 1)][1] / _local7[_local3][0]);
_local7[_local3] = [0, ((_local7[_local3][1] * _local16) - _local7[(_local3 - 1)][2]), (_local7[_local3][2] * _local16)];
_local8[_local3].x = ((_local8[_local3].x * _local16) - _local8[(_local3 - 1)].x);
_local8[_local3].y = ((_local8[_local3].y * _local16) - _local8[(_local3 - 1)].y);
_local7[_local3][2] = (_local7[_local3][2] / _local7[_local3][1]);
_local8[_local3].x = (_local8[_local3].x / _local7[_local3][1]);
_local8[_local3].y = (_local8[_local3].y / _local7[_local3][1]);
_local7[_local3][1] = 1;
_local3++;
};
_local9[(_local5 - 1)] = {x:_local8[(_local5 - 1)].x, y:_local8[(_local5 - 1)].y};
_local4 = (_local5 - 1);
while (_local4 > 0) {
_local9[(_local4 - 1)] = {x:(_local8[(_local4 - 1)].x - (_local7[(_local4 - 1)][2] * _local9[_local4].x)), y:(_local8[(_local4 - 1)].y - (_local7[(_local4 - 1)][2] * _local9[_local4].y))};
_local4--;
};
var _local10:Array = new Array();
var _local11:int;
_local3 = 0;
while (_local3 < (_local5 - 1)) {
_local14 = _local6[_local3];
_local17 = _arg1[_local3].x;
_local18 = _local9[_local3].x;
_local19 = ((((_arg1[(_local3 + 1)].x - _arg1[_local3].x) * 3) / (_local14 * _local14)) - ((_local9[(_local3 + 1)].x + (2 * _local9[_local3].x)) / _local14));
_local20 = (((_arg1[(_local3 + 1)].x - _arg1[_local3].x) * (-2 / ((_local14 * _local14) * _local14))) + ((_local9[(_local3 + 1)].x + _local9[_local3].x) * (1 / (_local14 * _local14))));
_local21 = _arg1[_local3].y;
_local22 = _local9[_local3].y;
_local23 = ((((_arg1[(_local3 + 1)].y - _arg1[_local3].y) * 3) / (_local14 * _local14)) - ((_local9[(_local3 + 1)].y + (2 * _local9[_local3].y)) / _local14));
_local24 = (((_arg1[(_local3 + 1)].y - _arg1[_local3].y) * (-2 / ((_local14 * _local14) * _local14))) + ((_local9[(_local3 + 1)].y + _local9[_local3].y) * (1 / (_local14 * _local14))));
_local25 = 0;
_local4 = 0;
while (_local4 < _arg2) {
_local10[_local11] = {x:((((((_local20 * _local25) + _local19) * _local25) + _local18) * _local25) + _local17), y:((((((_local24 * _local25) + _local23) * _local25) + _local22) * _local25) + _local21)};
_local11++;
_local25 = (_local25 + (_local14 / _arg2));
_local4++;
};
_local3++;
};
_local10[_local11] = {x:_arg1[(_local5 - 1)].x, y:_arg1[(_local5 - 1)].y};
return (_local10);
}
public function drawObj(_arg1:Graphics):void{
var _local2:int;
var _local5:uint;
var _local6:uint;
var _local3:Array = SplineStream(drawArr[0], 2);
var _local4:uint = (_local3.length - 1);
_arg1.beginFill(12263970);
_arg1.lineStyle(1, 13391189);
_arg1.moveTo(_local3[0].x, _local3[0].y);
_local2 = 1;
while (_local2 < _local4) {
_arg1.lineTo(_local3[_local2].x, _local3[_local2].y);
_local2++;
};
_arg1.lineTo(18, 389);
_arg1.lineTo(19, 118);
_arg1.endFill();
_arg1.lineStyle(26, 11149858);
_arg1.moveTo(_local3[0].x, _local3[0].y);
_local2 = 1;
while (_local2 < _local4) {
_arg1.curveTo(_local3[_local2].x, _local3[_local2].y, _local3[(_local2 + 1)].x, _local3[(_local2 + 1)].y);
_local2 = (_local2 + 2);
};
}
public function updateObj():void{
var i:int;
var a:*;
var b:*;
var loopmax:uint = pointArr[0].length;
i = 0;
while (i < loopmax) {
var _local2 = pointArr[0][i];
with (_local2) {
a = (drawArr[0][i].x - x);
b = (drawArr[0][i].y - y);
drawArr[0][i].x = (drawArr[0][i].x - (a / 10));
drawArr[0][i].y = (drawArr[0][i].y - (b / 10));
};
i = (i + 1);
};
}
}
}//package scenes
Section 31
//InsertObject (scenes.InsertObject)
package scenes {
import flash.events.*;
import flash.display.*;
import de.popforge.revive.member.*;
import flash.geom.*;
import de.popforge.revive.resolve.*;
import de.popforge.revive.geom.*;
import de.popforge.revive.forces.*;
import de.popforge.revive.application.*;
import flash.text.*;
import de.popforge.revive.display.*;
import flash.utils.*;
public class InsertObject {
private var BALL_FILL_COLOR:uint;
private var drawArr:Array;
private var BALL_RADIUS:uint;// = 25
private var center:Vector;
public var gateArr:Array;
private var POINT_NUM:Number;// = 7
public var gatePointArr:Array;
private var mSceneContainer:SceneContainer;
public var config_flg:Boolean;
public var pointArr:Array;
private var BALL_FILL_MATRIX:Matrix;
private var BALL_SPRITE_ARRAY:Array;
public function InsertObject(_arg1:SceneContainer){
var _local2:uint;
var _local3:Sprite;
var _local4:Array;
pointArr = new Array();
drawArr = new Array();
gatePointArr = new Array();
gateArr = new Array();
BALL_SPRITE_ARRAY = new Array();
super();
mSceneContainer = _arg1;
center = new Vector((SceneContainer.WIDTH / 2), (SceneContainer.HEIGHT / 2));
config_flg = false;
BALL_FILL_COLOR = 0;
_local2 = 0;
while (_local2 < POINT_NUM) {
_local3 = new Sprite();
BALL_FILL_MATRIX = new Matrix();
BALL_FILL_MATRIX.createGradientBox((BALL_RADIUS * 2), (BALL_RADIUS * 2), (Math.PI / 2), 0, 0);
_local3.graphics.beginGradientFill(GradientType.RADIAL, [0xFFFFFF, 0], [1, 1], [0, 0xFF], BALL_FILL_MATRIX, SpreadMethod.REPEAT, InterpolationMethod.LINEAR_RGB, 0);
_local3.graphics.drawCircle(BALL_RADIUS, BALL_RADIUS, BALL_RADIUS);
_local3.graphics.endFill();
BALL_SPRITE_ARRAY.push(_local3);
_local2++;
};
_local2 = 0;
while (_local2 < 2) {
_local4 = new Array();
pointArr[_local2] = _local4;
_local4 = new Array();
drawArr[_local2] = _local4;
_local2++;
};
createData();
}
public function createData():void{
var _local1:IForce;
var _local2:MovableCircle;
var _local3:int;
var _local4:int;
var _local5:uint;
_local3 = 0;
while (_local3 < POINT_NUM) {
_local2 = new MovableCircle(600, (30 + ((BALL_RADIUS * 2) * _local3)), BALL_RADIUS);
_local2.groupMask = 17;
mSceneContainer.simulation.movables.push(_local2);
pointArr[0].push(_local2);
if (_local3 > 0){
_local1 = new Spring(pointArr[0][_local3], pointArr[0][(_local3 - 1)], 0.5);
mSceneContainer.simulation.addForce(_local1);
};
_local3++;
};
}
public function restart():void{
var _local1:uint;
var _local2:uint;
var _local4:uint;
var _local5:Array;
var _local3:uint = pointArr.length;
_local1 = 0;
while (_local1 < _local3) {
_local4 = pointArr[_local1].length;
_local5 = pointArr[_local1];
_local2 = 0;
while (_local2 < _local4) {
_local5[_local2].x = 600;
_local5[_local2].y = (30 + ((BALL_RADIUS * 2) * _local2));
_local2++;
};
_local1++;
};
}
public function drawObj(_arg1:Graphics):void{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:Number;
var _local6:Array = drawArr[0];
_arg1.lineStyle(5, 0);
_local4 = (_local6.length - 1);
_local2 = 0;
while (_local2 < _local4) {
_arg1.moveTo(_local6[_local2].x, _local6[_local2].y);
_arg1.lineTo(_local6[(_local2 + 1)].x, _local6[(_local2 + 1)].y);
_local2++;
};
_arg1.moveTo(_local6[_local2].x, _local6[_local2].y);
_arg1.lineStyle(1, 0);
_arg1.beginFill(0);
_local4 = _local6.length;
_local2 = 0;
while (_local2 < _local4) {
_arg1.drawCircle(_local6[_local2].x, _local6[_local2].y, pointArr[0][_local2].r);
_local2++;
};
_arg1.endFill();
_arg1.beginFill(0xFFFFFF);
_local2 = 0;
while (_local2 < _local4) {
_local5 = pointArr[0][_local2].r;
_arg1.drawCircle((_local6[_local2].x - ((_local5 * 2) / 5)), (_local6[_local2].y - ((_local5 * 2) / 5)), (_local5 / 5));
_local2++;
};
_arg1.endFill();
}
private function createSpringPoly(_arg1:Number, _arg2:Number, _arg3:uint, _arg4:Number, _arg5:Boolean=true):void{
var _local6:MovableSegmentParticle;
var _local11:MovableSegmentParticle;
var _local12:MovableSegmentParticle;
var _local13:Spring;
var _local14:MovableSegment;
var _local16:int;
if ((((_arg3 < 3)) || ((_arg3 > 4)))){
trace("not supported yet.");
return;
};
var _local7:Array = new Array();
var _local8:Number = 0;
var _local9:Number = ((Math.PI * 2) / _arg3);
var _local10:int;
while (_local10 < _arg3) {
_local6 = new MovableSegmentParticle((_arg1 + (Math.cos(_local8) * _arg4)), (_arg2 + (Math.sin(_local8) * _arg4)));
_local6.velocity.x = ((Math.random() * 2) - 1);
_local6.velocity.y = ((Math.random() * 2) - 1);
mSceneContainer.simulation.addMovable(_local6);
_local8 = (_local8 + _local9);
pointArr[1].push(_local6);
_local7.push(_local6);
_local10++;
};
var _local15:int = _arg3;
_local16 = (_local15 - 1);
_local10 = 0;
while (_local10 < _local15) {
_local11 = _local7[_local10];
_local12 = _local7[_local16];
_local13 = new Spring(_local11, _local12);
mSceneContainer.simulation.addForce(_local13);
if (_arg5){
_local14 = new MovableSegment(_local11, _local12);
} else {
_local14 = new MovableSegment(_local12, _local11);
};
mSceneContainer.simulation.addMovable(_local14);
_local16 = _local10;
_local10++;
};
if (_arg3 == 4){
_local13 = new Spring(_local7[0], _local7[2]);
mSceneContainer.simulation.addForce(_local13);
_local13 = new Spring(_local7[1], _local7[3]);
mSceneContainer.simulation.addForce(_local13);
};
}
public function updateObj():void{
var _local1:uint;
var _local2:uint;
var _local4:uint;
var _local5:Array;
var _local6:int;
var _local7:int;
var _local8:int;
var _local3:uint = pointArr.length;
_local1 = 0;
while (_local1 < _local3) {
_local4 = pointArr[_local1].length;
_local5 = pointArr[_local1];
_local2 = 0;
while (_local2 < _local4) {
_local6 = _local5[_local2].x;
_local7 = _local5[_local2].y;
drawArr[_local1][_local2] = new Vector(_local5[_local2].x, _local5[_local2].y);
_local8 = (((191 - 438) * (_local7 - 197)) + ((197 - 144) * (191 - _local6)));
if (_local6 > 500){
_local5[_local2].groupMask = 1;
} else {
if (_local8 > 0){
_local5[_local2].groupMask = 17;
} else {
if (_local8 < 0){
_local5[_local2].groupMask = 4353;
};
};
};
_local2++;
};
_local1++;
};
}
}
}//package scenes
Section 32
//Test (scenes.Test)
package scenes {
import flash.events.*;
import de.popforge.revive.member.*;
import de.popforge.revive.forces.*;
import de.popforge.revive.application.*;
import de.popforge.revive.display.*;
public class Test extends SceneContainer {
public var editPoint:FixedSpring;
public var danmenBody:DanmenBody;
public var editFlg:Boolean;
public var insertObject:InsertObject;
public var drawFlg:Boolean;
public function Test(){
drawFlg = true;
editFlg = false;
createScene();
createStageBounds();
danmenBody = new DanmenBody(this);
insertObject = new InsertObject(this);
}
override protected function onMouseUp(_arg1:MouseEvent):void{
if (mouseSpring){
simulation.removeForce(mouseSpring);
mouseSpring = null;
};
if (editPoint){
editPoint.x = mouseX;
editPoint.y = mouseY;
editPoint = null;
};
}
override protected function onMouseDown(_arg1:MouseEvent):void{
var _local2:Number;
var _local3:Number;
var _local4:uint;
var _local5:uint;
var _local6:Movable;
var _local7:FixedSpring;
if ((((editFlg == false)) && ((mouseSpring == null)))){
_local5 = insertObject.pointArr.length;
_local4 = 0;
while (_local4 < _local5) {
for each (_local6 in insertObject.pointArr[_local4]) {
if ((((_local6 is MovableParticle)) || ((_local6 is MovableCircle)))){
_local2 = (MovableParticle(_local6).x - mouseX);
_local3 = (MovableParticle(_local6).y - mouseY);
if (((_local2 * _local2) + (_local3 * _local3)) < MOUSE_CATCH_DISTANCE2){
mouseSpring = new FixedSpring(mouseX, mouseY, MovableParticle(_local6), MOUSE_CATCH_STRENGTH, 0);
simulation.addForce(mouseSpring);
break;
};
};
};
_local4++;
};
} else {
for each (_local7 in danmenBody.pointBaseArr[0]) {
_local2 = (FixedSpring(_local7).x - mouseX);
_local3 = (FixedSpring(_local7).y - mouseY);
if (((_local2 * _local2) + (_local3 * _local3)) < MOUSE_CATCH_DISTANCE2){
editPoint = _local7;
break;
};
};
};
}
private function createWall():void{
var _local1:Immovable;
var _local2:Array;
var _local3:Array;
var _local4:uint;
_local2 = new Array(300, 400, 172, 20, 20, 191, 316, 438, 438, 191, 116, 81, 116, 198, 247, 235, 319, 446, 447, 326, 298, 314, 350, 418, 420, 449, 427, 280);
_local3 = new Array(0, 85, 116, 90, 177, 197, 167, 144, 144, 208, 207, 278, 349, 360, 323, 259, 234, 207, 213, 240, 279, 333, 344, 321, 273, 279, 326, 390);
var _local5:uint = (_local2.length - 1);
_local4 = 0;
while (_local4 < _local5) {
_local1 = new ImmovablePoint(_local2[_local4], _local3[_local4]);
simulation.addImmovable(_local1);
_local1 = new ImmovableGate(_local2[_local4], _local3[_local4], _local2[(_local4 + 1)], _local3[(_local4 + 1)]);
simulation.addImmovable(_local1);
_local4++;
};
}
public function restart():void{
insertObject.restart();
}
override public function onEnterFrame(_arg1:Event):void{
var _local2:int;
var _local3:Number;
var _local4:Number;
var _local5:IDrawAble;
if (simulation == null){
return;
};
if (mouseSpring){
_local3 = (mouseSpring.movableParticle.x - mouseX);
_local4 = (mouseSpring.movableParticle.y - mouseY);
mouseSpring.x = mouseX;
mouseSpring.y = mouseY;
};
simulation.nextFrame();
simulation.nextFrame();
danmenBody.updateObj();
insertObject.updateObj();
mShape.graphics.clear();
mShapeImage.graphics.clear();
if (drawFlg){
insertObject.drawObj(mShapeImage.graphics);
danmenBody.drawObj(mShapeImage.graphics);
} else {
mShape.graphics.lineStyle(0, COLOR_IMMOVABLE);
for each (_local5 in simulation.immovables) {
_local5.draw(mShape.graphics);
};
mShape.graphics.lineStyle(0, COLOR_MOVABLE);
for each (_local5 in simulation.movables) {
_local5.draw(mShape.graphics);
};
mShape.graphics.lineStyle(0, COLOR_FORCE);
for each (_local5 in simulation.forces) {
_local5.draw(mShape.graphics);
};
};
}
private function createObj():void{
var _local1:MovableParticle;
var _local7:MovableParticle;
var _local8:MovableParticle;
var _local9:Spring;
var _local10:MovableSegment;
var _local12:int;
var _local13:int;
var _local2:Array = new Array();
var _local3:Number = 100;
var _local4:Number = 400;
var _local5:Number = 200;
var _local6:Number = 50;
_local1 = new MovableParticle(_local3, _local4);
_local1.velocity.x = ((Math.random() * 2) - 1);
_local1.velocity.y = ((Math.random() * 2) - 1);
simulation.addMovable(_local1);
_local2.push(_local1);
_local1 = new MovableParticle((_local3 + _local5), _local4);
_local1.velocity.x = ((Math.random() * 2) - 1);
_local1.velocity.y = ((Math.random() * 2) - 1);
simulation.addMovable(_local1);
_local2.push(_local1);
_local1 = new MovableParticle((_local3 + _local5), (_local4 + _local6));
_local1.velocity.x = ((Math.random() * 2) - 1);
_local1.velocity.y = ((Math.random() * 2) - 1);
simulation.addMovable(_local1);
_local2.push(_local1);
_local1 = new MovableParticle(_local3, (_local4 + _local6));
_local1.velocity.x = ((Math.random() * 2) - 1);
_local1.velocity.y = ((Math.random() * 2) - 1);
simulation.addMovable(_local1);
_local2.push(_local1);
var _local11 = 4;
_local13 = (_local11 - 1);
_local12 = 0;
while (_local12 < _local11) {
_local7 = _local2[_local12];
_local8 = _local2[_local13];
_local9 = new Spring(_local7, _local8);
simulation.addForce(_local9);
_local10 = new MovableSegment(_local7, _local8);
simulation.addMovable(_local10);
_local13 = _local12;
_local12++;
};
_local9 = new Spring(_local2[0], _local2[2]);
simulation.addForce(_local9);
_local9 = new Spring(_local2[1], _local2[3]);
simulation.addForce(_local9);
}
override protected function createStageBounds():void{
var _local1:ImmovableGate;
var _local2:uint = (WIDTH + 400);
var _local3:uint = (HEIGHT - 150);
_local1 = new ImmovableGate(_local2, 0, 0, 0);
simulation.addImmovable(_local1);
_local1 = new ImmovableGate(0, _local3, _local2, _local3);
simulation.addImmovable(_local1);
_local1 = new ImmovableGate(0, 0, 0, _local3);
simulation.addImmovable(_local1);
_local1 = new ImmovableGate(_local2, _local3, _local2, 0);
simulation.addImmovable(_local1);
}
public function createScene():void{
var _local1:Immovable;
createWall();
}
}
}//package scenes
Section 33
//LabelButton (LabelButton)
package {
import flash.display.*;
import de.popforge.revive.application.*;
import flash.text.*;
public class LabelButton extends Sprite {
public var label:TextField;
public var scene:SceneContainer;
public function LabelButton(_arg1:String){
var _local2:TextFormat;
label = new TextField();
super();
_local2 = new TextFormat();
_local2.font = "_����";
_local2.size = 10;
_local2.color = 0;
label.setTextFormat(_local2);
label.text = _arg1;
label.autoSize = TextFieldAutoSize.CENTER;
label.border = true;
label.background = true;
label.backgroundColor = 0xDDDDDD;
label.selectable = false;
label.mouseEnabled = false;
addChild(label);
buttonMode = true;
}
}
}//package
Section 34
//Main (Main)
package {
import flash.events.*;
import flash.display.*;
import de.popforge.revive.member.*;
import de.popforge.revive.resolve.*;
import de.popforge.revive.geom.*;
import de.popforge.revive.forces.*;
import de.popforge.revive.application.*;
import scenes.*;
import flash.text.*;
import de.popforge.revive.display.*;
import de.popforge.surface.display.*;
import flash.utils.*;
import flash.system.*;
public class Main extends Sprite {
private var img0020:Bitmap;
private var img0000:Bitmap;
private var scene:Test;
private var btn1:LabelButton;
private var btn2:LabelButton;
private var btn3:LabelButton;
private var pointText:TextField;
private var btn4:LabelButton;
private var img0030:Bitmap;
private var img0010:Bitmap;
private var baseSprite:Sprite;
private static const Image0030:Class = Main_Image0030;
private static const Image0020:Class = Main_Image0020;
private static const Image0010:Class = Main_Image0010;
private static const Image0000:Class = Main_Image0000;
public function Main(){
initAll();
}
protected function onMouseDown(_arg1:MouseEvent):void{
pointText.appendText((((mouseX + ", ") + mouseY) + "\n"));
}
private function onDragChange(_arg1:Event):void{
scene.simulation.globalDrag = _arg1.target.getValue();
}
private function chg_btn3Mouse_upEventHandler(_arg1:MouseEvent):void{
var _local2:FixedSpring;
var _local3:uint;
var _local4 = "dataX = new Array(";
var _local5 = "dataY = new Array(";
for each (_local2 in scene.danmenBody.pointBaseArr[0]) {
_local4 = (_local4 + (FixedSpring(_local2).x + ", "));
_local5 = (_local5 + (FixedSpring(_local2).y + ", "));
_local3++;
};
pointText.text = _local4.slice(0, (_local4.length - 2));
pointText.appendText(" );");
pointText.appendText(" \n");
pointText.appendText(_local5.slice(0, (_local5.length - 2)));
pointText.appendText(" );");
pointText.appendText(" \n");
System.setClipboard(pointText.text);
}
private function onFpsChange(_arg1:Event):void{
stage.frameRate = _arg1.target.getValue();
}
private function createChangeButton():void{
btn4 = new LabelButton("RESTART");
btn4.x = 600;
btn4.y = 20;
this.addChild(btn4);
btn4.addEventListener(MouseEvent.MOUSE_UP, chg_btn4Mouse_upEventHandler);
}
private function chg_btn4Mouse_upEventHandler(_arg1:MouseEvent):void{
scene.restart();
}
private function chg_btn1Mouse_upEventHandler(_arg1:MouseEvent):void{
if (scene.drawFlg){
scene.drawFlg = false;
btn1.label.text = "NOWVIEW_MODEL";
img0010.visible = false;
} else {
scene.drawFlg = true;
btn1.label.text = "NOWVIEW_DRAW";
img0010.visible = true;
};
}
private function chg_btn2Mouse_upEventHandler(_arg1:MouseEvent):void{
if (scene.editFlg){
scene.editFlg = false;
btn2.label.text = "NOWMODE_MOVE";
} else {
scene.editFlg = true;
btn2.label.text = "NOWMODE_EDIT";
};
}
private function initAll():void{
stage.scaleMode = StageScaleMode.NO_SCALE;
addChild(new FPSCounter());
baseSprite = new Sprite();
addChild(baseSprite);
img0020 = (new Image0020() as Bitmap);
baseSprite.addChild(img0020);
scene = new Test();
scene.simulation.globalForce.y = 0.5;
scene.drawFlg = true;
baseSprite.addChild(scene);
img0010 = (new Image0010() as Bitmap);
baseSprite.addChild(img0010);
createChangeButton();
}
private function onGravityChange(_arg1:Event):void{
scene.simulation.globalForce.y = _arg1.target.getValue();
}
}
}//package
Section 35
//Main_Image0000 (Main_Image0000)
package {
import mx.core.*;
public class Main_Image0000 extends BitmapAsset {
}
}//package
Section 36
//Main_Image0010 (Main_Image0010)
package {
import mx.core.*;
public class Main_Image0010 extends BitmapAsset {
}
}//package
Section 37
//Main_Image0020 (Main_Image0020)
package {
import mx.core.*;
public class Main_Image0020 extends BitmapAsset {
}
}//package
Section 38
//Main_Image0030 (Main_Image0030)
package {
import mx.core.*;
public class Main_Image0030 extends BitmapAsset {
}
}//package