Hissam:

IMHO - using the renderer instance itself might lead to a lot more
trouble, because those instances are not reliable because of the
renderer recycling.

Harish

On Jul 30, 8:35 am, HISSAM <[email protected]> wrote:
> I actually wanted the selected the selected item.
> But this cannot be done as the item is still not created yet, its just in
> the setting its properties stage.
>
> Anyways I had already assigned the data of the first selected item to my
> right list(the other list).
> All I wanted is the selected item in my left list ie the renderer should
> change some state
> that means I have to add state to the item renderer, that means lots of
> changes :(
>
> On Thu, Jul 30, 2009 at 11:01 AM, [email protected] <
>
> [email protected]> wrote:
>
> > Hissam
>
> > I presume, you are accessing the itemRenderer of the List just to get
> > access to the data Object that it holds. If that is the case, you can
> > get the data object by doing the following
>
> > In my code, inside the myFunc method, you can access the data of the
> > selected item of ist1 by using  -( mylist1.dataProvider as
> > ArrayCollection).getItemAt(value)
>
> > This will give access to the object of the current selection that
> > mylist1 is holding. It is not very reilable tracking itemRenderer
> > instances of List / ListBase components as they get recycled at
> > various cycles like scrolling / dataProvider change. Its recommended
> > to use the underlying dataProvider to access the data objects.
>
> > Let me know if this approach works. I will post some code later the
> > day.
>
> > Harish
> > Evangelist, Adobe India
>
> > On Jul 30, 7:20 am, HISSAM <[email protected]> wrote:
> > > Hey Guys
>
> > > I tried the other way using the mx_internal accessing the rendererArray
> > > which stores all the renderers but not to my surprise I got NULL object
> > > as I'm just in the phase of assigning data
>
> > > :(
>
> > > On Thu, Jul 30, 2009 at 9:53 AM, HISSAM <[email protected]>
> > wrote:
> > > > Hey hsivaramakrishnan
>
> > > >                                      Its really appreciating that u
> > stood
> > > > up with an example for solving my issue, thanks for your support.
> > > > Things still did not work up as i have nothing to do with the selected
> > > > index change.
>
> > > > I'll explain again.
>
> > > > When a user click on an item in a list, the default "itemclick" event
> > is
> > > > generated which I'm catching and things are working smooth.
>
> > //****************************************************************************************************
>
> > > > private function selectLeftListItem(l:ListEvent):void
> > > >         {
> > > >             var item:SelectLeftRenderer;
> > > >             if(l.currentTarget is List)
> > > >             {
> > > >                 var list:PublishList=l.currentTarget as PublishList;
> > > >                 var o:Object=l.itemRenderer.data;
> > > >                 if(o!=selectedItemData)
> > > >                 {
> > > >                   .
> > > >                   .
> > > >                   .
>
> >  /**********************************************************************************************/
>
> > > > No I want to fire this default event ("itemselect" event) explictly at
> > the
> > > > start
> > > > where i was trying like this
>
> > /*************************************************************************************************************
> > > > leftList.dataProvider=libfiles;
> > > >                         leftList.selectedIndex=0;//setting the 1st item
> > as
> > > > selected
> > > >                         var l:ListEvent=new
> > > > ListEvent(ListEvent.ITEM_CLICK);//trying to dispatch event explictly
> > > >                         l.itemRenderer=leftList.itemRenderer as
> > > > IListItemRenderer;//****************problem area
> > > >                         l.itemRenderer.data=leftList.selectedItem as
> > > > IListItemRenderer;
> > > >                         leftList.dispatchEvent(l);
>
> > /****************************************************************************************************************/
>
> > > > But could not go ahead as list is not allowing me to access its
> > renderer
> > > > directly
>
> > > > I guess I'm clear enough to explain my problem.
>
> > > > My next plan of action is to use the mx_internal which I really dont
> > want
> > > > to do :(
>
> > > > On Wed, Jul 29, 2009 at 7:50 PM, [email protected] <
> > > > [email protected]> wrote:
>
> > > >> If I understood your problem correctly, The following code should
> > > >> solve your problem. It is indeed solved using BindingUtils.
>
> > > >> <?xml version="1.0" encoding="utf-8"?>
> > > >> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> > > >> layout="vertical" creationComplete="init()">
> > > >>        <mx:NumericStepper stepSize="0.01"/>
> > > >> <mx:Script>
> > > >>        <![CDATA[
> > > >>                import mx.binding.utils.BindingUtils;
> > > >>                [Bindable]private var _selectedIndex:Number = -1;
> > > >>                private function init():void
> > > >>                {
>
> > > >>                        BindingUtils.bindSetter(myFunc,
> > > >> mylist,"selectedIndex");
> > > >>                        _selectedIndex = 1;
> > > >>                }
> > > >>               /* As SelectedIndex Changes, this method gets called
> > > >> and will give you access to the property selected. You can use that or
> > > >> any other prop of the list to do your magic here */
>
> > > >>                private function myFunc(value:Object):void
> > > >>                {
> > > >>                        //dummy implementation, change this to yours.
> > > >>                        if(value != -1)
> > > >>                        {
> > > >>                                mylist2.dataProvider.addItem(4);
> > > >>                        }
> > > >>                }
> > > >>        ]]>
> > > >> </mx:Script>
> > > >> <mx:List id="mylist" dataProvider="{[1,2,3]}"
> > > >> selectedIndex="{_selectedIndex}" width="200" height="200"/>
> > > >> <mx:List id="mylist2" dataProvider="{[1,2,3]}" width="200"
> > > >> height="200"/>
> > > >> </mx:Application>
>
> > > >> On Jul 29, 4:29 pm, Ravi Mishra <[email protected]> wrote:
> > > >> > Try using collectionChange event of the dataprovider of first list.
> > It
> > > >> > could help.
>
> > > >> > -Ravi
>
> > > >> > On Jul 29, 4:18 pm, HISSAM <[email protected]> wrote:
>
> > > >> > > Its not the question of creation complete
> > > >> > > what when my dataprovider of left list changes??
> > > >> > > no creation event is gonna trigger
> > > >> > > Also at creation complete how do i access the 1st selected item??
>
> > > >> > > On Wed, Jul 29, 2009 at 6:49 PM, Amol Pandhare <
> > > >> [email protected]>wrote:
>
> > > >> > > > Hey Hissam,
>
> > > >> > > > You might be having a click listener on the left list and a
> > function
> > > >> > > > associated to it. On the same list keep a creationComplete
> > listener
> > > >> and
> > > >> > > > point it to the same listener function as that of the click
> > event.
> > > >> And for
> > > >> > > > the listener function to work make the event type of the
> > attribute
> > > >> as Event,
> > > >> > > > the super class, instead of say ListEvent. Dont forget to set
> > the
> > > >> selected
> > > >> > > > index of the left list.
>
> > > >> > > > This should help.
>
> > > >> > > > Regards,
> > > >> > > > Amol.
>
> > > >> > > > On Wed, Jul 29, 2009 at 4:00 PM, HISSAM <
> > [email protected]>
> > > >> wrote:
>
> > > >> > > >> I have already tried that!!
>
> > > >> > > >> On Wed, Jul 29, 2009 at 6:26 PM, sheetal <
> > [email protected]
> > > >> >wrote:
>
> > > >> > > >>> Try setting the selected index of that list and dispatch click
> > > >> event
> > > >> > > >>> on the list.
>
> > > >> > > >>> On Jul 29, 3:14 pm, HISSAM <[email protected]> wrote:
> > > >> > > >>> > I have 2 list(left list /right list ) and click on an item
> > of
> > > >> left-
> > > >> > > >>> > list , data is changed of the right list respective with the
> > > >> item
> > > >> > > >>> > selected in the lest list.
>
> > > >> > > >>> > This is working fine with no hassels at all.
>
> > > >> > > >>> > My requirement is
>
> > > >> > > >>> > At the start i want the 1st item of the right list be
> > selected
> > > >> and
> > > >> > > >>> > dispatch the respective event to change the data of the left
> > > >> list.
>
> > > >> > > >>> > How do i go about?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to