首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Flex MultiCore PureMVC通告程序初始化错误

Flex MultiCore PureMVC通告程序初始化错误
EN

Stack Overflow用户
提问于 2011-05-28 05:36:24
回答 1查看 1.1K关注 0票数 0

我正在试着写一个简单的多核PureMVC helloword。我收到错误:此通告程序的multitonKey尚未初始化!

在org.puremvc.as3.multicore.patterns.observer::Notifier/get Workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\patterns\observer\Notifier.as:89 ()C:\Documents org.puremvc.as3.multicore.patterns.observer::Notifier/get Settings\Owner.CapricornOne\My Documents\My facade at com.jacksutest.view::ApplicationMediator()C:\myworkspace\MyPureMVC\src\com\jacksutest\view\ApplicationMediator.as:15

下面是主要的mxml:

代码语言:javascript
复制
public static const APP_NAME : String = "MyPureMVC";
private var facade : ApplicationFacade = ApplicationFacade.getInstance(APP_NAME);
public function init() : void 
{
facade.startup(this);
}

..。

代码语言:javascript
复制
 <components:WordForm id="theWordForm"/>

这是ApplicationFacade。公共类ApplicationFacade扩展了外观实现IFacade {公共静态常量启动: String =“启动”;公共静态常量VERIFY_WORD : String = "VerifyWord";

代码语言:javascript
复制
    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);
    }
}

}

这是启动命令

代码语言:javascript
复制
public class StartupCommand extends MacroCommand
{
    public function StartupCommand()
    {
    trace("Startup command created");
        addSubCommand(ModelPrepCommand);
        addSubCommand(ViewPrepCommand);
    }
}

这是ViewPrepCommand

代码语言:javascript
复制
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:

代码语言:javascript
复制
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时发生错误。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-05-28 20:58:18

找到问题所在。我不应该在ApplicationMediator的构造函数中引用facade。

相反,我应该在onRegister方法中调用facade.registerMediator。

代码语言:javascript
复制
    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;
    }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6157948

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档