iLite’s Weblog

January 4, 2011

Making a List item scroll

Filed under: AMFPHP,Flex — ilite @ 7:25 am

Have you ever wanted your List items to automatically scroll…. well I have. I am building a Flex application that shows the latest 10 items in a list container.

I would like to cycle through the list once every 5 seconds, taking the last item and displaying it at the top. I am using AMFPHP to retrieve the content from a MySQL database.

 

So this is what I did

private function load():void
{
gateway = new RemotingConnection(serverName);
gateway.call(“mydetails”, new Responder(onResult, onFault));
}
private function onResult(result:Array):void
{
ac = new ArrayCollection()
for each(item in result){
var o:TicketVO = new TicketVO();
o.ticketId = item["ticketid"];
o.summary = item["summary"];
ac.addItem(o);
}
lRenderer.dataProvider = ac;                                                              // lRenderer is the name of my List container
timer = new Timer(5000, 0);
timer.addEventListener(TimerEvent.TIMER, updateList, false, 0, true);
timer.start();
}
private function updateList(event:TimerEvent):void
{
var len:Number = ac.length;
var i:Object = new Object();
i = lRenderer.dataProvider.getItemAt(len-1, 1);                   // Get the last item in the list
lRenderer.dataProvider.removeItemAt(len-1);                    // Remove the item from the list
lRenderer.dataProvider.addItemAt(i,0);                                 // Add it to the top of the list
}

The above is just a snapshot of the code I used.

 

Hope that helps some.

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.