Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Where I should register meditator?  (Read 10037 times)
TemeZ
Newbie
*
Posts: 4


View Profile Email
« 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?  ???
Logged
Joel Hooks
Courseware Beta
Sr. Member
***
Posts: 146


baby steps

 - 46288188  - passport@provinsal.com  - joeltuff
View Profile WWW Email
« Reply #1 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.
Logged

http://joelhooks.com - my ramblings about developing with actionscript and python using pureMVC and django respectively.
TemeZ
Newbie
*
Posts: 4


View Profile Email
« Reply #2 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
Logged
TemeZ
Newbie
*
Posts: 4


View Profile Email
« Reply #3 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') "
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 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>
Logged
TemeZ
Newbie
*
Posts: 4


View Profile Email
« Reply #5 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?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #6 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>
Logged
Pages: [1]
Print