00:00
00:00

Hey! To start this decade right, we believe Newgrounds should be ad-free for EVERYONE. For this to work, we need people who have the means to become paying supporters. For just \$3 per month or \$25 for the year, you can help this happen and get some nice perks!

For the month of January we have disabled ads on all E-M content. We need 184 people to reach our January goal of 3,000 active supporters. If we hit that, we'll continue with a new goal in February!

## AS: Physics Ball

1,577 Views | 13 Replies

AS: Physics Ball 2011-07-28 17:11:11

Instructions:

First of all, create a Circle using the Oval Tool. (Add whatever color or texture you want). Then right click the Circle and find on the pop-up menu "Convert To Symbol...". Press it then a menu should appear, make sure Movie Clip is filled in, name your Movie Clip "Physics Ball_mc". Now make sure that the ball isn't the world's smallest object, (what I'm trying to say is don't make it too small or big). Select the ball and enter in this Action Script. NOTE: Also change the Frame rate to 120 FPS to get the best speed for the ball. For the action script just copy and paste from here to the ball.

Action Script:

var acceleration = 0.005;
var termVelocity = 20;
var yVel = 0;
var xVel = 0;
var e = 0.8;
var f = 0.8;
var dragged = 0;
}
onClipEvent (enterFrame) {
if (this._y<380) {
if (dragged == 0) {
yVel += (termVelocity-yVel)*acceleration;
}
} else if (this._y>380) {
yVel *= -1*e;
xVel *= f;
this._y = 380;
}
if (this._x>530) {
xVel *= -1*e;
yVel *= f;
this._x = 530;
} else if (this._x<20) {
xVel *= -1*e;
yVel *= f;
this._x = 20;
}
if (dragged == 0) {
this._y += yVel;
this._x += xVel;
}
}
on (press) {
this.startDrag(false);
dragged = 1;
velocity = 0;
xVel = 0;
}
on (release, releaseOutside) {
this.stopDrag();
dragged = 0;
}

Hope this helped!

Enjoy!

LOL! ^_^

Response to AS: Physics Ball 2011-07-28 17:22:31

I do believe you're supposed to explain how and why this works. Copy/pasting code doesn't really help people to learn AS.

Response to AS: Physics Ball 2011-07-28 17:27:34

fail.

Response to AS: Physics Ball 2011-07-28 17:55:05

You forgot to type:
"Codes by lozman2k3k, from 2D Physics Tutorial"

Response to AS: Physics Ball 2011-07-28 18:23:34

o yeah sry

And codes from Codes by lozman2k3k, from 2D Physics Tutorial

LOL! ^_^

Response to AS: Physics Ball 2011-07-29 02:07:29

Sorry, but may I ask what version of AS3 this is? I don't like bringing people down, but I doubt it will to you, but it seems like it's AS1. Not many people here, including me, use AS1 anymore. It is absolutely nonstandard. I use AS3 and SOMETIMES AS2, and overall AS3 is the most standard version that I've programmed with. Like how you share source that you find interesting, but not really helpful to the modern programmers. I'm not trying to be mean, but just saying.

A great site to make you laugh: Parodies

Response to AS: Physics Ball 2011-07-29 02:24:15

At 7/29/11 02:07 AM, Darnose wrote: Sorry, but may I ask what version of AS3 this is? I don't like bringing people down, but I doubt it will to you, but it seems like it's AS1. Not many people here, including me, use AS1 anymore. It is absolutely nonstandard. I use AS3 and SOMETIMES AS2, and overall AS3 is the most standard version that I've programmed with. Like how you share source that you find interesting, but not really helpful to the modern programmers. I'm not trying to be mean, but just saying.

I think you mean 'What version of AS is this.' XD
It is AS1 and I mean, seriously, who copies code and pastes here. That's just rude.

Stage3D is awesome.

Response to AS: Physics Ball 2011-07-29 02:41:50

At 7/29/11 02:24 AM, HAROfficial wrote: I think you mean 'What version of AS is this.' XD
It is AS1 and I mean, seriously, who copies code and pastes here. That's just rude.

I know I did a type :)

Also, agree with what you said.

A great site to make you laugh: Parodies

Response to AS: Physics Ball 2011-08-01 21:38:21

It's AS2, I use on flash 8...

LOL! ^_^

Response to AS: Physics Ball 2011-08-01 22:20:29

At 8/1/11 09:38 PM, loopchocolateman1234 wrote: It's AS2, I use on flash 8...

You're allowed to write AS1 code in AS2, what you have there is AS1.

If ya have something to say, PM me. I have a lot of time to spare.

Also never PM egg82.

Response to AS: Physics Ball 2011-08-03 12:28:56

LOL! ^_^

Response to AS: Physics Ball 2011-08-03 18:33:32

I like the part where you think you're being clever and giving people unhelpful code to learn from :)

Response to AS: Physics Ball 2011-08-03 18:48:44

It's not really related to this, but didn't want to make a new post.

Been looking round the internet for advanced physics tutorials, like the collisions and physics in angry birds. Any of you know where I can find some learning material?

Want to increase knowledge in programming. If you need someone to program something, I will be happy to help for free :) .

Response to AS: Physics Ball 2011-08-03 19:43:25

At 8/3/11 06:48 PM, 1Kingfire1 wrote: It's not really related to this, but didn't want to make a new post.

Been looking round the internet for advanced physics tutorials, like the collisions and physics in angry birds. Any of you know where I can find some learning material?

Well what you're probably looking for is a full blown physics engine. Look up box2d. If you're not already experienced in as3 then forget it.

If ya have something to say, PM me. I have a lot of time to spare.

Also never PM egg82.