PureMVC Architects Lounge

PureMVC Manifold => Demos and Utils => Topic started by: puremvc on August 18, 2008, 05:15:44



Title: Slacker - A PureMVC AS3 / Flex Demo
Post by: puremvc on August 18, 2008, 05:15:44
This demo illustrates techniques for handling Flex's Deferred Instantiation of View Components.

The demo has historically been located here: http://trac.puremvc.org/Demo_AS3_Flex_Slacker
The project has been moved here: https://github.com/PureMVC/puremvc-as3-demo-flex-slacker/wiki

The author is Cliff Hall.


Title: Re: Slacker - A PureMVC AS3 / Flex Demo
Post by: loeribas on October 22, 2008, 01:41:26
Thanks for the Slacker example.
There can be a problem by using a ViewStack however.
Imagine each views Mediator in a ViewStack listens for an ApplicationFacade.ON_NEXT and ApplicationFacade.ON_PREVIOUS notification.
When I send such a notification through the application, ALL mediators react, because the ViewStack only HIDES the not selected views.

A simple check on the views visibility a the start of the handleNotification method doesn't solve this problem. I just want the mediator of the ACTIVE view to react on notifications.

Anyone any ideas about a simple solution?


Title: Re: Slacker - A PureMVC AS3 / Flex Demo
Post by: puremvc on October 23, 2008, 05:35:26
The mediator that owns the stack should be the one that listens for NEXT/PREV notes, not all mediators.

When it gets the note, it adjusts the stack selected index.

Then in onShow of your stack's view components send an event that will be heard by its Mediator, and voila - your revealed child's mediator will respond.

-=Cliff>


Title: Re: Slacker - A PureMVC AS3 / Flex Demo
Post by: loeribas on October 23, 2008, 09:42:42
Thanks for your answer.
My example isn't very clear. It is not about those specific notifications. The thing that's nasty for my, is that all mediators from inactive ViewStack assets keep receiving their notifications. Maybe the only valid solution to this problem is something like removing the mediator when its view is not active.


Title: Re: Slacker - A PureMVC AS3 / Flex Demo
Post by: puremvc on October 28, 2008, 06:22:59
You can certainly remove mediators when their children are hidden but if its categorical that you don't want a madiator to respond at all when its child is hidden, just check the visible property of the view component and return if false as the first line of handleNotification.

-=Cliff>


Title: Re: Slacker - A PureMVC AS3 / Flex Demo
Post by: kouri on November 30, 2008, 05:39:18
Cliff,

What if  one of viewstack's view contains several heavy containers that are not managed through a VS (i.e 4 forms fed by big datasources and displayed simultaneously...)
VS____V1
 l_____V2____C1,C2,C3,C4
 l_____V3

Is checking parent view is enough (through creationComplete/checkForMediator) or does I need to add checking for each components ?

Thx for your answer

Eric


Title: Re: Slacker - A PureMVC AS3 / Flex Demo
Post by: puremvc on December 01, 2008, 02:57:29
If you send bubbling events, and catch them at the ApplicationMediator, you can register the appropriate Mediator for any view component regardless of its nesting depth.

Just send the event from the creationComplete handler of the view component. VS.V1.C2 from your example for instance might send an event that causes a C2Mediator to be checked for/registered.

-=Cliff>


Title: Re: Slacker - A PureMVC AS3 / Flex Demo
Post by: Ohm on April 12, 2010, 08:55:49
Hi,

I'm trying to run this sample within Flash Builder 4, and guess what ? It doesn't want to work out.

the thing is that the events sent in the MainDisplay at the creationComplete of the views in the ViewStack are fired before the MainDisplayMediator is registered... so the MainDisplayMediator doesn't get for instance the GALLERY_CREATED event, which allows facade.registerMediator( new GalleryViewMediator( child ) ), and thus the galleryView in the onRegister function in the GalleryViewMediator is null :-(

any ideas ?


Title: Re: Slacker - A PureMVC AS3 / Flex Demo
Post by: Ohm on April 12, 2010, 09:33:50
ok, I got it !

I was using "NavigatorContent" for my views in the ViewStack... (I didn't understood yet why the events was fired so soon), but by replacing it with a Canvas, everything is fine !