Package | com.adobe.mosaic.core.events |
Class | public class Message |
Inheritance | Message Event Object |
Language Version: | ActionScript 3.0 |
Product Version: | Adobe Digital Enterprise Platform Experience Services - Composite Application Framework 9.5 |
Runtime Versions: | AIR 2.0.2, Flash Player 10.1 |
Message
class defines a transient notification including a namespace, a name, and a valid payload.
Messages are not retained or stored after all their listeners have been processed, so messages should only be used for communicating information that never needs to be persisted or recalled.
Property | Defined By | ||
---|---|---|---|
bubbles : Boolean [read-only]
Indicates whether an event is a bubbling event. | Event | ||
cancelable : Boolean [read-only]
Indicates whether the behavior associated with the event can be prevented. | Event | ||
constructor : Object
A reference to the class object or constructor function for a given object instance. | Object | ||
currentTarget : Object [read-only]
The object that is actively processing the Event object with an event listener. | Event | ||
eventPhase : uint [read-only]
The current phase in the event flow. | Event | ||
name : String [read-only]
Returns the name of this message. | Message | ||
nameSpace : String [read-only]
Returns the namespace of this message. | Message | ||
payload : * [read-only]
Returns the payload of this message. | Message | ||
target : Object [read-only]
The event target. | Event | ||
type : String [read-only]
The type of event. | Event |
Method | Defined By | ||
---|---|---|---|
Constructor. | Message | ||
[override]
Duplicates an instance of an Event subclass. | Message | ||
A utility function for implementing the toString() method in custom
ActionScript 3.0 Event classes. | Event | ||
Indicates whether an object has a specified property defined. | Object | ||
Checks whether the preventDefault() method has been called on the event. | Event | ||
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | ||
Cancels an event's default behavior if that behavior can be canceled. | Event | ||
Indicates whether the specified property exists and is enumerable. | Object | ||
Sets the availability of a dynamic property for loop operations. | Object | ||
Prevents processing of any event listeners in the current node and any subsequent nodes in
the event flow. | Event | ||
Prevents processing of any event listeners in nodes subsequent to the current node in the
event flow. | Event | ||
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | ||
Returns a string containing all the properties of the Event object. | Event | ||
Returns the primitive value of the specified object. | Object |
name | property |
nameSpace | property |
nameSpace:String
[read-only] Language Version: | ActionScript 3.0 |
Product Version: | Adobe Digital Enterprise Platform Experience Services - Composite Application Framework 9.5 |
Runtime Versions: | AIR 2.0.2, Flash Player 10.1 |
Returns the namespace of this message.
Implementation
public function get nameSpace():String
payload | property |
Message | () | Constructor |
public function Message(ns:String, name:String, payload:*)
Language Version: | ActionScript 3.0 |
Product Version: | Adobe Digital Enterprise Platform Experience Services - Composite Application Framework 9.5 |
Runtime Versions: | AIR 2.0.2, Flash Player 10.1 |
Constructor.
The constructor builds a Message
object containing a namespace, name, and payload
to deliver to other tiles using their event listeners.
ns:String — The namespace of the message.
| |
name:String — The name of the message.
| |
payload:* — Any object that is allowed to be serialized. The object will be sent to every listener.
|
clone | () | method |
override public function clone():Event
Language Version: | ActionScript 3.0 |
Product Version: | Adobe Digital Enterprise Platform Experience Services - Composite Application Framework 9.5 |
Runtime Versions: | AIR 2.0.2, Flash Player 10.1 |
Duplicates an instance of an Event subclass.
Returns a new Event object that is a copy of the original instance of the Event object.
You do not normally call clone()
; the EventDispatcher class calls it automatically
when you redispatch an event—that is, when you call dispatchEvent(event)
from a handler
that is handling event
.
The new Event object includes all the properties of the original.
When creating your own custom Event class, you must override the
inherited Event.clone()
method in order for it to duplicate the
properties of your custom class. If you do not set all the properties that you add
in your event subclass, those properties will not have the correct values when listeners
handle the redispatched event.
In this example, PingEvent
is a subclass of Event
and therefore implements its own version of clone()
.
class PingEvent extends Event { var URL:String; public override function clone():Event { return new PingEvent(type, bubbles, cancelable, URL); } }
Event — A new Event object that is identical to the original.
|
<?xml version="1.0" encoding="utf-8"?> <mc:Tile xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:mc="com.adobe.mosaic.core.*" layout="absolute" width="472" height="818" backgroundColor="#EEEEEE" applicationComplete="{onInit(event)}"> <mx:Script> <![CDATA[ import com.adobe.mosaic.core.events.Message; import com.adobe.mosaic.om.interfaces.*; import mx.collections.*; import mx.controls.*; import mx.utils.*; // Add Message Listeners private function onInit(event:Event):void { addAllMessageListeners(); } // Add all message listeners private function addAllMessageListeners():void { mosaicApp.addMessageListener("int", "intNotify", onIntNotifyMessage); mosaicApp.addMessageListener("string", "stringNotify", onStringNotifyMessage); mosaicApp.addMessageListener("XML", "XMLNotify", onXMLNotifyMessage); mosaicApp.addMessageListener("array", "arrayNotify", onArrayNotifyMessage); mosaicApp.addMessageListener("date", "dateNotify", onDateNotifyMessage); mosaicApp.addMessageListener("boolean", "booleanNotify", onBooleanNotifyMessage); mosaicApp.addMessageListener("arrayCollection", "arrayCollectionNotify", onArrayCollectionNotifyMessage); mosaicApp.addMessageListener("XMLList", "XMLListNotify", onXMLListNotifyMessage); mosaicApp.addMessageListener("number", "numberNotify", onNumberNotifyMessage); mosaicApp.addMessageListener("array", "arrayWithinArray", onArrayWithinArrayNotifyMessage); } // Remove all message listeners private function removeAllMessageListeners():void { mosaicApp.removeMessageListener("int", "intNotify", onIntNotifyMessage); mosaicApp.removeMessageListener("string", "stringNotify", onStringNotifyMessage); mosaicApp.removeMessageListener("XML", "XMLNotify", onXMLNotifyMessage); mosaicApp.removeMessageListener("array", "arrayNotify", onArrayNotifyMessage); mosaicApp.removeMessageListener("date", "dateNotify", onDateNotifyMessage); mosaicApp.removeMessageListener("boolean", "booleanNotify", onBooleanNotifyMessage); mosaicApp.removeMessageListener("arrayCollection", "arrayCollectionNotify", onArrayCollectionNotifyMessage); mosaicApp.removeMessageListener("XMLList", "XMLListNotify", onXMLListNotifyMessage); mosaicApp.removeMessageListener("number", "numberNotify", onNumberNotifyMessage); mosaicApp.removeMessageListener("array", "arrayWithinArray", onArrayWithinArrayNotifyMessage); } // Message Listeners private function onIntNotifyMessage(message:Message):void { IntOutput.text = message.nameSpace + ":" + message.name + " = " + message.payload; } private function onNumberNotifyMessage(message:Message):void { NumberOutput.text = message.nameSpace + ":" + message.name + " = " + message.payload; } private function onStringNotifyMessage(message:Message):void { StringOutput.text = message.nameSpace + ":" + message.name + " = " + message.payload; } private function onXMLNotifyMessage(message:Message):void { var xmlMessage:XML = message.payload; XMLOutput.text = xmlMessage.toXMLString(); } private function onArrayNotifyMessage(message:Message):void { var arrayMessage:Array = message.payload; if (arrayMessage != null) { ArrayOutput.text = arrayMessage.toString(); } } private function onArrayWithinArrayNotifyMessage(message:Message):void { var arrayMessage:Array = message.payload; if (arrayMessage != null) { ArrayWithinArrayOutput.text = arrayMessage.toString(); } } private function onDateNotifyMessage(message:Message):void { var dateMessage:Date = message.payload; DateOutput.text = message.nameSpace + ":" + message.name + " = " + dateMessage.getDate().toString() + " " + dateMessage.getMonth().toString() + " " + dateMessage.getFullYear().toString(); } private function onBooleanNotifyMessage(message:Message):void { var booleanMessage:Boolean = message.payload; BooleanOutput.text = message.nameSpace + ":" + message.name + " = " + booleanMessage.toString(); } private function onArrayCollectionNotifyMessage(message:Message):void { var str:String = message.payload.toString(); ArrayCollectionOutput.text = ""; if (str != null && str != "") { var arrayData:Array = str.split(','); var arrayCollectionMessage:ArrayCollection = new ArrayCollection(arrayData); ArrayCollectionOutput.text = arrayCollectionMessage.toString(); } } private function onXMLListNotifyMessage(message:Message):void { var XMLListMessage:XMLList = message.payload; XMLListOutput.text = message.nameSpace + ":" + message.name + " = "; var item:XML; for each(item in XMLListMessage) { XMLListOutput.text += item.toXMLString(); } } private function getContext():void { var context:IContext = this.mosaicApp.context; var xmlGlobalContext:XML = context.getAttribute("XMLGlobalContext"); if (xmlGlobalContext != null) { XMLOutput.text = xmlGlobalContext.toXMLString(); } var XMLListGlobalContext:XMLList = context.getAttribute("XMLListGlobalContext"); if (XMLListGlobalContext != null) { XMLListOutput.text = ""; var item:XML; for each(item in XMLListGlobalContext) { XMLListOutput.text += item.toXMLString(); } } BooleanOutput.text = context.getAttribute("BooleanGlobalContext"); var dateGlobalContext:Date = context.getAttribute("DateGlobalContext"); if (dateGlobalContext != null) { DateOutput.text = dateGlobalContext.getDate().toString() + " " + dateGlobalContext.getMonth().toString() + " " + dateGlobalContext.getFullYear().toString(); } StringOutput.text = context.getAttribute("StringGlobalContext"); IntOutput.text = context.getAttribute("IntGlobalContext"); NumberOutput.text = context.getAttribute("NumberGlobalContext"); var arrayGlobalContext:Array = context.getAttribute("ArrayGlobalContext"); if (arrayGlobalContext != null) { ArrayOutput.text = arrayGlobalContext.toString(); } var arrayWithinArrayContext:Array = context.getAttribute("ArrayWithinArrayContext"); if (arrayWithinArrayContext != null) { ArrayWithinArrayOutput.text = arrayWithinArrayContext.toString(); } var Atts:Array = new Array("complex1", "complex2"); var attribs:Array = context.getAttributes(Atts); if (attribs == null) { Alert.show("getAttributes() returned a null object."); } else { MultipleAttribs.text = ""; for each(var o:Object in attribs) { if (o != null) { MultipleAttribs.text += o.toString() + ", "; } } } try { ArrayCollectionOutput.text = ""; var arrayCollectionGlobal:ArrayCollection = context.getAttribute("ArrayCollectionContext"); if (arrayCollectionGlobal != null) { ArrayCollectionOutput.text = arrayCollectionGlobal.toString(); } } catch (e:Error) { } var nullAttrib:String = context.getAttribute("NullContext"); if (nullAttrib != null) { Alert.show("Null attribute is not null."); } } // getContext // This function verifies the default context data from Flex tile ComplexTypesFlexSender, set by loadContextData() private function verifyDefaultContextData():void { var today:Date = new Date; today.setHours(0, 0, 0); var dateStr:String = today.getDate().toString() + " " + today.getMonth().toString() + " " + today.getFullYear().toString(); if (this.DateOutput.text != dateStr) { Alert.show("Expected date: " + dateStr + "; actual: " + this.DateOutput.text); } if (this.ArrayOutput.text != "blue,purple,white") { Alert.show("Expected array: blue,purple,white; actual: " + this.ArrayOutput.text); } if (this.IntOutput.text != "10") { Alert.show("Expected int: 10; actual: " + this.IntOutput.text); } if (this.NumberOutput.text != "60.6") { Alert.show("Expected number: 60.6, actual: " + this.NumberOutput.text); } if (this.ArrayCollectionOutput.text != "") { Alert.show("ArrayCollectionOutput shouldn't contain any entry."); } var expectedStr:String = "~!@#$%^&*()_+{}|\"<>?`-=0[]\\;',./,10," + today.toString() + ",false,Do something,blue,purple,white"; if (this.ArrayWithinArrayOutput.text != expectedStr) { Alert.show("Expected arrayWithinArray: " + expectedStr + "; actual: " + this.ArrayWithinArrayOutput.text); } if (this.XMLOutput.text != "<target>Do something</target>") { Alert.show("Expected XML: <target>Do something</target>; actual: " + this.XMLOutput.text); } if (this.StringOutput.text != "~!@#$%^&*()_+{}|\"<>?`-=0[]\\;',./") { Alert.show("Expected string: ~!@#$%^&*()_+{}|\"<>?`-=0[]\\;',./; actual: " + this.StringOutput.text); } if (this.BooleanOutput.text != "false") { Alert.show("Expected boolean: false; actual: " + this.BooleanOutput.text); } if (this.XMLListOutput.text != "<car>honda</car><car>Porsche</car><car>Mercedes</car>") { Alert.show("Expected XMLList: <car>honda</car><car>Porsche</car><car>Mercedes</car>; actual: " + this.XMLListOutput.text); } if (this.MultipleAttribs.text.indexOf("globalComplex1.1") == -1 || this.MultipleAttribs.text.indexOf("globalComplex2.1") == -1) { Alert.show("Expected complex data: globalComplex1.1, globalComplex2.1,; actual: " + this.MultipleAttribs.text); } } // verifyDefaultContextData // This function verifies the default message data from Flex tile ComplexTypesFlexSender, set by loadMessageData() private function verifyDefaultMessageData():void { var bAllMessageDataVerified:Boolean = true; var today:Date = new Date(); today.setHours(0, 0, 0); var tomorrow:Date = new Date(today.getTime()+24*60*60*1000); var dateStr:String = "date:dateNotify = " + tomorrow.getDate().toString() + " " + tomorrow.getMonth().toString() + " " + tomorrow.getFullYear().toString(); if (this.DateOutput.text != dateStr) { bAllMessageDataVerified = false; Alert.show("Expected date: " + dateStr + "; actual: " + this.DateOutput.text); } if (this.ArrayOutput.text != "red,yellow,green") { bAllMessageDataVerified = false; Alert.show("Expected array: red,yellow,green; actual: " + this.ArrayOutput.text); } if (this.IntOutput.text != "int:intNotify = 8") { bAllMessageDataVerified = false; Alert.show("Expected int message: int:intNotify = 8; actual: " + this.IntOutput.text); } if (this.NumberOutput.text != "number:numberNotify = 6.6") { bAllMessageDataVerified = false; Alert.show("Expected number message: number:numberNotify = 6.6, actual: " + this.NumberOutput.text); } if (this.ArrayCollectionOutput.text != "AAA,BBB,CCC,DDD,EEE,FFF") { bAllMessageDataVerified = false; Alert.show("Expected arrayCollection: AAA,BBB,CCC,DDD,EEE,FFF; actual: " + this.ArrayCollectionOutput.text); } var expectedStr:String = "This is a message,8," + tomorrow.toString() + ",true,some files,red,yellow,green"; var actualStr:String = this.ArrayWithinArrayOutput.text; if (actualStr != expectedStr) { bAllMessageDataVerified = false; Alert.show("Expected arrayWithinArray: " + expectedStr + "; actual: " + actualStr); } var actualStr2:String = this.XMLOutput.text; if (actualStr2 != "<zip>some files</zip>") { bAllMessageDataVerified = false; Alert.show("Expected XML: <zip>some files</zip>; actual: " + actualStr2); } if (this.StringOutput.text != "string:stringNotify = This is a message") { bAllMessageDataVerified = false; Alert.show("Expected string: string:stringNotify = This is a message; actual: " + this.StringOutput.text); } if (this.BooleanOutput.text != "boolean:booleanNotify = true") { bAllMessageDataVerified = false; Alert.show("Expected boolean: boolean:booleanNotify = true; actual: " + this.BooleanOutput.text); } if (this.XMLListOutput.text != "XMLList:XMLListNotify = <car>toyota</car><car>BMW</car><car>Land Rover</car>") { bAllMessageDataVerified = false; Alert.show("Expected XMLList: XMLList:XMLListNotify = <car>toyota</car><car>BMW</car><car>Land Rover</car>; actual: " + this.XMLListOutput.text); } /* if (bAllMessageDataVerified) { Alert.show("All default message data verified!"); } */ } // verifyDefaultMessageData // This function verifies the default context data from JS tile GlobalAttributesHtmlTile1, set by loadDefaultData() private function verifyJSContextData():void { if (this.IntOutput.text != "100") { Alert.show("Expected int: 100; actual: " + this.IntOutput.text); } if (this.NumberOutput.text != "100.01") { Alert.show("Expected number: 100.01, actual: " + this.NumberOutput.text); } if (this.StringOutput.text != "JS Global Context") { Alert.show("Expected string: JS Global Context; actual: " + this.StringOutput.text); } } // verifyJSContextData // This function verifies the default message data from JS tile GlobalAttributesHtmlTile1, set by loadDefaultMessage() private function verifyJSMessageData():void { if (this.IntOutput.text != "int:intNotify = 999") { Alert.show("Expected int message: int:intNotify = 999; actual: " + this.IntOutput.text); } if (this.NumberOutput.text != "number:numberNotify = 999.001") { Alert.show("Expected number message: number:numberNotify = 999.001, actual: " + this.NumberOutput.text); } if (this.StringOutput.text != "string:stringNotify = JS Message") { Alert.show("Expected string: string:stringNotify = JS Message; actual: " + this.StringOutput.text); } } // verifyJSMessageData ]]> </mx:Script> <mx:VBox> <mx:Label text="ComplexTypesFlexReceiver" id="labelAllComplexTypes2V2" fontSize="14" fontWeight="bold"/> <mx:Label text="Press 'Get Global Context' to get values from ComplexTypesFlexSender" fontWeight="bold"/> <mx:HBox> <mx:VBox> <mx:Label text="Date"/> <mx:TextArea width="197" height="23" id="DateOutput" editable="false"/> <mx:Label text="Array"/> <mx:TextArea minWidth="197" minHeight="102" id="ArrayOutput" editable="false" wordWrap="true"/> <mx:Label text="Int"/> <mx:TextArea width="197" height="23" id="IntOutput" editable="false"/> <mx:Label text="Number"/> <mx:TextArea width="197" height="23" id="NumberOutput" editable="false"/> <mx:Label text="Array Collection"/> <mx:Label text="(expected not to work with getAttribute)"/> <mx:TextArea minWidth="197" minHeight="102" id="ArrayCollectionOutput" editable="false" wordWrap="true"/> <mx:Label text="ArrayWithinArray"/> <mx:Label text="(array of string, int, date, boolean, XML, array"/> <mx:TextArea minWidth="197" minHeight="102" id="ArrayWithinArrayOutput" editable="false" wordWrap="true"/> </mx:VBox> <mx:VBox> <mx:Label text="XML"/> <mx:TextArea minWidth="197" minHeight="102" id="XMLOutput" editable="false" wordWrap="true"/> <mx:Label text="String"/> <mx:TextArea minWidth="197" minHeight="102" id="StringOutput" editable="false" wordWrap="true"/> <mx:Label text="Boolean"/> <mx:TextArea width="197" height="23" id="BooleanOutput" editable="false"/> <mx:Label text="XMLList"/> <mx:TextArea minWidth="197" minHeight="102" id="XMLListOutput" editable="false" wordWrap="true"/> <mx:Label text="Complex Attributes"/> <mx:TextArea width="197" height="102" id="MultipleAttribs" editable="false" wordWrap="true"/> </mx:VBox> </mx:HBox> </mx:VBox> <mx:Button id="buttonGetGlobalContext" x="10" y="718" label="Get global context" click="getContext()" width="174"/> <mx:Button id="buttonVerifyDefaultContextData" x="10" y="748" label="Verify default context data" click="verifyDefaultContextData()" width="174"/> <mx:Button id="buttonVerifyDefaultMessageData" x="10" y="778" label="Verify default message data" click="verifyDefaultMessageData()" width="174"/> <mx:Button id="buttonVerifyJSContextData" x="206" y="748" label="Verify default context data from JS tile" click="verifyJSContextData()" width="232"/> <mx:Button id="buttonVerifyJSMessageData" x="206" y="778" label="Verify default message data from JS tile" click="verifyJSMessageData()" width="232"/> <mx:Button id="buttonAddAllMessageListeners" x="206" y="688" label="Add all message listeners" click="addAllMessageListeners()" width="232"/> <mx:Button id="butonRemoveAllMessageListeners" x="206" y="718" label="Remove all message listeners" click="removeAllMessageListeners()" width="232"/> </mc:Tile>
Mon Nov 18 2013, 11:47 AM -08:00