Forum Topic: Actionscript codes here!

(209,923 views • 8,558 replies)

This topic is 286 pages long. [ 1 | 2 | 3 | 4 | 5 | 6 | 7146286 ]

<< < > >>
None

WTF-Kurdt

Reply To Post Reply & Quote

Posted at: 6/22/03 06:01 AM

WTF-Kurdt NEUTRAL LEVEL 17

Sign-Up: 12/01/02

Posts: 1,171

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


None

gel

Reply To Post Reply & Quote

Posted at: 6/22/03 06:26 AM

gel DARK LEVEL 33

Sign-Up: 03/01/03

Posts: 77

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.


Thinking

EviLudy

Reply To Post Reply & Quote

Posted at: 6/22/03 06:54 AM

EviLudy LIGHT LEVEL 39

Sign-Up: 08/17/02

Posts: 4,526

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

None

EviLudy

Reply To Post Reply & Quote

Posted at: 6/22/03 06:56 AM

EviLudy LIGHT LEVEL 39

Sign-Up: 08/17/02

Posts: 4,526

feel free to ask anything!

Keep posting

(click my profile)

- EviLudy

Swing a Little more!
.. ROCK OUT!

BBS Signature

Happy

y3llow

Reply To Post Reply & Quote

Posted at: 6/22/03 06:58 AM

y3llow EVIL LEVEL 08

Sign-Up: 04/21/03

Posts: 1,274

hey guys i need some help with my game.
check out the thread i just started for more info.


None

EviLudy

Reply To Post Reply & Quote

Posted at: 6/22/03 07:00 AM

EviLudy LIGHT LEVEL 39

Sign-Up: 08/17/02

Posts: 4,526

Ok ill check the tread, but post your questions here, OK? Then Ill check it inmeadiatly.

(Ill post the awnser here)

Swing a Little more!
.. ROCK OUT!

BBS Signature

None

EviLudy

Reply To Post Reply & Quote

Posted at: 6/22/03 07:04 AM

EviLudy LIGHT LEVEL 39

Sign-Up: 08/17/02

Posts: 4,526

youve asked it before, but i think the 1st one is better (no color changes and actual scrolling)

Swing a Little more!
.. ROCK OUT!

BBS Signature

None

y3llow

Reply To Post Reply & Quote

Posted at: 6/22/03 07:05 AM

y3llow EVIL LEVEL 08

Sign-Up: 04/21/03

Posts: 1,274

At 6/22/03 07:00 AM, eviLudy wrote: Ok ill check the tread, but post your questions here, OK? Then Ill check it inmeadiatly.

(Ill post the awnser here)

well you'll see why i didnt post it here wen u see what it is.


None

y3llow

Reply To Post Reply & Quote

Posted at: 6/22/03 07:07 AM

y3llow EVIL LEVEL 08

Sign-Up: 04/21/03

Posts: 1,274

At 6/22/03 07:04 AM, eviLudy wrote: youve asked it before, but i think the 1st one is better (no color changes and actual scrolling)

i know i asked that already but now i have examples.
and as for the graphics they were just quick things i did for testing so the actual game will be better.


Shouting

Akula

Reply To Post Reply & Quote

Posted at: 6/22/03 12:52 PM

Akula FAB LEVEL 18

Sign-Up: 04/17/03

Posts: 8,777

he evilludy waar ben je where are you... i need more as help c'mon man!!!!!!!


None

Spider-X

Reply To Post Reply & Quote

Posted at: 6/22/03 01:43 PM

Spider-X NEUTRAL LEVEL 07

Sign-Up: 06/18/02

Posts: 30

Anyone know where I can get that Newgrounds preloader script, or any preloader script for that matter? Thanks.

~Spider


None

StarCleaver

Reply To Post Reply & Quote

Posted at: 6/22/03 01:47 PM

StarCleaver LIGHT LEVEL 29

Sign-Up: 01/03/03

Posts: 10,102

At 6/22/03 01:43 PM, Spider_X wrote: Anyone know where I can get that Newgrounds preloader script, or any preloader script for that matter? Thanks.

~Spider

well, just download the NG preloader and then look at the script in it. That script is about the same script everyone posts around here. Just use it but put it on something different. If you want more try going here. That is the rough version of the FAQ that me and PikaExploder are making so go there and towards the bottom is explained how to make preloaders. Good luck

-Star_Cleaver

I could surely die
If I only had some pie
Club-a-Club Club, son

BBS Signature

None

denacioust

Reply To Post Reply & Quote

Posted at: 6/22/03 01:57 PM

denacioust EVIL LEVEL 13

Sign-Up: 12/03/02

Posts: 151

How do I make it so that my character will always be on the ground like he can jumpp aswell and stuff but if i go over a cliff I'll fall.

BBS Signature

None

PikaExploder

Reply To Post Reply & Quote

Posted at: 6/22/03 01:58 PM

PikaExploder FAB LEVEL 14

Sign-Up: 04/08/01

Posts: 1,644

Ah crap. The tutorials. I completely forgot. Sorry about that. I will have them to you by tommorrow.


Happy

StarCleaver

Reply To Post Reply & Quote

Posted at: 6/22/03 02:11 PM

StarCleaver LIGHT LEVEL 29

Sign-Up: 01/03/03

Posts: 10,102

At 6/22/03 01:57 PM, denacioust wrote: How do I make it so that my character will always be on the ground like he can jumpp aswell and stuff but if i go over a cliff I'll fall.

well, just use Fargate's jumping script and make your MC "ground" into a cliff but don't make it extend all the way across the stage. Than put this on your guy:

onClipEvent (load){
vel_y = 0;
jumping = false;
}
onClipEvent ( enterFrame){
if (Key.isDown(Key.SPACE) && !jumping) {
vel_y =20;jumping = true;}
if (jumping == true) {
vel_y -=1;
if ( vel_y <=-10){ vel_y=-10;}
this._y -= vel_y;}
if (_root.ground.hitTest (this._x,this._y+27,true))
{vel_y = 0; jumping = false;}
}

make sure to give the ground MC the instance name "ground".

Its amazing, Fargate hasn't been here forever and yet his scripts will live on forever.

I could surely die
If I only had some pie
Club-a-Club Club, son

BBS Signature

Happy

StarCleaver

Reply To Post Reply & Quote

Posted at: 6/22/03 02:14 PM

StarCleaver LIGHT LEVEL 29

Sign-Up: 01/03/03

Posts: 10,102

At 6/22/03 01:58 PM, PikaExploder wrote: Ah crap. The tutorials. I completely forgot. Sorry about that. I will have them to you by tommorrow.

doin't worry about it. There's no rush. I'm even thinking of adding more stuff to it. It'll be my side project. I'll just continually add to it. But maybe if you could get on AIM later today than we could talk about it more, okay.

I could surely die
If I only had some pie
Club-a-Club Club, son

BBS Signature

None

EviLudy

Reply To Post Reply & Quote

Posted at: 6/22/03 02:16 PM

EviLudy LIGHT LEVEL 39

Sign-Up: 08/17/02

Posts: 4,526

Oops ive been gone for a while, was busy with my game... It is now in the portal! Criminality V2~ Onfortuneatly there was a bug and ppl voted 0... but I fixed the bug. Now I can only pray people vote higher.

It stands only 3.40 now...

Swing a Little more!
.. ROCK OUT!

BBS Signature

None

PikaExploder

Reply To Post Reply & Quote

Posted at: 6/22/03 02:20 PM

PikaExploder FAB LEVEL 14

Sign-Up: 04/08/01

Posts: 1,644

At 6/22/03 02:14 PM, Star_Cleaver wrote: doin't worry about it. There's no rush. I'm even thinking of adding more stuff to it. It'll be my side project. I'll just continually add to it. But maybe if you could get on AIM later today than we could talk about it more, okay.

Great! I'll have to catch you on MSN messenger though. AIM's at my dad's house and he's in Wisconsin for a while. :(


None

Akula

Reply To Post Reply & Quote

Posted at: 6/22/03 03:13 PM

Akula FAB LEVEL 18

Sign-Up: 04/17/03

Posts: 8,777

hey ppl how do i make my character go left when i press left and use the good animation the same for right! plz help i tried another script but that one had errors!


None

StarCleaver

Reply To Post Reply & Quote

Posted at: 6/22/03 03:21 PM

StarCleaver LIGHT LEVEL 29

Sign-Up: 01/03/03

Posts: 10,102

At 6/22/03 03:13 PM, Russian_Mobster wrote: hey ppl how do i make my character go left when i press left and use the good animation the same for right! plz help i tried another script but that one had errors!

onClipEvent (keyUp) {
_root.walk.gotoAndStop(1);
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_root.walk.play();
_root.walk._x -= 15;
_root.walk._xscale=100
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_root.walk.play();
_root.walk._x += 15;
_root.walk._xscale = -100;
}
}

name yoru MC of your guy walking, "walk" and then inside the MC on frame 1 put a stop() command and then on the last frame of the actual walking animation put

gotoAndPlay(2);

assuming 2 is the first frame of your walking sequence.

hope that helps

-Star_Cleaver

I could surely die
If I only had some pie
Club-a-Club Club, son

BBS Signature

Happy

Akula

Reply To Post Reply & Quote

Posted at: 6/22/03 03:26 PM

Akula FAB LEVEL 18

Sign-Up: 04/17/03

Posts: 8,777

ok i am going to check this post out in about 17 hours cause i am going to bed and tomorrow i need to go to school... plz give me a script for my earlier post


None

Spider-X

Reply To Post Reply & Quote

Posted at: 6/22/03 03:26 PM

Spider-X NEUTRAL LEVEL 07

Sign-Up: 06/18/02

Posts: 30

Thanks star cleaver, and while I'm here, I may as well get another question answered:

Movie Clip= ?

Can I make my own movie clip using flash? Eg. make a bouncing ball tween, turn it into a movie clip and use it in my preloader? What exactly is a movie clip and how do you amke it??

Sorry for the newb question, btu I gotta know!


Happy

StarCleaver

Reply To Post Reply & Quote

Posted at: 6/22/03 03:57 PM

StarCleaver LIGHT LEVEL 29

Sign-Up: 01/03/03

Posts: 10,102

At 6/22/03 03:26 PM, Spider_X wrote: Thanks star cleaver, and while I'm here, I may as well get another question answered:

Movie Clip= ?

Can I make my own movie clip using flash? Eg. make a bouncing ball tween, turn it into a movie clip and use it in my preloader? What exactly is a movie clip and how do you amke it??

Sorry for the newb question, btu I gotta know!

well, if you would look in that FAQ somewhere its in there. I'll even quote from it so you don't have to look through it.=)

"What are symbols Symbols are your best friend in Flash. They are drawings that you have made that can be used over and over again without having to redraw them. They are found in the library. As a rule of thumb, if you use a picture more than once in a movie, like a background, then make it a symbol. It will help reduce your filesizes in the end.

Types of Symbols Graphic: These are the basic symbols. They are static images of your drawing.
Movie Clips:These are symbols that have timelines inside of the MAIN timeline. And these timelines run independently of the main timeline. So if the main timeline is stopped, this object will keep playing. They are also necessary for AS.
Buttons:These are exactly what the name says, they are buttons that you can click. They are pretty worthless unless you have some actions attached to them. These are different then the other two symbols. Because if you right-click you button instance on the stage and go to edit, you will see that it has four frames, labeled "UP", "OVER" ,"DOWN", and "HIT". The UP frame is what the button will look like when you aren't hovering the mouse over it. The OVER frame is what the button will look like when you have the mouse over the button. They DOWN frame is what the button will look like when you click it. and The HIT frame is the actual area of the button that is active and will read the mouses. so if you have a big square and the hit frame is a circle, the button will only read the mouses presence over the circle part. The HIT frame is also not visible at all. so don't worry about making it look good. Also, if you only have a HIT frame for a button, the button will be invisible. It will appear a transparent blue color on the stage but won't be seen in the final project."

I could surely die
If I only had some pie
Club-a-Club Club, son

BBS Signature

None

Heran-Bago

Reply To Post Reply & Quote

Posted at: 6/22/03 05:21 PM

Heran-Bago LIGHT LEVEL 07

Sign-Up: 09/04/01

Posts: 159

how do you use actionscript for sound?


None

Spider-X

Reply To Post Reply & Quote

Posted at: 6/22/03 06:15 PM

Spider-X NEUTRAL LEVEL 07

Sign-Up: 06/18/02

Posts: 30

Not ot drag this off topic, but all you guys (especially star_cleaver) have been really helpful. Please let me know or email your FAQ qhen its done to spider_x131@hotmail.com.

Thanks, I'll let ya know when I have more questions :)

~Spider


None

The-Mercenary

Reply To Post Reply & Quote

Posted at: 6/22/03 09:01 PM

The-Mercenary EVIL LEVEL 17

Sign-Up: 01/22/03

Posts: 2,620

At 6/22/03 12:30 AM, Star_Cleaver wrote:
At 6/22/03 12:24 AM, Freek_Sk8er wrote:
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

Well wtf do you think I've been trying, I can get it to work, it just doesnt look right, if you come close to him and he goes to the fight seen he just does one thing, but I need him to follow you around and attack you, thats just hard.


None

The-Mercenary

Reply To Post Reply & Quote

Posted at: 6/22/03 09:05 PM

The-Mercenary EVIL LEVEL 17

Sign-Up: 01/22/03

Posts: 2,620

At 6/22/03 06:54 AM, eviLudy wrote: Since there aren't any more questions,

Dude are you even reading my posts, I'm tired of asking the same questaion, so please just go bhack and read my other posts to find the question. I know star_cleaver suggested something, but I just can make the code, so I need one thats ready.


None

The-Mercenary

Reply To Post Reply & Quote

Posted at: 6/22/03 09:16 PM

The-Mercenary EVIL LEVEL 17

Sign-Up: 01/22/03

Posts: 2,620

sorry, I meant "can't make the code" and please I'm begging I need it badly. HELP, need HELP, Ahhhhhhhh!

(I'm being a dumbass)


None

StarCleaver

Reply To Post Reply & Quote

Posted at: 6/22/03 09:32 PM

StarCleaver LIGHT LEVEL 29

Sign-Up: 01/03/03

Posts: 10,102

At 6/22/03 09:01 PM, Freek_Sk8er wrote: Well wtf do you think I've been trying, I can get it to work, it just doesnt look right, if you come close to him and he goes to the fight seen he just does one thing, but I need him to follow you around and attack you, thats just hard.

ummmm...try harder *shrug*

well, AS is not easy. What you're wanting to be handed to you on a silver platter is hard work. To make it look good and realisitic will take lots of work. I personally don't want to sit down and try to make some AI for a guy that i won't ever use. If you have specific questions i will answer them to the best of my ability but what you're asking is too much. I think most of the scripters in this forum probably feel the same way and that's why you're questions aren't being answered.

So go back and look at what you're doing and think of more specific questions to ask. Maybe one of the other scripters will be happy to take the time and help you but i personally just don't feel like doing that. So I wish you luck with your game.

-Star_Cleaver

I could surely die
If I only had some pie
Club-a-Club Club, son

BBS Signature

None

Heran-Bago

Reply To Post Reply & Quote

Posted at: 6/22/03 09:52 PM

Heran-Bago LIGHT LEVEL 07

Sign-Up: 09/04/01

Posts: 159

umm... how do you use actionscript for sound (attach sound and such)?


All times are Eastern Standard Time (GMT -5) | Current Time: 03:36 PM

<< Back

This topic is 286 pages long. [ 1 | 2 | 3 | 4 | 5 | 6 | 7146286 ]

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