ActionScript3.0平铺由外部加载的图片

var backImage:MovieClip = new MovieClip();

this.addChild (backImage);

var loader:Loader = new Loader();
loader.load (new URLRequest("http://www.baidu.com/img/logo-yy.gif"));
loader.contentLoaderInfo.addEventListener (Event.COMPLETE,showLoadResult);

function showLoadResult (event:Event):void {
        var _bitmap:Bitmap = Bitmap(loader.content);
        var matrix:Matrix = new Matrix(1, 0, 0, 1, this.stage.stageWidth / 2, this.stage.stageHeight / 2);
        var sampleSprite:Sprite = new Sprite();
		//sampleSprite.width=500;
		//sampleSprite.height=500;
        sampleSprite.graphics.beginBitmapFill (_bitmap.bitmapData, matrix , true , true);
        //sampleSprite.graphics.drawRect (this.stage.stageWidth / 2, this.stage.stageHeight / 2, _bitmap.width, _bitmap.height);
		 sampleSprite.graphics.drawRect (0, 0, this.stage.stageWidth, this.stage.stageHeight);
        sampleSprite.graphics.endFill ();
        backImage.addChild (sampleSprite);
}
posted @ 2011-02-22 14:04  Ricebug  阅读(378)  评论(0编辑  收藏  举报