import flash.display.Loader;
import flash.net.URLRequest;
var lc:LoaderContext = new LoaderContext(true);

var inid:String = stage.loaderInfo.parameters.inid; //qid
var temp_domain:String = stage.loaderInfo.parameters.my_domain;
var chushi_ban:String = stage.loaderInfo.parameters.ban;
var now_data:String =''; //本版报纸的时间
var news_big_pic_url:String =''; //新闻中大图的地址

var sys_sound:Number=1; //系统声音
var now_ban_page:Number = 1; //当前所在版面
var go_to_ban_page:Number = 1; //要转到的版面
var now_news_page:Number=0; //当前新闻的页数
var go_to_news_page:Number=1; //要转到的页数
var total_ban:Number = 0; //本期多少版
var total_news:Number=0; //本版多少新闻

var targetURLto:String; //   新窗口url

var mySprite:Sprite = new Sprite();  //选择区域
var load_php_sys_data:URLLoader = new URLLoader();
var load_php_sys:String = 'Newspaper_info_load.php'; //加载系统数据
var load_php_ban_data:URLLoader = new URLLoader();
var load_php_ban:String = 'Newspaper_info_ban_load.php'; //加载板块数据
var load_php_news_data:URLLoader = new URLLoader();
var load_php_news:String = 'Newspaper_info_news_load.php'; //加载新闻数据

if(inid == null){inid = "1287669734"; }
if(chushi_ban == null){chushi_ban = "1"; }
if(temp_domain == null){temp_domain = "http://localhost/bao/"; }
var my_domain:String = temp_domain + "";

//trace(temp_domain)


//初始选框
news_mc.visible = false;//新闻内容层不可见
news_mc_cp.visible = false;//新闻控制层不可见
news_title_tishi_mc.visible = false;//新闻标题提示不可见
down_page.visible = false;//下翻页不可见
up_page.visible = false; //上翻页不可见
load_mc.visible = false; //加载动画mc不可见
news_dao_hang.visible = false; //导航层
ban_dao_hang.visible = false; //导航层
dong_hua_mc.visible = false; //新闻翻篇动画
big_pic.visible = false; //大图片层
btn_up_ban.gotoAndStop(2);
btn_up_ban.buttonMode = true;
btn_down_ban.buttonMode = true;
btn_ban_daohang.buttonMode = true; //版面导航
btn_news_daohang.buttonMode = true; //新闻导航
news_mc_cp.btn_up_pian.buttonMode = true; //上一篇
news_mc_cp.btn_down_pian.buttonMode = true; //下一篇
news_mc.xia_la_tiao.source = news_mc.pan;//下拉条

//加载报纸头部图片
loadImage_cover(mc_cover, temp_domain + 'images/cover.jpg?time=' + new Date());

fn_load_php_sys_data(); //加载数据


//加载报纸主要数据--------------------------------------------------------------------------------------------------------------------------------------------------------------
function fn_load_php_sys_data() 
{
	var load_url:URLRequest = new URLRequest(my_domain + load_php_sys + "?qid=" + inid + "&time=" + new Date());
	//trace(my_domain + load_php_sys + "?nid=" + inid + "&time=" + new Date())
	load_php_sys_data.load(load_url);
	load_php_sys_data.addEventListener (Event.COMPLETE, load_php_sys_data_ok);
	load_php_sys_data.addEventListener (IOErrorEvent.IO_ERROR, onLoadError);
	load_php_sys_data.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
    load_php_sys_data.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
	
	function securityErrorHandler(event:SecurityErrorEvent)
	{
		//dbug(load_php_sys+'无法加载系统数据,错误代码(SECURITY_ERROR)');
	}
	function httpStatusHandler(event:HTTPStatusEvent)
	{
		//dbug(load_php_sys+'正在加载系统数据，请稍后...')
	}
	function onLoadError(event:Event)
	{
		//dbug(load_php_sys+'无法加载系统数据,错误代码(IO_ERROR)');
	}
}

//加载主要数据成功
function load_php_sys_data_ok(event:Event):void 
{
	var Temp_XML:XML=new XML();
	Temp_XML = new XML(event.target.data);
	title_mc.htmlText = Temp_XML.can_shu.@datahtml;
	total_ban = Temp_XML.can_shu.@ban_num;
	now_data= Temp_XML.can_shu.@now_data;
	//trace(pic_url,news_name)	
	//清除列表
	delDisplayList(ban_list_mc.list);
	delDisplayList(ban_dao_hang.list)//导航板块
	//生成板块列表面板数据
	for(var i2:int=0; i2<Temp_XML.ban_list.length(); i2++) 
	{
			var ban_title_mc:ban_title=new ban_title();			
			//设置传递的参数-----------------------------------------------------------------------
			ban_title_mc._bnum = Temp_XML.ban_list[i2].bnum;
			ban_title_mc._ban_name = Temp_XML.ban_list[i2].ban_name;			
			ban_title_mc._ban_pic = Temp_XML.ban_list[i2].ban_pic;
			
			//板块位置及大小
			ban_title_mc.x = 0;
			ban_title_mc.y = 28 * i2;
		
			ban_title_mc.note.text='第'+Temp_XML.ban_list[i2].ban_name;	
			ban_title_mc.buttonMode = true; 
			ban_list_mc.list.addChild(ban_title_mc);
			
			ban_title_mc.addEventListener(MouseEvent.CLICK, ban_title_mc_click);
			ban_title_mc.addEventListener(MouseEvent.MOUSE_OVER,ban_title_mc_MOUSE_OVER); //提示 
			ban_title_mc.addEventListener(MouseEvent.MOUSE_OUT, ban_title_mc_MOUSE_OUT); //提示消除
			
			//标题导航	--------------------------------------------------------------------		
			var name_dao_hang_mc:name_dao_hang=new name_dao_hang();			
			//传递参数
			name_dao_hang_mc._bnum = Temp_XML.ban_list[i2].bnum;
			//区域位置及大小
			name_dao_hang_mc.x = 0;
			name_dao_hang_mc.y = 28 * i2;
				
			name_dao_hang_mc.note.text='第'+Temp_XML.ban_list[i2].ban_name;	
			name_dao_hang_mc.buttonMode = true; 
			ban_dao_hang.list.addChild(name_dao_hang_mc);
			//事件
			name_dao_hang_mc.addEventListener(MouseEvent.CLICK, ban_title_mc_click);
			name_dao_hang_mc.addEventListener(MouseEvent.MOUSE_OVER,name_dao_hang_mc_MOUSE_OVER); //提示 
			name_dao_hang_mc.addEventListener(MouseEvent.MOUSE_OUT, name_dao_hang_mc_MOUSE_OUT); //提示消除	
	}	
	
	//加载默认板块新闻列表
	load_ban_list(chushi_ban);
}
function ban_title_mc_click(event:MouseEvent):void
{
 	go_to_ban_page = event.target.parent._bnum;
	if (go_to_ban_page != now_ban_page)
	{
		load_ban_list(event.target.parent._bnum);
	}
}
function ban_title_mc_MOUSE_OUT(event:MouseEvent):void
{
    event.target.parent.gotoAndStop(1);
}
 function ban_title_mc_MOUSE_OVER(event:MouseEvent):void
{
    event.target.parent.gotoAndStop(2);
}

//导航触发事件
function name_dao_hang_mc_MOUSE_OUT(event:MouseEvent):void
{
    
	event.target.parent.gotoAndStop(1);
}
 function name_dao_hang_mc_MOUSE_OVER(event:MouseEvent):void
{
    ban_dao_hang.visible = true;
	event.target.parent.gotoAndStop(2);
}




//加载指定的板块新闻图片和列表----------------------------------------------------------------------------------------------------------------------------------------
function load_ban_list(bnum)
{	
	addEventListener(Event.ENTER_FRAME, news_mc_return_d_del);
	//翻页状态
	if(bnum==1){btn_up_ban.gotoAndStop(2);}else{btn_up_ban.gotoAndStop(1);}
	if(bnum==total_ban){btn_down_ban.gotoAndStop(2);}else{btn_down_ban.gotoAndStop(1);}
		
	ban_page_tishi.text =bnum+'/'+total_ban;
	down_page.gotoAndStop(1);
	up_page.gotoAndStop(1);
	//判断翻页动画效果
	if (now_ban_page != go_to_ban_page)
	{
		now_news_page = 0;
		//trace('翻页')
		if (go_to_ban_page > now_ban_page)//向下翻页
		{
			//清除翻页画面
			delDisplayList(down_page.pic);
			//复制画面到翻页画面
			var bpd1 =  new BitmapData(450, 674, true, 0x00ffffff);
			bpd1.draw(baozhi_mc.pic_mc);
			delDisplayList(baozhi_mc.pic_mc);
			var Bitmap1= new Bitmap(bpd1);
			down_page.pic.addChild(Bitmap1);
			//开始效果
			down_page.gotoAndPlay(2);
			if(sys_sound==1){sound_mc.gotoAndPlay(2);}
			down_page.visible = true;
		}
		else//向上翻页
		{
			//清除翻页画面
			delDisplayList(up_page.pic);
			//复制画面到翻页画面
			var bpd2 =  new BitmapData(450, 674, true, 0x00ffffff);
			bpd2.draw(baozhi_mc.pic_mc);
			delDisplayList(baozhi_mc.pic_mc);
			var Bitmap2= new Bitmap(bpd2);
			up_page.pic.addChild(Bitmap2);
			//开始效果
			up_page.gotoAndPlay(2);
			if(sys_sound==1){sound_mc.gotoAndPlay(2);}
			up_page.visible = true;
		}
	
		
		
	}
	
	now_ban_page = bnum;
	//dbug('当前是第'+now_ban_page+'版')	
	//开始加载
	//dbug('加载第' + bnum + '版数据开始')
	var load_url2:URLRequest = new URLRequest(my_domain + load_php_ban + "?qid=" + inid + "&bnum=" + bnum + "&time=" + new Date());
	//trace(my_domain + load_php_ban + "?qid=" + inid + "&bnum=" + bnum + "&time=" + new Date())
	load_php_ban_data.load(load_url2);
	load_php_ban_data.addEventListener (Event.COMPLETE, load_ban_list_ok);
	load_php_ban_data.addEventListener (IOErrorEvent.IO_ERROR, onLoadError2);
	load_php_ban_data.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler2);
    load_php_ban_data.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler2);
	
	function securityErrorHandler2(event:SecurityErrorEvent)
	{
		//dbug(load_php_ban+'无法加载板块数据,错误代码(SECURITY_ERROR)');
	}
	function httpStatusHandler2(event:HTTPStatusEvent)
	{
		//dbug(load_php_ban+'正在加载板块数据，请稍后...')
	}
	function onLoadError2(event:Event)
	{
		//dbug(load_php_ban+'无法加载板块数据,错误代码(IO_ERROR)');
	}
}

//加载主要数据成功
function load_ban_list_ok(event:Event):void 
{
	var Temp_XML:XML=new XML();
	Temp_XML = new XML(event.target.data);
	
	news_list_mc.title_mc.text ='第'+Temp_XML.ban_name;//板块名称
	
	//加载图片
	load_mc.visible = true; //加载动画mc可见
	loadImage_ban(baozhi_mc.pic_mc, temp_domain + Temp_XML.can_shu.@ban_pic);
	total_news = Temp_XML.can_shu.@total_news;

	//绘制热点区域
	delDisplayList(baozhi_mc.quyu)
	delDisplayList(news_list_mc.list)
	delDisplayList(news_dao_hang.list)
	
	
	//dbug('共：'+total_ban+'版'+total_news+'条新闻'+go_to_ban_page+now_news_page)
	for(var i1:int=0; i1<Temp_XML.news_list.length(); i1++) 
	{
			//蓝色区域-------------------------------------------------------------
			var quyu_lan_mc:quyu_lan=new quyu_lan();
			//trace(quyu_lan_mc.name)
			quyu_lan_mc.name = 'quyu' + Temp_XML.news_list[i1].nid;
			//trace(quyu_lan_mc.name)
			//设置传递的参数
			
			quyu_lan_mc._npage = Temp_XML.news_list[i1].npage;
			quyu_lan_mc._bnum = Temp_XML.news_list[i1].bnum;
			quyu_lan_mc._nid = Temp_XML.news_list[i1].nid;			
			quyu_lan_mc._bid = Temp_XML.news_list[i1].bid;
			quyu_lan_mc._redian = Temp_XML.news_list[i1].redian;
			quyu_lan_mc._ztitle = Temp_XML.news_list[i1].ztitle;
			quyu_lan_mc._qtitle = Temp_XML.news_list[i1].qtitle;
			quyu_lan_mc._htitle = Temp_XML.news_list[i1].htitle;
			quyu_lan_mc.buttonMode = true;
			//区域位置及大小
			quyu_lan_mc.x = get_string_array(Temp_XML.news_list[i1].redian, '||', 0);
			quyu_lan_mc.y = get_string_array(Temp_XML.news_list[i1].redian, '||', 1);
			quyu_lan_mc.width = get_string_array(Temp_XML.news_list[i1].redian, '||', 2);
			quyu_lan_mc.height = get_string_array(Temp_XML.news_list[i1].redian, '||', 3);			
			baozhi_mc.quyu.addChild(quyu_lan_mc);
			//事件
			quyu_lan_mc.addEventListener(MouseEvent.CLICK, quyu_lan_mc_click);
			quyu_lan_mc.addEventListener(MouseEvent.MOUSE_MOVE,quyu_lan_mc_MOUSE_MOVE); //提示 
			quyu_lan_mc.addEventListener(MouseEvent.MOUSE_OUT, del_title_tishi); //提示消除
			
			
			//生成新闻列表数据-------------------------------------------------------------
			var news_title_mc:news_title=new news_title();			
			//传递参数
			news_title_mc._npage = Temp_XML.news_list[i1].npage;
			news_title_mc._nid = Temp_XML.news_list[i1].nid;
			//区域位置及大小
			news_title_mc.x = 0;
			news_title_mc.y = 28 * i1;
				
			news_title_mc.note.text=Temp_XML.news_list[i1].ztitle;	
			news_title_mc.buttonMode = true; 
			news_list_mc.list.addChild(news_title_mc);
			//事件
			news_title_mc.addEventListener(MouseEvent.CLICK, news_title_mc_click);
			news_title_mc.addEventListener(MouseEvent.MOUSE_OVER,news_title_mc_MOUSE_OVER); //提示 
			news_title_mc.addEventListener(MouseEvent.MOUSE_OUT, news_title_mc_MOUSE_OUT); //提示消除		
			
			//标题导航	--------------------------------------------------------------------		
			var title_dao_hang_mc:title_dao_hang=new title_dao_hang();			
			//传递参数
			title_dao_hang_mc._npage = Temp_XML.news_list[i1].npage;
			title_dao_hang_mc._nid = Temp_XML.news_list[i1].nid;
			//区域位置及大小
			title_dao_hang_mc.x = 0;
			title_dao_hang_mc.y = 28 * i1;
				
			title_dao_hang_mc.note.text=Temp_XML.news_list[i1].ztitle;	
			title_dao_hang_mc.buttonMode = true; 
			news_dao_hang.list.addChild(title_dao_hang_mc);
			//事件
			title_dao_hang_mc.addEventListener(MouseEvent.CLICK, title_dao_hang_mc_click);
			title_dao_hang_mc.addEventListener(MouseEvent.MOUSE_OVER,title_dao_hang_mc_MOUSE_OVER); //提示 
			title_dao_hang_mc.addEventListener(MouseEvent.MOUSE_OUT, title_dao_hang_mc_MOUSE_OUT); //提示消除	
			
	}
	

	
}
//点击蓝色区域
function quyu_lan_mc_click(event:MouseEvent):void
{
   open_news(event.target.parent._nid,event.target.parent._npage);//开启新闻
   news_dao_hang.visible = false;
}
//点击新闻列表
function news_title_mc_click(event:MouseEvent):void
{
   open_news(event.target.parent._nid,event.target.parent._npage);//开启新闻
   news_dao_hang.visible = false;
}
 function news_title_mc_MOUSE_OVER(event:MouseEvent):void
{
    event.target.parent.gotoAndStop(2);
	quyu_lan_view(event.target.parent._nid)//触发区域变化
}
function news_title_mc_MOUSE_OUT(event:MouseEvent):void
{
    event.target.parent.gotoAndStop(1);
	quyu_lan_del(event.target.parent._nid)//触发区域变化
}

//点击导航新闻列表
function title_dao_hang_mc_click(event:MouseEvent):void
{
	open_news(event.target.parent._nid,event.target.parent._npage);//开启新闻
	news_dao_hang.visible = false;
}
 function title_dao_hang_mc_MOUSE_OVER(event:MouseEvent):void
{
    news_dao_hang.visible = true;
	event.target.parent.gotoAndStop(2);
	quyu_lan_view(event.target.parent._nid)//触发区域变化
}

function title_dao_hang_mc_MOUSE_OUT(event:MouseEvent):void
{
    //news_dao_hang.visible = true;
	event.target.parent.gotoAndStop(1);
	quyu_lan_del(event.target.parent._nid)//触发区域变化
}


//区域显示蓝色
function quyu_lan_view(in_nid:String)
{
	//var temp_Child_obj:MovieClip = new MovieClip(); 
	var pan_cnum:uint = baozhi_mc.quyu.numChildren;		
	for (var i3:uint=0; i3 < pan_cnum; i3++)
	{
		baozhi_mc.quyu.getChildAt(i3).gotoAndStop(1);
		if (baozhi_mc.quyu.getChildAt(i3)._nid ==  in_nid) //选中要操作的面板
		{
			baozhi_mc.quyu.getChildAt(i3).gotoAndStop(2);
		}
	}
}
//区域不显示蓝色
function quyu_lan_del(in_nid:String)
{
	var pan_cnum:uint = baozhi_mc.quyu.numChildren;		
	for (var i4:uint=0; i4 < pan_cnum; i4++)
	{
		if (baozhi_mc.quyu.getChildAt(i4)._nid ==  in_nid) //选中要操作的面板
		{
			baozhi_mc.quyu.getChildAt(i4).gotoAndStop(1);
		}
	}
}

//新闻列表显示蓝色
function news_lan_view(in_nid:String)
{
	var pan_cnum:uint = news_list_mc.list.numChildren;		
	for (var i3:uint=0; i3 < pan_cnum; i3++)
	{
		news_list_mc.list.getChildAt(i3).gotoAndStop(1);
		if (news_list_mc.list.getChildAt(i3)._nid ==  in_nid) //选中要操作的面板
		{
			news_list_mc.list.getChildAt(i3).gotoAndStop(2);
		}
	}
}
//新闻列表不显示蓝色
function news_lan_del(in_nid:String)
{
	var pan_cnum:uint = news_list_mc.list.numChildren;		
	for (var i4:uint=0; i4 < pan_cnum; i4++)
	{
		if (news_list_mc.list.getChildAt(i4)._nid ==  in_nid) //选中要操作的面板
		{
			news_list_mc.list.getChildAt(i4).gotoAndStop(1);
		}
	}
}

function quyu_lan_mc_MOUSE_MOVE(event:MouseEvent)
{
	//trace(event.target.parent._ztitle,event.target._qtitle,event.target._htitle)
	event.target.parent.gotoAndStop(2);
	news_lan_view(event.target.parent._nid)//触发新闻区域变化
	news_title_tishi_mc.visible = true;//
	show_title_tishi(event.target.parent._ztitle,event.target.parent._qtitle,event.target.parent._htitle,10)
}


//点击返回到新闻列表
news_mc_cp.btn_retrun_list.addEventListener(MouseEvent.CLICK, btn_retrun_list_click);
function btn_retrun_list_click(event:MouseEvent):void
{
  addEventListener(Event.ENTER_FRAME, news_mc_return_d_del);
}

//点击新闻后----------------------------------------------------------------------------------------------------------------------------------------------------
function open_news(newsid:String,temp_news_page:String)
{
	news_mc_cp.btn_up_pian.gotoAndStop(1);
	news_mc_cp.btn_down_pian.gotoAndStop(1);
	//判断页码的合理性和翻页是否可用
	go_to_news_page=int(temp_news_page);
	if (go_to_news_page < 1){go_to_news_page = 1; }
	if (go_to_news_page > total_news ){go_to_news_page = total_news; }
    if (go_to_news_page == 1){news_mc_cp.btn_up_pian.gotoAndStop(2); }	
	if (go_to_news_page == total_news){news_mc_cp.btn_down_pian.gotoAndStop(2); }
	
	news_mc_cp.page_ji_shu.text = go_to_news_page + '/' + total_news;
	//判断可见属性 如果不可见 触发动画效果
	//trace(go_to_news_page,now_news_page)
	dong_hua_mc.visible = false;
	if (news_mc.visible == false)
	{
		news_mc.x = 1002;
		news_mc_cp.x = 1002;
		news_mc.visible = true;
		news_mc_cp.visible = true;
		addEventListener(Event.ENTER_FRAME, news_mc_return_d_j);
	}
	else
	{
		
		//翻页效果
		if (go_to_news_page != now_news_page)
		{
			if (now_news_page != 0)
			{
				if (now_news_page > go_to_news_page)
				{
					//复制画面到翻页画面
					var bpd3 =  new BitmapData(510, 543, true, 0x00ffffff);
					bpd3.draw(news_mc);				
					
						news_mc.pan.q_biao_ti.text = '';
						news_mc.pan.z_biao_ti.text = '';
						news_mc.pan.h_biao_ti.text = '';
						news_mc.pan.news_note.htmlText = '';	
						

						news_mc.now_time.text = now_data;
						delDisplayList(news_mc.pan.pic_mc.inpic); //清空
						delDisplayList(news_mc.pan.pic_mc.pic_page); //清空
						//屏蔽新闻显示
						news_mc.pan.visble = false;
					
					delDisplayList(dong_hua_mc);
					var Bitmap3 = new Bitmap(bpd3);
					dong_hua_mc.addChild(Bitmap3);					
					//开始效果
					news_mc.x = -78;
					dong_hua_mc.x = 462;
					dong_hua_mc.visible = true;
					addEventListener(Event.ENTER_FRAME, news_mc_up_pian_d);	
					
				}
				else
				{
					//复制画面到翻页画面
					var bpd4 =  new BitmapData(510, 543, true, 0x00ffffff);
					bpd4.draw(news_mc);
					
						news_mc.pan.q_biao_ti.text = '';
						news_mc.pan.z_biao_ti.text = '';
						news_mc.pan.h_biao_ti.text = '';
						news_mc.pan.news_note.htmlText = '';	
						

						news_mc.now_time.text = now_data;
						delDisplayList(news_mc.pan.pic_mc.inpic); //清空
						delDisplayList(news_mc.pan.pic_mc.pic_page); //清空
						//屏蔽新闻显示
						news_mc.pan.visble = false;
						
					delDisplayList(dong_hua_mc);
					var Bitmap4 = new Bitmap(bpd4);
					dong_hua_mc.addChild(Bitmap4);					
					//开始效果
					news_mc.x = 1002;
					dong_hua_mc.x = 462;
					dong_hua_mc.visible = true;
					addEventListener(Event.ENTER_FRAME, news_mc_down_pian_d);	
					
				}
			}
		}
	}
	
	//判断是否和当前显示的一致
	if (go_to_news_page != now_news_page)
	{
		
		now_news_page = go_to_news_page;
		
		//屏蔽新闻显示
		news_mc.pan.visble = false;
		
		
		//加载新闻
		//trace(now_ban_page,inid,now_news_page)
		var load_url3:URLRequest = new URLRequest(my_domain + load_php_news + "?nid=" + newsid + "&bnum="+now_ban_page+"&qid="+inid+"&page=" + now_news_page + "&time=" + new Date());
		load_php_news_data.load(load_url3);
		load_php_news_data.addEventListener (Event.COMPLETE, load_php_news_ok);
		load_php_news_data.addEventListener (IOErrorEvent.IO_ERROR, onLoadError3);
		load_php_news_data.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler3);
		load_php_news_data.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler3);
		
		function securityErrorHandler3(event:SecurityErrorEvent)
		{
			//dbug(load_php_news+'无法加载新闻数据,错误代码(SECURITY_ERROR)');
		}
		function httpStatusHandler3(event:HTTPStatusEvent)
		{
			//dbug(load_php_news+'正在加载新闻数据，请稍后...')
		}
		function onLoadError3(event:Event)
		{
			//dbug(load_php_news+'无法加载新闻数据,错误代码(IO_ERROR)');
		}
	}
}


//新闻翻页 上一篇
function news_mc_up_pian_d(event:Event)
{      	
	if (news_mc.x < 462)
	{
		news_list_mc.visible = false;
		ban_list_mc.visible=false;
		news_mc.x = news_mc.x +45 ;
		dong_hua_mc.x = dong_hua_mc.x+45;
	}
	else
	{
		news_mc.x = 462;
		dong_hua_mc.visible = false;
		news_list_mc.visible = true;
		ban_list_mc.visible=true;
		removeEventListener(Event.ENTER_FRAME, news_mc_up_pian_d);	
	}
}
//新闻翻页 下一篇
function news_mc_down_pian_d(event:Event)
{      	
	if (news_mc.x > 462)
	{
		news_list_mc.visible = false;
		ban_list_mc.visible=false;
		news_mc.x = news_mc.x -45 ;
		dong_hua_mc.x = dong_hua_mc.x-45;
	}
	else
	{
		news_mc.x = 462;
		dong_hua_mc.visible = false;
		news_list_mc.visible = true;
		ban_list_mc.visible=true;
		removeEventListener(Event.ENTER_FRAME, news_mc_down_pian_d);	
	}
}

news_mc.pan.z_biao_ti.autoSize = 'center';
news_mc.pan.q_biao_ti.autoSize = 'center';
news_mc.pan.h_biao_ti.autoSize = 'center';
news_mc.pan.news_note.autoSize = 'center';

//加载主要数据成功

function load_php_news_ok(event:Event):void 
{
	var temp_x:Number = 4.5;
	var temp_y:Number = 15;
	news_mc.pan.q_biao_ti.text = '';
	news_mc.pan.z_biao_ti.text = '';
	news_mc.pan.h_biao_ti.text = '';
	news_mc.pan.news_note.htmlText = '';	
	news_mc.pan.pic_mc.visible = false;

	news_mc.now_time.text = now_data;
	delDisplayList(news_mc.pan.pic_mc.inpic); //清空
	delDisplayList(news_mc.pan.pic_mc.pic_page); //清空
	//屏蔽新闻显示
	news_mc.pan.visble = false;
	
	var Temp_XML:XML=new XML();
	Temp_XML = new XML(event.target.data);
	//trace(Temp_XML)
	//处理文字和位置
	news_mc.bname.text = Temp_XML.news_note.bname;
	
	if(Temp_XML.news_note.qtitle != '')
	{
		news_mc.pan.q_biao_ti.text = Temp_XML.news_note.qtitle;
		news_mc.pan.q_biao_ti.x = temp_x;
		news_mc.pan.q_biao_ti.y = temp_y;
		temp_y = temp_y + news_mc.pan.q_biao_ti.textHeight;		
	}
	if(Temp_XML.news_note.ztitle != '')
	{
		news_mc.pan.z_biao_ti.text = Temp_XML.news_note.ztitle;
		news_mc.pan.z_biao_ti.x = temp_x;
		news_mc.pan.z_biao_ti.y = temp_y;
		temp_y = temp_y + news_mc.pan.z_biao_ti.textHeight;		
	}
	if(Temp_XML.news_note.htitle != '')
	{
		news_mc.pan.h_biao_ti.text = Temp_XML.news_note.htitle;
		news_mc.pan.h_biao_ti.x = temp_x;
		news_mc.pan.h_biao_ti.y = temp_y;
		temp_y = temp_y + news_mc.pan.h_biao_ti.textHeight;
	}
	
	
	//处理图片
	if (int(Temp_XML.news_note.pic_num) > 0 )
	{
		news_mc.pan.pic_mc.visible = true;
		news_mc.pan.pic_mc.y = temp_y + 10;
		temp_y = temp_y + 300;
		//加载图片
		
		news_mc.pan.pic_mc.pic_page.x = 374 - ((int(Temp_XML.news_note.pic_num) -1) * 25);
		for(var i5:int=0; i5<Temp_XML.pic_list.length(); i5++) 
		{
			//trace(Temp_XML.pic_list[i5].supfile)			
			//添加按钮
			var btn_click:btn_choose = new btn_choose();
			
			btn_click._id = i5;
			btn_click._pnum =Temp_XML.news_note.pic_num
			btn_click.name='btn_'+i5;
			btn_click._pname=Temp_XML.pic_list[i5].pname;
			btn_click._supfile = Temp_XML.pic_list[i5].supfile;
			btn_click._upfile=Temp_XML.pic_list[i5].upfile;
			btn_click.y=0
			btn_click.x = i5 * 25;		
		    btn_click.note.text= String(i5+1);
			news_mc.pan.pic_mc.pic_page.addChild (btn_click);		
			
			btn_click.buttonMode = true;
			btn_click.addEventListener(MouseEvent.CLICK, btn_click_flash);		
			
			if (i5 == 0)
			{
				btn_click.gotoAndStop(2);
				news_mc.pan.pic_mc.pic_name.text = Temp_XML.pic_list[i5].pname;
				news_big_pic_url = Temp_XML.pic_list[i5].upfile;
				loadImage_snews(news_mc.pan.pic_mc.inpic, temp_domain + Temp_XML.pic_list[i5].supfile);	
			}			
		}
		if (int(Temp_XML.news_note.pic_num) > 1)
		{
			news_mc.pan.pic_mc.pic_page.visible = true;
		}
		else
		{
			news_mc.pan.pic_mc.pic_page.visible = false;
		}
	}
	else
	{
		temp_y = temp_y -10;
	}
	
	//文字
	news_mc.pan.news_note.y = temp_y + 20;
	news_mc.pan.news_note.htmlText = '    ' + Temp_XML.news_note.n_note + '\n\n';
	
	news_mc.xia_la_tiao.update();
	news_mc.xia_la_tiao.verticalScrollPosition = 0; 	
}
		

function btn_click_flash(event:MouseEvent):void 
{	
	var temp_Child_obj:MovieClip = new MovieClip(); 
	for (var i6:uint=0; i6 < event.currentTarget._pnum; i6++)
	{
		
		temp_Child_obj = news_mc.pan.pic_mc.pic_page.getChildAt(i6);
		if (temp_Child_obj._id ==  event.currentTarget._id) 
		{
			temp_Child_obj.gotoAndStop(2);
		}
		else
		{
			temp_Child_obj.gotoAndStop(1);
		}
	}
	
	news_big_pic_url = event.currentTarget._upfile;
	news_mc.pan.pic_mc.pic_name.text = event.currentTarget._pname;
	loadImage_snews(news_mc.pan.pic_mc.inpic, temp_domain + event.currentTarget._supfile);
	//大图地址
	
}

//新闻动画效果 进入
function news_mc_return_d_j(event:Event)
{      	
	if (news_mc.x > 462)
	{
		news_mc.x = news_mc.x - 90;
		news_mc_cp.x = news_mc_cp.x - 90;
	}
	else
	{
		news_mc.x = 462;
		news_mc_cp.x = 462;
		removeEventListener(Event.ENTER_FRAME, news_mc_return_d_j);	
	}
}

//新闻动画效果 退出
function news_mc_return_d_del(event:Event)
{      	
	if (news_mc.x < 1002)
	{
		news_mc.x = news_mc.x + 90;
		news_mc_cp.x = news_mc_cp.x + 90;
	}
	else
	{
		news_mc.x = 1002;
		news_mc_cp.x = 1002;
		news_mc.visible = false;
		news_mc_cp.visible = false;
		removeEventListener(Event.ENTER_FRAME, news_mc_return_d_del);	
	}
}

//上一页
news_mc_cp.btn_up_pian.addEventListener(MouseEvent.CLICK, btn_up_pian_CLICK);
function btn_up_pian_CLICK(event:MouseEvent)
{
	go_to_news_page = now_news_page - 1;
	open_news('',String(go_to_news_page))
}
news_mc_cp.btn_down_pian.addEventListener(MouseEvent.CLICK, btn_down_pian_CLICK);
function btn_down_pian_CLICK(event:MouseEvent)
{
	go_to_news_page = now_news_page + 1;
	open_news('',String(go_to_news_page))
}
//滚动效果
news_mc_cp.btn_hondong.addEventListener(MouseEvent.MOUSE_OVER,btn_hondong_MOUSE_OVER); 
news_mc_cp.btn_hondong.addEventListener(MouseEvent.MOUSE_OUT, btn_hondong_MOUSE_OUT); 
function btn_hondong_MOUSE_OVER(event:MouseEvent):void
{
   addEventListener(Event.ENTER_FRAME, news_mc_btn_hondong_return_d);
}
function btn_hondong_MOUSE_OUT(event:MouseEvent):void
{
    removeEventListener(Event.ENTER_FRAME, news_mc_btn_hondong_return_d);	
}
function news_mc_btn_hondong_return_d(event:Event)
{      	
	 news_mc.xia_la_tiao.verticalScrollPosition += 0.8;
}

//建立提示对象--------------------------------------------------------------------------------------------------------
var infobg:Sprite = new Sprite();
//infobg.graphics.lineStyle(0.1, 0x000000);
infobg.graphics.beginFill(0xffffff);        
infobg.graphics.drawRect(0, 0, 20, 20);
news_title_tishi_mc.bg.addChild(infobg);

var infobg_red:Sprite = new Sprite();
infobg_red.graphics.beginFill(0xe99999);        
infobg_red.graphics.drawRect(0, 0, 18, 18);
infobg_red.x = 1;
infobg_red.y = 1;
news_title_tishi_mc.bg.addChild(infobg_red);

var infobg_bai:Sprite = new Sprite();
infobg_bai.graphics.beginFill(0xffffff);        
infobg_bai.graphics.drawRect(0, 0, 18, 18);
infobg_bai.x = 7;
infobg_bai.y = 7;
news_title_tishi_mc.bg.addChild(infobg_bai);

news_title_tishi_mc.z_biao_ti.autoSize = 'center';
news_title_tishi_mc.q_biao_ti.autoSize = 'center';
news_title_tishi_mc.h_biao_ti.autoSize = 'center';

var news_tishi_w:Number = 0; //提示高度
var news_tishi_h:Number=0; //提示文字宽度
var news_tishi_w_max:Number=0; //那个文字最宽

news_title_tishi_mc.visible = false;

function show_title_tishi(z_biao_ti:String,q_biao_ti:String,h_biao_ti:String,buchunx:int)
{ 
	news_title_tishi_mc.visible = true;
	news_title_tishi_mc.q_biao_ti.text = '';
	news_title_tishi_mc.z_biao_ti.text = '';
	news_title_tishi_mc.h_biao_ti.text = '';
	
	news_title_tishi_mc.q_biao_ti.text = q_biao_ti+'\n ';
	news_title_tishi_mc.z_biao_ti.text = z_biao_ti;
	news_title_tishi_mc.h_biao_ti.text =  h_biao_ti+'\n ';
	
	//取最大宽宽
	news_tishi_w_max = news_title_tishi_mc.z_biao_ti.textWidth;
	if (news_title_tishi_mc.z_biao_ti.textWidth < news_title_tishi_mc.q_biao_ti.textWidth)
	{
		news_tishi_w_max = news_title_tishi_mc.q_biao_ti.textWidth;
	}
	if (news_tishi_w_max < news_title_tishi_mc.h_biao_ti.textWidth)
	{
		news_tishi_w_max = news_title_tishi_mc.h_biao_ti.textWidth;
	}
	
	news_tishi_w = 22;
	news_tishi_h = 16;
	if (q_biao_ti != '')
	{
		
		news_title_tishi_mc.q_biao_ti.x = news_tishi_w;
		news_title_tishi_mc.q_biao_ti.y = news_tishi_h;
		news_title_tishi_mc.q_biao_ti.height = 25;
		news_title_tishi_mc.q_biao_ti.width = news_tishi_w_max;
		news_tishi_h = news_tishi_h + 22; 
	}
	
	
	news_title_tishi_mc.z_biao_ti.width = news_tishi_w_max;
	news_title_tishi_mc.z_biao_ti.x = news_tishi_w;
	news_title_tishi_mc.z_biao_ti.y = news_tishi_h;
	news_tishi_h = news_tishi_h + 32;
	
	if (h_biao_ti != '')
	{
		news_title_tishi_mc.h_biao_ti.x = news_tishi_w;
		news_title_tishi_mc.h_biao_ti.y = news_tishi_h;
		news_title_tishi_mc.h_biao_ti.width = news_tishi_w_max;
		news_title_tishi_mc.h_biao_ti.height = 30;
		news_tishi_h = news_tishi_h + 22; 
	}
	
	
	
	infobg.width=news_title_tishi_mc.z_biao_ti.width+44;
	infobg.height = news_tishi_h + 12;
	
	infobg_red.width= infobg.width-2;
	infobg_red.height = infobg.height - 2;
	
	infobg_bai.width= infobg.width-14;
	infobg_bai.height = infobg.height-14;
	
	
	
	news_title_tishi_mc.x=mouseX+buchunx;
	news_title_tishi_mc.y=mouseY-10;
	
}
function del_title_tishi(event:MouseEvent):void 
{
	event.target.parent.gotoAndStop(1);
	news_lan_del(event.target.parent._nid)//触发新闻区域变化
	news_title_tishi_mc.visible=false;
}


//按钮区域
//上翻-----------------------------------------------------------------------------------------------------------------
btn_up_ban.addEventListener(MouseEvent.CLICK, btn_up_ban_CLICK);
function btn_up_ban_CLICK(event:MouseEvent)
{
	go_to_ban_page=now_ban_page-1;
	if (go_to_ban_page < 1)
	{
		go_to_ban_page = 1
	}
	
	if (go_to_ban_page == 1)
	{
		btn_up_ban.gotoAndStop(2);
		if(go_to_ban_page != now_ban_page)
		{
			load_ban_list(go_to_ban_page);
		}
	}
	else
	{
		btn_down_ban.gotoAndStop(1);
		load_ban_list(go_to_ban_page);
	}	
}

//下翻
btn_down_ban.addEventListener(MouseEvent.CLICK, btn_down_ban_CLICK);
function btn_down_ban_CLICK(event:MouseEvent)
{
	go_to_ban_page = now_ban_page+1;
	//trace(now_ban_page,go_to_ban_page,total_ban)
	if (go_to_ban_page > total_ban)
	{
		go_to_ban_page = total_ban
	}
	
	if (go_to_ban_page == total_ban)
	{
		btn_down_ban.gotoAndStop(2);
		if (go_to_ban_page != now_ban_page)
		{
			load_ban_list(go_to_ban_page);
		}
	}
	else
	{
		btn_up_ban.gotoAndStop(1);
		load_ban_list(go_to_ban_page);
	}
	//trace(now_ban_page,go_to_ban_page,total_ban)
}

//返回首版
btn_go_ban1.addEventListener(MouseEvent.CLICK, btn_go_ban1_CLICK);
function btn_go_ban1_CLICK(event:MouseEvent)
{
	if (now_ban_page != 1)
	{
		btn_up_ban.gotoAndStop(2);
		btn_down_ban.gotoAndStop(1);
		
		go_to_ban_page = 1;
		load_ban_list(go_to_ban_page);
	}
}

//退出
btn_exit.addEventListener(MouseEvent.CLICK, btn_exit_CLICK);
function btn_exit_CLICK(event:MouseEvent)
{
	targetURLto = '/bao/';
	getURL(targetURLto, '_self');
}

//阅读pdf版本
btn_pdf.addEventListener(MouseEvent.CLICK, btn_pdf_CLICK);
function btn_pdf_CLICK(event:MouseEvent)
{
	targetURLto = '/bao/Newspaper_down.php?inid='+inid;
	getURL(targetURLto, '_target');
}

//日历检索
btn_rili.addEventListener(MouseEvent.CLICK,btn_rili_CLICK);
function btn_rili_CLICK(event:MouseEvent)
{
	targetURLto = '/bao/';
	getURL(targetURLto, '_self');
}

//搜索按钮
btn_search.addEventListener(MouseEvent.CLICK, btn_search_CLICK);
function btn_search_CLICK(event:MouseEvent)
{
	go_search();
} 
//键盘动作
insearch.addEventListener(KeyboardEvent.KEY_UP,insearch_reportKeyDown);
function insearch_reportKeyDown(event:KeyboardEvent):void
{
	if (event.keyCode == 13)
	{
		if (insearch.text != '')
		{
			go_search();
		}
	}		
}
function go_search()
{
	if(insearch.text == '')
	{
		ExternalInterface.call('alert("请输入搜索关键字!")');
		stage.focus = insearch;
	}
	else
	{
		targetURLto = '/bao/search.php?searchkey='+insearch.text;
		getURL(targetURLto, '_self');
	}
}
//音量滑动
//按钮拖动
sond_dian.buttonMode = true;
sond_dian.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown_sond_dian);
function onMouseDown_sond_dian(param1:MouseEvent) : void
{
    sond_dian.startDrag(false, new Rectangle(40, 743.2, 42, 0));
	stage.addEventListener(Event.ENTER_FRAME,onMove_btm_Saturation);
	stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUP);
}

function onMove_btm_Saturation(evt) : void
{
	update_sound();	
}

//移除拖放操作
function stage_onMouseUP(param1:MouseEvent) : void
{
	sond_dian.stopDrag();
	stage.removeEventListener(Event.ENTER_FRAME, onMove_btm_Saturation); //移除拖放
	update_sound();
}

//更新音量
function update_sound()
{
	//trace(sond_dian.x)
	if (sond_dian.x  < 45)
	{
		btn_sound_mc.gotoAndStop(2); sys_sound = 0;
	}
	else
	{
		btn_sound_mc.gotoAndStop(1); sys_sound = 1;
	}
}

//切换静音
btn_sound_mc.buttonMode = true;
btn_sound_mc.addEventListener(MouseEvent.CLICK, btn_sound_mc_CLICK);
function btn_sound_mc_CLICK(event:MouseEvent)
{
	if (sys_sound == 1)
	{
		sys_sound = 0;
		sond_dian.x = 40;
		btn_sound_mc.gotoAndStop(2);		
	}
	else
	{
		sys_sound = 1;
		sond_dian.x = 82;
		btn_sound_mc.gotoAndStop(1);
	}
}


//新闻标题导航
btn_news_daohang.addEventListener(MouseEvent.MOUSE_OVER,btn_news_daohang_MOUSE_OVER); //显示标题导航
news_dao_hang.addEventListener(MouseEvent.MOUSE_OUT, news_dao_hang_MOUSE_OUT); //隐藏标题导航
function news_dao_hang_MOUSE_OUT(event:MouseEvent):void
{
    news_dao_hang.visible = false;
}
 function btn_news_daohang_MOUSE_OVER(event:MouseEvent):void
{
   news_dao_hang.visible = true;
   ban_dao_hang.visible = false;
}

//板块导航
btn_ban_daohang.addEventListener(MouseEvent.MOUSE_OVER,btn_ban_daohang_MOUSE_OVER); //显示标题导航
ban_dao_hang.addEventListener(MouseEvent.MOUSE_OUT, ban_dao_hang_MOUSE_OUT); //隐藏标题导航
function ban_dao_hang_MOUSE_OUT(event:MouseEvent):void
{
    ban_dao_hang.visible = false;
}
 function btn_ban_daohang_MOUSE_OVER(event:MouseEvent):void
{
   ban_dao_hang.visible = true;
   news_dao_hang.visible = false;
}


 news_mc.pan.pic_mc.btn_zoom.visible = false;
//显示放大按钮
news_mc.pan.pic_mc.btn_zoom.addEventListener(MouseEvent.MOUSE_OVER,news_mc_pan_pic_mc_MOUSE_OVER); //显示标题导航
news_mc.pan.pic_mc.inpic.addEventListener(MouseEvent.MOUSE_OVER,news_mc_pan_pic_mc_MOUSE_OVER); //显示标题导航
news_mc.pan.pic_mc.inpic.addEventListener(MouseEvent.MOUSE_OUT, news_mc_pan_pic_mc_MOUSE_OUT); //隐藏标题导航
function news_mc_pan_pic_mc_MOUSE_OUT(event:MouseEvent):void
{
   news_mc.pan.pic_mc.btn_zoom.visible = false;
}
 function news_mc_pan_pic_mc_MOUSE_OVER(event:MouseEvent):void
{
  news_mc.pan.pic_mc.btn_zoom.visible = true;
}

//放大图片
news_mc.pan.pic_mc.btn_zoom.addEventListener(MouseEvent.CLICK, news_mc_btn_zoom_CLICK);
function news_mc_btn_zoom_CLICK(event:MouseEvent)
{
	if (news_big_pic_url != '')
	{
		delDisplayList(big_pic.inpic);
		big_pic.visible = true;
		loadImage_b_pic(big_pic.inpic, temp_domain + news_big_pic_url);
	}
}


big_pic.btn_close.addEventListener(MouseEvent.CLICK, big_pic_btn_close_CLICK);
function big_pic_btn_close_CLICK(event:MouseEvent)
{
	big_pic.visible = false;
}

//创建容器并加载新闻小图--------------------------------------------------------------------------------------------------------
function loadImage_b_pic(mc:DisplayObjectContainer, url:String) {
	var loader:Loader = new Loader();
	loader.contentLoaderInfo.addEventListener (Event.INIT, onLoadInit);
	loader.contentLoaderInfo.addEventListener (IOErrorEvent.IO_ERROR, onLoadError);
	loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
	loader.load(new URLRequest(url), lc);
	function progressHandler(event:ProgressEvent):void
    {
       	var loadpre:int = event.bytesLoaded / event.bytesTotal * 100;
		big_pic.load_mc.visible = true; //加载动画mc不可见
		big_pic.load_mc.note.text=''+loadpre;
    }
	function onLoadInit (event)
	{
		big_pic.load_mc.visible = false; //加载动画mc不可见
		var emp:Bitmap = Bitmap(event.target.content);		
		//位置和大小
		if (emp.width > 876)
		{
			emp.width = 876;
			emp.scaleY = emp.scaleX;			
		}
		if (emp.height > 576)
		{
			emp.height = 576;
			emp.scaleX = emp.scaleY;		
		}
		
		emp.x = 886/2 - emp.width / 2;
		
		emp.y = 586/2 - emp.height / 2;
		
		mc.addChild(emp);		
	}
	function onLoadError (event) {
		trace ("地址："+url+" 的对象不存在.");
	}

}

//创建容器并加载新闻小图--------------------------------------------------------------------------------------------------------
function loadImage_snews(mc:DisplayObjectContainer, url:String) {
	var loader:Loader = new Loader();
	loader.contentLoaderInfo.addEventListener (Event.INIT, onLoadInit);
	loader.contentLoaderInfo.addEventListener (IOErrorEvent.IO_ERROR, onLoadError);
	loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
	loader.load(new URLRequest(url), lc);
	function progressHandler(event:ProgressEvent):void
    {
       	var loadpre:int = event.bytesLoaded / event.bytesTotal * 100;
		news_mc.pan.pic_mc.load_mc.visible = true;
		news_mc.pan.pic_mc.load_mc.note.text=''+loadpre;
    }
	function onLoadInit (event)
	{
		news_mc.pan.pic_mc.load_mc.visible = false; //加载动画mc不可见
		var emp:Bitmap = Bitmap(event.target.content);		
		//位置和大小
		if (emp.width > emp.height)
		{
			emp.height = 300;
			emp.scaleX = emp.scaleY;
			emp.x = 200 - emp.width / 2;
		}
		else
		{
			emp.width = 400;
			emp.scaleY = emp.scaleX;
			emp.y = 150 - emp.height / 2;
		}
		mc.addChild(emp);		
	}
	function onLoadError (event) {
		trace ("地址："+url+" 的对象不存在.");
	}

}



//创建容器并加载小图--------------------------------------------------------------------------------------------------------
function loadImage_ban(mc:DisplayObjectContainer, url:String) {
	var loader:Loader = new Loader();
	loader.contentLoaderInfo.addEventListener (Event.INIT, onLoadInit);
	loader.contentLoaderInfo.addEventListener (IOErrorEvent.IO_ERROR, onLoadError);
	loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
	loader.load(new URLRequest(url), lc);
	function progressHandler(event:ProgressEvent):void
    {
       	var loadpre:int = event.bytesLoaded / event.bytesTotal * 100;
		load_mc.note.text=''+loadpre;	
    }
	function onLoadInit (event)
	{
		load_mc.visible = false; //加载动画mc不可见
		var emp:Bitmap = Bitmap(event.target.content);
		mc.addChild (emp);
		
	}
	function onLoadError (event) {
		trace ("地址："+url+" 的对象不存在.");
	}

}


//创建容器并加载图片--------------------------------------------------------------------------------------------------------
function loadImage_cover(mc:DisplayObjectContainer, url:String) {
	var loader:Loader = new Loader();
	loader.contentLoaderInfo.addEventListener (Event.INIT, onLoadInit);
	loader.contentLoaderInfo.addEventListener (IOErrorEvent.IO_ERROR, onLoadError);
	loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
	loader.load(new URLRequest(url), lc);
	function progressHandler(event:ProgressEvent):void
    {
       	var loadpre:int = event.bytesLoaded / event.bytesTotal * 100;
		load_mc.note.text=''+loadpre;	
    }
	function onLoadInit (event)
	{
		load_mc.visible = false; //加载动画mc不可见
		var emp:Bitmap = Bitmap(event.target.content);
		mc.addChild (emp);
		
	}
	function onLoadError (event) {
		trace ("地址："+url+" 的对象不存在.");
	}

}


//删除指定mc下的所有元素--------------------------------------------------------------------------------------------------------
function delDisplayList(container:DisplayObjectContainer,indentString:String = ""):void
{
    var child:DisplayObject;
	var cnum:uint=container.numChildren;
    for (var i:uint=0; i < cnum; i++)
    {
       	child = container.getChildAt(0);
		container.removeChildAt(0);
        //trace(indentString, child, child.name,container.numChildren,i,cnum); 		
    }
}

//取 字符 串数组  --------------------------------------------------------------------------------------------------------
function get_string_array(inString:String,informat:String = " ",i:Number=0)
{
	var temp_size_Array:Array = inString.split(informat);
	return temp_size_Array[i];
}

//打开链接--------------------------------------------------------------------------------------------------------
function getURL(url:String, window:String = "_blank"):void
{ 
	var broswer:String = ExternalInterface.call("function getBrowser(){return navigator.userAgent}") as String; 
	if(broswer.indexOf("Firefox") != -1 || broswer.indexOf("MSIE 7.0") != -1)
	{  
		ExternalInterface.call('window.open("' + url + '","' + window + '")'); 
	}
	else
	{   
		//navigateToURL(new URLRequest(url), window);
		ExternalInterface.call('window.open("' + url + '","' + window + '")'); 
	}
}

//调试输出----------------------------------------------------------------------------------------------------------
var dbug_txt = new TextField();
var dbug_String:String = '';
function dbug(note) 
{
	
	//dbug_mc.visible = false; 	
	dbug_txt.textColor=0xff0000;
	dbug_txt.selectable = false;
	dbug_String=dbug_String+note+"\n"
	dbug_txt.text = dbug_String;
	dbug_txt.width=dbug_txt.textWidth+9;
	dbug_txt.width=dbug_txt.textWidth+9;
	dbug_txt.height = dbug_txt.textHeight + 5;
	
	dbug_mc.addChild(dbug_txt);
	dbug_mc.x=500; dbug_mc.y=40;
	dbug_mc.addEventListener(MouseEvent.MOUSE_DOWN, dbug_txt_mousedown);
	function dbug_txt_mousedown(event:MouseEvent)
	{
		dbug_mc.startDrag();
	}
	
	dbug_mc.addEventListener(MouseEvent.MOUSE_UP, dbug_txt_mouseup);
	function dbug_txt_mouseup(event:MouseEvent)
	{
		dbug_mc.stopDrag();
	}
	
}

//版权-----------------------------------------------------------------------------------------------------------------------
var mycopymenu:ContextMenu = new ContextMenu();
var mymenu1:ContextMenuItem = new ContextMenuItem("星美软件",true);
mycopymenu.customItems.push(mymenu1);
mycopymenu.hideBuiltInItems();
this.contextMenu = mycopymenu; 
mymenu1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuItemSelectHandler_1);
function menuItemSelectHandler_1(event:ContextMenuEvent):void
{var request:URLRequest = new URLRequest("http://www.flash-soft.net/");  navigateToURL(request, "_blank"); }

