00:00
00:00
Newgrounds Background Image Theme

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

AS: Basic Combo.

13,138 Views | 131 Replies
New Topic Respond to this Topic

AS: Basic Combo. 2005-10-02 04:23:31


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 :)


BBS Signature

Response to AS: Basic Combo. 2005-10-02 04:27:09


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

Nice tutorial ;)

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

wat

Response to AS: Basic Combo. 2005-10-02 04:28:59


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

Response to AS: Basic Combo. 2005-10-02 04:33:24


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.


BBS Signature

Response to AS: Basic Combo. 2005-10-02 04:35:44


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


wat

Response to AS: Basic Combo. 2005-10-02 04:38:21


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.

Response to AS: Basic Combo. 2005-10-02 04:40:28


Bleh I spam youz

AS: Basic Combo.


wat

Response to AS: Basic Combo. 2005-10-02 04:41:02


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 ;)


BBS Signature

Response to AS: Basic Combo. 2005-10-02 04:43:23


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...);


BBS Signature

Response to AS: Basic Combo. 2005-10-02 04:45:19


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.

Response to AS: Basic Combo. 2005-10-02 04:54:45


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!

Response to AS: Basic Combo. 2005-10-02 04:55:49


Are you over the post count,buddy buddy?


wat

Response to AS: Basic Combo. 2005-10-02 04:57:41


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.

Response to AS: Basic Combo. 2005-10-02 05:10:21


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


BBS Signature

Response to AS: Basic Combo. 2005-10-02 06:35:49


Thanks toast, that was actually pretty helpful.

lol you did well after AS:Variables

Response to AS: Basic Combo. 2005-10-02 06:39:02


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

Response to AS: Basic Combo. 2005-10-02 06:39:52


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


BBS Signature

Response to AS: Basic Combo. 2005-10-02 06:41:08


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


BBS Signature

Response to AS: Basic Combo. 2005-10-02 06:44:21


I wonder who is younger out of toast and spam

Response to AS: Basic Combo. 2005-10-02 06:46:41


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


BBS Signature

Response to AS: Basic Combo. 2005-10-02 06:47:57


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

Response to AS: Basic Combo. 2005-10-02 06:50:14


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

Response to AS: Basic Combo. 2005-10-02 06:51:37


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

Response to AS: Basic Combo. 2005-10-02 06:52:11


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.


BBS Signature

Response to AS: Basic Combo. 2005-10-02 06:54:23


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

Response to AS: Basic Combo. 2005-10-02 06:56:28


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...)


BBS Signature

Response to AS: Basic Combo. 2005-10-02 06:57:31


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

Response to AS: Basic Combo. 2005-10-02 07:02:58


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.

Response to AS: Basic Combo. 2005-10-02 07:04:19


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


BBS Signature

Response to AS: Basic Combo. 2005-10-02 07:05:11


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