First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
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;
stop();

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:

Stop();

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

On(release){
If(Name.text eq “Neo”){
GotoAndStop(“correct”);
}else
{
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!

Comments

  • 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: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
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: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.