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: Slacker - A PureMVC AS3 / Flex Demo  (Read 21885 times)
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« 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.
« Last Edit: September 23, 2012, 10:25:10 by puremvc » Logged
loeribas
Newbie
*
Posts: 2


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



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


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



View Profile WWW Email
« Reply #4 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>
Logged
kouri
Courseware Beta
Full Member
***
Posts: 28


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



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


View Profile Email
« Reply #7 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 ?
Logged
Ohm
Newbie
*
Posts: 6


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