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);

}

你可能感兴趣的:(actionscript)