why do you need the textFormat if youre using html? you can do all the
formating with html.

i got curious about that. your textformat will not take effect cause
youre setting the textfields htmlText, not its text. seems like format
and html are no good friends...different things

copy that in the first frame of a new flash, create
1 TextField: TF
1 button: BTN_html
1 button: BTN_form

code:


var form:TextFormat = new TextFormat();
form.bold = true;
form.font = "Arial";
form.color = 0xFF9900;
form.size = 15;


//



//


function setTextFormat() {
        var str:String = 
random_arr[Math.ceil(Math.random()*random_arr.length-1)];
        TF.autoSize = "left";
        TF.html = false;
        // BEFORE SET NEW TEXT
        TF.setNewTextFormat(form);
        // text, NOT htmlText
        TF.text = "TextFormat: "+str;
}
//
function setTextHTML() {
        var str:String = 
random_arr[Math.ceil(Math.random()*random_arr.length-1)];
        TF.html = true;
        TF.autoSize = true;

        var html_str = "<font face='arial' size='15' color='#FF9900'><b>HTML:
"+str+"</b></font>";
        // include a html link
        // --->  html_str += "<br><font face='arial' size='15'
color='#FF2299'><u>"+"<a href='http://www.adobe.com'>links are
cool</a>"+"</u></font>";
        TF.htmlText = html_str;
}

//

var random_arr:Array = ["Heyho Friend!", "Howz the things?", "Thanks
im fine, too :-) "];


this.BTN_form.onRelease = setTextFormat;
this.BTN_html.onRelease = setTextHTML;




cheers
olee

2007/6/12, Giles Roadnight <[EMAIL PROTECTED]>:
That's exactly what I have done:

            if(this.Model.pages[i].text.indexOf("<font") != 0)
            {
                this.Model.pages[i].text = '<font face="Arial">' +
this.Model.pages[i].text + '</font>';
            }

but the setNEwTextFormat funtion is not working the way it should do. That
would be a more elegant solution that the above.

On 6/12/07, o renken <[EMAIL PROTECTED]> wrote:
>
> no danny. setNewTextFormat means that all NEW text in the textfield
> will be formed. setTextFormat is only once and not for new text. and
> if you do some new text via AS setNexTextFormat will work fine..
>
> giles. if i understand you right youll get html-strings from your xml.
> some of them have a font-tag, some not.
>   so make a searchFunction which is used for each textString from xml.
> if the search will not find '<font face=" you have to rewrite your
> string
>
> eg
>
> searchFontTag=function(str){
>   if(str.indexOf("<font face=")==-1){
>       var s="<font face='arial'>"+str+"</font>"
>       return s
>   }
> return
> }
>
> but, other question....why is your xml inconsistent like it seems?!
>
> olee
>
>
>
>
> 2007/6/12, Danny Kodicek <[EMAIL PROTECTED]>:
> >
> > > Hi All
> > >
> > > I have a loop that creates pages, creates textfields then
> > > adds text. Some of this text has font tags and some doesn't.
> > > I want to use a default textFormat so that an embedded font
> > > is used when no <font is specified in the text:
> > >
> > >             currentPage.createTextField("my_txt", 1, 5, 5,
> > > currentPage._width - 10, currentPage._height - 10);
> > >             currentPage.my_txt.autoSize = false;
> > >             currentPage.my_txt.multiline = true;
> > >             currentPage.my_txt.wordWrap = true;
> > >             currentPage.my_txt.selectable = false;
> > >             currentPage.my_txt.embedFonts = true;
> > >             currentPage.my_txt.html = true;
> > >
> > >             var my_fmt:TextFormat = new TextFormat();
> > >             my_fmt.font = "Arial";
> > >             currentPage.my_txt.setNewTextFormat (my_fmt);
> > >
> > >             currentPage.my_txt.htmlText = this.Model.pages[i].text;
> > >
> > > This works fine for text that has Arial specified in a font
> > > tag but for all the other pages which are just text no text
> > > appears (when tracing I see that Times is used which is not embedded).
> > >
> > > Why isn't this working? The setNewTextformat should change
> > > the default textformat for the field from then on? I am still
> > > getting Times though.
> >
> > setNewTextFormat is, in my opinion, broken: it works for text entered by
> a
> > user but not for text entered through ActionScript. You need to run
> > setTextFormat manually after changing it.
> >
> > Danny
> >
> > _______________________________________________
> > Flashcoders@chattyfig.figleaf.com
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> >
>
>
> --
> http://www.renkster.de/#/about/
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com



--
http://www.renkster.de/#/about/
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to