as3 绘制Sprite背景色

北城以北 提交于 2019-11-27 08:39:48

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!