Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Extensions and Plugins > Components

Reply
 
Thread Tools Rate Thread Display Modes
Old 10-28-2002, 11:33 AM   #1
barrowman
Registered User
 
Join Date: Sep 2002
Location: in the dark
Posts: 250
Default getting an array into listbox component...

HIi

I know how to get an external txt file into the listbox component...

ActionScript Code:
myData = new LoadVars (); myData.onLoad = AddItems; myData.load ("ComboBox_Text_Link2.txt"); //---------------------- function AddItems() {         for (i=0; i<5; i++) {             var Name       = eval("myData.Name"+i);                         var DataProvider = { Link:Name};       dropDown.addItem(Name, DataProvider);     }     dropDown.setChangeHandler("SelectItem"); }

But what if I have an array

dArray = ["item0" , "item1" , "item2" , "item3" , "item4"];

How could I get that into the component list box...

thanks in advance...
barrowman is offline   Reply With Quote
Old 10-28-2002, 11:49 AM   #2
pom
Allez les Bleus!!!
 
pom's Avatar
 
Join Date: Oct 2002
Location: Paname
Posts: 2,493
Default

If your listbox is called myList, then
ActionScript Code:
dArray = ["item0" , "item1" , "item2" , "item3" , "item4"]; for (var item in dArray) myList.addItem(dArray[item]);
will fill it. Then you can fill it on (press) or anything else...

pom
pom is offline   Reply With Quote
Old 10-28-2002, 03:36 PM   #3
barrowman
Registered User
 
Join Date: Sep 2002
Location: in the dark
Posts: 250
Default

Here is what I've narrowed it down to...

dArray = ["item0" , "item1" , "item2" , "item3" , "item4"];

function AddItems() {
for (i=0; i<5; i++) {
dropDown.setDataProvider(dArray);
}
dropDown.setChangeHandler("SelectItem");
}

function SelectItem(){
trace (dropDown.getSelectedItem().dArray[1]); // this should return the same value as the drop down selected
}

But I want it to be able to trace the value via the select item...
barrowman is offline   Reply With Quote
Old 10-28-2002, 03:49 PM   #4
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Howdy...

Haven't tried DataProvider myself... But I know that pom's code work... That's how I have used to populate the listbox before...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 10-28-2002, 03:56 PM   #5
barrowman
Registered User
 
Join Date: Sep 2002
Location: in the dark
Posts: 250
Default

thanks but I'm not entirely sure how to implement that code with the rest of it. ie how I could trace what happens when I select something...

Last edited by barrowman; 10-28-2002 at 03:59 PM.
barrowman is offline   Reply With Quote
Old 10-28-2002, 04:00 PM   #6
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

ActionScript Code:
dArray = ["item0" , "item1" , "item2" , "item3" , "item4"]; function AddItems() {   for (i=0; i<5; i++)   {     dropDown.addItem(dArray[i]);   }   dropDown.setChangeHandler("SelectItem"); } function SelectItem() {   trace (dropDown.getSelectedItem().label); }
Try this and see if it works...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 10-28-2002, 04:13 PM   #7
barrowman
Registered User
 
Join Date: Sep 2002
Location: in the dark
Posts: 250
Default

no doesn't seem to be loading the array into dropDown...??? :-(
barrowman is offline   Reply With Quote
Old 10-28-2002, 04:18 PM   #8
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Oh... I see what's missing...

Put

AddItems();

at the end of the code, and drag the listbox from the component library and name it 'dropDown'... I just tested it and it worked just fine...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 10-28-2002, 04:30 PM   #9
barrowman
Registered User
 
Join Date: Sep 2002
Location: in the dark
Posts: 250
Default

wow, thanks so much, I don't know what I'd do without you guys. I've sent you a PM
barrowman 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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
loading an object from an array NateVeronica ActionScript 2.0 1 03-30-2004 10:53 PM


All times are GMT. The time now is 11:56 PM.

///
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.