Posted by Sankar.G | Posted in APE Engine | Posted on 6:44 PM
package
{
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Sprite;
import org.cove.ape.*;
public class Test extends Sprite
{
private var wp:WheelParticle;
private var array:Array=new Array("");
private var i:Number;
public function Test():void
{
stage.frameRate = 20;
addEventListener(Event.ENTER_FRAME, run);
APEngine.init(2/4);
APEngine.container = this;
var defaultGroup:Group = new Group();
defaultGroup.collideInternal = true;
APEngine.addMasslessForce(new Vector(0,2));
var rp1:RectangleParticle=new RectangleParticle(490,300,200,10,-0.52,true);
defaultGroup.addParticle(rp1);
rp1.setFill(0xff0000);
rp1.setLine(0,0x666666,1);
rp1.sprite.name="rp1";
array.push(rp1);
var rp2:RectangleParticle=new RectangleParticle(430,450,200,10,0,true);
defaultGroup.addParticle(rp2);
rp2.setFill(0xff0000);
rp2.setLine(0,0x666666,1);
rp2.sprite.name="rp2";
array.push(rp2);
var rp3:RectangleParticle = new RectangleParticle(250,300,200,10,0.52,true);
defaultGroup.addParticle(rp3);
rp3.setFill(0x666666);
rp3.setLine(0, 0xff0000, 1);
rp3.sprite.name="rp3";
array.push(rp3);
for(i=1;i< 4;i++) { array[i].sprite.addEventListener(MouseEvent.MOUSE_DOWN,one); array[i].sprite.addEventListener(MouseEvent.MOUSE_UP,two); } function one(e1:MouseEvent):void { removeEventListener(Event.ENTER_FRAME,run); e1.target.startDrag(); } function two(e2:MouseEvent):void { array[e2.target.name.substr(2)].px=mouseX; array[e2.target.name.substr(2)].py=mouseY; stopDrag(); addEventListener(Event.ENTER_FRAME, run); } function run(evt:Event):void { APEngine.step(); APEngine.paint(); } } } } Example: APE with Dragable.swf
{
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Sprite;
import org.cove.ape.*;
public class Test extends Sprite
{
private var wp:WheelParticle;
private var array:Array=new Array("");
private var i:Number;
public function Test():void
{
stage.frameRate = 20;
addEventListener(Event.ENTER_FRAME, run);
APEngine.init(2/4);
APEngine.container = this;
var defaultGroup:Group = new Group();
defaultGroup.collideInternal = true;
APEngine.addMasslessForce(new Vector(0,2));
var rp1:RectangleParticle=new RectangleParticle(490,300,200,10,-0.52,true);
defaultGroup.addParticle(rp1);
rp1.setFill(0xff0000);
rp1.setLine(0,0x666666,1);
rp1.sprite.name="rp1";
array.push(rp1);
var rp2:RectangleParticle=new RectangleParticle(430,450,200,10,0,true);
defaultGroup.addParticle(rp2);
rp2.setFill(0xff0000);
rp2.setLine(0,0x666666,1);
rp2.sprite.name="rp2";
array.push(rp2);
var rp3:RectangleParticle = new RectangleParticle(250,300,200,10,0.52,true);
defaultGroup.addParticle(rp3);
rp3.setFill(0x666666);
rp3.setLine(0, 0xff0000, 1);
rp3.sprite.name="rp3";
array.push(rp3);
for(i=1;i< 4;i++) { array[i].sprite.addEventListener(MouseEvent.MOUSE_DOWN,one); array[i].sprite.addEventListener(MouseEvent.MOUSE_UP,two); } function one(e1:MouseEvent):void { removeEventListener(Event.ENTER_FRAME,run); e1.target.startDrag(); } function two(e2:MouseEvent):void { array[e2.target.name.substr(2)].px=mouseX; array[e2.target.name.substr(2)].py=mouseY; stopDrag(); addEventListener(Event.ENTER_FRAME, run); } function run(evt:Event):void { APEngine.step(); APEngine.paint(); } } } } Example: APE with Dragable.swf
Comments (0)
Post a Comment