Forum Topic: Help!!

(174 views • 23 replies)

This topic is 1 page long.

<< < > >>
None

kris008

Reply To Post Reply & Quote

Posted at: 11/23/08 04:02 PM

kris008 DARK LEVEL 10

Sign-Up: 05/11/07

Posts: 587

How come this code works at taking -5 health away:

onClipEvent (enterFrame)
{
if (this.hitTest(_root.fish))
_root.health.text = _root.health.text - 5;}

but this code for adding 10 health dont:

onClipEvent (enterFrame)
{
if (this.hitTest(_root.fish))
_root.health.text = _root.health.text + 10;}

instead of adding +10 like ...40...50...60 it does this instead ...40....4010....401010.....40101010

help plz

and secondly why dont this code work?
onClipEvent (enterFrame)
{
if (this.hitTest(_root.fish))
_root.heart (visible = false)}

thx in advance


Happy

Spaltzer

Reply To Post Reply & Quote

Posted at: 11/23/08 04:34 PM

Spaltzer NEUTRAL LEVEL 15

Sign-Up: 06/29/08

Posts: 103

You're attaching "10" to a string variable. You're not adding 10 to a number. You need to make a variable, and make Health.text = the numerical variable. Increase the variable, don't add a one and a zero to the text. Make sense?


None

Magical-Zorse

Reply To Post Reply & Quote

Posted at: 11/23/08 04:36 PM

Magical-Zorse FAB LEVEL 21

Sign-Up: 05/10/08

Posts: 2,547

Basically, put += 10 instead of + 10

.

BBS Signature

None

kris008

Reply To Post Reply & Quote

Posted at: 11/23/08 04:41 PM

kris008 DARK LEVEL 10

Sign-Up: 05/11/07

Posts: 587

At 11/23/08 04:36 PM, Magical-Zorse wrote: Basically, put += 10 instead of + 10

that diddnt work still just put 10 on the end instead of adding it.
abd no the previous explination diddnt help i understand but i dont know how to do it


None

kris008

Reply To Post Reply & Quote

Posted at: 11/23/08 05:28 PM

kris008 DARK LEVEL 10

Sign-Up: 05/11/07

Posts: 587


None

CrustySheet

Reply To Post Reply & Quote

Posted at: 11/23/08 05:47 PM

CrustySheet LIGHT LEVEL 03

Sign-Up: 05/03/06

Posts: 534

healthVar = 10;
onClipEvent (enterFrame)
{
if (this.hitTest(_root.fish))

_root.health.text +=healthVar;}

when you add +10 to a string its like adding to a chat

if i say hi then add 10 its hi10


None

kris008

Reply To Post Reply & Quote

Posted at: 11/23/08 05:55 PM

kris008 DARK LEVEL 10

Sign-Up: 05/11/07

Posts: 587

At 11/23/08 05:47 PM, CrustySheet wrote: healthVar = 10;
onClipEvent (enterFrame)
{
if (this.hitTest(_root.fish))

_root.health.text +=healthVar;}

when you add +10 to a string its like adding to a chat

if i say hi then add 10 its hi10

diddnt work instead of adding 10 on the health number just turned to the word 'NAN' watever that means


None

CrustySheet

Reply To Post Reply & Quote

Posted at: 11/23/08 05:58 PM

CrustySheet LIGHT LEVEL 03

Sign-Up: 05/03/06

Posts: 534

it will work so obviously you done something wrong

have you made it a dynamic textbox?
if not do it and put in where it says Variable healthVar


None

kris008

Reply To Post Reply & Quote

Posted at: 11/23/08 05:59 PM

kris008 DARK LEVEL 10

Sign-Up: 05/11/07

Posts: 587

At 11/23/08 05:47 PM, CrustySheet wrote: healthVar = 10;

shouldnt it be somthin like:
health.var = 10;
?


None

CrustySheet

Reply To Post Reply & Quote

Posted at: 11/23/08 06:06 PM

CrustySheet LIGHT LEVEL 03

Sign-Up: 05/03/06

Posts: 534

healthVar is a new Variable which equels 10


None

kris008

Reply To Post Reply & Quote

Posted at: 11/23/08 06:07 PM

kris008 DARK LEVEL 10

Sign-Up: 05/11/07

Posts: 587

well the code u gave still just puts 10 onto the end


None

CrustySheet

Reply To Post Reply & Quote

Posted at: 11/23/08 06:09 PM

CrustySheet LIGHT LEVEL 03

Sign-Up: 05/03/06

Posts: 534

ok then try this

healthVar = 10;
onClipEvent (enterFrame)
{
if (this.hitTest(_root.fish))
healthVar +=10;
_root.health.text =healthVar;}

None

kris008

Reply To Post Reply & Quote

Posted at: 11/23/08 06:30 PM

kris008 DARK LEVEL 10

Sign-Up: 05/11/07

Posts: 587

that just set the number to just 10 so still dont work


None

CrustySheet

Reply To Post Reply & Quote

Posted at: 11/23/08 06:34 PM

CrustySheet LIGHT LEVEL 03

Sign-Up: 05/03/06

Posts: 534

then you have it set up wrong cos i tested it and they work no problem at all


None

kris008

Reply To Post Reply & Quote

Posted at: 11/23/08 06:44 PM

kris008 DARK LEVEL 10

Sign-Up: 05/11/07

Posts: 587

wat version flash u test it in? cuz im using flash 8


None

CrustySheet

Reply To Post Reply & Quote

Posted at: 11/23/08 06:49 PM

CrustySheet LIGHT LEVEL 03

Sign-Up: 05/03/06

Posts: 534

as am i
just put a textbox out there give an "INSTANCE" name of health not a variable name a Instance name of health and put that code on the frame on the maintimeline thats all i did and it works


None

kris008

Reply To Post Reply & Quote

Posted at: 11/23/08 06:53 PM

kris008 DARK LEVEL 10

Sign-Up: 05/11/07

Posts: 587

but thats exactly what ive done and it makes the health just go to '10' instead of increasing by '10' so if it starts on 500 it just goes instantly to 10 with that code you gave me.


None

CrustySheet

Reply To Post Reply & Quote

Posted at: 11/23/08 06:55 PM

CrustySheet LIGHT LEVEL 03

Sign-Up: 05/03/06

Posts: 534

well then change the healthVar =10 to healthVar = 500


None

kris008

Reply To Post Reply & Quote

Posted at: 11/23/08 06:59 PM

kris008 DARK LEVEL 10

Sign-Up: 05/11/07

Posts: 587

At 11/23/08 06:55 PM, CrustySheet wrote: well then change the healthVar =10 to healthVar = 500

ya but now everytime you get hit health just keeps resetting back to 500...i really dont think that code is going to work...atleast how i want it to work.


None

CrustySheet

Reply To Post Reply & Quote

Posted at: 11/23/08 07:03 PM

CrustySheet LIGHT LEVEL 03

Sign-Up: 05/03/06

Posts: 534

sounds to me like you have the healthVar in the enterframe part

you dont want it in the enterframe make sure it is not in any enterframe otherwise it will reset it to 500 eveyr frame
put it as the very very very first line of the code


None

kris008

Reply To Post Reply & Quote

Posted at: 11/24/08 05:09 AM

kris008 DARK LEVEL 10

Sign-Up: 05/11/07

Posts: 587

dont work any1 else?


None

kris008

Reply To Post Reply & Quote

Posted at: 11/24/08 05:53 AM

kris008 DARK LEVEL 10

Sign-Up: 05/11/07

Posts: 587

At 11/23/08 07:03 PM, CrustySheet wrote: sounds to me like you have the healthVar in the enterframe part

you dont want it in the enterframe make sure it is not in any enterframe otherwise it will reset it to 500 eveyr frame
put it as the very very very first line of the code

if its not i get this error

**Error** Scene=Scene 1, layer=health, frame=3:Line 2: Statement must appear within on/onClipEvent handler
healthVar = 10;

Total ActionScript Errors: 1 Reported Errors: 1


None

CrustySheet

Reply To Post Reply & Quote

Posted at: 11/24/08 06:09 AM

CrustySheet LIGHT LEVEL 03

Sign-Up: 05/03/06

Posts: 534

onClipEvent(load);{
healthVar = 10;
}


None

iamgrimreaper

Reply To Post Reply & Quote

Posted at: 11/24/08 06:16 AM

iamgrimreaper EVIL LEVEL 06

Sign-Up: 08/22/07

Posts: 1,622

simple. Parse the string into an integer.

onClipEvent (enterFrame)
{
if (this.hitTest(_root.fish))
_root.health.text = parseInt(_root.health.text) + 10;}

I don't get what you're trying to do here:
onClipEvent (enterFrame)
{
if (this.hitTest(_root.fish))
_root.heart (visible = false)}

When it's party time, we PARTY!
Tankmen Day Petition!

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 12:47 PM

<< Back

This topic is 1 page long.

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