Re: How can I change the content of a text layer??

Leónidas Williams Gaínza <[email protected]> Thu, 21 Nov 2002 11:06:46 +0100
Newsgroups gmane.comp.java.jgenerator.devel
Message-ID <001f01c29145$b3b43d60$a1ea2550@lwilliams>
Hi Dmitry:

Again thanks for your help.

I tried what you suggested but I have the problem that a void swf file is
created. I have followed the code and I have found that the method process
of the FlashObject class is void and is executed, so I supose that this is
the reason why I obtain an empty file.

Do I have a wrong version of the library? Is not this the reason of the
failing?

Thanks in advance for your help
----- Original Message -----
From: "Dmitry Skavish" <[email protected]>
To: "Leónidas Williams Gaínza" <[email protected]>
Cc: <[email protected]>
Sent: Thursday, November 21, 2002 7:32 AM
Subject: Re: [Jgen-devel] How can I change the content of a text layer??


Leónidas,

> I like your idea, but can you tell me any place where could I find any
help
> and/or documentation regarding this way of work? (I would be interested in
> collaborate in the development of this tool, but first at all I would like
> to understand very well how it works, etc.)

I would recommend you to look at com.iv.flash.Generator class. In short you
need something
like this:

             try {
                 file = FlashFile.parse(inFileName, false, encoding);
             } catch( FileNotFoundException e ) {
                 Log.logRB(Resource.FILENOTFOUND, new Object[] {inFileName},
e);
             }

             if( file != null ) {
                 // load environment
                 Context context = new StandardContext();

                 context.setValue("make", "BMW");
                 context.setValue("model", "328i");

                 file.processFile(context);

                 try {
                     file.setCompressed(compressOutput);
                     FlashOutput fob = file.generate();
                     BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream( outFileName ) );
                     bos.write( fob.getBuf(), 0, fob.getSize() );
                     bos.close();
                 } catch( IOException e ) {
                     Log.logRB(Resource.ERRWRITINGFILE, new Object[]
{outFileName}, e);
                 }

             }

so now if in this file there is a text like: "My car is {make} {model}",
then
after file.processFile(context) it will be: "My car is BMW 328i"

I hope it helps!

>
> Thanks again for your help, time and attention.
>
> Att. Leónidas Williams
> ----- Original Message -----
> From: "Dmitry Skavish" <[email protected]>
> To: "Leónidas Williams Gaínza" <[email protected]>
> Cc: <[email protected]>
> Sent: Tuesday, November 19, 2002 6:06 AM
> Subject: Re: [Jgen-devel] How can I change the content of a text layer??
>
>
>
>>Leónidas,
>>
>>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 variables
>
> into
>
>>the text like {var1}, then create StandardContext, put variables in it and
>>process flash file with this context.
>>
>>
>>>I need your help. I am trying to
>>>
>>>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 = FlashFile.parse("source.swt");
>>>
>>>            String flash_path = "Text1";
>>>
>>>             Script scr = (Script)ff.getDefFromLibrary(flash_path);
>>>             Frame frm = scr.getFrameAt(0);
>>>             for(Enumeration enum =
>>
> frm.elements();enum.hasMoreElements();){
>
>>>                Text txt = (Text)((Instance)enum.nextElement()).def;
>>>                IVVector iv =
>>>(IVVector)txt.getTextItems();
>>>                    for(Enumeration enum2 =
>>>iv.elements();enum2.hasMoreElements();){
>>>                        TextItem txtItem =
>>
> (TextItem)enum2.nextElement();
>
>>>                        txtItem.text = "Hello World.
>>>Modified!!";
>>>                    }
>>>             }
>>>
>>>             ff.addDefToLibrary("Text1",  scr);
>>>             FlashOutput fob = ff.generate();
>>>             BufferedOutputStream bos = 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ón: " + e);
>>>        }
>>>    }
>>
>>
>
>
>




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Jgen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jgen-devel





-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf