ݺߣ

ݺߣShare a Scribd company logo
Краткое введение в  Mate Flex framework Константин Ковалёв http://riapriority.com/ [email_address] 24 августа 2008 г.
Как это выглядит? http://mate.asfusion.com/   М á тэ
Немного фактов Публичное появление 4 мая 2008 Альфа Использовался в проектах  AsFusion Текущая версия 0.7.5 http://mate-framework.googlecode.com/svn/trunk/src   Apache License, Version 2.0
Особенности СОБЫТИЯ! «Родная» событийная модель Декларативный синтаксис Dependency injection Связывание данных Используются сильные стороны  Flex ! Это не микроархитектура – это  framework ! Синглтонов – нет!
Использование http://mate.asfusion.com/page/documentation/getting-started
1 . Главный файл приложения <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mx:Application  xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;  xmlns=&quot;*&quot;> <MainEventMap /> <MainUI /> </mx:Application>
2. Событие package { import flash.events.Event; public class TestEvent extends Event { public static const BUTTON_CLICK:String = &quot;buttonClick&quot;; public function TestEvent(type:String,  bubbles:Boolean = true , cancelable:Boolean=false) { super(type, bubbles, cancelable); } } }
3. Класс представления <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mx:Box  xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;  xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:Dispatcher id=&quot;clickDispatcher&quot; generator=&quot;{TestEvent}&quot; type=&quot;{TestEvent.BUTTON_CLICK}&quot; /> <mx:Button label=&quot;Click Me!&quot; click=&quot; clickDispatcher.generateEvent() &quot; /> </mx:Box>
3. Класс представления ( old style ) <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mx:Box  xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;  xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mx:Button label=&quot;Click Me!&quot; click=&quot; dispatchEvent(new TestEvent (TestEvent.BUTTON_CLICK) &quot; /> </mx:Box>
4. EventMap <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mate:EventMap xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;  xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:EventHandlers type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <SomeAction /> </mate:EventHandlers> </mate:EventMap>
5. Model package { public class ClickManager { [Bindable] public var clickNumber:int = 0; public function performClick ():void { clickNumber ++; } } }
4. EventMap  из реальной жизни (почти   ) <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mate:EventMap xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;  xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:EventHandlers type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <mate:MethodInvoker generator=&quot;{ClickManager}&quot; method=&quot;performClick&quot; /> </mate:EventHandlers> </mate:EventMap>
3. Класс представления (из реальной жизни   ) <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mx:Box  xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;  xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:Dispatcher id=&quot;clickDispatcher&quot; generator=&quot;{TestEvent}&quot; type=&quot;{TestEvent.BUTTON_CLICK}&quot; /> <mx:Number id=&quot;clickNumber&quot; /> <mx:Button label=&quot;Click Me!&quot; click=&quot;clickDispatcher.generateEvent()&quot; /> <mx:Label text=&quot;{clickNumber}&quot; /> </mx:Box>
4.  EventMap ( финальный аккорд ) <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mate:EventMap xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;  xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:EventHandlers type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <mate:MethodInvoker generator=&quot;{ClickManager}&quot; method=&quot;performClick&quot; /> </mate:EventHandlers> <mate:Injectors target=&quot;{MainUI}&quot;> <mate:PropertyInjector source=&quot;{ClickManager}&quot; sourceKey=&quot;clickNumber&quot; targetKey=&quot;clickNumber&quot; /> </mate:Injectors> </mate:EventMap>
Общая картина MainUI MainEventMap ClickManager
Общая картина MainUI MainEventMap ClickManager TestEvent.BUTTON_CLICK
Общая картина MainUI MainEventMap ClickManager performClick () TestEvent.BUTTON_CLICK
Общая картина MainUI MainEventMap ClickManager {clickNumber} performClick () TestEvent.BUTTON_CLICK
Общая картина MainUI MainEventMap ClickManager {clickNumber} performClick () TestEvent.BUTTON_CLICK Model Controller View
Разделяем контроллер и  Dependency injection <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mx:Application  xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;  xmlns=&quot;*&quot;> <MainEventMap /> <MainUI /> <ModelMap /> </mx:Application>
Разделяем контроллер и  Dependency injection <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <!-- ModelMap --> <mate:EventMap xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;  xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:Injectors target=&quot;{MainUI}&quot;> <mate:PropertyInjector source=&quot;{ClickManager}&quot; sourceKey=&quot;clickNumber&quot; targetKey=&quot;clickNumber&quot; /> </mate:Injectors> </mate:EventMap>
Взаимодействие  с сервером MainUI MainEventMap Server
Взаимодействие  с сервером MainUI MainEventMap Server TestEvent.BUTTON_CLICK
Взаимодействие  с сервером MainUI MainEventMap Server performClick () TestEvent.BUTTON_CLICK
Взаимодействие  с сервером MainUI MainEventMap Server performClick () TestEvent.BUTTON_CLICK clickNumber ++
Взаимодействие  с сервером MainUI MainEventMap Server performClick () TestEvent.BUTTON_CLICK clickNumber ++ clickNumber
Взаимодействие  с сервером MainUI MainEventMap Server performClick () TestEvent.BUTTON_CLICK clickNumber ++ clickNumber clickNumber
Идем на сервер <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mate:EventMap xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;  xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:EventHandlers type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <mate:RemoteObjectInvoker destination=&quot;someDestination&quot; method=&quot;performClick&quot;> <mate:resultHandlers> <mate:ServiceResponseAnnouncer type=&quot;result&quot; /> </mate:resultHandlers> </mate:RemoteObjectInvoker> </mate:EventHandlers> </mate:EventMap>
Видоизмененный  View <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mx:Box xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mx:Script> <![CDATA[ import com.asfusion.mate.events.ResponseEvent; [Bindable] public var clickNumber:Number = 0; private function  onResult  (event:ResponseEvent):void { clickNumber = Number (event.result); } ]]> </mx:Script> <mate:Dispatcher id=&quot;clickDispatcher” generator=&quot;{TestEvent}” type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <mate:ServiceResponseHandler result=&quot;onResult(event)&quot; /> </mate:Dispatcher> <mx:Button label=&quot;Click Me!” click=&quot;clickDispatcher.generateEvent()&quot; /> <mx:Label text=&quot;{clickNumber}&quot; /> </mx:Box>
Передача параметров
Видоизмененное событие package { import flash.events.Event; public class TestEvent extends Event   { public static const BUTTON_CLICK:String = &quot;buttonClick&quot;; public var amount:int; public function TestEvent(type:String,  bubbles:Boolean=true, cancelable:Boolean=false)   { super(type, bubbles, cancelable); } } }
Параметр во  View <mx:Number id=&quot;currentAmount&quot;>1</mx:Number> <mx:RadioButtonGroup  id=&quot;amountGroup&quot; change=&quot;currentAmount =  event.currentTarget.selection.data&quot; /> <mx:RadioButton group=&quot;{amountGroup}“ selected=“true” data=&quot;1&quot; label=&quot;1&quot; /> <mx:RadioButton group=&quot;{amountGroup}&quot; data=&quot;2&quot; label=&quot;2&quot; />
Рассылка события из  View <mate:Dispatcher id=&quot;clickDispatcher&quot; generator=&quot;{TestEvent}&quot; type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <mate:eventProperties> <mate:EventProperties amount=&quot;{currentAmount}&quot; /> </mate:eventProperties> </mate:Dispatcher> <mx:Number id=&quot;currentAmount&quot;>1</mx:Number>
Отсылка параметра  на сервер <mate:EventHandlers type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <mate:RemoteObjectInvoker destination=&quot;someDestination&quot; method=&quot;performClick &quot; arguments=&quot;{event.amount}&quot; > <mate:resultHandlers> <mate:ServiceResponseAnnouncer type=&quot;result&quot; /> </mate:resultHandlers> </mate:RemoteObjectInvoker> </mate:EventHandlers>
EventMap: SmartObject event resultObject fault lastReturn message data scope currentEvent <mate:RemoteObjectInvoker destination=&quot;someDestination“ method=&quot;performClick “ arguments=&quot;{ event.amount }&quot;> … </mate:RemoteObjectInvoker>
Хитрости  SmartObject Можно: arguments=“{event.count}” Нельзя: arguments=“{event.count  + 1 }” arguments=“{event.book.id}” итд. Можно использовать  MethodInvoker
Отладка <mate:Debugger level=&quot;{Debugger.DEBUG}&quot; /> <mate:EventHandlers debug=&quot;true&quot; type=&quot;{TestEvent.BUTTON_CLICK}&quot;> Не забывайте убирать после отладки: жрет ресурсы!
Взаимодействие  с сервером RemoteObjectInvoker HTTPServiceInvoker WebServiceInvoker Производные от  ServiceInvoker   >  AbstractServiceInvoker При создании своего сервиса: implements IAction
Собственные обработчики implements IAction Можно унаследоваться от  AbstractAction
Ресурсы http://mate.asfusion.com/page/documentation http://mate.asfusion.com/api_docs   http://mate.asfusion.com/page/downloads http://mate.asfusion.com/page/examples
Mate+Cairngorm=  ♥ http://mate.asfusion.com/page/examples/cafe-townsend
Пример  Ozon Book Finder
Q&A Константин Ковалёв http://riapriority.com/ [email_address]

More Related Content

Viewers also liked (20)

The New Guardian
The New GuardianThe New Guardian
The New Guardian
Matt McAlister
BarilocheBariloche
Bariloche
riodelaplata
10 MEDALHAS DE OURO DE PEQUIM10 MEDALHAS DE OURO DE PEQUIM
10 MEDALHAS DE OURO DE PEQUIM
Ricardo Gouvêa
Recerca Cultura Eivissa I Formentera
Recerca Cultura Eivissa I FormenteraRecerca Cultura Eivissa I Formentera
Recerca Cultura Eivissa I Formentera
Gemma Tur
UNIDAD 5UNIDAD 5
UNIDAD 5
susanabiebs
Los Alumnos De Primero A PowerLos Alumnos De Primero A Power
Los Alumnos De Primero A Power
andreaviviana
Interrupt In Linux 1.1
Interrupt In Linux 1.1Interrupt In Linux 1.1
Interrupt In Linux 1.1
Stanley Ho
Hom Express 2008Hom Express 2008
Hom Express 2008
DIDIER VALL
Alejandra  aristizabal  otalvaro estrategias y  tacticas de busquedaAlejandra  aristizabal  otalvaro estrategias y  tacticas de busqueda
Alejandra aristizabal otalvaro estrategias y tacticas de busqueda
alejaaristizabal
Campamento Noviembre 2008Campamento Noviembre 2008
Campamento Noviembre 2008
jorgefilu
ʳ/ʱの話
ʳ/ʱの話ʳ/ʱの話
ʳ/ʱの話
Satoshi Hirata
Teste01
Teste01Teste01
Teste01
elmoreira01
ݺߣshow IT_kom Mainz 19.09.2008
ݺߣshow IT_kom Mainz 19.09.2008ݺߣshow IT_kom Mainz 19.09.2008
ݺߣshow IT_kom Mainz 19.09.2008
Kirchhoff Datensysteme Software GmbH & Co. KG
Giethoorn a village in Holland
Giethoorn a village in HollandGiethoorn a village in Holland
Giethoorn a village in Holland
depeer
Andamio 2Andamio 2
Andamio 2
Ramon Humbertó Ortega
Accidentes Formula 1Accidentes Formula 1
Accidentes Formula 1
marksm0808
arte con tenedoresarte con tenedores
arte con tenedores
guest2606e5
BarilocheBariloche
Bariloche
riodelaplata
10 MEDALHAS DE OURO DE PEQUIM10 MEDALHAS DE OURO DE PEQUIM
10 MEDALHAS DE OURO DE PEQUIM
Ricardo Gouvêa
Recerca Cultura Eivissa I Formentera
Recerca Cultura Eivissa I FormenteraRecerca Cultura Eivissa I Formentera
Recerca Cultura Eivissa I Formentera
Gemma Tur
UNIDAD 5UNIDAD 5
UNIDAD 5
susanabiebs
Los Alumnos De Primero A PowerLos Alumnos De Primero A Power
Los Alumnos De Primero A Power
andreaviviana
Interrupt In Linux 1.1
Interrupt In Linux 1.1Interrupt In Linux 1.1
Interrupt In Linux 1.1
Stanley Ho
Hom Express 2008Hom Express 2008
Hom Express 2008
DIDIER VALL
Alejandra  aristizabal  otalvaro estrategias y  tacticas de busquedaAlejandra  aristizabal  otalvaro estrategias y  tacticas de busqueda
Alejandra aristizabal otalvaro estrategias y tacticas de busqueda
alejaaristizabal
Campamento Noviembre 2008Campamento Noviembre 2008
Campamento Noviembre 2008
jorgefilu
Giethoorn a village in Holland
Giethoorn a village in HollandGiethoorn a village in Holland
Giethoorn a village in Holland
depeer
Accidentes Formula 1Accidentes Formula 1
Accidentes Formula 1
marksm0808
arte con tenedoresarte con tenedores
arte con tenedores
guest2606e5

More from Constantiner (6)

Flex 4 Gumbo
Flex 4 GumboFlex 4 Gumbo
Flex 4 Gumbo
Constantiner
Cairngorm Microarchitecture
Cairngorm MicroarchitectureCairngorm Microarchitecture
Cairngorm Microarchitecture
Constantiner
Архитектурные проблемы Flex-приложений
Архитектурные проблемы Flex-приложенийАрхитектурные проблемы Flex-приложений
Архитектурные проблемы Flex-приложений
Constantiner
Flex Component Lifecycle Overview
Flex Component Lifecycle OverviewFlex Component Lifecycle Overview
Flex Component Lifecycle Overview
Constantiner
Data Binding in Flex
Data Binding in FlexData Binding in Flex
Data Binding in Flex
Constantiner
Customizing Flex Apps
Customizing Flex AppsCustomizing Flex Apps
Customizing Flex Apps
Constantiner
Cairngorm Microarchitecture
Cairngorm MicroarchitectureCairngorm Microarchitecture
Cairngorm Microarchitecture
Constantiner
Архитектурные проблемы Flex-приложений
Архитектурные проблемы Flex-приложенийАрхитектурные проблемы Flex-приложений
Архитектурные проблемы Flex-приложений
Constantiner
Flex Component Lifecycle Overview
Flex Component Lifecycle OverviewFlex Component Lifecycle Overview
Flex Component Lifecycle Overview
Constantiner

Краткое введение в Mate Flex framework

  • 1. Краткое введение в Mate Flex framework Константин Ковалёв http://riapriority.com/ [email_address] 24 августа 2008 г.
  • 2. Как это выглядит? http://mate.asfusion.com/ М á тэ
  • 3. Немного фактов Публичное появление 4 мая 2008 Альфа Использовался в проектах AsFusion Текущая версия 0.7.5 http://mate-framework.googlecode.com/svn/trunk/src Apache License, Version 2.0
  • 4. Особенности СОБЫТИЯ! «Родная» событийная модель Декларативный синтаксис Dependency injection Связывание данных Используются сильные стороны Flex ! Это не микроархитектура – это framework ! Синглтонов – нет!
  • 6. 1 . Главный файл приложения <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns=&quot;*&quot;> <MainEventMap /> <MainUI /> </mx:Application>
  • 7. 2. Событие package { import flash.events.Event; public class TestEvent extends Event { public static const BUTTON_CLICK:String = &quot;buttonClick&quot;; public function TestEvent(type:String, bubbles:Boolean = true , cancelable:Boolean=false) { super(type, bubbles, cancelable); } } }
  • 8. 3. Класс представления <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mx:Box xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:Dispatcher id=&quot;clickDispatcher&quot; generator=&quot;{TestEvent}&quot; type=&quot;{TestEvent.BUTTON_CLICK}&quot; /> <mx:Button label=&quot;Click Me!&quot; click=&quot; clickDispatcher.generateEvent() &quot; /> </mx:Box>
  • 9. 3. Класс представления ( old style ) <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mx:Box xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mx:Button label=&quot;Click Me!&quot; click=&quot; dispatchEvent(new TestEvent (TestEvent.BUTTON_CLICK) &quot; /> </mx:Box>
  • 10. 4. EventMap <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mate:EventMap xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:EventHandlers type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <SomeAction /> </mate:EventHandlers> </mate:EventMap>
  • 11. 5. Model package { public class ClickManager { [Bindable] public var clickNumber:int = 0; public function performClick ():void { clickNumber ++; } } }
  • 12. 4. EventMap из реальной жизни (почти  ) <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mate:EventMap xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:EventHandlers type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <mate:MethodInvoker generator=&quot;{ClickManager}&quot; method=&quot;performClick&quot; /> </mate:EventHandlers> </mate:EventMap>
  • 13. 3. Класс представления (из реальной жизни  ) <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mx:Box xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:Dispatcher id=&quot;clickDispatcher&quot; generator=&quot;{TestEvent}&quot; type=&quot;{TestEvent.BUTTON_CLICK}&quot; /> <mx:Number id=&quot;clickNumber&quot; /> <mx:Button label=&quot;Click Me!&quot; click=&quot;clickDispatcher.generateEvent()&quot; /> <mx:Label text=&quot;{clickNumber}&quot; /> </mx:Box>
  • 14. 4. EventMap ( финальный аккорд ) <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mate:EventMap xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:EventHandlers type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <mate:MethodInvoker generator=&quot;{ClickManager}&quot; method=&quot;performClick&quot; /> </mate:EventHandlers> <mate:Injectors target=&quot;{MainUI}&quot;> <mate:PropertyInjector source=&quot;{ClickManager}&quot; sourceKey=&quot;clickNumber&quot; targetKey=&quot;clickNumber&quot; /> </mate:Injectors> </mate:EventMap>
  • 15. Общая картина MainUI MainEventMap ClickManager
  • 16. Общая картина MainUI MainEventMap ClickManager TestEvent.BUTTON_CLICK
  • 17. Общая картина MainUI MainEventMap ClickManager performClick () TestEvent.BUTTON_CLICK
  • 18. Общая картина MainUI MainEventMap ClickManager {clickNumber} performClick () TestEvent.BUTTON_CLICK
  • 19. Общая картина MainUI MainEventMap ClickManager {clickNumber} performClick () TestEvent.BUTTON_CLICK Model Controller View
  • 20. Разделяем контроллер и Dependency injection <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns=&quot;*&quot;> <MainEventMap /> <MainUI /> <ModelMap /> </mx:Application>
  • 21. Разделяем контроллер и Dependency injection <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <!-- ModelMap --> <mate:EventMap xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:Injectors target=&quot;{MainUI}&quot;> <mate:PropertyInjector source=&quot;{ClickManager}&quot; sourceKey=&quot;clickNumber&quot; targetKey=&quot;clickNumber&quot; /> </mate:Injectors> </mate:EventMap>
  • 22. Взаимодействие с сервером MainUI MainEventMap Server
  • 23. Взаимодействие с сервером MainUI MainEventMap Server TestEvent.BUTTON_CLICK
  • 24. Взаимодействие с сервером MainUI MainEventMap Server performClick () TestEvent.BUTTON_CLICK
  • 25. Взаимодействие с сервером MainUI MainEventMap Server performClick () TestEvent.BUTTON_CLICK clickNumber ++
  • 26. Взаимодействие с сервером MainUI MainEventMap Server performClick () TestEvent.BUTTON_CLICK clickNumber ++ clickNumber
  • 27. Взаимодействие с сервером MainUI MainEventMap Server performClick () TestEvent.BUTTON_CLICK clickNumber ++ clickNumber clickNumber
  • 28. Идем на сервер <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mate:EventMap xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mate:EventHandlers type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <mate:RemoteObjectInvoker destination=&quot;someDestination&quot; method=&quot;performClick&quot;> <mate:resultHandlers> <mate:ServiceResponseAnnouncer type=&quot;result&quot; /> </mate:resultHandlers> </mate:RemoteObjectInvoker> </mate:EventHandlers> </mate:EventMap>
  • 29. Видоизмененный View <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <mx:Box xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:mate=&quot;http://mate.asfusion.com/&quot;> <mx:Script> <![CDATA[ import com.asfusion.mate.events.ResponseEvent; [Bindable] public var clickNumber:Number = 0; private function onResult (event:ResponseEvent):void { clickNumber = Number (event.result); } ]]> </mx:Script> <mate:Dispatcher id=&quot;clickDispatcher” generator=&quot;{TestEvent}” type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <mate:ServiceResponseHandler result=&quot;onResult(event)&quot; /> </mate:Dispatcher> <mx:Button label=&quot;Click Me!” click=&quot;clickDispatcher.generateEvent()&quot; /> <mx:Label text=&quot;{clickNumber}&quot; /> </mx:Box>
  • 31. Видоизмененное событие package { import flash.events.Event; public class TestEvent extends Event { public static const BUTTON_CLICK:String = &quot;buttonClick&quot;; public var amount:int; public function TestEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=false) { super(type, bubbles, cancelable); } } }
  • 32. Параметр во View <mx:Number id=&quot;currentAmount&quot;>1</mx:Number> <mx:RadioButtonGroup id=&quot;amountGroup&quot; change=&quot;currentAmount = event.currentTarget.selection.data&quot; /> <mx:RadioButton group=&quot;{amountGroup}“ selected=“true” data=&quot;1&quot; label=&quot;1&quot; /> <mx:RadioButton group=&quot;{amountGroup}&quot; data=&quot;2&quot; label=&quot;2&quot; />
  • 33. Рассылка события из View <mate:Dispatcher id=&quot;clickDispatcher&quot; generator=&quot;{TestEvent}&quot; type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <mate:eventProperties> <mate:EventProperties amount=&quot;{currentAmount}&quot; /> </mate:eventProperties> </mate:Dispatcher> <mx:Number id=&quot;currentAmount&quot;>1</mx:Number>
  • 34. Отсылка параметра на сервер <mate:EventHandlers type=&quot;{TestEvent.BUTTON_CLICK}&quot;> <mate:RemoteObjectInvoker destination=&quot;someDestination&quot; method=&quot;performClick &quot; arguments=&quot;{event.amount}&quot; > <mate:resultHandlers> <mate:ServiceResponseAnnouncer type=&quot;result&quot; /> </mate:resultHandlers> </mate:RemoteObjectInvoker> </mate:EventHandlers>
  • 35. EventMap: SmartObject event resultObject fault lastReturn message data scope currentEvent <mate:RemoteObjectInvoker destination=&quot;someDestination“ method=&quot;performClick “ arguments=&quot;{ event.amount }&quot;> … </mate:RemoteObjectInvoker>
  • 36. Хитрости SmartObject Можно: arguments=“{event.count}” Нельзя: arguments=“{event.count + 1 }” arguments=“{event.book.id}” итд. Можно использовать MethodInvoker
  • 37. Отладка <mate:Debugger level=&quot;{Debugger.DEBUG}&quot; /> <mate:EventHandlers debug=&quot;true&quot; type=&quot;{TestEvent.BUTTON_CLICK}&quot;> Не забывайте убирать после отладки: жрет ресурсы!
  • 38. Взаимодействие с сервером RemoteObjectInvoker HTTPServiceInvoker WebServiceInvoker Производные от ServiceInvoker > AbstractServiceInvoker При создании своего сервиса: implements IAction
  • 39. Собственные обработчики implements IAction Можно унаследоваться от AbstractAction
  • 40. Ресурсы http://mate.asfusion.com/page/documentation http://mate.asfusion.com/api_docs http://mate.asfusion.com/page/downloads http://mate.asfusion.com/page/examples
  • 41. Mate+Cairngorm= ♥ http://mate.asfusion.com/page/examples/cafe-townsend
  • 42. Пример Ozon Book Finder
  • 43. Q&A Константин Ковалёв http://riapriority.com/ [email_address]