00:00
00:00
Newgrounds Background Image Theme

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

391,400 Views | 7,981 Replies
New Topic

Response to Actionscript codes here! 2004-10-12 08:53:02


http://www.flashkit.com - One of the best Flash resource sites out there. Has everything. SoundFX/tutorials/movies/loops etc.
http://www.kirupa.com - Pretty much like flashkit
http://www.actionscript.org - All kind of actionscript stuff you can ask for
http://www.angelfire.com/in4/star_cleaver/tut.html - A Flash FAQ. Has answers to many questions N00bs have.
http://www.flashadvisor.com/ - Pretty much like flashkit
http://www.echoecho.com/flash.htm - Tutorial site. All kinds of tutorials.
http://www.ultrashock.com/ - A great site. Has tutorials + goodies/book reviews/fla source files.
http://www.sfdt.com/support/ - List of tutorials made in flash. Some examples of tutorials would be how to make special effects or make sticks.
http://www.lionbichstudios.com/flash_tutorials_01.htm - A very good Flash MX tutorial site. Has advanced stuff :)
http://www.gotoAndPlay.it/ - Tons of tutorials, and great stuff.

Response to Actionscript codes here! 2004-10-12 09:19:04


At 10/12/04 08:53 AM, Inglor wrote:

you pwn!
Thanks!

Response to Actionscript codes here! 2004-10-12 18:17:15


Ummm I need script for score, if you press SPACE the number goes up by 5, i have the dynamic box layed out, and it's alrdy named score, I just need the script plz.

Response to Actionscript codes here! 2004-10-12 18:38:40


THX FOR MAKING SUCH A COOL BBS POST!!!

Response to Actionscript codes here! 2004-10-12 22:30:31


At 10/1/04 10:49 PM, Jokerman01 wrote: this may have been asked before ut i dont want to go through 107 pages of actionscript sooo

how can you make it when one moveclip hits another movieclip it bounces off

(because im making a billairds game and i want to mkae it when the white ball hits the other ones they bounce off)

Pleas and Thank You!

will this help?

Response to Actionscript codes here! 2004-10-13 00:02:07


All right. I got the variables to work by removing a getTimer command I had put on reducing the healthbar. But now I've hit a slightly less significant but just as annoying snag.

Each soldier movieclip has a health bar inside the MC named "soldierHealthbar". I want the health bar to decrease based upon the soldiers current health value, so I have an if (soldierHealth==9), if (soldierHealth==8), etc. system. But since all the soldiers are duplicates, I can't name a specific tellTarget clip like ".../FootSoldier/soldierHealthbar". How would I address the health bar duplicate inside the individual soldier MC?

Note: I tried tellTarget (this/"soldierHealthbar") to no avail...

-Frenchi

Response to Actionscript codes here! 2004-10-13 07:14:44


At 10/13/04 12:02 AM, Frenchi wrote:

:stuff

1)never use tell target, it's outdated and useless, if you want to change a var you can always do healthbar-=something or mc1.mc2.healthbar-=something

when you duplicate an mc there are 3ways i know of to acces something inside it

1)put the actions inside "onClipEvent" inside the duplicated MC which is kind of limited and sometimes slow
2)accessing it with eval: with(_parent.eval("enemy"+i){}
3)accessing it with [] such as _parent["enemy"+i].stuff

hope it helps

Response to Actionscript codes here! 2004-10-13 07:17:37


At 10/12/04 06:17 PM, 1DarKneSS wrote: Ummm I need script for score, if you press SPACE the number goes up by 5, i have the dynamic box layed out, and it's alrdy named score, I just need the script plz.

put this inside a movie clip
onClipEvent(keyDown){
if(key.isDown(key.SPACE)){
variablenamehere+=5;
}
}

Response to Actionscript codes here! 2004-10-13 07:26:23


thanks for the codes!, they really help me

Response to Actionscript codes here! 2004-10-13 07:53:14


Why Josh, I'm touched that you care so much about my posting style. In fact, you have moved me so greatly with your derogatory and otherwise pointless observation that I may just reassess my entire paradigm of forum useage.

Anyway, thanks Inglor, I was able to script the healthbar to move independantly by checking its parent MC for the health variable. Much appreciated.

-Frenchi

Response to Actionscript codes here! 2004-10-13 08:55:44


Hey guys, The sites and tuturoials are GREAT! and are really helping...

However...

Could someone tell me or direct me to where I can find the code for every key on the keybord? I'm starting to make a kicking any punching game, but I only know the code for the "k" button. Thanks!

Response to Actionscript codes here! 2004-10-13 13:49:32


Have I mentioned lately that I love you?

Response to Actionscript codes here! 2004-10-13 13:58:16


Arg! Just ran into another problem... what you told me to do work PERFECTLY! My fighter guy now has a choice between punching or kicking. However, when i have him punch the movie clip of him standing thee ready to kick is still there. How do I make it, or set up the layers, movie clips, or frames so that he can EITHER do punching or kicking, without the other image staying there?

Response to Actionscript codes here! 2004-10-13 14:35:17


Some information has already been answered... I'm not changing my post, sorry. I do hope the information i give is better then Inglor's-- I mean offers a reasonable alternative to the generously given answers that were given before ;)

At 10/11/04 10:47 PM, Twistedsoulman wrote: Now , where do I find the action script codes for the other keys on the key board?

Press F1 for the flash help and do a search on ASCII. It should bring up a list for all the keys and their corresponding numbers.

Also, this I'm guessing will be harder... how do I make that kick that my guy can now do connect with another movie clip and make the guy die or something?

Make a MC called "foothitTest" where the kick action is playing. Then, on an enemy put something like this:

onClipEvent(enterFrame){
if(this.hitTest(_root.hero.foothitTest)){
this.gotoAndPlay("Die");
}
}

Make sure there is a string of frames in the enemy that show it dying.

At 10/12/04 06:17 PM, 1DarKneSS wrote: ...I just need the script plz.

Put this on the stage:

onEnterFrame=function(){
if(Key.isDown(Key.SPACE) && !spress){
spress=true;
score += 5;
}
if(!Key.isDown(Key.SPACE)){
spress=false;
}
};

I set it up so that the player has to hit the key to get points rather then just holding the key down.

At 10/13/04 12:02 AM, Frenchi wrote: healthbar troubles...

Well, did you try placing the health variable on the health bar rather then the soldier itself? That way all you have to do is something like this if the soldier gets hit:

this.hitTest(_root.enemy){
healthbar.health -= 5;
}

Then, on the health bar all you have to do is:

this._xscale = health;

It's better to change the x scale rather then having individual numbers to individually change the length of the bar.

At 10/13/04 01:58 PM, Twistedsoulman wrote: Arg!

Just make it so that once the kicking animation ends the MC goes to the idol frame of the MC. Like once the mc gets to the last frame of an animation it goes to the first frame.

Response to Actionscript codes here! 2004-10-13 15:11:43


Hi, I've been working on a platformer engine, it's coming along quite well, however I've come across a few glitches and problems. Here's the swf so far:
Engine
As you may of noticed, gravity is a bit screwed up, and sometimes when Mario jumps he lands slightly in the platform, oh and also, if any of you have played Super Mario World, when he does the spin jump he spins around until goes back to the ground, for some reason I can't get that to work. Oh and finally, when Mario jumps how do I make it so that he goes up with his jump animation, and drops with the falling animation?
PS I'm only using Mario for the engine.

Here's my script on the


//Platformer Engine ~ **Zonox** 13/08/04
//Controls
onClipEvent (load) {
function playOnce(frame) {
if (this._currentframe != frame) {
this.gotoAndStop(frame);
}
}
movespeed = 5;
jumping = false;
jSpeed = 5;
still = 0;
yspeed = 0;
gravity = 0.2;
grav = 1;
ysp = 0;
}
onClipEvent (enterFrame) {
if (jumping) {
this._y -= jSpeed;
jSpeed--;
for (var i = 0; i<=10; i++) {
if (hitTest(_root["ground"+i])) {
yspeed = 0;
_y -= 2;
if (jumping == true) {
jumping = false;
}
}
}
}
if (Key.isDown(Key.RIGHT)) {
this._x += movespeed;
_xscale = 100;
playOnce(2);
} else if (Key.isDown(Key.LEFT)) {
this._x -= movespeed;
_xscale = -100;
playOnce(2);
} else if (Key.isDown(Key.DOWN)) {
playOnce(3);
this._x -= still;
}else if (Key.isDown(Key.UP)) {
playOnce(4);
this._x-= still;
} else {
playOnce(1);
}
_y -= yspeed;
if (Key.isDown(90) && !jumping) {
jumping = true;
jSpeed = 10;
}
_y -= yspeed;
if (Key.isDown(88) && !jumping) {
jumping = true;
jSpeed = 10;
gotoAndStop(5);
}
}

Oh and the platforms have instance names of ground#, # being replaced with a number.

Can anyone help me or neaten up my script add to it? Or whatever it needs. Cheers

Response to Actionscript codes here! 2004-10-13 15:50:34


if(grav<0){
this.gotoAndStop("JumpAnim");
} else {
this.gotoAndStop("FallAnim");
}

I'm assuming that grav is the variable that you use to control how much the character moves up or down.

In order to make the platforms function, you have to turn off the jump variable and also set the MC's _y position so that it's on top of the platform, i.e.

if(this.hitTest(_root.hero)){
_root.hero.jump=false;
_root.hero._y=this._y-this._height;
}

Response to Actionscript codes here! 2004-10-13 16:44:27


At 10/13/04 02:35 PM, Deathcon7 wrote: Some information has already been answered... I'm not changing my post, sorry. I do hope the information i give is better then Inglor's-- I mean offers a reasonable alternative to the generously given answers that were given before ;)

wouldn't it be better to just answer the questions when they are asked instead of making this long post that answers many questions? i agree it's less spammish but when people ask for answers they usually want them asap...

anyhow offtopic, why are you never online on AIM?

Response to Actionscript codes here! 2004-10-13 16:50:21


At 10/13/04 02:35 PM, Deathcon7 wrote: Well, did you try placing the health variable on the health bar rather then the soldier itself? That way all you have to do is something like this if the soldier gets hit:

this.hitTest(_root.enemy){
healthbar.health -= 5;
}

Then, on the health bar all you have to do is:

this._xscale = health;

It's better to change the x scale rather then having individual numbers to individually change the length of the bar.

Right now the hitTest is on the soldier:

if (_name != "FootSoldier") {
if (Key.isDown(Key.SPACE)) {
if (_root.TargetCore.hitTest(this)) {
soldierHealth -= 1;
}
}
}

If I put the hitTest inside the hit bar and the target as its parent, _root.soldier, then wouldn't flash look at the original soldier that all the copies are duplicated from?

Let me show you the engine so far, if it helps any.
http://www.frenchi.net/turret.php

-Frenchi

Response to Actionscript codes here! 2004-10-13 16:59:42


i think you and i are the only 2 people who use duplicateMovieClip and not attachMovieClip for that kind of thing

Response to Actionscript codes here! 2004-10-14 02:45:02


yeah yeah, stupid question probly but i only just got flash and i am not fimiliar with everything on it and i really dont know what action script is. if someone coulda explain OR defer me to a site, that'd be great.

Thanks

Response to Actionscript codes here! 2004-10-14 05:36:52


Can anybody help me with this?

How do I reference to a stored variable through another variable that is made up of strings concatenated.

E.g.
strAttackDmg = Array[i] + "Dmg"
.'. if Array[i] = "laser", strAttackDmg = laserDmg.

laserDmg is a global variable and has an Number type value, eg. 15.

So in the end, When I deduct strAttackDmg from my hitPoints variable, I want the laserDmg value (15) to be deducted.
Eg.
hitPoints = hitPoints - strAttackDmg
.'. hitPoints = hitPoints - laserDmg
.'. hitPoints = hitPoints - 15

Here's a basic summary:
hitPoints(number) -= laserDmg(int);
hitPoints -= strAttackDmg(array[i] + "Dmg"; string) == laserDmg(already created variable; string) == int (15, number)

Response to Actionscript codes here! 2004-10-14 08:27:22


that is a really bad way to do a really simple thing...

Response to Actionscript codes here! 2004-10-14 09:42:02


At 10/14/04 03:54 AM, Joshman_123 wrote: Ah, this is all well and dandy but how do you know my name, Frenchi, if that is your real name.

Because you signed it at the end of your last post.

At 10/13/04 02:55 AM, Joshman_123 wrote: don't see the point of that, I mean, who can't look about 2 centimetres to the left to see your name? It's stupid and a waste of time. Idiots.

:~Joshman_123

-Frenchi

Response to Actionscript codes here! 2004-10-14 10:07:17


I haven't included the rest of the code.

I need to pass variables. Going with the array and adding strings to fetch information (attackDmg, attackRoll, attackMin etc..) is the only way I've seen fit so far.

I also need to play certain frames according to the array value.

But I'm open for suggestions

Response to Actionscript codes here! 2004-10-14 15:34:31


At 10/13/04 03:50 PM, Deathcon7 wrote: if(grav<0){
this.gotoAndStop("JumpAnim");
} else {
this.gotoAndStop("FallAnim");
}

I'm assuming that grav is the variable that you use to control how much the character moves up or down.

In order to make the platforms function, you have to turn off the jump variable and also set the MC's _y position so that it's on top of the platform, i.e.

if(this.hitTest(_root.hero)){
_root.hero.jump=false;
_root.hero._y=this._y-this._height;
}

COuld you be a little bit more specific, I'm confused, now Mario starts half up the screen, and when he jumps he goes down to the platform then it spaz's, what sort of script do I need to set the Mario starting hiehgt?

Response to Actionscript codes here! 2004-10-14 16:01:49


At 10/14/04 03:34 PM, Zonox wrote:
At 10/13/04 03:50 PM, Deathcon7 wrote: if(grav<0){
this.gotoAndStop("JumpAnim");
} else {
this.gotoAndStop("FallAnim");
}

Do You have this code good? All it does is recognize weather mario is going up ("JumpAnim") or if he's falling down after the jump ("FallAnim").

if(this.hitTest(_root.hero)){
_root.hero.jump=false;
_root.hero._y=this._y-this._height;
}
COuld you be a little bit more specific, I'm confused, now Mario starts half up the screen, and when he jumps he goes down to the platform then it spaz's, what sort of script do I need to set the Mario starting hiehgt?

Well, the code I gave you is for you to put it onto your platform. Paste it on the platform, and give the Mario MC an instance name of "hero".

Response to Actionscript codes here! 2004-10-14 16:04:15


At 10/13/04 04:50 PM, Frenchi wrote:
Right now the hitTest is on the soldier:

if (_name != "FootSoldier") {
if (Key.isDown(Key.SPACE)) {
if (_root.TargetCore.hitTest(this)) {
soldierHealth -= 1;
}
}
}

Quite a lot for something easier. When you check if this and this and this and then just add, substract or do any assignment, much better to do something like:

soldierHealth -= (_name!="FootSoldier") && Key.isDown(Key.SPACE) && _root.TargetCore.hitTest(this);

Only if all 3 conditions are true you'll have a "true", this is, a 1. Else, it will just substract 0.

If I put the hitTest inside the hit bar and the target as its parent,

:_root.soldier, then wouldn't flash look at the original soldier that

all the copies are duplicated from?

Yes, so I think it would be better to use the _parent alias. Then it would look for the parent MC, not the original one.

Response to Actionscript codes here! 2004-10-14 17:52:32


At 10/14/04 04:01 PM, Deathcon7 wrote:
if(this.hitTest(_root.hero)){
_root.hero.jump=false;
_root.hero._y=this._y-this._height;
}
COuld you be a little bit more specific, I'm confused, now Mario starts half up the screen, and when he jumps he goes down to the platform then it spaz's, what sort of script do I need to set the Mario starting hiehgt?
Well, the code I gave you is for you to put it onto your platform. Paste it on the platform, and give the Mario MC an instance name of "hero".

Yeah I understood the first bit, but the second bit when I place it in the platform, with a on(clip) etc etc, it messes up, and puts mario in the middle of the screen, how do I set him at a starting hieght on the platform?

Response to Actionscript codes here! 2004-10-14 22:33:42


Do you have scripts for defeating bosses in a platform shooter? Not exaclty sure if i'm asking the right question. Do you also have script for life gauges for the hero?

Response to Actionscript codes here! 2004-10-15 02:38:40


At 10/14/04 10:33 PM, bbm1 wrote: Do you have scripts for defeating bosses in a platform shooter? Not exaclty sure if i'm asking the right question. Do you also have script for life gauges for the hero?

you are right, you haven't asked the right question, but that's ok since you are a newbie and one of the main purposes of this forum is to help you.

i'll assume that your situation is not that you have a full platformer and just want a "boss script" but that you are yet to accomplish the platformer, i recommand visiting flashkit which is a really good tutorial site, and reading tutorials at flashregs, good luck and if you have more specific questions ask away.