How can I change the content of a text layer??
Leónidas Williams Gaínza <[email protected]> Sun, 17 Nov 2002 00:29:57 +0100
| Newsgroups | gmane.comp.java.jgenerator.devel |
|---|---|
| Message-ID | <000e01c28dc8$13ea1a00$a1ea2550@lwilliams> |
This is a multi-part message in MIME format.
------=_NextPart_000_000B_01C28DD0.753448F0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi to everybody:
I need your help. I am trying to=20
1) read a swt file that has a layer containing a Library Item kind of =
movie clip that is a text.
2) open this file and change the content of this text item, changing the =
text shown.
3) obtain a new swf file.
I am trying it using the code that I enclose in this message, but it is =
not working. Could you help me please? Where am I doing wrong the steps?
Thanks in advance for your help:
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.hasMoreElements();){
Text txt =3D (Text)((Instance)enum.nextElement()).def;
IVVector iv =3D (IVVector)txt.getTextItems(); =
=20
for(Enumeration enum2 =3D =
iv.elements();enum2.hasMoreElements();){
TextItem txtItem =3D =
(TextItem)enum2.nextElement();
txtItem.text =3D "Hello World. Modified!!"; =
=20
}
}
=20
ff.addDefToLibrary("Text1", scr); =20
FlashOutput fob =3D ff.generate();
BufferedOutputStream bos =3D new BufferedOutputStream( new =
FileOutputStream( "target.swf" ) );
bos.write( fob.getBuf(), 0, fob.getSize() );
bos.close();
System.out.println("Done!");
}catch(Exception e){
System.out.println("Excepci=F3n: " + e);
}
}
------=_NextPart_000_000B_01C28DD0.753448F0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2719.2200" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi to everybody:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I need your help. I am trying to =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>1) read a swt file that has a layer =
containing a=20
Library Item kind of movie clip that is a text.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>2) open this file and change the =
content of this=20
text item, changing the text shown.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>3) obtain a new swf file.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I am trying it using the code that =
I enclose=20
in this message, but it is not working. Could you help me please? Where =
am I=20
doing wrong the steps?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks in advance for your =
help:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> public static void =
main(String[]=20
args) {<BR> =20
try{<BR>  =
;=20
FlashFile ff =3D=20
FlashFile.parse("source.swt");<BR> &nb=
sp; =20
<BR> =
String=20
flash_path =3D=20
"Text1";<BR> &=
nbsp; =20
<BR> &nb=
sp;=20
Script scr =3D=20
(Script)ff.getDefFromLibrary(flash_path);<BR> &nbs=
p; =20
Frame frm =3D=20
scr.getFrameAt(0);<BR> &nb=
sp; =20
for(Enumeration enum =3D=20
frm.elements();enum.hasMoreElements();){<BR>  =
; =20
Text txt =3D=20
(Text)((Instance)enum.nextElement()).def;<BR> &nbs=
p; =20
IVVector iv =3D=20
(IVVector)txt.getTextItems(); &n=
bsp; =20
<BR> &nb=
sp; =20
for(Enumeration enum2 =3D=20
iv.elements();enum2.hasMoreElements();){<BR>  =
; =
=20
TextItem txtItem =3D=20
(TextItem)enum2.nextElement();<BR> &nb=
sp; &nbs=
p; =20
txtItem.text =3D "Hello World.=20
Modified!!"; &=
nbsp; &n=
bsp;=20
<BR> &nb=
sp; =20
}<BR> &n=
bsp;=20
}<BR> &n=
bsp; =20
<BR> &nb=
sp;=20
ff.addDefToLibrary("Text1", scr); =20
<BR> &nb=
sp;=20
FlashOutput fob =3D=20
ff.generate();<BR> &=
nbsp; =20
BufferedOutputStream bos =3D new BufferedOutputStream( new =
FileOutputStream(=20
"target.swf" )=20
);<BR> &=
nbsp;=20
bos.write( fob.getBuf(), 0, fob.getSize()=20
);<BR> &=
nbsp;=20
bos.close();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p; =20
System.out.println("Done!");<BR>  =
;=20
}catch(Exception=20
e){<BR> =
=20
System.out.println("Excepci=F3n: " +=20
e);<BR> =
}<BR> =20
}</FONT></DIV></BODY></HTML>
------=_NextPart_000_000B_01C28DD0.753448F0--
-------------------------------------------------------
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