To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Search this Thread Display Modes
Old 10-01-2004, 11:55 AM   #1
flamingmongrel
Junior Member
 
Join Date: Apr 2003
Location: UK
Posts: 14
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 02:57 PM.
flamingmongrel is offline   Reply With Quote
Old 10-01-2004, 12:06 PM   #2
frozenfire89
Senior Member
 
Join Date: Jul 2004
Location: In a box outside of Safeway
Posts: 201
code:

on (release) {
if (h1._visibility && h2._visibility) {
h1._visibility, h2._visibility = false;
} else {
h1._visibility, h2._visibility = true;
}
}

__________________
If computer games affected us, would I not be running into walls popping strange yellow pills and listening to repetitive music?

Last edited by jbum; 10-01-2004 at 02:57 PM.
frozenfire89 is offline   Reply With Quote
Old 10-01-2004, 12:31 PM   #3
flamingmongrel
Junior Member
 
Join Date: Apr 2003
Location: UK
Posts: 14
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.
flamingmongrel is offline   Reply With Quote
Old 10-01-2004, 02:55 PM   #4
frozenfire89
Senior Member
 
Join Date: Jul 2004
Location: In a box outside of Safeway
Posts: 201
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
__________________
If computer games affected us, would I not be running into walls popping strange yellow pills and listening to repetitive music?

Last edited by jbum; 10-01-2004 at 02:58 PM.
frozenfire89 is offline   Reply With Quote
Old 10-01-2004, 03:48 PM   #5
jbum
Senior Member
 
jbum's Avatar
 
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
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;
}
}

__________________
jbum is offline   Reply With Quote
Old 10-01-2004, 03:54 PM   #6
Lexicon
Monkey Moderator
 
Lexicon's Avatar
 
Join Date: Jul 2001
Location: UK
Posts: 2,038
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?
Lexicon is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:25 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.