The if statement is one of the most powerful tools to action scripting, if it werent 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 youre making a comparison using
words you need to use the eq command, while if youre comparing numbers
you use the == command. Expect a more advanced tutorial to follow.
| » Level Basic |
|
Added: 2003-03-01 Rating: 3 Votes: 9 |
| » Author |
| 14 year old guy |
| » Download |
| Download the files used in this tutorial. |
| Download (0 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


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