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: TileList problem  (Read 5687 times)
rreyes
Newbie
*
Posts: 3


View Profile Email
« on: August 06, 2008, 02:21:15 »

Hi

I am having problems creating my first custom component with PureMVC. It is a menu that uses both Accordions and TileLists. I have it almost working, but for some strange reason, I can't make the items from the ItemList selectable. I already made a similar menu without using PureMVC and I have it working already.
I am attaching the source code. Please help.

Rodrigo  ???
Logged
Lothiack


Email
« Reply #1 on: August 06, 2008, 03:47:35 »

Could you be a little more specific? Most people in foruns don´t have the time to look thru all your code just to find what is wrong with it.

Try posting only the parts you think may have a problem.
Logged
rreyes
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: August 07, 2008, 08:11:56 »

Sure I can be. Sorry.
This may not be a PureMVC problem but I am not sure. I have a MenuProxy which loads the Menu Value objects. The ViewPrepCommand inyects the Proxy info into the Menu Component and this is what happens:

1) The MenuComponent creates a new MenuGroup (AccordionPanel) for each MenuGroupVO
:
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" xmlns:ns1="com.corbitecso.cegacorp.cegacontrol.flex.view.components.*">
<!-- Events dispatched by this View Component -->
<mx:Metadata>
[Event('selectionChange')]
</mx:Metadata>

<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import com.corbitecso.cegacorp.cegacontrol.flex.model.vo.MenuGroupVO;
import com.corbitecso.cegacorp.cegacontrol.flex.model.vo.MenuItemVO;
public static const SELECTION_CHANGE:String = "selectionChange";

public function set menuGroups(mgs:ArrayCollection):void{
var mgvo:MenuGroupVO;
var mg:MenuGroup;
for(var i:int = 0; i < mgs.length; i++){
mgvo = mgs[i];
mg = new MenuGroup();
mg.menuItems = mgvo;
this.acc.addChild(mg);
}
}
]]>
</mx:Script>

<mx:Accordion id="acc" width="100%" height="100%" headerHeight="40">
</mx:Accordion>
</mx:VBox>

2)  The MenuGroup contains a TileList which gets populated with the info of the MenuItems contained in the MenuGroup.
:
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" label="{labelStr}" initialize="init()">
<mx:Script>
<![CDATA[
import com.corbitecso.cegacorp.cegacontrol.flex.model.vo.MenuGroupVO;
import mx.collections.ArrayCollection;

private var menuGroupVO:MenuGroupVO;

[Bindable]
private var menuItemsCollection:ArrayCollection;

[Bindable]
private var labelStr:String;

public function set menuItems(mi:MenuGroupVO):void {
this.menuGroupVO = mi;
this.menuItemsCollection = mi.menuItems;
this.labelStr = mi.name;
}

public function init():void {

}
]]>
</mx:Script>
<mx:TileList id="tList" width="100%" verticalScrollPolicy="auto" height="100%" dataProvider="{menuItemsCollection}" itemRenderer="com.corbitecso.cegacorp.cegacontrol.flex.view.components.MenuItem" columnCount="1" selectedIndex="0" borderStyle="none" >
</mx:TileList>
</mx:HBox>

3) Finally, here is the itemRender code.
:
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" verticalAlign="middle" verticalScrollPolicy="off" horizontalScrollPolicy="off">
<mx:Script>
<![CDATA[
import com.benstucki.utilities.IconUtility;
import com.corbitecso.cegacorp.cegacontrol.flex.model.vo.MenuItemVO;

[Bindable]
        private var nameStr:String;

        [Bindable]
        [Embed(source="assets/accept.png")]
        private var imageSrc:Class;
       
        [Bindable]
        private var desc:String;
       
        public var menuItemData:MenuItemVO;

override public function set data(value:Object):void {
            nameStr = value.name;
            desc = value.desc;
           
            menuItemData = value as MenuItemVO;
        }

]]>
</mx:Script>
<mx:Image source="{imageSrc}" width="32" height="32"/>
<mx:VBox width="100%" height="100%" horizontalAlign="left" verticalAlign="middle" id="vbox1">
<mx:Text text="{nameStr}" width="100%" textAlign="left" selectable="false" id="text1" fontSize="14"/>
</mx:VBox>
</mx:HBox>

I really don't know what is happening. Maybe is because I am creating dinamicly the accordions and TileLists. I have seen lots of posts about people having problems trying TileList not to show selection. Mine is the exact opposite :)

Thanks again...

Rodrigo
Logged
Lothiack


Email
« Reply #3 on: August 07, 2008, 08:48:19 »

I don´t get it. I just tried your source here and all seems well.

Check the image I attached and see if that´s "selected".
I´m a "PureAS3" guy so I don´t know this mxml and components stuff very well.  :D

<edit>

Testing again I noticed that I can select any combination in the list, but can´t deselect them. I don´t know if that´s the intention, but it´s what´s happening here.
« Last Edit: August 07, 2008, 08:51:33 by Lothiack » Logged
rreyes
Newbie
*
Posts: 3


View Profile Email
« Reply #4 on: August 07, 2008, 08:57:22 »

Lothiack

Thanx for your help. I already figured it out. You need to call super.data = value; at the itemRender set data(value:Object) function in order to have selection working.
What you saw was a selection mecanism I was trying to program myself since the other one was not working :)

Here is the correct code:

:
override public function set data(value:Object):void {
super.data = value;
            nameStr = value.name;
            desc = value.desc;
           
            menuItemData = value as MenuItemVO;
        }

Hope this helps someone (or even you). And thanx again...

Rodrigo
Logged
Lothiack


Email
« Reply #5 on: August 07, 2008, 09:10:42 »

Well, good luck with your project.
I hope I can be more helpfull next time.
Logged
Pages: [1]
Print