Title: Where I should register meditator? Post by: TemeZ on March 09, 2008, 02:44:05 Hi,
This is very basic question.. I have two MovieClips on Stage, named 'buttonOne' and 'buttonTwo' for example. So, I have 'ApplicationFacade' what fires with startup notification a 'StartupCommand'. So how I register meditators for those buttons? should I make first meditator for stage ('StageMeditator') and in 'StageMeditator' constructor create meditators for buttons or what? ??? Title: Re: Where I should register meditator? Post by: Joel Hooks on March 10, 2008, 10:56:22 Are you sure you need separate mediators for each button?
I use an ApplicationMediator that registers several component mediators. Sometimes a I will register mediators via a Command. I think in many examples, StartupCommand is a macro command that fires off ModelPrepCommand and ViewPrepCommand, with component mediators being registered in ViewPrepCommand. Title: Re: Where I should register meditator? Post by: TemeZ on March 10, 2008, 12:16:36 As you can see, Im total noobie..
In first question I meant that flash system creation order (when some movieclip is added to stage), and because Mediators is not object in displaystack I cant get reference to instance from Stage class.. So I have to pass stage instance in document class to ApplicationFacade so I can refer to some movieclip, am I right? I was doing some first tests, I has two buttons in stage for example play and stop, or buttons witch do some tweens for those same buttons.. and I want to do proxy that keep those movements in memory and afterwards I can undo those movements.. I wanted to do that because usually I learn things better, when I do some coding by myselft.. not only to see how some other person do that.. And Its hard to explain my matter because of my bad language skills ;D Title: Re: Where I should register meditator? Post by: TemeZ on March 11, 2008, 10:49:25 more things..
Should I pass Document Class object to 'ApplicationFacade', so I can get reference by " Main.getChildByName('buttonOne') "? If I pass stage, then I have to get reference about this way " stage.getChildAt(0).getChildByName('buttonOne') " Title: Re: Where I should register meditator? Post by: puremvc on March 11, 2008, 02:07:33 This is definitely a much more reasonable way of doing things. Of course you don't want to be doing a lot of deep drilling into the child anymore than you would in a Flex component. You should try and keep your Mediator as unaware of the internals of the component as possible.
-=Cliff> Title: Re: Where I should register meditator? Post by: TemeZ on March 12, 2008, 04:01:43 Ok, thank you. My mistake was that I tried to make Moditators for every movieclip (this is my first touch to frameworks) and of course its stupid. So I have to make bigger components that have many displayobjects?
Title: Re: Where I should register meditator? Post by: puremvc on March 12, 2008, 07:50:50 Finding the appropriate granulairty is an art. And what is appropriate differs with each project.
As a general rule of thumb if a mediator is handling more than 5 or 6 events coming from its view component, then you should probably consider splitting it and its view component. The view compnent is probably becoming monolithic and less managable. -=Cliff> |