Shockwave Flash functions SWF PHP offers the ability to create Shockwave Flash files via Paul Haeberli's libswf module. You can download libswf at &url.swf;. Once you have libswf all you need to do is to configure where DIR is a location containing the directories include and lib. The include directory has to contain the swf.h file and the lib directory has to contain the libswf.a file. If you unpack the libswf distribution the two files will be in one directory. Consequently you will have to copy the files to the proper location manually. Once you've successfully installed PHP with Shockwave Flash support you can then go about creating Shockwave files from PHP. You would be surprised at what you can do, take the following code: SWF example ]]> SWF support was added in PHP 4 RC2. The libswf does not have support for Windows. The development of that library has been stopped, and the source is not available to port it to another systems. swf_openfile Open a new Shockwave Flash file Description void swf_openfile string filename float width float height float framerate float r float g float b The swf_openfile function opens a new file named filename with a width of width and a height of height a frame rate of framerate and background with a red color of r a green color of g and a blue color of b. The swf_openfile must be the first function you call, otherwise your script will cause a segfault. If you want to send your output to the screen make the filename: "php://stdout" (support for this is in 4.0.1 and up). swf_closefile Close the current Shockwave Flash file Description void swf_closefile int return_file Close a file that was opened by the swf_openfile function. If the return_file parameter is set then the contents of the SWF file are returned from the function. Creating a simple flash file based on user input and outputting it and saving it in a database ]]> swf_labelframe Label the current frame Description void swf_labelframe string name Label the current frame with the name given by the name parameter. swf_showframe Display the current frame Description void swf_showframe The swf_showframe function will output the current frame. swf_setframe Switch to a specified frame Description void swf_setframe int framenumber The swf_setframe changes the active frame to the frame specified by framenumber. swf_getframe Get the frame number of the current frame Description int swf_getframe The swf_getframe function gets the number of the current frame. swf_mulcolor Sets the global multiply color to the rgba value specified Description void swf_mulcolor float r float g float b float a The swf_mulcolor function sets the global multiply color to the rgba color specified. This color is then used (implicitly) by the swf_placeobject, swf_modifyobject and the swf_addbuttonrecord functions. The color of the object will be multiplied by the rgba values when the object is written to the screen. The rgba values can be either positive or negative. swf_addcolor Set the global add color to the rgba value specified Description void swf_addcolor float r float g float b float a The swf_addcolor function sets the global add color to the rgba color specified. This color is then used (implicitly) by the swf_placeobject, swf_modifyobject and the swf_addbuttonrecord functions. The color of the object will be add by the rgba values when the object is written to the screen. The rgba values can be either positive or negative. swf_placeobject Place an object onto the screen Description void swf_placeobject int objid int depth Places the object specified by objid in the current frame at a depth of depth. The objid parameter and the depth must be between 1 and 65535. This uses the current mulcolor (specified by swf_mulcolor) and the current addcolor (specified by swf_addcolor) to color the object and it uses the current matrix to position the object. Full RGBA colors are supported. swf_modifyobject Modify an object Description void swf_modifyobject int depth int how Updates the position and/or color of the object at the specified depth, depth. The parameter how determines what is updated. how can either be the constant MOD_MATRIX or MOD_COLOR or it can be a combination of both (MOD_MATRIX|MOD_COLOR). MOD_COLOR uses the current mulcolor (specified by the function swf_mulcolor) and addcolor (specified by the function swf_addcolor) to color the object. MOD_MATRIX uses the current matrix to position the object. swf_removeobject Remove an object Description void swf_removeobject int depth Removes the object at the depth specified by depth. swf_nextid Returns the next free object id Description int swf_nextid The swf_nextid function returns the next available object id. swf_startdoaction Start a description of an action list for the current frame Description void swf_startdoaction The swf_startdoaction function starts the description of an action list for the current frame. This must be called before actions are defined for the current frame. swf_actiongotoframe Play a frame and then stop Description void swf_actiongotoframe int framenumber The swf_actionGotoFrame function will go to the frame specified by framenumber, play it, and then stop. swf_actiongeturl Get a URL from a Shockwave Flash movie Description void swf_actiongeturl string url string target The swf_actionGetUrl function gets the URL specified by the parameter url with the target target. swf_actionnextframe Go foward one frame Description void swf_actionnextframe Go foward one frame. swf_actionprevframe Go backwards one frame Description void swf_actionprevframe swf_actionplay Start playing the flash movie from the current frame Description void swf_actionplay Start playing the flash movie from the current frame. swf_actionstop Stop playing the flash movie at the current frame Description void swf_actionstop Stop playing the flash movie at the current frame. swf_actiontogglequality Toggle between low and high quality Description void swf_actiontogglequality Toggle the flash movie between high and low quality. swf_actionwaitforframe Skip actions if a frame has not been loaded Description void swf_actionwaitforframe int framenumber int skipcount The swf_actionWaitForFrame function will check to see if the frame, specified by the framenumber parameter has been loaded, if not it will skip the number of actions specified by the skipcount parameter. This can be useful for "Loading..." type animations. swf_actionsettarget Set the context for actions Description void swf_actionsettarget string target The swf_actionSetTarget function sets the context for all actions. You can use this to control other flash movies that are currently playing. swf_actiongotolabel Display a frame with the specified label Description void swf_actiongotolabel string label The swf_actionGotoLabel function displays the frame with the label given by the label parameter and then stops. swf_enddoaction End the current action Description void swf_enddoaction Ends the current action started by the swf_startdoaction function. swf_defineline Define a line Description void swf_defineline int objid float x1 float y1 float x2 float y2 float width The swf_defineline defines a line starting from the x coordinate given by x1 and the y coordinate given by y1 parameter. Up to the x coordinate given by the x2 parameter and the y coordinate given by the y2 parameter. It will have a width defined by the width parameter. swf_definerect Define a rectangle Description void swf_definerect int objid float x1 float y1 float x2 float y2 float width The swf_definerect defines a rectangle with an upper left hand coordinate given by the x, x1, and the y, y1. And a lower right hand coordinate given by the x coordinate, x2, and the y coordinate, y2 . Width of the rectangles border is given by the width parameter, if the width is 0.0 then the rectangle is filled. swf_definepoly Define a polygon Description void swf_definepoly int objid array coords int npoints float width The swf_definepoly function defines a polygon given an array of x, y coordinates (the coordinates are defined in the parameter coords). The parameter npoints is the number of overall points that are contained in the array given by coords. The width is the width of the polygon's border, if set to 0.0 the polygon is filled. swf_startshape Start a complex shape Description void swf_startshape int objid The swf_startshape function starts a complex shape, with an object id given by the objid parameter. swf_shapelinesolid Set the current line style Description void swf_shapelinesolid float r float g float b float a float width The swf_shapeLineSolid function sets the current line style to the color of the rgba parameters and width to the width parameter. If 0.0 is given as a width then no lines are drawn. swf_shapefilloff Turns off filling Description void swf_shapefilloff The swf_shapeFillOff function turns off filling for the current shape. swf_shapefillsolid Set the current fill style to the specified color Description void swf_shapefillsolid float r float g float b float a The swf_shapeFillSolid function sets the current fill style to solid, and then sets the fill color to the values of the rgba parameters. swf_shapefillbitmapclip Set current fill mode to clipped bitmap Description void swf_shapefillbitmapclip int bitmapid Sets the fill to bitmap clipped, empty spaces will be filled by the bitmap given by the bitmapid parameter. swf_shapefillbitmaptile Set current fill mode to tiled bitmap Description void swf_shapefillbitmaptile int bitmapid Sets the fill to bitmap tile, empty spaces will be filled by the bitmap given by the bitmapid parameter (tiled). swf_shapemoveto Move the current position Description void swf_shapemoveto float x float y The swf_shapeMoveTo function moves the current position to the x coordinate given by the x parameter and the y position given by the y parameter. swf_shapelineto Draw a line Description void swf_shapelineto float x float y The swf_shapeLineTo draws a line to the x,y coordinates given by the x parameter & the y parameter. The current position is then set to the x,y parameters. swf_shapecurveto Draw a quadratic bezier curve between two points Description void swf_shapecurveto float x1 float y1 float x2 float y2 The swf_shapecurveto function draws a quadratic bezier curve from the x coordinate given by x1 and the y coordinate given by y1 to the x coordinate given by x2 and the y coordinate given by y2. The current position is then set to the x,y coordinates given by the x2 and y2 parameters swf_shapecurveto3 Draw a cubic bezier curve Description void swf_shapecurveto3 float x1 float y1 float x2 float y2 float x3 float y3 Draw a cubic bezier curve using the x,y coordinate pairs x1, y1 and x2,y2 as off curve control points and the x,y coordinate x3, y3 as an endpoint. The current position is then set to the x,y coordinate pair given by x3,y3. swf_shapearc Draw a circular arc Description void swf_shapearc float x float y float r float ang1 float ang2 The swf_shapeArc function draws a circular arc from angle A given by the ang1 parameter to angle B given by the ang2 parameter. The center of the circle has an x coordinate given by the x parameter and a y coordinate given by the y, the radius of the circle is given by the r parameter. swf_endshape Completes the definition of the current shape Description void swf_endshape The swf_endshape completes the definition of the current shape. swf_definefont Defines a font Description void swf_definefont int fontid string fontname The swf_definefont function defines a font given by the fontname parameter and gives it the id specified by the fontid parameter. It then sets the font given by fontname to the current font. swf_setfont Change the current font Description void swf_setfont int fontid The swf_setfont sets the current font to the value given by the fontid parameter. swf_fontsize Change the font size Description void swf_fontsize float size The swf_fontsize function changes the font size to the value given by the size parameter. swf_fontslant Set the font slant Description void swf_fontslant float slant Set the current font slant to the angle indicated by the slant parameter. Positive values create a foward slant, negative values create a negative slant. swf_fonttracking Set the current font tracking Description void swf_fonttracking float tracking Set the font tracking to the value specified by the tracking parameter. This function is used to increase the spacing between letters and text, positive values increase the space and negative values decrease the space between letters. swf_getfontinfo The height in pixels of a capital A and a lowercase x Description array swf_getfontinfo The swf_getfontinfo function returns an associative array with the following parameters: Aheight - The height in pixels of a capital A. xheight - The height in pixels of a lowercase x. swf_definetext Define a text string Description void swf_definetext int objid string str int docenter Define a text string (the str parameter) using the current font and font size. The docenter is where the word is centered, if docenter is 1, then the word is centered in x. swf_textwidth Get the width of a string Description float swf_textwidth string str The swf_textwidth function gives the width of the string, str, in pixels, using the current font and font size. swf_definebitmap Define a bitmap Description void swf_definebitmap int objid string image_name The swf_definebitmap function defines a bitmap given a GIF, JPEG, RGB or FI image. The image will be converted into a Flash JPEG or Flash color map format. swf_getbitmapinfo Get information about a bitmap Description array swf_getbitmapinfo int bitmapid The swf_getbitmapinfo function returns an array of information about a bitmap given by the bitmapid parameter. The returned array has the following elements: "size" - The size in bytes of the bitmap. "width" - The width in pixels of the bitmap. "height" - The height in pixels of the bitmap. swf_startsymbol Define a symbol Description void swf_startsymbol int objid Define an object id as a symbol. Symbols are tiny flash movies that can be played simultaneously. The objid parameter is the object id you want to define as a symbol. swf_endsymbol End the definition of a symbol Description void swf_endsymbol The swf_endsymbol function ends the definition of a symbol that was started by the swf_startsymbol function. swf_startbutton Start the definition of a button Description void swf_startbutton int objid int type The swf_startbutton function starts off the definition of a button. The type parameter can either be TYPE_MENUBUTTON or TYPE_PUSHBUTTON. The TYPE_MENUBUTTON constant allows the focus to travel from the button when the mouse is down, TYPE_PUSHBUTTON does not allow the focus to travel when the mouse is down. swf_addbuttonrecord Controls location, appearance and active area of the current button Description void swf_addbuttonrecord int states int shapeid int depth The swf_addbuttonrecord function allows you to define the specifics of using a button. The first parameter, states, defines what states the button can have, these can be any or all of the following constants: BSHitTest, BSDown, BSOver or BSUp. The second parameter, the shapeid is the look of the button, this is usually the object id of the shape of the button. The depth parameter is the placement of the button in the current frame. <function>swf_addbuttonrecord</function> function example swf_oncondition Describe a transition used to trigger an action list Description void swf_oncondition int transition The swf_onCondition function describes a transition that will trigger an action list. There are several types of possible transitions, the following are for buttons defined as TYPE_MENUBUTTON: IdletoOverUp OverUptoIdle OverUptoOverDown OverDowntoOverUp IdletoOverDown OutDowntoIdle MenuEnter (IdletoOverUp|IdletoOverDown) MenuExit (OverUptoIdle|OverDowntoIdle) For TYPE_PUSHBUTTON there are the following options: IdletoOverUp OverUptoIdle OverUptoOverDown OverDowntoOverUp OverDowntoOutDown OutDowntoOverDown OutDowntoIdle ButtonEnter (IdletoOverUp|OutDowntoOverDown) ButtonExit (OverUptoIdle|OverDowntoOutDown) swf_endbutton End the definition of the current button Description void swf_endbutton The swf_endButton function ends the definition of the current button. swf_viewport Select an area for future drawing Description void swf_viewport float xmin float xmax float ymin float ymax The swf_viewport function selects an area for future drawing for xmin to xmax and ymin to ymax, if this function is not called the area defaults to the size of the screen. swf_ortho Defines an orthographic mapping of user coordinates onto the current viewport Description void swf_ortho float xmin float xmax float ymin float ymax float zmin float zmax The swf_ortho funcion defines a orthographic mapping of user coordinates onto the current viewport. swf_ortho2 Defines 2D orthographic mapping of user coordinates onto the current viewport Description void swf_ortho2 float xmin float xmax float ymin float ymax The swf_ortho2 function defines a two dimensional orthographic mapping of user coordinates onto the current viewport, this defaults to one to one mapping of the area of the Flash movie. If a perspective transformation is desired, the swf_perspective function can be used. swf_perspective Define a perspective projection transformation Description void swf_perspective float fovy float aspect float near float far The swf_perspective function defines a perspective projection transformation. The fovy parameter is field-of-view angle in the y direction. The aspect parameter should be set to the aspect ratio of the viewport that is being drawn onto. The near parameter is the near clipping plane and the far parameter is the far clipping plane. Various distortion artifacts may appear when performing a perspective projection, this is because Flash players only have a two dimensional matrix. Some are not to pretty. swf_polarview Define the viewer's position with polar coordinates Description void swf_polarview float dist float azimuth float incidence float twist The swf_polarview function defines the viewer's position in polar coordinates. The dist parameter gives the distance between the viewpoint to the world space origin. The azimuth parameter defines the azimuthal angle in the x,y coordinate plane, measured in distance from the y axis. The incidence parameter defines the angle of incidence in the y,z plane, measured in distance from the z axis. The incidence angle is defined as the angle of the viewport relative to the z axis. Finally the twist specifies the amount that the viewpoint is to be rotated about the line of sight using the right hand rule. swf_lookat Define a viewing transformation Description void swf_lookat float view_x float view_y float view_z float reference_x float reference_y float reference_z float twist The swf_lookat function defines a viewing transformation by giving the viewing position (the parameters view_x, view_y, and view_z) and the coordinates of a reference point in the scene, the reference point is defined by the reference_x, reference_y , and reference_z parameters. The twist controls the rotation along with viewer's z axis. swf_pushmatrix Push the current transformation matrix back unto the stack Description void swf_pushmatrix The swf_pushmatrix function pushes the current transformation matrix back onto the stack. swf_popmatrix Restore a previous transformation matrix Description void swf_popmatrix The swf_popmatrix function pushes the current transformation matrix back onto the stack. swf_scale Scale the current transformation Description void swf_scale float x float y float z The swf_scale scales the x coordinate of the curve by the value of the x parameter, the y coordinate of the curve by the value of the y parameter, and the z coordinate of the curve by the value of the z parameter. swf_translate Translate the current transformations Description void swf_translate float x float y float z The swf_translate function translates the current transformation by the x, y, and z values given. swf_rotate Rotate the current transformation Description void swf_rotate float angle string axis The swf_rotate rotates the current transformation by the angle given by the angle parameter around the axis given by the axis parameter. Valid values for the axis are 'x' (the x axis), 'y' (the y axis) or 'z' (the z axis). swf_posround Enables or Disables the rounding of the translation when objects are placed or moved Description void swf_posround int round The swf_posround function enables or disables the rounding of the translation when objects are placed or moved, there are times when text becomes more readable because rounding has been enabled. The round is whether to enable rounding or not, if set to the value of 1, then rounding is enabled, if set to 0 then rounding is disabled.