onInitModel...

6 views
Skip to first unread message

Dante!

unread,
Apr 28, 2011, 11:32:29 AM4/28/11
to pixlib
Hello

j'ai une view qui étend PXAbstractView et qui ecoute mon model. Celui-
ci execute onInitModel à la fin du constructeur. La vue n'entend
rien...

Dans le Main :

var appModel:AppModel = new AppModel(null, ModelList.APPLI);
appModel.addListener(gameView);

Dans appModel :

public function AppModel(modelOwner:PXPlugin = null, modelName:String
= null)
{
super(modelOwner, modelName);
onInitModel();
}

Dans gameView :

override public function onInitModel (e:PXModelEvent) : void
{
PXDebug.DEBUG("onInitModel", this);
}

Rien ne se passe...
Any idea?

Romain Ecarnot

unread,
May 8, 2011, 12:30:01 PM5/8/11
to pixlib
Bonjour,

Tu ne dois appeler le onInitModel dans ton constructeur. La vue n'est
pas encore abonnée à ton modèle à ce moment là.
Donc... tu peux faire :

public function AppModel(modelOwner:PXPlugin = null, modelName:String
= null)
{
super(modelOwner, modelName);
}

public function run() : Void
{
onInitModel();
}

var appModel:AppModel = new AppModel(null, ModelList.APPLI);
appModel.addListener(gameView);
appModel.run();

Cdt,
R.
Reply all
Reply to author
Forward
0 new messages