我正在尝试编写一个简单的多核PureMVC helloword。我收到错误:此Notifier的multitonKey尚未初始化!
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 \多核\图案\观察者\ Notifier.as:89] at 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);
}
...
< components:WordForm id =“theWordForm”/>
这是ApplicationFacade。 公共类ApplicationFacade扩展了Facade实现的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);
}
}
}
这是启动命令
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。
时发生错误答案 0 :(得分:1)
找到问题所在。我不应该在ApplicationMediator的构造函数中引用facade。
相反,我应该在onRegister方法中调用facade.registerMediator。
public static const NAME : String = "MyPureMVCApplicationMediator";
public function ApplicationMediator(viewComponent : MyPureMVC)
{
super( NAME, viewComponent );
}
override public function onRegister():void
{
// Retrieve reference to frequently consulted Proxies
facade.registerMediator(new WordFormMediator(mainApp.theWordForm));
}
public function get mainApp() : MyPureMVC
{
return viewComponent as MyPureMVC;
}