EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 200

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
200 Chapter 11: Working with External Media
To display download progress using the ProgressBar component:
1 In a new Flash document, create a movie clip on the Stage and name it target_mc.
2 Open the Components panel (Window > Development Panels > Components).
3 Drag a ProgressBar component from the Components panel to the Stage.
4 In the Property inspector, give the ProgressBar component the name pBar and, on the
Parameters tab, select Manual from the Mode pop-up menu.
5 Select Frame 1 in the Timeline and then open the Actions panel (Window > Development
Panels > Actions).
6 Add the following code to the Actions panel:
// create both a MovieClipLoader object and a listener object
myLoader = new MovieClipLoader();
myListener = new Object();
// add the MovieClipLoader callbacks to your listener object
myListener.onLoadStart = function(clip) {
// this event is triggered once, when the load starts
pBar.label = "Now loading: " + clip;
};
myListener.onLoadProgress = function(clip, bytesLoaded, bytesTotal) {
var percentLoaded = int (100*(bytesLoaded/bytesTotal));
pBar.setProgress(bytesLoaded, bytesTotal);
};myLoader.addListener(myListener);
myLoader.loadClip("veryLargeFile.swf", target_mc);
7 Test the document by selecting Control > Test Movie.
For more information, see the MovieClipLoader class entry in Chapter 12, ā€œActionScript
Dictionary,ā€ on page 205.

Table of Contents

Related product manuals