To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Actionscript 3.0

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 11-03-2009, 02:52 PM   #1
jamrobot
Member
 
Join Date: Mar 2009
Posts: 43
Unhappy How to apply gravity to an array of sprites?

How??
Code:
var spring:Number=.1;
var frizione:Number=.98;
var gravita:int=1;
var limite:Number=stage.stageHeight;

stage.frameRate=31;



var colorsArray:Array = new Array();
colorsArray=['0xFF0000','0xFFFF00','0x65FF00','0x0000FF','0xCC00FF'];
var cwidth:Number = 360;
var cirArray:Array = new Array();
for (var i:int = 0; i < 30; i++)
{
var num = Math.floor(Math.random() * 5)
var cir:Sprite = new Sprite();
cir.graphics.lineStyle(1);
cir.graphics.beginFill(colorsArray[num]);
cir.graphics.drawCircle(0,50,cwidth);
cir.x = Math.random() * 500 - 1500
cir.y = Math.random() * 300
cir.alpha =.5
addChildAt(cir, i)
cir.name="cir"+i
cirArray[i] = this.getChildByName("cir"+i)
}; 

function motion(event:Event):void
{
for (var i:int = 0; i < 30; i++)
{
if (cirArray[i].x > 520)
{
cirArray[i].x = 00
cirArray[i].y = Math.random()* 300
} else
cirArray[i].x +=25
}
}; 

start_btn.addEventListener(MouseEvent.CLICK, startMotion);
function startMotion(event:MouseEvent):void{
stage.addEventListener(Event.ENTER_FRAME, motion);
stop_btn.visible = true
start_btn.visible = false
};

stop_btn.addEventListener(MouseEvent.CLICK, stopMotion);
function stopMotion(event:MouseEvent):void{
stage.removeEventListener(Event.ENTER_FRAME, motion);
stop_btn.visible = false
start_btn.visible = true
};
jamrobot is offline   Reply With Quote
Old 11-03-2009, 03:11 PM   #2
jAQUAN
it's automatic
 
jAQUAN's Avatar
 
Join Date: Jul 2000
Location: NaN
Posts: 2,000
http://www.bit-101.com/tutorials/gravity.html
__________________
I approve this message.
AS3SOURCE: @ @ @ @
SD | fk css | Believe the HYPE | I tweet.
jAQUAN is offline   Reply With Quote
Old 11-03-2009, 03:14 PM   #3
AttackRabbit
rabid_Delineator
 
AttackRabbit's Avatar
 
Join Date: Dec 2003
Location: Orlando, Florida
Posts: 307
http://www.amazon.com/Foundation-Act...7275607&sr=8-1

one of the best books i have ever purchased.
AttackRabbit is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Actionscript 3.0

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:14 AM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.