May
19

A TextFormat bug?

5 comments Posted by: Nahuel I wonder if this is a bug.
This is the scenario: you have a TextField to which you have applied a TextFormat. Then you try to add some text to the TextField. There are two possible outcomes of doing that: if it is an HTML TextField, the formatting is preserved after inserting the additional text, as you would expect. But if it is a non-HTML TextField, all formatting is lost when the text is added.
An example of this:
After pressing "Add Text", the String "is a long" loses its formatting in the non-HTML TextField
This is the code:
t = "this is a long text bla bla bla bla bla";

tfield1.html = true;
tfield1.border = true;
tfield1.htmlText = t;

tfield2.html = false;
tfield2.border = true;
tfield2.text = t;

var tformat = new TextFormat();
tformat.bold = true;
tformat.italic = true;

tfield1.setTextFormat( 4 ,15, tformat );
tfield2.setTextFormat( 4 ,15, tformat );


but.onRelease = function()
{ tfield1.htmlText += " more text "; tfield2.htmlText += " more text "; }
Category: Flash |

5 Comments so far

Write yours
adrian
1. adrian wrote on May 19, 2004 at 3:26 PM
Have a look at setNewTextFormat() as opposed to setTextFormat()
Zarate
2. Zarate wrote on November 18, 2004 at 6:41 AM
Hello,

I'm also having problems with setNewTextFormat and html textfields.

Don't you?
Joseph Balderson
HTML textfields can be used with setNewTextFormat, but the formatting applies to the entire field (or an index selection if you are using the second and third parameters of the method) -- all text-related formatting with HTML tags are ignored. In order to get HTML tag formatting to work within an HTML textfield, you need to use a TextField.StyleSheet object, either defined in actionscript or as an external CSS stylesheet.
Gaurav
Hi

Joseph is very rite. for this purpose you need to use TextField.StyleSheet.


you can find the reference to this class here http://visiblearea.com/visdoc/examples/ActionScript2dot0/mmfl8/TextField.html#styleSheet
Lesley
5. Lesley wrote on September 28, 2006 at 1:42 PM
I have an input box that allows the user to search on what they put in the box. I would like for the box to always enter data in uppercase no matter if the user has caps on or not. Is there a way to do this?

Here is my code for the input box.
<!--- Matl Description Input Box --->
            <cfformgroup type="vbox" style="verticalGap:-5">
               <cfformitem type="text" style="fontWeight:bold;">Matl Description:</cfformitem>
               <cfinput type="text" name="Material_Description"
               value="FORM.Material_Description"
                  onKeyDown="if(Key.isDown(Key.ENTER)) {submitForm()}">

            </cfformgroup>

Leave your comment

Comment etiquette: As a gesture to those subscribed to this post, please keep your comments relevant to the post.

Your email address will never be displayed.
Email is gravatar enabled.Gravatar are the pictures you see next to the comments. If you like to have one, visit gravatar



Allowed tags:

<code>
All other tags will be shown as such, when in doubt, use the preview.




Preview:

Refresh Preview
1. You wrote on