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 03-08-2003, 08:45 PM   #1
cfx
Registered User
 
Join Date: Mar 2003
Location: NJ
Posts: 8
Send a message via AIM to cfx
Unhappy Listbox selecting/displaying/sending and loading multiples

I am having trouble selecting multiple in the FListbox. Here's what's going on.
I have a listbox of dynamically generated clothing sizes from a coldfusion template. So far so good.
I want to be able to select multiple sizes and put them in an array to send to back to coldfusion.
Here is my change handler:

lboSizes.setChangeHandler("setSizes");
function setSizes(){
sizeArray = new Array();
sizeArray.sizes = lboSizes.getSelectedItems();
selectedSizes = sizeArray.sizes;
}

This pretty much comes down to I don't know how to use the listbox to get multple values.

Can anyone help?
cfx is offline   Reply With Quote
Old 03-08-2003, 09:04 PM   #2
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Howdy and Welcome aboard...

Create an instance of list box on the stage with the instance name of 'lboSizes', and put the following code to the frame...
ActionScript Code:
lboData = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13); lboSizes.setDataProvider(lboData); lboSizes.setSelectMultiple(true); lboSizes.setChangeHandler("setSizes"); function setSizes(component) {     sizeArray = component.getSelectedItems();     sizeArray.sortOn("label");     for (i = 0 ; i < sizeArray.length ; i++)         trace("Item " + (i + 1) + " =  " + sizeArray[i].label); }
I think this can get you started...

Check out the methods in the specific component in the Flash manual for more information...
__________________
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 03-08-2003, 09:06 PM   #3
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Arg... Dumb, dumb, dumb... I am...
Attached Files
File Type: zip lbosizes.zip (47.0 KB, 297 views)
__________________
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 03-09-2003, 08:36 PM   #4
cfx
Registered User
 
Join Date: Mar 2003
Location: NJ
Posts: 8
Send a message via AIM to cfx
Default

First of all, thanks CyanBlue for helping me out so fast. Someone once told me there is no such thing as too much information. Please forgive the length of this. Here's what's going on.

Where I am at:
I can get the selected sizes to appear in the output window fine but I would like to be able to display them in a dynamic text box and store them in a Load Vars object as well.

What I have tried:
When I specify the array (outside of the loop) Object.Object is displayed in the dynamic textbox. Objext.Object will react to the amount of sizes selected in the listBox. When I put the array in the loop and specify an index and label, the textBox will only display the last clicked selected item. I have tried several array methods including join(), and toString() to no avail.

Code:
//Separate the loadVars object
lboLabels = sizeObj.size.split(",");
lboData = sizeObj.sizeID.split(",");

//populate the listbox

for (i=0; i < lboLabels.length; i++){
lboSizes.addItem(lboLabels[i], lboData[i]);
}
lboSizes.setSelectMultiple(true);

//set a change handlesr for the listbox
lboSizes.setChangeHandler("setSizes");
function setSizes(component){

//create array to hold selected items
sizeArray = new Array();

//populate array with selected items
sizeArray = component.getSelectedItems();


for (i=0; i < sizeArray.length;i++){
sizeArray.sortOn(data);
trace("item ="+ sizeArray[i].label.toString());
item = sizeArray[i].label.toString();
}
}

stop();


Extraneous Info:
A little more background on this application. When a user selects the sizes they will be put into a Load Vars object called newItemObj.sizes. There are other movies in this app where a user specifies a model or pricing. All the variables are kept in the Load Vars object until the user is satisfied and clicks a finish button which sends the Load Vars to a CF template and inserts them into my database.

I tried to include a zipped .fla file but it was too big. Sorry about that.
cfx is offline   Reply With Quote
Old 03-09-2003, 10:28 PM   #5
cfx
Registered User
 
Join Date: Mar 2003
Location: NJ
Posts: 8
Send a message via AIM to cfx
Default

Easier to read prehaps.

ActionScript Code:
//Separate the loadVars object lboLabels = sizeObj.size.split(","); lboData = sizeObj.sizeID.split(","); //populate the listbox for (i=0; i < lboLabels.length; i++){ lboSizes.addItem(lboLabels[i], lboData[i]); } lboSizes.setSelectMultiple(true); //set a change handlesr for the listbox lboSizes.setChangeHandler("setSizes"); function setSizes(component){ //create array to hold selected items sizeArray = new Array(); //populate array with selected items sizeArray = component.getSelectedItems(); for (i=0; i < sizeArray.length;i++){ sizeArray.sortOn(data); trace("item ="+ sizeArray[i].label.toString()); item = sizeArray[i].label.toString(); } } stop();
cfx is offline   Reply With Quote
Old 03-10-2003, 01:29 AM   #6
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Well... I just happened to be browsing the forum at the time you were posting the question... Oh... I think this question belongs to 'Flash MX' forum rather than 'Components'...

sizeArray = new Array();

You have this one specified within your function... What it does is to renew the array to blank when the function gets executed... That's why you are getting the last item... I think just commenting this line out will solve your problem... Maybe there are somethings I might have missed from your post since I have bad headache... See if that one solves the problem first...

Try that and let me know...

If the file is too big to put into the forum, you can upload the file into your server, or free sites such as Geocities, and give us the url for it...
__________________
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
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 10:23 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.