00:00
00:00
Newgrounds Background Image Theme

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

problem with code

764 Views | 14 Replies
New Topic Respond to this Topic

problem with code 2008-03-19 12:35:28


Hey guys, I have the following code all in one layer, on a frame which goes over the whole level, so the effects are consistent throughout the level. I want it to go to the frame "dead" when the health reaches 0, at the moment health works, but nothing happens when it reaches 0.

stop();

health=50
score=0

if (health=0) {
gotoAndStop("dead",1);

}

Response to problem with code 2008-03-19 12:42:44


bump

Response to problem with code 2008-03-19 12:57:38


bump

Response to problem with code 2008-03-19 13:54:04


bump

Response to problem with code 2008-03-19 14:03:32


At 3/19/08 12:35 PM, Da-Hui-58 wrote: if (health=0) {

if(health == 0){

Now stop bumping.


MY E-PENIS IS BIGGER THAN YOURS

8=================================>

...and this is my fag...

BBS Signature

Response to problem with code 2008-03-19 14:05:08


stop();
var health:Number = 50;
var score:Number = 0;
onEnterFrame = function():Void {
if (health<=0) {
gotoAndStop("dead",1);
onEnterFrame = null;
}
}

Lol, Flash regs ;)


BBS Signature

Response to problem with code 2008-03-19 14:08:16


My bad, forgot the onEnterFrame. By the way, use GuyWithHisComp's, since he spent real time rewriting your whole code. You should be pretty thankful. You know you made DeltaLuca throw up?


MY E-PENIS IS BIGGER THAN YOURS

8=================================>

...and this is my fag...

BBS Signature

Response to problem with code 2008-03-19 18:35:22


At 3/19/08 02:05 PM, GuyWithHisComp wrote: stop();
var health:Number = 50;
var score:Number = 0;
onEnterFrame = function():Void {
if (health<=0) {
gotoAndStop("dead",1);
onEnterFrame = null;
}
}

Lol, Flash regs ;)

Put the code in and checked syntax and got like 5 errors :(

Response to problem with code 2008-03-19 18:38:35


Could you show us the errors? And if you stuck it in a movieclip, don't even bother posting.


MY E-PENIS IS BIGGER THAN YOURS

8=================================>

...and this is my fag...

BBS Signature

Response to problem with code 2008-03-19 18:43:49


Scene=level1, Layer=Layer 6, Frame=1: Line 4: '{' expected
onEnterFrame = function():Void {

Scene=level1, Layer=Layer 6, Frame=1: Line 9: Unexpected '}' encountered
}

Response to problem with code 2008-03-19 18:48:45


1....2....wait, I'm trying to get to 5....
That's one error, and it didn't show up when I stuck it in. Replace the onEnterFrame = function ():Void { with function onEnterFrame () { and see if it works. AS2 or 3?


MY E-PENIS IS BIGGER THAN YOURS

8=================================>

...and this is my fag...

BBS Signature

Response to problem with code 2008-03-19 18:52:45


There's no error in the code I posted.
Use ActionScript 2.0 and put the code on the frame and it'll work.


BBS Signature

Response to problem with code 2008-03-19 18:52:52


At 3/19/08 06:48 PM, El-Presidente wrote: 1....2....wait, I'm trying to get to 5....
That's one error, and it didn't show up when I stuck it in. Replace the onEnterFrame = function ():Void { with function onEnterFrame () { and see if it works. AS2 or 3?

I got Flash MX so I think its AS2, also, the code didn't work, it just sends me straight to the "dead" scene as it sets my health at 0 from the start. What I need is it to stay at 50, and go down to 0 (I've got it working except going to the scene)

Response to problem with code 2008-03-19 19:10:23


Every time your health changes, check to see if it's under zero. If so, die. You don't need to check every frame unless you think your health will be changing every frame...

function hit( damage:Number ): Void
health -= damage;
if ( health <= 0 )
{
gotoAndStop( "dead" );
}
}


Flash Game Development Blog: { P I X E L W E L D E R S } | Coming soon: OS Wars: Winvasion!

BBS Signature

Response to problem with code 2008-03-22 11:52:22


At 3/19/08 07:10 PM, Pixelwelder wrote: Every time your health changes, check to see if it's under zero. If so, die. You don't need to check every frame unless you think your health will be changing every frame...

function hit( damage:Number ): Void
health -= damage;
if ( health <= 0 )
{
gotoAndStop( "dead" );
}
}

AS 2.0 don't work in MX.

OP - here's MANY tips.
- frame code only executes when that frame is reached. Not continuously if it's stopped on that frame.
- 'onClipEvent(enterFrame)' is something you could use. I often have a 'controller' MC because I'm old-school.
- Learn patience
- learn that results often require work to be done by you.