Ce bug est difficile à décrire, mais facilement reproduit avec le code du bas. Il suffit de copier, coller et compiler + exécuter dans Flex 3 et vous verrez le problème. Quelqu'un sait d'un travail autour?Flex TextArea htmlTexte avec bug de feuille de style
Editer: Voici un lien vers une démo en cours d'exécution: http://shiinaringo.se/hosted/flex/textarea-bug/HtmlTextBug.html Dans la démo, la couleur par défaut de TextArea est rouge.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" applicationComplete="applicationComplete(event);">
<mx:Script>
<![CDATA[
import mx.events.FlexEvent;
private function applicationComplete(event:Event):void {
var styles:String = "a:hover { color: #6666ff; text-decoration: underline; } a { color: #0000ff; }";
var ss:StyleSheet = new StyleSheet();
ss.parseCSS(styles);
textGreenStylesheet.styleSheet = ss;
}
private function enteredText(event:FlexEvent):void {
textDefault.htmlText = event.currentTarget.text;
textGreen.htmlText = event.currentTarget.text;
textGreenStylesheet.htmlText = event.currentTarget.text;
}
]]>
</mx:Script>
<mx:VBox height="100%" width="400" horizontalAlign="center">
<mx:Panel width="250" height="200" layout="absolute" title="TextArea A. Default colored text">
<mx:TextArea id="textDefault" condenseWhite="true" width="100%" height="100%" x="0" y="0">
<mx:htmlText>
<![CDATA[
This text has the default text color of the TextArea control.
]]>
</mx:htmlText>
</mx:TextArea>
</mx:Panel>
<mx:Panel width="250" height="200" layout="absolute" title="TextArea B. Green text">
<mx:TextArea id="textGreen" condenseWhite="true" width="100%" height="100%" x="0" y="0" color="green">
<mx:htmlText>
<![CDATA[
This text has the text color set to green
]]>
</mx:htmlText>
</mx:TextArea>
</mx:Panel>
<mx:Panel width="250" height="200" layout="absolute" title="TextArea C. Green text + stylesheet">
<mx:TextArea id="textGreenStylesheet" condenseWhite="true" width="100%" height="100%" x="0" y="0" color="green">
<mx:htmlText>
<![CDATA[
This text has the text color set to green, and also uses a stylesheet to make <a href="http://example.com">links</a> blue and underlined when hovered.
]]>
</mx:htmlText>
</mx:TextArea>
</mx:Panel>
<mx:TextInput x="69" y="282" width="207" enter="enteredText(event);"/>
</mx:VBox>
<mx:VBox height="100%" width="200">
<mx:Text width="166" text="We have three TextArea controls. The top uses default text color, the middle one uses defined green text color, the bottom one also uses green color, but also uses a stylesheet to define some custom coloring of A tags." height="232"/>
<mx:Text width="166" text="To reproduce the problem, first try to just enter new text in the input field in the bottom, and press enter. The text in the three boxes will update. Notice that the colors and other styles don't change in any of the three boxes. But when you click once inside textarea C, then enter new text in the input field and hit enter, you'll notice that the color and font is lost in textarea C. Bug?" height="232"/>
</mx:VBox>
</mx:Application>
Merci. Vos idées semblent plus ou moins correctes. Dans l'ensemble, les feuilles de style ne se mélangent pas bien avec les autres styles. Ainsi, soit vous n'utilisez pas du tout les feuilles de style, soit vous les utilisez et rien d'autre ... en quelque sorte. J'ai mis en œuvre votre suggestion de tout emballer dans un span classifié, définissant le style de cette classe dans la feuille de style. Cela fonctionne, pour moi, jusqu'à présent. Lors du débogage, j'ai également remarqué que si je définissais TextArea "enabled" sur "false", je n'obtiens pas le problème de perte de style lorsque je clique. Cela pourrait être une solution, mais dans mon cas, j'ai besoin des liens à l'intérieur du TextArea. – Jonny