A few months ago, after years and years coding in AS2, I decided to start writing code in AS3. Overall I think AS3 is great, but I have found some component behaviors I think are nothing short of bizarre and was hoping you guys could shine some light on it.
(I found those behaviors while coding in a .as file with the components manually created, sitting on the stage. I am not sure if the same problem would occur if coding directly in the timeline.)
Bizarre behavior 1:
Populating a comboBox component with data before applying a style to its textField property seems to prevent the style from being applied.
In other words:
1 - myComboBox.textField.setStyle(‘textFormat’, someTextFormat);
2 - Code to load myComboBox with data
In the case above, no style gets applied to the textField of myComboBox.
The code below, which is exactly the same code but in reverse order, works though!
1 - Code to load myComboBox with data
2 - myComboBox.textField.setStyle(‘textFormat’, someTextFormat);
In this case, the style does get applied.
This bizarre behavior seems unique to comboBoxes.
Bizarre behavior 2:
The radioButton component seems to need some time before it can be accessed. If I try to access the label property, for example, right off the bat (in the constructor or in a function called by the constructor), nothing happens. If I set a Timer to call that same function, however, the instance of the component becomes reachable!
public function Constructor() {
labelRadiosButtons();
}
private function labelRadiosButtons():void {
radio1_RB.label = ‘Some Label’;
radio2_RB.label = ‘Some Other Label’;
}
The code above doesn’t work, the labels are not changed. However, the code below does work:
public function Constructor() {
var rbTimer:Timer = new Timer(50, 1);
rbTimer.addEventListener(TimerEvent.TIMER, labelRadiosButtons);
rbTimer.start();
}
private function labelRadiosButtons():void {
radio1_RB.label = ‘Some Label’;
radio2_RB.label = ‘Some Other Label’;
}
Does anybody have any idea what’s going on? Any help is much appreciated.