Hello,
I am trying preload multiple images into an array of MCs…
So far I can do this with 1 image using the loadBitmapSmoothed function from this site: http://www.kaourantin.net/2005/12/dynamically-loading-bitmaps-with.html
Im using this function mainly because the images will be panning and scaling alot.
Here is my code which includes a preloader and I have also attached the flash file (Flash8)
stop();
import flash.display.*;
// INITIAL PRELOADER SCALE
preloader_mc._xscale = 0;
function loadBitmapSmoothed(url:String, target:MovieClip) {
// Create a movie clip which will contain our
// unsmoothed bitmap
var bmc:MovieClip = target.createEmptyMovieClip(
"bmc",
target.getNextHighestDepth());
// Create a listener which will notify us when
// the bitmap loaded successfully
var listener:Object = new Object();
// Track the target
listener.tmc = target;
// If the bitmap loaded successfully we redraw the
// movie into a BitmapData object and then attach
// that BitmapData to the target movie clip with
// the smoothing flag turned on.
listener.onLoadInit = function(mc:MovieClip) {
//_root.map._visible = false;
var bitmap:BitmapData = new BitmapData(
mc._width,
mc._height,
true);
this.tmc.attachBitmap(
bitmap,
this.tmc.getNextHighestDepth(),
"auto",
true);
bitmap.draw(mc);
};
//Listener for preloader
listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
var Total = bytesTotal;
percent = Math.round((bytesLoaded/bytesTotal)*100);
loaded = Math.round(getBytesLoaded() / 1024);
kBTotal = Math.round(Total/1024) + "kb";
_root.preloader_mc._xscale = bytesLoaded/bytesTotal * 100;
}
// Do it, load the bitmap now
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
loader.loadClip(url, bmc);
}
// Sample code
createEmptyMovieClip("mc1", getNextHighestDepth());
mc1.createEmptyMovieClip("mc", mc1.getNextHighestDepth());
loadBitmapSmoothed("sepia.jpg", mc1.mc);
Any help appreciated :beam: