Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
<?xml version="1.0" encoding="utf-8"?><mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ //public static const TERMINOU_SPLASH:String = "terminouSplash"; import com.empresa.Teste.ApplicationFacade; import flash.events.Event; private function inicia():void { // dispatchEvent( new Event( TERMINOU_SPLASH )); // parent.dispatchEvent( new Event( ApplicationFacade.SHOW_LOGIN, true )); // dispatchEvent( new Event( ApplicationFacade.SHOW_LOGIN, true )); } ]]> </mx:Script> <mx:Image creationComplete="inicia()"/></mx:Canvas>
ive tried using event meta toobut i simply cannot catch the event in the applicationmediator
<mx:Panel title="Things List" xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ public static const ADD_THINGS:String = 'addThings'; public static const REMOVE_THINGS:String = 'removeThings'; // Bindable for internal use, as a dataProvider for DataGrid [Bindable] public var things:Array; public var selectedThing:Object; // send the named event private function sendEvent( eventName:String ):void { dispatchEvent( new Event( eventName, true ) ); } ]]> </mx:Script> <mx:DataGrid id="dg" dataProvider="{things}" click="selectedThing=dg.selectedItem"/> <mx:Button label="Add Thing" click="sendEvent(ADD_THING)"/> <mx:Button label="Remove Thing" click="sendEvent(REMOVE_THING)" enabled="{(selectedThing!=null)}"/></mx:Panel>
<mx:TabNavigator xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:me="com.me.myapp.view.components.*"> <me:StuffPanel id='stuffPanel' /> <me:ThingsPanel id='thingsPanel'/></mx:TabNavigator>
package me.myapp.view{ import flash.events.Event; import org.puremvc.as3.interfaces.INotification; import org.puremvc.as3.patterns.mediator.Mediator; import org.puremvc.as3.patterns.observer.Notification; import me.myapp.me.myapp.ApplicationFacade; import me.myapp.me.myapp.model.StuffProxy; import me.myapp.me.myapp.view.components.StuffPanel; import me.myapp.me.myapp.model.ThingsProxy; import me.myapp.me.myapp.view.components.ThingsPanel; public class ListsMediator extends Mediator { private var stuffProxy:StuffProxy; private var thingsProxy:ThingsProxy; public static const NAME:String = 'ListsMediator' public function ListsMediator( viewComponent:Object ) { super( NAME, viewComponent ); } // register the event listeners and tell the proxies to fetch data override public function onRegister():void { listsNavigator.addEventListener( StuffPanel.ADD_STUFF, onAddStuff ); listsNavigator.addEventListener( StuffPanel.REMOVE_STUFF, onRemoveStuff ); listsNavigator.addEventListener( ThingsPanel.ADD_STUFF, onAddThings ); listsNavigator.addEventListener( ThingsPanel.REMOVE_STUFF, onRemoveThings ); stuffProxy = facade.retrieveProxy( StuffProxy.NAME ) as StuffProxy; stuffProxy.fetchStuff(); thingsProxy = facade.retrieveProxy( ThingsProxy.NAME ) as ThingsProxy; thingsProxy.fetchThings(); } private function get listsNavigator():ListsNavigator { return viewComponent as ListsNavigator; } private function get thingsPanel():ThingsPanel { return listsNavigator.thingsPanel as ThingsPanel; } private function get stuffPanel():StuffPanel { return listsNavigator.stuffPanel as StuffPanel; } private function onAddStuff( event:Event ):void { stuffProxy.addStuff( stuffPanel.selectedStuff ); } private function onRemoveStuff( event:Event ):void { stuffProxy.removeStuff( stuffPanel.selectedStuff ); } private function onAddThings( event:Event ):void { thingsProxy.addThings( thingsPanel.selectedThings ); } private function onRemoveThings( event:Event ):void { thingsProxy.addThings( thingsPanel.selectedThings ); } override public function listNotificationInterests():Array { return [ StuffProxy.UPDATE_STUFF, ThingsProxy.UPDATE_THINGS, ApplicationFacade.SHOW_STUFF, ApplicationFacade.SHOW_THINGS ]; } override public function handleNotification( note:INotification ):void { switch ( note.getName() ) { case StuffProxy.UPDATE_STUFF: stuffPanel.stuff = stuffProxy.stuff; break; case ThingsProxy.UPDATE_THINGS: thingsPanel.things = thingsProxy.things; break; case ApplicationFacade.SHOW_STUFF: listsNavigator.selectedChild = stuffPanel; break; case ApplicationFacade.SHOW_THINGS: listsNavigator.selectedChild = thingsPanel; break; } } }}