对于位图的切分,我们可以用BitmapData的copyPixels函数操作,下面是一个代码实例
import flash.display.Loader;import flash.net.URLRequest;import flash.display.Bitmap;import flash.display.BitmapData;import flash.events.Event;import flash.geom.Rectangle;import flash.geom.Point;import flash.display.Sprite;var loader:Loader = new Loader();var imgUrl:URLRequest = new URLRequest('123.jpg');loader.contentLoaderInfo.addEventListener(Event.COMPLETE,load_complete);loader.load(imgUrl);function load_complete(evt:Event):void{ var sourceBitmap = evt.target.loader.content as Bitmap;//等同于loader.content as Bitmap var spliteHorizon = 8; var spliteVertical = 5; var cHorizonLength = sourceBitmap.width/spliteHorizon; var cVerticalLength = sourceBitmap.height/spliteVertical; trace(cHorizonLength+','+cVerticalLength); var margin_top = 5; var margin_left = 5; for(var i=0 ; i< spliteVertical ; i++){ for(var j=0 ; j
执行结果如下: