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.
Now if you've loaded Flash movies into your projects, you'll now doubt want to control them in various ways. Perhaps you need to precisely places these loaded swf files on the host movie stage or stop their playback or perhaps you want to navigate to different locations on their timelines. Let's now review some code for controlling your loaded swf movies. Before you can control a loaded movie, you first have to make sure it has completely loaded. You can detect when the swf file has completely loaded by accessing its loader info object. This loader info object provides events including event.complete and event.open that provides information about the load processes. You also have other events that provide information about how much data has loaded such as information about how many bytes has loaded, the frame rate and a lot of other useful information. To access this load info object you'll use the content loader info of your loader object. Consider the script that we created previously for loading an external swf file into a Flash file. That's these three lines of code here in this file. You can go ahead and open this from the Work Files folder Control underscore External underscore swf.fla. Now, after the load call is made you can access information about the load with the content loader info property with the following code: myloader.contentloaderinfo.bytesloaded. This statement will return the amount of data loaded into the my loader object right here. This next line of code, let me go ahead and add some line spaces here. Myloader.contentinfo.content returns the object that's loaded into the myloader object and I could use these examples to detect a successful load so that it's then safe to control the loaded movie. You'll do this by writing an event handler that detects the event complete event of the loader info class like this line right here. Let's go ahead and delete these two lines. I don't need those for this example. Myloader.contentloaderinfo.addeventlistener and then the parameter here is event.complete and then once that has detected that the event is complete, it'll then go ahead and run the movie loaded function right there. Also here, only when Flash detects the completion of a load process into the my loader object is the loaded swf file placed on the stage using the add child method and then the movie loaded function calls, which changes the properties of the loaded swf file. That's what this script does down here. You'll note that the content of the event target, the loaded swf file, is given the movie clip variable my content right here and it will do that in order to more easily manipulate and control the loaded movie. To repeat, after the event complete has been detected; in other words the swf file has completely loaded, Flash will give that loaded movie clip the variable name my content so that you can then use that to manipulate its properties. Also note that in this case we're changing the X and Y coordinates of the my content movie clip and navigating to Frame 5 of its timeline right there. So let's go ahead and test this movie and then start manipulating these properties to see how this works. Control Test Movie of the Control underscore External underscore swf fla file. Notice that it loads the external movie and then proceeds to go to Frame 5 of that movie. Let's go ahead and change that from Frame 5 to Frame 1 and now let's do a Control Test Movie. This time it will go to a different frame of that loaded movie. Let's also change the location of the loaded movie. Let's change it from 50 to X equals 0, Y equals 0, Control Test Movie. Puts it up in the corner. That's the registration point of the stage up there. Let's change that to 100 on the Y and 200 on the Y. Again, manipulating these parameters and properties is a great way to really get a handle on the scripts and make this work. Because inevitably, after you learn how to load various content into a Flash project, you're going to want to learn some coding for controlling that loaded content. Now, the same methods demonstrated her for dynamically loading swf movies into your Flash projects can also be used to load external images so let's move on to the next movie and explore some scripts demonstrating the technique of dynamically loading external JPEG images into your Flash projects.
| 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 |