flex成品作--不知道有哪位大神能看懂是干嘛的

原创 2013年05月27日 17:46:57

小弟布局什么都乱七八糟,但是功能还是行了,不知道哪位大神可以看懂吐舌头,我乱七八糟的代码,是干嘛的,这功能幸好公司内部用,不然做出去就难看死了

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
					   xmlns:s="library://ns.adobe.com/flex/spark" 
					   xmlns:mx="library://ns.adobe.com/flex/mx" 
					   width="800" height="600"
					   showStatusBar="false">
	
	<fx:Script>
		<![CDATA[
			import flashx.textLayout.conversion.TextConverter;
			import flashx.textLayout.elements.TextFlow;
			import flashx.textLayout.factory.StringTextLineFactory;
			
			import mx.collections.ArrayCollection;
			import mx.controls.Alert;
			import mx.events.FlexEvent;
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;
			
			import spark.events.GridSelectionEvent;
			import spark.utils.DataItem;
			
			private var content:String="";
			private var newcontent:String="";
			private var imgcount:int=0;
			private var imgreplace:int=0;
			private var servename:String="";
			public var customerid:String="";
			
			[Bindable]
			public var customerList:ArrayCollection;
			[Bindable]
			public var _pageList:ArrayCollection;
			
			private function richeditabletext1_pasteHandler(event:Event):void
			{
				var a:* = Clipboard.generalClipboard.getData(ClipboardFormats.HTML_FORMAT); //从系统剪切板中读取是html格式的数据
				if(a!=null){
					var stra:String= a as String;
					content=content as String;
					
					var myPattern:RegExp =/file:\/\/\//gi; 
					stra=stra.replace(myPattern, "");
					
					content=content+stra;
					a=content as Object;
					abc.textFlow = TextConverter.importToFlow(a, TextConverter.TEXT_FIELD_HTML_FORMAT);
				}
				
			}
			
			protected function button1_clickHandler(event:MouseEvent):void
			{
				
				if(abc.text==""){
					Alert.show("输入不能为空");
					return ;
				}
				var flexreg:RegExp=/<IMG/gi;
				
				if(content.search(flexreg)<0){//说明提交的内容没有图片,那么就直接提交
					var params:Object = {};  
					params["content"]=abc.text;
					params["customer.serveCustomer"]=servename;
					params["customer.id"]=customerid;
					service.send(params);
					return;
				}
				
				
				//把content中的img的标签替换掉,替换成{图片发送上去,服务器返回给客户端的一个地址}
				
				
				while(content.search(flexreg)>=0){
					
					imgcount++;//图片数量加一
					
					var start:int=content.search(flexreg);
					newcontent=newcontent+content.substring(0,start);//newcontent信息取到标签之前
					content=content.substring(start,content.length);//content字符串去掉<IMG之前的字符
					
					var intsrc:int=content.indexOf("src");
					newcontent=newcontent+content.substring(0,intsrc);//把src属性之前的字符取到,可能有width之类的
					content=content.substring(intsrc,content.length);
					
					var intone:int=content.indexOf('"');
					newcontent=newcontent+content.substring(0,intone+1);//把第一个引号字符取到,可能有width之类的
					newcontent=newcontent+"{"+imgcount+"}";
					
					content=content.substring(intone+1,content.length);
					
					var inttwo:int=content.indexOf('"');
					
					var strsrc:String=content.substring(0,inttwo);//图片的地址
					content=content.substring(inttwo,content.length);//原先字符串去掉路径
					
					
					//向newcontent中添加返回的绝对路径
					var file:File = new File(strsrc);
					if(file.exists){
						file.upload(new URLRequest("http://localhost:8080/WallpaperShowShow/terminal/serve_uploadImg?imgcount="+imgcount),"file");
						file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadComplete);
						file.addEventListener(IOErrorEvent.IO_ERROR,onIoError);
					}
					
				}
				
				//要把最后一个img标签后面的字符加入进去
				newcontent=newcontent+content;
				
				
			}
			
			
			protected function uploadComplete(event:DataEvent):void{
				
				var obj:Object=JSON.parse(event.data)
				var state:String=obj.state as String;
				if(state == "0"){
					Alert.show("图片上传失败");
					return ;
				}
				var strs:Array=state.split("&");
				
				newcontent=newcontent.replace("{"+strs[1]+"}",strs[0]);
				imgreplace++;
				
				if(imgcount==imgreplace){
					var params:Object = {};  
					params["content"]=newcontent;
					params["customer.serveCustomer"]=servename;
					params["customer.id"]=customerid;
					service.send(params);
				}
				
			}
			
			protected function onIoError(event:IOErrorEvent):void{
				Alert.show("图片上传失败");
			}
			
			//调用失败  
			protected function service_faultHandler(event:FaultEvent):void  
			{  
				Alert.show("提交失败了","提示");
			}
			//内容点击提交之后是成功还是失败
			protected function service_resultHandler(event:ResultEvent):void 
			{
				var obj:Object=JSON.parse(event.result.toString());
				var state:String=obj.state as String;
				if(state=="1"){
					Alert.show("提交成功","提示");
					abc.text="";
				}else{
					Alert.show("提交失败","提示");
				}
				
			}
			//点击登陆按钮开始验证,并发送请求
			protected function login_clickHandler(event:MouseEvent):void
			{
				if(""==username.text || ""==userpwd.text){
					Alert.show("请出入完整信息","提示");
					return;
				}
				var params:Object = {};  
				params["admin.loginName"]=username.text;
				params["admin.loginPwd"]=userpwd.text;
				loginservice.send(params);
			}
			
			protected function login_faultHandler(event:FaultEvent):void  
			{  
				Alert.show("登陆失败了","提示");
			}
			//登陆成功,发送请求去读取客户数据
			protected function login_resultHandler(event:ResultEvent):void 
			{
				
				var obj:Object=JSON.parse(event.result.toString());
				var state:String=obj.state as String;
				
				if(state == "0"){
					Alert.show("用户名密码错误");
				}else{
					servename=obj.name as String;
					customerservice.send();
				}
			}
			
			protected function customer_faultHandler(event:FaultEvent):void  
			{  
				Alert.show("读取客户表失败","提示");
			}
			
			//登陆成功要进行客户列表的显示
			protected function customer_resultHandler(event:ResultEvent):void 
			{
				
				var obj:Object=JSON.parse(event.result.toString());
				customerList = new ArrayCollection();
				_pageList = new ArrayCollection();
				for (var i:int = 0; i < obj.customerList.length; i++) 
				{
					var dataItem:DataItem = new DataItem();
					dataItem.name = obj.customerList[i].name;
					dataItem.phone = obj.customerList[i].phone;
					dataItem.serveCustomer = obj.customerList[i].serveCustomer;
					dataItem.customerType = obj.customerList[i].customerType;
					dataItem.id=obj.customerList[i].id;
					customerList.addItem(dataItem);
				}
				
				
				if(obj.page.currentPage>1)
					_pageList.addItem({num:obj.page.currentPage-1,left:true,click:gotoPage});
				for (var j:int = 1; j <= obj.page.sumPage; j++) 
				{
					if(j==obj.page.currentPage){
						_pageList.addItem({num:j,current:true});
					}else if((j < obj.page.currentPage+3 && j > obj.page.currentPage-3) || j > obj.page.sumPage-2 || j < 3){
						_pageList.addItem({num:j,click:gotoPage});
					}else if(j == obj.page.currentPage+3||j == obj.page.currentPage-3){
						_pageList.addItem({num:"...",isPoint:true});
					}
				}
				if(obj.page.currentPage<obj.page.sumPage)
					_pageList.addItem({num:obj.page.currentPage+1,right:true,click:gotoPage});
				
				currentState = "logined";
			}
			
			//翻页按钮 进行翻页
			private function gotoPage(currentPage:int = 1):void
			{
				var req:Object ={};
				if(cname.text!=""){
					req["name"]=cname.text;
				}
				req["page.currentPage"]=currentPage;
				customerservice.send(req);
			}
			private function creationCompleteHandler(event:FlexEvent):void
			{
				event.target.scroller.setStyle('verticalScrollPolicy','off');
				event.target.scroller.setStyle('horizontalScrollPolicy','off');
			}
			// 点返回按钮状态返回
			protected function back_clickHandler(event:MouseEvent):void
			{
				currentState="logined";
			}
			
			
			protected function search_clickHandler(event:MouseEvent):void
			{
				var params:Object={};
				params["name"]=cname.text;
				
				customerservice.send(params);
			}
			
		]]>
	</fx:Script>
	
	<fx:Declarations>
		
		<s:HTTPService id="service"   
					   url="http://192.168.1.200:8080/WallpaperShowShow/terminal/serve_addServeRecord"   
					   useProxy="false" method="POST"  
					   fault="service_faultHandler(event)"   
					   result="service_resultHandler(event)" resultFormat="text">    
			
		</s:HTTPService>  
		
		<s:HTTPService id="loginservice"   
					   url="http://192.168.1.200:8080/WallpaperShowShow/terminal/flex_logined"   
					   useProxy="false" method="POST"  
					   fault="login_faultHandler(event)"   
					   result="login_resultHandler(event)" resultFormat="text">    
			
		</s:HTTPService>
		
		<s:HTTPService id="customerservice"   
					   url="http://192.168.1.200:8080/WallpaperShowShow/terminal/flex_searchCustomer"
					   useProxy="false" method="POST"  
					   fault="customer_faultHandler(event)"   
					   result="customer_resultHandler(event)" resultFormat="text">    
			
		</s:HTTPService>
		
		
	</fx:Declarations>
	<s:states>
		<s:State name="login"/>
		<s:State name="logined"/>
		<s:State name="recording" />
	</s:states>
	
	<s:VGroup includeIn="login" verticalCenter="0" horizontalCenter="0" horizontalAlign="center">
		<s:HGroup verticalAlign="middle">
			<s:Label text="用户名:" width="100" textAlign="right"/>
			<s:TextInput id="username" />
		</s:HGroup>
		<s:HGroup verticalAlign="middle">
			<s:Label text="密 码:" width="100" textAlign="right"/>
			<s:TextInput id="userpwd" displayAsPassword="true" />
		</s:HGroup>
		<s:HGroup verticalAlign="middle" >
			<s:Button label="登录" click="login_clickHandler(event)" />
		</s:HGroup>	
	</s:VGroup>
	
	<s:Group includeIn="logined" verticalCenter="0" horizontalCenter="0" >
		<s:VGroup>
			<s:HGroup verticalCenter="-20" horizontalCenter="-10">
				<s:Label text="姓名:" verticalAlign="middle" width="100" textAlign="right" height="20" />
				<s:TextInput id="cname" />
				<s:Button label="查询" click="search_clickHandler(event)"/>
			</s:HGroup>
			<s:DataGrid x="10" y="10" width="700" height="351" borderColor="0xdedede"
						dataProvider="{customerList}" fontSize="14">
				<s:columns>
					<s:ArrayList>
						<s:GridColumn dataField="name" headerText="客户名称"></s:GridColumn>
						<s:GridColumn dataField="phone" headerText="电话"></s:GridColumn>
						<s:GridColumn dataField="serveCustomer" headerText="销售员"></s:GridColumn>
						<s:GridColumn dataField="customerType" headerText="客户类型"></s:GridColumn>
						<s:GridColumn  headerText="增加记录">
							<s:itemRenderer>
								<fx:Component>
									<s:GridItemRenderer>
										<fx:Script>
											<![CDATA[
												import mx.controls.Alert;
												protected function gostate(event:MouseEvent):void
												{
													outerDocument.customerid=data.id;
													outerDocument.currentState="recording";
												}
											]]>
										</fx:Script>
										<s:Label text="添加记录" left="5" color="0x26546c" verticalCenter="0" click="gostate(event)" mouseChildren="false" buttonMode="true" useHandCursor="true"/>
									</s:GridItemRenderer>
								</fx:Component>
							</s:itemRenderer>
						</s:GridColumn>
					</s:ArrayList>
				</s:columns>
			</s:DataGrid>
		</s:VGroup>
		
		<s:HGroup  horizontalAlign="right" verticalCenter="200" horizontalCenter="-60">
			<s:List dataProvider="{_pageList}" borderVisible="false" contentBackgroundAlpha="0"  height="50" creationComplete="creationCompleteHandler(event)" itemRenderer="itemRenderer.PageItemRenderer">
				<s:layout>
					<s:HorizontalLayout verticalAlign="middle" gap="5" />
				</s:layout>
			</s:List>
		</s:HGroup>
		
	</s:Group>
	<s:Group includeIn="recording">
		<s:HGroup verticalCenter="20" horizontalCenter="20">
			<s:Label backgroundColor="#FFFFFF" fontFamily="Arial" fontSize="14" text="内容:"/>
			<s:Group>
				
				<s:Rect width="600" height="450">
					<s:stroke>
						<s:SolidColorStroke color="0x0"/>
					</s:stroke>
				</s:Rect>
				<s:RichEditableText id="abc" x="0" y="0" width="600" height="450" text="RichEditableText" paste="richeditabletext1_pasteHandler(event)">
					<s:span></s:span>
				</s:RichEditableText>
			</s:Group>
			<s:VGroup>
				<s:Button label="提交" click="button1_clickHandler(event)"/>
				<s:Button label="返回" click="back_clickHandler(event)"/>
			</s:VGroup>
		</s:HGroup>
		
	</s:Group>
</s:WindowedApplication>


static的应用原理(不知道哪位大神写的)

static对象如果出现在类中,那么该对象即使从未被使用到,它也会被构造以及析构。而函数中的static对象,如果该函数从未被调用,这个对象也就绝不会诞生,但是在函数每次被调用时检查对象是否需要诞生。...

不知道是哪位java大神写给女神的情书~~~~~

我能抽象出整个世界... 但是我却不能抽象出你... 你肯定是一个单例,因为你是那样的独一无二... 所以我的世界并不完整... 我可以重载甚至覆盖这个世界里的任何一种方法... 但是却不能覆盖对你的...

#跪求 有没有哪位大神知道怎么加入多线程断点续传功能

package jluzh; import java.awt.BorderLayout; import java.awt.GridBagConstraints;   import jav...

请问有哪位大神能破解这个DLL?

  • 2016年06月11日 16:46
  • 1.68MB
  • 下载

构建JDK8报错了,哪位大神能帮忙看下什么原因 ?

构建JDK8报错了,哪位大神能帮忙看下什么原因 ?

哪位大神帮我看看ListView上的数据不能实时更新

package org.lhm.laofengxiang; import java.util.*; import cn.yljd.service.MyXMLParser; import and...
  • mvcgo
  • mvcgo
  • 2013年01月21日 19:15
  • 1340

(找到原因了)(又改了下,感觉有个最下面那块函数,应传入指针的指针)求求哪位大神给看看吧,为何注释部分放开竟然会出错,琢磨一天了啊,万分感谢!!!!!!!!!!!!!!!!!!!!

SharedPtr.h #pragma once #include #include using namespace std; class SharedPtr { public: friend ...

哪位大神 能将asp的一段代码逻辑 用java语言实现!!!我QQ“:596963475 求大神!!!

Notepad++ v6.6.8 new feature and bug fixes: 1.  Settings on cloud - Google Drive. 2.  Fix Settings ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:flex成品作--不知道有哪位大神能看懂是干嘛的
举报原因:
原因补充:

(最多只允许输入30个字)