I just recently got a notice on my last post from Neil that when using FunFX a null pointer exception is thrown when any form item's label in a form is null as shown in the first listing. Neil pointed out that it was also happening when the label was set to an empty string.
<mx:form>
<mx:formitem label="Form Label">
<mx:label id="lLabel"/>
</mx:formitem>
<mx:formitem>
<mx:textinput id="tTextInput"/>
</mx:formitem>
</mx:form>
<mx:formitem label="Form Label">
<mx:label id="lLabel"/>
</mx:formitem>
<mx:formitem>
<mx:textinput id="tTextInput"/>
</mx:formitem>
</mx:form>
Neil pointed out that it was something to do with the FunFX and FormItemAutomationImpl interaction. And that one need to set all the form items labels to a non empty string. And that using whitespaces as label affects the layout. He suggested a nice workaround until a fix with the FormItemAutomationImpl is done. And that is to set the label width to 0.
<mx:form>
<mx:formitem label="Form Label">
<mx:label id="lLabel"/>
</mx:formitem>
<mx:formitem label="" labelWidth="0">
<mx:textinput id="tTextInput"/>
</mx:formitem>
</mx:form>
<mx:formitem label="Form Label">
<mx:label id="lLabel"/>
</mx:formitem>
<mx:formitem label="" labelWidth="0">
<mx:textinput id="tTextInput"/>
</mx:formitem>
</mx:form>
I have created the error for my own, and the reason for the error is as Neil said. The FunFX uses the automation framework from Adobe to create string id of the display objects that it interacts with. And this method in the FormItemAutomationImpl.as as displayed in the following listing. When the label of the formitem is null, there is no check that will prevent the method to call the length method of the label, which might be null.
private function getItemAutomationName(child:IAutomationObject):String
{
//Have cut down the method
result = (label.length != 0 ? label + ":" + child.automationName : child.automationName);
// More in the real method
}
{
//Have cut down the method
result = (label.length != 0 ? label + ":" + child.automationName : child.automationName);
// More in the real method
}
I have not yet been able to check wether it is possible to just add a null pointyer check in the method. But this will probably implie a change in th corresponding method that creates an object from the string id.
I hope this will help people in the same situation as Neil. And I will see if it can be fixed. But so long you will need to do as Neil suggested and set the labelWidth of the form item to zero.
Thanks alot Neil, for this valuable tip and solution!