⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qbg.as

📁 as3.0 翻书效果
💻 AS
字号:
/**
* Description 版权所有2006@qz http://www.quick35.com
* @author crlnet
* @version 0.1
* @discription:用于整体背景;
*/
package crlclr.ui{
	
	import flash.display.BitmapData;
	import flash.net.URLRequest;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.*;
	
	import crlclr.data.BgInfor;
	import crlclr.siteCommon;
	

	public class Qbg extends Sprite {
		
		public var  bgInfor:BgInfor;
		private var loader:Loader;
		public var bmd:BitmapData;
		
		function Qbg(bgInfor:BgInfor) {
			
			
			//没有背影;
			if(!bgInfor.Path){
				return;
			}
			this.bgInfor=bgInfor;
			
			loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.INIT,initHander);
			loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR ,IoErrorHander);
			var urlRequest:URLRequest=new URLRequest(this.bgInfor.Path);
			loader.loadClip(urlRequest);
			
		}
		private function initHander(event:Event):Void {
			
			event.target.removeEventListener(Event.INIT,initHander);
			event.target.removeEventListener(IOErrorEvent.IO_ERROR ,IoErrorHander);
			
			if(!this.bgInfor.Repeat){
				loader._x=int((stage.stageWidth-loader.width)/2);
				loader._y=int((stage.stageWidth-loader.height)/2);
				loader.alpha=this.bgInfor.Alpha;
				return;
			}
			
			bmd = new BitmapData(loader.width, loader.height, false, 0);
			bmd.draw(target);
			
			with (this.graphics) {
				beginBitmapFill(this.bmd, new Matrix(), true);
				moveTo(0, 0);
				lineTo(2700, 0);
				lineTo(2700, 1500);
				lineTo(0, 1500);
				lineTo(0, 0);
				endFill();
				alpha=this.bgInfor.Alpha;
			}
			loader.unload();
			
		}
		
		
		private function IoErrorHander(event:Event) {
			loader.close();
			event.target.removeEventListener(Event.INIT,initHander);
			event.target.removeEventListener(IOErrorEvent.IO_ERROR ,IoErrorHander);
			
			throw new Error("在加载背景时出错");
		}
		
		public function onResize(){
			this.x=int((stage.stageWidth-this.width)/2);
			this.y=int((stage.stageHeight-this.height)/2);
		}		
		
		public function moveTo(x, y):Void {
			if (x != null) {
				self._x = x;
			}
			
			if (y != null) {
				self._y = y;
			}
			
		}
		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -