Menu

[r98]: / cairngorm3 / trunk / libraries / ObserverTest / src / ObserverSamples.mxml  Maximize  Restore  History

Download this file

86 lines (75 with data), 3.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:observer="com.adobe.cairngorm.observer.*">
<mx:Script>
<![CDATA[
import com.adobe.cairngorm.observer.Person;
[Bindable]
private var person:Person = new Person();
private function observe(parameter:String):void
{
trace("observe " + parameter);
if (statusText)
statusText.text += "observe " + parameter + "\n";
}
private function observeWithoutParameter():void
{
trace("observeWithoutParameter");
if (statusText)
statusText.text += "observeWithoutParameter" + "\n";
}
private function observeValue():void
{
trace("observeValue");
statusText.text += "observeValue" + "\n";
}
private function observeValueWithParameter(parameter:String):void
{
trace("observeValueWithParameter " + parameter);
if (statusText)
statusText.text += "observeValueWithParameter " + parameter + "\n";
}
private function eventListener(event:Event):void
{
trace("eventListener " + event.type);
statusText.text += "eventListener " + event.type + "\n";
}
private function eventListenerWithoutParameter():void
{
trace("eventListenerWithoutParameter");
statusText.text += "eventListenerWithoutParameter" + "\n";
}
]]>
</mx:Script>
<observer:Observe source="{ person.firstName }" handler="observe" />
<observer:Observe
source="{ person.firstName }"
handler="observeWithoutParameter"
sendArgumentsToHandler="false" />
<observer:ObserveValue
source="{ person.lastName }" value="{ 'bar' }"
handler="observeValue" />
<observer:ObserveValue
source="{ person.lastName }" value="{ 'bar' }"
handler="observeValueWithParameter"
sendArgumentsToHandler="true" />
<observer:EventListener
source="{ person }"
type="{ Person.UPDATE_EVENT }"
handler="eventListener" />
<observer:EventListener
source="{ person }"
type="{ Person.UPDATE_EVENT }"
handler="eventListenerWithoutParameter"
sendArgumentsToHandler="false" />
<mx:HBox>
<mx:VBox>
<mx:Button label="observe change to foo" click="person.firstName = 'foo'" />
<mx:Button label="observe change to bar" click="person.firstName = 'bar'" />
<mx:Button label="observeValue change to foo" click="person.lastName = 'foo'" />
<mx:Button label="observeValue change to bar" click="person.lastName = 'bar'" />
<mx:Button label="dispatchUpdateEvent" click="person.dispatchUpdateEvent()" />
</mx:VBox>
<mx:TextArea id="statusText"
width="400" height="600" />
</mx:HBox>
</mx:Application>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.