问题
a simple
<s:TextInput x="163" y="117" prompt="hello"/>
Does not clear the prompt on focus, but clears the prompt when user first type in a letter.
This is the behaviour on flex mobile (behaviour is OK on swf )
Is that a bug and how to correct that ?
regards
回答1:
There May be an-other way to get rid of that, but my approach is that you may add a focusIn event and do some thing like :
<s:TextInput id="textInput" x="10" y="24" prompt="Enter SomeThing" focusIn="textinput1_focusInHandler(event)"/>
<fx:Script>
<![CDATA[
protected function textinput1_focusInHandler(event:FocusEvent):void
{
// TODO Auto-generated method stub
textInput.prompt = "";
}
]]>
</fx:Script>
may that should work for you...
回答2:
www.Flextras.com is on the right path. I had the same issues with TextInput on iPad where the field wouldn't display as a password when I needed it to.
All you need to do is manually apply the mobile TextInput skin.
<s:TextInput x="163" y="117" skinClass="spark.skins.mobile.TextInputSkin" prompt="hello"/>
You can see the answer provided to me in a separate question here.
回答3:
Actually the solution to hide prompt on focus is pretty easy, just add a style declaration like this
s|TextInput{
showPromptWhenFocused: false;
}
or in a class
.noPromptOnFocus{
showPromptWhenFocused: false;
}
If you use the second approach, your TextInput should look something like
<s:TextInput id="myTextInput" prompt="Write something here.." styleName="noPromptWhenFocused" />
This works fine no matter if you're using StageText or the TextInputSkin.
来源:https://stackoverflow.com/questions/13048099/flex-mobile-textinput-does-not-clear-prompt-on-focus