Hi,
I'm trying to use the Mvc pattern for the first time and I'm guessing
if I'm using the best method to achieve a goal.
Now the thing is working... only not sure there is a better mode!
This is the problem:
1) in my fla there are some movieclip containing button, they are
called elem1_mc.bottone_btn, elem2_mc.bottone_btn etc.
2) in a cycle in the View I do
_rootMc.elementiAvatar_mc["elem"+i+"_mc"].model=_model;
_rootMc.elementiAvatar_mc["elem"+i+"_mc"].bottone_btn.onRelease =
Delegate.create(_rootMc.elementiAvatar_mc["elem"+i+"_mc"],
_controller.onElementiAvatarReleased);
3) in the Controller there is this function
public function onElementiAvatarReleased() {
var elementClicked:Number =
Number(arguments.caller.target._name.substr(4, 1));
var model:AvatarModel = arguments.caller.target.model;
model.changeCurrentElementTo(elementClicked);
}
4) finally in the Model there is the function
public function changeCurrentElementTo(newCurrentElement:Number) {
_typeCurrent=newCurrentElement;
var stringa:String = "changed Current Element To:
"+newCurrentElement;
var stato:Result = new Result(true, stringa);
broadcastMessage("onChangedElementType", stato);
readElementi();
}
the broadcastMessage tell the view to update itself according to the
new state of Model
I hope this is clear...
My question there is a method to do this without use
arguments.caller.target?
if you are a curious one can have a look at
www.imageinaction.net/avatar but at the moment is no finished...
Thank you
Roberto
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com