1

I am working on a project, which uses PureMVC Standard. Now I need to add a new module SWF, which also uses Standard. I know the solution is to replace Standard MVC with MultiCore MVC, but there are two problems:

  • Standard's package structure is different from MultiCore's - do I have to correct this manually?
  • Under standard mvc framework, some code in the constructor of Mediator is allowed, while in MultiCore, this seems to be absolutely forbidden - so do I have to change so many constructors to get rid of this?

And finally: Other than replacing Standard with MultiCore, is there any better way to resolve the problem?

4

1 回答 1

1

除了跨项目的全局搜索和替换之外,我不知道有任何其他更改包结构的好方法。我这样做也没有问题。

对于中介,我在构造函数中初始化简单变量(整数、布尔值、数组等)从来没有遇到过问题,但其他任何东西都会被推迟到 onRegister (尤其是任何涉及舞台的东西),看起来像:

public class MyMediator extends Mediator implements IMediator {
    public static const NAME : String = "MyMediator";

    // internal states
    private var foo : int;

    public function MyMediator (viewComponent : Object) {
        super(NAME, viewComponent);

        foo = 0;

        trace("MyMediator()", main_mc);
    }

    override public function onRegister () : void {
        main_mc.addEventListener(...);
    }

    protected function get main_mc () : Main {
        return viewComponent as Main;
    }
}

无论如何,在 AS3 中使用稀疏构造函数是个好主意,因为构造函数代码总是被解释而不是编译

现在出于习惯,我对所有项目都使用多核,即使我有一个单核。这使得在新项目中重用调解器和代理变得更加容易。

于 2012-05-22T15:48:02.343 回答