Jason, try this... it worked for me.
target_mc.tf_txt.setTextFormat(my_fmt); applies to the text in the textField before you apply setTextFormat i.e. Hello world" and target_mc.tf_txt.setNewTextFormat(my_fmt); applies to all text after the setTextFormat call i.e. "hi" J class SimpleTextField{ public static function create(target_mc:MovieClip):TextField{ var my_fmt:TextFormat = new TextFormat(); my_fmt.font = "Swis"; my_fmt.color = 0x000000; my_fmt.size = 16; target_mc.createTextField("tf_txt",0,20,20,200,20); target_mc.tf = target_mc.tf_txt target_mc.tf_txt.embedFonts = true; target_mc.tf_txt.text="Hello world"; target_mc.tf_txt.setTextFormat(my_fmt); target_mc.tf_txt.setNewTextFormat(my_fmt); return target_mc.tf_txt; } } On 3/10/06, Merrill, Jason <[EMAIL PROTECTED]> wrote: > > Thanks Jamie - yeah, I thought of that, and Duncan also suggested it > offlist, but any combination of setNextTextFormat doesn't seem to work > for me either. My problem IS easily testable: > > 1. Create a font in your library - export it for actionscript, call it > "Swis". > 2. Make your SimpleTextField.as class file next to your .fla like this: > class SimpleTextField{ > public static function create(target_mc:MovieClip):TextField{ > var my_fmt:TextFormat = new TextFormat(); > my_fmt.font = "Swis"; > my_fmt.color = 0x000000; > my_fmt.size = 16; > target_mc.createTextField("tf_txt",0,20,20,200,20); > target_mc.tf = target_mc.tf_txt > target_mc.tf_txt.embedFonts = true; > target_mc.tf_txt.text="Hello world"; > target_mc.tf_txt.setTextFormat(my_fmt);//or > setNewTextFormat > return target_mc.tf_txt; > } > } > > 3. Put this code on the timeline: > > import SimpleTextField; > tf=SimpleTextField.create(this) > tf.text="hi" > > If I remove the last line: tf.text="hi" it works fine. If I leave it > in, nothing appears on the stage. This is driving me nutz. > > > Jason Merrill | E-Learning Solutions | icfconsulting.com > > > > > > > > > > > >>-----Original Message----- > >>From: [EMAIL PROTECTED] [mailto:flashcoders- > >>[EMAIL PROTECTED] On Behalf Of Jamie S > >>Sent: Friday, March 10, 2006 4:13 PM > >>To: Flashcoders mailing list > >>Subject: Re: [Flashcoders] Still need help-Can't reference library > font fromclass > >> > >>Although I have had my fair share of headaches with TextFormat, I > >>think I may know what is going on here. > >> > >>There are two methods for assigning a textFormat to a textField. These > >>are setTextFormat() and setNewTextFormat(). > >> > >>The way I understand it setTextFormat() sets the style of the text > >>that is currently assigned to the textField BUT any new text assigned > >>by actionscript, by replaceSel() or by the user (in the case of input > >>text) is styled according to the setNewTextFormat() method and if none > >>is given, as in your class, the new text is given some default style, > >>which, as you've noticed, is not necessarily the same as the style you > >>defined by setTextFormat(). > >> > >>so I would try using setNewTextFormat() also and see if that works. > >> > >>J > >> > >>On 3/10/06, Merrill, Jason <[EMAIL PROTECTED]> wrote: > >>> I finally did get this to work by trying it in a fresh .fla, but now > I'm > >>> seeing this issue: > >>> > >>> When I do this: > >>> > >>> import com.icfconsulting.objects.SimpleTextField; > >>> tf=SimpleTextField.create(this) > >>> > >>> It's fine, the text field show and with the right font. But when I > try > >>> and set the text on the text field it returns, like this: > >>> > >>> import com.icfconsulting.objects.SimpleTextField; > >>> tf=SimpleTextField.create(this) > >>> tf.text="hello, hello!" > >>> > >>> It just shows blank, like setting the text on the text field my > class > >>> returns screws it up somehow. Any idea what's up? The class code is > the > >>> same, and I am trying this in a new fresh .fla with a "Swis" font in > the > >>> library. Why would adding that one line screw it up again? > >>> > >>> My simple class test file is as follows: > >>> > >>> class com.icfconsulting.objects.SimpleTextField{ > >>> public static function create(target_mc:MovieClip):TextField{ > >>> var my_fmt:TextFormat = new TextFormat(); > >>> my_fmt.font = "Swis"; > >>> my_fmt.color = 0x000000; > >>> my_fmt.size = 16; > >>> target_mc.createTextField("tf_txt",0,20,20,200,20); > >>> target_mc.tf_txt.embedFonts = true; > >>> target_mc.tf_txt.text="Hello world"; > >>> target_mc.tf_txt.setTextFormat(my_fmt); > >>> return target_mc.tf_txt; > >>> } > >>> } > >>> > >>> Jason Merrill | E-Learning Solutions | icfconsulting.com > >>> > >>> > >>> > >>> > >>> NOTICE: > >>> This message is for the designated recipient only and may contain > privileged or > >>confidential information. If you have received it in error, please > notify the sender > >>immediately and delete the original. Any other use of this e-mail by > you is > >>prohibited. > >>> _______________________________________________ > >>> 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 > _______________________________________________ > 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