Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-22-2005, 07:47 AM   #1
cjhsb
Registered User
 
Join Date: Jun 2005
Posts: 7
Angry ComboBox Hell

Hi all!

ComboBox needing to be populated from a .cfc returned DataSet. Using Actionscript as it needs to be repopulated from other DataSets dynamically based on another ComboBox choice.

Whole movie is one frame in length, 2 layers (other one only triggers the WCSs).

Haven't even got to the dynamic bit yet, still trying to populate the ComboBox at the start!

ComboBox name is title_Select

Starting DataSet is NEWS_WEEKDataSet

When I try:

title_Select.dataProvider = NEWS_WEEKDataSet;

I can *see* the darn Combobox is populating with the correct number of records (3), due to the depth of the dropdown box. But it's blank.

I'm trying to pupulate the .label with a field called .TITLE and the data with .ID (both defined correctly during the DC Wizard phase). I've tried literally hundreds of traces, listener events and even a couple of arrays to take the data and populate it correctly, all with no or just frustrating results.

Twelve hours of hairpulling and I've given up and decided to post here; I really hope someone can point me in the right direction or I may just break my computer! (and then regret it when I miss the deadline for my client on Friday).

Thanks to whichever saviour answers in advance!
cjhsb is offline   Reply With Quote
Old 06-22-2005, 10:12 AM   #2
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

Hello, a few things to try:

Give the combo box a frame to initialise before attempting to populate it (use a setInterval).

Make sure you are using the import statement in your fla or class: import mx.controls.ComboBox;

Try replacing the data with simple hardcoded values to make you can get these to show up (and see if there are any whitespace issues with your data)

Let me know how you get on.
Mort
__________________
............................
FLEX/FLASH BLOG
Previous Flash Tutorials

............................
Mortimer Jazz is offline   Reply With Quote
Old 06-22-2005, 12:31 PM   #3
cjhsb
Registered User
 
Join Date: Jun 2005
Posts: 7
Default

Hi Mort - thanks for responding and for your help!

Ok:

Quote:
Originally Posted by Mortimer Jazz
Give the combo box a frame to initialise before attempting to populate it (use a setInterval).
Stretched the frames out at first by 1 then by 10 seconds worth. Tried both running the Actionscript from frame 2 and then doing the below, sadly without success.

function initialiseChoices() {
title_Select.dataProvider = NEWS_WEEKDataSet;
}
var intervalID;
intervalID = setInterval( initialiseChoices, 5000 );

Quote:
Originally Posted by Mortimer Jazz
Make sure you are using the import statement in your fla or class: import mx.controls.ComboBox;
How do I do that (sorry I'm still only in my second week of Flash MX )?

Quote:
Originally Posted by Mortimer Jazz
Try replacing the data with simple hardcoded values to make you can get these to show up (and see if there are any whitespace issues with your data)
Tried that and I can via both the component inspector and a simple Actionscript. Also I threw the same Dataset into a listbox and it generated perfectly with no whitespaces in either of the colums I'm after (their required fields to boot on the backend anyhow just for double security). I've also actionscripted a product catalouge/cart/purchasing system with the same methods with no problem (such a pity I don't need Listboxes and Labels etc and I need this stupid ComboBox...) so I'm pretty confident the problem is in my (very newbie) Actionscript specific to a ComboBox component, rather than any of the other components or their scripts.

So I'm still stuck I'm afraid. I don't know if it makes a difference but one of the things I did not mention in the first post is that the Dataset holds more than just the two colums I need for the ComboBox...if that makes any difference?

Other than that, I'm still stumped.
cjhsb is offline   Reply With Quote
Old 06-22-2005, 01:41 PM   #4
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

Is your Combo under a mask by any chance, or is it in an external swf which is loaded into the main Movie?

Give your combo an instance name of myCombo, and chuck this code on the first frame - does it work?
ActionScript Code:
stop(); import mx.controls.ComboBox; var myInt:Number = setInterval(lazyInit, 300); var myCombo:ComboBox; var myArr:Array = ["some", "false", "data"]; function lazyInit() {     if(myInt != undefined) clearInterval(myInt);         myCombo.addItem({label:"Select ...", data:""})     var len:Number = myArr.length;     for(j=0; j<len;++j)     {         myCombo.addItem({label:myArr[j] , data:j});                     } }
__________________
............................
FLEX/FLASH BLOG
Previous Flash Tutorials

............................
Mortimer Jazz is offline   Reply With Quote
Old 06-22-2005, 10:52 PM   #5
cjhsb
Registered User
 
Join Date: Jun 2005
Posts: 7
Default

Sorry for the delay in response Mort - had to sleep!

Ok, no, its a sub-movie in the same swf. It's not masked either.

Plonked the code in, and it didn't run either. Moved it to frame 2 and no joy there as well, still a blank combobox with in my case 3 blank choices and in your case 1.

The list still populates fine, mocking me - although I realise you may know the answer now your code didn't work either in it, I'm still stumped!
cjhsb is offline   Reply With Quote
Old 06-23-2005, 12:09 AM   #6
madgett
is my last name...
 
Join Date: May 2004
Posts: 1,051
Default

Make sure the dataset is in the form:
ActionScript Code:
// dataprovider object cb.dataProvider = new Array({label:"First", data:1}, {label:"Second", data:2}, {label:"Third", data:3});
To test, put a combobox on the stage with instance name cb to see it work. The dataprovider is an array of objects.
__________________
Anything is possible with Flash, it's just a matter of inventing the possibilities
Certified Swfwizard
madgett is offline   Reply With Quote
Old 06-23-2005, 08:39 AM   #7
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

Okay, you just mentioned that your combo is in a sub movie - sorry I assumed it was on the main stage. The likelyhood is that the code fails because you didn't alter the pathing accordingly - make sure that the 2 references to the combo box in the "lazyInit" method, take the form mySubMovieInstanceName.MyComboInstanceName - whatever they may be.

I was hoping for it to give me some clues, yes
Obviously at the moment you are not sure whether your errors are caused by the ComboBox component itself (a reasonable assumption, because it is pretty buggy), or other factors. The reason I gave you the code is so we can quickly narrow down the cause - if you can get my code to work in your movie then we can rule out a whole host of common problems with the combobox and move (such as incorrect publish settings, timing/initialisation problems with the combobox, etc etc).

Try getting the combo working with my hardcoded array. One you have it working, if you still have issues then you know it must be a problem with the data itself (see madgett's post )
__________________
............................
FLEX/FLASH BLOG
Previous Flash Tutorials

............................
Mortimer Jazz is offline   Reply With Quote
Old 06-24-2005, 11:43 AM   #8
cjhsb
Registered User
 
Join Date: Jun 2005
Posts: 7
Default

Apologies to you both for the delay - sitting checking my email for a response and nothing arrived, eventually decided to come bump the thread and it looks like my notification was off :-(

Ok, so, Madgett's code works fine when I rename the combobox to cb; if I could be 100% sure I could write unbuggy code to take the columns out of the dataset into an array I'd actually just do that and feed the array into the combobox then. Thinking further, if anyone happens to have an example, I'll modify it and try it!

Mort, your code still doesn't work, and I cant see why not.

Just FYI im putting the AS code in the submovie, on the same layer as the box itself.

And thanks for the continuing help guys

Last edited by cjhsb; 06-24-2005 at 11:49 AM.
cjhsb is offline   Reply With Quote
Old 06-24-2005, 01:04 PM   #9
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

Other than it possibly being a pathing/naming issue I don't understand why.
Anyway, is what you wanted working now, or are you still having problems?

If madgett's solution has fixed your problem then there's no real need to find out why the code I gave is not working for you, else, if you're still having problems then check your publish settings (Flash Player 7, Actionscript 2.0)

Just out of interest, if you can spare a second, get the Fla containing Madgett's code (the one that works), and temporarily replace his code with this (below) -I have changed the instance name to cb, and the pathing will be correct. If this doesn't work then I'll really be scratching my head.
ActionScript Code:
stop(); import mx.controls.ComboBox; var myInt:Number = setInterval(lazyInit, 300); var cb:ComboBox; var myArr:Array = ["some", "false", "data"]; function lazyInit() {      if(myInt != undefined) clearInterval(myInt);            cb.addItem({label:"Select ...", data:""})      var len:Number = myArr.length;      for(j=0; j<len;++j)      {           cb.addItem({label:myArr[j] , data:j});                } }
__________________
............................
FLEX/FLASH BLOG
Previous Flash Tutorials

............................
Mortimer Jazz is offline   Reply With Quote
Old 06-24-2005, 03:29 PM   #10
cjhsb
Registered User
 
Join Date: Jun 2005
Posts: 7
Default

Ok, so your new snippet worked, so I guess it was just my bad codeing..idiot (slaps head against wall).

But no - all I have so far is that if I use AS to hardcode the dropdown box, it works...which I knew a couple of posts back....

I'm still not any closer to populating the dropdown box from the dataset, although I'm much closer now to going bald!

Given what we know now (I'm useless, dropdowns in flash suck, etc etc), any idea how I can actually populate the dropdown with the right information? (Sorry, I realise this may come across as sarcasticly bad - it's not, I'm just infuriated at a dev suite that cant even apparently make a dropdown box work simply, and I really am most appreciative of your help!)
cjhsb 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


All times are GMT. The time now is 04:02 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.