use the URLLoader and URLRequest classes. About the URLLoader and URLRequest Classes The URLLoader class downloads data from a URL. It is useful for downloading text files, XML, or other information to be used in a dynamic, data-driven application. A URLLoader object downloads all of the data from a URL before making it available to ActionScript. The URLRequest class captures all of the information in a single HTTP request. URLRequest objects are passed to the load() method of URLLoader to initiate the URL download. Using URLLoader and URLRequest Classes You'll use the URLRequest class to capture the data from the text file and pass it to the URLLoader class, which will load it onto the page. To use the classes, you'll first create variables that you can refer to later in the script. 1. With frame 3 of the Actions layer still selected, type the following line in the Actions panel to create a loader variable for a URLLoader object: var loader:URLLoader = new URLLoader(); Note Press Enter or Return after each line to move to the next line in the Actions panel. 2. Create another variable for the URLRequest object: var requestURL:URLRequest = new URLRequest(fileName); 3. Use the variables to request and load the URL data: loader.load(requestURL); [View full size image] Working with Events An event is something that is initiated by a button click, a key press, or the end of a video. An event listener, also called an event handler, is a function that is executed in response to specific events. An EventDispatcher object notifies the event listener of an event. You'll add an EventDispatcher object and an event listener to recognize and respond to the button click and load the appropriate text file. Adding an Event Listener and Function To make the loaded data available, you need to add an event listener to the URLLoader object you created earlier. You'll use the Event.COMPLETE type of event listener, which means that it will be dispatched when the content has been completely loaded. Then, define a function that will be called when the event occurs. The function uses the loader you created earlier to load the text. Finally, create a function to handle the data and pass it to the text field where you want it to appear. 1. In the Actions panel, type loader.addEventListener(Event.COMPLETE,completeHandler); 2. In the Actions panel, type function completeHandler(event:Event):void { var loader:URLLoader = URLLoader(event.target); var pageText:String = loader.data; this.pageText_txt.text = pageText; } Note Be sure to include the final curly bracket, or the function won't work. 3.