Why do your buttons all need references to different models? If they really do use different models then I'd create different views to render them and different controllers to control them.
If they're all using the same model then just pass a reference to the button (this) to the controller, the controller can then check whatever it needs on the button before calling a function on the model. T -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Roberto Scordino Sent: 13 December 2006 11:35 To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] MVC pattern problem 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 _______________________________________________ Flashcoders@chattyfig.figleaf.com 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 -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.15.18/584 - Release Date: 12/12/2006 23:17 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.15.18/584 - Release Date: 12/12/2006 23:17 _______________________________________________ Flashcoders@chattyfig.figleaf.com 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