-
Very quick if statement question.
Hi I have a very quick question about writing if statements.
When the user clicks a button I want h1 and h2 to either appear or dissapear depending on their current state, I can get just one to work (i.e. h1 on its own) but I don't know the correct syntax for two or even three variables. I've shown my code below, as you can see I thought a comma might work to separate the values but it doesn't.
code:
on (release) {
if (h1,h2._visible) {
h1,h2._visible = false;
} else {
h1,h2._visible = true;
}
}
Last edited by jbum; 10-01-2004 at 01:57 PM.
-
code:
on (release) {
if (h1._visibility && h2._visibility) {
h1._visibility, h2._visibility = false;
} else {
h1._visibility, h2._visibility = true;
}
}
Last edited by jbum; 10-01-2004 at 01:57 PM.
If computer games affected us, would I not be running into walls popping strange yellow pills and listening to repetitive music?
-
That doesn't work mate. I assume you meant _visible instead of _visibility. Anyway I tried both methods and neither worked. Any more ideas on this one, I know its only a small thing, but I don't know the proper syntax in ActionScript.
-
code:
on (release) {
if (h1._visible == true && h2._visible == true) {
h1._visible, h2._visible = false;
} else {
h1._visible, h2._visible = true;
}
}
EDIT: Edited some of the posts in this thread to use as tags - jbum
Last edited by jbum; 10-01-2004 at 01:58 PM.
If computer games affected us, would I not be running into walls popping strange yellow pills and listening to repetitive music?
-
Senior Member
In my version of flash (MX 2004) the following code does not work:
code:
// BROKEN!!
x,y = 5;
trace(x);
trace(y);
If you do the above, y will be equal to 5, but x will be undefined. This implies that the example shown above, also using a comma, will also not work.
The following does work, however:
code:
x = y = 5;
trace(x);
trace(y);
As does this:
code:
x = 5;
y = 5;
trace(x);
trace(y);
Personally, I would go with that last method - it's clearest. However, if you really want to save typing a few characters, at the expense of a little readability, by all means try this:
code:
on (release) {
if (h1._visible == true && h2._visible == true) {
h1._visible = h2._visible = false;
} else {
h1._visible = h2._visible = true;
}
}
-
Monkey Moderator
if all you are doing is toggling the visibility then there is no need for an if statement anyway...
code:
on(release){
h1._visible = h2._visible = !h1._visible;
}
www.lexicon-design.co.uk
If we aren't supposed to eat animals, then why are they made of meat?
If Vegetarians like animals so much, why do they eat all their food?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|