12-29-2010 12:46 PM
Hi guys,
I've just started making an app for the PlayBook so pardon my "n00b-ishness".
I have a simple question about drop down menus. My code is below. When I view this on the simulator I get a drop down with just the word "Background" and when I click on the arrow, I get one blank line. Nothing inside it. I've searched the forums and can't find anything specific to this one. Please let m e know.
var backgroundOptions:DropDown = new DropDown();
backgroundOptions.rowCount = 8;
backgroundOptions.rowHeight = 30;
backgroundOptions.prompt = "Background";
backgroundOptions.x = 20;
backgroundOptions.y = 300;
var dp:DataProvider = new DataProvider();
var listOfBackgrounds:Array = new Array([{label: 'Black'},
{label: 'Green'},
{label: 'Blue'},
{label: 'White'},
{label: 'Slow Lines'},
{label: 'Abstract'},
{label: 'Lines'},
{label: 'Aurora'}]);
dp.setItems(listOfBackgrounds);
backgroundOptions.dataProvider = dp;
addChild(backgroundOptions);
Any help would be great!
Thanks!
Solved! Go to Solution.
12-29-2010 12:58 PM
Try:
var backgroundOptions:DropDown = new DropDown();
backgroundOptions.rowCount = 8;
backgroundOptions.rowHeight = 30;
backgroundOptions.prompt = "Background";
backgroundOptions.x = 20;
backgroundOptions.y = 300;
var listOfBackgrounds:Array = new Array([{label: 'Black'},
{label: 'Green'},
{label: 'Blue'},
{label: 'White'},
{label: 'Slow Lines'},
{label: 'Abstract'},
{label: 'Lines'},
{label: 'Aurora'}]);
backgroundOptions.dataProvider = new DataProvider( listOfBackgrounds );
addChild( backgroundOptions );
12-29-2010 01:09 PM
Hey jtegen,
I tried the solution you posted, but unfortunately I still get the same blank line as the first.
Sorry.
12-29-2010 01:18 PM - edited 12-29-2010 01:19 PM
I see it now. You're creating an array of arrays. Try:
var listOfBackgrounds:Array = new Array({label: 'Black'},
{label: 'Green'},
{label: 'Blue'},
{label: 'White'},
{label: 'Slow Lines'},
{label: 'Abstract'},
{label: 'Lines'},
{label: 'Aurora'});
No square brackets in the Array constructor. Just an array of objects.
12-29-2010 01:20 PM
Perfect kind sir!
It worked!
Thanks so much! I've been racking my brain since 8am this morning and its 1.30pm now.
Time for a break maybe? ![]()
12-29-2010 01:27 PM
Just think, you'll never make that mistake in your lifetime again (or for at least a week).
Good luck.
04-08-2011 04:51 AM
hello ..
i m stuck in a probm please help me
i m making a drop down menu ...in which there are some text now i want to if that particular text selected than it should perform the task.
the code through which i m adding the dropdown menu is...
04-08-2011 08:10 AM
@gaura2k11: This is the Adobe AIR/AS3 forum. The code you posted does not appear to be AS3. If you are in the correct forum, please post the actual code snippet you are having trouble with.
04-08-2011 12:23 PM - edited 04-08-2011 12:27 PM
here is the full code of that page ...that drop down menu item is adding on the screen now i need to call the function of that each menu please help me on that....
thankyou
04-08-2011 12:26 PM
@gaurav2k11: This is an Action Script forum (Adobe AIR), not a Java forum. You may want to post the code there for help.