PDA

View Full Version : ComboBox category spacing


robb58
09-04-2006, 12:18 AM
Hi, this is probably a really basic question but...how do you increase the spacing between the dropdown categories in the ComboBox Component in Flash 8. I've tried the simple option of just free transforming the size of the combobox but that doesn't seem to affect the spacing. Ideally, I want the choices to be more or less double the distance apart compared to the standard setting. I know I'm probably missing something really basic here and it seems such a trivial request... but I going crazy trying to work it out!!:confused:

Mazoonist
09-05-2006, 01:42 AM
Hey, Robb58,

No problem. Seems like a reasonable question to me. I wasn't really sure myself, so I opened a new flash document, opened the actions panel, and started reading the properties of the comboBox from the helpful actionscript reference at the left. None of the properties of comboBox seemed to be the one, but I did notice that the "dropdown" property of the comboBox is a reference to the List component contained within the comboBox. Remembering that the comboBox contains an instance of the List component (and now having a way to reference it), I switched over to the properties of the list component to look for the answer there. To sum it all up, here's what did the trick:

myCombo.dropdown.rowHeight = 44;

The value 44 wasn't chosen arbitrarily, although you can make it whatever you want. If you execute the following line BEFORE you change the value:

trace(myCombo.dropdown.rowHeight);

you'll find that the default rowHeight is 22. So setting it to 44 makes it twice the size. Actually, without knowing what it was in the first place, you could also do this:

myCombo.dropdown.rowHeight *= 2;

robb58
09-05-2006, 10:26 PM
I see the theory but how do you wrap it up in the correct actionscript to get it going?.. :confused: (sorry, being totally thick here!!)

Mazoonist
09-06-2006, 02:01 AM
Okay, start a new Flash document. Drag a comboBox component from the components panel. Give it an instance name in the properties panel. Call it "myCombo" just for this example's sake. The instance name is what you can use in your actionscript code to address the comboBox.

Make a new layer on the timeline. Call it "actions." This is just to keep the code separate from the content.

You may have noticed that you can add things to a comboBox using a method called addItem(). However, I prefer another way, and it seems much easier to me: you just create an array, and then set it as the dataProvider for the comboBox. Then, any changes you make to the array can be updated to the comboBox.

Click on frame 1 of the newly created actions layer. Press F9 and enter the following code in the actions panel:

var myArray:Array = new Array("Steve", "Bill", "George", "Carol", "Patty");
myCombo.dataProvider = myArray;
myCombo.dropdown.rowHeight = 44;
Pretty simple when you get used to it. The first line just creates an array and starts it off with some names I just made up. The second line sets the "dataProvider" property of the comboBox to be the array I just made. These two lines by themselves will make the comboBox have the values from the array. The third line sets the rowHeight to twice the default, which gives you that spacing you were asking about.

There's more that you can do with the comboBox, of course. I really recommend getting into the various methods and properties and learning what they are and what they do. It's not that hard, but you gotta dig.

robb58
09-13-2006, 11:11 PM
Hi Mazoonist, sorry about the delay in getting back to you, been away from the computer for a while :D . i've just tried your suggestion and it works perfectly. Thank you for the advice :)