Tuesday, August 3, 2010

Add a movie clip from library in AS3.0

 Hi Guys ,
In this post i am going to tell a basic way to load a movie clip from library.

Step 1: Add a movie Clip in stage so that it will get added to your library.
Step 2: Delete from the stage so it will be available in the library.
Step 3: Now open the library (ctr+l) right click the movie clip and give Export for Action script and give a name

Step 4: link the stage property to the class file addmc.
Step 5: create a flash script file name it as addmc.as.
Step 6:Now in the as file
package {
    import flash.display.MovieClip;
    public class addmc extends MovieClip{
        public function addmc(){
            //creating a object for the movie clip we created and placed in the library.
            var male_mc:male;
            male_mc = new male;
            //setting the position.
            male_mc.x=100;
            male_mc.y=100;
            //adding the movieclip to the stage
            addChild(male_mc);
        }
    }
}

This is a basic example how to add a library file to stage.

you can download the sample file from addMC

Do u want to search anything in my site just try out the Google search Above next to the head. Don't forget to leave a comment about this