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

Show Posts

| * |

  Show Posts
Pages: [1]
1  PureMVC Manifold / Standard Version / How to use Mediator with Flex's Repeater ? on: December 31, 2008, 04:24:15
Hello,
I'm developing some kind of image gallery in Flex 3 + PureMVC and in one of my UI component, I use a repeater, I guess it is a kind of unusual case... Usually it is simply:

Mediator:
:
someId.addEventListener()...

View component:
:
[Bindable] public var images:ArrayCollection;

...

<mx:HBox id="thumbnailContainer" width="50%" horizontalCenter="true" horizontalAlign="center" styleName="thumbContainer" backgroundAlpha="0.2" backgroundColor="#433838">
    <mx:Repeater id="thumbRepeater" dataProvider="{images}">
    <mx:Image source="{String(thumbRepeater.currentItem.thumb)}"
maintainAspectRatio="true"
height="50" width="100%"
click="onChangeCurrentImage(event)"
styleName="selectedThumb" />
    </mx:Repeater>
</mx:HBox>

...

private function onChangeCurrentImage(event:MouseEvent):void //, item:Object):void
{
selectedTarget = event.currentTarget;
selectedItem = selectedTarget.getRepeaterItem();
dispatchEvent(new Event(EVENT_CHANGE_CURRENT_IMAGE));
}

And in the mediator:
:
ui.addEventListener( ItemImagesPanel.EVENT_CHANGE_CURRENT_IMAGE, onChangeCurrentImage);


It is the first time I use a repeater in an UI with PUREMVC Mediator and I'm not sure if I did it right !
I need to get the item data in order to change the image... I hope my post was understabe enough ;-)

Any advices, remarks ?

I guess I could make a custom event and add a "data" property on it...

Thanks!
Pages: [1]