📄 main.mxml
字号:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" xmlns:code="http://code.google.com/p/flexlib/"
title="inSync"
showStatusBar="false"
layout="absolute"
width="800" height="600"
applicationComplete="init()">
<mx:Script>
<![CDATA[
import mx.messaging.ChannelSet;
import mx.messaging.channels.AMFChannel;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable] private var contacts:ArrayCollection;
private var channelSet:ChannelSet;
private function init():void
{
var channel:AMFChannel = new AMFChannel("my-amf", "http://localhost:8080/messagebroker/amf");
channelSet = new ChannelSet();
channelSet.addChannel(channel);
ro.channelSet = channelSet;
}
private function resultHandler(event:ResultEvent):void
{
contacts = event.result as ArrayCollection
}
private function faultHandler(event:FaultEvent):void
{
Alert.show(event.fault.faultDetail);
}
public function openContact(contact:Contact):void
{
var children:Array = tn.getChildren();
for (var i:int = 0; i<children.length; i++)
{
if (ContactForm(children[i]).contact.id == contact.id)
{
tn.selectedChild = children[i];
return;
}
}
var form:ContactForm = new ContactForm();
tn.addChild(form);
form.contact = contact;
form.channelSet = channelSet;
tn.selectedChild = form;
}
private function search():void
{
ro.findByName(sb.text);
}
private function getFullName(item:Object):String
{
return item.firstName + " " + item.lastName;
}
]]>
</mx:Script>
<mx:Style source="styles.css"/>
<mx:RemoteObject id="ro" destination="contactService" fault="faultHandler(event)">
<mx:method name="findByName" result="resultHandler(event)"/>
</mx:RemoteObject>
<mx:HBox top="12" left="12" right="12" verticalAlign="middle" horizontalGap="20">
<mx:Label text="inSync" styleName="appTitle"/>
<mx:Spacer width="100%"/>
<mx:Button icon="@Embed('assets/icon_plus.png')" height="28" width="31"
toolTip="New Contact" click="openContact(new Contact())"/>
<SearchBox id="sb" right="143" width="145" height="18" dataProvider="{contacts}"
textChange="search()"
labelFunction="getFullName"
select="openContact(sb.selectedItem as Contact)"/>
</mx:HBox>
<code:SuperTabNavigator id="tn" top="60" left="12" right="12" bottom="12"/>
</mx:WindowedApplication>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -