00:00
00:00
Newgrounds Background Image Theme

OrangeWedge just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Actionscript codes here!

426,558 Views | 7,948 Replies
New Topic

Response to Actionscript codes here! 2006-12-16 23:49:06


this might sound pathetic but can some one tell me how to make a mouse game?

Response to Actionscript codes here! 2006-12-17 00:20:37


At 12/16/06 11:49 PM, dumbbannaman wrote: this might sound pathetic but can some one tell me how to make a mouse game?

Not pathetic. Everybody hast to start somewhere
. I made a first person shooter, but I missed out on learning hitTests.

I think this might be what your looking for, just make sure you examin the script and try to learn it:
Mouse Maze Tutorial

Response to Actionscript codes here! 2006-12-17 00:33:46


Everything was good. But when it came to rounding I had no clue. So... whats a script for rounding to the nearest tenth, one, ten, hundred, thousand, etc? I know it involves the Math.round code but I'm stuck from there.

add Math.round. It cuts off all the decimal places.
:handy! :P
just thought id post, again.


BBS Signature

Response to Actionscript codes here! 2006-12-17 00:45:36


Here is a basic code for moving with invisable walls to keep the mc from going of the stage/screen:

onClipEvent(enterFrame){
if(Key.isDown(Key.LEFT)){
_x=_x-10;
_xscale=-100;
gotoAndStop(2);}

if(Key.isDown(Key.RIGHT)){
_x=_x+10;
_xscale=100;
gotoAndStop(2);}

if(Key.isDown(Key.DOWN)){
_y=_y+10;}

if(Key.isDown(Key.UP)){
_y=_y-10;
gotoAndStop(3);}

if(this._y<=5){
this._y=10}
if(this._y>=Stage.height){
this._y=(Stage.height-20);}

if(this._x<=5){
this._x=10}
if(this._x>=Stage.width){
this._x=(Stage.width-20);}}

Notes:
On the left side and top of the stage the mc will stop normally. On the right side and bottom the mc will bounce back a bit from the walls. BY: RMC


BBS Signature

Response to Actionscript codes here! 2006-12-17 10:28:25


At 12/16/06 05:09 PM, Zeek664 wrote: your asking alot there.... I could try to help you with the collistion detection and the movement.
I just need to know if its an over head game or an side scroller. which is it?

side scroller please.
thank you


BBS Signature

Response to Actionscript codes here! 2006-12-17 12:34:21


I want an actionscript where you click somewhere at the frame and a movieclip moves to the spot. I also wonder how you make an area that the mc can't go outside. Can someone help me please?

Response to Actionscript codes here! 2006-12-17 13:11:47


lol, not simple. walls I can do, but the move to the selected spot thing...... thats what I cant help you with.

wall code:

onClipEvent (enterFrame) {
if (this.hitTest(_root.wall)){
//y or x code here with speed variable
}
}

Put that script in the thing you are controlling.
thats as far as I go for you.

Response to Actionscript codes here! 2006-12-17 13:40:27


I'm looking for script to make a ragdoll physics game, can anyone help?

Response to Actionscript codes here! 2006-12-17 13:52:30


At 12/17/06 10:28 AM, ifsey wrote: side scroller please.
thank you

Put this code in your jet:

onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_y -= 8;
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.DOWN)) {
_y += 8;
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_x -= 8;
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_x += 8;
}
}
onClipEvent (enterFrame) {
if (this.hitTest(_root.bullet)) {
_parent.gotoAndPlay("death");
//lable your lose screen "death"
//but without qoutes
}
}

I made an example for you: Example
intrustions: use arrow keys to move around.
if you hit the big red ball you die.

Response to Actionscript codes here! 2006-12-17 13:55:25


At 12/17/06 01:40 PM, Shotgun-Productions wrote: I'm looking for script to make a ragdoll physics game, can anyone help?

Waaaaaaay to advanced for me. seriously, If your a n00b and are looking for something bigger to tackle, try a first person shooter. pop up targets or whatever, because I dont know ragdoll physics.

Response to Actionscript codes here! 2006-12-17 14:34:01


At 12/17/06 01:52 PM, Zeek664 wrote:
At 12/17/06 10:28 AM, ifsey wrote: side scroller please.
thank you
Put this code in your jet:

many problems, when i enter code there is 5 problems. help.


BBS Signature

Response to Actionscript codes here! 2006-12-17 15:14:59


At 12/17/06 02:34 PM, ifsey wrote: many problems, when i enter code there is 5 problems. help.

well what are they?

Response to Actionscript codes here! 2006-12-18 02:49:08


At 12/17/06 03:14 PM, Zeek664 wrote:
At 12/17/06 02:34 PM, ifsey wrote: many problems, when i enter code there is 5 problems. help.
well what are they?

sorry, i solved them. i didnt copy all of it.

does anyone know how to make things shoot out of other things, like a missle from a jet fighter?


BBS Signature

Response to Actionscript codes here! 2006-12-18 06:48:06


Oh, that's okay.
I'll try less advanced stuff.
Speaking of which, how do you make the screen move to the left or right in a platformer?

Response to Actionscript codes here! 2006-12-18 07:54:43


Hy, I've figured out how to do a walking animation when you press a button. It's

onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop(2);
} else if (!Key.isDown(Key.RIGHT)) {
this.gotoAndStop(1);
}
}
But how do you make it move in that direction?
I still want to know how to move the screen.

Response to Actionscript codes here! 2006-12-18 12:50:55


THE ULTIMATE MOVEMENT SCRIPT:

onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
speed = 8;
}
if (Math.abs(speed)>20) {
speed *= .35;
}
if (Key.isDown(Key.LEFT)) {
_rotation -= 6;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 6;
}
if (Key.isDown(Key.DOWN)) {
speed = -7;
}
speed *= .4;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-.7;
if (!_root.land.hitTest(_x+x, _y+y, false)) {
_x += x;
_y += y;
} else {
speed *= -.001;
}
}
onClipEvent (enterFrame) {
if (_root.Block.hitTest(_x, _y, true)) {
//_x -= speed*1;
//_y -= speed*1;
_x -= Math.sin(_rotation*(Math.PI/180))*speed;
_y -= Math.cos(_rotation*(Math.PI/180))*speed*-.7;
//speed = -1;
}
}

--------------------------------------------- -----STOP COPYING BEFORE HERE---------------------------------

Everything you want to be a wall should be in one symbol, witch should be instance named Block

Response to Actionscript codes here! 2006-12-18 14:43:43


What did that have to do with anything?

Response to Actionscript codes here! 2006-12-18 14:57:44


Whoever was working on that jumping engine on the last page, i just wanted you to know there is a easier way to do it. Instead of making a bunch of symbols for the ground (ground1, ground2, etc.) just draw your ground, name it "ground" and put this script into your player.::

OnClipEvent(load){
xs=0
jump=0
grav=0
w=_width/2
h=_height/2
}onClipEvent(enterFrame){
grav++
_x+=xs
_y-=jump
_y+=grav
jump*=.85
xs*=.8
if(_root.ground.hitTest(_x, _y+h, true)){
_y-=.01
grav=0
if(Key.isDown(Key.SPACE)){
jump=10 //change this to make him jump higher
}
}if(Key.isDown(Key.RIGHT)){
xs++
}if(Key.isDown(Key.LEFT)){
xs--
}if(_root.ground.hitTest(_x+w, _y,true) || _root.ground.hitTest(_x-w,_y,true)){
_x-=xs
}
}

Response to Actionscript codes here! 2006-12-18 14:59:42


Sorry for double posting, but change the first letter, O, to a lowercase o. and check for other errors. i haven't tested that code.

Response to Actionscript codes here! 2006-12-18 15:53:50


I can't beleive I got another two pages outta this just by asking for code and saying resurrect a lot

Response to Actionscript codes here! 2006-12-18 21:11:09


At 12/18/06 03:53 PM, Hawkfire wrote: I can't beleive I got another two pages outta this just by asking for code and saying resurrect a lot

neWOOB
:win!

Response to Actionscript codes here! 2006-12-18 21:12:44


Sorry for double post,

NG really needs an edit button!

But umm how do you like make a camera move in a bird's eye view adventure game? Please help me!

Response to Actionscript codes here! 2006-12-19 15:15:55


Cheers westendpro.

Response to Actionscript codes here! 2006-12-19 17:37:34


How do you make a button direct to a different frame (example: clicking a help button and it takes you too a frame with the contents of 'help' on it)?

Response to Actionscript codes here! 2006-12-19 20:06:13


At 12/19/06 05:37 PM, SavvaS wrote: How do you make a button direct to a different frame (example: clicking a help button and it takes you too a frame with the contents of 'help' on it)?

put this in your button:

on (release){
gotoAndStop("help");
}

Response to Actionscript codes here! 2006-12-19 20:35:33


Hi, I'm trying to make a game. I got the main mechanics figured out, but here's my problem.

I have 2 movie clips. the first is a solid ball. The second is an open circle.I want to make it so when you control the open circle, the filled circle inside it reacts with gravity. Like a hamster in a ball.

Here's the code for the ball inside:

onClipEvent (load) {
ySpeed = 0;
// starting fall speed of object
gravity = 3;
// how fast the ySpeed rises, should be no higher then 3
bounce = .8;
// how much the speed decreases when for each bounce
ground = 350;
// where to bounce back
}
onClipEvent (enterFrame) {
if (_y<ground) {
ySpeed += gravity;
} else if (ySpeed>gravity*4) {
// change 4 to a higher number if it doesnt work
_y = ground;
ySpeed *= -bounce;
} else {
ySpeed = 0;
_y = ground;
}
_y += ySpeed;
}

Now this actully works, but it thinks the bottom of the browser is the ground. The rims of the circle is what I want it to stop at.I gave the circle the instance name "ground".

Can anyone help me?

Response to Actionscript codes here! 2006-12-19 21:44:10


Aww doenst work for some reason...

At 12/19/06 03:04 AM, West-End-Pro wrote: use the V-CAM and put:

onClipEvent(enterFrame){
this._x = player._x;
this._y = player._y;
}

Response to Actionscript codes here! 2006-12-19 23:37:35


I have a question.. This is the code I have so far and it figures out the tip of an entered amount based on three different percentages.. (You choose from 3 check boxes). How would I add into this another set of 3 check boxes that subtract from the tip depending on the quality of the service..

Code so far..

function formatCurrency(value:Number):String
{
var cents:Number = Math.round(value*100);
var result:String = "$" + Math.floor(cents/100) + ".";
cents %= 100;
if (cents < 10) {
result += "0";
}
result += String(cents);
return result;
}

function calculate():Void
{
var percent:Number = Number(radioGroup.selection.data);

var tip:Number = Number(subtotal_ti.text) * percent;
if (isNaN(tip)) {
gratuity_ti.text = "";
} else {
gratuity_ti.text = formatCurrency(tip);
}
}

var gratuity_ti:mx.controls.TextInput;
var subtotal_ti:mx.controls.TextInput;

gratuity_ti.editable = false;

Response to Actionscript codes here! 2006-12-20 02:16:17


At 12/19/06 09:44 PM, Axlenz wrote: Aww doenst work for some reason...

At 12/19/06 03:04 AM, West-End-Pro wrote: use the V-CAM and put:

onClipEvent(enterFrame){
this._x = _root. player._x;
this._y = _root.player._y;
}

fixed! (he forgot to put the root command b4 the instance name, which you need btw.)

Response to Actionscript codes here! 2006-12-20 02:27:18


im interested in making a better dress up game that has alot more items, etc but am limited by the fact that with just making things dragable you still need to make everything fit. Would anybody know how maybe I could make a menu that drops down and you could drag items out of that? or perhaps make the items really small and u click them to make em big and then u drag them? any help would be greatly appreciated.


The preceding statement was bullshit.

Playstation Network: CkGordon

Battlefield: Bad Company 2 March 2nd, 2010

BBS Signature