Hi ,
See if the following code snippet solves your problem. Let me know if you face any issues.
<?xml version="1.0"?>
<!-- styles/runtime/BasicApp.mxml -->
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
use namespace mx_internal;
// the namespace is used as the getTextField() etc method is not available in the default namespace...
function makeBold(){
// makes the selected text from textField bold
var tf:TextFormat = new TextFormat();
var beginIndex:int = myText.getTextField().selectionBeginIndex;
var endIndex:int = myText.getTextField().selectionEndIndex;
tf.bold = true
myText.getTextField().setTextFormat(tf,beginIndex,endIndex);
}
function makeBoldAndBlue(){
// makes the selected text from textField bold and red
var tf:TextFormat = new TextFormat();
var beginIndex:int = myText.getTextField().selectionBeginIndex;
var endIndex:int = myText.getTextField().selectionEndIndex;
tf.bold = true
tf.color = "0xe50f0f"
myText.getTextField().setTextFormat(tf,beginIndex,endIndex);
}
function makeleftAlign(){
// Aligns the text of whole text Area
var tf:TextFormat = new TextFormat();
var beginIndex = myText.getTextField().getFirstCharInParagraph(beginIndex) - 1;
beginIndex = Math.max(0, beginIndex);
var endIndex =
myText.getTextField().getFirstCharInParagraph(endIndex) +
myText.getTextField().getParagraphLength(endIndex) - 1;
tf.align= "left";
myText.getTextField().setTextFormat(tf);
}
]]>
</mx:Script>
<mx:Button id="b1" label="make me Bold " click="makeBold()"/>
<mx:Button id="b2" label="make me Bold and red" click="makeBoldAndBlue()"/>
<mx:Button id="b3" label="make me leftAlign" click="makeleftAlign()"/>
<mx:Label text="Type here the text and/or select the text here and click respective button" />
<mx:TextArea textAlign="center" id="myText" height="254" text="Virus hunters at Symantec have stumbled upon a malicious server using an attack framework that intelligently chooses exploits based on the client's browser. Here's a blow-by-blow of the attack. "/>
</mx:Application>
Regards!
On 7/15/07, kanu <kanukukreja@...> wrote:
i have a text field
in which from character 1-9 its bold italic and with blue color
character 12-14 some different properties
but now if i'm selecting align center then it automatically changes
the color of whole text according to selected color.
in getTextFormat () method
its written:
Any property that is mixed, meaning that it has different values at
different points in the text, has a value of null.
is there is any method to solve this problem.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to flex_india@...
To unsubscribe from this group, send email to flex_india-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---