PDA

View Full Version : [AS3] Combobox in AS only


Abigail
06-11-2009, 02:05 PM
I'm trying to create a combobox but i can't find it...

I am using adobe flex builder on a action script project so no flash,
there is a namespace mx in the import but it has no controls under it.

Is it even possible??

Love abi

Tilpo
06-11-2009, 02:17 PM
package
{
import flash.display.Sprite
import flash.text.TextField;
import flash.events.Event;
import fl.controls.ComboBox;

public class ComboBoxExample extends Sprite
{
private var tf:TextField;

public function ComboBoxExample() {
setupComboBox();
setupTextField();
}
private function setupTextField():void {
tf = new TextField();
tf.x = 180;
tf.y = 15;
tf.autoSize = "left";
addChild(tf);
}
private function setupComboBox():void {
cb.setSize(150,22);
cb.addItem( { label: "MasterCard", data:1 } );
cb.addItem( { label: "Visa", data:2 } );
cb.addItem( { label: "American Express", data:3 } );
cb.addEventListener(Event.CHANGE, cardSelected);
}
private function cardSelected(e:Event):void {
tf.text = "You have selected: "
tf.appendText(cb.selectedItem.label);
}
}
}
Yes it is possible as described in the documentation.
Here's the link to the ComboBox class:
http://help.adobe.com/en_US/AS3LCR/Flash_10.0/fl/controls/ComboBox.html

Abigail
06-11-2009, 02:46 PM
Like i said it's not in flash, meaning i cant import fl.controls.ComboBox;
Or can i add fl to my project somehow?

DukeW
06-13-2009, 01:59 PM
I don't know if this will help or not, in flash you can avoid doing import by dragging the component from the Components toolbox in to the library.