Adobe Flash Professional CS6 Adobe Flash Professional CS6 Classroom In A Book | Page 355

Loading external Content You’ll use ActionScript to load each of the external SWFs into your main Flash movie. Loading external content keeps your overall project in separate modules and prevents the project from becoming too bloated and difficult to download. It also makes it easier for you to edit, because you can edit individual sections instead of one, large, unwieldy file. For example, if you wanted to change the article on the new car in the second section, you would simply open and edit the Flash file page2.fla, which contains that content. To load the external files, you’ll use two ActionScript objects: one called a ProLoader and another called a URLRequest. 1 Insert a new layer at the top and rename it actionscript. 2 Press F9 (Windows) or Option+F9 (Mac) to open the Actions panel. P Note: The ProLoader object is an ActionScript object introduced in Flash Professional CS5.5. Older versions of Flash relied on a similar object called the Loader object. The ProLoader and the Loader objects are identical except that the ProLoader handles the loading of TLF text better for more reliable and consistent performance. P Note: To compare punctuation, spacing, spelling, or any other aspects of the ActionScript, view the Actions panel in the 09End.fla file. 3 Type the following two lines exactly as they appear here: import fl.display.ProLoader; var myProLoader:ProLoader=new ProLoader(); This code first imports the necessary code for the ProLoader class, and then creates a ProLoader object and names it myProLoader. 4 On the next line, type the following lines exactly as they appear here: page1_mc.addEventListener(MouseEvent.CLICK, page1content); function page1content(e:MouseEvent):void { var myURL:URLRequest=new URLRequest("page1.swf"); myProLoader.load(myURL); addChild(myProLoader); } 346 Lesson 9 Loading and Controlling Flash Content