Forum Topic: Godammit, comparing variables...

(105 views • 15 replies)

This topic is 1 page long.

<< < > >>
Misunderstood

squidly

Reply To Post Reply & Quote

Posted at: 5/27/09 11:20 AM

squidly EVIL LEVEL 20

Sign-Up: 02/16/07

Posts: 4,321

Why is it impossible to do ask if the number is larger then the variable?
I've tried it all!

if (1990> this._parent.healthb){
nextFrame();
}

Doesn't work

if (this._parent.healthb< 1990 ){
nextFrame();
}

Doesn't work

if (this._parent.healthb<1990 ){
nextFrame();
}

Doesn't work

if (this._parent.healthb<= 1990 ){
nextFrame();
}

Doesn't work...

God, how do I do this?
This is frustrating me...
Don't tell me it's impossible, please don't tell me it's impossible...

It's the only way out!
Contraversal::C&C::FAIL::Idiot Pm's

BBS Signature

None

WolfAkela

Reply To Post Reply & Quote

Posted at: 5/27/09 11:24 AM

WolfAkela LIGHT LEVEL 08

Sign-Up: 12/19/05

Posts: 2,324

Try tracing instead of anything else to check whenever a condition is met?

if (condition){
trace("omfg true");
}

Trace your variables as well to ensure that you're reading them properly.

trace(this._parent.healthb);

None

Saza

Reply To Post Reply & Quote

Posted at: 5/27/09 11:25 AM

Saza LIGHT LEVEL 15

Sign-Up: 10/01/05

Posts: 1,895

Well then it means something wrong with the this._parent.health and not the way your writing it.


None

Toast

Reply To Post Reply & Quote

Posted at: 5/27/09 11:25 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,907

At 5/27/09 11:20 AM, squidly wrote: Don't tell me it's impossible, please don't tell me it's impossible...

Open up a new flash document and type the following:

a = 1;
trace(a>5);

then come back and tell us if it's impossible.

Obviously whatever's wrong with your flash project is not something we can find out by reading your post. Either your variable names are wrong, there is no nextFrame in "this.", or some other parts of your code cause this to not work.


None

squidly

Reply To Post Reply & Quote

Posted at: 5/27/09 11:29 AM

squidly EVIL LEVEL 20

Sign-Up: 02/16/07

Posts: 4,321

The thing is, if I do this:

if (this._parent.healthb> 1990 ){
nextFrame();
}

It's all fine, works like a charm.

It's the only way out!
Contraversal::C&C::FAIL::Idiot Pm's

BBS Signature

None

Saza

Reply To Post Reply & Quote

Posted at: 5/27/09 11:33 AM

Saza LIGHT LEVEL 15

Sign-Up: 10/01/05

Posts: 1,895

At 5/27/09 11:29 AM, squidly wrote: The thing is, if I do this:

if (this._parent.healthb> 1990 ){
nextFrame();
}

It's all fine, works like a charm.

Then that obviously means healthb is bigger than 1990. Thats why it didnt work before because it wasnt smaller.


None

squidly

Reply To Post Reply & Quote

Posted at: 5/27/09 11:43 AM

squidly EVIL LEVEL 20

Sign-Up: 02/16/07

Posts: 4,321

At 5/27/09 11:33 AM, Saza wrote:
At 5/27/09 11:29 AM, squidly wrote: The thing is, if I do this:

if (this._parent.healthb> 1990 ){
nextFrame();
}

It's all fine, works like a charm.
Then that obviously means healthb is bigger than 1990. Thats why it didnt work before because it wasnt smaller.

...
I made healthb smaller.
I'm not stupid, you know.

It's the only way out!
Contraversal::C&C::FAIL::Idiot Pm's

BBS Signature

None

squidly

Reply To Post Reply & Quote

Posted at: 5/27/09 11:50 AM

squidly EVIL LEVEL 20

Sign-Up: 02/16/07

Posts: 4,321

Oh, ok, found the problem, but it leads to another question.
You see, on a seperate MC I did this:

this.healthb = 2000

For some reason, that makes it so that the code is invalid if the variable goes down later on, after the initial load...

As in:

this.healthb = 1980

The code will work, but, if I subratcted 20 from 2000, then it won't work, anyone know why is this so?

By the way, the code in the OP is on a frame.

It's the only way out!
Contraversal::C&C::FAIL::Idiot Pm's

BBS Signature

None

A-star

Reply To Post Reply & Quote

Posted at: 5/27/09 12:01 PM

A-star DARK LEVEL 04

Sign-Up: 12/16/07

Posts: 64

use the instance name of the MC that defined the Variable, not "this".


None

squidly

Reply To Post Reply & Quote

Posted at: 5/27/09 12:09 PM

squidly EVIL LEVEL 20

Sign-Up: 02/16/07

Posts: 4,321

At 5/27/09 12:01 PM, A-star wrote: use the instance name of the MC that defined the Variable, not "this".

It's not a variable, it's dynamic text.

It's the only way out!
Contraversal::C&C::FAIL::Idiot Pm's

BBS Signature

None

Saza

Reply To Post Reply & Quote

Posted at: 5/27/09 12:13 PM

Saza LIGHT LEVEL 15

Sign-Up: 10/01/05

Posts: 1,895

Do you have your if(healthb> whatever) on an EnterFrame function? Otherwise it'll run just once.


None

Toast

Reply To Post Reply & Quote

Posted at: 5/27/09 12:35 PM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,907

At 5/27/09 12:09 PM, squidly wrote:
At 5/27/09 12:01 PM, A-star wrote: use the instance name of the MC that defined the Variable, not "this".
It's not a variable, it's dynamic text.

What?


None

squidly

Reply To Post Reply & Quote

Posted at: 5/27/09 12:39 PM

squidly EVIL LEVEL 20

Sign-Up: 02/16/07

Posts: 4,321

At 5/27/09 12:13 PM, Saza wrote: Do you have your if(healthb> whatever) on an EnterFrame function? Otherwise it'll run just once.

Wait, what?
Oh snap, I didn't, how do you use an EnterFrame function?
What has to be the "on," as in, onClipEvent...

It's the only way out!
Contraversal::C&C::FAIL::Idiot Pm's

BBS Signature

None

Saza

Reply To Post Reply & Quote

Posted at: 5/27/09 12:41 PM

Saza LIGHT LEVEL 15

Sign-Up: 10/01/05

Posts: 1,895

At 5/27/09 12:39 PM, squidly wrote:
At 5/27/09 12:13 PM, Saza wrote: Do you have your if(healthb> whatever) on an EnterFrame function? Otherwise it'll run just once.
Wait, what?
Oh snap, I didn't, how do you use an EnterFrame function?
What has to be the "on," as in, onClipEvent...

If its on the frame do:

onEnterFrame = function(){
//your if statement
}

on a movieclip:

onClipEvent(enterFrame){
//your if statement
}

None

squidly

Reply To Post Reply & Quote

Posted at: 5/27/09 01:07 PM

squidly EVIL LEVEL 20

Sign-Up: 02/16/07

Posts: 4,321

NOW it works, thanks.

It's the only way out!
Contraversal::C&C::FAIL::Idiot Pm's

BBS Signature

None

Saza

Reply To Post Reply & Quote

Posted at: 5/27/09 01:08 PM

Saza LIGHT LEVEL 15

Sign-Up: 10/01/05

Posts: 1,895

At 5/27/09 01:07 PM, squidly wrote: NOW it works, thanks.

No problem


All times are Eastern Standard Time (GMT -5) | Current Time: 12:30 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!