Monday, 29 December 2008

Using input text 2

This Flash tutorial is a continuation of the previous input text tutorial. This time I will add error checking and character limitation to the input text questionnaire. I will be checking whether an input text field in empty and limiting the number of characters in the input field.

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.


dsa 26 August 2009 at 13:44  

Ok this works fine,
how about if I want to change the appearance of the display dynamic text, color, font, maybe rotate it... this doesn't work when I try to change the dynamic fields in any way.

iliketo 29 August 2009 at 10:27  


Changing dynamic text is the same as changing static text. Simply select the dynamic text field and change the various settings.

lizardsplash 19 May 2010 at 10:29  

hi there,
In the sample when the user lands on scene 2- the fields no longer look like dynamic input text but static. How is that so? I do not see any code that says to change submitted data to static text?

iliketo 20 May 2010 at 10:33  


Take a look at part 1 of the tutorial.

  COPYRIGHT © 2014 · ILIKE2FLASH · Theme by Ourblogtemplates

Back to TOP