Flex MultiCore PureMVC 通知程序初始化错误
我正在尝试编写一个简单的多核 PureMVC helloword。我收到错误:此通知程序的 multitonKey 尚未初始化!
在 org.puremvc.as3.multicore.patterns.observer::Notifier/getfacade()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\多核\模式\观察者\Notifier.as:89] 在 com.jacksutest.view::ApplicationMediator()[C:\myworkspace\MyPureMVC\src\com\jacksutest\view\ApplicationMediator.as:15]
这是主要的 mxml:
public static const APP_NAME : String = "MyPureMVC";
private var facade : ApplicationFacade = ApplicationFacade.getInstance(APP_NAME);
public function init() : void
{
facade.startup(this);
}
...
<组件:WordForm id="theWordForm"/>
这是应用程序外观。 公共类 ApplicationFacade 扩展 Facade 实现 IFacade { 公共静态 const STARTUP : String = "启动"; 公共静态 const VERIFY_WORD : String = "VerifyWord";
public function ApplicationFacade(key:String)
{
super(key);
}
public static function removeInstance(key:String):void
{
if( null != instanceMap )
{
if( null != instanceMap[key] )
{
delete instanceMap[key];
}
}
}
/**
* Singleton ApplicationFacade Factory Method
*/
public static function getInstance(key:String):ApplicationFacade
{
if ( null == instanceMap[key] )
{
instanceMap[key] = new ApplicationFacade(key);
}
return instanceMap[key] as ApplicationFacade;
}
/**
* Register Commands with the Controller
*/
override protected function initializeController():void
{
super.initializeController();
registerCommand(STARTUP, StartupCommand);
registerCommand(VERIFY_WORD, VerifyWordCommand);
}
public function startup(app : MyPureMVC):void
{
trace("In facade startup");
sendNotification(STARTUP, app);
}
public function verifyWord(wordDTO : WordDTO) : void
{
sendNotification(VERIFY_WORD, wordDTO);
}
}
这
是启动命令
public class StartupCommand extends MacroCommand
{
public function StartupCommand()
{
trace("Startup command created");
addSubCommand(ModelPrepCommand);
addSubCommand(ViewPrepCommand);
}
}
这是ViewPrepCommand
public class ViewPrepCommand extends SimpleCommand
{
override public function execute( note : INotification ) : void
{
var app : MyPureMVC = note.getBody() as MyPureMVC;
facade.registerMediator(new ApplicationMediator(app));
}
}
这是ApplicationMediator:
public class ApplicationMediator extends Mediator implements IMediator
{
public static const NAME : String = "MyPureMVCApplicationMediator";
public function ApplicationMediator(mainApp : MyPureMVC)
{
facade.registerMediator(new WordFormMediator(mainApp.theWordForm));
}
当facade.registerMediator时发生错误。
I am trying to write a simple multicore PureMVC helloword. I am getting Error: multitonKey for this Notifier not yet initialized!
at org.puremvc.as3.multicore.patterns.observer::Notifier/get facade()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\patterns\observer\Notifier.as:89]
at com.jacksutest.view::ApplicationMediator()[C:\myworkspace\MyPureMVC\src\com\jacksutest\view\ApplicationMediator.as:15]
Here is the main mxml:
public static const APP_NAME : String = "MyPureMVC";
private var facade : ApplicationFacade = ApplicationFacade.getInstance(APP_NAME);
public function init() : void
{
facade.startup(this);
}
...
<components:WordForm id="theWordForm"/>
This is the ApplicationFacade.
public class ApplicationFacade extends Facade implements IFacade
{
public static const STARTUP : String = "Startup";
public static const VERIFY_WORD : String = "VerifyWord";
public function ApplicationFacade(key:String)
{
super(key);
}
public static function removeInstance(key:String):void
{
if( null != instanceMap )
{
if( null != instanceMap[key] )
{
delete instanceMap[key];
}
}
}
/**
* Singleton ApplicationFacade Factory Method
*/
public static function getInstance(key:String):ApplicationFacade
{
if ( null == instanceMap[key] )
{
instanceMap[key] = new ApplicationFacade(key);
}
return instanceMap[key] as ApplicationFacade;
}
/**
* Register Commands with the Controller
*/
override protected function initializeController():void
{
super.initializeController();
registerCommand(STARTUP, StartupCommand);
registerCommand(VERIFY_WORD, VerifyWordCommand);
}
public function startup(app : MyPureMVC):void
{
trace("In facade startup");
sendNotification(STARTUP, app);
}
public function verifyWord(wordDTO : WordDTO) : void
{
sendNotification(VERIFY_WORD, wordDTO);
}
}
}
This is startup command
public class StartupCommand extends MacroCommand
{
public function StartupCommand()
{
trace("Startup command created");
addSubCommand(ModelPrepCommand);
addSubCommand(ViewPrepCommand);
}
}
This is ViewPrepCommand
public class ViewPrepCommand extends SimpleCommand
{
override public function execute( note : INotification ) : void
{
var app : MyPureMVC = note.getBody() as MyPureMVC;
facade.registerMediator(new ApplicationMediator(app));
}
}
And this is ApplicationMediator:
public class ApplicationMediator extends Mediator implements IMediator
{
public static const NAME : String = "MyPureMVCApplicationMediator";
public function ApplicationMediator(mainApp : MyPureMVC)
{
facade.registerMediator(new WordFormMediator(mainApp.theWordForm));
}
Error happens when facade.registerMediator.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到问题所在。我不应该在 ApplicationMediator 的构造函数中引用facade。
相反,我应该在 onRegister 方法中调用facade.registerMediator。
Find the problem. I should not reference facade in the constructor of ApplicationMediator.
Instead, I should call the facade.registerMediator in onRegister method.