Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
<mx:Script><![CDATA[ public static const COOLNESS_CHANGED:String = 'coolnessChanged'; public var coolness:Number; public var item:ItemVO;]]></mx:Script><mx:Binding destination="coolness" source="coolnessSlider.value"/><mx:VSlider id="coolnessSlider" value="{coolness}" minimum="0" maximum="10" change="dispatchEvent(new Event(COOLNESS_CHANGED))"/><!-- Display the item --><view:MyItemDisplayComponent id="itemDisplay" item="{item}"/>
private function get myComponent():MyComponent{ return viewComponent as MyCompoent;}override public function onRegister():void{ myComponent.addEventListener( MyComponent.COOLNESS_CHANGED, onCoolnessChanged);}override public function handleNotification( note:INotification ):void { switch (note.getName()) { case ItemProxy.ITEM_RETRIEVED: case ItemProxy.ITEM_UPDATED: myComponent.item:ItemVO = note.getBody() as ItemVO; myComponent.coolness=itemVO.coolness; break; }}private function onCoolnessChanged(event:Event):void{ sendNotification(ApplicationFacade.APPLY_COOLNESS, [myComponent.item, myComponent.coolness]);}
override public function execute( note:INotification ):void{ var args:Array = note.getBody(); var item:Number = args[0]; var coolness:Number = args[1]; if (coolness == item.coolness) return; // debounce var itemProxy:ItemProxy = facade.retriveProxy(ItemProxy.NAME) as ItemProxy; itemProxy.updateCoolness(args); // this will result in a ItemProxy.ITEM_UPDATED note being sent... // do other stuff that justified doing this in a command instead of back in the Mediator}
public var sliderValue:Number;public function onRegister():void { viewComponent.addEventListener(Event.Change, onChangeHandler, false, 0, true);}public function onChangeHandler(event:Event):void { sliderValue = event.target.slider.value //probably use a custom event containing the value rather than direct access}