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

📄 reportprojectpanel.mxml

📁 flex 实现的一个showcase 喜欢flex的朋友可以
💻 MXML
字号:
<?xml version="1.0" encoding="utf-8"?>
<components:FlexDotOrgWindow
	xmlns:mx="http://www.adobe.com/2006/mxml"
	xmlns:components="com.flexShowcase.components.*"
	label="Report An Application"
	width="510" height="300">
	
	<mx:Script>
	
		<![CDATA[
	
			////////////////////////////////////////////////////////////////////////////////////
			//import
			
			import com.flexShowcase.constants.TextRestrictions;
			import com.flexShowcase.data.*;
			import com.flexShowcase.events.MailEvent;
			import com.flexShowcase.net.remote.FlexShowcaseServiceConfig;
			
			import mx.controls.Alert;
			import mx.effects.Fade;
			import mx.events.*;
			import mx.rpc.events.*;
			import mx.validators.Validator;
			
			////////////////////////////////////////////////////////////////////////////////
			//private variables
			
			private var focussedFormControl:DisplayObject;
			
			[Bindable] private var formIsEmpty:Boolean;
			[Bindable] private var formIsValid:Boolean;
			
			////////////////////////////////////////////////////////////////////////////////
			//public variables
			
			[Bindable] public var flexShowcaseServiceConfig:FlexShowcaseServiceConfig;
			[Bindable] public var project:Project;
			[Bindable] public var user:User;
			

			/////////////////////////////////////////////////////////////////////////////////
			//general
			
			override public function show():void {
				super.show()
				
				resetForm();
				
				
				if (user.loggedIn == true) {
					nameText_mc.text = user.firstName + " " + user.lastName;
					emailText_mc.text = user.email;
					focusManager.setFocus(subjectText_mc);
				} else {
					nameText_mc.text = "";
					emailText_mc.text = "";
					focusManager.setFocus(nameText_mc);
				}
				formIsValid = false;
				formIsEmpty = true;
			}
			
			private function cancelClickHandler(mouseEvent:MouseEvent):void {
				hide();
			}
			
			private function hideCompleteHandler(tweenEvent:TweenEvent):void {
				visible = false;
			}
			
			private function resetForm():void {
				nameText_mc.text = "";
				emailText_mc.text = "";
				subjectText_mc.text = "";
				message_mc.text = "";
				nameText_mc.errorString = "";
				emailText_mc.errorString = "";
				subjectText_mc.errorString = "";
				message_mc.errorString = "";
			}
			
			//dragging---------------------------------------------------------------------------
			private function startDragging():void {
				startDrag();
			}
			
			private function stopDragging():void {
				stopDrag();
			}
			
			
			//validation---------------------------------------------------------------------------
			private function validateProjectForm(event:Event):void {
				focussedFormControl = event.target as DisplayObject;
				
				formIsEmpty = (nameText_mc.text == ""&&emailText_mc.text == ""&&subjectText_mc.text == ""&&message_mc.text == "");
				formIsValid = true;
				
				validateProject(nameValidator);
				validateProject(emailValidator);
				validateProject(subjectValidator);
				validateProject(messageValidator);
			}
			
			private function validateProject(validator:Validator):Boolean {
				var validatorSource:DisplayObject = validator.source as DisplayObject;
				var suppressEvents:Boolean = (validatorSource != focussedFormControl);
				var event:ValidationResultEvent = validator.validate(null, suppressEvents);
				var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID);
				
				formIsValid = formIsValid && currentControlIsValid;
				
				return currentControlIsValid;
			}
			
			//send---------------------------------------------------------------------------
			private function sendReport():void {
				var date:Date = new Date();
				
				var body:String = new String();
				body += "Date: " + date.date + "/" + (date.month + 1) + "/" + date.fullYear + "\n";
				body += "\n";
				body += "User\n";
				body += "ID: " + user.id + "\n";
				body += "Name: " + nameText_mc.text + "\n";
				body += "Email: " + emailText_mc.text + "\n";
				body += "\n";
				body += "Project\n";
				body += "ID: " + project.id + "\n";
				body += "Name: " + project.name + "\n";
				body += "\n";
				body += "Subject: " + subjectText_mc.text + "\n";
				body += "Message: " + message_mc.text;
				
				var mailEvent:MailEvent = new MailEvent(MailEvent.SEND, true);
				mailEvent.mailKey = date.date.toString();
				mailEvent.toEmail = flexShowcaseServiceConfig.adminEmailAddress;
				mailEvent.subject = "Flex.org - Report Application";
				mailEvent.body = body;
				mailEvent.fromEmail = user.email;
				
				dispatchEvent(mailEvent);
				
				hide();
			}
			
		]]>
	</mx:Script>
	
	<mx:StringValidator id="nameValidator" source="{nameText_mc}" property="text" minLength="1" />
	<mx:EmailValidator id="emailValidator" source="{emailText_mc}" property="text" />
	<mx:StringValidator id="subjectValidator" source="{subjectText_mc}" property="text" minLength="1" />
	<mx:StringValidator id="messageValidator" source="{message_mc}" property="text" minLength="1" />
	
	<mx:VBox width="100%" height="100%">
		<mx:HBox width="100%" horizontalAlign="right">
			<mx:Label text="Name" styleName="flexDarkLabel"/>
			<mx:TextInput id="nameText_mc" maxChars="{TextRestrictions.SMALL}" width="393" 
				styleName="flexDarkTextBox" change="validateProjectForm(event)" />
		</mx:HBox> 
		<mx:HBox width="100%" horizontalAlign="right">
			<mx:Label text="Email" styleName="flexDarkLabel"/>
			<mx:TextInput id="emailText_mc" maxChars="{TextRestrictions.SMALL}" width="393"  
				styleName="flexDarkTextBox" change="validateProjectForm(event)"/>
		</mx:HBox>
		<mx:HBox width="100%" horizontalAlign="right">
			<mx:Label text="Subject" styleName="flexDarkLabel"/>
			<mx:TextInput id="subjectText_mc" maxChars="{TextRestrictions.SMALL}" width="393"  
				styleName="flexDarkTextBox" change="validateProjectForm(event)"/>
		</mx:HBox>
		<mx:HBox width="100%" horizontalAlign="right">
			<mx:Label text="Message" styleName="flexDarkLabel"/>
			<mx:TextArea id="message_mc"  width="393" maxChars="{TextRestrictions.LARGE}" 
				height="64" editable="true" styleName="flexDarkTextBox" change="validateProjectForm(event)"/>
		</mx:HBox>
		<mx:HBox horizontalAlign="center" width="100%" paddingTop="14">
			<mx:Button id="saveBut_mc" styleName="blackButton" width="90" label="Send" 
				click="this.sendReport()" enabled="{formIsValid}" buttonMode="{formIsValid}"/>
			<mx:Button id="cancelBut_mc" styleName="blackButton" width="90" label="Cancel" 
				click="cancelClickHandler(event);" buttonMode="true"/>
		</mx:HBox>
	</mx:VBox>
	
</components:FlexDotOrgWindow>

⌨️ 快捷键说明

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