TextField.setFont

Jeremy LaCivita <[email protected]> Fri, 12 Aug 2005 21:30:33 -0400
Newsgroups gmane.comp.java.jgenerator.devel
Message-ID <[email protected]>
Hi List,

I'm trying to use the JGenerator classes to allow me to change  
certain text in my flash movies.  The text is in a Dynamic TextField  
on the stage, using a font that is embedded in the document's library  
(and exported for runtime).  The textfield is given an instance name.

i just added some simple code to the Generator.java class to change  
the text, and so far so good:


                 // Code lives just after the file object is initialized

                 Instance instance = file.getMainScript().findInstance 
("myTextField");
                 System.out.println("instance: " + instance);
                 System.out.println("class:    " + instance.getClass());
                 System.out.println("flashdef: " + instance.def);
                 System.out.println("class:    " +  
instance.def.getClass());

                 if ( instance.def instanceof TextField ) {
                     TextField tf = (TextField)instance.def;
                     tf.setInitText("GENERATED!");
                 }


This works, however, it only lets me use characters that were  
embedded in the Dynamic TextField (via the Character options in the  
Flash IDE)

I'd like to allow any characters at all, and the text must stay anti- 
aliased.  The reason i embedd the font in the first place is because  
its the only way to keep the text antialiased, even without  
JGenerator.  (it would also be good if the generated swf only  
embedded the characters that were used in the end)

so I tried using some of JGenerators font classes, but this just  
makes all my text disappear!

                 Instance instance = file.getMainScript().findInstance 
("lbl_search_for");
                 System.out.println("instance: " + instance);
                 System.out.println("class:    " + instance.getClass());
                 System.out.println("flashdef: " + instance.def);
                 System.out.println("class:    " +  
instance.def.getClass());

                 if ( instance.def instanceof TextField ) {
                     TextField tf = (TextField)instance.def;
                     tf.setInitText("GeNERATED!");
                     Font arial = FontDef.load("Arial.fft");
                     System.out.println("glyphs:   " +  
arial.getNumGlyph());
                     System.out.println("index!:   " + arial.getIndex 
('!'));
                     System.out.println("index@:   " + arial.getIndex 
('@'));
                     tf.setFont(arial, 18);
                 }

Would definitely appreciate help!

My only requirements are that I can change some text in a flash movie  
based on an instance name. So any solution would help, either  
changing my code or the way I set my Flash movie up.

-Jeremy LaCivita

PS: the reason i need to do it this way is that the original SWFs  
need to be usable without any jgenerator interaction, so i can't put  
any jgenerator specific stuff in my movies.




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf