The TextFormat needs to be in a MovieClip like a Canvas component.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
verticalGap="0"
backgroundColor="#7D8FA8"
xmlns:mx= "http://www.macromedia.com/2003/mxml" xmlns="*"
pageTitle="Dingen"
width="690" height="484">
<mx:Script>
<![CDATA[
public function start()
{
var x_num = my_mc.mouseX;
var y_num = my_mc.mouseY;
var depth_num = my_mc.getNextHighestDepth();
var name_str = "myOriginalInstanceName" +
depth_num;
my_mc.createTextField(name_str, depth_num,
x_num, y_num, 10, 20);
var txt = my_mc[name_str];
txt.autoSize = "left";
txt.text = "great1!!";
var my_fmt:TextFormat = new TextFormat();
my_fmt.color = 0xFF0000;
my_fmt.underline = true;
txt.setTextFormat(0,2,my_fmt);
};
]]>
</mx:Script>
<mx:Canvas width="300" height="200" id="my_mc"
mouseDown="start()" backgroundColor="#3333FF"></mx:Canvas>
</mx:Application>
<mx:Application
verticalGap="0"
backgroundColor="#7D8FA8"
xmlns:mx= "http://www.macromedia.com/2003/mxml" xmlns="*"
pageTitle="Dingen"
width="690" height="484">
<mx:Script>
<![CDATA[
public function start()
{
var x_num = my_mc.mouseX;
var y_num = my_mc.mouseY;
var depth_num = my_mc.getNextHighestDepth();
var name_str = "myOriginalInstanceName" +
depth_num;
my_mc.createTextField(name_str, depth_num,
x_num, y_num, 10, 20);
var txt = my_mc[name_str];
txt.autoSize = "left";
txt.text = "great1!!";
var my_fmt:TextFormat = new TextFormat();
my_fmt.color = 0xFF0000;
my_fmt.underline = true;
txt.setTextFormat(0,2,my_fmt);
};
]]>
</mx:Script>
<mx:Canvas width="300" height="200" id="my_mc"
mouseDown="start()" backgroundColor="#3333FF"></mx:Canvas>
</mx:Application>
On 7/15/05, Bruno Martins <[EMAIL PROTECTED]> wrote:
I'd like build a Text Editor but the TextArea don't accept setTextFormat method.I try to create a TextField end bind the htmlText property to TextArea.htmlText and apply the TextFormat in the TextField component.But this simple example returns: undefinedvar my_txt:TextField = new TextField();
my_txt.text = "teste";
alert("" + my_txt.text);Thanks,Bruno Martins.Sorry about my english.This example works in flash:var my_fmt:TextFormat = new TextFormat();
my_fmt.bold = true;
my_fmt.font = "Arial";
my_fmt.color = 0xFF9900;var my_fmt2:TextFormat = new TextFormat();
my_fmt2.bold = false;
my_fmt2.font = "Arial";
my_fmt2.color = 0xFF0000;this.createTextField("my_txt", 10999, 0, 0, 400, 300);
my_txt.wordWrap = true;
my_txt.multiline = true;
my_txt.border = true;
my_txt.type = "input";
my_txt.setNewTextFormat(my_fmt);
my_txt.text = "Oranges are a good source of vitamin C";
my_txt.html = true;
trace("" + my_txt.htmlText)my_txt.setTextFormat(0,7,my_fmt2);
trace("" + my_txt.htmlText)
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.