Forum Topic: AS: Basic Combo.

(5,127 views • 136 replies)

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

<< < > >>
Angry

Toast

Reply To Post Reply & Quote

Posted at: 10/2/05 04:23 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

AS: Combo:

AS: Main – Teh one to rule 'em all?

Knowledge needed:

Basic actionscript knowledge: gotoAndPlays, if statements, onClipEvents, and preferably _currentframe function (Which will be explained anyways).

Introduction:

Today you are going to be programming a complete simple combo system. Some parts of the code may depend on your animations; you are going to use _currentframe.
The code I am going to post allows to create a total of 4 animations in the combo. However, you will be able to add / delete some of the combos (You can have 100 combos if you want :))

This is not a complicated tutorial, everything you need to know is how to use onClipEvents, if statements, and simple Actionscript actions such as gotoAndPlay();.
You will also be needing a good knowledge of how frames work, including frame instances and simple "stop();" and "play();" functions.
Especially if you are new to Actionscript - For your own good, DO NOT copy and paste the code without reading the entire thread once or twice.
Feel free to modify the code to your likes, I just don't advise you to use this code if you don't understand how it works, then it means you don't actually learn anything... Anyways, do as you wish, I hope you aren't getting bored - we're getting started!

The "_currentframe" funtion:

What is it?

This function basically allows you to detect on what frame an object is(Teh object's timeline).
It is extremely easy to use yet a very useful function that can save you quite a lot of time.
It is mainly used for attacks in games, for example:

if(_currentframe == 1 && Key.isDown(Key.SPACE)){// && Means "and".
this.gotoAndPlay("Attack frame");/*"Attack frame" is a frame labled "Attack frame" with an animation of some guy attacking.*/
}

What is it used for?

Simple: to find out what frame an object is currently playing.

Example:
if(_currentframe == x){
//action
}

Frame instances

To add an instance (name) to a frame, simply click the frame once and go to the propeties window. Then, type whatever you want in the textbox that should appear.
Then you can freely use gotoAndPlays or gotoAndStops using the name of the frame.

Example:

if(_currentframe == 3 && Key.isDown(Key.SPACE)){
this.gotoAndPlay("<Put teh name here>");
}

When/ How/ Where is it used?

It is used a lot for Game Overs, simple character animations, etc...

I think it can only be used with gotoAndPlays or gotoAndStops.

Okay, this is getting boring, let's go on!

The combo engine. (Finally).

The code may depend on your animations, it can totally contain 4 como animations, but you can modify it to your likes. If you have any questions about how to modify it, feel free to ask.

1. You need to have four animations in four different movie clips, all set in different frames.
2. When you've put all the 4 animations into the MovieClip, make sure every animation has the amount of frames that it actually contains. (See picture below).
3. Name the first frame of every animation "combo1","combo2", etc...
4. Finally add this code:

onClipEvent(mouseDown){
if(this._currentframe == 1){ // if the frame number is "one".
this.gotoAndPlay("combo1");//Plays animation number 1.
}
if(this._currentframe > 20 && this._currentframe < 29){/* change those numbers to the frames from where the player can begin the 2nd animation to the last frame of it.*/
this.gotoAndPlay("combo2");// Plays animation number 2.
}
if(this._currentframe > 33 && this._currentframe < 43){/* change those numbers to the frames from where the player can begin the 3rd animation to the last frame of it.*/
this.gotoAndPlay("combo3");// Plays animation number 3.
}
if(this._currentframe > 45 && this._currentframe < 54){/* change those numbers to the frames from where the player can begin the 4th animation to the last frame of it.*/
this.gotoAndPlay("combo4");// Plays animation number 4.
}
}

I hopr I have been clear enough, don't hesitate to e-mail me if you're having any problems.

Good luck :)

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Thomas

Reply To Post Reply & Quote

Posted at: 10/2/05 04:27 AM

Thomas LIGHT LEVEL 13

Sign-Up: 02/14/05

Posts: 2,429

I knew Currentframe had something to do with Combo's or whatever...

Nice tutorial ;)

...an angry face?Wow dude,anger issues.

None

Newsdee

Reply To Post Reply & Quote

Posted at: 10/2/05 04:28 AM

Newsdee LIGHT LEVEL 18

Sign-Up: 01/21/05

Posts: 650

I wonder if there is any way to look up the current frame's name...
You know like if frame 2 is called "main", _currentframe returns 2, but there's nothing (AFAIK) to return "main". Maybe this was changed in Flash 8... I need to check the docs...

The only way I've found is to build an array of frame numbers and names. So that you do:
"nameArray[_currentframe]" to retrieve that value. But that's just a dirty workaround...


None

Toast

Reply To Post Reply & Quote

Posted at: 10/2/05 04:33 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

At 10/2/05 04:27 AM, -Thomas- wrote: I knew Currentframe had something to do with Combo's or whatever...

Actually, it doesn't although it can certainly be used in combos :)

Nice tutorial ;)

<3


...an angry face?Wow dude,anger issues.

>:(

At 10/2/05 04:28 AM, newsdee wrote: I wonder if there is any way to look up the current frame's name...
You know like if frame 2 is called "main", _currentframe returns 2,

I thought about that aswell, but it's pretty teh silly since frame names can't be changed in a swf...
I mean, I suppose you already know how the frames are called if you're teh animator :)

"nameArray[_currentframe]" to retrieve that value. But that's just a dirty workaround...

I've never tried that - it can be a good solution.

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Thomas

Reply To Post Reply & Quote

Posted at: 10/2/05 04:35 AM

Thomas LIGHT LEVEL 13

Sign-Up: 02/14/05

Posts: 2,429

BTW DARK Toaster...did you ever work on the RPG you expected to hit frontpage?


None

Newsdee

Reply To Post Reply & Quote

Posted at: 10/2/05 04:38 AM

Newsdee LIGHT LEVEL 18

Sign-Up: 01/21/05

Posts: 650

You know like if frame 2 is called "main", _currentframe returns 2,
I thought about that aswell, but it's pretty teh silly since frame names can't be changed in a swf...
I mean, I suppose you already know how the frames are called if you're teh animator :)

Well, it would be just to look the names up, not change them. I was trying to do that many moons ago for one of my first games, but then used the array. Today I don't even remember if it made sense to use the frame name; I just remember that it seemed odd that you couldn't retrieve it.


None

Thomas

Reply To Post Reply & Quote

Posted at: 10/2/05 04:40 AM

Thomas LIGHT LEVEL 13

Sign-Up: 02/14/05

Posts: 2,429

Bleh I spam youz

AS: Basic Combo.


None

Toast

Reply To Post Reply & Quote

Posted at: 10/2/05 04:41 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

At 10/2/05 04:35 AM, -Thomas- wrote: BTW DARK Toaster...did you ever work on the RPG you expected to hit frontpage?

What?! You must have got something wrong, I'm not dark toaster... :S

P.S: Log on msn ;)

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Toast

Reply To Post Reply & Quote

Posted at: 10/2/05 04:43 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

At 10/2/05 04:38 AM, newsdee wrote: Well, it would be just to look the names up, not change them. I was trying to do that many moons ago for one of my first games, but then used the array. Today I don't even remember if it made sense to use the frame name; I just remember that it seemed odd that you couldn't retrieve it.

I know what you mean - what's the point in getting a name if you already know it?
If you want the viewers to know teh name of the frame, just have like:
var frame1 = walking
var frame2 = blah balh
or even use arrays:
frames = new Array("walking","attacking",etc...);

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Devenger

Reply To Post Reply & Quote

Posted at: 10/2/05 04:45 AM

Devenger NEUTRAL LEVEL 09

Sign-Up: 12/24/04

Posts: 1,104

Maybe it's just my defective memory, but he stopped making that RPG due to communication issues with the other person :\

Nice tutorial, by the way. I might actually use _currentframe a bit more, I can imagine it makes some things easier.

I'm back! on a temporary basis. No-one can remember who I am! but I don't really mind.


None

BrotherToast

Reply To Post Reply & Quote

Posted at: 10/2/05 04:54 AM

BrotherToast NEUTRAL LEVEL 04

Sign-Up: 03/05/05

Posts: 139

At 10/2/05 04:45 AM, TheDeviousDuck wrote: Maybe it's just my defective memory, but he stopped making that RPG due to communication issues with the other person :\

I actually think he stopped because he had to go to school... =/

Nice tutorial, by the way. I might actually use _currentframe a bit more, I can imagine it makes some things easier.

Yeah, as I said in teh intro, it can save much time, headaches, and anger.
I remember I spent days about that stupid combo system (with no success) until one night, I dreamed about _currentframe!
Yeah, that's the truth, I dreamed about it!


None

Thomas

Reply To Post Reply & Quote

Posted at: 10/2/05 04:55 AM

Thomas LIGHT LEVEL 13

Sign-Up: 02/14/05

Posts: 2,429

Are you over the post count,buddy buddy?


None

Devenger

Reply To Post Reply & Quote

Posted at: 10/2/05 04:57 AM

Devenger NEUTRAL LEVEL 09

Sign-Up: 12/24/04

Posts: 1,104

Dreaming about flash... then again, I gather inspiration from dreams. I mean, some things just come with time, like the knowledge playing with _root variables like _x are fun.

I'm back! on a temporary basis. No-one can remember who I am! but I don't really mind.


None

Toast

Reply To Post Reply & Quote

Posted at: 10/2/05 05:10 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

At 10/2/05 04:57 AM, TheDeviousDuck wrote: Dreaming about flash... then again, I gather inspiration from dreams. I mean, some things just come with time, like the knowledge playing with _root variables like _x are fun.

Yeah, I also once "dreamed" about _root. A so simple way to zoom in, scroll everything, etc... Instead of adding a _xscale += 5; to every movieclip..

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

T-H

Reply To Post Reply & Quote

Posted at: 10/2/05 06:35 AM

T-H LIGHT LEVEL 38

Sign-Up: 01/07/04

Posts: 4,903

Thanks toast, that was actually pretty helpful.

lol you did well after AS:Variables

None

Kipling

Reply To Post Reply & Quote

Posted at: 10/2/05 06:39 AM

Kipling NEUTRAL LEVEL 13

Sign-Up: 05/04/04

Posts: 2,644

-Toast- and spamburger should be married. With the whole "I'm 12, I have threads in AS Main" thing that they've got going on.


None

Toast

Reply To Post Reply & Quote

Posted at: 10/2/05 06:39 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

At 10/2/05 06:35 AM, T-H wrote: Thanks toast, that was actually pretty helpful.

Yeah, although I think teh _currentframe was more useful than the combo itself :P

l u did we aft A :

What are you talking about?!

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Toast

Reply To Post Reply & Quote

Posted at: 10/2/05 06:41 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

At 10/2/05 06:39 AM, kipling wrote: -Toast- and spamburger should be married. With the whole "I'm 12, I have threads in AS Main" thing that they've got going on.

I bet you're just jealous...

1. Being 12 is not my fault :P

2. I didn't type that AS: for boasting...

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

T-H

Reply To Post Reply & Quote

Posted at: 10/2/05 06:44 AM

T-H LIGHT LEVEL 38

Sign-Up: 01/07/04

Posts: 4,903

I wonder who is younger out of toast and spam


None

Toast

Reply To Post Reply & Quote

Posted at: 10/2/05 06:46 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

I was born in March 13th 1993. Beat that! :p

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Rustygames

Reply To Post Reply & Quote

Posted at: 10/2/05 06:47 AM

Rustygames LIGHT LEVEL 18

Sign-Up: 05/07/05

Posts: 6,429

Man you got alot of n00bs praising you above because they didnt know the _currentframe property. Thats right property no function like you said above :P
Mediocre tutorial but overall kinda pointless and because the regs were all banned yesterday im assuming youve kinda got away with murder here
But still congrats on beating your variables tutorial

- Matt, Rustyarcade.com


None

T-H

Reply To Post Reply & Quote

Posted at: 10/2/05 06:50 AM

T-H LIGHT LEVEL 38

Sign-Up: 01/07/04

Posts: 4,903

At 10/2/05 06:47 AM, Ninja-Chicken wrote: Man you got alot of n00bs praising you above because they didnt know the _currentframe property.

*Bows head in shame*

Seriously I would have ended up putting it on the frames : (

Flame me pls


None

Rustygames

Reply To Post Reply & Quote

Posted at: 10/2/05 06:51 AM

Rustygames LIGHT LEVEL 18

Sign-Up: 05/07/05

Posts: 6,429

At 10/2/05 06:50 AM, T-H wrote:
At 10/2/05 06:47 AM, Ninja-Chicken wrote: Man you got alot of n00bs praising you above because they didnt know the _currentframe property.
*Bows head in shame*

Seriously I would have ended up putting it on the frames : (

Flame me pls

lol I didnt say you were a n00b but really did you not know _currentframe?
And where are you your not on msn?

- Matt, Rustyarcade.com


None

Toast

Reply To Post Reply & Quote

Posted at: 10/2/05 06:52 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

At 10/2/05 06:47 AM, Ninja-Chicken wrote: Thats right property no function like you said above :P

Hmph, did I call it a function!?

Mediocre tutorial but overall kinda pointless

I'm sure many people know _currentframe but just don't bother / remmember to use it often.

and because the regs were all banned yesterday im assuming youve kinda got away with murder here

What do you mean? I talked about making it before the "NG sucks" thread existed...
Glaiel, you, Liam, Flashkid, and I all got banned, what a shame Tim was away when it happened :P

But still congrats on beating your variables tutorial

Heh, but I'm not sure it beats the physics one.

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

T-H

Reply To Post Reply & Quote

Posted at: 10/2/05 06:54 AM

T-H LIGHT LEVEL 38

Sign-Up: 01/07/04

Posts: 4,903

At 10/2/05 06:51 AM, Ninja-Chicken wrote: lol I didnt say you were a n00b but really did you not know _currentframe?
And where are you your not on msn?

Yeah I knew it I just would have never thought to use it :S

And MSN is fucking broken,can't sign on . I'll be back on later after ive got homework to do.

Talk in abit :D


None

Paranoia

Reply To Post Reply & Quote

Posted at: 10/2/05 06:56 AM

Paranoia DARK LEVEL 31

Sign-Up: 04/22/05

Posts: 9,119

At 10/2/05 06:46 AM, -Toast- wrote: I was born in March 13th 1993. Beat that! :p

Heh I never realised -Toast- was 13... And you're still better at AS than me! (Probably... I mean, I could have made this code myself if I had to... Yeah...)

A rate of change in sanity with respect to time.

BBS Signature

None

Teee-Haych

Reply To Post Reply & Quote

Posted at: 10/2/05 06:57 AM

Teee-Haych EVIL LEVEL 02

Sign-Up: 09/18/05

Posts: 52

Until I come back enjoy :P

Darkened toast: I once got one of those
Darkened toast: It made me sad
Darkened toast: I DO have a pen0r :-(
TimHeasmanAIM: lol
Darkened toast: he's here!
Darkened toast: say hello bob
TimHeasmanAIM: lol gotta save this one....
Darkened toast: :O
Darkened toast: no!
Darkened toast: ahhh!
Darkened toast: *Runs away*
Darkened toast: Deletes Newgrounds account*

Laters


None

BrotherToast

Reply To Post Reply & Quote

Posted at: 10/2/05 07:02 AM

BrotherToast NEUTRAL LEVEL 04

Sign-Up: 03/05/05

Posts: 139

Oh my god! You posted our convo! Shame on you >:(

Since you already posted it, I'll post the entire convo :P

Darkened toast: Oh my god, you just did something really stupid :P
TimHeasmanAIM: ?
Darkened toast: At 10/2/05 06:50 AM, T-H wrote:

Flame me pls

Darkened toast: You'll get tons of n00b mails
TimHeasmanAIM: lol
Darkened toast: =p
TimHeasmanAIM: not the first time ive said it
Darkened toast: hmm..
Darkened toast: Did you get any mail already? >__>
TimHeasmanAIM: nope
Darkened toast: "lol j00 suck sily n00b w/e n0 pen0rr!!1!11"
TimHeasmanAIM: lol
Darkened toast: I once got one of those
Darkened toast: It made me sad
Darkened toast: I DO have a pen0r :-(
TimHeasmanAIM: lol
Darkened toast: he's here!
Darkened toast: say hello bob
TimHeasmanAIM: lol gotta save this one....
Darkened toast: :O
Darkened toast: no!
Darkened toast: ahhh!
Darkened toast: *Runs away*
Darkened toast: Deletes Newgrounds account*
Darkened toast: *Deletes aim account*
TimHeasmanAIM: lol there you go
TimHeasmanAIM: back later
Darkened toast: just dont paste it on NG :-)
TimHeasmanAIM: uh oh
TimHeasmanAIM: ...
TimHeasmanAIM: runs
Darkened toast: =o
TimHeasmanAIM signed off at 12:57:56.
Darkened toast: nooooooo
Previous message was not received by TimHeasmanAIM because of error: User TimHeasmanAIM is not available.


None

Paranoia

Reply To Post Reply & Quote

Posted at: 10/2/05 07:04 AM

Paranoia DARK LEVEL 31

Sign-Up: 04/22/05

Posts: 9,119

At 10/2/05 06:57 AM, Teee-Haych wrote: Darkened toast: *Runs away*
Darkened toast: Deletes Newgrounds account*

Ah where would we be without it =P. You missed an asterix there btw...

Oh crap... Better make this post relevant to the topic... Umm...

A rate of change in sanity with respect to time.

BBS Signature

None

Nick

Reply To Post Reply & Quote

Posted at: 10/2/05 07:05 AM

Nick FAB LEVEL 22

Sign-Up: 08/22/05

Posts: 1,966

At 10/2/05 06:46 AM, -Toast- wrote: I was born in March 13th 1993. Beat that! :p

Lol, i CAN beat that. June 16th 1993. now just to wait for spamburger...


All times are Eastern Standard Time (GMT -5) | Current Time: 11:23 AM

<< Back

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

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