| This is NOT the official website of AvantBiz Consulting Limitd but just some casual discussions about various topics. Please visit www.avantbiz.com if you need our professional services. |
Dynamically loading bitmaps with smoothing in Flash Player 8 March 11, 2009
Posted by eddie in : Computer 電腦,Flash , trackbackFunction
import flash.display.*;
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) {
mc._visible = false;
var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true);
this.tmc.attachBitmap(bitmap, this.tmc.getNextHighestDepth(),”auto”, true);
bitmap.draw(mc);
};
// Do it, load the bitmap now
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
loader.loadClip(url, bmc);
}
To use this snippet simple paste the function into your code and then load a bitmap this way f.ex.:
loadBitmapSmoothed(“flash.png”, mc1.mc);
Comments»
no comments yet - be the first?