if statement and visible statement dont work but the things inside it work? ACTIONSCRIPT 3

64 Views Asked by At

Yeah so here's my code

if(defaultmeter.visible = true)
{
meter1.visible = true;
meter1.x = 124.10;
meter.y = 63.10;
jizz.visible = false;
}

Thing is the things inside the { } work but the the if statement doesnt apply Like when defaultmeter is not visible, the stuff inside the {} still applies :C help please

3

There are 3 best solutions below

0
On

If you do mc.visible = true so you assign the true value to mc.visible so you make mc visible which normally always true.

To compare in this level, we use == (equal) operator to check if two values are equal or the != (not equal, different ) to check if two values are not equal.

So in your case you can do :

if(defaultmeter.visible == true){
    // instructions here
}

Or

if(defaultmeter.visible != false){
    // instructions here
}

Or simply

if(defaultmeter.visible){
    // instructions here
}
0
On

Well of course, you need to cover the other case as well, like this:

if(defaultmeter.visible == true)
{
    meter1.visible = true;
    meter1.x = 124.10;
    meter.y = 63.10;
    jizz.visible = false;
}else{
    meter1.visible = false;
    jizz.visible = true; //btw, jizz, seriously?
    ...
}
1
On

use like this if (defaultmeter.visible == true){}