Start learning with our library of video tutorials taught by experts. Get started

Flash CS3 Professional Beyond the Basics

Loading text from an external file


From:

Flash CS3 Professional Beyond the Basics

with Todd Perkins

Video: Loading text from an external file

Now we'll talk about loading an external text file into a text field in Flash. Before we load the external text file, let's take a look at what's in the external text file. If you have access to the exercise files find Chapter 03 in the Exercise Files folder. Then find the text folder inside of that folder. Open up external.txt in a text editor. I'm going to open it up in TextWrangler. When you open the text file, you can see that it's just very simple text and the text is actually something called lorem ipsum text, which is basically just a bunch of gibberish.
Expand all | Collapse all
  1. 3m 30s
    1. Welcome
      1m 20s
    2. Getting the most from this training
      1m 20s
    3. Using the exercise files
      50s
  2. 15m 28s
    1. Managing digital assets
      4m 9s
    2. Creating custom keyboard shortcuts
      5m 1s
    3. Creating custom color swatches
      3m 41s
    4. Creating a custom template
      2m 37s
  3. 14m 38s
    1. Working with variables
      3m 41s
    2. Using functions
      3m 30s
    3. Working with events
      2m 11s
    4. Using event listeners
      2m 42s
    5. Working with arrays
      2m 34s
  4. 29m 41s
    1. Understanding dynamic text fields
      2m 37s
    2. Loading text from an external file
      6m 42s
    3. Reading HTML from a text field
      5m 29s
    4. Applying CSS with ActionScript
      7m 0s
    5. Applying external CSS to a text field
      7m 53s
  5. 45m 27s
    1. Masking dynamic text
      4m 59s
    2. Dragging the Scroll Bar
      7m 3s
    3. Calculating a scroll percent
      5m 20s
    4. Setting scroll boundaries
      4m 9s
    5. Connecting the ScrollBar to the text field
      2m 55s
    6. Easing the text with the ScrollBar
      4m 12s
    7. Scrolling the text with buttons
      2m 38s
    8. Animating the scrolling text with the buttons
      4m 26s
    9. Setting boundaries for the scrolling text
      4m 26s
    10. Easing the text using the buttons
      1m 37s
    11. Connecting the ScrollBar to the Scroll buttons
      3m 42s
  6. 20m 46s
    1. Organizing a complex object into layers
      1m 51s
    2. Duplicating MovieClips
      1m 29s
    3. Undocking the timeline
      1m 20s
    4. Animating a complex MovieClip
      4m 36s
    5. Creating an animated Hinge effect
      5m 13s
    6. Creating complex animations
      6m 17s
  7. 28m 1s
    1. Controlling objects with buttons
      4m 6s
    2. Understanding frame labels
      3m 25s
    3. Using buttons to navigate labeled frames
      2m 30s
    4. Nesting code within MovieClips
      5m 8s
    5. Adding sound to the application
      2m 34s
    6. Adding drag interactivity to the robot
      6m 1s
    7. Animating the dragged robot
      4m 17s
  8. 20m 3s
    1. Understanding components
      2m 30s
    2. Using components to setup a form
      3m 45s
    3. Setting up the form to send an email
      3m 38s
    4. Working with form variables
      6m 11s
    5. Skinning components
      3m 59s
  9. 27m 40s
    1. Using transparency in a video
      4m 16s
    2. Working with embedded video
      3m 38s
    3. Animating a VideoClip
      2m 53s
    4. Creating an advanced animation with video
      2m 40s
    5. Working with the bitmap data class
      3m 37s
    6. Working with the bitmap class
      1m 40s
    7. Copying the video to create a reflection
      1m 35s
    8. Reflecting the video
      2m 42s
    9. Enhancing a video reflection with a mask
      4m 39s
  10. 1h 38m
    1. Viewing the finished MP3 player
      1m 45s
    2. Understanding the project flow
      2m 52s
    3. Preparing to build the MP3 player
      5m 11s
    4. Understanding classes and packages
      5m 32s
    5. Creating the MP3 player class
      9m 59s
    6. Loading sounds from external files
      9m 20s
    7. Accessing ID3 tag information
      6m 11s
    8. Controlling sound playback with Play and Pause buttons
      11m 3s
    9. Changing tracks
      12m 1s
    10. Displaying the current volume
      9m 33s
    11. Changing the volume
      6m 40s
    12. Wiring the progress bar
      8m 4s
    13. Building the progress bar slider
      10m 4s
  11. 5m 36s
    1. Making Flash movies accessible
      1m 49s
    2. Adding a name and description to your Flash movie
      52s
    3. Accessibility and text fields
      2m 55s
  12. 12m 2s
    1. Understanding Flash Mobile
      35s
    2. Exploring Device Central
      1m 45s
    3. Updating Device Profiles
      1m 7s
    4. Creating a Flash file from Device Central
      2m 7s
    5. Creating and testing Flash Lite applications
      2m 48s
    6. Downloading the Flash Lite player for Windows Mobile
      1m 44s
    7. Getting a Flash Lite application onto your phone
      1m 56s
  13. 27s
    1. Goodbye
      27s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
Flash CS3 Professional Beyond the Basics
5h 21m Intermediate Dec 06, 2007

Viewers: in countries Watching now:

Through several hands-on tutorials, instructor Todd Perkins shows how to best build dynamic, streamlined sites using Flash CS3 Professional. Learn how to create custom keyboard shortcuts, apply advanced text techniques such as animating scrolling text with custom easing controls, and using advanced animation techniques. Flash CS3 Professional Beyond the Basics covers many challenging features, including adding complex interactivity to a Flash CS3 project and getting Flash content on a phone. Exercise files accompany the tutorials.

Topics include:
  • Customizing Flash CS3 and managing assets Working with ActionScript variables Understanding dynamic text fields Adding interactivity to dynamic text Animating a complex MovieClip Using buttons to navigate labeled frames Working with components Exploring advanced audio and video techniques Creating accessible Flash content Understanding Flash Mobile
Subject:
Web
Software:
Flash Professional
Author:
Todd Perkins

Loading text from an external file

Now we'll talk about loading an external text file into a text field in Flash. Before we load the external text file, let's take a look at what's in the external text file. If you have access to the exercise files find Chapter 03 in the Exercise Files folder. Then find the text folder inside of that folder. Open up external.txt in a text editor. I'm going to open it up in TextWrangler. When you open the text file, you can see that it's just very simple text and the text is actually something called lorem ipsum text, which is basically just a bunch of gibberish.

But this text will work just great for loading external text in Flash. So if you don't have access to the exercise files, you can just create a text file with a .txt extension and type some text inside of it. I'm going to close this file now and go over to Flash. In Flash I'm working in a file called O2_external_text.fla. The only thing in this file are two layers - actions and text field. And the text field layer contains the text field that we created in the last exercise. Now let's write the action script to load the text from the external text file inside of this text field. Select the first keyframe of the actions layer and press Option+F9 on the Mac, or F9 on the PC, to open the Actions panel.

Now loading text from an external text field into Flash is that we talked about in ActionScript 3.0 and Flash CS3 Professional Essential Training. If you haven't seen that title before and this does seem confusing to you, then you might want to see the chapter about text. In that chapter there's a lot more detail about loading texts from an external file into Flash. If you're already familiar with loading text from an external file you may remember that there are few steps to load an external file into Flash. The first thing you need to do is create something that's going to load the external file.

So I'm going to do that now by creating a variable. I'm going to call this variable textLoader. And the data type for the variable I'm going to set with a colon. It's going to be URLLoader. Capital U, capital R, capital L, and then a capital L for Loader. We'll set that equal to a new instance of the URL loader class. Let's go to the next line. And the next thing we need to define is something called a URL request. The URL request holds the information about the external file that's going to be loaded into Flash. Type var and a space.

Text capital Req, short for text request. Set the data type with a colon to URL, all caps, Request with a capital R. I'll set that equal to an new URL request. And then in the parentheses, when we create the new URL request, we'll pass in the path to the text file. Now you may remember the text file is in a folder called text. So type some quotes. Just remember this path is a string or a text value in Flash.

And type the name of the folder which is text, a forward slash, and then the name of the file, which is external.txt. After this line go down a few lines and now we'll make the text loader load the file that's held in the text request variable. So type textLoader, capital L.load And the value we're going to pass in parentheses is textReq, the text request variable that we created. Now simply loading the file alone doesn't really do anything as far as putting it inside of a text field in Flash. There are actually a On the next line, what we're going to do is tell Flash to run a function once the text file finishes loading.

So type textLoader.addEventListener, capital E for event, capital L for listener. The type of event is going to be Event, capital E, dot COMPLETE, all caps. Type a comma and a space. And the function that will run once the text files finish loading, will be a function called textLoaded. Now let's define the text loaded function to tell Flash what happens once the text file finishes loading. I'm going to define that function in between my variable section and my code that runs immediately section.

So in between the two sections of code, I'm going to create a function called textLoaded. It;s going to receive the event.COMPLETE event. So I'm going to call the parameter event and set the data type to event. It's not going to return a value so I'm going to type void for the return data type. Some curly braces for the function and then inside of the function I'm going to set the value of the text in the text field on the stage. If you remember the text field on the stage is called external_txt.

Now the external_txt is different than the name of the text field in the external file, which is external.txt. Cakes external_txt refers to the instance of the text field on the stage in our Flash file. So after external_txt, type .text. Text is a property connected to all dynamic text fields. The text property holds the text inside of a text field. So whatever we set after the equal sign, after .txt, will be displayed in the text field. The value we want to display is the value that's loaded from the external file.

Now that value is held inside of our textLoader object that we created. So the textLoader loads the external file specified on my code in line 9. Once the file is loaded, the textLoader then has all the information, or all the data that's inside of that file. To access that data after the equal sign that we just typed, type textLoader.data, and data is the property of the URL loader that holds the data that's loaded from a file.

So the text inside of the external_txt text field is set to textLoader.data or the data that's loaded in from the external.txt file. Once we have our code written, we can test the movie to make sure that the text is loading properly. Command+Return on the Mac. Ctrl+Enter on the PC. And you can that see the text loads right into the dynamic text field we created, and it's coming from that external file that we were working with. I'll close this window.

And there's a look at taking text from an external text file and loading it into a dynamic text field in Flash.

There are currently no FAQs about Flash CS3 Professional Beyond the Basics.

Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Flash CS3 Professional Beyond the Basics.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked