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: Big Picture Question about Views  (Read 10177 times)
DavidPesta
Newbie
*
Posts: 7


View Profile Email
« on: September 29, 2009, 04:44:09 »

Hello Everyone

Beginner question here.

If I want a view of a panel with a large list of items that needs a scrollbar, the whole thing should be one view, right? The scrollbar should not be its own separate view, but rather be a part of the same view as the panel and the items inside of that panel. Granted, the scrollbar would exist in its own class. (I'm guessing Flex has a scrollbar, but I'm more interested in pure actionscript.)

So a view is used to represent a chunk of interface functionality where several widgets are related to the same task and are working together. We should not have a separate view for every single widget in the assembly.

So, do I have all this understood correctly?

Thanks!
David
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #1 on: September 29, 2009, 06:05:47 »

More or less, that's right. You only need to mediate where data is being fed into a component or view. A ScrollBar doesn't have data, per-say (by data I mean information coming from a backend). For instance, if you had a list control, you could mediate the list because you are likely to feed data from the backend into the list. There's no need to mediate the scrollbar on the list, the list control handles that and keeps it's logic encapsulated within the control.
Logged
Helmut Granda
Full Member
***
Posts: 47

Flash Developer.


View Profile WWW Email
« Reply #2 on: September 29, 2009, 06:22:22 »

Just out of curiosity. Who are you referring to when you say "Control" are you talking about any specific kind of class within puremvc?
Logged
mariusht
Full Member
***
Posts: 26


View Profile Email
« Reply #3 on: September 29, 2009, 03:58:26 »

Jason is referring to Flex List Control.

As you may know, Flex comes with variety of components:
Controls: Button, Label, LinkButton, List, Tree...
Layout: Canvas, Tile, VBox...
Navigators: LinkBar, TabNavigator...

Mariush T.
http://mariusht.com/blog/
Logged
DavidPesta
Newbie
*
Posts: 7


View Profile Email
« Reply #4 on: September 29, 2009, 07:02:35 »

Okay, so once I have my custom panel class with all the gadgets ready for action, I want my view to inherit from this panel class. Is this the best way to go? In all the examples I've seen so far (not a whole lot), the view always inherits from Sprite. But it's okay for the view class itself to inherit from another class, right?
Logged
Helmut Granda
Full Member
***
Posts: 47

Flash Developer.


View Profile WWW Email
« Reply #5 on: September 29, 2009, 09:28:25 »

Jason is referring to Flex List Control.

As you may know, Flex comes with variety of components:
Controls: Button, Label, LinkButton, List, Tree...
Layout: Canvas, Tile, VBox...
Navigators: LinkBar, TabNavigator...


I see, some of us use the framework without Flex, that is why I was a little confused ;)
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #6 on: September 30, 2009, 08:55:38 »

Have a look at the PureMVC Flex Employee Admin demo. It is a good introduction to how to divide the work in the view into separate components and how to mediate those components so that they can collaborate on various use cases like adding employees and roles.

http://trac.puremvc.org/Demo_AS3_Flex_EmployeeAdmin
-=Cliff>
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #7 on: September 30, 2009, 08:59:50 »

The best way I find is to have a view/component that exposes public methods for feeding data into the sub components. Then have a mediator mediate that component. This allows you to keep the inner workings of the child components encapsulated within the view component.

Of course, if your main component becomes really big, or a sub component is a candiate for being mediated on it's own, the main component mediator can create another mediator to handle that sub component by passing the child into the viewComponent param of the new mediator.

Okay, so once I have my custom panel class with all the gadgets ready for action, I want my view to inherit from this panel class. Is this the best way to go? In all the examples I've seen so far (not a whole lot), the view always inherits from Sprite. But it's okay for the view class itself to inherit from another class, right?

The view component can extend, or be, any valid decendant of DisplayObject (Sprite, DisplayObjectContainer, MovieClip etc).
« Last Edit: September 30, 2009, 09:33:44 by Jason MacDonald » Logged
Pages: [1]
Print