00:00
00:00
Newgrounds Background Image Theme

RandomGuyTV 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!

390,065 Views | 7,981 Replies
New Topic

Response to Actionscript codes here! 2003-06-20 14:17:54


Sometimes I use telltarget, sometimes i dont. I've learned the thing with telltarget and I knew that one before I bought my AS-book and once I got the book I learned the other way...


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-20 14:23:08


At 6/20/03 02:16 PM, Russian_Mobster wrote:
At 5/4/03 05:01 AM, eviLudy wrote:
how do make that when i klick with the laserdot i here a gunshot... i already have the gunshot sound in my library

go to the laserdot movieclip, doubleclick on it and add this script to the 1st frame:

stop()

Then make a 2nd frame in that movieclip, the 2nd frame must have exactly the same image, but attach the sound to that frame...

-This will probably be my last post today, because:

You may post up to 4 replies to this topic per hour.


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-20 14:32:34


looks like i can keep posting!

Hey Russian_Mobster je bent nederlands!


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-20 14:38:33


about the sound thing... it didn't work... you know another way

p.s. You may post up to 4 replies to this topic perhour. don't tell me your going if you live in england at 10 pm to bed...do you?

Response to Actionscript codes here! 2003-06-20 16:23:22


Damn... I never use sound with Actionscript...
Im going to bed now, sorry

Tommorow I'll post another way.


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-20 16:27:05


At 6/20/03 02:38 PM, Russian_Mobster wrote: about the sound thing... it didn't work... you know another way

p.s. You may post up to 4 replies to this topic perhour. don't tell me your going if you live in england at 10 pm to bed...do you?

Im from holland, just like you.


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-20 19:31:52


hey guys im following up my project:GHOST game and its going to be a shooter, ive got everyhting down but i cant make the enemy go to the death animatin?..when i click on the mouse the shooting animation goes but they dont die, and when i take off the script that shows the shooting animation and i shoot the enemy it goes to the death animation,ive got them both
on (press) {
play();
}
what do i do

Response to Actionscript codes here! 2003-06-20 19:38:43


At 6/18/03 06:12 AM, y3llow wrote: ok i no this question has been answered in a couple of other threads but none of those answers worked for me, heres the question.

.

Heres the code i currently have.

if(Key.isDown(Key.UP)){
gotoAndPlay(2);
}else{
stop();

This code is in the first frame of the MC. is there an error in there? or should i just place it somewhere else and change it a bit?

Yeah , THe code is suppose to be on the MC and its suppose to be "this.gotoAndPlat (2);" than it should work.

Response to Actionscript codes here! 2003-06-20 19:47:17


At 6/18/03 06:12 AM, y3llow wrote:
Im tryin to work out how to make the walking animation play in an MC when i press one of the directional buttons.

Heres the code i currently have.

Yeah, You shoulod put the code in the MC, then it should work and change it to this.

if(Key.isDown(Key.UP)){
this.gotoAndPlay(2);
}else{
stop();

Response to Actionscript codes here! 2003-06-20 19:56:05


sorry if I douple posted but, When yall come back from sleeping, can you guys tell me the code for and enemyu that attacks. you know like when you get close to him he comes after you and hits you, maybe just that he comes after you. I know a Bunch o'scripts but damn this one is a puzzle. I would appriciated if anyone could help.

Response to Actionscript codes here! 2003-06-21 07:49:56


ok ive got the walking animation problem working.

now im just trying to get the background changing.
Heres wat im doing.

My game is viewed from the top, my guy at the moment can walk left and right. I've already got the code for when he gets to one side of the screen he teleports to the other side. Now my problem comes in here.

Im trying to get it so the background doesn't move, but when he reaches the edge of one it changes to to next background and say if he goes off the left side of the screen, he comes onto the new background on the right side of the screen. Then wen he walks off the right side of the second background he comes into the first background again.

Hope someone can brighten up this situation for me cause the other codes havent worked.


BBS Signature

Response to Actionscript codes here! 2003-06-21 10:55:53


At 6/20/03 02:38 PM, Russian_Mobster wrote: about the sound thing... it didn't work... you know another way

I couldn't find a way with actionscript...
(you're the first one that beat me man!) I found some sound things and i tried some things
but they didn't work...

but this should do the trick:

1) Label your mouse pointer/gun aimer "aimer"
2) Double-Click on it and make a second frame
3) In the second frame, put the sound
4) Add this script to the first frame of the movieclip:

stop();

5) Get out of the mousepointer
6) Add this piece of script to the movieclip labelled "aimer:"

onClipEvent (mouseDown) {
tellTarget ("_root.aimer") {
play();
}
}

This MUST work because I tested it.


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-21 12:14:30


Could sum1 gimme a script like what Tom Fulp uses in Pico 2 to make hime shrink when u press up I've got a script but it doesn't work like he'll shrink to different amounts eache time and THe Psycho Goldfish script doesn't work.


BBS Signature

Response to Actionscript codes here! 2003-06-21 12:47:11


At 6/21/03 07:49 AM, y3llow wrote:
Im trying to get it so the background doesn't move, but when he reaches the edge of one it changes to to next background and say if he goes off the left side of the screen, he comes onto the new background on the right side of the screen. Then wen he walks off the right side of the second background he comes into the first background again.

Hope someone can brighten up this situation for me cause the other codes havent worked.

OK here goes nothing:

1) Make the background a movieclip and label it "background"
2) Make sure the movieclip background is stopped at the first frame
3) Add more backgrounds in the movieclip, you can make as many as you want
4) Add this script to your character (the teleporting must already been done


onClipEvent (enterFrame) {
if (this._x > 550) {
tellTarget ("_root.background") {
nextFrame();
}
}
if (this._x < 0) {
tellTarget ("_root.background") {
prevFrame();
}
}
}

Keep Posting!

-EviLudy


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-21 12:54:35


At 6/21/03 12:14 PM, denacioust wrote: Could sum1 gimme a script like what Tom Fulp uses in Pico 2 to make hime shrink when u press up I've got a script but it doesn't work like he'll shrink to different amounts eache time and THe Psycho Goldfish script doesn't work.

You mean that when he walks away from you he gets smaller? Thats easy, here you go:

I have made an entire moving script so the script you used for moving the character must be deleted, here's the script:


onClipEvent (load) {
// Set the move speed and the srinking size
moveSpeed = 10;
srinkSize = 2;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x += moveSpeed;
// Move Right
} else if (Key.isDown(Key.UP)) {
this._y -= moveSpeed;
this._height -= srinkSize;
this._width -= srinkSize;
// Move Up
} else if (Key.isDown(Key.DOWN)) {
this._y += moveSpeed;
this._height += srinkSize;
this._width += srinkSize;
// Move Down
} else if (Key.isDown(Key.LEFT)) {
this._x -= moveSpeed;
// Move Left
}
}


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-21 14:06:44


How can I make a character with a gun shoting
at enemys and bullets kill theM?

Response to Actionscript codes here! 2003-06-21 15:53:56


thanks but I want it to stop at a certain time


BBS Signature

Response to Actionscript codes here! 2003-06-21 15:56:31


weet ik ik was alleen ff weg de hele dag

Response to Actionscript codes here! 2003-06-21 16:08:08


At 6/20/03 07:31 PM, xtumtumx wrote:

Try this:

on (press){
_root.shootAnimation.gotoAndPlay(#);
_root.deathAnimation.gotoAndPlay(#);

Replace "shootAnimation" with whatever the instance of the shooting animation is, and "deathAnimation" with whatever the instance of the death animation is.

Change "#" to whatever frame the animation starts on.

Are you working on ghost and bot? I suggest working on one before the other. It sucks having 2 or three different projects going on at once.

Good to see you dropping by tumtum.
Show me some of that cool art :)

Response to Actionscript codes here! 2003-06-22 00:03:52


At 6/21/03 12:47 PM, eviLudy wrote: OK here goes nothing:

sorry dude but that one didn't work either. wen i tested it he got to the edge and an error popped up and said that it couldnt find the target for tellTarget. does it work with Flash MX?


BBS Signature

Response to Actionscript codes here! 2003-06-22 00:24:54


Are you guys ignoring me on purpose, cause 2 people already asked about the fighting game(I was 1) and you guy dont seem to be answering, so here it is again,
CAN YOU GUYS GIVE ME THE CODE FOR A ENEMY THAT ATTACK YOU WHEN YOU GET NEAR HIM?
dont ignore me.

Response to Actionscript codes here! 2003-06-22 00:25:57


At 6/22/03 12:03 AM, y3llow wrote:
At 6/21/03 12:47 PM, eviLudy wrote: OK here goes nothing:
sorry dude but that one didn't work either. wen i tested it he got to the edge and an error popped up and said that it couldnt find the target for tellTarget. does it work with Flash MX?

if you're using MX then you shouldn't be using tellTarget. use dot syntax. Its the new operator so it should be the one you are using. Don't get into the habit of using deprecated methods. And i looked at EvilLudy's script and it looks fine just replace the tellTarget with the dot syntax and it should work.


I could surely die

If I only had some pie

Club-a-Club Club, son

BBS Signature

Response to Actionscript codes here! 2003-06-22 00:30:09


At 6/22/03 12:24 AM, Freek_Sk8er wrote: Are you guys ignoring me on purpose, cause 2 people already asked about the fighting game(I was 1) and you guy dont seem to be answering, so here it is again,
CAN YOU GUYS GIVE ME THE CODE FOR A ENEMY THAT ATTACK YOU WHEN YOU GET NEAR HIM?
dont ignore me.

ummmm, make the code yourself *shrug*

just use some simple logic and i'm sure you'll think of something. just use the position of you enemy and then if your "good guy" is within a certain distance of your enemy, the enemy goes into a "fight" state of some sort. I have faith that you can figure it out from there, cuz i'm tired and am going to bed and i don't want to explain a lot of stuff right now. have fun

-Star_Cleaver


I could surely die

If I only had some pie

Club-a-Club Club, son

BBS Signature

Response to Actionscript codes here! 2003-06-22 00:33:00


At 6/22/03 12:25 AM, Star_Cleaver wrote: if you're using MX then you shouldn't be using tellTarget. use dot syntax. Its the new operator so it should be the one you are using. Don't get into the habit of using deprecated methods. And i looked at EvilLudy's script and it looks fine just replace the tellTarget with the dot syntax and it should work.

i thought thats wat i should be doing, i know waht dot syntax is but im not sure of the code. could u plz give me an example of it so i can figure it out.


BBS Signature

Response to Actionscript codes here! 2003-06-22 00:41:40


At 6/22/03 12:33 AM, y3llow wrote: i thought thats wat i should be doing, i know waht dot syntax is but im not sure of the code. could u plz give me an example of it so i can figure it out.

well, tellTarget and dot syntax will do the same things but dot syntax is just the newer, better way to do it. And what do you mean by "im not sure of the code"? and here's an example using ludy's script:

onClipEvent (enterFrame) {
if (this._x > 550) {
_root.background.nextFrame();
trace("Off right side")
}
}
if (this._x < 0) {
_root.background.prevFrame();
trace("Off left side")
}
}
}

i just threw in some trace commands just to make sure that you're reading everything right. you can omit those if you want, i'm just in the habit of putting those in there when doing hitTest and position checks.


I could surely die

If I only had some pie

Club-a-Club Club, son

BBS Signature

Response to Actionscript codes here! 2003-06-22 05:07:48


Im too used to telltarget to drop it completly, but for things like

_x
_y
_visible
enabled

And that stuff, I mostly use dot syntax


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-06-22 05:58:08


thanks for the help, i finally got it goin almost ok. theres still a couple of bugs in the script but ill work them out later.


BBS Signature

Response to Actionscript codes here! 2003-06-22 06:01:04


hey, theres some pretty useful stuff here, thanks guys, this has got my game a helluva lot further.

Response to Actionscript codes here! 2003-06-22 06:26:24


Yeah, it's about time you stopped using tellTarget. It's ugly. I do agree with Idoru that tellTarget can speed things up if you have many things to do with the same movie clips, but isn't that what the with() code is for?

with(_root.someClip) {
_x = 100;
_y = 200;
_visible = true;
}

Even better than tellTarget, plus with() isn't deprecated.

Response to Actionscript codes here! 2003-06-22 06:54:55


Since there aren't any more questions, here is a bat and ball (pong) tutorial:

(All the actions will be explained at the end of the tutorial)
Here we will learn how to make an arkanoid game in my way. First, we will make the ship then, the ball (remember to make them movie clips and name the ball in the instance). Now we will create a movie clip that will not be seen on the screen, make it the shape that you want and name it “line” in the instance. Make a double click on it an make another movie clip into it. Now, make double click again on the movie clip and write the next on the frame actions:
tellTarget (_root._root.ball) {
_x -= 10;
_y -= 10;}

this will make that the ball gets in way to the northwest. Now make another frame and write; gotoAndPlay (1),this will make that the movement repeats constantly. Now make a double click out of the clip and write in the frame actions : stop ();,now make another frame (2nd) and make another movie clip in this second frame into the first movie clip we had already done (not the last one). Make a double click on it an write on the frame actions the next:
tellTarget (_root._root.ball) {
_x -= 10;
_y += 10;}

This will make the ball gets in way to the southwest. Make another frame in this movie clip, an write: gotoAndPlay (1);.make double click out of the movie clip and make another frame (3rd) , then make another movie clip and repeat the same process (rememer to write: stop ();)but in this one you will write:
tellTarget (_root._root.ball) {
_x += 10;
_y -= 10;}

to get northeast position. Repeat the same and in the next frame (4th) you will make the same but in the frame actions of the movie clip you will write:
tellTarget (_root._root.ball) {
_x += 10;
_y += 10;}

to get southeast position. Now make a double click out and write: stop();on the frame actions. Make another double click out to get in the movie. Now we will get into the ship, make double click on it. In there make an invisible movie clip (if you don´t know how to make transparent colours just select the colour you want and make a click on the mixer icon an there write 0% in the alpha) with a rectangle shape and there write the next:
onClipEvent (enterFrame) {
if (this.hitTest(_root._root.ball)) {
_root._root.line.gotoAndPlay(2);
} else {
}
}

The number of the frame depends on the way you want the ball to go ( the frame number is of the movie clip we were working on) . I recommend to copy this movie clip, paste it next to the other one and to write in the actions another frame number for the ball to get in two different directions.
Now make the walls and write:
onClipEvent (enterFrame) {
if (this.hitTest(_root.ball)) {
_root.line.gotoAndPlay(3);
} else {
}
}

depending on the frame number of the direction of the ball. Now, we will make the blocks that will be destroyed by the ball.
Make a block with the shape you want, make a double click to enter in the movie clip and write a stop (); in the first frame, make another frame which will have no drawing, and write stop (); again in the frame actions. Now make double click out of the movie clip and write the next actions for the movie clip:
onClipEvent (enterFrame) {
if (this.hitTest(_root.ball)) {
_root.line.gotoAndPlay(4);
gotoAndPlay (2);
} else {
}
}

Remember that the frame number of the “line” can be the way you want, but the frame number that appears beneath it cannot be changed because it says that the movie clip will go to its second frame, where it is nothing, this is the frame where it will go when the ball hits the block. Now write the next actions on the ship:
onClipEvent (keyDown) {
if (Key.isDown(key.LEFT)) {
_x -= 7;
}
}
onClipEvent (keyDown) {
if (Key.isDown(key.RIGHT)) {
_x +=7;
}
}

This will allow you to move the ship. And the number 7 indicates the number of pixels it will advance. Now you can make the ball to go any direction you want and to make the walls that you want and make the game more complex.
This is the explanation some of the actions:
_root.
is a very useful action that means that the movie clip you are referring is out of the movie clip you actually are.
tellTarget ( ) {
}
means that you want another movie clip to make something when you want it


Swing a Little more!

.. ROCK OUT!

BBS Signature