Re: API Commands

Dave Patton <[email protected]> 14 Oct 2003 12:20:14 -0700
Newsgroups gmane.comp.java.jgenerator.devel
Message-ID <[email protected]>
Well there is good news and bad news.  I was finally able to get a swf
file generated using the code below.  However when I run the SWF,
nothing seems to happen.  Initially I did not set the background color
which gave me a white box.  I thought maybe the text was white as well
which is why I couldnt see it.  So I changed the background to black but
now I just have a black box?   Im getting closer I can feel it :-) 


Util.init("../classes");
         System.out.println("Starting TickerTest");
         FlashFile file = FlashFile.newFlashFile(); // create default
flash file
         Script script = new Script(1); // create main script with 1
frame
         script.setMain();
         file.setMainScript(script); // set main script for the file
         script.setBackgroundColor(new SetBackgroundColor(new Color(0,
0, 0)));
         Frame frame = new Frame();

         Instance instance = frame.addInstance(new Script(), 1, null,
null);

         GenericCommand command = new TickerCommand();
         command.setInstance(instance);

         command.addParameter("datasource", "#Hello World");
         command.addParameter("orient", "horizontal");
         command.addParameter("mask", "false");
         command.addParameter("stepsize", "8");
         command.addParameter("itemspace", "5");
         command.addParameter("halign", "left");
         command.addParameter("valign", "top");
         command.addParameter("instancename", "");
         instance.setCommand(command);

         StandardContext context = new StandardContext();
         System.out.println("GOT HERE");
         file.processFile(context);
         FlashOutput fob = file.generate();
         BufferedOutputStream bos = new BufferedOutputStream(new
FileOutputStream("E:\\Docs\\projects\\OTD\\tmp\\tickertest.swf"));
         bos.write(fob.getBuf(), 0, fob.getSize());
         bos.close();
         System.out.println("Wrote File");


On Tue, 2003-10-14 at 11:08, Dmitry Skavish wrote:
> >          Util.init("../classes");
> >          System.out.println("Starting TickerTest");
> >          FlashFile file = FlashFile.newFlashFile(); // create default
> > flash file
> >          Script script = new Script(); // create main script with 1
> > frame
> >          script.setMain();
> >          file.setMainScript(script); // set main script for the file
> >          //int startFrame = 1;
> >          //Frame frame = script.getFrameAt(1);
> >          Frame frame = new Frame();
> 
> >          Instance instance = frame.addInstance(script, 1, null, null);
> 
> script here has to be new Script() for the instance, i.e. change it to
> 
>            Instance instance = frame.addInstance(new Script(), 1, null, null);
> 
>            GenericCommand command = new TickerCommand();
> >          command.setInstance(instance);
> > 
> >          command.addParameter("datasource", "text.txt");
> >          command.addParameter("orient", "horizontal");
> >          command.addParameter("mask", "false");
> >          command.addParameter("stepsize", "8");
> >          command.addParameter("itemspace", "5");
> >          command.addParameter("halign", "left");
> >          command.addParameter("valign", "top");
> >          command.addParameter("instancename", "");
> > 
> >          instance.setCommand(command);
> >          StandardContext context = new StandardContext();
> >          context.setValue("filename", "tickertest.swf");
> 
> you need to set values to the context only if you use variables in command 
> parameters (variables things like {varname}), so no need to setValue here
> 
> if you got some exception then send the exception stacktrace as well.



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php