flashactionscriptactionscript-2flash-8

How to load bitmaps in an array with AS2?


I would know if with AS2 it's possible to load programmatically a bulk of images and save them in an array; then how to attach programmatically each image to an empty movieclip.

I know how to do this in AS3 however it seems impossible in AS2.

Thank You in advance,

Max


Solution

  • Not tested, but here's the gist:

    var bitmaps:Array = [];
    var tempClip = this.createEmptyMovieClip()
    var timer;
    
    function loadImage(){
       timer = setInterval(checkHeight, 10)
       var mc = tempClip.createEmptyMovieClip("img",this.getNextHighestDepth());
       mc.loadMovie(myPathToMyImage)
    }
    
    function checkHeight(){
       if (tempClip._height){
           clearInterval(timer)
          var bmp:BitmapData = new BitmapData(tempClip._width, tempClip._height, true);
           bmp.draw(tempClip);
           bitmaps.push(bmp);
           tempClip.unloadMovie();
       }
    }