Be sure to have completed the previous tutorial before attempting this one
Using input text 2
Step 1
Open your simple questionnaire file.
Select the text tool (T) with dynamic text selected and drag a rectangle shape like below:

If you have no space on the stage, you can adjust the stage size by selecting Modify > Document and changing the size of the stage.
Step 2
Using the selection tool (V) select the dynamic text field and give it an instance name: answer_txt. I change the text fill colour to red to make the text standout. You can choose whatever colour you wish.

Step 3
Again using the selection tool (V) select each of the input text fields in turn and give them the instance names: input1_txt, input2_txt, and input3_txt respectively.

Step 4
On the timeline select the actions layer and right click on the 1st frame and select Actions and add the following code:
1. stop();
2. input1_txt.maxChars = 15;
3. input2_txt.maxChars = 15;
4. input3_txt.maxChars = 15;
5. sub_btn.onRelease = function() {
6. if (input1_txt.text == "") {
answer_txt.text = "Please enter favourite drink";
7. } else if (input2_txt.text == "") {
answer_txt.text = "Please enter favourite food";
8. } else if (input3_txt.text == "") {
answer_txt.text = "Please enter favourite colour";
9. } else {
gotoAndStop("Scene 2", 1);
10. }
11. };
**Line 1, stops the current scene from going to the next scene.
Line 2-4, limits the number of character in each of the three text fields to 15 characters. You can set this number to whatever you wish.
Line 6 -7, if the input text fields are empty the respective message appears on the dynamic text field (answer_txt).
Line 9, if all the text fields are not empty then it can proceed to the next scene.
Step 5
Test your movie Ctrl + Enter. Try leaving a text field empty you should notice a message and notice the text field are limited to 15 characters.
Feel free to contact me for any questions or comments.








0 comments:
Post a Comment
Welcome to ilike2flash! If you like this post you can subscribe here to get updates via RSS or opt to have them sent directly to your inbox .
I appreciate your feedback, so please feel free to comment.