Am new to AS3/Flex & Flash, and need to develop a flash form for an embedded device where space is of the essence. The form will consist of a file picker and combobox, am starting with the combobox.
First thing I’ve noticed is that Flex’s mx/Combobox, with almost no other functionality, seems to compile to a really large .swf, like 200K. But at first when I tried to compile a pure Actionscript solution, “import fl.controls.ComboBox;” resulted in a compile error.
Found a workaround “How to Use Flash CS3’s V3 Components in Flex Builder” at http://www.moock.org/blog/archives/000253.html Using the technique described there I created a ComboBox.swc and placed this in Flex’s frameworks/libs directory (also did this with corelib.swc so that I will have access to JSON functionality, but first things first ;), and then could compile a ComboBoxExample.as file.
Problem is, though it compiles, it doesn’t display a combobox (whereas the commented out setupTextField() method results in a visible textField). Would appreciate pointers as to what I might be doing wrong. Thanks in advance. You might recognize sample code from more than one example incorporated in the following:
package
{
import fl.controls.ComboBox;
import fl.data.DataProvider;
import flash.display.Sprite
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
public class ComboBoxExample extends Sprite
{
private var aCb:ComboBox;
private var tf:TextField;
public function ComboBoxExample() {
setupComboBox();
//setupTextField();
}
private function setupTextField():void {
tf = new TextField();
tf.x = 15;
tf.y = 15;
tf.text = root.loaderInfo.loaderURL;
tf.autoSize = TextFieldAutoSize.LEFT;
addChild(tf);
}
private function setupComboBox():void {
var sfUniversities:Array = new Array(
{label:"University of California, Berkeley",
data:"http://www.berkeley.edu/"},
{label:"University of San Francisco",
data:"http://www.usfca.edu/"},
{label:"San Francisco State University",
data:"http://www.sfsu.edu/"},
{label:"California State University, East Bay",
data:"http://www.csuhayward.edu/"},
{label:"Stanford University", data:"http://www.stanford.edu/"},
{label:"University of Santa Clara", data:"http://www.scu.edu/"},
{label:"San Jose State University", data:"http://www.sjsu.edu/"}
);
aCb = new ComboBox();
aCb.dropdownWidth = 210;
aCb.width = 200;
aCb.move(20, 20);
aCb.prompt = "San Francisco Area Universities";
aCb.dataProvider = new DataProvider(sfUniversities);
//aCb.addEventListener(Event.CHANGE, changeHandler);
addChild(aCb);
aCb.open();
}
}
}