Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: Actionscript codes here!

(196,713 views • 8,513 replies)

This topic is 284 pages long. [ 199197 | 198 | 199 | 200 | 201242284 ]

<< < > >>
None

NuiStyles

Reply To Post Reply & Quote

Posted at: 12/27/04 04:59 PM

NuiStyles LIGHT LEVEL 03

Sign-Up: 07/10/04

Posts: 367

hey im making a energy bar for my game
example
bar(100% full) when i click a button the bar gos down to (80%full) and when a click a difrent button thebar gos back to (100%) full


None

LastNameLeftOver

Reply To Post Reply & Quote

Posted at: 12/27/04 06:59 PM

LastNameLeftOver NEUTRAL LEVEL 04

Sign-Up: 09/01/03

Posts: 52

Anyone know how to, through actionscript make a blinking cursor. Like the cursor that you type with. I am wanting to make a green one.


None

Cactusjuice

Reply To Post Reply & Quote

Posted at: 12/27/04 07:10 PM

Cactusjuice EVIL LEVEL 16

Sign-Up: 07/04/03

Posts: 1,758

At 12/27/04 04:59 PM, NuiStyles wrote: hey im making a energy bar for my game
example
bar(100% full) when i click a button the bar gos down to (80%full) and when a click a difrent button thebar gos back to (100%) full

put this on your frame where you want the health to be:
health=100;

then on the button that should take the health down to 80 have:
on(release) {
_root.health=80;
}

and then the other button that puts it back up:
on(release) {
_root.health=100;
}

now make a dynamic txt box with the variable name "health", you could even have a mc representing health that goes to a certain frame when the you press the button e.g.:
on(release) {
_root.movieclip.gotoandstop(2);
}


None

ZYX3D

Reply To Post Reply & Quote

Posted at: 12/27/04 07:10 PM

ZYX3D DARK LEVEL 21

Sign-Up: 07/31/04

Posts: 437

At 12/27/04 04:59 PM, NuiStyles wrote: hey im making a energy bar for my game
example
bar(100% full) when i click a button the bar gos down to (80%full) and when a click a difrent button thebar gos back to (100%) full

on (release){_root.healthbar._xscale=80;}

Or 100 instead of 80 for full. Change the instance name accordingly. Change the value accordingly. Change the route accordingly. If you don't know what is a route or instance name, make the Flash tutorials that come with Flash and/or use the magical, all-answering F1 key. Make the Flash tutorials anyway. Learn to use variables and change health bars according to variables. Learn to search the BBS. Don't be lazy to do so, never. Always ask for methods and techniques, not for concrete solutions that will be useful just in an instance, and then we'll have you again asking "now I want the bar to be at 70%, how do I that? Yay, you answered for 80%, but now I want it at 70%". It has happened before, and I don't want this to happen to you. Neither do you.

Thanks :)


None

ZYX3D

Reply To Post Reply & Quote

Posted at: 12/27/04 07:17 PM

ZYX3D DARK LEVEL 21

Sign-Up: 07/31/04

Posts: 437

At 12/27/04 06:59 PM, LastNameLeftOver wrote: Anyone know how to, through actionscript make a blinking cursor. Like the cursor that you type with. I am wanting to make a green one.

Then you'll need to use a green square movieclip, for instance. Maybe a green circle. A green something movieclip, anyways.

In its onClipEvent(enterFrame) handler, put:

this._visible=!this.visible;

so if you don't have anything else to do to it, the complete code would be:

onClipEvent(enterFrame){this._visible= !this._visible;}

This works with red cursors also. And any color that has more than a 0% alpha (opacity).


Questioning

Belong100

Reply To Post Reply & Quote

Posted at: 12/28/04 06:05 PM

Belong100 EVIL LEVEL 03

Sign-Up: 07/26/04

Posts: 51

Hey can any guys tell me the code for an ammo count like every time the mouse clicks the ammo goes down? and tell me where to put it...it would be REALLY APRECIATED :) thanx


None

Simon4145

Reply To Post Reply & Quote

Posted at: 12/29/04 01:59 PM

Simon4145 EVIL LEVEL 06

Sign-Up: 12/23/04

Posts: 118

is there any way to make random stuff fall down fall down at random spots


None

Cactusjuice

Reply To Post Reply & Quote

Posted at: 12/29/04 03:15 PM

Cactusjuice EVIL LEVEL 16

Sign-Up: 07/04/03

Posts: 1,758

At 12/29/04 01:59 PM, Simon4145 wrote: is there any way to make random stuff fall down fall down at random spots

yep, have this on the object(s) you want to fall down:
onClipEvent(load) {
_x=random(400);
_y=random(550);
}

onClipEvent(enterFrame) {
_y+=10;
if(_y<=0) {
this._y=random(550);
this._x=random(400);
}
}


None

Cactusjuice

Reply To Post Reply & Quote

Posted at: 12/29/04 03:18 PM

Cactusjuice EVIL LEVEL 16

Sign-Up: 07/04/03

Posts: 1,758

At 12/28/04 06:05 PM, Belong100 wrote: Hey can any guys tell me the code for an ammo count like every time the mouse clicks the ammo goes down? and tell me where to put it...it would be REALLY APRECIATED :) thanx

Put this on your frame wshere the shooter guy is:
ammo=10;

then put this on the shooter;
onClipEvent(enterFrame) {
if(key.isDown(Key.SPACE)) {
this.gotoandstop(2) ;
//this is the frame where the shooting animation comes from
_root.ammo--;
} if(key.isDown(key.SPACE) && _root.ammo<=0) {
this.gotoandstop(3);
//this is the "no shooting" animation;
}
}


None

scottmale24

Reply To Post Reply & Quote

Posted at: 12/29/04 03:20 PM

scottmale24 DARK LEVEL 20

Sign-Up: 08/13/01

Posts: 11,298

Here's one I made myself. It works in ANY MOVIE. just copy and paste it into the first frame of your movie, and PRESTO!!!

tellTarget (movie) {
be_awesome;
}

Webcomic - Sig art by Shalonesk
Nipple edited out to make forum-acceptable

BBS Signature

None

Cactusjuice

Reply To Post Reply & Quote

Posted at: 12/29/04 03:21 PM

Cactusjuice EVIL LEVEL 16

Sign-Up: 07/04/03

Posts: 1,758

At 12/29/04 03:20 PM, scottmale24 wrote: Here's one I made myself. It works in ANY MOVIE. just copy and paste it into the first frame of your movie, and PRESTO!!!

tellTarget (movie) {
be_awesome;
}

Woah man!!!That was bloody awesome!!!MORE!


None

Simon4145

Reply To Post Reply & Quote

Posted at: 12/29/04 04:27 PM

Simon4145 EVIL LEVEL 06

Sign-Up: 12/23/04

Posts: 118

At 12/29/04 03:15 PM, Nova_dragon wrote:
At 12/29/04 01:59 PM, Simon4145 wrote: is there any way to make random stuff fall down fall down at random spots
yep, have this on the object(s) you want to fall down:
onClipEvent(load) {
_x=random(400);
_y=random(550);
}

onClipEvent(enterFrame) {
_y+=10;
if(_y<=0) {
this._y=random(550);
this._x=random(400);
}
}

ok thnxs for the script but i put all of it on the object right


Happy

Belong100

Reply To Post Reply & Quote

Posted at: 12/29/04 05:35 PM

Belong100 EVIL LEVEL 03

Sign-Up: 07/26/04

Posts: 51

At 12/29/04 03:18 PM, Nova_dragon wrote:
At 12/28/04 06:05 PM, Belong100 wrote: Hey can any guys tell me the code for an ammo count like every time the mouse clicks the ammo goes down? and tell me where to put it...it would be REALLY APRECIATED :) thanx
Put this on your frame wshere the shooter guy is:
ammo=10;

then put this on the shooter;
onClipEvent(enterFrame) {
if(key.isDown(Key.SPACE)) {
this.gotoandstop(2) ;
//this is the frame where the shooting animation comes from
_root.ammo--;
} if(key.isDown(key.SPACE) && _root.ammo<=0) {
this.gotoandstop(3);
//this is the "no shooting" animation;
}
}

ok thanx but...i dont understand it and it dont work either (maybe jus cuz im such a n00b at actionscript) cud u plz plz plz explain it a little better?


None

NuiStyles

Reply To Post Reply & Quote

Posted at: 12/29/04 07:58 PM

NuiStyles LIGHT LEVEL 03

Sign-Up: 07/10/04

Posts: 367

hey i need the number for the letter keys i no that the letter Z key is 90 but whats X and how do i find out all the others Thanks :D


None

NuiStyles

Reply To Post Reply & Quote

Posted at: 12/29/04 09:48 PM

NuiStyles LIGHT LEVEL 03

Sign-Up: 07/10/04

Posts: 367

Hey I Anserd My Own Question ( here are the key codes for other users :D )

Letters A to Z and standard numbers 0 to 9
The following table lists the keys on a standard keyboard for the letters A to Z and the numbers 0 to 9, with the corresponding ASCII key code values that are used to identify the keys in ActionScript.

Letter or number key
Key code

A
65

B
66

C
67

D
68

E
69

F
70

G
71

H
72

I
73

J
74

K
75

L
76

M
77

N
78

O
79

P
80

Q
81

R
82

S
83

T
84

U
85

V
86

W
87

X
88

Y
89

Z
90

0
48

1
49

2
50

3
51

4
52

5
53

6
54

7
55

8
56

9
57

Example:
onClipEvent (enterFrame) {
if (Key.isDown(Key.65)) {
BlahBlah
}
}
thats the code for onkey press A i think correct me if im wrong please

Thanks
NuiStyles


Questioning

CarbonCX

Reply To Post Reply & Quote

Posted at: 12/30/04 08:26 AM

CarbonCX NEUTRAL LEVEL 04

Sign-Up: 10/17/04

Posts: 13

Can anyone help me. I need a code so that the character can jump on to more than one "ground" movieclip without falling through. This is the script I have put on my character so far :

onClipEvent (load) {
moveSpeed = 10;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x += moveSpeed;
} else if (Key.isDown(Key.UP)) {
this._y-moveSpeed;
} else if (Key.isDown(Key.DOWN)) {
this._y -= moveSpeed;
} else if (Key.isDown(Key.LEFT)) {
this._x -= moveSpeed;
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP) && !jumping) {
vel_y = 50;
jumping = true;
}
if (jumping == true) {
vel_y -= 5;
if (vel_y<=-15) {
vel_y = -15;
}
this._y -= vel_y;
}
if (_root.ground.hitTest(this._x, this._y+0, true)) {
vel_y = 0;
jumping = false;
}
}
onClipEvent (enterFrame) {
this._y += 5;
if (_root.ground.hitTest(this._x, this._y+1, true)) {
this._y -= 5;
}
}


None

mooseisloose

Reply To Post Reply & Quote

Posted at: 12/30/04 08:45 AM

mooseisloose FAB LEVEL 31

Sign-Up: 12/06/04

Posts: 2,281

tellTarget (movie) {
be_awesome;
}

lol, that is the most awesome thing i've ever seen!


None

Skribble-Style

Reply To Post Reply & Quote

Posted at: 12/30/04 09:15 AM

Skribble-Style EVIL LEVEL 07

Sign-Up: 05/18/03

Posts: 65

tellTarget (movie) {
be_awesome;
}

i must agree, that is one of the most awesome things ive ever seen.


None

SupaTuna

Reply To Post Reply & Quote

Posted at: 12/30/04 05:07 PM

SupaTuna NEUTRAL LEVEL 19

Sign-Up: 06/18/04

Posts: 630

Hey, I resisted posting in this topic for a little while, but i jsut couldnt fid the code i need. i have looked through abotu ten pages of this topic and didnt find it, so i gave up. I have a over view game, and i need my MC to change directions when i press the direction i want to go, right now it always faces the same way when i move it around. this is the code in the MC:

onClipEvent (keyDown) {
if (Key.isDown( key.LEFT)) {
_x-=10;
}
}
onClipEvent (keyDown) {
if (Key.isDown( key.RIGHT)) {
_x+=10;
}
}
onClipEvent (keyDown) {
if (Key.isDown( key.UP )) {
_y-=10;
}
}
onClipEvent (keyDown) {
if (Key.isDown( key.DOWN )) {
_y+=10;
}
}

thanks in advance to everyone who helps.


None

dELtaluca

Reply To Post Reply & Quote

Posted at: 12/30/04 05:30 PM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,023

the ammo count thingy majobby with mouse.

var ammoCount = 100;
this.onMouseDown = function() {
ammocount--;
}

My social worker says im special!

BBS Signature

None

Ebolarama

Reply To Post Reply & Quote

Posted at: 12/30/04 09:08 PM

Ebolarama NEUTRAL LEVEL 16

Sign-Up: 02/23/04

Posts: 2,666

Can someone give me the script to Stop All Sounds?

Thanks a million.


None

Pazoozoo

Reply To Post Reply & Quote

Posted at: 12/31/04 02:16 AM

Pazoozoo EVIL LEVEL 02

Sign-Up: 12/30/04

Posts: 29

At 12/30/04 09:08 PM, ImmortalDarkness wrote: Can someone give me the script to Stop All Sounds?

Thanks a million.

put this on; on(release){ stopAllSounds () and add a } to the last line sorry my keyboard is screwing up


None

Pazoozoo

Reply To Post Reply & Quote

Posted at: 12/31/04 02:24 AM

Pazoozoo EVIL LEVEL 02

Sign-Up: 12/30/04

Posts: 29

I have read through and pretty much memorised 80 pages of this topic but i have questions that linger on such as : How Can I make it if an mc jumps on a character it does a hittest and gotoandplay(5) but if the mc2 hits when mc1 isnt jumping it gotoandplay(6) or something also how do i make a control like if (key.is.down (SPACE)) race off in this direction when touched but if not goto and play (6) or remain motionless


None

Simon4145

Reply To Post Reply & Quote

Posted at: 12/31/04 02:47 AM

Simon4145 EVIL LEVEL 06

Sign-Up: 12/23/04

Posts: 118

i have another question how do i make it so id i press a certain button it makes random stuff fall down this is almost the same as my other question and sorry for being stupid


None

Cactusjuice

Reply To Post Reply & Quote

Posted at: 12/31/04 11:30 AM

Cactusjuice EVIL LEVEL 16

Sign-Up: 07/04/03

Posts: 1,758

ok thanx but...i dont understand it and it dont work either (maybe jus cuz im such a n00b at actionscript) cud u plz plz plz explain it a little better?

I just tested it and it works fine, plz tell me exactly what you did so I can figure out where you've gone wrong


None

Cactusjuice

Reply To Post Reply & Quote

Posted at: 12/31/04 11:33 AM

Cactusjuice EVIL LEVEL 16

Sign-Up: 07/04/03

Posts: 1,758

At 12/31/04 02:47 AM, Simon4145 wrote: i have another question how do i make it so id i press a certain button it makes random stuff fall down this is almost the same as my other question and sorry for being stupid

Ok gets a lil more ocmplicated now, first make a buton, then put this code on it:
on(release) {
a=true;
}

on the frame where the button is put:
a=false;

now put this code on one of your objects:

onClipEvent(load) {
_x=random(400);
_y=random(550);
}
onClipEvent(enterFrame) {
if(a) {
_y+=10;
if(_y<=0) {
this._y=random(550);
this._x=random(400);
}
}
}

I haven't tested it but it should work, let me know how it goes

I have my own question now, the (if(key.isDown)) method is alright but I want to know how you can activate a command if the key is just tapped instead of held down, can anyone help?


None

Simon4145

Reply To Post Reply & Quote

Posted at: 12/31/04 02:16 PM

Simon4145 EVIL LEVEL 06

Sign-Up: 12/23/04

Posts: 118

ok thanks for the script ill test it now


None

TwiggyG

Reply To Post Reply & Quote

Posted at: 12/31/04 06:49 PM

TwiggyG NEUTRAL LEVEL 03

Sign-Up: 03/09/04

Posts: 122

i need help on this game im making, i have an automatic gun that i am using for a weapon to shoot people but they people will only die if i click them. i want it so that when the mouse is held down playing the shooting animation of the autogun, i want them to die instead of clicking each time..

the code i am using for the automatic gin is=

onClipEvent (mouseDown) {
shot += 1;
}
onClipEvent (enterFrame) {
if (shot>0) {
tellTarget ("_root.gun") {
play();
}
}
}
onClipEvent (mouseUp) {
shot=0;
}


None

Simon4145

Reply To Post Reply & Quote

Posted at: 12/31/04 08:48 PM

Simon4145 EVIL LEVEL 06

Sign-Up: 12/23/04

Posts: 118

nova_dragon the script doesnt work


None

TwiggyG

Reply To Post Reply & Quote

Posted at: 12/31/04 09:16 PM

TwiggyG NEUTRAL LEVEL 03

Sign-Up: 03/09/04

Posts: 122

you have to put it on a mc, the movie clip has to be labeled "gun"

then you have you put shot=0 in the first frame of the flash, then you have to make the animation of the gun shooting inside the gun movie clip

GUYS I STILL NEED HELP with this pleasee!!!


All times are Eastern Daylight Time (GMT -4) | Current Time: 06:13 AM

<< Back

This topic is 284 pages long. [ 199197 | 198 | 199 | 200 | 201242284 ]

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!