Here is how to dynamically create a movie clip in ActionScript 3 using the MovieClip class
First you have to declare the movie clip:
var myMC:MovieCLip = new MovieClip();
Than you have to add it to the stage using addChild:
addChild(myMC);
You can create MovieClips, Sprites, and Objects by calling the word new
Here is an example of the AS2 syntax:
var myMC:MovieClip = _root.createEmptyMovieClip("mc1", _root.getNextHighestDepth());
But for AS3, remember that after declaring your MovieClip it remains in memory and won’t be visible on stage until you call addChild(YOUR_MOVIE_CLIP_NAME)
Here is the AS3 example with property settings:
var myMC:MovieClip = new MovieClip(); myMC.x = 50; myMC.y = 50; myMC.name = "mc1"; addChild(myMC);
Please rate this post by clicking a star:


(11 votes, average: 4.36 out of 5)