If you want to view this problem you'll need the PromptingTextInput
component available on the wonderful FlexLib site:
http://code.google.com/p/flexlib/wiki/ComponentList
Aside from this bug, this is a useful component for those that like
using prompts in their text input fields.
PromptingTextInput:
I seem to have encountered a bug in this extension of the TextInput
Component. I have created a simple test to show the problem. At the
heart of it, for some reason the binding in the PromptingTextInput
does not work if the bound variable becomes undefined, whereas it
works as expected in the Base Class TextInput. Try the sample code
below and you will see the problem.
1) Click Enter Test to see that both components bind correctly.
2) Click Run Test and you will see that the TextInput component
updates correctly to an empty string if the bound var becomes
undefined whereas the PromptingTextInput keeps the previous value.
I haven't found the cause of this yet, but I am hoping that some of
you will be able to spot it quicker than I. I am fairly new to Flex.
I love this component and had started to develop my own version
(based on one I developed in Flash for AS2) until I saw this. Let me
know if there is anything I can do to help fix this bug as I use this
class throughout my current app.
Thanks, Kevin
<mx:Script>
<![CDATA[
[Bindable]
public var text1:String;
[Bindable]
public var text2:String;
public function enterText():void{
text1 = "Hello";
text2 = "There";
}
public function runTest():void{
text1 = "Adios";
text2 = undefined;
}
]]>
</mx:Script>
<mx:VBox x="100" y="100" >
<mx:Label text="Prompting Text Input" />
<controls:PromptingTextInput id="test1" text="{text1}" width="100"
prompt="Enter Text" />
<controls:PromptingTextInput id="test2" text="{text2}" width="100"
prompt="Enter Text" />
<mx:Label text="Text Input" />
<mx:TextInput id="test3" text="{text1}" width="100" />
<mx:TextInput id="test4" text="{text2}" width="100" />
<mx:Button id="testbutton1" label="Enter Text" click="enterText();" />
<mx:Button id="testbutton2" label="Run Test" click="runTest();" />
</mx:VBox>