Reputation: 71
I am using a TextArea in my application, and wish to change the font color of textArea at runtime based on certain conditions? I am using the following code in a function
resultText.setStyle("color", 0x842D22). However, this does not work, and gives me an exception at runtime Cannot Access property of null object reference.
setStyle does not seem to work with textArea . please advise.
Upvotes: 0
Views: 2082
Reputation: 392
See if this example helps you:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ public var flag:Boolean = true; public function clickHandler():void{ if(flag) {resultText.setStyle("color","red"); } else { resultText.setStyle("color","blue"); } flag = !flag; } ]]> </mx:Script><mx:TextArea x="59" y="104" id="resultText"/> <mx:Button id="colorChangeButton" label="Change Color" click="clickHandler()" x="83" y="180" /></mx:Application>
Try sharing code in case this doesnt help..
Upvotes: 2