Flash MX Hands On Training: Working with Text

This chapter will show you how to create horizontal or vertical text, text fields that bring in text from an external document, make text scroll, and create text fields where someone can enter information themselves.

This sample is taken from Chapter 12: "Working with Text" of the glasshaus title "Flash MX H.O.T"

4.   Scrollable Dynamic Text Fields

In the previous two exercises, you have been working with Dynamic Text fields. This exercise will take the project file one step further: You will learn to make the Dynamic Text scroll.

1.    You should still have the dynamicText.fla file open from the last exercise.

12_04_01

2.    Select the Dynamic Text field on the Stage. In the Property Inspector, type learnText in the Instance Name box. This will assign the instance name learnText to the Dynamic Text field.

Note | Why Do I Need an Instance Name and a Variable Name?

In Macromedia Flash MX, text is its own ActionScript object, so now (this is new in Flash MX) a text field (Dynamic and Input Text) can have both a variable name and an instance name. As you learned in Exercise 2, you need a variable name to be able to load the external text file into a Dynamic Text field. In this exercise, you need to give the text field an instance name so that ActionScripting on the Buttons can control the text field. You will do this next.

12_04_02

3.     On the Main Timeline, lock the holder layer and click the Insert Layer button to add a new layer. Rename the layer buttons. Position the buttons layer below the actions layer.

12_04_03

4.     Open the Library (F11) and notice that it contains two Buttons: btnDown and btnUp. Drag an instance of each Button onto the Stage. Position the btnDown Button under the btnUp Button, as in the picture above.

5.    Select the btnUp Button on the Stage and press F9 to open the Actions panel.

12_04_04

6.    In the Actions panel Toolbox, choose Objects > Movie > TextField > Properties. Double-click on the scroll property to add it to the Script pane.

12_04_05

7.    In the Expression box, place your cursor before .scroll and type the instance name of the Dynamic Text field: learnText. After the word scroll, type += 1. The expression should now read learnText.scroll += 1. This tells Macromedia Flash MX that, when a user clicks on the Up Button, it should take the learnText instance (the Dynamic Text field) and scroll it up 1 line.

Tip: You can change the number of lines that scroll at one time by changing the number after the += 1. For example, learnText.scroll += 5 will scroll the Dynamic Text field up 5 lines for each click on the Button.

8.   Select the btnDown Button on the Stage and press F9 to open the Actions panel. Choose Objects > Movie > TextField > Properties and double-click on the scroll property to add it to the Script pane.

12_04_06

9.    In the Expression box, place your cursor before .scroll and type learnText. After the word scroll, this time type -= 1. The expression should now read learnText.scroll -= 1. This will tell Macromedia Flash MX that, when a user clicks on the Down Button, it should take the learnText instance (the Dynamic Text field) and scroll it down 1 line.

12_04_07

10. Choose Control > Test Movie to try out your new scroll buttons!

Troubleshooting tip: If your scroll buttons don't work, go back and check the ActionScripting on the buttons and make sure that all the text is spelled correctly and that you used the correct lowercase and uppercase letters, since the ActionScript you applied to the Buttons is case sensitive.

11. When you are finished, save and close this file.

George Petrov

George PetrovGeorge Petrov is a renowned software writer and developer whose extensive skills brought numerous extensions, articles and knowledge to the DMXzone- the online community for professional Adobe Dreamweaver users. The most popular for its over high-quality Dreamweaver extensions and templates.

George is also the founder of Wappler.io - the most Advanced Web & App Builder

See All Postings From George Petrov >>

Comments

asdf

November 6, 2002 by Jack xiang
asdfasdf

great!!

November 19, 2002 by Behring Bautista

Perfect to start working with text.

It was so helpful to me.

But I get and error in the username/password example. If somebody can give a hand i will very greatful.

It seems everthing is ok, but it doesn't verify the password , whatever I write I go always to frame 10 (pass) and never reach the frame 20 (fail). :-) thank you

 

nice tutorial...but...

March 8, 2004 by Stefaan Contreras
How to avoid a 'space' as the first character on a new line? Let me explain a bit more: since the wrapping is done by Flash it happens that a space and the rest of the text is wrapped to the next line. How can this be avoided?

Multiline Text

April 13, 2004 by Kevin Slack

Indeed, this is very useful information.  I apologize if this is not the correct forum for asking questions.  But I have the same problem as Stefaan.  How do you keep a mulitline text box from starting a new line with a space character?  It's very annoying besides ugly.  Thanks.

 

See all 5 Comments

You must me logged in to write a comment.