Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In this chapter we're going to take a look at adding interactivity to our text field. Specifically we'll create a scroll bar and scroll buttons to control the scrolling in our text field. We'll start out by talking about how to mask dynamic text. If you're following along, I'm working in 01_Masking.fla in the Chapter 04 folder in the Exercise Files folder. Let's take a look at how this file is set up. There are four layers - actions, buttons, mask, and text field. Let's select the first keyframe of the actions layer and open up the Actions panel. Remember the keyboard shortcut is Option+F9 on the Mac, F9 on the PC.
So there's already a lot of ActionScript here. First off there's ActionScript to load an external text file. That goes at the top and the bottom of the code. There are event listeners added to all the buttons on the stage. And skeletons of event handler functions for all of those objects on the stage. If you don't have access to the exercise files, you may want to pause the movie and copy down the code at the bottom here that I have selected. One line of code here that might be new to you is scroller_mc.buttonMode = true.
Button mode is a property of movie clips the controls showing the Hand icon when you make the movie clip interactive, or in other words when you make the movie clip respond to mouse events. setting this value to true in this case, will display the Hand cursor when you roll over the scroller_mc movie clip. Now I'll close the Actions panel. I'm going to test the movie and demonstrate how this file is working. Command+Return on the Mac. Ctrl+Enter on the PC. So the text file is being loaded. And if I click and drag in the text field you can scroll down.
I'm going to close the window. Let's take a look at how the text field is set up. I'm going to unlock the text field layer, and using the Selection tool, I'm going to select the text field on the stage. Notice that this is not a dynamic text field, but is a movie clip, an instance of the mc text called text_mc. I'm going to double-click this instance on the stage to enter its timeline. Inside the timeline of mc text is a text field. The text field has an instance name of external_txt. We'll talk more about the other items in the library once we start working with them.
But for now click Scene 1 at the bottom of the timeline to return to the main timeline. The mask layer is currently set to be a guide layer. I'm going to right click, or Control click on the Mac, the mask layer and uncheck the Guide option, I'm also going to choose not to hide the mask layer and show that the mask layer is a magenta rectangle. If you unlock the mask layer and select the mask from the stage you'll see it's an instance of mcMask named mask_mc. This movie clip is simply a rectangle that has been converted to a movie clip.
What we're going to do to build our scrolling text field throughout this chapter is mask the text field and instead of using the modifying text field properties to scroll the text or going to animate the text field movement by animating the movie clip that the text field is within. To give the text field boundaries we're putting that movie clip inside of this mask. By default Flash does not mask dynamic text. To give an example I'm going to set the mask layer as a mask. So I'm going to right click the mask layer, and its Control click on the Mac, and choose Mask.
Flash converts the mask layer to a mask and the text field layer to a masked layer. Now I'm going to test the movie by pressing Command+Return on the Mac, or Ctrl+Enter on the PC. Notice the text field does not display. I'm going to close the Preview window. This can be very frustrating when you're learning Flash. Why on earth will Flash not mask the dynamic text field? What you have to do to mask or rotate or apply filters to a dynamic text field is embed the font inside of the text field. Once you do that you can put a dynamic text field inside of a movie clip and then do anything with that movie clip that you can do with any other object in Flash.
So what I'm going to do is I'm going to enter the mcText movie clip through the library. So in the library find mcText and double-click the movie clip symbol icon next to mcText to enter its timeline. Select the dynamic text field on the stage. And here's the step that you have to do in order to mask dynamic text field. Click the Embed button in the Property inspector. When you click the Embed button, Flash opens the Character Embedding window. In the Character Embedding window you can tell Flash what characters you'd like to embed inside of this text field.
Since I know all the text in this text field is going to be English, I'm going to embed all uppercase, lowercase, numerals, and punctuation. So I'm going to select Uppercase and I'm going to hold Shift on my keyboard and click Punctuation to select Uppercase, Lowercase, Numerals and Punctuation. This will embed all the characters that are going be used in our external text file, or all English characters. Once you've made your selection, click OK to close the Character Embedding window. And now I'm going to test the movie to see the mask applied to the dynamic text field. Command+Return on the Mac. Ctrl+Enter on the PC.
Now you can and see that the text field is being masked. So once you embed the font you can mask a dynamic text field. I'm going to close the Preview window. Now that we have our text field and masked properly to start adding our scrolling interactivity.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.