Flash ActionScript 3 Tutorial:
Load MovieClip from Library to Stage
This flash ActionScript tutorial series show how to load MovieClips from the Library to the stage with ActionScript 3. We usually drag MovieClips from the Library to the stage in developing stage. However this is also easy to do it with Flash ActionScript 3.
Flash Tutorial Content:
Sometimes we wish to add MovieClip to the Flash stage in the runtime. We already show how to load external swf and external image in other Flash ActionScript tutorials. In this tutorial, we shows how to load MovieClip from the library to the stage with Flash ActionScript.
Flash ActionScript Codes:
/*
Preparation: Create Linkage for the MovieClip
STEP 1: Prepare MovieClip
You already prepared a MovieClip in the library
In this example, the name of the MovieClip is called "Tree"
STEP 2: Create Linkage
Select the "Tree" movieclip from the library window
Select "Linkage..." from the pop up window
The Linkage Properties window appear
Check the "Export for ActionScript"
Enter "Tree" in the Class field.
*/
// Create a new MovieClip
var myMovieClip:MovieClip = new Tree();
// Add the new MovieClip to the MainTimeline
// so that we can see it.
addChild(myMovieClip);
// Set the location of the new MovieClip
myMovieClip.x = 150;
myMovieClip.y =210;
Download Flash Source File:
Remarks:
This Flash ActionScript tutorial shows how to load MovieClip from the library to the stage .In next Flash ActionScript tutorial, we will create an empty MovieClip on the stage of Flash. The MovieClip from the library is then added to the empty MovieClip.