Re: Inserting action script variables to a frame

Dmitry Skavish <[email protected]> Fri, 10 Jan 2003 13:07:14 -0500
Newsgroups gmane.comp.java.jgenerator.devel
Organization PTC
Message-ID <[email protected]>
Niek,

> I'm new to this list, but I have a question.
> I'm trying to put some varibales in action script in a swt that alllready
> contains action script code.
> The code looks like this (actions for frame 2):
> var prevy=0;
> var prevx=0;
> var holdcount=0;
> 
> I's like to add some variables to this list (like var name="value";).
> Is this possible? If so, how can this be done?
> I tried the following in my code (did not work):

right way to do it:

FlashFile file ....;

   1. obtain the frame you want to put your actionscript to. in your case (frame 2) it will be:

         Frame frame = file.getMainScript().getFrameAt(1);   // frames are counted from zero

   2. create actionscript block (var myvar=10):

         ASAssembler as = new ASAssembler(file);
         as.localVar("myvar", new Integer(10));

   3. create DoAction object:

         DoAction actions = new DoAction(as.toProgram());

   4. add the actions to the frame:

         frame.addFlashObject(actions);

then you just need to generate the file and save it

-- 
Dmitry Skavish
-----------------------
Boston, MA, USA
tel. +1 781 910-3810
http://www.jzox.com
http://www.flashgap.com



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com