First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Ori Cohen
The If Statement

The if statement is one of the most powerful tools to action scripting, if it weren’t for if statements applications and games would run the exact same way every time.

What we will do is create an application that asks for the user name. If provided correctly it greets you.
First thing you should do is create a layer and call it Text. In this layer put in a label that says Name:

After doing this create another label and turn it into an input box. To do this open up its properties and change it from Static Text to Input Text. Then change the Instance name to Name.
Finally, create a label that says Please Try Again. Change it to Dynamic Text and change the Instance name to wrong. After doing that create a button with an enter caption on it. After doing this create a new layer called Actions. Open up the actions for the first frame of the Actions frame and type in:

strName = “Neo”;
wrong._visible = false;

This creates a new variable called strName, makes the wrong label invisible, and tells the movie to stop.

Now create a new key frame and delete the button and the two text boxes. Then change the text on the wrong label to say Hello, Neo

Click on the frame and change the frame name to correct

Now open up the Actions frame and type in:


Now go back to the first frame and open up the actions for the button. Type in:

If(Name.text eq “Neo”){
wrong._visible = false;

You can now run the movie, and everything should work.

Final Note: if you’re making a comparison using words you need to use the eq command, while if you’re comparing numbers you use the == command. Expect a more advanced tutorial to follow.

» Level Basic

Added: 2003-03-01
Rating: 3 Votes: 9
(10 being the highest)
» Author
14 year old guy
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.