fxmq

来源:互联网 发布:php有什么证书 编辑:程序博客网 时间:2024/06/07 07:23

Flex Message Queue

Flex Message Queue (fxmq) (based on Appcelerator Entourage MQ) provides a lightweight client-side message bus to power event driven programming in Flex with a fraction of the code required for other event handling mechanisms, such as the MVC-style event handling provided by Adobe's Cairngorm Microarchitecture. This implementation of the observer pattern provides a much easier to use programming interface than that of Cairngorm or the native events provided by Flex.

Simple Example

The following is a simple example of using the publish/subscribe programming model of fxmq

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()">         <mx:Script>                 <![CDATA[                         import com.lightrail.mq.*;                                                  private var mq:MessageQueue = MessageQueue.getGlobal();                         [Bindable]                         private var msgLog:String = "";                                                  private function init():void {                                 mq.sub("log.message", function(message:Message):void {                                         msgLog = msgLog + "Received message: " + message.payload.message + "/n";                                 });                         }                                                  private function send():void {                                 mq.pub("log.message", {                                         message:this.message.text                                 });                         }                 ]]>         </mx:Script>         <mx:HBox>                 <mx:TextInput id="message"/>                 <mx:Button label="Send Message" click="send()"/>         </mx:HBox>         <mx:Label text="Message Log:"/>         <mx:TextArea id="log" height="400" width="500" text="{msgLog}"/> </mx:Application>
原创粉丝点击