|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
FSMovieListener | Deprecated. the FSMovieListener interface will no longer be used future release to report decoding and encoding events and to report errors. |
Class Summary | |
---|---|
FSAction | The FSAction class is used to represent stack-based actions, defined by simple byte-codes, that are executed by the Flash Player. |
FSActionObject | The FSActionObject is a base class for the classes that represent the different types of actions defined in the Flash file format specification. |
FSAudioData | FSAudioData is used to define sounds for a Flash Video (flv) file. |
FSBitmapFill | The FSBitmapFill class is used to fill a shape with an image. |
FSBounds | The FSBounds class is used to define the area inside which shapes, text fields and characters are drawn. |
FSButton | FSButton identifies the shape that is drawn when a button is in a particular state. |
FSButtonColorTransform | FSButtonColorTransform defines the colour transform that is applied to each shape that is used to draw a button. |
FSButtonEvent | FSButtonEvent is used to define the actions that a button will execute in response to a particular event. |
FSButtonSound | FSButtonSound defines the sounds that are played when an event occurs in a button. |
FSCall | FSCall is used to execute the actions previously assigned to a given frame with an FSDoAction object. |
FSCharacter | The FSCharacter class is used to identify the glyph that is displayed for a given character in a line of text. |
FSClipEvent | FSClipEvent is used to define the actions that a movie clip will execute in response to a particular event. |
FSCoder | FSCoder is a similar to Java stream classes, allowing words and bit fields to be read and written from an internal array of bytes. |
FSColor | FSColor is used to represent colours. |
FSColorTable | The FSColorTable class contains a set of factory methods to generate FSColor objects for each of the colours defined in the Netscape Colour Table. |
FSColorTransform | The FSColorTransform is used to change the colour of a shape or button without changing the values in the original definition of the object. |
FSCoordTransform | FSCoordTransform is used to specify two-dimensional coordinate transforms, allowing an object to be scaled, rotated or moved without changing the original definition of how the object is drawn. |
FSCurve | FSCurve is used to define a curve. |
FSDefineButton | FSDefineButton defines the appearance of a button and the actions performed when the button is clicked. |
FSDefineButton2 | FSDefineButton2 defines the appearance and actions of push and menu buttons. |
FSDefineFont | FSDefineFont defines the glyphs that are drawn when text characters are rendered in a particular font. |
FSDefineFont2 | FSDefineFont2 defines the shapes and layout of the glyphs used in a font. |
FSDefineImage | FSDefineImage is used to define an image compressed using the lossless zlib compression algorithm. |
FSDefineImage2 | FSDefineImage2 is used to define a transparent image compressed using the lossless zlib compression algorithm. |
FSDefineJPEGImage | FSDefineJPEGImage is used to define a JPEG encoded image. |
FSDefineJPEGImage2 | FSDefineJPEGImage2 is used to define a JPEG encoded image with an integrated encoding table. |
FSDefineJPEGImage3 | FSDefineJPEGImage3 is used to define a transparent JPEG encoded image. |
FSDefineMorphShape | FSDefineMorphShape defines a shape that will morph from one form into another. |
FSDefineMovieClip | FSDefineMovieClip defines a movie clip that animates shapes within a movie. |
FSDefineObject | The FSDefineObject is a base class for the different types of object used to create images, buttons, shapes and sounds. |
FSDefineShape | FSDefineShape defines a shape to be displayed. |
FSDefineShape2 | FSDefineShape2 defines a shape to be displayed. |
FSDefineShape3 | FSDefineShape3 defines a transparent shape to be displayed. |
FSDefineSound | FSDefineSound is used to define a sound that will be played when a given event occurs. |
FSDefineText | FSDefineText defines one or more lines of text. |
FSDefineText2 | FSDefineText2 defines one or more lines of transparent text. |
FSDefineTextField | FSDefineTextField defines an editable text field. |
FSDefineVideo | The FSDefineVideo class is used to display video within a Flash file. |
FSDoAction | FSDoAction is used to specify a sequence of actions that are executed when a frame is displayed. |
FSEnableDebugger | Enables a movie to be debugged when played using the Flash authoring tool, allowing the variables defined in the arrays of actions specified in object to be inspected. |
FSEnableDebugger2 | Enables a movie to be debugged when played using the Flash authoring tool, allowing the variables defined in the arrays of actions specified in object to be inspected. |
FSEnvelope | FSEnvelope is used to define an envelope which controls how a particular sound is played over time. |
FSExceptionHandler | The FSExceptionHandler class is used to specify try..catch blocks so exceptions can be thrown and handled when executing a series of actions. |
FSExport | FSExport is used to export shapes and other objects so they can be used in another Flash file. |
FSFillStyle | FSFillStyle is an abstract base class for the different types of fill style that can be applied to shapes. |
FSFontInfo | FSFontInfo defines the name and face of a font and maps the codes for a given character set to the glyphs that are drawn to represent each character. |
FSFontInfo2 | FSFontInfo2 describes the mapping of codes for a given character set to the glyphs that are drawn to represent the character. |
FSFrame | The Frame class is used to provide a higher level view of a movie. |
FSFrameLabel | FSFrameLabel defines a name for the current frame in a movie or movie clip. |
FSFree | FSFree deletes the object with the specified identifier, freeing up resources in the Flash Player. |
FSGetUrl | FSGetUrl is used to display a web page or load a movie clip into the Flash Player. |
FSGetUrl2 | The FSGetUrl2 action is used to either load a web page or movie clip or load or submit variable values to/from a server. |
FSGotoFrame | The FSGotoFrame action instructs the player to move to the specified frame in the current movie's main time-line. |
FSGotoFrame2 | The FSGotoFrame2 action instructs the player to go to the named or numbered frame in the current movie's main time-line. |
FSGotoLabel | The FSGotoLabel action instructs the player to move to the frame in the current movie with the specified label. |
FSGradient | FSGradient defines a control point that is used to specify how a gradient colour is displayed. |
FSGradientFill | FSGradientFill defines how a colour changes across an area to be filled with colour. |
FSHeader | The FSHeader class can be used to quickly decode the header information in a flash file to get information about the number of frames, screen size etc. |
FSIf | The FSIf action is used to perform a conditional branch to control the actions executed by the Flash Player. |
FSImageBlock | When an image is sent in a ScreenVideo stream only pixel information for the portions of the image that change are sent. |
FSImport | FSImport is used to import shapes and other objects from another Flash file. |
FSInitialize | FSInitialize is used to specify a sequence of actions that are executed to initialise a movie clip before it is displayed. |
FSJPEGEncodingTable | FSJPEGEncodingTable defines an encoding table for JPEG images. |
FSJump | The FSJump action performs an unconditional branch to control the actions executed by the Flash Player. |
FSKerning | FSKerning describes the spacing between a pair of glyphs. |
FSLayer | The Layer class can be used to simplify the creation of movies. |
FSLimitScript | The FSLimitScript is used to define the execution environment of the Flash Player, limiting the resources available when executing actions. |
FSLine | FSLine defines a straight line. |
FSLineStyle | The FSLineStyle is the abstract root class for line styles. |
FSMorphBitmapFill | FSMorphBitmapFill uses a bitmap image to fill an area of a morphing shape. |
FSMorphGradient | FSMorphGradient defines the control points that is used to specify how a gradient fill is displayed at the start and end of the shape morphing process. |
FSMorphGradientFill | FSMorphGradientFill defines how a colour changes across an area filled in a morphing shape. |
FSMorphSolidFill | FSMorphSolidFill defines the solid colours that are used to fill a morphing shape at the start and end of the morphing process. |
FSMorphSolidLine | FSMorphSolidLine defines the width and colour of a line drawn for a morphing shape. |
FSMovie | FSMovie is a container class for the objects that represents the data structures in a Flash file. |
FSMovieEvent | Deprecated. the FSMovieEvent will no longer be supported in future releases to report decoding and encoding events and to report errors. |
FSMovieObject | The FSMovieObject is the root class for objects that represent each of the tagged data structures that make up the Flash file format specification. |
FSNewFunction | The FSNewFunction action is used to create a user-defined function. |
FSNewFunction2 | The FSNewFunction2 action is used to create a user-defined function. |
FSNull | FSNull is a lightweight object that is used solely to allow null values to be pushed onto the Flash Player stack by The FSPush class. |
FSPathsArePostscript | The FSPathsArePostscript class is used to notify the Flash Player that the glyphs encoded in a font definition were derived from a PostScript-based font definition. |
FSPlaceObject | FSPlaceObject is used to add an object (shape, button, etc.) to the Flash Player's display list. |
FSPlaceObject2 | FSPlaceObject2 is used to add and manipulate objects (shape, button, etc.) on the Flash Player's display list. |
FSPointer | FSPointer defines an unsigned 32-bit pointer. |
FSProperty | FSProperty is a lightweight class used to hold codes that specify movie clip and movie properties that will be pushed onto the Flash Player stack. |
FSProtect | FSProtect marks a file as not-readable, preventing the file from being loaded into an editor. |
FSPush | FSPush is used to push values on the Flash Player's internal stack. |
FSQuicktimeMovie | The FSQuicktimeMovie defines the name of an external Quicktime movie to be played. |
FSRegisterCopy | FSRegisterCopy is used to copy the item at the top of the stack to one of the Flash Player's internal registers. |
FSRegisterIndex | FSRegisterIndex is used with an FSPush action to refer to one of the Flash Player's internal registers that contains a value to be used in a calculation. |
FSRegisterVariable | FSRegisterVariable is a lightweight class used to identify the register that an argument defined in The FSNewFunction2 class is mapped into when executing the function. |
FSRemoveObject | FSRemoveObject removes an object from the Flash Player's Display List. |
FSRemoveObject2 | FSRemoveObject2 removes an object from the display list. |
FSScreenVideoPacket | The FSScreenVideoPacket class is used to encode or decode a frame of video data using Macromedia's ScreenVideo format. |
FSSerialNumber | FSSerialNumber is used to add a user-defined serial number into a Flash file. |
FSSetBackgroundColor | FSSetBackgroundColor sets the background colour displayed in every frame in the movie. |
FSSetTarget | FSSetTarget is used to control the time-line of a particular movie clip. |
FSShape | FSShape is a container for the shape objects (FSLine, FSCurve and FSShapeStyle objects) that describe how a particular shape is drawn. |
FSShapeStyle | FSShapeStyle is used to change the drawing environment when a shape is drawn. |
FSShowFrame | FSShowFrame is used to instruct the Flash Player to display a single frame in a movie or movie clip. |
FSSolidFill | FSSolidFill defines a solid colour that is used to fill an enclosed area in a shape. |
FSSolidLine | FSSolidLine defines the width and colour of a line that is used when drawing the outline of a shape. |
FSSound | The FSSound class identifies a sound (previously defined using The FSDefineSound class) and controls how it is played. |
FSSoundStreamBlock | FSSoundStreamBlock contains the sound data being streamed to the Flash Player. |
FSSoundStreamHead | FSSoundStreamHead defines the format of a streaming sound, identifying the encoding scheme, the rate at which the sound will be played and the size of the decoded samples. |
FSSoundStreamHead2 | FSSoundStreamHead2 defines an sound compressed using different compression formats that is streamed in tight synchronisation with the movie being played. |
FSStartSound | FSStartSound instructs the player to start or stop playing a sound defined using the FSDefineSound class. |
FSTable | FSTable is used to create a table of string literals that can be referenced by an index rather than using the literal value when executing a sequence of actions. |
FSTableIndex | FSTableIndex is used with an FSPush action to push a reference to an entry in a table of literals onto the stack. |
FSTabOrder | The FSTabOrder class is used to set the tabbing order of text fields, movie clips and buttons visible on the display list. |
FSText | FSText is used to display a line of text. |
FSTransformObject | The FSTransformObject object defines the basic set of method that an object must implement if it can used to represent the data structures that make up the Flash File Format specification. |
FSUnknownAction | FSUnknownAction class is used to represent any action decoded from a Flash file that is currently not supported by the framework. |
FSUnknownObject | FSUnknownObject is used to represent any data structure decoded from a Flash file that is currently not supported by the framework. |
FSVideo | FSVideo is a container class for the objects that represents the data structures in a Flash video file. |
FSVideoData | The FSVideoData class is used to store the data for a single video frame. |
FSVideoFrame | FSVideoFrame contains the video data displayed in a single frame of a Flash movie. |
FSVideoMetaData | The FSVideoMetaData class is used to store information on how the video stream should be displayed. |
FSVideoObject | The FSVideoObject is the root class for objects that represent each of the tagged data structures that make up the Flash Video file format specification. |
FSVoid | FSVoid is a lightweight object that is used solely to allow void values to be pushed onto the Flash Player stack by The FSPush class. |
FSWaitForFrame | The FSWaitForFrame action instructs the player to wait until the specified frame number has been loaded. |
FSWaitForFrame2 | The FSWaitForFrame2 action instructs the player to wait until the specified frame number or named frame has been loaded. |
FSWith | FSWith is a stack-based action and supports the with statement from the ActionScript language. |
Transform | The %Transform class defines constants and methods used throughout the %Transform package. |
Exception Summary | |
---|---|
FSCoderException | This exception is thrown when parse errors are encountered. |
Transform SWF is designed to read and write Flash file.
Flash is designed to display vector graphics across the Internet and displayed on host devices using the Macromedia Flash Player. Flash is designed to be compact, extensible and platform independent. Animations delivered using Flash will be displayed consistently and accurately across a wide range of devices.
A Flash file (movie) contain a sequence of tagged data blocks.
Each movie starts with header information followed by a sequence of tags that describe how the movie is displayed. All movies end with an End tag which marks the end of the file.
The header identifies the type and version of Flash contained in the file; the size of screen displayed by the Flash Player; the length of file; the rate at which frames are displayed and the number of frames in the movie.
Two categories of tag are provided: definition tags which are used to describe shapes, images, buttons, sounds, etc., and control tags that create instances of the shapes, etc. and display them on the Flash Player screen to create animations.
Flash also supports actions which control the behaviour of objects in response to events such as a button being clicked or when a particular frame is displayed. Actions are represented by byte-codes and the Flash Player supports a stack-based programming model which provides a rich programming environment that supports complex behaviours. This allows Flash movies to provide all the flexibility and sophistication of user interfaces found in desktop computers and personal devices.
The Transform SWF library is a collection of classes for each of the tags and data structures that make up the Flash File Format. The FSMovie class is the principal class in the library. FSMovie objects are used to represent a complete Flash movie, containing instances of the classes that represent each type of tag.
FSMovie is designed to simplify the creation and manipulation of Flash files. Creating an instance of the class:
FSMovie aMovie(filename);
parses the Flash file, filename and creates objects for each different tags and data structure decoded from the file. The objects may be inspected and their attributes changed accordingly. Once the objects have been updated:
aMovie.writeToFile(filename);
encodes each object and generates the file according to the Macromedia Flash (SWF) File Format Specification.
Flash is, in effect, a programming language for the Flash Player. A movie contains definitions of objects which are created, displayed and updated to create an animation. In order to understand how the classes provided in Transform are used to create Flash movies it is essential to understand the programming model provided by the Flash Player.
The Dictionary is a table that contains the definitions of the objects (buttons, images, sounds) that will be displayed in the movie. Each definition tag (represented in Transform by classes derived from FSDefineObject) contains a unique identifier which allows the definition to be referenced when creating instances of a particular shape, button, etc., to display on the screen. Entries are added to the dictionary whenever a definition tag is decoded from the Flash movie. Dictionary entries may be deleted using the FSFree class once a definition is no longer needed.
The Display List controls the order in which objects are displayed on the screen. The display list is divided into layers. To display an object on the screen it is placed on a display list layer (using the FSPlaceObject or FSPlaceObject2 classes). The layer number controls the stacking order of object when the movie is displayed. Objects placed on a higher layer are displayed in front on an object on a lower layer. Only one object can be placed on a given layer at a time so like the unique identifier used to create the object from its definition in the Dictionary the layer number can be used to refer to an object once it is on the display list. When placed on the Display List an object is always visible (unless hidden by another or moved off the visible area of the screen) until it is explicitly removed (using FSRemoveObject or FSRemoveObject2). Once an object is removed it is "destroyed" so another instance must be re-created from its definition if the object must be displayed again.
The Movie List is used to manage the movie and any movie clips (also known as sprites). The Movie List contains a number of virtual levels, analogous to the layers in the Display List, which are used to keep track of which movie clips are currently loaded. The main movie is placed automatically on _level0. Movie clips that are displayed within the main movie may be loaded to _level1, _level2, etc. Note that movie clips must still be placed on the Display List for them to become visible on the Screen. Loading a movie clip (using the FSGetUrl2 class) to a level replaces any clip already loaded at that level. Movies loaded to _level0 replace the main movie. This allows several movies sequences to be chained together into a single movie.
The Screen is a bit-mapped display where the Flash Player renders the graphics objects to create the animation. Each time a ShowFrame tag is decoded the objects added to the Display List are rendered on the Screen. All graphics and fonts are anti-aliased. The size of the Screen is defined by the frameSize attribute of the FSMovie object. Coordinates in Flash are specified in twips where 1 twip equals 1/1440th of an inch or 1/20th of a point. For most practical purposes this can be simplified to 1 twip = 1/20th of a pixel.
It is important to note that in Flash the positive x and y axes extend from the top left corner of the screen (not from the lower left as in the Cartesian coordinate system). The coordinate range may also be specified in the attributes of a Flash movie so that the top left corner is set to an arbitrary pair of coordinates. For example specifying the corners at the points (-100,-100) and (100,100) defines a screen 200 twips by 200 twips with the point (0,0) located in the centre. Specifying the points (0,0) and (200,200) defines a screen with the same size however the centre is now located at (100,100).
The Flash Player supports three other physical devices (through the host operating system) to allow a user to interact with the animation being played. Users can enter data and keystrokes representing commands through a keyboard. A mouse or other pointing device is supported to allow users to click buttons and generate events for movie clips. Finally the Flash Player supports CD-quality sound in mono or stereo with between three and eight sound channels playing simultaneously, depending on the capabilities of the host platform. Sounds can be played in response to specific events, such as a mouse being clicked or streamed with the movie to provide as sound-track as it is displayed. With the introduction of Flash 5, access to the keyboard and mouse are provided through the Key and Mouse objects and the methods they support, see Object-Oriented Programming below.
Actions executed by the Flash Player are loaded into the Instruction Buffer. Actions may be specified as part of a button definition to be executed when the button is clicked. Flash also allows actions to be executed whenever each frame is displayed (using the FSDoAction class). Flash does not support the concept of a program as such. Rather the complete movie can be regarded as the program executed by the Flash Player. Sequences of actions defined in FSDefineButton, FSDoAction objects are best viewed as procedures or sub-routines that are executed whenever a particular event occurs. A given set of actions are executed each and every time the corresponding event occurs. The Instruction Buffer is byte-addressable. Control flow within the Instruction Buffer is controlled by the Instruction Pointer which contains the address of the next instruction to be executed. Conditional and unconditional jumps are supported through the FSIf and FSJump classes respectively. Each action contains a 16-bit offset which is added to the address in the Instruction Pointer to obtain the address of the next instruction in the Instruction Buffer.
Calculations are performed using the Stack. The FSPush class is used to push values onto the stack. When actions are executed any required arguments are popped from the Stack and any results are pushed back on the stack then the action finishes executing. Values pushed onto the Stack are primarily integers or strings. When values are used repeatedly in a calculation the Flash Player provides the String Table and a set of 256 internal Registers (increased from 4 in Flash 6) to improve efficiency. Rather than repeatedly push a string value onto the Stack the FSTable class allows an array of strings to be defined in a look-up table, using the FSTable class. A string is referenced from the table by pushing an FSTableIndex value onto the Stack. A table index only occupies 1 or 2 bytes in the Instruction Buffer so the space required by a sequence of actions can be reduced considerably using indices rather than explicitly pushing strings onto the stack. The Flash Player also has a set of 256 internal registers for temporarily storing values. Values are copied (not popped) from the top of the Stack using the FSRegisterCopy action. The contents of the register is referenced by pushing an FSRegisterIndex onto the Stack. This simplifies use of the Stack is complex calculations and again reduced the space required to represent a given set of actions in the Instruction Buffer.
Although calculations are performed using the Stack, Flash also supports the concept of named variables. Variables are stored in Memory which is a scratch-pad memory accessible only by the Flash Player. It cannot be accessed using any of the actions provided by Flash. Variables are fetched and set from Memory using the GetVariable and SetVariable actions (byte-code actions are supported using the FSAction class). The name of the variable is pushed onto the Stack and a GetVariable action is executed. The value of the variable is fetched form Memory and pushed onto the Stack by the Flash Player. Similarly to set a variable the value followed by the variable name are pushed onto the Stack and a SetVariable action is executed to update the variable in Memory.
Flash provides a rich environment for drawing object and creating animations. This is a brief description of the main aspects of Flash and is intended to introduce the main classes available in the Transform SWF library. Examples showing how to use the individual classes to create Flash movies are presented on Flagstone's web site.
Drawing Shapes
Shapes are drawn using a combination FSLine and FSCurve which specify the line or
curve to draw relative to the current drawing point. The line style is defined
using FSSolidLine class - only solid lines are supported. Shapes can be filled
with solid colour (FSSolidFill), an image (FSBitmapFill) or a colour gradient
(FSGradientFill). The FSShapeStyle class is used to select a particular line and
fill style while drawing a shape. It can also change the current drawing point
and the set of line and fill styles used for a particular shape. Shapes are defined
using FSDefineShape, FSDefineShape2 or FSDefineShape3. FSDefineShape is the most
commonly used class. FSDefineShape2 extends FSDefineShape to support a large number
(greater than 65535) of line and fill styles while FSDefineShape3 supports transparent
shapes.
Flash supports shape morphing using the FSDefineMorphShape class which defines the appearance of the start and end shapes. The interpolation between the start and end shapes is performed by the Flash Player. Displaying a morphing shape is controlled by the FSPlaceObject2 class which identifies the point in the morphing process and updates the display list with the morphed shape.
Buttons
Buttons are created by defining a shape for when button is up, the mouse is over
the button or the button is clicked.FSDefineButton displays a button that executes
a set of actions when it is clicked. FSDefineButton2 provides are more flexible
class allowing actions to be executed for any of the states a button can occupy.
Sounds can also be played, using the FSButtonSound class, when an event occurs,
such as the button being clicked.
Images
Flash supports JPEG and lossless image formats such as GIF. Several classes are
provided which display "regular" and transparent images. Images cannot be displayed
directly. They can only be displayed inside a shape that contains a bitmap fill
style. Creating such "image shapes" is simple however.
Fonts and Text
Flash ensures consistency and quality when display text by defining the glyphs
that represent each of the text characters displayed in a movie. Fonts are defined
using FSDefineFont and FSDefineFont2 - the latter combines the FSDefineFont and
FSFontInfo classes into a more convenient and flexible class. A string is defined,
using FSDefineText and FSText, by specifying the index of the glyph, from the font
definition, that represents a given character. Using the index of a glyph allows
only the glyphs actually displayed to be used, greatly reducing the size of a Flash
file. The relative placement of glyphs is also specified in the text string giving
a high degree of control over how a piece of text is rendered.
Creating fonts and text directly using the Transform classes can be very cumbersome. Flagstone provides the Transform Utilities library that allows fonts and text to be created from existing Flash or Java font definitions greatly simplifying the process.
Text fields can be created using the FSDefineTextField class. This class is very flexible and can be used to create editable text fields that allow users to submit information to a server in the same way as HTML forms.
Sound
Flash can supports sounds that are played when an event occurs such as a button
being clicked (FSDefineSound) or streaming sound that allows a soundtrack to be
played while displaying a movie (FSSoundStreamHead, FSSoundStreamBlock). Flash can
play sounds that are compressed using ADPCM or MP3. A high degree of control over
the sound is available - an envelope can be created that controls how a sound fades
in and fades out (FSSound).
Movie Clips
Movie Clips (sprites) contain "pre-packaged" animation sequences that liven up a
movie. Movie clip are defined using the FSDefineMovie class. A Flash file can
contain all the required movie clips or they can be loaded on demand using the
FSGetUrl and FSGetUrl2 classes.
Display List
Shapes, buttons, images and text are placed on the display list using the
FSPlaceObject and FSPlaceObject2 classes. Objects can be removed from the display
list using FSRemoveObject and FSRemoveObject2.
Timelines
A Flash file is composed of a series of frames. Each frame contains definitions
of objects to be displayed and the sequence of commands used to update the display
list. Frames in a movie are displayed using the FSShowFrame class. This instructs
the Flash Player to display all the objects currently in the display list.
Successive frames in a movie or movie clip are delimited by successive FSShowFrame
objects. The timeline is controlled by FSGotoFrame, FSGotoFrame2 and FSGotoLabel
actions which instruct the Flash Player to play the movie or clip starting at a
particular frame.
Actions
Actions are executed when a frame is displayed, a button is clicked or an event
occurs in a movie clip. The FSDoAction class is used to define the list of actions
for a given frame. The FSButtonEvent class defines actions for a button and the
FSClipEvent class in conjunction with the FSPlaceObject2 class is used to define
the events for a movie clip.
FSPush is used to push integers, strings, double precision floating point numbers onto the Stack. The byte-codes that represent stack-based actions are supported using the FSAction class. The type assigned to instances of this class identify the type of action to be executed.
Control flow is performed using FSIf and FSJump.
FSGetUrl and FSGetUrl2 are used to load web pages, movies and movie clips. FSGetUrl2 also allows variables to be loaded and submitted to and from a remote server. XML formatted data can also be exchanged using the XMLSocket class allowing direct communication with a server process.
With the introduction of Flash 5 the concept of classes and objects (in the programming sense) was introduced to Flash. The Flash Player supports several pre-defined classes for different data types such as Strings, Integers and XML formatted data structures. Classes are also used access to system resources such as the mouse or other pointing device supported by the host device. The Flash Player also supports Socket objects which allow XML formatted data to be exchanged between the Flash Player and a remote server.
Objects are instantiated and assigned to variables in Memory. Instances of pre-defined classes (String, Integer, etc.) are created by pushing any arguments followed by the name of the class onto the Stack then executing a NamedObject action. Methods are executed by pushing the arguments, if any, followed by a reference to the object (usually through a variable) and a string containing the name of a method. The ExecuteMethod pops the items from the stack and executes the function associated with the method definition, returning any results to the stack.
User defined classes and objects can also be defined and created. User-defined classes are created by pushing pairs of strings and default values onto the Stack for each member variable then executing the NewObject action. A reference to the object in memory is pushed on the Stack. Assigning this reference to a variable allows the object to be referenced in future calculations. Methods can be defined by using the FSNewFunction class to define a function and then assigning it to a member variable of the class using the SetAttribute action. Methods can be executed using the ExecuteMethod action using the same sequence of operations described previously.
The introduction of classes and objects is significant. Future releases of Flash and the Flash Player can have new functionality added using the general purpose mechanism describe above for creating objects and executing methods without adding new tags to the file format specification.
ActionScript is a high-level language provided by Macromedia to control and manipulate objects using the Flash authoring program. ActionScript is compiled into the byte-codes and actions supported by Transform when a movie is encoded to the Flash file format. Programming directly using the actions defined in Transform is analogous to assembly-language programming for microprocessors. Creating programs at this low level is relatively cumbersome, prone to error and difficult to debug. To address this, Flagstone developed Translate, a Java based program that compiles ActionScript into the objects supported in the Transform SWF Library. This greatly simplifies the creation of programs that can be used in Flash files. Although Translate is current only available for Java, compiled scripts can easily be added to programs developed in C++ by compiling the ActionScript and encoding the objects to a Flash file. The file can then be parsed using the FSMovie class and the compiled actions extracted and added to the relevant objects in the current movie.
|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |