PHOTOGRAPHERSONLINEPROOFING.COM

army drownproofing - www.photographersonlineproofing.com

Menu


Choose Control > Test Movie. The page content is loaded from the Content_home.txt file. If you receive an error, check to make sure


you've typed the script correctly. Refer to the error message to see which line of the script contains the error. You can refer to the lines of script in the 07End.fla file; you can even copy the lines of script from that file and paste them into the Actions panel in your project file. [View full size image] [View full size image]   Using Events to Script Buttons In ActionScript 3.0, you add all code to buttons dynamically. You'll use another event listener to respond to a mouse click on one of the buttons (named b1, b2, b3, and b4). You'll create a function that updates the URLLoader object you created earlier, identifying the appropriate filename for each button, and you'll use the event listener type MouseEvent.CLICK to call the function. Note If you have used ActionScript 2.0, you may have applied the on(release) method to the buttons themselves, but that is not possible in ActionScript 3.0. 1. In the Actions panel, add another event listener to the script: b1.addEventListener(MouseEvent.CLICK, b1Listener); 2. Type the following lines to add event listeners to the other buttons, as well: b2.addEventListener(MouseEvent.CLICK, b2Listener); b3.addEventListener(MouseEvent.CLICK, b3Listener); b4.addEventListener(MouseEvent.CLICK, b4Listener); 3. To create the function that will be called when the first button is clicked, type the following: function b1Listener(event:MouseEvent):void { loadFile("content_home.txt"); } [View full size image] 4. Create the functions for the other buttons: function b2Listener(event:MouseEvent):void { loadFile("content_cast.txt"); } function b3Listener(event:MouseEvent):void { loadFile("content_crew.txt"); } function b4Listener(event:MouseEvent):void { loadFile("content_release_dates.txt"); } 5. Create the loadFile function by typing the following: function loadFile(fileName:String):void{ requestURL.url = fileName; loader.load(requestURL); } Note The loadFile function expects to find a string and passes that string to the URLRequest object. The URLRequest object finds that file, gathers the data, and passes it to the loader, which displays the text on the page. 6. Choose Control > Test Movie to see the final project. Click each button to see the appropriate text appear.