if - AS2

Subscribe to if - AS2 10 posts

avatar for Hahaitwork Hahaitwork 52 posts
Flag Post

I do assume the problem is the 2x IF and no else statment maybe?

Key.addListener(this);

function onKeyDown ():Void
{
        if (Key.getCode() == Key.SPACE )
        {
			if (_root.counter == 1) {
			
                var bomb:MovieClip = attachMovie("bomb", "", getNextHighestDepth());
                bomb._x = _root.player._x;
                bomb._y = _root.player._y;
			}
        }
}
 
avatar for NineFiveThree NineFiveThree 1378 posts
Flag Post

If you’re not saying what you want to achieve nobody can help you with a sloppy help request like yours.
You didn’t even format the code properly.

If you do not know whether an else statement is mandatory after an if statement or not, working with user input and adding things to the display is far ahead of your skills.

Don’t dance if you can’t walk.

 
avatar for saybox saybox 2675 posts
Flag Post

Worked when I tested it, though that was with some editing to fix the Kong formatting. Try tracing to make sure that counter is 1 and the conditional is running correctly, first.

 
avatar for Hahaitwork Hahaitwork 52 posts
Flag Post
Originally posted by NineFiveThree:

If you’re not saying what you want to achieve nobody can help you with a sloppy help request like yours.
You didn’t even format the code properly.

If you do not know whether an else statement is mandatory after an if statement or not, working with user input and adding things to the display is far ahead of your skills.

Don’t dance if you can’t walk.

Well, I love to learn it this way, it makes it stick in my head alot better.. I’m not a pro in flash, and I do it for the fun.
A forum is to help people out and give ideas, there is no need to comment about anothers flash skills or not.

- saybox, I’m 100% sure the counter is 1, but I just noticed something wrong in the script, will take another test later tonight as I got a bad headache atm.
Thx for the reply tho :D tracing was a good idea tho

 
avatar for Hahaitwork Hahaitwork 52 posts
Flag Post
Originally posted by NineFiveThree:

If you’re not saying what you want to achieve nobody can help you with a sloppy help request like yours.
You didn’t even format the code properly.

If you do not know whether an else statement is mandatory after an if statement or not, working with user input and adding things to the display is far ahead of your skills.

Don’t dance if you can’t walk.

There, Now it’s in a box!
- Will remember that from now.

 
avatar for Hahaitwork Hahaitwork 52 posts
Flag Post
Originally posted by saybox:

Worked when I tested it, though that was with some editing to fix the Kong formatting. Try tracing to make sure that counter is 1 and the conditional is running correctly, first.

Made it work now actually, it was my bad but I did not notice I had the wrong path to the counter :)
Thx for opening my eyes.
Will try to be sure on the path next time for sure, but yeah all other code was on maintime line and not this counter, so I forgot all about the small path I had to write.
Hope ppl don’t facepalm to much
-thx.
Atleast I wrote what was wronge.. not everyone is writing how they made it work.

 
avatar for NineFiveThree NineFiveThree 1378 posts
Flag Post
Originally posted by Hahaitwork:

There, Now it’s in a box!

thanks.

Originally posted by Hahaitwork:
Hope ppl don’t facepalm to much

I actually told you that placing _root everywhere will not necessarily fix your problems.
Where did you define the variable?
Consider writing a class for whatever spawns the bombs.

 
avatar for Hahaitwork Hahaitwork 52 posts
Flag Post

The text aka the counter is place in the cam in that level, so.. I wrote _root.cam.counter == 1
I forgot it was placed inside the cam MC.

 
avatar for NineFiveThree NineFiveThree 1378 posts
Flag Post
Originally posted by Hahaitwork:

The text aka the counter

You should not use the “variable” of a TextField.
Instead use the instance name and apply the .text property.

The TextField should not hold the variable, it’s purpose is to display it.
Create the variable in the class it belongs into, which depends on what that counter is counting.

 
avatar for Hahaitwork Hahaitwork 52 posts
Flag Post
Originally posted by NineFiveThree:
Originally posted by Hahaitwork:

The text aka the counter

You should not use the “variable” of a TextField.
Instead use the instance name and apply the .text property.

The TextField should not hold the variable, it’s purpose is to display it.
Create the variable in the class it belongs into, which depends on what that counter is counting.

no.. it is a Var of course and I use a textfield to display it.
But only for this level it is a bit special in diffrent to rest of my lvls.