Flash - Perl extension for Flash libswf.a
use Flash;
Flash is a gives you PERL access to libswf.a as programmed by Paul Haeberli. To obtain the library go to http://reality.sgi.com/grafica/flash/
This has now been modifed by me for my own nefarious uses but it is based on code by The Labs (http://the-labs.com/FlashPerl/).
It is part of a suite of SWF manipulation modules, Flash::*, for the analysis, creation, decomposition and general hacking of Shockwave Flash movies, by Simon Wistow
Start a new SWF file. the rgb values, which must be between 0 and 1 will set the background colour. They default to 1.
Outputs the SWF file.
Used to label the frame (surprisingly) so that action_goto_label can jump to it. Good place for secret messages :)
Shows the current frame and starts a new one.
Selects the frame you should add commands to.
returns the frame you are currently working on.
Sets the global add colour to the rgba value specified. This colour is used by place_object, modify_object and add_button_record. This colour is added to the original colour of the object when it is drawn. These values can be positive or negative.
Sets the global multiply colour to the rgba value specified. This colour is used by place_object, modify_object and add_button_record. The colour of the object will be multiplied by the values given when it is drawn. These values can be positive or negative.
Selects an area on the drawing surface for future drawing. This defaults to the screen area of the Flash movie.
Defines a 2D orthographic mapping of user coordinates onto the current viewport. This defaults to be a one to one mapping with the area of the Flash movie. If a perspective transformation is desired, swf_perspective may be used.
Define a perspective projection transformation. Fovy selects the field-of-view angle in the y direction. Aspect should be set to the aspect ratio of the viewport we're drawing into. The near and far clipping planes are specified by near and far. Various distortion artifacts may appear when using a perspective projection, since Flash players only have a 2D matrix. Some of these can be quite disturbing.
Defines the viewer's position in polar coordinates. dist selects the distance from the viewpoint to the world space origin. Azimuth defines the azimuthal angle in the x-y plane, measured from the y axis. Incidence specifies the angle of incidence in the y-z plane, measured from the z axis. The incidence angle is the angle of the viewport relative to the z axis. Twist defines the amount that the viewpoint is to be rotated around the line of sight using the right-hand rule.
Defines a viewing transformation by giving the view position vx, vy, vz, and the coordinates of a reference point in the scene at px, py, pz. Twist controls a rotation along the viewer's z axis.
Push the current transformation matrix onto the stack.
Restore a previous transformation matrix.
Scale the current transformation.
Translate the current transformation.
Rotate the current transformation by the given angle about x, y, or z axis. The axis may be 'x', 'y', or 'z'.
This enables or disables rounding of the translation when objects are places or moved. There are times when text can be made more readable if position rounding is turned on.
Places the object with the ID specified to be placed at the specified depth. There is a maximum on both those figures of 65535 and they both must be more than 1.
Modify the objects at the given depth. HOW can either be FlashModColour, FlashModMatrix or FlashModColour|FlashModMatrix.
Remove the objects at the given depth
Return the next free Id.
Buttons provide the interaction in Flash movies. The functions below are used to define the appearance and behavior of a button. In typical application, a complete button will look something like this:
start_button(objid,TYPE_MENUBUTTON); add_buttonrecord(FlashBSHitTest|FlashBSDown|FlashBSOver|FlashBSUp,RECTFILLID,3000); on_condition(FlashMenuEnter); swf_actionGetURL("overlay.swf","_level1"); on_condition(FlashMenuExit); swf_actionGetURL("","_level1"); end_button();
A button definition always starts with start_button and ends with end_button. There should be one or more add_buttonrecord calls, and zero or more calls to on_condition followed by action elements. To make a button appear on the screen, you will have to use place_object to position it in a frame.
Starts the definition of a button with the specified object id. type can have the value TYPE_MENUBUTTON or TYPE_PUSHBUTTON. this will select whether focus can move from the button while the mouse is down. If type is TYPE_MENUBUTTON, focus travels, while if type is TYPE_PUSHBUTTON, focus stays with the button.
Controls the location, appearance and active area of the current button. There must be one or more calls to this function to indicate what object to associate with FlashBSHitTest (the button hit test area) and BSUp, BSOver and BSDown (the three button state bits). This uses the current mulcolor, addcolor and matrix to position and color the specified object. There can be any number of button records in a single button.
Describes a transition used to trigger an action list.
These transitions apply to buttons of type TYPE_MENUBUTTON:
FlashIdletoOverUp FlashOverUptoIdle FlashOverUptoOverDown FlashOverDowntoOverUp
FlashIdletoOverDown FlashOutDowntoIdle
FlashMenuEnter = (FlashIdletoOverUp|FlashIdletoOverDown) FlashMenuExit = (FlashOverUptoIdle|FlashOverDowntoIdle)
These transitions apply to buttons of type TYPE_PUSHBUTTON:
FlashIdletoOverUp FlashOverUptoIdle FlashOverUptoOverDown FlashOverDowntoOverUp
FlashOverDowntoOutDown FlashOutDowntoOverDown FlashOutDowntoIdle
FlashButtonEnter = (FlashIdletoOverUp|FlashOutDowntoOverDown) FlashButtonExit = (FlashOverUptoIdle|FlashOverDowntoOutDown)
The call to swf_oncondition should be followed by one or more action elements as described above.
Completes the definition of a button.
Symbols are tiny Flash movies that can be played simultaneously. To define a symbol, call this function with the objid that you want to use to identify the symbol.
Completes the symbol.
An action list is described by a sequence of calls as shown here:
start_doaction(); action_goto_frame(143); action_play(); end_doaction(); You can put lots and lots of actions between startDoAction and endDoAction to create an actionlist. All the actions are performed in sequence after the current frame is drawn.
This starts the description of an action list for the current frame. There should be only one action list associated with a single frame in the Flash movie.
Ends the list of actions to perform for the current frame.
Starts playing the Flash movie from the current frame.
Stops playing the Flash movie at the current frame.
Causes the Flash movie to display the specified frame and stop.
Gets the specified URL. TARGET indicates what to do with the content from the URL. If target is ``_level0'', data from the URL will replace the current Flash movie. If target is ``_level1'', The new URL will displayed on top of the current Flash movie.
Goes forward one frame.
Goes backward one frame.
Toggles between high and low quality.
Stops playing sound.
If the specified frame has not been loaded, skip the specified number of actions in the action list. This can be used to show an animation while frames are being loaded.
Set the context for actions. This can be used to control other Flash movies that are playing.
Causes the Flash movie to display the frame with the given label, and stop.
Defines a font name specifies the PostScript name of the font to use. This font also becomes the current font.
Sets the current font to the font indicated by fontid.
Sets the current font size to the height indicated.
Sets the current font slant to the slant angle indicated. Positive values slant forward, negative values slant backwards.
Sets the current font tracking to the specified value. The is used to adjust the spacing between letters in text. Positive values increase the amount of space, while negative numbers decrease the amount of space. A tracking value of 1.0 will add the currenet font height's worth of space between letters.
Returns the height of a capital 'A' and a lowercase 'x' in the current font;
Sets the width of the font outlines.
Returns the width of the text using the current font settings.
Define some text using the current font values. setting DOCENTER to 1 will center the text in the x axis.
Defines a bitmap given the name of a .gif .rgb .jpeg or .fi image. The image will be converted into Flash jpeg or Flash color map format.
Returns the size of a previously defined bitmap. xsize and ysize are the width and height in pixels.
Defines a line segment from x1,y1 to x2,y2 with the given line width.
Defines an outlined rectangle from x1,y1 to x2,y2 with the given line width. If width is 0.0, the rectangle is filled instead of stroked.
Starts the definition of a complex shape. An object with the specified objid will be created.
Sets the current line style. The color is given by r, g, b, and a. width specifies the thickness of the line. If a width of 0.0 is given, no lines are drawn.
Turns off filling.
Sets the current fill style to a solid fill with the the specified color.
Sets the current fill mode clipped bitmap fill. Pixels from the previously defined bitmapid will be used to fill areas.
Sets the current fill mode tiled bitmap fill. Pixels from the previously defined bitmapid will be used to fill areas. The image will repeat across the area.
This moves the current position to the given x,y.
Draws a line from the current position to x,y. Then the current position is set to x,y.
Draws a quadradic bezier curve starting at the current position using x1,y1 as an off curve control point and using x2,y2 as the end point. Then the current position is set to x2,y2.
Draws a cubic bezier curve starting at the current position using x1,y1 and x2,y2 as off curve control points and using x3,y3 as the end point. Then the current position is set to x3,y3. The cubic bezier curve is converted to the quadradic beziers used internally by Flash.
Draws a circular arc from ang1 to ang2. The center of the circle is given by x, and y. r specifies the radius of the arc.
Completes the definition of the current shape.
Sets the sample rate for future sound definitions to the specified value. The only rates supported are 5500, 11000, 22000 and 44000 sampels pre second.
Selects the number of bits that sound samples should be compressed to when sounds are defined. The only values supported are 0, 2, 3, 4 and 5. The value of 0 is used to create sounds with no compression. NB: It looks like the Flash plugin on some PC's have trouble playing uncompressed sound.
Defines a sound.
Associates sounds with an already defined button. outid, overid and downid can be previously defined sounds, or 0 if no sound should be playd for the particular transition.
Adds the samples to the movie starting at the current frame. The number of frames that the sound plays for is returned.
Starts playing the sound defined by soundid.
Simon Wistow <simon@twoshortplanks.com> based on code orginally by Rene K. Mueller <kiwi@the-labs.com>
perl(1),
Flash::Object