Search code examples
dynamicduplicatesactionscript-2movieclipstage

AS2 How to Dynamically Duplicate Movieclips Until They Fill the Stage?


I am wondering how I would go about dynamically duplicating a movieclip (that runs a Tweenlite animation), until it fills the stage? The idea is to have snowflakes animate in and fill the screen (white-out) and that the movieclips are coming in at random x and y positions based on a stage area.

Thanks so much!


Solution

  • var i = 0;
    
    attachMovie("a_snowFlake_mc","a",this.getNextHighestDepth()); //AS linkage reference
    
    onEnterFrame = function(){
    
    duplicateMovieClip("a","ac"+i,this.getNextHighestDepth());
        _root["ac"+i]._x = Math.random()*Stage.height;
        _root["ac"+i]._y = Math.random()*Stage.width;
        i++;
    }