Brian Chia
       
 
categories
actionscript
actionscript 1.0
actionscript 2.0
misc
 
processing
 
links
brian chia
kelvin zhao
ronald leong
 
 
Bitmaps Smoothing
 
In order to allow external loaded bitmaps to have it smoothing turn on is by using the BitmapData Class.

In this example, i created a BitmapData instance and set the BitmapData smooth parameters to true to draw the external bitmap. This boolean will determines if a BitmapData object is smoothed when scale. The default value is false.



import flash.display.BitmapData;
import flash.geom.*;

// create an empty movieclip to load external bitmap
var mc:MovieClip=createEmptyMovieClip("mc",getNextHighestDepth());
mc._x=190;
mc._y=10;

/*
use loadClip() method to load external bitmap
offer number of advantages as it invoke:
onLoadStart handler when loading begins
onLoadError handler if clip cannot be loaded
onLoadProgress handler as the loading process progresses
onLoadComplete handler when a file completes downloading
onLoadInit handler after the actions in he 1st fram of clip is executed so that we can manipulate the loaded clip
*/

var mcl:MovieClipLoader=new MovieClipLoader();
mcl.addListener(this);
mcl.loadClip("http://www.thinklunatic.com/../images/caricature.jpg",mc);

// onLoadInit handler
function onLoadInit(mc:MovieClip){
var w:Number=mc._width;
var h:Number=mc._height;

// create a BitmapData object with loaded bitmap width and height
var bd:BitmapData=new BitmapData(w,h,true,0x00000000);

// create an empty movieclip to attach the BitmapData
var smc:MovieClip=createEmptyMovieClip("smc",getNextHighestDepth());
smc.attachBitmap(bd,2,"Always",true); //set the smooth parameter to true
smc._x=190;
smc._y=10;

// draw the source bitmap(mc) to the destination bitmap(bd)
bd.draw(mc);

// perform scaling
smc._xscale=80;
smc._yscale=80;

// remove mc to free up memory
mc.removeMovieClip();
}



suggestion

 
 
 
         
  © copyright 2007 THINKLUNATIC.    
Brian Chia Jonathan Ng