A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: If condition with multiple (and different kinds) variables?

  1. #1
    Senior Member
    Join Date
    Jul 2003
    Posts
    119

    If condition with multiple (and different kinds) variables?

    Hey, i have the basics down with variables and the if condition but now im having trouble with a script that combines some different things.

    Basically i have these variables in the actionscript of a frame

    left = 4;

    classwizard = 0;
    classfighter = 0;
    classthief = 0;

    its basically for an RPG character creator thing, the left points are attributes which are distributed amongst stats and the classes are what class you choose. Whenever you choose a class it goes to 1 and the others 0, so far so good no problem.

    Now what i want is a button that goes to one frame if left = 0 (so that you have all your stats out) and that either classwizard, classfighter or classthief is 1 (anyone of the three will do), plus here is the tricky part: an input variable called name (where you put in your character name) this can be anything just as long as its not empty, and another frame if these conditions are not met.

    The end result will be a button that jumps to the game when you're done with your character or will jump to a frame that tells you that you have to choose a class and spend your attribute points.

    Basically

    If inputvariable name has something in it(isn't blank) & left = 0; & classwizard, classfighter or classthief =1 gotoandplay "next"
    or else
    gotoandplay "notdone"

    How is this script supposed to look ?
    Last edited by n00belator; 04-26-2012 at 07:03 PM.

  2. #2
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    276
    You could write it like that, i'm sure there's a more efficient way to write it but this is just easier to read and simpler. Nested IF and ELSE statements.

    Code:
    if(playername != null){
       if(left == 0){
          if(class != null){
             gotoAndPlay("nextFrame");
          }else{
             gotoAndStop("classFrame");
          }
       }else{
          gotoAndStop("leftFrame");
       }
    }else{
       gotoAndStop("nameFrame");
    }
    Last edited by Steven FN; 04-27-2012 at 01:59 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center