ActionScript Developer’s Guide to Robotlegs by Joel Hooks & Stray (Lindsey Fallow)

ActionScript Developer’s Guide to Robotlegs by Joel Hooks & Stray (Lindsey Fallow)

Author:Joel Hooks & Stray (Lindsey Fallow) [Joel Hooks]
Language: eng
Format: epub
Tags: COMPUTERS / Software Development & Engineering / General
ISBN: 9781449308896
Publisher: O'Reilly Media
Published: 2011-08-07T16:00:00+00:00


Mediator Structure

Mediators are simple by design. As shown below, your mediators declare injections, register events to listen to, and define methods to handle those events.

Example 8-2. MosaicTool: GridViewMediator.as listens for events on its view and from the Context

public class GridViewMediator extends Mediator { [Inject] public var view:GridView; override public function onRegister():void { addViewListener(TileColorChangeEvent.CHANGED, dispatch, TileColorChangeEvent); addContextListener(TileSupplyEvent.SUPPLY_SELECTED, changeSelectionColor, TileSupplyEvent); addContextListener(TileSupplyEvent.SELECTED_SUPPLY_COLOR_CHANGED, changeSelectionColor, TileSupplyEvent); addContextListener(GroutEvent.COLOR_CHANGED, changeGroutColor, GroutEvent); addContextListener(GroutEvent.COLOR_LOADED, changeGroutColor, GroutEvent); addContextListener(DesignEvent.DESIGN_COLORS_CHANGED, redrawGrid, DesignEvent); dispatch(new GridReadyEvent(GridReadyEvent.READY)); } protected function changeSelectionColor(e:TileSupplyEvent):void { view.selectionColor = e.color; } protected function changeGroutColor(e:GroutEvent):void { view.groutColor = e.color; } protected function redrawGrid(e:DesignEvent):void { view.applyColorsToWholeGrid(e.colors); } }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.