We will be undergoing scheduled maintenance on May 20th, 2013 at 02:00 GMT.
Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com�s entire library of video tutorials.
Previously, I demonstrated how to link to external files using the navigate to URL method and also how to use JavaScript with the method. Another way Flash can communicate with external content is to combine it with other Flash movies or external data like images or sound or video. Now, there are a number of ways to import external data into your published swf file at runtime. The loader class provides the load method to load many kinds of external content into Flash and then integrate it with current content. The original Flash file controls the stage size, color, frame rate and other properties. This practice puts more control in the hands of the user and keeps file sizes small and load time short. Imagine you have a photography gallery website featuring hundreds of photographs. If you were to place all of these bitmaps into your main Flash file, even with the best optimization, you file size would quickly become unwieldy. If your images were kept separate also it'd be easier to edit them or swap out alternative images. After you've loaded the external swf file with the loader class, you must add it to the display list which makes it then visible to the user. I'll cover more about the display list a little bit later. To load an external swf file entitled External SWF use this code here. We'll set up a variable for my request, a URL request here. Notice that the parameter there is the name and the path to the swf file that you want to load into this particular file. In this case the swf file is located in the same folder as this published swf file that I'm loading it into. The second line then creates a new loader object. You do that just by calling it. Notice that it says New Loader and there's the method with the open and close parentheses. On the next line, call the load method for you new loader object and then use the URL request object as the parameter. That reads myloader.load and then my request for the parameter. And then on the last line we'll call the Add Child Method to add the loader object to the stage. This will actually display the external swf file. Let me go ahead and demonstrate this by showing you first the file here that I'm going to load the content into. Notice that it's blank with a beige background. Let's go ahead and load in this into Flash, the external.swf file. Let me show you what that looks like by opening up the fla file here in the Work Files Folder and that file looks like this. No script in this one. It has two frames. The first ones says this is an externally-loaded swf file and then in Frame 5 it has Welcome to Frame 5 of the externally loaded file. There's two stop actions there just to stop the play head from looping back and forth between Frame 1 and Frame 5. So that's all there is to it. So notice that there's no content here in this original swf file. Now let's go ahead and do a Control Test Movie and let that run and notice that it loads that external swf file right here onto the stage. Let me give you a few tips for using this method to load external swf files into a project. ActionScript 2.0 movies cannot load ActionScript 3.0 moves although AS 2.0 movies can be loaded into ActionScript 3.0 movies but there are enough limitations that it's probably not a good practice. Better to migrate your ActionScript 2.0 content to ActionScript 3.0 and then load it into your ActionScript 3.0 movies. Let's review some of the properties of these loaded movies. First they all have transparent stages. Notice that in this example my loaded swf file has a colored blue background but it's transparent when loaded. So the yellow color of the host movie shows through. You'll remember that the color of the background when I tested this was not blue but this yellow-being color. Also loaded movies are aligned to the registration point of the object that they're loaded into. This means the object is loaded to the top left corner of the stage where X equals 0 and Y equals 0. This also means that objects off the stage of loaded movies that are smaller than the host movies will show up in the host movie. In other words, if you have a very small movie that you're loading into a larger movie, there may be content here in the loaded movie that's off stage that still will be visible in the final result over here in the host movie. Next the loader objects can only have one loaded movie. The new load calls will replace the previously loaded movie. So notice right here, when I call the new loader here, if I do more than one, the new one will replace the old one. To load multiple movies, you'll need to use multiple loader objects, each with that unique name. Each time you use the app Child Method right here to display the loaded movie, it will be displayed on top of any previously loaded movies. What I recommend that you do is to experiment with each of these properties to get a better feel for how loaded movies interact with the stage and with other loaded movies. Now, after students learn how to load various swf movies into a project, the next question I always get is how do you unload these movies? Unload swf movies from the stage using the Unload Method; myloader.unload. Open close parentheses colon as you see right here is the method that you want. This will unload the Flash movie loaded by the previous myloader calls. See the unload swf fla file in the Work Files folder. For example, a script of this technique; here I'm setting up a event listener for this unload movie button and then when that button is pressed, I'm simply unloading the movie right there that I've loaded up previously with the myloader method up here. That's the same script as the previous movie. So if we do a Control Test Movie, there is the movie that's been loaded. Clicking on the button will very quickly and easily remove that movie from the stage. You can also use the unload and stop method to load the Flash movie and stop any audio or video from the file that may be continued to play. Now, after you've loaded Flash movies into your project, you will no doubt want to control them such as precisely placing them on the stage, stopping them or perhaps navigating to different location on their timeline. So let me now move on to the next movie and demonstrate some coding for controlling your loaded Flash movies.
| Course: | Adobe Flash ActionScript 3.0 for Designers |
| Author: | James Gonzalez |
| SKU: | 34060 |
| ISBN: | 1-935320-82-3 |
| Release Date: | 2009-11-09 |
| Duration: | 9.5 hrs / 101 lessons |
| Work Files: |
Yes |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |