Re: How can I change the content of a text layer??
Dmitry Skavish <[email protected]> Tue, 19 Nov 2002 00:06:36 -0500
| Newsgroups | gmane.comp.java.jgenerator.devel |
|---|---|
| Message-ID | <[email protected]> |
Le=F3nidas,
first of all try to put some debug code to see whether you in fact change
the text or not. If you do then it should work.
second why don't you try pure jgenerator approach, i.e. put some variable=
s into
the text like {var1}, then create StandardContext, put variables in it an=
d
process flash file with this context.
> I need your help. I am trying to
> =20
> 1) read a swt file that has a layer containing a Library Item kind of=20
> movie clip that is a text.
> 2) open this file and change the content of this text item, changing th=
e=20
> text shown.
> 3) obtain a new swf file.
> =20
> I am trying it using the code that I enclose in this message, but it is=
=20
> not working. Could you help me please? Where am I doing wrong the steps=
?
> =20
> Thanks in advance for your help:
> =20
> public static void main(String[] args) {
> try{
> FlashFile ff =3D FlashFile.parse("source.swt");
> =20
> String flash_path =3D "Text1";
> =20
> Script scr =3D (Script)ff.getDefFromLibrary(flash_path);
> Frame frm =3D scr.getFrameAt(0);
> for(Enumeration enum =3D frm.elements();enum.hasMoreElemen=
ts();){
> Text txt =3D (Text)((Instance)enum.nextElement()).def;
> IVVector iv =3D=20
> (IVVector)txt.getTextItems(); =20
> for(Enumeration enum2 =3D=20
> iv.elements();enum2.hasMoreElements();){
> TextItem txtItem =3D (TextItem)enum2.nextElemen=
t();
> txtItem.text =3D "Hello World.=20
> Modified!!"; =20
> }
> }
> =20
> ff.addDefToLibrary("Text1", scr); =20
> FlashOutput fob =3D ff.generate();
> BufferedOutputStream bos =3D new BufferedOutputStream( new=
=20
> FileOutputStream( "target.swf" ) );
> bos.write( fob.getBuf(), 0, fob.getSize() );
> bos.close();
> =20
> System.out.println("Done!");
> }catch(Exception e){
> System.out.println("Excepci=F3n: " + e);
> }
> }
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing
your web site with SSL, click here to get a FREE TRIAL of a Thawte
Server Certificate: http://www.gothawte.com/rd524.html