A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Check variables entries

  1. #1
    Senior Member
    Join Date
    Jan 2003
    Location
    @Home
    Posts
    104

    Check variables entries

    Hi,
    I have a form where I have two results variables.
    Example: variable a = user types his name
    variable b = user types how old he is

    Then, I need a code that checks this two variables like:
    if (name == "Joe" && age == "20")
    gotoandplay ("scene"","frame number/label")
    Is that supposed to work? I mean, can I check two variables at once like what I´m trying to do???
    Please help!!!!!!!!!!
    ====================
    I love this forum!!!
    Pilot_22
    ====================

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    assuming the variables are on the current timeline, then you can use,

    if (name == "Joe" && age == "20") {

    }

    to test if the user entered Joe as the name and 20 as the age, note if the user entered joe and 20 it would not work. maybe a you could use a function to check the name entered,

    Code:
    function checkStringEquality(str1, str2) {
        if (str1.toLowerCase() == str2.toLowerCase()) {
            return true;
        }
        return false;
    }
    if (checkStringEquality(name, "Joe") && age == "20") {

    }

    It's also not a good idea to use scene names in gotoAndPlay actions instead just place frame labels on the frames you need to target and use
    gotoAndPlay("framelabel");

  3. #3
    Senior Member
    Join Date
    Jan 2003
    Location
    @Home
    Posts
    104
    catbert303 or anybody else,
    Thank you for your support, I just got a few more questions about your reply.
    1) I'm going to have a list box menu with some countries in it. This is for the origin country.
    2) I'll have another list box menu with the same countries, but this is for the destination country.
    The user chooses the origin country and its name is shown in a confirmation text variable (dynamic text box) such as:
    Origin country: United States
    Then, the user chooses the destination country and its name is also shown in another dynamic text field like:
    Destination Country: Spain
    I already have that part ready. Now I need a funcion (actionscript) that would taje the user to the RIGHT scene to calculate the price to send something from United States to Spain (from origin to destination). I have all the scenes ready, just need the script that understands that:
    if origin = united states and destination = spain, take the user to "scenexx"
    Did you understand??? Please help me.
    More information:
    Everything is on the same timeline (there are no movie clips in this scene).
    Feel free to ask anything you may need to help me out.
    God bless you, my friend!
    ====================
    I love this forum!!!
    Pilot_22
    ====================

  4. #4
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    I think the easiest way to do this is using carefully named frame labels, say for the scene to display where the user selected Origin united states and destination spain give the first frame the frame label,

    united states_spain

    you can then dynamically create a variable to go to this frame, like,

    on (press) {
    frame = origin + "_" + destination;
    gotoAndPlay(frame);
    }

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