Have you tried modifying the array/array collection that the list component is
using for the dataProvider property?
So you would move and item up or down using a button on the UI and that
button's click handler would look similar to this:
That btnMoveUp_clickHandler might look like:
private function btnMoveUp_clickHandler:void
{
var index:Number = list.selectedIndices[0];
//temp array for reassembling your data for the list
var newArray:Array = new Array();
for (var i:Number=0; i < test2.length; i++)
{ {
//item to move down
if (i == index - 1)
{
//Push the item to move up first
newArray.push(listDataProviderArray[index]);
//Push the item to move down next
newArray.push(listDataProviderArray[index - 1]);
}
//item to move up
else if (i == index)
{
//Do nothing, wait for next pass to add items again
otherwise you risk duplicating data
}
else
{
newArray.push(listDataProviderArray [i]);
}
}
listDataProviderArray = newArray;
validateNow();
}
You will need to double check this code and make corrections and make sure the
listDataProviderArray is [Bindable] so any changes to it's structure are
reflected back to the list control.
Steve Lawdis
-----Original Message-----
From: Lucas Junqueira / Ciclope [mailto:[email protected]]
Sent: Wednesday, March 13, 2013 4:49 AM
To: [email protected]
Subject: Re: help with moving list elements up and down
Nope... nor validateNow or setting the item, instead of the index worked...
2013/3/13 Evyatar Ben Halevi-Arbib <[email protected]>
> I suggest using the selectedItem property instead of selectedIndex.
> I witnessed cases where changing the selectedIndex had no impact on
> the UI and using selectedItem did work properly.
>
> Good luck,
> Evyatar
>
> On Tue, Mar 12, 2013 at 11:29 PM, Alex Harui <[email protected]> wrote:
>
> > Try calling validateNow after changing selectedIndex.
> >
> >
> > On 3/12/13 2:19 PM, "Lucas Junqueira / Ciclope"
> > <[email protected]>
> > wrote:
> >
> > > Hi, I was trying to create an order list withe the spark list control.
> I
> > > would like to move itens up and down, but this seems to be a problem.
> > Here
> > > is the code I'm trying to use to move an item up. Can anyone tell
> > > me
> why
> > it
> > > isn't working? The item label is, indeed, changed, but the list
> selection
> > > not (the selected index does not change):
> > >
> > > if (this.sequenceList.selectedIndex > 0) {
> > > var list1:Object = new Object();
> > > var list2:Object = new Object();
> > > list1.label =
> > > String(this.sequenceListData.getItemAt(this.sequenceList.selectedI
> > > ndex
> -
> > > 1).label);
> > > list1.data =
> > > String(this.sequenceListData.getItemAt(this.sequenceList.selectedI
> > > ndex
> -
> > > 1).data);
> > > list2.label =
> > >
> >
> >
> String(this.sequenceListData.getItemAt(this.sequenceList.selectedIndex
> ).label)>
> > ;
> > > list2.data =
> > >
> >
> String(this.sequenceListData.getItemAt(this.sequenceList.selectedIndex
> ).data);
> > >
> > > this.sequenceListData.getItemAt(this.sequenceList.selectedIndex -
> > > 1).label = list2.label;
> > >
> > > this.sequenceListData.getItemAt(this.sequenceList.selectedIndex -
> > > 1).data = list2.data;
> > >
> > this.sequenceListData.getItemAt(this.sequenceList.selectedIndex).lab
> > el
> > > = list1.label;
> > >
> > this.sequenceListData.getItemAt(this.sequenceList.selectedIndex).dat
> > a =
> > > list1.data;
> > >
> > > // the following does not work
> > > this.sequenceList.selectedIndex =
> > > this.sequenceList.selectedIndex -
> > 1;
> > >
> > > // tryied with and without the refresh
> > > this.sequenceListData.refresh(); }
> > >
> > > Thank you all!
> >
> > --
> > Alex Harui
> > Flex SDK Team
> > Adobe Systems, Inc.
> > http://blogs.adobe.com/aharui
> >
> >
>
--
Lucas Junqueira
[email protected] / (31)2555-0635 / (31)9133-6635 Ateliê Ciclope de arte e
publicação digital
________________________________
THIS MESSAGE IS INTENDED ONLY FOR THE USE OF THE INDIVIDUAL OR ENTITY TO WHICH
IT IS ADDRESSED AND MAY CONTAIN INFORMATION THAT IS PRIVILEGED, CONFIDENTIAL,
AND EXEMPT FROM DISCLOSURE UNDER APPLICABLE LAWS. If the reader of this message
is not the intended recipient, or the employee or agent responsible for
delivering the message to the intended recipient, you are hereby notified that
any dissemination, distribution, forwarding, or copying of this communication
is strictly prohibited. If you have received this communication in error,
please notify the sender immediately by e-mail or telephone, and delete the
original message immediately. Thank you.