加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex入门小例子

发布时间:2020-12-15 04:50:53 所属栏目:百科 来源:网络整理
导读:?xml version="1.0" encoding="utf-8"?mx:Applicationxmlns:mx="http://www.adobe.com/2006/mxml"layout="absolute"width="500" height="300"creationComplete="init()"mx:Script![CDATA[import mx.managers.PopUpManager;import mx.collections.ArrayCollec
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
	xmlns:mx="http://www.adobe.com/2006/mxml"
	layout="absolute"
	width="500" height="300"
	creationComplete="init()">
	<mx:Script>
		<![CDATA[
			import mx.managers.PopUpManager;
			import mx.collections.ArrayCollection;
			
			[Bindable]
			private var notes:ArrayCollection = new ArrayCollection();
			
			private var addNoteScreen:AddNote;
			
			private function init():void
			{
				addNoteScreen = new AddNote();
				addNoteScreen.addEventListener("SaveNote",saveNote);
			}
			
			private function addNote():void
			{
				PopUpManager.addPopUp(addNoteScreen,this,true);
				PopUpManager.centerPopUp(addNoteScreen);
				addNoteScreen.author.text = "";
				addNoteScreen.topic.text = "";
				addNoteScreen.description.text = "";
			}
			
			private function saveNote(e:Event):void
			{
				var note:Note = new Note();
				note.author = addNoteScreen.author.text;
				note.topic = addNoteScreen.topic.text;
				note.description = addNoteScreen.description.text;
				notes.addItem(note);
				PopUpManager.removePopUp(addNoteScreen);
			}
		]]>
	</mx:Script>
	<mx:Panel title="Notes"
			  width="100%" height="100%"
			  layout="vertical" horizontalAlign="right"
			  paddingTop="3" paddingLeft="3" paddingRight="3" paddingBottom="3">
		<mx:DataGrid dataProvider="{notes}" width="100%" height="100%">
			<mx:columns>
				<mx:DataGridColumn headerText="Author" dataField="author" width="80"/>
				<mx:DataGridColumn headerText="Topic" dataField="topic" width="100"/>
				<mx:DataGridColumn headerText="Description" dataField="description"/>
			</mx:columns>
		</mx:DataGrid>
		<mx:Button label="Add Note" click="addNote()"/>
	</mx:Panel>
</mx:Application>


?
?
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
				layout="absolute" width="348" height="218"
				title="Add A Note">
	<mx:Metadata>
		[Event(name="SaveNote")]
	</mx:Metadata>
	<mx:Script>
		<![CDATA[
			import mx.managers.PopUpManager;
			
			private function close():void
			{
				PopUpManager.removePopUp(this);
			}
			
			private function save():void
			{
				this.dispatchEvent(new Event("SaveNote"));
			}
		]]>
	</mx:Script>
	<mx:Label text="Author" x="35" y="10"/>
	<mx:TextInput id="author" width="150" x="84" y="8"/>
	<mx:Label text="Topic"  y="36" x="42"/>
	<mx:TextInput id="topic" width="150" x="84" y="34"/>
	<mx:Label text="Description"  y="62" x="10"/>
	<mx:TextArea id="description" width="234" height="77" x="84" y="61"/>
	<mx:Button label="Cancel" click="close()" x="193" y="146"/>
	<mx:Button label="Save" click="save()" x="264" y="146"/>
</mx:TitleWindow>


?
?
?package
{
?public class Note
?{
??public var author:String;
??public var topic:String;
??public var description:String;
?}
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读