加载图片,把图片平均分成两半,填充两个new shap.

package { 

import flash.display.Sprite;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.display.Shape;
import flash.geom.Rectangle;

public class ArgTest extends Sprite {
public function ArgTest() {
var url:String = "2009.jpg";
var _request:URLRequest = new URLRequest(url);
var loader:Loader = new Loader();
loader.load(_request);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadComplete);
}
private function loadComplete(evt:Event):void{
var bitmap:Bitmap = evt.target.content as Bitmap;
var shape1:Shape = new Shape();
shape1.graphics.beginBitmapFill(bitmap.bitmapData);
shape1.graphics.drawRect(bitmap.x,bitmap.y,bitmap.width ,bitmap.height/2);
addChild(shape1);
var shape2:Shape = new Shape();
shape2.graphics.beginBitmapFill(bitmap.bitmapData);
shape2.graphics.drawRect(bitmap.x,shape1.y+shape1.height+2,bitmap.width ,bitmap.height/2);
addChild(shape2);
}

}
}

你可能感兴趣的:(.net,Flash)