Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

Closed Thread
Results 1 to 4 of 4
  1. #1

    Default IF, THEN, =, statements

    How do you use simple statements like IF, THEN, =, in flash? Also how do you use variables.
    for example how would I do this in flash: IF A = 5 THEN...

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    Flash uses an "if/else" method instead of if/then. The format looks like this...
    Code:
    if(some condition == true){
    do something;
    }
    adding an else statement .....
    Code:
    if(some condition == true){
    do something;
    }else if(some other condition== true){
    do something else;
    }
    So, Your demo would look like...
    Code:
    if(A==5){
    execute code here;
    }else{
    execute some other code;
    }
    Now, without going too deeply into methods without confusion, I will simply mention that there is also a shorthand for if/else statements, known as "nested conditionals". Basically shorthand for the code samples posted above...

    condition ? statement : alternative statement;

    A==5 ? trace("A is 5") : trace("A is not 5");


    Hope it helps
    Regards
    NTD

  4. #3

    Default

    Can you have an if statement within an if statement?
    e.g. if (condition) {if (another condition) {do something} }
    the point is to have two conditions. Is there and AND statement?
    e.g. IF A=1 AND B=5 or if (a = 1) and (b = 2) {do something}

  5. #4
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    Yes, you can nest if statements within other if statements. One problem I notice is how your using the = sign. A single equals sign(=) assigns a value. A double equal sign(==) compares a value.
    Code:
    if(a==1 && b==5){
    do something;
    }
    The above requires both conditions to be true before firing the code.

    Code:
    if(a==1){
    if(b==2){
    do something;
    }
    }
    The above is a nested if statement. The first condition must be true or the second if statement wont fire.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. if statements help
    By Ginrikki in forum Flash Scripting
    Replies: 1
    Last Post: 04-06-2005, 11:32 PM
  2. 2 IF/ELSE statements on 1 action - possible?
    By nwaTOT in forum Flash Scripting
    Replies: 7
    Last Post: 03-30-2005, 09:04 PM
  3. If else statements that don't work
    By KingKong in forum Flash Scripting
    Replies: 1
    Last Post: 12-26-2004, 10:12 PM
  4. conditional statements help?
    By krylon in forum Flash Scripting
    Replies: 1
    Last Post: 09-07-2004, 06:48 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial