as3 绘制Sprite背景色
作者:互联网
原文链接:http://www.cnblogs.com/WilliamJiang/archive/2012/06/27/2565521.html
1.可以用来更改Flash背景风格
private function imgLoader(imagePath:String):void { skinsLoader = new Loader(); skinsLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,imgLoaderComplete); skinsLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,imgIOErrorHandler); var urlRequest:URLRequest = new URLRequest(); urlRequest.url = "resource/"+imagePath; skinsLoader.load(urlRequest); } private function imgLoaderComplete(event:Event):void { var bitmap:Bitmap = event.target.content as Bitmap; bitmap.width = stage.stageWidth, bitmap.height = stage.stageHeight; var bitmapData:BitmapData=bitmap.bitmapData; this.graphics.beginFill(0x000000); this.graphics.drawRect(0,0,this.width,this.height); this.graphics.beginBitmapFill(bitmapData); this.graphics.drawRect(this.x,this.y,this.width,this.height); this.graphics.endFill(); skinsLoader.contentLoaderInfo.removeEventListener (Event.COMPLETE , imgLoaderComplete); skinsLoader.contentLoaderInfo.removeEventListener (IOErrorEvent.IO_ERROR , imgIOErrorHandler); skinsLoader = null; }
转载于:https://www.cnblogs.com/WilliamJiang/archive/2012/06/27/2565521.html
标签:as3,imgLoaderComplete,Sprite,bitmap,背景色,width,graphics,skinsLoader,contentLoader 来源: https://blog.csdn.net/weixin_30763397/article/details/99614404