0% found this document useful (0 votes)
35 views

In Flash PDF File Chapter 11 On Coding Text. by The End of This Learning Module, You Will

This document provides instructions for creating a Flash birthday card that allows the user to type their name, which then appears in the animation. It explains the differences between static, input, and dynamic text fields and how to create each type. It demonstrates how to use an input text field for the user to enter their name, store it in a variable, and display it in a dynamic text field in the animation. The document also provides code examples for creating input and dynamic text fields at runtime using ActionScript.

Uploaded by

Tarik Alkelani
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

In Flash PDF File Chapter 11 On Coding Text. by The End of This Learning Module, You Will

This document provides instructions for creating a Flash birthday card that allows the user to type their name, which then appears in the animation. It explains the differences between static, input, and dynamic text fields and how to create each type. It demonstrates how to use an input text field for the user to enter their name, store it in a variable, and display it in a dynamic text field in the animation. The document also provides code examples for creating input and dynamic text fields at runtime using ActionScript.

Uploaded by

Tarik Alkelani
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Basic Text Manipulation (Resource: Learning actionScript 2.

0 in Flash PDF file


chapter 11 ”Working with Text and Strings” pp. 344-428)

Target audience: High school graduates who have had minimal exposure to
coding using Adobe Flash actionScript and bought you CD as self learners not
associated with any school.

Today is Mikey and Pepino’s birthday and I want to make them a Flash movie birthday
card. When they open it, I want them to type in their name and then navigate to the
animated sequence. How can I do this using Flash actionScript? There are a few
approaches I can take. As we are learning about the difference between static, input,
and dynamic text, I will demonstrate how these three texts can be used effectively to
meet my objective when I create the birthday card. I can have them type in their name
in the opening frame of the flash movie using an input text field. That information is
stored in a variable text string and sent to the appropriate dynamic text field according
to how I code it. See my finished card at the following url.
http://www.cameron.edu/%7Elindas/WHO.htm

At the end of the last Module, you were assigned to read the Learning actionScript 2.0
in Flash PDF file chapter 11 on coding text. By the end of this learning module, you will
be able to:

Explain the difference between static, input, and dynamic text


Create static text
Create input text
Create dynamic text
Use a text Component
Create a scrollbar
Create a swf file that demonstrates a basic mastery of text usage in Flash

You used your text tool to type in static text and adjusted the text height, color, font,
and kerning with the object’s Properties Panel actionScript to create and control
your text properties.

Dr. Linda Wright Smith Simplified Start of a Learning Module Page 1


NOTE: Check Appendix A for Adobe Flash definitions used in this tutorial.

Static text is text that you put in your movie and it remains the same, its content does
not change. You select which text option you want to use in the Properties panel. You
can click on the downward arrow and click on the “Input Text” option in the Properties
panel. When you select this option the movie viewer can type information in that text
field. In my case, I want my friends to type in their name before it goes to the animation
so I used an input text field (See graphic on the next page).

A. Create a simple input text field

1. Select Text Tool


2. Set Properties Panel font, size, color, and show border
3. Click the down arrow to select Input Text
4. Give it an instance name: myName
5. Use the Text Tool to draw your text field on the stage
6. Click ctrl + enter to test your movie
7. Type in the text box to verify that the user can add text

You can also create a dynamic text field. Flash actionScript retrieves data from different
text variables and external sources such as “as” files, and then loads them in the
appropriate dynamic text field.

B. Create a simple dynamic text field

1. Select Text Tool

2. In the Properties Panel set: font, size, color, and show border

3. Click the down arrow to select Dynamic Text

Dr. Linda Wright Smith Simplified Start of a Learning Module Page 2


4. Give it an instance name: getName
5. set the Var to: myName
5. Use the Text Tool to draw your text field on the stage
6. Click ctrl + enter to test your movie

Input
Text Field

Dynamic
Text Field

Notice that with this simple method you did not use any actionScript.

Answer the following questions and then we will make an input text field for the
user’s name and a dynamic text using some script.

Can you differentiate between static, input and dynamic text fields?
1. Which text does not change?
2. Which text can show external texts and variable data generated by
actionScript?
3. Which text allows the user to type in information? (Answers: Appendix B #1)

Dr. Linda Wright Smith Simplified Start of a Learning Module Page 3


C. Using field texts to solve my card problem
Open a new fla file and create an input text like you did above in the first frame. Use
the stop(); function to keep the movie in frame one and create a button to jump to frame
two.

Now in frame two create a dynamic text and set the Var as myName.

If you used the stop(); in an actions layer in the first frame and used a button to jump to
the next screen, your animation could run using the name entered in the first frame input
text in the dynamic text in the second frame.
When you typed that information in the input text
field, the dynamic text received the text string from
the variable called myName.

Dr. Linda Wright Smith Simplified Start of a Learning Module Page 4


Take this quiz to see how your code reading skills and understanding of field
texts has progressed. (Answers: Appendix B #2)

1. What does the actionScript in the following screen shot accomplishing?

2. Referencing the script above, what can you say about the text fields below?

Dr. Linda Wright Smith Simplified Start of a Learning Module Page 5


D. Using actionScript to read a text variable
Sometime you want to get user information during movie runtime. You can assign text
to an input text field at runtime. Below is the text I created using the example on page
346 of your Adobe PDF file. Open a new Flash file and create your own runtime input
text field as directed in the PDF file.

Do you notice the text field in the fla file behind the movie screen?
I used the top layer in the Timeline to write the actionScript code.

You can also code so that the actual text field is not created until runtime. In the
following example I set the position, text color, text border, margins and size among
other options.

If you are having trouble understanding how the actionScript is functioning, be sure to
review the relevant sections in your Adobe PDF file. You can also go to
http://www.flashkit.com for free access to basic tutorials and free sound files.

Open a new fla file and try to recreate the codes on page 346 of your PDF file. When
you are done, click Ctrl Enter to see your results. I did a little formatting of the code
below. See if you can do the same with your text field.

Dr. Linda Wright Smith Simplified Start of a Learning Module Page 6


The user can also type in this
text field since it is an input text.

Can you explain what each line of the code above is doing? (Answers: Appendix B #3)

NOTE: You should continue creating your learning package in the way shown above. Refer to
Gagne’s Nine Events of Instruction to guide your approach to this assignment. You can use
Flash Captivate files to capture your keystrokes or actually teach and quiz your independent
learner.

Remember to not only present the content but:

Provide cues
Allow opportunities to practice
Provide feedback as you transition to your next objective
Allow frequent self-testing so the student can gauge their progress
Provide information/cues that helps student to transfer this new
knowledge to other situations
Summarize what they have learned in this module

Dr. Linda Wright Smith Simplified Start of a Learning Module Page 7


Appendix A: Vocabulary
Excerpt from Learning actionScript 2.0 in Flash PDF pp. 343-344

Characters
Characters are letters, numerals, and punctuation that you combine to
make up strings.

Device fonts
Device fonts are special fonts in Flash that are not embedded in a SWF
file. Instead, Flash Player uses whatever font on the local computer that
most closely resembles the device font. Because font outlines are not
embedded, a SWF file size is smaller than using embedded font outlines.
However, because device fonts are not embedded, the text that you
create with these fonts looks different than expected on computer systems
that do not have a font installed that corresponds to the device font. Flash
includes three device fonts: _sans (similar to Helvetica and Arial), _serif
(similar to Times Roman), and _typewriter (similar to Courier).

Fonts
Sets of characters with a similar font face, style, and size.

String
A sequence of characters.

Text
A series of one or more strings that can be displayed in a text field, or
within a user interface component.

Text fields
A visual element on the Stage that lets you display text to a user. Similar
to an input text field or text area form control in HTML, Flash lets you set
text fields as editable (read-only), allow HTML formatting, enable multiline
support, password masking, or apply a CSS stylesheet to your HTML
formatted text.

Text formatting
You can apply formatting to a text field, or certain characters within a text
field. Some examples of text formatting options that can be applied to text
are: alignment, indenting, bold, color, font size, margin widths, italics, and
letter spacing.

Dr. Linda Wright Smith Simplified Start of a Learning Module Page 8


A dynamic or input text field is a TextField object (an instance of the
TextField class). When you create a text field in the authoring
environment, you can assign it an instance name in the Property
inspector.

You can use the instance name in ActionScript statements to set, change,
and format the text field and its content by using the TextField and
TextFormat classes.

You can use the user interface to create several kinds of text fields, or you
can use ActionScript to create text fields.

You can create the following kinds of text fields in Flash:

Static text
Use static text to display characters that do not need to change, to display
small amounts of text, or to display special fonts that are not available on
most computers. You can also display uncommon fonts by embedding
characters for dynamic text fields.

Dynamic text
Use dynamic text fields when you need to display characters that are
updated or that change at runtime. Also, you can load text into dynamic
text fields.

Input text
Use input text fields when you need to capture user input. Users can type
in these text fields.

Text components
You can use TextArea or TextInput components to display or capture
text in your applications.

The TextArea component is similar to a dynamic text field with built-in


scroll bars.

The TextInput component is similar to an input text field. Both


components have additional functionality over their text field equivalents;
however, they add more file size to your application.

Dr. Linda Wright Smith Simplified Start of a Learning Module Page 9


Appendix B: Quiz Answers

#1 (page 3)
Which text does not change? Static Text

Which text can show external texts and variable data generated by actionScript?
Dynamic Text

Which text allows the user to type in information? Input Text

#2 (page 5)

The actionScript creates two variables called x, y, and myvar with an initial value of
zero.

Two input texts called “one” and “two” only allows the user to only type in numeric
values.

The variable x gets the value typed in the “one” input text while the variable y gets the
value typed in the input text called “two.”

We can also see that there is a third text identified as a dynamic text field called
“myvar.”

With the information provided that is all we know. When I created this code, I was
making an adding machine. The variable myvar receives the sum of data from input
text fields “one” and “two” then returns this value to a variable called z which is given to
the dynamic text field so it can display the answer to the user.

function addme(x,y) {
z= number(x) + number(y)
return z;
}

Dr. Linda Wright Smith Simplified Start of a Learning Module Page 10


#3 (page 7)

Note: 1) If you chose to have a test answer sheet in an appendix, make sure to identify where
the reader can find the answers. 2) Our authoring programs allow us to provide immediate
feedback to test questions. If you decide to use Captivate, Flash and/or Director, please
provide immediate feedback to each section’s test questions. 3) You must include all artifacts
that you created for your ISD package including all the learner start and completed fla files you
have written for this learning package. Below is an example of one package. Each level has
their own set of artifacts. Needless to say, she got an “A” on her ISD package.

Dr. Linda Wright Smith Simplified Start of a Learning Module Page 11

You might also like