Hi,
I'm implementing my first Fabrication app and I'm missing something since the trap/reactTo support is not working for any of my mediators.
I've double checked (following
http://code.google.com/p/fabrication/wiki/Reactions):
1. My mediator extends FlexMediator;
2. I do have a property get function at the mediator for the component I'd like to reactTo/trap (btnEntrar);
3. My reactTo method is CamelCase named with the event (Click) CamelCased as well.
[EDITED] The only difference between the sample and my application that I'm aware of is the mediator registration:
registerMediator(new LoginScreenMediator(app.loginScreen));
I'm not able to use correctly the resolve method receiving a cast exception when I do use it:
resolve(application).loginScreen
(and I do have the loginScreen component at the application.
If I register the event listener (commented line on onRegister method) my application works fine.
Any idea on what am I missing?
package icm.main.view
{
import flash.events.MouseEvent;
import icm.main.*;
import icm.main.controller.*;
import icm.main.model.*;
import icm.main.model.vo.*;
import icm.main.view.screens.*;
import mx.controls.Button;
import org.puremvc.as3.multicore.interfaces.*;
import org.puremvc.as3.multicore.utilities.fabrication.patterns.mediator.FlexMediator;
public class LoginScreenMediator extends FlexMediator
{
public static const NAME:String = "LoginScreenMediator";
private var configProxy:ConfigProxy;
private var localeProxy:LocaleProxy;
private var authProxy:AuthProxy;
public function LoginScreenMediator( viewComponent:LoginScreen )
{
super( NAME, viewComponent );
}
override public function onRegister():void {
super.onRegister();
//btnEntrar.addEventListener( MouseEvent.CLICK, trapBtnEntrarClick );
}
protected function get loginScreen():LoginScreen
{
return viewComponent as LoginScreen;
}
public function get btnEntrar():Button {
return loginScreen.btnEntrar as Button;
}
public function respondToSuccessAuth(note:INotification):void {
sendNotification( Messages.SHOW_MAIN_SCREEN );
}
public function respondToFailedAuth(note:INotification):void {
loginScreen.userMessagePanel.visible = true;
var msgkey:String = note.getBody() as String;
var msgcomplement:String = note.getType() as String;
var msg:String = localeProxy.getText(msgkey);
if(msgcomplement != null)
msg += " " + msgcomplement;
loginScreen.userMessage.text = msg;
}
public function trapBtnEntrarClick(event:MouseEvent):void
{
var user:UserVO = new UserVO();
user.username = loginScreen.txtUsuario.text;
user.password = loginScreen.txtSenha.text;
return sendNotification(Messages.LOGIN, user);
}
}
}