Flash actionscript 3.0

pre Loader in AS 3 .0

0

Posted by Sankar.G | Posted in | Posted on 4:26 PM

var percentage:Number=0;
stage.addEventListener(Event.ENTER_FRAME,BeeMoving);
function BeeMoving(event:Event):void
{
var nLoadedBytes:Number = loaderInfo.bytesLoaded;
var nTotalBytes:Number = loaderInfo.bytesTotal;
percentage= Math.round(nLoadedBytes / nTotalBytes * 100);
BitsLoaded.text = nLoadedBytes+"kbs /"+nTotalBytes+"kbs";
if (nLoadedBytes==nTotalBytes) {
stage.removeEventListener(Event.ENTER_FRAME,BeeMoving);
gotoAndStop(2);
}
}

How to put 'U'shape Curve in AS 3.0

0

Posted by Sankar.G | Posted in | Posted on 5:28 PM

var angle:Number=0.05;
var radian:Number=0;
b1_btn.addEventListener(MouseEvent.CLICK,fun);
function fun(event:MouseEvent):void
{
ball_mc.y=351.9;
ball_mc.x=250;
addEventListener(Event.ENTER_FRAME,one);
function one(event:Event):void
{
angle+=0.05;
radian=Math.sin(angle)*3;
ball_mc.y=(351.9)-radian*180/Math.PI;
ball_mc.x+=2;
if(ball_mc.y>352.9)
{
removeEventListener(Event.ENTER_FRAME,one);
}
}
}

Create 2 MovieClip and Name it as b1_btn & ball_mc
and put this script and click the b1_btn button

Multiple KeyBoard Event in AS 3.0

2

Posted by Sankar.G | Posted in | Posted on 5:13 PM

var isKeyOne:Boolean = false;
var isKeyTwo:Boolean = false

stage.addEventListener(Event.ENTER_FRAME, checkTrue);

function checkTrue(event:Event):void
{
if(isKeyOne)
{
test.x--;
}
if(isKeyTwo)
{
test.y--;
}
}

stage.addEventListener(KeyboardEvent.KEY_DOWN, makeTrue);
stage.addEventListener(KeyboardEvent.KEY_UP, makeFalse);

function makeTrue(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.LEFT)
{
isKeyOne = true;
}
if(event.keyCode == Keyboard.UP)
{
isKeyTwo = true;
}
}

function makeFalse(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.LEFT)
{
isKeyOne = false;
}
if(event.keyCode == Keyboard.UP)
{
isKeyTwo = false;
}
}
Create one MovieClip and Name it as test and Put this Script for Multiple Keyboard Handling

How to do the start Drag the APE Objects Dynamically

0

Posted by Sankar.G | Posted in | 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

How to create rectangles & circles use APE & bounce effects

0

Posted by Sankar.G | Posted in | Posted on 4:31 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;
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 rp:RectangleParticle = new RectangleParticle(250,300,200,10,0.52,true);
defaultGroup.addParticle(rp);
rp.setFill(0x666666);
rp.setLine(0, 0xff0000, 1);

var rp1:RectangleParticle=new RectangleParticle(490,300,200,10,-0.52,true);
defaultGroup.addParticle(rp1);
rp1.setFill(0xff0000);
rp1.setLine(0,0x666666,1);

var rp2:RectangleParticle=new RectangleParticle(430,450,200,10,0,true);
defaultGroup.addParticle(rp2);
rp2.setFill(0xff0000);
rp2.setLine(0,0x666666,1);

wp = new WheelParticle(280,10,25,false,10,0.3,0.1,1);
defaultGroup.addParticle(wp);
wp.setFill(0xff0000);
wp.setLine(0,0xff0000,0);

wp.sprite.addEventListener(MouseEvent.MOUSE_DOWN,down);

wp.sprite.addEventListener(MouseEvent.MOUSE_UP,up);

APEngine.addGroup(defaultGroup);

function down(d1:Event):void
{
removeEventListener(Event.ENTER_FRAME,run);
wp.sprite.startDrag();
}
function up(d2:Event):void
{
wp.px=wp.sprite.x;
wp.py=wp.sprite.y;
stopDrag();
addEventListener(Event.ENTER_FRAME, run);
}
function run(evt:Event):void
{
APEngine.step();
APEngine.paint();
}

}


}
}

Examples:

APE with out Drag.swf