stephank
08-26-2007, 06:50 PM
Dear Forum
I'm having some problems with my comboBox. My application contains two movieClips which are attached and removed several times across the application. Each of those 2 movieCLips contains a comboBox which is populated by XML data.
Everything works fine the first movieClip is attached for the first time. Any time after that when I attach one of the two movieClips containing a comboBox the selectedIndex property fails to work. Nothing appears in the first position (the text box on the top which is visible before the comboBox opens).
Is anyone aware of this bug and maybe a workaround? Or am I doing something else wrong?
Any insight or leads appreciated.
Thank you very much.
cheers
stephank
Here is the code I'm using:
class com.datagridformat.DG_P_Project_LabelsDropDown{
//screenclass
private var screenClass:Screen_P_ProjectEditor;
//grid
private var dd:ComboBox;
//bol
private var doOnce:Boolean = false;
public var gridLocked:Boolean = false;
public function DG_P_Project_LabelsDropDown(_screenClass:Screen_P_ ProjectEditor,_dd:ComboBox){
dd = _dd;
screenClass = _screenClass;
}
public function formatDropDown(){
dd.setStyle("fontSize", 9);
if(!doOnce){
doOnce=true;
dd.addEventListener("change", Delegate.create(this, itemSelect));
}
}
public function refreshData(){
clear();
var dp:Array = new Array();
var sI:Number = 0;
for(var i:Number = 0; i< P_ProjectData.getTotalDBLabels(); i++){
var item:Object = { data: P_ProjectData.getDBLabelID(i),
label: P_ProjectData.getDBLabelName(i)
}
if(P_ProjectData.getSelectedLabelID()==P_ProjectDa ta.getDBLabelID(i)){
sI = i;
}
dp.push(item);
}
dd.dataProvider = dp;
setSelectedIndex(sI);
}
public function clear(){
dd.dataProvider = new Array();
dd.removeAll();
}
private function setSelectedIndex(_index:Number){
dd.selectedIndex = _index;
}
//////////////////
// DropDown Events
//////////////////
private function itemSelect(evt) {
screenClass.onDropDownItemSelect(evt);
}
//Lock
//////
public function lock(){
gridLocked = true;
dd.enabled = false;
}
public function unlock(){
gridLocked = false;
dd.enabled = true;
}
}
I'm having some problems with my comboBox. My application contains two movieClips which are attached and removed several times across the application. Each of those 2 movieCLips contains a comboBox which is populated by XML data.
Everything works fine the first movieClip is attached for the first time. Any time after that when I attach one of the two movieClips containing a comboBox the selectedIndex property fails to work. Nothing appears in the first position (the text box on the top which is visible before the comboBox opens).
Is anyone aware of this bug and maybe a workaround? Or am I doing something else wrong?
Any insight or leads appreciated.
Thank you very much.
cheers
stephank
Here is the code I'm using:
class com.datagridformat.DG_P_Project_LabelsDropDown{
//screenclass
private var screenClass:Screen_P_ProjectEditor;
//grid
private var dd:ComboBox;
//bol
private var doOnce:Boolean = false;
public var gridLocked:Boolean = false;
public function DG_P_Project_LabelsDropDown(_screenClass:Screen_P_ ProjectEditor,_dd:ComboBox){
dd = _dd;
screenClass = _screenClass;
}
public function formatDropDown(){
dd.setStyle("fontSize", 9);
if(!doOnce){
doOnce=true;
dd.addEventListener("change", Delegate.create(this, itemSelect));
}
}
public function refreshData(){
clear();
var dp:Array = new Array();
var sI:Number = 0;
for(var i:Number = 0; i< P_ProjectData.getTotalDBLabels(); i++){
var item:Object = { data: P_ProjectData.getDBLabelID(i),
label: P_ProjectData.getDBLabelName(i)
}
if(P_ProjectData.getSelectedLabelID()==P_ProjectDa ta.getDBLabelID(i)){
sI = i;
}
dp.push(item);
}
dd.dataProvider = dp;
setSelectedIndex(sI);
}
public function clear(){
dd.dataProvider = new Array();
dd.removeAll();
}
private function setSelectedIndex(_index:Number){
dd.selectedIndex = _index;
}
//////////////////
// DropDown Events
//////////////////
private function itemSelect(evt) {
screenClass.onDropDownItemSelect(evt);
}
//Lock
//////
public function lock(){
gridLocked = true;
dd.enabled = false;
}
public function unlock(){
gridLocked = false;
dd.enabled = true;
}
}