Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-06-2007, 07:48 AM   #1
Nap0
Registered User
 
Join Date: Sep 2007
Posts: 4
Default Populate a list

Hi,

I'm beginner, I wish populate a Control List in ActionScript (with a divisors of a number but it's may be anything else). how to do this ?

Thanks for your help.
Nap0 is offline   Reply With Quote
Old 09-06-2007, 08:33 AM   #2
drkstr
Flexpert
 
drkstr's Avatar
 
Join Date: Sep 2006
Location: Seattle, WA: USA
Posts: 1,587
Default

Not quite sure what you mean, but here is a link that gives you example usage for every component.

http://examples.adobe.com/flex2/inpr.../explorer.html

Hope this helps,
...aaron
drkstr is offline   Reply With Quote
Old 09-06-2007, 09:01 AM   #3
Nap0
Registered User
 
Join Date: Sep 2007
Posts: 4
Default Good Link

Thanks, it's a good link. I save it

But isn't exactly that i wish. My problem is to populate list by a code AS3. The DataProvider isn't a hard coded or XML File.

For exemple.

for ( i=1; i <= 5; i++) {
add value of i in Control List (!!!)
}

Result in Control List :
1
2
3
4
5
Nap0 is offline   Reply With Quote
Old 09-06-2007, 03:49 PM   #4
drkstr
Flexpert
 
drkstr's Avatar
 
Join Date: Sep 2006
Location: Seattle, WA: USA
Posts: 1,587
Default

You would want to create a [Bindable] data provider of type ArrayCollection.

Like this:

Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
	 width="100%" height="100%"
	 creationComplete="onCreationComplete();"  >

   <mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

[Bindable]
private var myDataProvider:ArrayCollection;

private function onCreationComplete(): void {
	var itemList:Array = new Array();
	var item:Object;
	
	for( var i:int = 0; i < 10; i++ ) {
		item = new Object();
		item.data = i;
		itemList.push( item );
	}
	
	myDataProvider = new ArrayCollection( itemList );
}


]]>
</mx:Script>

<mx:Panel id="idBoxFrame" width="100%" height="100%" >
	<mx:List id="idDataList" labelField="data" dataProvider="{myDataProvider}" />
</mx:Panel>
    
</mx:Application>
You can also update the data provider directly by using myDataProvider.addItem(item) in the loop, but this will update the display list 10 times instead of one which takes more processor work.

Best regards,
...aaron
drkstr is offline   Reply With Quote
Old 09-06-2007, 09:57 PM   #5
Nap0
Registered User
 
Join Date: Sep 2007
Posts: 4
Default Yes !

It's exactly that.

Thanks drkstr !
Nap0 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
populate list and combobox from xml smakwam Flex 2, 3 & 4 6 02-25-2008 07:02 PM
Major Problems trying to capture "click" event in List component ManinBlaq Components 11 01-30-2007 07:12 PM
Filter list as you type interface like on an iPod BCSWebStudio ActionScript 2.0 4 10-01-2006 06:54 AM
CyanBlue's 5000th Post - Useful Threads List CyanBlue Projectors and CDs 104 02-25-2005 01:13 PM
Macromedia Central CyanBlue ActionScript 1.0 (and below) 13 08-01-2003 09:05 PM


All times are GMT. The time now is 11:13 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.