diff --git a/functions/ming.xml b/functions/ming.xml
index 6c39909af6..d03afadb49 100755
--- a/functions/ming.xml
+++ b/functions/ming.xml
@@ -1 +1,4257 @@
-
Ming functions for FlashMing (flash)
&warn.experimental;
Introduction
Ming is an open-source (LGPL) library which allows you to create SWF
("Flash") format movies. Ming supports almost all of Flash 4's features,
including: shapes, gradients, bitmaps (pngs and jpegs), morphs ("shape
tweens"), text, buttons, actions, sprites ("movie clips"), streaming mp3,
and color transforms--the only thing that's missing is sound events.
Ming is not an acronym.
Note that all values specifying length, distance, size, etc. are in "twips",
twenty units per pixel. That's pretty much arbitrary, though, since the player
scales the movie to whatever pixel size is specified in the embed/object tag,
or the entire frame if not embedded.
Ming offers a number of advantages over the existing PHP/libswf module.
You can use Ming anywhere you can compile the code, whereas libswf is
closed-source and only available for a few platforms, Windows not one of
them. Ming provides some insulation from the mundane details of the SWF
file format, wrapping the movie elements in PHP objects. Also, Ming is
still being maintained; if there's a feature that you want to see, just
let us know &email.ming;.
Ming was added in PHP 4.0.5.
Installation
To use Ming with PHP, you first need to build and install the Ming
library. Source code and installation instructions are available at the
Ming home page : &url.ming;
along with examples, a small tutorial, and the latest news.
Download the ming archive. Unpack the archive. Go in the
Ming directory. make. make install.
This will build libming.so and install it
into /usr/lib/, and copy
ming.h into /usr/include/.
Edit the PREFIX= line in the
Makefile to change the installation directory.
built into php (unix)
mkdir <phpdir>/ext/ming
cp php_ext/* <phpdir>/ext/ming
cd <phpdir>
./buildconf
./configure --with-ming <other config options>
Build and install php as usual,
Restart web server if necessary
built into php (unix)
download php_ming.so.gz.
uncompress it and copy it to your php modules directory.
(you can find your php module directory by running
php-config --extension-dir).
Now either just add extension=php_ming.so
to your php.ini file, or put
dl('php_ming.so'); at the head of all of your
Ming scripts.
How to use Ming
Ming introduces 13 new object in PHP, all with matching methods and
attributes. To use them, you need to know about
objects.
swfmovie.
swfshape.
swfdisplayitem.
swfgradient.
swfbitmap.
swffill.
swfmorph.
swftext.
swffont.
swftextfield.
swfsprite.
swfbutton.
swfaction.
SWFMovieCreates a new movie object, representing an SWF version 4 movie.Descriptionnew swfmovie
&warn.experimental.func;
swfmovie creates a new movie object,
representing an SWF version 4 movie.
SWFMovie has the following methods :
swfmovie->output,swfmovie->save,
swfmovie->add, swfmovie->remove,
swfmovie->nextframe, swfmovie->setbackground,
swfmovie->setrate, swfmovie->setdimension,
swfmovie->setframes and swfmovie->streammp3.
See examples in :
swfdisplayitem->rotateto, swfshape->setline,
swfshape->addfill... Any example will use this object.
SWFMovie->outputDumps your lovingly prepared movie out.Descriptionvoid swfmovie->output
&warn.experimental.func;
swfmovie->output dumps your lovingly prepared movie out.
In PHP, preceding this with the command
<?php
header('Content-type: application/x-shockwave-flash');
?>
convinces the browser to display this as a flash movie.
See also
swfmovie->save.
See examples in :
swfmovie->streammp3,
swfdisplayitem->rotateto,
swfaction...
Any example will use this method.
SWFMovie->saveSaves your movie in a file.Descriptionvoid swfmovie->savestring filename
&warn.experimental.func;
swfmovie->save saves your movie to the
file named filename.
See also
output.
SWFMovie->addAdds any type of data to a movie.Descriptionvoid swfmovie->addressource instance
&warn.experimental.func;
swfmovie->add adds instance to
the current movie. instance is any type of data :
Shapes, text, fonts, etc. must all be add'ed to the movie to make this work.
For displayable types (shape, text, button, sprite), this returns an
SWFDisplayItem, a handle to the object in a display
list. Thus, you can add the same shape to a movie multiple
times and get separate handles back for each separate instance.
See also all other objects (adding this later), and
swfmovie->remove
See examples in :
swfdisplayitem->rotateto and
swfshape->addfill.
SWFMovie->removeRemoves the object instance from the display list.Descriptionvoid swfmovie->removeresource instance
&warn.experimental.func;
swfmovie->remove removes the object instance
instance from the display list.
See also
swfmovie->add.
SWFMovie->setbackgroundSets the background color.Descriptionvoid swfmovie->setbackgroundint redint greenint blue
&warn.experimental.func;
swfmovie->setbackground sets the background color. Why is
there no rgba version? Think about it. (Actually, that's not such a dumb
question after all- you might want to let the html background show through.
There's a way to do that, but it only works on IE4. Search the
&url.macromedia; site for
details.)
SWFMovie->setrateSets the animation's frame rate.Descriptionvoid swfmovie->setrateint rate
&warn.experimental.func;
swfmovie->setrate sets the frame rate to
rate, in frame per seconds.
Animation will slow down if the player can't render frames fast enough- unless
there's a streaming sound, in which case display frames are sacrificed to
keep sound from skipping.
SWFMovie->setdimensionSets the movie's width and height.Descriptionvoid swfmovie->setdimensionint widthint height
&warn.experimental.func;
swfmovie->setdimension sets the movie's width
to width and height to height.
SWFMovie->setframesSets the total number of frames in the animation.Descriptionvoid swfmovie->setframesstring numberofframes
&warn.experimental.func;
swfmovie->setframes sets the total number of frames
in the animation to numberofframes.
SWFMovie->nextframeMoves to the next frame of the animation.Descriptionvoid swfmovie->nextframe
&warn.experimental.func;
swfmovie->setframes moves to the next frame of
the animation.
SWFMovie->streammp3Streams a MP3 file.Descriptionvoid swfmovie->streammp3string mp3FileName
&warn.experimental.func;
swfmovie->streammp3 streams the mp3 file
mp3FileName. Not very robust in dealing with
oddities (can skip over an initial ID3 tag, but that's about it).
Like SWFShape->addJpegFill, this isn't a stable function- we'll
probably need to make a separate SWFSound object to contain sound types.
Note that the movie isn't smart enough to put enough frames in to contain
the entire mp3 stream- you'll have to add (length of song * frames per second)
frames to get the entire stream in.
Yes, now you can use ming to put that rock and roll devil worship music
into your SWF files. Just don't tell the RIAA.
swfmovie->streammp3 example
<?php
$m = new SWFMovie();
$m->setRate(12.0);
$m->streamMp3("distortobass.mp3");
// use your own MP3
// 11.85 seconds at 12.0 fps = 142 frames
$m->setFrames(142);
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
SWFDisplayItemCreates a new displayitem object.Descriptionnew swfdisplayitem
&warn.experimental.func;
swfdisplayitem creates a new swfdisplayitem object.
Here's where all the animation takes place. After you define a shape,
a text object, a sprite, or a button, you add it to the movie, then use
the returned handle to move, rotate, scale, or skew the thing.
SWFDisplayItem has the following methods : swfdisplayitem->move,
swfdisplayitem->moveto, swfdisplayitem->scaleto,
swfdisplayitem->scale, swfdisplayitem->rotate,
swfdisplayitem->rotateto, swfdisplayitem->skewxto,
swfdisplayitem->skewx, swfdisplayitem->skewytoswfdisplayitem->skewyto, swfdisplayitem->setdepthswfdisplayitem->remove, swfdisplayitem->setnameswfdisplayitem->setratio, swfdisplayitem->addcolor
and swfdisplayitem->multcolor.
SWFDisplayItem->moveToMoves object in global coordinates.Descriptionvoid swfdisplayitem->movetoint xint y
&warn.experimental.func;
swfdisplayitem->moveto moves the current object to
(x,y) in global coordinates.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
See also
swfdisplayitem->move.
SWFDisplayItem->moveMoves object in relative coordinates.Descriptionvoid swfdisplayitem->moveint dxint dy
&warn.experimental.func;
swfdisplayitem->move moves the current object by
(dx,dy) from its
current position.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
See also
swfdisplayitem->moveto.
SWFDisplayItem->scaleToScales the object in global coordinates.Descriptionvoid swfdisplayitem->scaletoint xint y
&warn.experimental.func;
swfdisplayitem->scaleto scales the current object to
(x,y) in global coordinates.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
See also
swfdisplayitem->scale.
SWFDisplayItem->scaleScales the object in relative coordinates.Descriptionvoid swfdisplayitem->scaleint dxint dy
&warn.experimental.func;
swfdisplayitem->scale scales the current object by
(dx,dy) from its
current size.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
See also
swfdisplayitem->scaleto.
SWFDisplayItem->rotateToRotates the object in global coordinates.Descriptionvoid swfdisplayitem->rotatetofloat degrees
&warn.experimental.func;
swfdisplayitem->rotateto set the current object
rotation to degrees degrees in global coordinates.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
This example bring three rotating string from the background to the
foreground. Pretty nice.
swfdisplayitem->rotateto example
<?php
$thetext = "ming!";
$f = new SWFFont("Bauhaus 93.fdb");
$m = new SWFMovie();
$m->setRate(24.0);
$m->setDimension(2400, 1600);
$m->setBackground(0xff, 0xff, 0xff);
// functions with huge numbers of arbitrary
// arguments are always a good idea! Really!
function text($r, $g, $b, $a, $rot, $x, $y, $scale, $string)
{
global $f, $m;
$t = new SWFText();
$t->setFont($f);
$t->setColor($r, $g, $b, $a);
$t->setHeight(960);
$t->moveTo(-($f->getWidth($string))/2, $f->getAscent()/2);
$t->addString($string);
// we can add properties just like a normal php var,
// as long as the names aren't already used.
// e.g., we can't set $i->scale, because that's a function
$i = $m->add($t);
$i->x = $x;
$i->y = $y;
$i->rot = $rot;
$i->s = $scale;
$i->rotateTo($rot);
$i->scale($scale, $scale);
// but the changes are local to the function, so we have to
// return the changed object. kinda weird..
return $i;
}
function step($i)
{
$oldrot = $i->rot;
$i->rot = 19*$i->rot/20;
$i->x = (19*$i->x + 1200)/20;
$i->y = (19*$i->y + 800)/20;
$i->s = (19*$i->s + 1.0)/20;
$i->rotateTo($i->rot);
$i->scaleTo($i->s, $i->s);
$i->moveTo($i->x, $i->y);
return $i;
}
// see? it sure paid off in legibility:
$i1 = text(0xff, 0x33, 0x33, 0xff, 900, 1200, 800, 0.03, $thetext);
$i2 = text(0x00, 0x33, 0xff, 0x7f, -560, 1200, 800, 0.04, $thetext);
$i3 = text(0xff, 0xff, 0xff, 0x9f, 180, 1200, 800, 0.001, $thetext);
for($i=1; $i<=100; ++$i)
{
$i1 = step($i1);
$i2 = step($i2);
$i3 = step($i3);
$m->nextFrame();
}
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
See also
swfdisplayitem->rotate.
SWFDisplayItem->RotateRotates in relative coordinates.Descriptionvoid swfdisplayitem->rotatefloat ddegrees
&warn.experimental.func;
swfdisplayitem->rotate rotates the current object
by ddegrees degrees from its current rotation.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
See also
swfdisplayitem->rotateto.
SWFDisplayItem->skewXToSets the X-skew.Descriptionvoid swfdisplayitem->skewxtofloat degrees
&warn.experimental.func;
swfdisplayitem->skewxto sets the
x-skew to degrees. For degrees
is 1.0, it means a 45-degree forward slant. More is more forward,
less is more backward.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
See also
swfdisplayitem->skewx,
swfdisplayitem->skewy and
swfdisplayitem->skewyto.
SWFDisplayItem->skewXSets the X-skew.Descriptionvoid swfdisplayitem->skewxfloat ddegrees
&warn.experimental.func;
swfdisplayitem->skewx adds ddegrees
to current x-skew.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
See also
swfdisplayitem->skewx,
swfdisplayitem->skewy and
swfdisplayitem->skewyto.
SWFDisplayItem->skewYToSets the Y-skew.Descriptionvoid swfdisplayitem->skewytofloat degrees
&warn.experimental.func;
swfdisplayitem->skewyto sets the
y-skew to degrees. For degrees
is 1.0, it means a 45-degree forward slant. More is more upward,
less is more downward.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
See also
swfdisplayitem->skewy,
swfdisplayitem->skewx and
swfdisplayitem->skewxto.
SWFDisplayItem->skewYSets the Y-skew.Descriptionvoid swfdisplayitem->skewyfloat ddegrees
&warn.experimental.func;
swfdisplayitem->skewy adds ddegrees
to current y-skew.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
See also
swfdisplayitem->skewyto,
swfdisplayitem->skewx and
swfdisplayitem->skewxto.
SWFDisplayItem->setDepthSets z-orderDescriptionvoid swfdisplayitem->setdepthfloat depth
&warn.experimental.func;
swfdisplayitem->rotate sets the object's
z-order to depth. Depth defaults to the
order in which instances are created (by add'ing a shape/text to
a movie)- newer ones are on top of older ones. If two objects are
given the same depth, only the later-defined one can be moved.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
SWFDisplayItem->removeRemoves the object from the movieDescriptionvoid swfdisplayitem->remove
&warn.experimental.func;
swfdisplayitem->remove removes this object from
the movie's display list.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
See also
swfmovie->add.
SWFDisplayItem->setNameSets the object's nameDescriptionvoid swfdisplayitem->setnamestring name
&warn.experimental.func;
swfdisplayitem->setname sets the object's name to
name, for targetting with action script.
Only useful on sprites.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
SWFDisplayItem->setRatioSets the object's ratio.Descriptionvoid swfdisplayitem->setratiofloat ratio
&warn.experimental.func;
swfdisplayitem->setratio sets the object's ratio
to ratio. Obviously only useful for morphs.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
This simple example will morph nicely three concentric circles.
swfdisplayitem->setname example
<?php
$p = new SWFMorph();
$g = new SWFGradient();
$g->addEntry(0.0, 0, 0, 0);
$g->addEntry(0.16, 0xff, 0xff, 0xff);
$g->addEntry(0.32, 0, 0, 0);
$g->addEntry(0.48, 0xff, 0xff, 0xff);
$g->addEntry(0.64, 0, 0, 0);
$g->addEntry(0.80, 0xff, 0xff, 0xff);
$g->addEntry(1.00, 0, 0, 0);
$s = $p->getShape1();
$f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT);
$f->scaleTo(0.05);
$s->setLeftFill($f);
$s->movePenTo(-160, -120);
$s->drawLine(320, 0);
$s->drawLine(0, 240);
$s->drawLine(-320, 0);
$s->drawLine(0, -240);
$g = new SWFGradient();
$g->addEntry(0.0, 0, 0, 0);
$g->addEntry(0.16, 0xff, 0, 0);
$g->addEntry(0.32, 0, 0, 0);
$g->addEntry(0.48, 0, 0xff, 0);
$g->addEntry(0.64, 0, 0, 0);
$g->addEntry(0.80, 0, 0, 0xff);
$g->addEntry(1.00, 0, 0, 0);
$s = $p->getShape2();
$f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT);
$f->scaleTo(0.05);
$f->skewXTo(1.0);
$s->setLeftFill($f);
$s->movePenTo(-160, -120);
$s->drawLine(320, 0);
$s->drawLine(0, 240);
$s->drawLine(-320, 0);
$s->drawLine(0, -240);
$m = new SWFMovie();
$m->setDimension(320, 240);
$i = $m->add($p);
$i->moveTo(160, 120);
for($n=0; $n<=1.001; $n+=0.01)
{
$i->setRatio($n);
$m->nextFrame();
}
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
SWFDisplayItem->addColorAdds the given color to this item's color transform.Descriptionvoid swfdisplayitem->addcolorint redint greenint blueint a
&warn.experimental.func;
swfdisplayitem->addcolor adds the color to
this item's color transform. The color is given in its RGB form.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
SWFDisplayItem->multColorMultiplies the item's color transform.Descriptionvoid swfdisplayitem->multcolorint redint greenint blueint a
&warn.experimental.func;
swfdisplayitem->multcolor multiplies the item's
color transform by the given values.
The object may be a swfshape, a
swfbutton, a swftext or a
swfsprite object. It must have been added using
the swfmovie->add.
This simple example will modify your picture's atmospher
to Halloween (use a landscape or bright picture).
swfdisplayitem->multcolor example
<?php
$b = new SWFBitmap("backyard.jpg");
// note use your own picture :-)
$s = new SWFShape();
$s->setRightFill($s->addFill($b));
$s->drawLine($b->getWidth(), 0);
$s->drawLine(0, $b->getHeight());
$s->drawLine(-$b->getWidth(), 0);
$s->drawLine(0, -$b->getHeight());
$m = new SWFMovie();
$m->setDimension($b->getWidth(), $b->getHeight());
$i = $m->add($s);
for($n=0; $n<=20; ++$n)
{
$i->multColor(1.0-$n/10, 1.0, 1.0);
$i->addColor(0xff*$n/20, 0, 0);
$m->nextFrame();
}
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
SWFShapeCreates a new shape object.Descriptionnew swfshape
&warn.experimental.func;
swfshape creates a new shape object.
SWFShape has the following methods : swfshape->setline,
swfshape->addfill, swfshape->setleftfill,
swfshape->setrightfill, swfshape->movepento,
swfshape->movepen, swfshape->drawlineto,
swfshape->drawline, swfshape->drawcurveto
and swfshape->drawcurve.
This simple example will draw a big red elliptic quadrant.
swfshape example
<?php
$s = new SWFShape();
$s->setLine(40, 0x7f, 0, 0);
$s->setRightFill($s->addFill(0xff, 0, 0));
$s->movePenTo(200, 200);
$s->drawLineTo(6200, 200);
$s->drawLineTo(6200, 4600);
$s->drawCurveTo(200, 4600, 200, 200);
$m = new SWFMovie();
$m->setDimension(6400, 4800);
$m->setRate(12.0);
$m->add($s);
$m->nextFrame();
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
SWFShape->setLineSets the shape's line style.Descriptionvoid swfshape->setlineint widthint redint greenint blueint a
&warn.experimental.func;
swfshape->setline sets the shape's line style.
width is the line's width. If width
is 0, the line's style is removed (then, all other arguments are ignored).
If width > 0, then line's color is set to
red, green, blue.
Last parameter a is optional.
swfshape->setline accepts 1, 4 or 5 arguments
(not 3 or 2).
You must declare all line styles before you use them (see example).
This simple example will draw a big "!#%*@", in funny colors and
gracious style.
swfshape->setline example
<?php
$s = new SWFShape();
$f1 = $s->addFill(0xff, 0, 0);
$f2 = $s->addFill(0xff, 0x7f, 0);
$f3 = $s->addFill(0xff, 0xff, 0);
$f4 = $s->addFill(0, 0xff, 0);
$f5 = $s->addFill(0, 0, 0xff);
// bug: have to declare all line styles before you use them
$s->setLine(40, 0x7f, 0, 0);
$s->setLine(40, 0x7f, 0x3f, 0);
$s->setLine(40, 0x7f, 0x7f, 0);
$s->setLine(40, 0, 0x7f, 0);
$s->setLine(40, 0, 0, 0x7f);
$f = new SWFFont('Techno.fdb');
$s->setRightFill($f1);
$s->setLine(40, 0x7f, 0, 0);
$s->drawGlyph($f, '!');
$s->movePen($f->getWidth('!'), 0);
$s->setRightFill($f2);
$s->setLine(40, 0x7f, 0x3f, 0);
$s->drawGlyph($f, '#');
$s->movePen($f->getWidth('#'), 0);
$s->setRightFill($f3);
$s->setLine(40, 0x7f, 0x7f, 0);
$s->drawGlyph($f, '%');
$s->movePen($f->getWidth('%'), 0);
$s->setRightFill($f4);
$s->setLine(40, 0, 0x7f, 0);
$s->drawGlyph($f, '*');
$s->movePen($f->getWidth('*'), 0);
$s->setRightFill($f5);
$s->setLine(40, 0, 0, 0x7f);
$s->drawGlyph($f, '@');
$m = new SWFMovie();
$m->setDimension(3000,2000);
$m->setRate(12.0);
$i = $m->add($s);
$i->moveTo(1500-$f->getWidth("!#%*@")/2, 1000+$f->getAscent()/2);
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
SWFShape->addFillAdds a solid fill to the shape.Descriptionvoid swfshape->addfillint redint greenint blueint a
&warn.experimental.func;
void swfshape->addfillSWFbitmap bitmapint flags
&warn.experimental.func;
void swfshape->addfillSWFGradient gradientint flags
&warn.experimental.func;
swfshape->addfill adds a solid fill to the shape's list
of fill styles. swfshape->addfill accepts three different
types of arguments.
red, green, blue
is a color (RGB mode). Last parameter a is optional.
The bitmap argument is an swfbitmap object.
The flags argument can be one
of the following values : SWFFILL_CLIPPED_BITMAP or SWFFILL_TILED_BITMAP.
Default is SWFFILL_TILED_BITMAP. I think.
The gradient argument is an swfgradient
object. The flags argument can be one of the following values :
SWFFILL_RADIAL_GRADIENT or SWFFILL_LINEAR_GRADIENT. Default is
SWFFILL_LINEAR_GRADIENT. I'm sure about this one. Really.
swfshape->addfill returns an swffill
object for use with the swfshape->setleftfill
and swfshape->setrightfill functions
described below.
See also
swfshape->setleftfill and
swfshape->setrightfill.
This simple example will draw a frame on a bitmap. Ah, here's another buglet in
the flash player- it doesn't seem to care about the second shape's bitmap's
transformation in a morph. According to spec, the bitmap should stretch
along with the shape in this example..
swfshape->addfill example
<?php
$p = new SWFMorph();
$b = new SWFBitmap("alphafill.jpg");
// use your own bitmap
$width = $b->getWidth();
$height = $b->getHeight();
$s = $p->getShape1();
$f = $s->addFill($b, SWFFILL_TILED_BITMAP);
$f->moveTo(-$width/2, -$height/4);
$f->scaleTo(1.0, 0.5);
$s->setLeftFill($f);
$s->movePenTo(-$width/2, -$height/4);
$s->drawLine($width, 0);
$s->drawLine(0, $height/2);
$s->drawLine(-$width, 0);
$s->drawLine(0, -$height/2);
$s = $p->getShape2();
$f = $s->addFill($b, SWFFILL_TILED_BITMAP);
// these two have no effect!
$f->moveTo(-$width/4, -$height/2);
$f->scaleTo(0.5, 1.0);
$s->setLeftFill($f);
$s->movePenTo(-$width/4, -$height/2);
$s->drawLine($width/2, 0);
$s->drawLine(0, $height);
$s->drawLine(-$width/2, 0);
$s->drawLine(0, -$height);
$m = new SWFMovie();
$m->setDimension($width, $height);
$i = $m->add($p);
$i->moveTo($width/2, $height/2);
for($n=0; $n<1.001; $n+=0.03)
{
$i->setRatio($n);
$m->nextFrame();
}
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
SWFShape->setLeftFillSets left rasterizing color.Descriptionvoid swfshape->setleftfillswfgradient fill
&warn.experimental.func;
void swfshape->setleftfillint redint greenint blueint a
&warn.experimental.func;
What this nonsense is about is, every edge segment borders at most two fills.
When rasterizing the object, it's pretty handy to know what those fills are
ahead of time, so the swf format requires these to be specified.
swfshape->setleftfill sets the fill on the left side of
the edge- that is, on the interior if you're defining the outline of the shape in a counter-clockwise
fashion. The fill object is an SWFFill object returned from one of the addFill
functions above.
This seems to be reversed when you're defining a shape in a morph, though.
If your browser crashes, just try setting the fill on the other side.
Shortcut for swfshape->setleftfill($s->addfill($r, $g, $b [, $a]));.
See also
swfshape->setrightfill.
SWFShape->setRightFillSets right rasterizing color.Descriptionvoid swfshape->setrightfillswfgradient fill
&warn.experimental.func;
void swfshape->setrightfillint redint greenint blueint a
&warn.experimental.func;
See also
swfshape->setleftfill.
Shortcut for swfshape->setrightfill($s->addfill($r, $g, $b [, $a]));.
SWFShape->movePenToMoves the shape's pen.Descriptionvoid swfshape->movepentoint xint y
&warn.experimental.func;
swfshape->setrightfill move the shape's pen to
(x,y) in the shape's
coordinate space.
See also
swfshape->movepen,
swfshape->drawcurveto,
swfshape->drawlineto and
swfshape->drawline.
SWFShape->movePenMoves the shape's pen (relative).Descriptionvoid swfshape->movepenint dxint dy
&warn.experimental.func;
swfshape->setrightfill move the shape's pen from
coordinates (current x,current y) to (current x + dx,
current y + dy) in the shape's coordinate space.
See also
swfshape->movepento,
swfshape->drawcurveto,
swfshape->drawlineto and
swfshape->drawline.
SWFShape->drawLineToDraws a line.Descriptionvoid swfshape->drawlinetoint xint y
&warn.experimental.func;
swfshape->setrightfill draws a line (using the
current line style, set by swfshape->setline) from the current
pen position to point (x,y)
in the shape's coordinate space.
See also
swfshape->movepento,
swfshape->drawcurveto,
swfshape->movepen and
swfshape->drawline.
SWFShape->drawLineDraws a line (relative).Descriptionvoid swfshape->drawlineint dxint dy
&warn.experimental.func;
swfshape->setrightfill draws a line (using the current line style
set by swfshape->setline) from the current pen position to
displacement (dx,dy).
See also
swfshape->movepento,
swfshape->drawcurveto,
swfshape->movepen and
swfshape->drawlineto.
SWFShape->drawCurveToDraws a curve.Descriptionvoid swfshape->drawcurvetoint controlxint controlyint anchorxint anchory
&warn.experimental.func;
swfshape->drawcurveto draws a quadratic curve
(using the current line style, set by swfshape->setline)
from the current pen position to
(anchorx,anchory)
using (controlx,controly)
as a control point. That is, head towards the control point,
then smoothly turn to the anchor point.
See also
swfshape->drawlineto,
swfshape->drawline,
swfshape->movepento and
swfshape->movepen.
SWFShape->drawCurveDraws a curve (relative).Descriptionvoid swfshape->drawcurveint controldxint controldyint anchordxint anchordy
&warn.experimental.func;
swfshape->drawcurve draws a quadratic curve
(using the current line style,set by swfshape->setline)
from the current pen position to the relative position
(anchorx,anchory)
using relative control point
(controlx,controly).
That is, head towards the control point, then smoothly turn to the
anchor point.
See also
swfshape->drawlineto,
swfshape->drawline,
swfshape->movepento and
swfshape->movepen.
SWFGradientCreates a gradient objectDescriptionnew swfgradient
&warn.experimental.func;
swfgradient creates a new SWFGradient object.
After you've added the entries to your gradient, you can use the gradient
in a shape fill with the swfshape->addfill method.
SWFGradient has the following methods : swfgradient->addentry.
This simple example will draw a big black-to-white gradient as background,
and a redish disc in its center.
swfgradient example
<?php
$m = new SWFMovie();
$m->setDimension(320, 240);
$s = new SWFShape();
// first gradient- black to white
$g = new SWFGradient();
$g->addEntry(0.0, 0, 0, 0);
$g->addEntry(1.0, 0xff, 0xff, 0xff);
$f = $s->addFill($g, SWFFILL_LINEAR_GRADIENT);
$f->scaleTo(0.01);
$f->moveTo(160, 120);
$s->setRightFill($f);
$s->drawLine(320, 0);
$s->drawLine(0, 240);
$s->drawLine(-320, 0);
$s->drawLine(0, -240);
$m->add($s);
$s = new SWFShape();
// second gradient- radial gradient from red to transparent
$g = new SWFGradient();
$g->addEntry(0.0, 0xff, 0, 0, 0xff);
$g->addEntry(1.0, 0xff, 0, 0, 0);
$f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT);
$f->scaleTo(0.005);
$f->moveTo(160, 120);
$s->setRightFill($f);
$s->drawLine(320, 0);
$s->drawLine(0, 240);
$s->drawLine(-320, 0);
$s->drawLine(0, -240);
$m->add($s);
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
SWFGradient->addEntryAdds an entry to the gradient list.Descriptionvoid swfgradient->addentryfloat ratioint redint greenint blueint a
&warn.experimental.func;
swfgradient->addentry adds an entry to the gradient list.
ratio is a number between 0 and 1 indicating where in
the gradient this color appears. Thou shalt add entries in order of increasing ratio.
red, green, blue
is a color (RGB mode). Last parameter a is optional.
SWFBitmapLoads Bitmap objectDescriptionnew swfbitmapstring filenameint alphafilename
&warn.experimental.func;
swfbitmap creates a new SWFBitmap object from
the Jpeg or DBL file named filename.
alphafilename indicates a MSK file to
be used as an alpha mask for a Jpeg image.
We can only deal with baseline (frame 0) jpegs, no baseline optimized or
progressive scan jpegs!
SWFBitmap has the following methods : swfbitmap->getwidth
and swfbitmap->getheight.
You can't import png images directly, though- have to use the png2dbl
utility to make a dbl ("define bits lossless") file from the png.
The reason for this is that I don't want a dependency on the png library
in ming- autoconf should solve this, but that's not set up yet.
Import PNG files
<?php
$s = new SWFShape();
$f = $s->addFill(new SWFBitmap("png.dbl"));
$s->setRightFill($f);
$s->drawLine(32, 0);
$s->drawLine(0, 32);
$s->drawLine(-32, 0);
$s->drawLine(0, -32);
$m = new SWFMovie();
$m->setDimension(32, 32);
$m->add($s);
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
And you can put an alpha mask on a jpeg fill.
swfbitmap example
<?php
$s = new SWFShape();
// .msk file generated with "gif2mask" utility
$f = $s->addFill(new SWFBitmap("alphafill.jpg", "alphafill.msk"));
$s->setRightFill($f);
$s->drawLine(640, 0);
$s->drawLine(0, 480);
$s->drawLine(-640, 0);
$s->drawLine(0, -480);
$c = new SWFShape();
$c->setRightFill($c->addFill(0x99, 0x99, 0x99));
$c->drawLine(40, 0);
$c->drawLine(0, 40);
$c->drawLine(-40, 0);
$c->drawLine(0, -40);
$m = new SWFMovie();
$m->setDimension(640, 480);
$m->setBackground(0xcc, 0xcc, 0xcc);
// draw checkerboard background
for($y=0; $y<480; $y+=40)
{
for($x=0; $x<640; $x+=80)
{
$i = $m->add($c);
$i->moveTo($x, $y);
}
$y+=40;
for($x=40; $x<640; $x+=80)
{
$i = $m->add($c);
$i->moveTo($x, $y);
}
}
$m->add($s);
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
SWFBitmap->getWidthReturns the bitmap's width.Descriptionint swfbitmap->getwidth
&warn.experimental.func;
swfbitmap->getwidth returns the bitmap's width in pixels.
See also
swfbitmap->getheight.
SWFBitmap->getHeightReturns the bitmap's height.Descriptionint swfbitmap->getheight
&warn.experimental.func;
swfbitmap->getheight returns the bitmap's height in pixels.
See also
swfbitmap->getwidth.
SWFFillLoads SWFFill objectDescription
The swffill object allows you to transform
(scale, skew, rotate) bitmap and gradient fills. swffill
objects are created by the swfshape->addfill methods.
SWFFill has the following methods : swffill->moveto
and swffill->scaleto, swffill->rotateto,
swffill->skewxto and swffill->skewyto.
SWFFill->moveToMoves fill originDescriptionvoid swffill->movetoint xint y
&warn.experimental.func;
swffill->moveto moves fill's origin to
(x,y) in global coordinates.
SWFFill->scaleToSets fill's scaleDescriptionvoid swffill->scaletoint xint y
&warn.experimental.func;
swffill->scaleto sets fill's scale to
x in the x-direction,
y in the y-direction.
SWFFill->rotateToSets fill's rotationDescriptionvoid swffill->rotatetofloat degrees
&warn.experimental.func;
swffill->rotateto sets fill's rotation to
degrees degrees.
SWFFill->skewXToSets fill x-skewDescriptionvoid swffill->skewxtofloat x
&warn.experimental.func;
swffill->skewxto sets fill x-skew to x.
For x is 1.0, it is a is a 45-degree
forward slant. More is more forward, less is more backward.
SWFFill->skewYToSets fill y-skewDescriptionvoid swffill->skewytofloat y
&warn.experimental.func;
swffill->skewyto sets fill y-skew to y.
For y is 1.0, it is a is a 45-degree
upward slant. More is more upward, less is more downward.
SWFMorphCreates a new SWFMorph object.Descriptionnew swfmorph
&warn.experimental.func;
swfmorph creates a new SWFMorph object.
Also called a "shape tween". This thing lets you make those tacky
twisting things that make your computer choke. Oh, joy!
The methods here are sort of weird. It would make more sense to just
have newSWFMorph(shape1, shape2);, but as things are now, shape2 needs
to know that it's the second part of a morph. (This, because it starts
writing its output as soon as it gets drawing commands- if it kept its
own description of its shapes and wrote on completion this and some
other things would be much easier.)
SWFMorph has the following methods : swfmorph->getshape1
and swfmorph->getshape1.
This simple example will morph a big red square into a smaller
blue black-bordered square.
swfmorph example
<?php
$p = new SWFMorph();
$s = $p->getShape1();
$s->setLine(0,0,0,0);
/* Note that this is backwards from normal shapes (left instead of right).
I have no idea why, but this seems to work.. */
$s->setLeftFill($s->addFill(0xff, 0, 0));
$s->movePenTo(-1000,-1000);
$s->drawLine(2000,0);
$s->drawLine(0,2000);
$s->drawLine(-2000,0);
$s->drawLine(0,-2000);
$s = $p->getShape2();
$s->setLine(60,0,0,0);
$s->setLeftFill($s->addFill(0, 0, 0xff));
$s->movePenTo(0,-1000);
$s->drawLine(1000,1000);
$s->drawLine(-1000,1000);
$s->drawLine(-1000,-1000);
$s->drawLine(1000,-1000);
$m = new SWFMovie();
$m->setDimension(3000,2000);
$m->setBackground(0xff, 0xff, 0xff);
$i = $m->add($p);
$i->moveTo(1500,1000);
for($r=0.0; $r<=1.0; $r+=0.1)
{
$i->setRatio($r);
$m->nextFrame();
}
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
SWFMorph->getshape1Gets a handle to the starting shapeDescriptionmixed swfmorph->getshape1
&warn.experimental.func;
swfmorph->getshape1 gets a handle to the morph's
starting shape. swfmorph->getshape1 returns an
swfshape object.
SWFMorph->getshape2Gets a handle to the ending shapeDescriptionmixed swfmorph->getshape2
&warn.experimental.func;
swfmorph->getshape2 gets a handle to the morph's
ending shape. swfmorph->getshape2 returns an
swfshape object.
SWFTextCreates a new SWFText object.Descriptionnew swftext
&warn.experimental.func;
swftext creates a new SWFText object,
fresh for manipulating.
SWFText has the following methods : swftext->setfont,
swftext->setheight, swftext->setspacing,
swftext->setcolor, swftext->moveto,
swftext->addstring and swftext->getwidth.
This simple example will draw a big yellow "PHP generates Flash with Ming"
text, on white background.
swftext example
<?php
$f = new SWFFont("Techno.fdb");
$t = new SWFText();
$t->setFont($f);
$t->moveTo(200, 2400);
$t->setColor(0xff, 0xff, 0);
$t->setHeight(1200);
$t->addString("PHP generates Flash with Ming!!");
$m = new SWFMovie();
$m->setDimension(5400, 3600);
$m->add($t);
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
SWFText->setFontSets the current fontDescriptionvoid swftext->setfontstring font
&warn.experimental.func;
swftext->setfont sets the current font to
font.
SWFText->setHeightSets the current font heightDescriptionvoid swftext->setheightint height
&warn.experimental.func;
swftext->setheight sets the current font height to
height. Default is 240.
SWFText->setSpacingSets the current font spacingDescriptionvoid swftext->setspacingfloat spacing
&warn.experimental.func;
swftext->setspacing sets the current font spacing to
spacingspacing. Default is 1.0.
0 is all of the letters written at the same point. This doesn't really work
that well because it inflates the advance across the letter, doesn't add
the same amount of spacing between the letters. I should try and explain
that better, prolly. Or just fix the damn thing to do constant spacing.
This was really just a way to figure out how letter advances work,
anyway.. So nyah.
SWFText->setColorSets the current font colorDescriptionvoid swftext->setcolorint redint greenint blueint a
&warn.experimental.func;
swftext->setspacing changes the current text color.
Default is black. I think. Color is represented using the RGB system.
SWFText->moveToMoves the penDescriptionvoid swftext->movetoint xint y
&warn.experimental.func;
swftext->moveto moves the pen (or cursor, if
that makes more sense) to (x,y)
in text object's coordinate space. If either is zero, though, value
in that dimension stays the same. Annoying, should be fixed.
SWFText->addStringDraws a stringDescriptionvoid swftext->addstringstring string
&warn.experimental.func;
swftext->addstring draws the string string
at the current pen (cursor) location. Pen is at the baseline of the text;
i.e., ascending text is in the -y direction.
SWFText->getWidthComputes string's widthDescriptionvoid swftext->addstringstring string
&warn.experimental.func;
swftext->addstring returns the rendered width of the
string string at the text object's current font,
scale, and spacing settings.
SWFFontLoads a font definitionDescriptionnew swffontstring filename
&warn.experimental.func;
If filename is the name of an FDB file
(i.e., it ends in ".fdb"), load the font definition found in said
file. Otherwise, create a browser-defined font reference.
FDB ("font definition block") is a very simple wrapper for the SWF DefineFont2
block which contains a full description of a font. One may create FDB files from
SWT Generator template files with the included makefdb utility- look in the
util directory off the main ming distribution directory.
Browser-defined fonts don't contain any information about the font other
than its name. It is assumed that the font definition will be provided by
the movie player. The fonts _serif, _sans, and _typewriter should always
be available. For example:
<?php
$f = newSWFFont("_sans");
?>
will give you the standard sans-serif font, probably the same as what you'd get
with <font name="sans-serif"> in HTML.
swffont returns a reference to the font
definition, for use in the SWFText->setFont
and the SWFTextField->setFont methods.
SWFFont has the following methods : swffont->getwidth.
swffont->getwidthReturns the string's widthDescriptionint swffont->getwidthstring string
&warn.experimental.func;
swffont->getwidth returns the string
string's width, using font's default scaling.
You'll probably want to use the SWFText version of this method which
uses the text object's scale.
SWFTextFieldCreates a text field objectDescriptionnew swftextfieldint flags
&warn.experimental.func;
swftextfield creates a new text field object.
Text Fields are less flexible than swftext objects-
they can't be rotated, scaled non-proportionally, or skewed, but they can
be used as form entries, and they can use browser-defined fonts.
The optional flags change the text field's behavior. It has the following
possibles values :
SWFTEXTFIELD_NOEDIT indicates that the field shouldn't be user-editable
SWFTEXTFIELD_PASSWORD obscures the data entry
SWFTEXTFIELD_DRAWBOX draws the outline of the textfield
SWFTEXTFIELD_MULTILINE allows multiple lines
SWFTEXTFIELD_WORDWRAP allows text to wrap
SWFTEXTFIELD_NOSELECT makes the field non-selectable
Flags are combined with the bitwise
OR operation. For example,
<?php
$t = newSWFTextField(SWFTEXTFIELD_PASSWORD | SWFTEXTFIELD_NOEDIT);
?>
creates a totally useless non-editable password field.
SWFTextField has the following methods : swftextfield->setfont,
swftextfield->setbounds, swftextfield->align,
swftextfield->setheight, swftextfield->setleftmargin,
swftextfield->setrightmargin, swftextfield->setmargins,
swftextfield->setindentation, swftextfield->setlinespacing,
swftextfield->setcolor, swftextfield->setname and
swftextfield->addstring.
SWFTextField->setFontSets the text field fontDescriptionvoid swftextfield->setfontstring font
&warn.experimental.func;
swftextfield->setfont sets the text field font to
the [browser-defined?] font font.
SWFTextField->setboundsSets the text field width and heightDescriptionvoid swftextfield->setboundsint widthint height
&warn.experimental.func;
swftextfield->setbounds sets the text field width
to width and height to height.
If you don't set the bounds yourself, Ming makes a poor guess at what
the bounds are.
SWFTextField->alignSets the text field alignmentDescriptionvoid swftextfield->alignint alignement
&warn.experimental.func;
swftextfield->align sets the text field alignment
to alignement. Valid values for
alignement are : SWFTEXTFIELD_ALIGN_LEFT,
SWFTEXTFIELD_ALIGN_RIGHT, SWFTEXTFIELD_ALIGN_CENTER and
SWFTEXTFIELD_ALIGN_JUSTIFY.
SWFTextField->setHeightSets the font height of this text field font.Descriptionvoid swftextfield->setheightint height
&warn.experimental.func;
swftextfield->setheight sets the font height of this text field
font to the given height height. Default is 240.
SWFTextField->setLeftMarginSets the left margin width of the text field.Descriptionvoid swftextfield->setleftmarginint width
&warn.experimental.func;
swftextfield->setleftmargin sets the left margin width
of the text field to width. Default is 0.
SWFTextField->setrightMarginSets the right margin width of the text field.Descriptionvoid swftextfield->setrightmarginint width
&warn.experimental.func;
swftextfield->setrightmargin sets the right margin width
of the text field to width. Default is 0.
SWFTextField->setMarginsSets the margins width of the text field.Descriptionvoid swftextfield->setmarginsint leftint right
&warn.experimental.func;
swftextfield->setmargins set both margins at once,
for the man on the go.
SWFTextField->setindentationSets the indentation of the first line.Descriptionvoid swftextfield->setindentationint width
&warn.experimental.func;
swftextfield->setindentation sets the indentation of
the first line in the text field, to width.
SWFTextField->setLineSpacingSets the line spacing of the text field.Descriptionvoid swftextfield->setlinespacingint height
&warn.experimental.func;
swftextfield->setlinespacing sets the line spacing
of the text field to the height of height. Default is 40.
SWFTextField->setcolorSets the color of the text field. Descriptionvoid swftextfield->setcolorint redint greenint blueint a
&warn.experimental.func;
swftextfield->setcolor sets the color of the text field.
Default is fully opaque black. Color is represented using RGB system.
SWFTextField->setnameSets the variable nameDescriptionvoid swftextfield->setnamestring name
&warn.experimental.func;
swftextfield->setname sets the variable name of this
text field to name, for form posting and action
scripting purposes.
SWFTextField->addstringConcatenates the given string to the text fieldDescriptionvoid swftextfield->addstringstring string
&warn.experimental.func;
swftextfield->setname concatenates the string
string to the text field.
SWFSpriteCreates a movie clip (a sprite)Descriptionnew swfsprite
&warn.experimental.func;
swfsprite are also known as a "movie clip",
this allows one to create objects which are animated in their own
timelines. Hence, the sprite has most of the same methods as the movie.
swfsprite has the following methods :
swfsprite->add,
swfsprite->remove, swfsprite->nextframe
and swfsprite->setframes.
This simple example will spin gracefully a big red square.
swfsprite example
<?php
$s = new SWFShape();
$s->setRightFill($s->addFill(0xff, 0, 0));
$s->movePenTo(-500,-500);
$s->drawLineTo(500,-500);
$s->drawLineTo(500,500);
$s->drawLineTo(-500,500);
$s->drawLineTo(-500,-500);
$p = new SWFSprite();
$i = $p->add($s);
$p->nextFrame();
$i->rotate(15);
$p->nextFrame();
$i->rotate(15);
$p->nextFrame();
$i->rotate(15);
$p->nextFrame();
$i->rotate(15);
$p->nextFrame();
$i->rotate(15);
$p->nextFrame();
$m = new SWFMovie();
$i = $m->add($p);
$i->moveTo(1500,1000);
$i->setName("blah");
$m->setBackground(0xff, 0xff, 0xff);
$m->setDimension(3000,2000);
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
SWFSprite->addAdds an object to a spriteDescriptionvoid swfsprite->addressource object
&warn.experimental.func;
swfsprite->add adds a swfshape, a
swfbutton, a swftext,
a swfaction or a swfsprite object.
For displayable types (swfshape,
swfbutton, swftext,
swfaction or swfsprite),
this returns a handle to the object in a display list.
SWFSprite->removeRemoves an object to a spriteDescriptionvoid swfsprite->removeressource object
&warn.experimental.func;
swfsprite->remove remove a swfshape, a
swfbutton, a swftext,
a swfaction or a swfsprite object
from the sprite.
SWFSprite->setframesSets the total number of frames in the animation.Descriptionvoid swfsprite->setframesint numberofframes
&warn.experimental.func;
swfsprite->setframes sets the total number of frames
in the animation to numberofframes.
SWFSprite->nextframeMoves to the next frame of the animation.Descriptionvoid swfsprite->nextframe
&warn.experimental.func;
swfsprite->setframes moves to the next frame of
the animation.
SWFbuttonCreates a new Button.Descriptionnew swfbutton
&warn.experimental.func;
swfbutton creates a new Button.
Roll over it, click it, see it call action code. Swank.
SWFButton has the following methods : swfbutton->addshape,
swfbutton->setup, swfbutton->setoverswfbutton->setdown, swfbutton->sethitswfbutton->setaction and
swfbutton->addaction.
This simple example will show your usual interactions with buttons :
rollover, rollon, mouseup, mousedown, noaction.
swfbutton example
<?php
$f = new SWFFont("_serif");
$p = new SWFSprite();
function label($string)
{
global $f;
$t = new SWFTextField();
$t->setFont($f);
$t->addString($string);
$t->setHeight(200);
$t->setBounds(3200,200);
return $t;
}
function addLabel($string)
{
global $p;
$i = $p->add(label($string));
$p->nextFrame();
$p->remove($i);
}
$p->add(new SWFAction("stop();"));
addLabel("NO ACTION");
addLabel("SWFBUTTON_MOUSEUP");
addLabel("SWFBUTTON_MOUSEDOWN");
addLabel("SWFBUTTON_MOUSEOVER");
addLabel("SWFBUTTON_MOUSEOUT");
addLabel("SWFBUTTON_MOUSEUPOUTSIDE");
addLabel("SWFBUTTON_DRAGOVER");
addLabel("SWFBUTTON_DRAGOUT");
function rect($r, $g, $b)
{
$s = new SWFShape();
$s->setRightFill($s->addFill($r, $g, $b));
$s->drawLine(600,0);
$s->drawLine(0,600);
$s->drawLine(-600,0);
$s->drawLine(0,-600);
return $s;
}
$b = new SWFButton();
$b->addShape(rect(0xff, 0, 0), SWFBUTTON_UP | SWFBUTTON_HIT);
$b->addShape(rect(0, 0xff, 0), SWFBUTTON_OVER);
$b->addShape(rect(0, 0, 0xff), SWFBUTTON_DOWN);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(1);"),
SWFBUTTON_MOUSEUP);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(2);"),
SWFBUTTON_MOUSEDOWN);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(3);"),
SWFBUTTON_MOUSEOVER);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(4);"),
SWFBUTTON_MOUSEOUT);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(5);"),
SWFBUTTON_MOUSEUPOUTSIDE);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(6);"),
SWFBUTTON_DRAGOVER);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(7);"),
SWFBUTTON_DRAGOUT);
$m = new SWFMovie();
$m->setDimension(4000,3000);
$i = $m->add($p);
$i->setName("label");
$i->moveTo(400,1900);
$i = $m->add($b);
$i->moveTo(400,900);
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
This simple example will enables you to drag draw a big red button
on the windows. No drag-and-drop, just moving around.
swfbutton->addaction example
<?php
$s = new SWFShape();
$s->setRightFill($s->addFill(0xff, 0, 0));
$s->drawLine(1000,0);
$s->drawLine(0,1000);
$s->drawLine(-1000,0);
$s->drawLine(0,-1000);
$b = new SWFButton();
$b->addShape($s, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER);
$b->addAction(new SWFAction("startDrag('/test', 0);"), // '0' means don't lock to mouse
SWFBUTTON_MOUSEDOWN);
$b->addAction(new SWFAction("stopDrag();"),
SWFBUTTON_MOUSEUP | SWFBUTTON_MOUSEUPOUTSIDE);
$p = new SWFSprite();
$p->add($b);
$p->nextFrame();
$m = new SWFMovie();
$i = $m->add($p);
$i->setName('test');
$i->moveTo(1000,1000);
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
SWFbutton->addShapeAdds a shape to a buttonDescriptionvoid swfbutton->addshaperessource shapeint flags
&warn.experimental.func;
swfbutton->addshape adds the shape
shape to this button. The following
flags' values are valid:
SWFBUTTON_UP, SWFBUTTON_OVER, SWFBUTTON_DOWN or SWFBUTTON_HIT.
SWFBUTTON_HIT isn't ever displayed, it defines the hit region for the button.
That is, everywhere the hit shape would be drawn is considered a "touchable"
part of the button.
SWFbutton->setUpAlias for addShape(shape, SWFBUTTON_UP)Descriptionvoid swfbutton->setupressource shape
&warn.experimental.func;
swfbutton->setup alias for addShape(shape, SWFBUTTON_UP).
See also
swfbutton->addshape and
SWFAction.
SWFbutton->setOverAlias for addShape(shape, SWFBUTTON_OVER)Descriptionvoid swfbutton->setoverressource shape
&warn.experimental.func;
swfbutton->setover alias for addShape(shape, SWFBUTTON_OVER).
See also
swfbutton->addshape and
SWFAction.
SWFbutton->setdownAlias for addShape(shape, SWFBUTTON_DOWN))Descriptionvoid swfbutton->setdownressource shape
&warn.experimental.func;
swfbutton->setdown alias for addShape(shape, SWFBUTTON_DOWN).
See also
swfbutton->addshape and
SWFAction.
SWFbutton->setHitAlias for addShape(shape, SWFBUTTON_HIT)Descriptionvoid swfbutton->sethitressource shape
&warn.experimental.func;
swfbutton->sethit alias for addShape(shape, SWFBUTTON_HIT).
See also
swfbutton->addshape and
SWFAction.
SWFbutton->addActionAdds an actionDescriptionvoid swfbutton->addactionressource actionint flags
&warn.experimental.func;
swfbutton->addaction adds the action
action to this button for the given conditions.
The following flags are valid:
SWFBUTTON_MOUSEOVER, SWFBUTTON_MOUSEOUT, SWFBUTTON_MOUSEUP,
SWFBUTTON_MOUSEUPOUTSIDE, SWFBUTTON_MOUSEDOWN, SWFBUTTON_DRAGOUT and
SWFBUTTON_DRAGOVER.
See also
swfbutton->addshape and
SWFAction.
SWFbutton->setActionSets the actionDescriptionvoid swfbutton->setactionressource action
&warn.experimental.func;
swfbutton->setaction sets the action to be performed
when the button is clicked. Alias for addAction(shape, SWFBUTTON_MOUSEUP).
action is a swfaction.
See also
swfbutton->addshape and
SWFAction.
SWFActionCreates a new Action.Descriptionnew swfactionstring script
&warn.experimental.func;
swfaction creates a new Action, and
compiles the given script into an SWFAction object.
The script syntax is based on the C language, but with a lot taken out- the SWF
bytecode machine is just too simpleminded to do a lot of things we might like.
For instance, we can't implement function calls without a tremendous
amount of hackery because the jump bytecode has a hardcoded offset
value. No pushing your calling address to the stack and returning-
every function would have to know exactly where to return to.
So what's left? The compiler recognises the following tokens:
break
for
continue
if
else
do
while
There is no typed data; all values in the SWF action machine are stored as strings.
The following functions can be used in expressions:
time()
Returns the number of milliseconds (?) elapsed since the movie started.
random(seed)
Returns a pseudo-random number in the range 0-seed.
length(expr)
Returns the length of the given expression.
int(number)
Returns the given number rounded down to the nearest integer.
concat(expr, expr)
Returns the concatenation of the given expressions.
ord(expr)
Returns the ASCII code for the given character
chr(num)
Returns the character for the given ASCII code
substr(string, location, length)
Returns the substring of length length at location location of
the given string string.
Additionally, the following commands may be used:
duplicateClip(clip, name, depth)
Duplicate the named movie clip (aka sprite). The new movie clip has name name
and is at depth depth.
removeClip(expr)
Removes the named movie clip.
trace(expr)
Write the given expression to the trace log. Doubtful that the browser
plugin does anything with this.
startDrag(target, lock, [left, top, right, bottom])
Start dragging the movie clip target. The lock argument indicates whether
to lock the mouse (?)- use 0 (&false;) or 1 (&true;). Optional parameters
define a bounding area for the dragging.
stopDrag()
Stop dragging my heart around. And this movie clip, too.
callFrame(expr)
Call the named frame as a function.
getURL(url, target, [method])
Load the given url into the named target. The target argument can be a
frame name (I think), or one of the magical values "_level0" (replaces
current movie) or "_level1" (loads new movie on top of current movie).
The optional method argument can be post or get if you want to submit
variables back to the server.
loadMovie(url, target)
Same as above, more or less. Come to think of it, I don't quite know what
the difference is.
nextFrame()
Go to the next frame.
prevFrame()
Go to the last (or, rather, previous) frame.
play()
Start playing the movie.
stop()
Stop playing the movie.
toggleQuality()
Toggle between high and low quality.
stopSounds()
Stop playing all sounds.
gotoFrame(num)
Go to frame number num. Frame numbers start at 0.
gotoFrame(name)
Go to the frame named name. Which does a lot of good, since I
haven't added frame labels yet.
setTarget(expr)
Sets the context for action. Or so they say- I really have no
idea what this does.
And there's one weird extra thing. The expression frameLoaded(num) can be used
in if statements and while loops to check if the given frame number has been
loaded yet. Well, it's supposed to, anyway, but I've never tested it and I
seriously doubt it actually works. You can just use /:framesLoaded instead.
Movie clips (all together now- aka sprites) have properties. You can
read all of them (or can you?), you can set some of them, and here
they are:
x
y
xScale
yScale
currentFrame - (read-only)
totalFrames - (read-only)
alpha - transparency level
visible - 1=on, 0=off (?)
width - (read-only)
height - (read-only)
rotation
target - (read-only) (???)
framesLoaded - (read-only)
name
dropTarget - (read-only) (???)
url - (read-only) (???)
highQuality - 1=high, 0=low (?)
focusRect - (???)
soundBufTime - (???)
So, setting a sprite's x position is as simple as /box.x = 100;.
Why the slash in front of the box, though? That's how flash keeps
track of the sprites in the movie, just like a unix filesystem-
here it shows that box is at the top level. If the sprite named
box had another sprite named biff inside of it, you'd set its x
position with /box/biff.x = 100;. At least, I think so; correct
me if I'm wrong here.
This simple example will move the red square across the window.
swfaction example
<?php
$s = new SWFShape();
$f = $s->addFill(0xff, 0, 0);
$s->setRightFill($f);
$s->movePenTo(-500,-500);
$s->drawLineTo(500,-500);
$s->drawLineTo(500,500);
$s->drawLineTo(-500,500);
$s->drawLineTo(-500,-500);
$p = new SWFSprite();
$i = $p->add($s);
$i->setDepth(1);
$p->nextFrame();
for($n=0; $n<5; ++$n)
{
$i->rotate(-15);
$p->nextFrame();
}
$m = new SWFMovie();
$m->setBackground(0xff, 0xff, 0xff);
$m->setDimension(6000,4000);
$i = $m->add($p);
$i->setDepth(1);
$i->moveTo(-500,2000);
$i->setName("box");
$m->add(new SWFAction("/box.x += 3;"));
$m->nextFrame();
$m->add(new SWFAction("gotoFrame(0); play();"));
$m->nextFrame();
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
This simple example tracks down your mouse on the screen.
swfaction example
<?php
$m = new SWFMovie();
$m->setRate(36.0);
$m->setDimension(1200, 800);
$m->setBackground(0, 0, 0);
/* mouse tracking sprite - empty, but follows mouse so we can
get its x and y coordinates */
$i = $m->add(new SWFSprite());
$i->setName('mouse');
$m->add(new SWFAction("
startDrag('/mouse', 1); /* '1' means lock sprite to the mouse */
"));
/* might as well turn off antialiasing, since these are just squares. */
$m->add(new SWFAction("
this.quality = 0;
"));
/* morphing box */
$r = new SWFMorph();
$s = $r->getShape1();
/* Note this is backwards from normal shapes. No idea why. */
$s->setLeftFill($s->addFill(0xff, 0xff, 0xff));
$s->movePenTo(-40, -40);
$s->drawLine(80, 0);
$s->drawLine(0, 80);
$s->drawLine(-80, 0);
$s->drawLine(0, -80);
$s = $r->getShape2();
$s->setLeftFill($s->addFill(0x00, 0x00, 0x00));
$s->movePenTo(-1, -1);
$s->drawLine(2, 0);
$s->drawLine(0, 2);
$s->drawLine(-2, 0);
$s->drawLine(0, -2);
/* sprite container for morphing box -
this is just a timeline w/ the box morphing */
$box = new SWFSprite();
$box->add(new SWFAction("
stop();
"));
$i = $box->add($r);
for($n=0; $n<=20; ++$n)
{
$i->setRatio($n/20);
$box->nextFrame();
}
/* this container sprite allows us to use the same action code many times */
$cell = new SWFSprite();
$i = $cell->add($box);
$i->setName('box');
$cell->add(new SWFAction("
setTarget('box');
/* ...x means the x coordinate of the parent, i.e. (..).x */
dx = (/mouse.x + random(6)-3 - ...x)/5;
dy = (/mouse.y + random(6)-3 - ...y)/5;
gotoFrame(int(dx*dx + dy*dy));
"));
$cell->nextFrame();
$cell->add(new SWFAction("
gotoFrame(0);
play();
"));
$cell->nextFrame();
/* finally, add a bunch of the cells to the movie */
for($x=0; $x<12; ++$x)
{
for($y=0; $y<8; ++$y)
{
$i = $m->add($cell);
$i->moveTo(100*$x+50, 100*$y+50);
}
}
$m->nextFrame();
$m->add(new SWFAction("
gotoFrame(1);
play();
"));
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
Same as above, but with nice colored balls...
swfaction example
<?php
$m = new SWFMovie();
$m->setDimension(11000, 8000);
$m->setBackground(0x00, 0x00, 0x00);
$m->add(new SWFAction("
this.quality = 0;
/frames.visible = 0;
startDrag('/mouse', 1);
"));
// mouse tracking sprite
$t = new SWFSprite();
$i = $m->add($t);
$i->setName('mouse');
$g = new SWFGradient();
$g->addEntry(0, 0xff, 0xff, 0xff, 0xff);
$g->addEntry(0.1, 0xff, 0xff, 0xff, 0xff);
$g->addEntry(0.5, 0xff, 0xff, 0xff, 0x5f);
$g->addEntry(1.0, 0xff, 0xff, 0xff, 0);
// gradient shape thing
$s = new SWFShape();
$f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT);
$f->scaleTo(0.03);
$s->setRightFill($f);
$s->movePenTo(-600, -600);
$s->drawLine(1200, 0);
$s->drawLine(0, 1200);
$s->drawLine(-1200, 0);
$s->drawLine(0, -1200);
// need to make this a sprite so we can multColor it
$p = new SWFSprite();
$p->add($s);
$p->nextFrame();
// put the shape in here, each frame a different color
$q = new SWFSprite();
$q->add(new SWFAction("gotoFrame(random(7)+1); stop();"));
$i = $q->add($p);
$i->multColor(1.0, 1.0, 1.0);
$q->nextFrame();
$i->multColor(1.0, 0.5, 0.5);
$q->nextFrame();
$i->multColor(1.0, 0.75, 0.5);
$q->nextFrame();
$i->multColor(1.0, 1.0, 0.5);
$q->nextFrame();
$i->multColor(0.5, 1.0, 0.5);
$q->nextFrame();
$i->multColor(0.5, 0.5, 1.0);
$q->nextFrame();
$i->multColor(1.0, 0.5, 1.0);
$q->nextFrame();
// finally, this one contains the action code
$p = new SWFSprite();
$i = $p->add($q);
$i->setName('frames');
$p->add(new SWFAction("
dx = (/:mousex-/:lastx)/3 + random(10)-5;
dy = (/:mousey-/:lasty)/3;
x = /:mousex;
y = /:mousey;
alpha = 100;
"));
$p->nextFrame();
$p->add(new SWFAction("
this.x = x;
this.y = y;
this.alpha = alpha;
x += dx;
y += dy;
dy += 3;
alpha -= 8;
"));
$p->nextFrame();
$p->add(new SWFAction("prevFrame(); play();"));
$p->nextFrame();
$i = $m->add($p);
$i->setName('frames');
$m->nextFrame();
$m->add(new SWFAction("
lastx = mousex;
lasty = mousey;
mousex = /mouse.x;
mousey = /mouse.y;
++num;
if(num == 11)
num = 1;
removeClip('char' & num);
duplicateClip(/frames, 'char' & num, num);
"));
$m->nextFrame();
$m->add(new SWFAction("prevFrame(); play();"));
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
This simple example will handles keyboard actions.
(You'll probably have to click in the window to give it focus.
And you'll probably have to leave your mouse in the frame, too.
If you know how to give buttons focus programatically, feel free
to share, won't you?)
swfaction example
<?php
/* sprite has one letter per frame */
$p = new SWFSprite();
$p->add(new SWFAction("stop();"));
$chars = "abcdefghijklmnopqrstuvwxyz".
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".
"1234567890!@#$%^&*()_+-=/[]{}|;:,.<>?`~";
$f = new SWFFont("_sans");
for($n=0; $n < strlen($chars); ++$n)
{
$c = substr($chars, $n, 1);
if($i) $p->remove($i);
$t = new SWFTextField();
$t->setFont($f);
$t->setHeight(240);
$t->setBounds(600,240);
$t->align(SWFTEXTFIELD_ALIGN_CENTER);
$t->addString($c);
$i = $p->add($t);
$p->labelFrame($c);
$p->nextFrame();
}
/* hit region for button - the entire frame */
$s = new SWFShape();
$s->setFillStyle0($s->addSolidFill(0, 0, 0, 0));
$s->drawLine(600, 0);
$s->drawLine(0, 400);
$s->drawLine(-600, 0);
$s->drawLine(0, -400);
/* button checks for pressed key, sends sprite to the right frame */
$b = new SWFButton();
$b->addShape($s, SWFBUTTON_HIT);
for($n=0; $naddAction(new SWFAction("
setTarget('/char');
gotoFrame('$c');
"), SWFBUTTON_KEYPRESS($c));
}
$m = new SWFMovie();
$m->setDimension(600,400);
$i = $m->add($p);
$i->setName('char');
$i->moveTo(0,80);
$m->add($b);
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
\ No newline at end of file
+
+
+
+ Ming functions for Flash
+ Ming (flash)
+
+
+ &warn.experimental;
+
+ Introduction
+
+ Ming is an open-source (LGPL) library which allows you to create SWF
+ ("Flash") format movies. Ming supports almost all of Flash 4's features,
+ including: shapes, gradients, bitmaps (pngs and jpegs), morphs ("shape
+ tweens"), text, buttons, actions, sprites ("movie clips"), streaming mp3,
+ and color transforms--the only thing that's missing is sound events.
+
+
+ Ming is not an acronym.
+
+
+ Note that all values specifying length, distance, size, etc. are in "twips",
+ twenty units per pixel. That's pretty much arbitrary, though, since the player
+ scales the movie to whatever pixel size is specified in the embed/object tag,
+ or the entire frame if not embedded.
+
+
+ Ming offers a number of advantages over the existing PHP/libswf module.
+ You can use Ming anywhere you can compile the code, whereas libswf is
+ closed-source and only available for a few platforms, Windows not one of
+ them. Ming provides some insulation from the mundane details of the SWF
+ file format, wrapping the movie elements in PHP objects. Also, Ming is
+ still being maintained; if there's a feature that you want to see, just
+ let us know &email.ming;.
+
+
+ Ming was added in PHP 4.0.5.
+
+
+
+
+ Installation
+
+ To use Ming with PHP, you first need to build and install the Ming
+ library. Source code and installation instructions are available at the
+ Ming home page : &url.ming;
+ along with examples, a small tutorial, and the latest news.
+
+
+ Download the ming archive. Unpack the archive. Go in the
+ Ming directory. make. make install.
+
+
+ This will build libming.so and install it
+ into /usr/lib/, and copy
+ ming.h into /usr/include/.
+ Edit the PREFIX= line in the
+ Makefile to change the installation directory.
+
+
+ built into php (unix)
+
+
+ mkdir <phpdir>/ext/ming
+ cp php_ext/* <phpdir>/ext/ming
+ cd <phpdir>
+ ./buildconf
+ ./configure --with-ming <other config options>
+
+ Build and install php as usual,
+ Restart web server if necessary
+
+
+
+ built into php (unix)
+
+ download php_ming.so.gz.
+ uncompress it and copy it to your php modules directory.
+ (you can find your php module directory by running
+ php-config --extension-dir).
+ Now either just add extension=php_ming.so
+ to your php.ini file, or put
+ dl('php_ming.so'); at the head of all of your
+ Ming scripts.
+
+
+
+
+ How to use Ming
+
+ Ming introduces 13 new object in PHP, all with matching methods and
+ attributes. To use them, you need to know about
+ objects.
+
+
+
+
+ swfmovie.
+
+
+
+
+ swfshape.
+
+
+
+
+ swfdisplayitem.
+
+
+
+
+ swfgradient.
+
+
+
+
+
+ swfbitmap.
+
+
+
+
+ swffill.
+
+
+
+
+ swfmorph.
+
+
+
+
+ swftext.
+
+
+
+
+ swffont.
+
+
+
+
+ swftextfield.
+
+
+
+
+ swfsprite.
+
+
+
+
+ swfbutton.
+
+
+
+
+ swfaction.
+
+
+
+
+
+
+
+
+
+
+ SWFMovie
+ Creates a new movie object, representing an SWF version 4 movie.
+
+
+ Description
+
+
+ new swfmovie
+
+
+
+ &warn.experimental.func;
+
+ swfmovie creates a new movie object,
+ representing an SWF version 4 movie.
+
+
+ SWFMovie has the following methods :
+ swfmovie->output,swfmovie->save,
+ swfmovie->add, swfmovie->remove,
+ swfmovie->nextframe, swfmovie->setbackground,
+ swfmovie->setrate, swfmovie->setdimension,
+ swfmovie->setframes and swfmovie->streammp3.
+
+
+ See examples in :
+ swfdisplayitem->rotateto, swfshape->setline,
+ swfshape->addfill... Any example will use this object.
+
+
+
+
+
+
+ SWFMovie->output
+ Dumps your lovingly prepared movie out.
+
+
+ Description
+
+
+ void swfmovie->output
+
+
+
+ &warn.experimental.func;
+
+ swfmovie->output dumps your lovingly prepared movie out.
+ In PHP, preceding this with the command
+
+<?php
+header('Content-type: application/x-shockwave-flash');
+?>
+
+ convinces the browser to display this as a flash movie.
+
+
+ See also
+ swfmovie->save.
+
+
+ See examples in :
+ swfmovie->streammp3,
+ swfdisplayitem->rotateto,
+ swfaction...
+ Any example will use this method.
+
+
+
+
+
+
+ SWFMovie->save
+ Saves your movie in a file.
+
+
+ Description
+
+
+ void swfmovie->save
+ string filename
+
+
+ &warn.experimental.func;
+
+ swfmovie->save saves your movie to the
+ file named filename.
+
+
+ See also
+ output.
+
+
+
+
+
+
+ SWFMovie->add
+ Adds any type of data to a movie.
+
+
+ Description
+
+
+ void swfmovie->add
+ ressource instance
+
+
+ &warn.experimental.func;
+
+ swfmovie->add adds instance to
+ the current movie. instance is any type of data :
+ Shapes, text, fonts, etc. must all be add'ed to the movie to make this work.
+
+
+ For displayable types (shape, text, button, sprite), this returns an
+ SWFDisplayItem, a handle to the object in a display
+ list. Thus, you can add the same shape to a movie multiple
+ times and get separate handles back for each separate instance.
+
+
+ See also all other objects (adding this later), and
+ swfmovie->remove
+
+
+ See examples in :
+ swfdisplayitem->rotateto and
+ swfshape->addfill.
+
+
+
+
+
+
+
+ SWFMovie->remove
+ Removes the object instance from the display list.
+
+
+ Description
+
+
+ void swfmovie->remove
+ resource instance
+
+
+ &warn.experimental.func;
+
+ swfmovie->remove removes the object instance
+ instance from the display list.
+
+
+ See also
+ swfmovie->add.
+
+
+
+
+
+
+ SWFMovie->setbackground
+ Sets the background color.
+
+
+ Description
+
+
+ void swfmovie->setbackground
+ int red
+ int green
+ int blue
+
+
+ &warn.experimental.func;
+
+ swfmovie->setbackground sets the background color. Why is
+ there no rgba version? Think about it. (Actually, that's not such a dumb
+ question after all- you might want to let the html background show through.
+ There's a way to do that, but it only works on IE4. Search the
+ &url.macromedia; site for
+ details.)
+
+
+
+
+
+
+ SWFMovie->setrate
+ Sets the animation's frame rate.
+
+
+ Description
+
+
+ void swfmovie->setrate
+ int rate
+
+
+ &warn.experimental.func;
+
+ swfmovie->setrate sets the frame rate to
+ rate, in frame per seconds.
+ Animation will slow down if the player can't render frames fast enough- unless
+ there's a streaming sound, in which case display frames are sacrificed to
+ keep sound from skipping.
+
+
+
+
+
+
+ SWFMovie->setdimension
+ Sets the movie's width and height.
+
+
+ Description
+
+
+ void swfmovie->setdimension
+ int width
+ int height
+
+
+ &warn.experimental.func;
+
+ swfmovie->setdimension sets the movie's width
+ to width and height to height.
+
+
+
+
+
+
+ SWFMovie->setframes
+ Sets the total number of frames in the animation.
+
+
+ Description
+
+
+ void swfmovie->setframes
+ string numberofframes
+
+
+ &warn.experimental.func;
+
+ swfmovie->setframes sets the total number of frames
+ in the animation to numberofframes.
+
+
+
+
+
+
+ SWFMovie->nextframe
+ Moves to the next frame of the animation.
+
+
+ Description
+
+
+ void swfmovie->nextframe
+
+
+
+ &warn.experimental.func;
+
+ swfmovie->setframes moves to the next frame of
+ the animation.
+
+
+
+
+
+
+
+ SWFMovie->streammp3
+ Streams a MP3 file.
+
+
+ Description
+
+
+ void swfmovie->streammp3
+ string mp3FileName
+
+
+ &warn.experimental.func;
+
+ swfmovie->streammp3 streams the mp3 file
+ mp3FileName. Not very robust in dealing with
+ oddities (can skip over an initial ID3 tag, but that's about it).
+ Like SWFShape->addJpegFill, this isn't a stable function- we'll
+ probably need to make a separate SWFSound object to contain sound types.
+
+
+ Note that the movie isn't smart enough to put enough frames in to contain
+ the entire mp3 stream- you'll have to add (length of song * frames per second)
+ frames to get the entire stream in.
+
+
+ Yes, now you can use ming to put that rock and roll devil worship music
+ into your SWF files. Just don't tell the RIAA.
+
+ swfmovie->streammp3 example
+
+<?php
+ $m = new SWFMovie();
+ $m->setRate(12.0);
+ $m->streamMp3("distortobass.mp3");
+// use your own MP3
+
+ // 11.85 seconds at 12.0 fps = 142 frames
+ $m->setFrames(142);
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+
+
+
+
+
+
+ SWFDisplayItem
+ Creates a new displayitem object.
+
+
+ Description
+
+
+ new swfdisplayitem
+
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem creates a new swfdisplayitem object.
+
+
+ Here's where all the animation takes place. After you define a shape,
+ a text object, a sprite, or a button, you add it to the movie, then use
+ the returned handle to move, rotate, scale, or skew the thing.
+
+
+ SWFDisplayItem has the following methods : swfdisplayitem->move,
+ swfdisplayitem->moveto, swfdisplayitem->scaleto,
+ swfdisplayitem->scale, swfdisplayitem->rotate,
+ swfdisplayitem->rotateto, swfdisplayitem->skewxto,
+ swfdisplayitem->skewx, swfdisplayitem->skewyto
+ swfdisplayitem->skewyto, swfdisplayitem->setdepth
+ swfdisplayitem->remove, swfdisplayitem->setname
+ swfdisplayitem->setratio, swfdisplayitem->addcolor
+ and swfdisplayitem->multcolor.
+
+
+
+
+
+
+ SWFDisplayItem->moveTo
+ Moves object in global coordinates.
+
+
+ Description
+
+
+ void swfdisplayitem->moveto
+ int x
+ int y
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->moveto moves the current object to
+ (x,y) in global coordinates.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+ See also
+ swfdisplayitem->move.
+
+
+
+
+
+
+ SWFDisplayItem->move
+ Moves object in relative coordinates.
+
+
+ Description
+
+
+ void swfdisplayitem->move
+ int dx
+ int dy
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->move moves the current object by
+ (dx,dy) from its
+ current position.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+ See also
+ swfdisplayitem->moveto.
+
+
+
+
+
+
+ SWFDisplayItem->scaleTo
+ Scales the object in global coordinates.
+
+
+ Description
+
+
+ void swfdisplayitem->scaleto
+ int x
+ int y
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->scaleto scales the current object to
+ (x,y) in global coordinates.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+ See also
+ swfdisplayitem->scale.
+
+
+
+
+
+
+ SWFDisplayItem->scale
+ Scales the object in relative coordinates.
+
+
+ Description
+
+
+ void swfdisplayitem->scale
+ int dx
+ int dy
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->scale scales the current object by
+ (dx,dy) from its
+ current size.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+ See also
+ swfdisplayitem->scaleto.
+
+
+
+
+
+
+ SWFDisplayItem->rotateTo
+ Rotates the object in global coordinates.
+
+
+ Description
+
+
+ void swfdisplayitem->rotateto
+ float degrees
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->rotateto set the current object
+ rotation to degrees degrees in global coordinates.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+ This example bring three rotating string from the background to the
+ foreground. Pretty nice.
+
+ swfdisplayitem->rotateto example
+
+<?php
+ $thetext = "ming!";
+
+ $f = new SWFFont("Bauhaus 93.fdb");
+
+ $m = new SWFMovie();
+ $m->setRate(24.0);
+ $m->setDimension(2400, 1600);
+ $m->setBackground(0xff, 0xff, 0xff);
+
+ // functions with huge numbers of arbitrary
+ // arguments are always a good idea! Really!
+
+ function text($r, $g, $b, $a, $rot, $x, $y, $scale, $string)
+ {
+ global $f, $m;
+
+ $t = new SWFText();
+ $t->setFont($f);
+ $t->setColor($r, $g, $b, $a);
+ $t->setHeight(960);
+ $t->moveTo(-($f->getWidth($string))/2, $f->getAscent()/2);
+ $t->addString($string);
+
+ // we can add properties just like a normal php var,
+ // as long as the names aren't already used.
+ // e.g., we can't set $i->scale, because that's a function
+
+ $i = $m->add($t);
+ $i->x = $x;
+ $i->y = $y;
+ $i->rot = $rot;
+ $i->s = $scale;
+ $i->rotateTo($rot);
+ $i->scale($scale, $scale);
+
+ // but the changes are local to the function, so we have to
+ // return the changed object. kinda weird..
+
+ return $i;
+ }
+
+ function step($i)
+ {
+ $oldrot = $i->rot;
+ $i->rot = 19*$i->rot/20;
+ $i->x = (19*$i->x + 1200)/20;
+ $i->y = (19*$i->y + 800)/20;
+ $i->s = (19*$i->s + 1.0)/20;
+
+ $i->rotateTo($i->rot);
+ $i->scaleTo($i->s, $i->s);
+ $i->moveTo($i->x, $i->y);
+
+ return $i;
+ }
+
+ // see? it sure paid off in legibility:
+
+ $i1 = text(0xff, 0x33, 0x33, 0xff, 900, 1200, 800, 0.03, $thetext);
+ $i2 = text(0x00, 0x33, 0xff, 0x7f, -560, 1200, 800, 0.04, $thetext);
+ $i3 = text(0xff, 0xff, 0xff, 0x9f, 180, 1200, 800, 0.001, $thetext);
+
+ for($i=1; $i<=100; ++$i)
+ {
+ $i1 = step($i1);
+ $i2 = step($i2);
+ $i3 = step($i3);
+
+ $m->nextFrame();
+ }
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+ See also
+ swfdisplayitem->rotate.
+
+
+
+
+
+
+ SWFDisplayItem->Rotate
+ Rotates in relative coordinates.
+
+
+ Description
+
+
+ void swfdisplayitem->rotate
+ float ddegrees
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->rotate rotates the current object
+ by ddegrees degrees from its current rotation.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+ See also
+ swfdisplayitem->rotateto.
+
+
+
+
+
+
+ SWFDisplayItem->skewXTo
+ Sets the X-skew.
+
+
+ Description
+
+
+ void swfdisplayitem->skewxto
+ float degrees
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->skewxto sets the
+ x-skew to degrees. For degrees
+ is 1.0, it means a 45-degree forward slant. More is more forward,
+ less is more backward.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+ See also
+ swfdisplayitem->skewx,
+ swfdisplayitem->skewy and
+ swfdisplayitem->skewyto.
+
+
+
+
+
+
+ SWFDisplayItem->skewX
+ Sets the X-skew.
+
+
+ Description
+
+
+ void swfdisplayitem->skewx
+ float ddegrees
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->skewx adds ddegrees
+ to current x-skew.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+ See also
+ swfdisplayitem->skewx,
+ swfdisplayitem->skewy and
+ swfdisplayitem->skewyto.
+
+
+
+
+
+
+ SWFDisplayItem->skewYTo
+ Sets the Y-skew.
+
+
+ Description
+
+
+ void swfdisplayitem->skewyto
+ float degrees
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->skewyto sets the
+ y-skew to degrees. For degrees
+ is 1.0, it means a 45-degree forward slant. More is more upward,
+ less is more downward.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+ See also
+ swfdisplayitem->skewy,
+ swfdisplayitem->skewx and
+ swfdisplayitem->skewxto.
+
+
+
+
+
+
+ SWFDisplayItem->skewY
+ Sets the Y-skew.
+
+
+ Description
+
+
+ void swfdisplayitem->skewy
+ float ddegrees
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->skewy adds ddegrees
+ to current y-skew.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+ See also
+ swfdisplayitem->skewyto,
+ swfdisplayitem->skewx and
+ swfdisplayitem->skewxto.
+
+
+
+
+
+
+ SWFDisplayItem->setDepth
+ Sets z-order
+
+
+ Description
+
+
+ void swfdisplayitem->setdepth
+ float depth
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->rotate sets the object's
+ z-order to depth. Depth defaults to the
+ order in which instances are created (by add'ing a shape/text to
+ a movie)- newer ones are on top of older ones. If two objects are
+ given the same depth, only the later-defined one can be moved.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+
+
+
+
+ SWFDisplayItem->remove
+ Removes the object from the movie
+
+
+ Description
+
+
+ void swfdisplayitem->remove
+
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->remove removes this object from
+ the movie's display list.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+ See also
+ swfmovie->add.
+
+
+
+
+
+
+ SWFDisplayItem->setName
+ Sets the object's name
+
+
+ Description
+
+
+ void swfdisplayitem->setname
+ string name
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->setname sets the object's name to
+ name, for targetting with action script.
+ Only useful on sprites.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+
+
+
+
+ SWFDisplayItem->setRatio
+ Sets the object's ratio.
+
+
+ Description
+
+
+ void swfdisplayitem->setratio
+ float ratio
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->setratio sets the object's ratio
+ to ratio. Obviously only useful for morphs.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+ This simple example will morph nicely three concentric circles.
+
+ swfdisplayitem->setname example
+
+<?php
+
+ $p = new SWFMorph();
+
+ $g = new SWFGradient();
+ $g->addEntry(0.0, 0, 0, 0);
+ $g->addEntry(0.16, 0xff, 0xff, 0xff);
+ $g->addEntry(0.32, 0, 0, 0);
+ $g->addEntry(0.48, 0xff, 0xff, 0xff);
+ $g->addEntry(0.64, 0, 0, 0);
+ $g->addEntry(0.80, 0xff, 0xff, 0xff);
+ $g->addEntry(1.00, 0, 0, 0);
+
+ $s = $p->getShape1();
+ $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT);
+ $f->scaleTo(0.05);
+ $s->setLeftFill($f);
+ $s->movePenTo(-160, -120);
+ $s->drawLine(320, 0);
+ $s->drawLine(0, 240);
+ $s->drawLine(-320, 0);
+ $s->drawLine(0, -240);
+
+ $g = new SWFGradient();
+ $g->addEntry(0.0, 0, 0, 0);
+ $g->addEntry(0.16, 0xff, 0, 0);
+ $g->addEntry(0.32, 0, 0, 0);
+ $g->addEntry(0.48, 0, 0xff, 0);
+ $g->addEntry(0.64, 0, 0, 0);
+ $g->addEntry(0.80, 0, 0, 0xff);
+ $g->addEntry(1.00, 0, 0, 0);
+
+ $s = $p->getShape2();
+ $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT);
+ $f->scaleTo(0.05);
+ $f->skewXTo(1.0);
+ $s->setLeftFill($f);
+ $s->movePenTo(-160, -120);
+ $s->drawLine(320, 0);
+ $s->drawLine(0, 240);
+ $s->drawLine(-320, 0);
+ $s->drawLine(0, -240);
+
+ $m = new SWFMovie();
+ $m->setDimension(320, 240);
+ $i = $m->add($p);
+ $i->moveTo(160, 120);
+
+ for($n=0; $n<=1.001; $n+=0.01)
+ {
+ $i->setRatio($n);
+ $m->nextFrame();
+ }
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+
+
+
+
+ SWFDisplayItem->addColor
+ Adds the given color to this item's color transform.
+
+
+ Description
+
+
+ void swfdisplayitem->addcolor
+ int red
+ int green
+ int blue
+ int a
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->addcolor adds the color to
+ this item's color transform. The color is given in its RGB form.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+
+
+
+
+ SWFDisplayItem->multColor
+ Multiplies the item's color transform.
+
+
+ Description
+
+
+ void swfdisplayitem->multcolor
+ int red
+ int green
+ int blue
+ int a
+
+
+ &warn.experimental.func;
+
+ swfdisplayitem->multcolor multiplies the item's
+ color transform by the given values.
+
+
+ The object may be a swfshape, a
+ swfbutton, a swftext or a
+ swfsprite object. It must have been added using
+ the swfmovie->add.
+
+
+ This simple example will modify your picture's atmospher
+ to Halloween (use a landscape or bright picture).
+
+ swfdisplayitem->multcolor example
+
+<?php
+
+ $b = new SWFBitmap("backyard.jpg");
+ // note use your own picture :-)
+ $s = new SWFShape();
+ $s->setRightFill($s->addFill($b));
+ $s->drawLine($b->getWidth(), 0);
+ $s->drawLine(0, $b->getHeight());
+ $s->drawLine(-$b->getWidth(), 0);
+ $s->drawLine(0, -$b->getHeight());
+
+ $m = new SWFMovie();
+ $m->setDimension($b->getWidth(), $b->getHeight());
+
+ $i = $m->add($s);
+
+ for($n=0; $n<=20; ++$n)
+ {
+ $i->multColor(1.0-$n/10, 1.0, 1.0);
+ $i->addColor(0xff*$n/20, 0, 0);
+ $m->nextFrame();
+ }
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+
+
+
+
+
+
+ SWFShape
+ Creates a new shape object.
+
+
+ Description
+
+
+ new swfshape
+
+
+
+ &warn.experimental.func;
+
+ swfshape creates a new shape object.
+
+
+ SWFShape has the following methods : swfshape->setline,
+ swfshape->addfill, swfshape->setleftfill,
+ swfshape->setrightfill, swfshape->movepento,
+ swfshape->movepen, swfshape->drawlineto,
+ swfshape->drawline, swfshape->drawcurveto
+ and swfshape->drawcurve.
+
+
+ This simple example will draw a big red elliptic quadrant.
+
+ swfshape example
+
+<?php
+ $s = new SWFShape();
+ $s->setLine(40, 0x7f, 0, 0);
+ $s->setRightFill($s->addFill(0xff, 0, 0));
+ $s->movePenTo(200, 200);
+ $s->drawLineTo(6200, 200);
+ $s->drawLineTo(6200, 4600);
+ $s->drawCurveTo(200, 4600, 200, 200);
+
+ $m = new SWFMovie();
+ $m->setDimension(6400, 4800);
+ $m->setRate(12.0);
+ $m->add($s);
+ $m->nextFrame();
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+
+
+
+
+ SWFShape->setLine
+ Sets the shape's line style.
+
+
+ Description
+
+
+ void swfshape->setline
+ int width
+ int red
+ int green
+ int blue
+ int a
+
+
+ &warn.experimental.func;
+
+ swfshape->setline sets the shape's line style.
+ width is the line's width. If width
+ is 0, the line's style is removed (then, all other arguments are ignored).
+ If width > 0, then line's color is set to
+ red, green, blue.
+ Last parameter a is optional.
+
+
+ swfshape->setline accepts 1, 4 or 5 arguments
+ (not 3 or 2).
+
+
+ You must declare all line styles before you use them (see example).
+
+
+ This simple example will draw a big "!#%*@", in funny colors and
+ gracious style.
+
+ swfshape->setline example
+
+<?php
+ $s = new SWFShape();
+ $f1 = $s->addFill(0xff, 0, 0);
+ $f2 = $s->addFill(0xff, 0x7f, 0);
+ $f3 = $s->addFill(0xff, 0xff, 0);
+ $f4 = $s->addFill(0, 0xff, 0);
+ $f5 = $s->addFill(0, 0, 0xff);
+
+ // bug: have to declare all line styles before you use them
+ $s->setLine(40, 0x7f, 0, 0);
+ $s->setLine(40, 0x7f, 0x3f, 0);
+ $s->setLine(40, 0x7f, 0x7f, 0);
+ $s->setLine(40, 0, 0x7f, 0);
+ $s->setLine(40, 0, 0, 0x7f);
+
+ $f = new SWFFont('Techno.fdb');
+
+ $s->setRightFill($f1);
+ $s->setLine(40, 0x7f, 0, 0);
+ $s->drawGlyph($f, '!');
+ $s->movePen($f->getWidth('!'), 0);
+
+ $s->setRightFill($f2);
+ $s->setLine(40, 0x7f, 0x3f, 0);
+ $s->drawGlyph($f, '#');
+ $s->movePen($f->getWidth('#'), 0);
+
+ $s->setRightFill($f3);
+ $s->setLine(40, 0x7f, 0x7f, 0);
+ $s->drawGlyph($f, '%');
+ $s->movePen($f->getWidth('%'), 0);
+
+ $s->setRightFill($f4);
+ $s->setLine(40, 0, 0x7f, 0);
+ $s->drawGlyph($f, '*');
+ $s->movePen($f->getWidth('*'), 0);
+
+ $s->setRightFill($f5);
+ $s->setLine(40, 0, 0, 0x7f);
+ $s->drawGlyph($f, '@');
+
+ $m = new SWFMovie();
+ $m->setDimension(3000,2000);
+ $m->setRate(12.0);
+ $i = $m->add($s);
+ $i->moveTo(1500-$f->getWidth("!#%*@")/2, 1000+$f->getAscent()/2);
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+
+
+
+
+ SWFShape->addFill
+ Adds a solid fill to the shape.
+
+
+ Description
+
+
+ void swfshape->addfill
+ int red
+ int green
+ int blue
+ int a
+
+
+ &warn.experimental.func;
+
+
+ void swfshape->addfill
+ SWFbitmap bitmap
+ int flags
+
+
+ &warn.experimental.func;
+
+
+ void swfshape->addfill
+ SWFGradient gradient
+ int flags
+
+
+ &warn.experimental.func;
+
+ swfshape->addfill adds a solid fill to the shape's list
+ of fill styles. swfshape->addfill accepts three different
+ types of arguments.
+
+
+ red, green, blue
+ is a color (RGB mode). Last parameter a is optional.
+
+
+ The bitmap argument is an swfbitmap object.
+ The flags argument can be one
+ of the following values : SWFFILL_CLIPPED_BITMAP or SWFFILL_TILED_BITMAP.
+ Default is SWFFILL_TILED_BITMAP. I think.
+
+
+ The gradient argument is an swfgradient
+ object. The flags argument can be one of the following values :
+ SWFFILL_RADIAL_GRADIENT or SWFFILL_LINEAR_GRADIENT. Default is
+ SWFFILL_LINEAR_GRADIENT. I'm sure about this one. Really.
+
+
+ swfshape->addfill returns an swffill
+ object for use with the swfshape->setleftfill
+ and swfshape->setrightfill functions
+ described below.
+
+
+ See also
+ swfshape->setleftfill and
+ swfshape->setrightfill.
+
+
+ This simple example will draw a frame on a bitmap. Ah, here's another buglet in
+ the flash player- it doesn't seem to care about the second shape's bitmap's
+ transformation in a morph. According to spec, the bitmap should stretch
+ along with the shape in this example..
+
+ swfshape->addfill example
+
+<?php
+
+ $p = new SWFMorph();
+
+ $b = new SWFBitmap("alphafill.jpg");
+ // use your own bitmap
+ $width = $b->getWidth();
+ $height = $b->getHeight();
+
+ $s = $p->getShape1();
+ $f = $s->addFill($b, SWFFILL_TILED_BITMAP);
+ $f->moveTo(-$width/2, -$height/4);
+ $f->scaleTo(1.0, 0.5);
+ $s->setLeftFill($f);
+ $s->movePenTo(-$width/2, -$height/4);
+ $s->drawLine($width, 0);
+ $s->drawLine(0, $height/2);
+ $s->drawLine(-$width, 0);
+ $s->drawLine(0, -$height/2);
+
+ $s = $p->getShape2();
+ $f = $s->addFill($b, SWFFILL_TILED_BITMAP);
+
+ // these two have no effect!
+ $f->moveTo(-$width/4, -$height/2);
+ $f->scaleTo(0.5, 1.0);
+
+ $s->setLeftFill($f);
+ $s->movePenTo(-$width/4, -$height/2);
+ $s->drawLine($width/2, 0);
+ $s->drawLine(0, $height);
+ $s->drawLine(-$width/2, 0);
+ $s->drawLine(0, -$height);
+
+ $m = new SWFMovie();
+ $m->setDimension($width, $height);
+ $i = $m->add($p);
+ $i->moveTo($width/2, $height/2);
+
+ for($n=0; $n<1.001; $n+=0.03)
+ {
+ $i->setRatio($n);
+ $m->nextFrame();
+ }
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+
+
+
+
+ SWFShape->setLeftFill
+ Sets left rasterizing color.
+
+
+ Description
+
+
+ void swfshape->setleftfill
+ swfgradient fill
+
+
+ &warn.experimental.func;
+
+
+ void swfshape->setleftfill
+ int red
+ int green
+ int blue
+ int a
+
+
+ &warn.experimental.func;
+
+ What this nonsense is about is, every edge segment borders at most two fills.
+ When rasterizing the object, it's pretty handy to know what those fills are
+ ahead of time, so the swf format requires these to be specified.
+
+
+ swfshape->setleftfill sets the fill on the left side of
+ the edge- that is, on the interior if you're defining the outline of the shape in a counter-clockwise
+ fashion. The fill object is an SWFFill object returned from one of the addFill
+ functions above.
+
+
+ This seems to be reversed when you're defining a shape in a morph, though.
+ If your browser crashes, just try setting the fill on the other side.
+
+
+ Shortcut for swfshape->setleftfill($s->addfill($r, $g, $b [, $a]));.
+
+
+ See also
+ swfshape->setrightfill.
+
+
+
+
+
+
+ SWFShape->setRightFill
+ Sets right rasterizing color.
+
+
+ Description
+
+
+ void swfshape->setrightfill
+ swfgradient fill
+
+
+ &warn.experimental.func;
+
+
+ void swfshape->setrightfill
+ int red
+ int green
+ int blue
+ int a
+
+
+ &warn.experimental.func;
+
+ See also
+ swfshape->setleftfill.
+
+
+ Shortcut for swfshape->setrightfill($s->addfill($r, $g, $b [, $a]));.
+
+
+
+
+
+
+ SWFShape->movePenTo
+ Moves the shape's pen.
+
+
+ Description
+
+
+ void swfshape->movepento
+ int x
+ int y
+
+
+ &warn.experimental.func;
+
+ swfshape->setrightfill move the shape's pen to
+ (x,y) in the shape's
+ coordinate space.
+
+
+ See also
+ swfshape->movepen,
+ swfshape->drawcurveto,
+ swfshape->drawlineto and
+ swfshape->drawline.
+
+
+
+
+
+
+ SWFShape->movePen
+ Moves the shape's pen (relative).
+
+
+ Description
+
+
+ void swfshape->movepen
+ int dx
+ int dy
+
+
+ &warn.experimental.func;
+
+ swfshape->setrightfill move the shape's pen from
+ coordinates (current x,current y) to (current x + dx,
+ current y + dy) in the shape's coordinate space.
+
+
+ See also
+ swfshape->movepento,
+ swfshape->drawcurveto,
+ swfshape->drawlineto and
+ swfshape->drawline.
+
+
+
+
+
+
+ SWFShape->drawLineTo
+ Draws a line.
+
+
+ Description
+
+
+ void swfshape->drawlineto
+ int x
+ int y
+
+
+ &warn.experimental.func;
+
+ swfshape->setrightfill draws a line (using the
+ current line style, set by swfshape->setline) from the current
+ pen position to point (x,y)
+ in the shape's coordinate space.
+
+
+ See also
+ swfshape->movepento,
+ swfshape->drawcurveto,
+ swfshape->movepen and
+ swfshape->drawline.
+
+
+
+
+
+
+ SWFShape->drawLine
+ Draws a line (relative).
+
+
+ Description
+
+
+ void swfshape->drawline
+ int dx
+ int dy
+
+
+ &warn.experimental.func;
+
+ swfshape->setrightfill draws a line (using the current line style
+ set by swfshape->setline) from the current pen position to
+ displacement (dx,dy).
+
+
+ See also
+ swfshape->movepento,
+ swfshape->drawcurveto,
+ swfshape->movepen and
+ swfshape->drawlineto.
+
+
+
+
+
+
+ SWFShape->drawCurveTo
+ Draws a curve.
+
+
+ Description
+
+
+ void swfshape->drawcurveto
+ int controlx
+ int controly
+ int anchorx
+ int anchory
+
+
+ &warn.experimental.func;
+
+ swfshape->drawcurveto draws a quadratic curve
+ (using the current line style, set by swfshape->setline)
+ from the current pen position to
+ (anchorx,anchory)
+ using (controlx,controly)
+ as a control point. That is, head towards the control point,
+ then smoothly turn to the anchor point.
+
+
+ See also
+ swfshape->drawlineto,
+ swfshape->drawline,
+ swfshape->movepento and
+ swfshape->movepen.
+
+
+
+
+
+
+ SWFShape->drawCurve
+ Draws a curve (relative).
+
+
+ Description
+
+
+ void swfshape->drawcurve
+ int controldx
+ int controldy
+ int anchordx
+ int anchordy
+
+
+ &warn.experimental.func;
+
+ swfshape->drawcurve draws a quadratic curve
+ (using the current line style,set by swfshape->setline)
+ from the current pen position to the relative position
+ (anchorx,anchory)
+ using relative control point
+ (controlx,controly).
+ That is, head towards the control point, then smoothly turn to the
+ anchor point.
+
+
+ See also
+ swfshape->drawlineto,
+ swfshape->drawline,
+ swfshape->movepento and
+ swfshape->movepen.
+
+
+
+
+
+
+
+
+ SWFGradient
+ Creates a gradient object
+
+
+ Description
+
+
+ new swfgradient
+
+
+
+ &warn.experimental.func;
+
+ swfgradient creates a new SWFGradient object.
+
+
+ After you've added the entries to your gradient, you can use the gradient
+ in a shape fill with the swfshape->addfill method.
+
+
+ SWFGradient has the following methods : swfgradient->addentry.
+
+
+ This simple example will draw a big black-to-white gradient as background,
+ and a redish disc in its center.
+
+ swfgradient example
+
+<?php
+
+ $m = new SWFMovie();
+ $m->setDimension(320, 240);
+
+ $s = new SWFShape();
+
+ // first gradient- black to white
+ $g = new SWFGradient();
+ $g->addEntry(0.0, 0, 0, 0);
+ $g->addEntry(1.0, 0xff, 0xff, 0xff);
+
+ $f = $s->addFill($g, SWFFILL_LINEAR_GRADIENT);
+ $f->scaleTo(0.01);
+ $f->moveTo(160, 120);
+ $s->setRightFill($f);
+ $s->drawLine(320, 0);
+ $s->drawLine(0, 240);
+ $s->drawLine(-320, 0);
+ $s->drawLine(0, -240);
+
+ $m->add($s);
+
+ $s = new SWFShape();
+
+ // second gradient- radial gradient from red to transparent
+ $g = new SWFGradient();
+ $g->addEntry(0.0, 0xff, 0, 0, 0xff);
+ $g->addEntry(1.0, 0xff, 0, 0, 0);
+
+ $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT);
+ $f->scaleTo(0.005);
+ $f->moveTo(160, 120);
+ $s->setRightFill($f);
+ $s->drawLine(320, 0);
+ $s->drawLine(0, 240);
+ $s->drawLine(-320, 0);
+ $s->drawLine(0, -240);
+
+ $m->add($s);
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+
+
+
+
+ SWFGradient->addEntry
+ Adds an entry to the gradient list.
+
+
+ Description
+
+
+ void swfgradient->addentry
+ float ratio
+ int red
+ int green
+ int blue
+ int a
+
+
+ &warn.experimental.func;
+
+ swfgradient->addentry adds an entry to the gradient list.
+ ratio is a number between 0 and 1 indicating where in
+ the gradient this color appears. Thou shalt add entries in order of increasing ratio.
+
+
+ red, green, blue
+ is a color (RGB mode). Last parameter a is optional.
+
+
+
+
+
+
+
+
+ SWFBitmap
+ Loads Bitmap object
+
+
+ Description
+
+
+ new swfbitmap
+ string filename
+ int alphafilename
+
+
+ &warn.experimental.func;
+
+ swfbitmap creates a new SWFBitmap object from
+ the Jpeg or DBL file named filename.
+ alphafilename indicates a MSK file to
+ be used as an alpha mask for a Jpeg image.
+
+
+
+ We can only deal with baseline (frame 0) jpegs, no baseline optimized or
+ progressive scan jpegs!
+
+
+
+ SWFBitmap has the following methods : swfbitmap->getwidth
+ and swfbitmap->getheight.
+
+
+ You can't import png images directly, though- have to use the png2dbl
+ utility to make a dbl ("define bits lossless") file from the png.
+ The reason for this is that I don't want a dependency on the png library
+ in ming- autoconf should solve this, but that's not set up yet.
+
+ Import PNG files
+
+<?php
+ $s = new SWFShape();
+ $f = $s->addFill(new SWFBitmap("png.dbl"));
+ $s->setRightFill($f);
+
+ $s->drawLine(32, 0);
+ $s->drawLine(0, 32);
+ $s->drawLine(-32, 0);
+ $s->drawLine(0, -32);
+
+ $m = new SWFMovie();
+ $m->setDimension(32, 32);
+ $m->add($s);
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+ And you can put an alpha mask on a jpeg fill.
+
+ swfbitmap example
+
+<?php
+
+ $s = new SWFShape();
+
+ // .msk file generated with "gif2mask" utility
+ $f = $s->addFill(new SWFBitmap("alphafill.jpg", "alphafill.msk"));
+ $s->setRightFill($f);
+
+ $s->drawLine(640, 0);
+ $s->drawLine(0, 480);
+ $s->drawLine(-640, 0);
+ $s->drawLine(0, -480);
+
+ $c = new SWFShape();
+ $c->setRightFill($c->addFill(0x99, 0x99, 0x99));
+ $c->drawLine(40, 0);
+ $c->drawLine(0, 40);
+ $c->drawLine(-40, 0);
+ $c->drawLine(0, -40);
+
+ $m = new SWFMovie();
+ $m->setDimension(640, 480);
+ $m->setBackground(0xcc, 0xcc, 0xcc);
+
+ // draw checkerboard background
+ for($y=0; $y<480; $y+=40)
+ {
+ for($x=0; $x<640; $x+=80)
+ {
+ $i = $m->add($c);
+ $i->moveTo($x, $y);
+ }
+
+ $y+=40;
+
+ for($x=40; $x<640; $x+=80)
+ {
+ $i = $m->add($c);
+ $i->moveTo($x, $y);
+ }
+ }
+
+ $m->add($s);
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+
+
+
+
+ SWFBitmap->getWidth
+ Returns the bitmap's width.
+
+
+ Description
+
+
+ int swfbitmap->getwidth
+
+
+
+ &warn.experimental.func;
+
+ swfbitmap->getwidth returns the bitmap's width in pixels.
+
+
+ See also
+ swfbitmap->getheight.
+
+
+
+
+
+
+ SWFBitmap->getHeight
+ Returns the bitmap's height.
+
+
+ Description
+
+
+ int swfbitmap->getheight
+
+
+
+ &warn.experimental.func;
+
+ swfbitmap->getheight returns the bitmap's height in pixels.
+
+
+ See also
+ swfbitmap->getwidth.
+
+
+
+
+
+
+
+
+ SWFFill
+ Loads SWFFill object
+
+
+ Description
+
+ The swffill object allows you to transform
+ (scale, skew, rotate) bitmap and gradient fills. swffill
+ objects are created by the swfshape->addfill methods.
+
+
+ SWFFill has the following methods : swffill->moveto
+ and swffill->scaleto, swffill->rotateto,
+ swffill->skewxto and swffill->skewyto.
+
+
+
+
+
+
+ SWFFill->moveTo
+ Moves fill origin
+
+
+ Description
+
+
+ void swffill->moveto
+ int x
+ int y
+
+
+ &warn.experimental.func;
+
+ swffill->moveto moves fill's origin to
+ (x,y) in global coordinates.
+
+
+
+
+
+
+ SWFFill->scaleTo
+ Sets fill's scale
+
+
+ Description
+
+
+ void swffill->scaleto
+ int x
+ int y
+
+
+ &warn.experimental.func;
+
+ swffill->scaleto sets fill's scale to
+ x in the x-direction,
+ y in the y-direction.
+
+
+
+
+
+
+ SWFFill->rotateTo
+ Sets fill's rotation
+
+
+ Description
+
+
+ void swffill->rotateto
+ float degrees
+
+
+ &warn.experimental.func;
+
+ swffill->rotateto sets fill's rotation to
+ degrees degrees.
+
+
+
+
+
+
+ SWFFill->skewXTo
+ Sets fill x-skew
+
+
+ Description
+
+
+ void swffill->skewxto
+ float x
+
+
+ &warn.experimental.func;
+
+ swffill->skewxto sets fill x-skew to x.
+ For x is 1.0, it is a is a 45-degree
+ forward slant. More is more forward, less is more backward.
+
+
+
+
+
+
+ SWFFill->skewYTo
+ Sets fill y-skew
+
+
+ Description
+
+
+ void swffill->skewyto
+ float y
+
+
+ &warn.experimental.func;
+
+ swffill->skewyto sets fill y-skew to y.
+ For y is 1.0, it is a is a 45-degree
+ upward slant. More is more upward, less is more downward.
+
+
+
+
+
+
+
+
+ SWFMorph
+ Creates a new SWFMorph object.
+
+
+ Description
+
+
+ new swfmorph
+
+
+
+ &warn.experimental.func;
+
+ swfmorph creates a new SWFMorph object.
+
+
+ Also called a "shape tween". This thing lets you make those tacky
+ twisting things that make your computer choke. Oh, joy!
+
+
+ The methods here are sort of weird. It would make more sense to just
+ have newSWFMorph(shape1, shape2);, but as things are now, shape2 needs
+ to know that it's the second part of a morph. (This, because it starts
+ writing its output as soon as it gets drawing commands- if it kept its
+ own description of its shapes and wrote on completion this and some
+ other things would be much easier.)
+
+
+ SWFMorph has the following methods : swfmorph->getshape1
+ and swfmorph->getshape1.
+
+
+ This simple example will morph a big red square into a smaller
+ blue black-bordered square.
+
+ swfmorph example
+
+<?php
+ $p = new SWFMorph();
+
+ $s = $p->getShape1();
+ $s->setLine(0,0,0,0);
+
+ /* Note that this is backwards from normal shapes (left instead of right).
+ I have no idea why, but this seems to work.. */
+
+ $s->setLeftFill($s->addFill(0xff, 0, 0));
+ $s->movePenTo(-1000,-1000);
+ $s->drawLine(2000,0);
+ $s->drawLine(0,2000);
+ $s->drawLine(-2000,0);
+ $s->drawLine(0,-2000);
+
+ $s = $p->getShape2();
+ $s->setLine(60,0,0,0);
+ $s->setLeftFill($s->addFill(0, 0, 0xff));
+ $s->movePenTo(0,-1000);
+ $s->drawLine(1000,1000);
+ $s->drawLine(-1000,1000);
+ $s->drawLine(-1000,-1000);
+ $s->drawLine(1000,-1000);
+
+ $m = new SWFMovie();
+ $m->setDimension(3000,2000);
+ $m->setBackground(0xff, 0xff, 0xff);
+
+ $i = $m->add($p);
+ $i->moveTo(1500,1000);
+
+ for($r=0.0; $r<=1.0; $r+=0.1)
+ {
+ $i->setRatio($r);
+ $m->nextFrame();
+ }
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+
+
+
+
+ SWFMorph->getshape1
+ Gets a handle to the starting shape
+
+
+ Description
+
+
+ mixed swfmorph->getshape1
+
+
+
+ &warn.experimental.func;
+
+ swfmorph->getshape1 gets a handle to the morph's
+ starting shape. swfmorph->getshape1 returns an
+ swfshape object.
+
+
+
+
+
+
+ SWFMorph->getshape2
+ Gets a handle to the ending shape
+
+
+ Description
+
+
+ mixed swfmorph->getshape2
+
+
+
+ &warn.experimental.func;
+
+ swfmorph->getshape2 gets a handle to the morph's
+ ending shape. swfmorph->getshape2 returns an
+ swfshape object.
+
+
+
+
+
+
+
+
+ SWFText
+ Creates a new SWFText object.
+
+
+ Description
+
+
+ new swftext
+
+
+
+ &warn.experimental.func;
+
+ swftext creates a new SWFText object,
+ fresh for manipulating.
+
+
+ SWFText has the following methods : swftext->setfont,
+ swftext->setheight, swftext->setspacing,
+ swftext->setcolor, swftext->moveto,
+ swftext->addstring and swftext->getwidth.
+
+
+ This simple example will draw a big yellow "PHP generates Flash with Ming"
+ text, on white background.
+
+ swftext example
+
+<?php
+ $f = new SWFFont("Techno.fdb");
+ $t = new SWFText();
+ $t->setFont($f);
+ $t->moveTo(200, 2400);
+ $t->setColor(0xff, 0xff, 0);
+ $t->setHeight(1200);
+ $t->addString("PHP generates Flash with Ming!!");
+
+ $m = new SWFMovie();
+ $m->setDimension(5400, 3600);
+
+ $m->add($t);
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+
+
+
+
+ SWFText->setFont
+ Sets the current font
+
+
+ Description
+
+
+ void swftext->setfont
+ string font
+
+
+ &warn.experimental.func;
+
+ swftext->setfont sets the current font to
+ font.
+
+
+
+
+
+
+ SWFText->setHeight
+ Sets the current font height
+
+
+ Description
+
+
+ void swftext->setheight
+ int height
+
+
+ &warn.experimental.func;
+
+ swftext->setheight sets the current font height to
+ height. Default is 240.
+
+
+
+
+
+
+ SWFText->setSpacing
+ Sets the current font spacing
+
+
+ Description
+
+
+ void swftext->setspacing
+ float spacing
+
+
+ &warn.experimental.func;
+
+ swftext->setspacing sets the current font spacing to
+ spacingspacing. Default is 1.0.
+ 0 is all of the letters written at the same point. This doesn't really work
+ that well because it inflates the advance across the letter, doesn't add
+ the same amount of spacing between the letters. I should try and explain
+ that better, prolly. Or just fix the damn thing to do constant spacing.
+ This was really just a way to figure out how letter advances work,
+ anyway.. So nyah.
+
+
+
+
+
+
+ SWFText->setColor
+ Sets the current font color
+
+
+ Description
+
+
+ void swftext->setcolor
+ int red
+ int green
+ int blue
+ int a
+
+
+ &warn.experimental.func;
+
+ swftext->setspacing changes the current text color.
+ Default is black. I think. Color is represented using the RGB system.
+
+
+
+
+
+
+ SWFText->moveTo
+ Moves the pen
+
+
+ Description
+
+
+ void swftext->moveto
+ int x
+ int y
+
+
+ &warn.experimental.func;
+
+ swftext->moveto moves the pen (or cursor, if
+ that makes more sense) to (x,y)
+ in text object's coordinate space. If either is zero, though, value
+ in that dimension stays the same. Annoying, should be fixed.
+
+
+
+
+
+
+ SWFText->addString
+ Draws a string
+
+
+ Description
+
+
+ void swftext->addstring
+ string string
+
+
+ &warn.experimental.func;
+
+ swftext->addstring draws the string string
+ at the current pen (cursor) location. Pen is at the baseline of the text;
+ i.e., ascending text is in the -y direction.
+
+
+
+
+
+
+ SWFText->getWidth
+ Computes string's width
+
+
+ Description
+
+
+ void swftext->addstring
+ string string
+
+
+ &warn.experimental.func;
+
+ swftext->addstring returns the rendered width of the
+ string string at the text object's current font,
+ scale, and spacing settings.
+
+
+
+
+
+
+
+
+ SWFFont
+ Loads a font definition
+
+
+ Description
+
+
+ new swffont
+ string filename
+
+
+ &warn.experimental.func;
+
+ If filename is the name of an FDB file
+ (i.e., it ends in ".fdb"), load the font definition found in said
+ file. Otherwise, create a browser-defined font reference.
+
+
+ FDB ("font definition block") is a very simple wrapper for the SWF DefineFont2
+ block which contains a full description of a font. One may create FDB files from
+ SWT Generator template files with the included makefdb utility- look in the
+ util directory off the main ming distribution directory.
+
+
+ Browser-defined fonts don't contain any information about the font other
+ than its name. It is assumed that the font definition will be provided by
+ the movie player. The fonts _serif, _sans, and _typewriter should always
+ be available. For example:
+
+<?php
+$f = newSWFFont("_sans");
+?>
+
+ will give you the standard sans-serif font, probably the same as what you'd get
+ with <font name="sans-serif"> in HTML.
+
+
+ swffont returns a reference to the font
+ definition, for use in the SWFText->setFont
+ and the SWFTextField->setFont methods.
+
+
+ SWFFont has the following methods : swffont->getwidth.
+
+
+
+
+
+
+ swffont->getwidth
+ Returns the string's width
+
+
+ Description
+
+
+ int swffont->getwidth
+ string string
+
+
+ &warn.experimental.func;
+
+ swffont->getwidth returns the string
+ string's width, using font's default scaling.
+ You'll probably want to use the SWFText version of this method which
+ uses the text object's scale.
+
+
+
+
+
+
+
+
+ SWFTextField
+ Creates a text field object
+
+
+ Description
+
+
+ new swftextfield
+ int flags
+
+
+ &warn.experimental.func;
+
+ swftextfield creates a new text field object.
+ Text Fields are less flexible than swftext objects-
+ they can't be rotated, scaled non-proportionally, or skewed, but they can
+ be used as form entries, and they can use browser-defined fonts.
+
+
+ The optional flags change the text field's behavior. It has the following
+ possibles values :
+
+
+
+ SWFTEXTFIELD_NOEDIT indicates that the field shouldn't be user-editable
+
+
+
+
+ SWFTEXTFIELD_PASSWORD obscures the data entry
+
+
+
+
+ SWFTEXTFIELD_DRAWBOX draws the outline of the textfield
+
+
+
+
+ SWFTEXTFIELD_MULTILINE allows multiple lines
+
+
+
+
+ SWFTEXTFIELD_WORDWRAP allows text to wrap
+
+
+
+
+ SWFTEXTFIELD_NOSELECT makes the field non-selectable
+
+
+
+ Flags are combined with the bitwise
+ OR operation. For example,
+
+<?php
+$t = newSWFTextField(SWFTEXTFIELD_PASSWORD | SWFTEXTFIELD_NOEDIT);
+?>
+
+ creates a totally useless non-editable password field.
+
+
+ SWFTextField has the following methods : swftextfield->setfont,
+ swftextfield->setbounds, swftextfield->align,
+ swftextfield->setheight, swftextfield->setleftmargin,
+ swftextfield->setrightmargin, swftextfield->setmargins,
+ swftextfield->setindentation, swftextfield->setlinespacing,
+ swftextfield->setcolor, swftextfield->setname and
+ swftextfield->addstring.
+
+
+
+
+
+
+ SWFTextField->setFont
+ Sets the text field font
+
+
+ Description
+
+
+ void swftextfield->setfont
+ string font
+
+
+ &warn.experimental.func;
+
+ swftextfield->setfont sets the text field font to
+ the [browser-defined?] font font.
+
+
+
+
+
+
+ SWFTextField->setbounds
+ Sets the text field width and height
+
+
+ Description
+
+
+ void swftextfield->setbounds
+ int width
+ int height
+
+
+ &warn.experimental.func;
+
+ swftextfield->setbounds sets the text field width
+ to width and height to height.
+ If you don't set the bounds yourself, Ming makes a poor guess at what
+ the bounds are.
+
+
+
+
+
+
+ SWFTextField->align
+ Sets the text field alignment
+
+
+ Description
+
+
+ void swftextfield->align
+ int alignement
+
+
+ &warn.experimental.func;
+
+ swftextfield->align sets the text field alignment
+ to alignement. Valid values for
+ alignement are : SWFTEXTFIELD_ALIGN_LEFT,
+ SWFTEXTFIELD_ALIGN_RIGHT, SWFTEXTFIELD_ALIGN_CENTER and
+ SWFTEXTFIELD_ALIGN_JUSTIFY.
+
+
+
+
+
+
+ SWFTextField->setHeight
+ Sets the font height of this text field font.
+
+
+ Description
+
+
+ void swftextfield->setheight
+ int height
+
+
+ &warn.experimental.func;
+
+ swftextfield->setheight sets the font height of this text field
+ font to the given height height. Default is 240.
+
+
+
+
+
+
+ SWFTextField->setLeftMargin
+ Sets the left margin width of the text field.
+
+
+ Description
+
+
+ void swftextfield->setleftmargin
+ int width
+
+
+ &warn.experimental.func;
+
+ swftextfield->setleftmargin sets the left margin width
+ of the text field to width. Default is 0.
+
+
+
+
+
+
+ SWFTextField->setrightMargin
+ Sets the right margin width of the text field.
+
+
+ Description
+
+
+ void swftextfield->setrightmargin
+ int width
+
+
+ &warn.experimental.func;
+
+ swftextfield->setrightmargin sets the right margin width
+ of the text field to width. Default is 0.
+
+
+
+
+
+
+ SWFTextField->setMargins
+ Sets the margins width of the text field.
+
+
+ Description
+
+
+ void swftextfield->setmargins
+ int left
+ int right
+
+
+ &warn.experimental.func;
+
+ swftextfield->setmargins set both margins at once,
+ for the man on the go.
+
+
+
+
+
+
+ SWFTextField->setindentation
+ Sets the indentation of the first line.
+
+
+ Description
+
+
+ void swftextfield->setindentation
+ int width
+
+
+ &warn.experimental.func;
+
+ swftextfield->setindentation sets the indentation of
+ the first line in the text field, to width.
+
+
+
+
+
+
+ SWFTextField->setLineSpacing
+ Sets the line spacing of the text field.
+
+
+ Description
+
+
+ void swftextfield->setlinespacing
+ int height
+
+
+ &warn.experimental.func;
+
+ swftextfield->setlinespacing sets the line spacing
+ of the text field to the height of height. Default is 40.
+
+
+
+
+
+
+ SWFTextField->setcolor
+ Sets the color of the text field.
+
+
+ Description
+
+
+ void swftextfield->setcolor
+ int red
+ int green
+ int blue
+ int a
+
+
+ &warn.experimental.func;
+
+ swftextfield->setcolor sets the color of the text field.
+ Default is fully opaque black. Color is represented using RGB system.
+
+
+
+
+
+
+ SWFTextField->setname
+ Sets the variable name
+
+
+ Description
+
+
+ void swftextfield->setname
+ string name
+
+
+ &warn.experimental.func;
+
+ swftextfield->setname sets the variable name of this
+ text field to name, for form posting and action
+ scripting purposes.
+
+
+
+
+
+
+ SWFTextField->addstring
+ Concatenates the given string to the text field
+
+
+ Description
+
+
+ void swftextfield->addstring
+ string string
+
+
+ &warn.experimental.func;
+
+ swftextfield->setname concatenates the string
+ string to the text field.
+
+
+
+
+
+
+
+
+ SWFSprite
+ Creates a movie clip (a sprite)
+
+
+ Description
+
+
+ new swfsprite
+
+
+
+ &warn.experimental.func;
+
+ swfsprite are also known as a "movie clip",
+ this allows one to create objects which are animated in their own
+ timelines. Hence, the sprite has most of the same methods as the movie.
+
+
+ swfsprite has the following methods :
+ swfsprite->add,
+ swfsprite->remove, swfsprite->nextframe
+ and swfsprite->setframes.
+
+
+ This simple example will spin gracefully a big red square.
+
+ swfsprite example
+
+<?php
+ $s = new SWFShape();
+ $s->setRightFill($s->addFill(0xff, 0, 0));
+ $s->movePenTo(-500,-500);
+ $s->drawLineTo(500,-500);
+ $s->drawLineTo(500,500);
+ $s->drawLineTo(-500,500);
+ $s->drawLineTo(-500,-500);
+
+ $p = new SWFSprite();
+ $i = $p->add($s);
+ $p->nextFrame();
+ $i->rotate(15);
+ $p->nextFrame();
+ $i->rotate(15);
+ $p->nextFrame();
+ $i->rotate(15);
+ $p->nextFrame();
+ $i->rotate(15);
+ $p->nextFrame();
+ $i->rotate(15);
+ $p->nextFrame();
+
+ $m = new SWFMovie();
+ $i = $m->add($p);
+ $i->moveTo(1500,1000);
+ $i->setName("blah");
+
+ $m->setBackground(0xff, 0xff, 0xff);
+ $m->setDimension(3000,2000);
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+
+
+
+
+ SWFSprite->add
+ Adds an object to a sprite
+
+
+ Description
+
+
+ void swfsprite->add
+ ressource object
+
+
+ &warn.experimental.func;
+
+ swfsprite->add adds a swfshape, a
+ swfbutton, a swftext,
+ a swfaction or a swfsprite object.
+
+
+ For displayable types (swfshape,
+ swfbutton, swftext,
+ swfaction or swfsprite),
+ this returns a handle to the object in a display list.
+
+
+
+
+
+
+ SWFSprite->remove
+ Removes an object to a sprite
+
+
+ Description
+
+
+ void swfsprite->remove
+ ressource object
+
+
+ &warn.experimental.func;
+
+ swfsprite->remove remove a swfshape, a
+ swfbutton, a swftext,
+ a swfaction or a swfsprite object
+ from the sprite.
+
+
+
+
+
+
+ SWFSprite->setframes
+ Sets the total number of frames in the animation.
+
+
+ Description
+
+
+ void swfsprite->setframes
+ int numberofframes
+
+
+ &warn.experimental.func;
+
+ swfsprite->setframes sets the total number of frames
+ in the animation to numberofframes.
+
+
+
+
+
+
+ SWFSprite->nextframe
+ Moves to the next frame of the animation.
+
+
+ Description
+
+
+ void swfsprite->nextframe
+
+
+
+ &warn.experimental.func;
+
+ swfsprite->setframes moves to the next frame of
+ the animation.
+
+
+
+
+
+
+
+
+ SWFbutton
+ Creates a new Button.
+
+
+ Description
+
+
+ new swfbutton
+
+
+
+ &warn.experimental.func;
+
+ swfbutton creates a new Button.
+ Roll over it, click it, see it call action code. Swank.
+
+
+ SWFButton has the following methods : swfbutton->addshape,
+ swfbutton->setup, swfbutton->setover
+ swfbutton->setdown, swfbutton->sethit
+ swfbutton->setaction and
+ swfbutton->addaction.
+
+
+ This simple example will show your usual interactions with buttons :
+ rollover, rollon, mouseup, mousedown, noaction.
+
+ swfbutton example
+
+<?php
+
+ $f = new SWFFont("_serif");
+
+ $p = new SWFSprite();
+
+ function label($string)
+ {
+ global $f;
+
+ $t = new SWFTextField();
+ $t->setFont($f);
+ $t->addString($string);
+ $t->setHeight(200);
+ $t->setBounds(3200,200);
+ return $t;
+ }
+ function addLabel($string)
+ {
+ global $p;
+
+ $i = $p->add(label($string));
+ $p->nextFrame();
+ $p->remove($i);
+ }
+
+ $p->add(new SWFAction("stop();"));
+ addLabel("NO ACTION");
+ addLabel("SWFBUTTON_MOUSEUP");
+ addLabel("SWFBUTTON_MOUSEDOWN");
+ addLabel("SWFBUTTON_MOUSEOVER");
+ addLabel("SWFBUTTON_MOUSEOUT");
+ addLabel("SWFBUTTON_MOUSEUPOUTSIDE");
+ addLabel("SWFBUTTON_DRAGOVER");
+ addLabel("SWFBUTTON_DRAGOUT");
+
+ function rect($r, $g, $b)
+ {
+ $s = new SWFShape();
+ $s->setRightFill($s->addFill($r, $g, $b));
+ $s->drawLine(600,0);
+ $s->drawLine(0,600);
+ $s->drawLine(-600,0);
+ $s->drawLine(0,-600);
+
+ return $s;
+ }
+
+ $b = new SWFButton();
+ $b->addShape(rect(0xff, 0, 0), SWFBUTTON_UP | SWFBUTTON_HIT);
+ $b->addShape(rect(0, 0xff, 0), SWFBUTTON_OVER);
+ $b->addShape(rect(0, 0, 0xff), SWFBUTTON_DOWN);
+
+ $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(1);"),
+ SWFBUTTON_MOUSEUP);
+
+ $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(2);"),
+ SWFBUTTON_MOUSEDOWN);
+
+ $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(3);"),
+ SWFBUTTON_MOUSEOVER);
+
+ $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(4);"),
+ SWFBUTTON_MOUSEOUT);
+
+ $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(5);"),
+ SWFBUTTON_MOUSEUPOUTSIDE);
+
+ $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(6);"),
+ SWFBUTTON_DRAGOVER);
+
+ $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(7);"),
+ SWFBUTTON_DRAGOUT);
+
+ $m = new SWFMovie();
+ $m->setDimension(4000,3000);
+
+ $i = $m->add($p);
+ $i->setName("label");
+ $i->moveTo(400,1900);
+
+ $i = $m->add($b);
+ $i->moveTo(400,900);
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+ This simple example will enables you to drag draw a big red button
+ on the windows. No drag-and-drop, just moving around.
+
+ swfbutton->addaction example
+
+<?php
+
+ $s = new SWFShape();
+ $s->setRightFill($s->addFill(0xff, 0, 0));
+ $s->drawLine(1000,0);
+ $s->drawLine(0,1000);
+ $s->drawLine(-1000,0);
+ $s->drawLine(0,-1000);
+
+ $b = new SWFButton();
+ $b->addShape($s, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER);
+
+ $b->addAction(new SWFAction("startDrag('/test', 0);"), // '0' means don't lock to mouse
+ SWFBUTTON_MOUSEDOWN);
+
+ $b->addAction(new SWFAction("stopDrag();"),
+ SWFBUTTON_MOUSEUP | SWFBUTTON_MOUSEUPOUTSIDE);
+
+ $p = new SWFSprite();
+ $p->add($b);
+ $p->nextFrame();
+
+ $m = new SWFMovie();
+ $i = $m->add($p);
+ $i->setName('test');
+ $i->moveTo(1000,1000);
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+
+
+
+
+ SWFbutton->addShape
+ Adds a shape to a button
+
+
+ Description
+
+
+ void swfbutton->addshape
+ ressource shape
+ int flags
+
+
+ &warn.experimental.func;
+
+ swfbutton->addshape adds the shape
+ shape to this button. The following
+ flags' values are valid:
+ SWFBUTTON_UP, SWFBUTTON_OVER, SWFBUTTON_DOWN or SWFBUTTON_HIT.
+ SWFBUTTON_HIT isn't ever displayed, it defines the hit region for the button.
+ That is, everywhere the hit shape would be drawn is considered a "touchable"
+ part of the button.
+
+
+
+
+
+
+ SWFbutton->setUp
+ Alias for addShape(shape, SWFBUTTON_UP)
+
+
+ Description
+
+
+ void swfbutton->setup
+ ressource shape
+
+
+ &warn.experimental.func;
+
+ swfbutton->setup alias for addShape(shape, SWFBUTTON_UP).
+
+
+ See also
+ swfbutton->addshape and
+ SWFAction.
+
+
+
+
+
+
+ SWFbutton->setOver
+ Alias for addShape(shape, SWFBUTTON_OVER)
+
+
+ Description
+
+
+ void swfbutton->setover
+ ressource shape
+
+
+ &warn.experimental.func;
+
+ swfbutton->setover alias for addShape(shape, SWFBUTTON_OVER).
+
+
+ See also
+ swfbutton->addshape and
+ SWFAction.
+
+
+
+
+
+
+ SWFbutton->setdown
+ Alias for addShape(shape, SWFBUTTON_DOWN))
+
+
+ Description
+
+
+ void swfbutton->setdown
+ ressource shape
+
+
+ &warn.experimental.func;
+
+ swfbutton->setdown alias for addShape(shape, SWFBUTTON_DOWN).
+
+
+ See also
+ swfbutton->addshape and
+ SWFAction.
+
+
+
+
+
+
+ SWFbutton->setHit
+ Alias for addShape(shape, SWFBUTTON_HIT)
+
+
+ Description
+
+
+ void swfbutton->sethit
+ ressource shape
+
+
+ &warn.experimental.func;
+
+ swfbutton->sethit alias for addShape(shape, SWFBUTTON_HIT).
+
+
+ See also
+ swfbutton->addshape and
+ SWFAction.
+
+
+
+
+
+
+ SWFbutton->addAction
+ Adds an action
+
+
+ Description
+
+
+ void swfbutton->addaction
+ ressource action
+ int flags
+
+
+ &warn.experimental.func;
+
+ swfbutton->addaction adds the action
+ action to this button for the given conditions.
+ The following flags are valid:
+ SWFBUTTON_MOUSEOVER, SWFBUTTON_MOUSEOUT, SWFBUTTON_MOUSEUP,
+ SWFBUTTON_MOUSEUPOUTSIDE, SWFBUTTON_MOUSEDOWN, SWFBUTTON_DRAGOUT and
+ SWFBUTTON_DRAGOVER.
+
+
+ See also
+ swfbutton->addshape and
+ SWFAction.
+
+
+
+
+
+
+ SWFbutton->setAction
+ Sets the action
+
+
+ Description
+
+
+ void swfbutton->setaction
+ ressource action
+
+
+ &warn.experimental.func;
+
+ swfbutton->setaction sets the action to be performed
+ when the button is clicked. Alias for addAction(shape, SWFBUTTON_MOUSEUP).
+ action is a swfaction.
+
+
+ See also
+ swfbutton->addshape and
+ SWFAction.
+
+
+
+
+
+
+
+
+ SWFAction
+ Creates a new Action.
+
+
+ Description
+
+
+ new swfaction
+ string script
+
+
+ &warn.experimental.func;
+
+ swfaction creates a new Action, and
+ compiles the given script into an SWFAction object.
+
+
+ The script syntax is based on the C language, but with a lot taken out- the SWF
+ bytecode machine is just too simpleminded to do a lot of things we might like.
+ For instance, we can't implement function calls without a tremendous
+ amount of hackery because the jump bytecode has a hardcoded offset
+ value. No pushing your calling address to the stack and returning-
+ every function would have to know exactly where to return to.
+
+
+ So what's left? The compiler recognises the following tokens:
+
+
+
+ break
+
+
+
+
+ for
+
+
+
+
+ continue
+
+
+
+
+ if
+
+
+
+
+ else
+
+
+
+
+ do
+
+
+
+
+ while
+
+
+
+
+
+ There is no typed data; all values in the SWF action machine are stored as strings.
+ The following functions can be used in expressions:
+
+
+ time()
+
+
+ Returns the number of milliseconds (?) elapsed since the movie started.
+
+
+
+
+ random(seed)
+
+
+ Returns a pseudo-random number in the range 0-seed.
+
+
+
+
+ length(expr)
+
+
+ Returns the length of the given expression.
+
+
+
+
+ int(number)
+
+
+ Returns the given number rounded down to the nearest integer.
+
+
+
+
+ concat(expr, expr)
+
+
+ Returns the concatenation of the given expressions.
+
+
+
+
+ ord(expr)
+
+
+ Returns the ASCII code for the given character
+
+
+
+
+ chr(num)
+
+
+ Returns the character for the given ASCII code
+
+
+
+
+ substr(string, location, length)
+
+
+ Returns the substring of length length at location location of
+ the given string string.
+
+
+
+
+
+
+ Additionally, the following commands may be used:
+
+
+ duplicateClip(clip, name, depth)
+
+
+ Duplicate the named movie clip (aka sprite). The new movie clip has name name
+ and is at depth depth.
+
+
+
+
+ removeClip(expr)
+
+
+ Removes the named movie clip.
+
+
+
+
+ trace(expr)
+
+
+ Write the given expression to the trace log. Doubtful that the browser
+ plugin does anything with this.
+
+
+
+
+ startDrag(target, lock, [left, top, right, bottom])
+
+
+ Start dragging the movie clip target. The lock argument indicates whether
+ to lock the mouse (?)- use 0 (&false;) or 1 (&true;). Optional parameters
+ define a bounding area for the dragging.
+
+
+
+
+ stopDrag()
+
+
+ Stop dragging my heart around. And this movie clip, too.
+
+
+
+
+ callFrame(expr)
+
+
+ Call the named frame as a function.
+
+
+
+
+ getURL(url, target, [method])
+
+
+ Load the given url into the named target. The target argument can be a
+ frame name (I think), or one of the magical values "_level0" (replaces
+ current movie) or "_level1" (loads new movie on top of current movie).
+ The optional method argument can be post or get if you want to submit
+ variables back to the server.
+
+
+
+
+ loadMovie(url, target)
+
+
+ Same as above, more or less. Come to think of it, I don't quite know what
+ the difference is.
+
+
+
+
+ nextFrame()
+
+
+ Go to the next frame.
+
+
+
+
+ prevFrame()
+
+
+ Go to the last (or, rather, previous) frame.
+
+
+
+
+ play()
+
+
+ Start playing the movie.
+
+
+
+
+ stop()
+
+
+ Stop playing the movie.
+
+
+
+
+ toggleQuality()
+
+
+ Toggle between high and low quality.
+
+
+
+
+ stopSounds()
+
+
+ Stop playing all sounds.
+
+
+
+
+ gotoFrame(num)
+
+
+ Go to frame number num. Frame numbers start at 0.
+
+
+
+
+ gotoFrame(name)
+
+
+ Go to the frame named name. Which does a lot of good, since I
+ haven't added frame labels yet.
+
+
+
+
+ setTarget(expr)
+
+
+ Sets the context for action. Or so they say- I really have no
+ idea what this does.
+
+
+
+
+ And there's one weird extra thing. The expression frameLoaded(num) can be used
+ in if statements and while loops to check if the given frame number has been
+ loaded yet. Well, it's supposed to, anyway, but I've never tested it and I
+ seriously doubt it actually works. You can just use /:framesLoaded instead.
+
+
+ Movie clips (all together now- aka sprites) have properties. You can
+ read all of them (or can you?), you can set some of them, and here
+ they are:
+
+
+
+ x
+
+
+
+
+ y
+
+
+
+
+ xScale
+
+
+
+
+ yScale
+
+
+
+
+ currentFrame - (read-only)
+
+
+
+
+ totalFrames - (read-only)
+
+
+
+
+ alpha - transparency level
+
+
+
+
+ visible - 1=on, 0=off (?)
+
+
+
+
+ width - (read-only)
+
+
+
+
+ height - (read-only)
+
+
+
+
+ rotation
+
+
+
+
+ target - (read-only) (???)
+
+
+
+
+ framesLoaded - (read-only)
+
+
+
+
+ name
+
+
+
+
+ dropTarget - (read-only) (???)
+
+
+
+
+ url - (read-only) (???)
+
+
+
+
+ highQuality - 1=high, 0=low (?)
+
+
+
+
+ focusRect - (???)
+
+
+
+
+ soundBufTime - (???)
+
+
+
+ So, setting a sprite's x position is as simple as /box.x = 100;.
+ Why the slash in front of the box, though? That's how flash keeps
+ track of the sprites in the movie, just like a unix filesystem-
+ here it shows that box is at the top level. If the sprite named
+ box had another sprite named biff inside of it, you'd set its x
+ position with /box/biff.x = 100;. At least, I think so; correct
+ me if I'm wrong here.
+
+
+ This simple example will move the red square across the window.
+
+ swfaction example
+
+<?php
+ $s = new SWFShape();
+ $f = $s->addFill(0xff, 0, 0);
+ $s->setRightFill($f);
+
+ $s->movePenTo(-500,-500);
+ $s->drawLineTo(500,-500);
+ $s->drawLineTo(500,500);
+ $s->drawLineTo(-500,500);
+ $s->drawLineTo(-500,-500);
+
+ $p = new SWFSprite();
+ $i = $p->add($s);
+ $i->setDepth(1);
+ $p->nextFrame();
+
+ for($n=0; $n<5; ++$n)
+ {
+ $i->rotate(-15);
+ $p->nextFrame();
+ }
+
+ $m = new SWFMovie();
+ $m->setBackground(0xff, 0xff, 0xff);
+ $m->setDimension(6000,4000);
+
+ $i = $m->add($p);
+ $i->setDepth(1);
+ $i->moveTo(-500,2000);
+ $i->setName("box");
+
+ $m->add(new SWFAction("/box.x += 3;"));
+ $m->nextFrame();
+ $m->add(new SWFAction("gotoFrame(0); play();"));
+ $m->nextFrame();
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+ This simple example tracks down your mouse on the screen.
+
+ swfaction example
+
+<?php
+
+ $m = new SWFMovie();
+ $m->setRate(36.0);
+ $m->setDimension(1200, 800);
+ $m->setBackground(0, 0, 0);
+
+ /* mouse tracking sprite - empty, but follows mouse so we can
+ get its x and y coordinates */
+
+ $i = $m->add(new SWFSprite());
+ $i->setName('mouse');
+
+ $m->add(new SWFAction("
+ startDrag('/mouse', 1); /* '1' means lock sprite to the mouse */
+ "));
+
+
+ /* might as well turn off antialiasing, since these are just squares. */
+
+ $m->add(new SWFAction("
+ this.quality = 0;
+ "));
+
+ /* morphing box */
+ $r = new SWFMorph();
+ $s = $r->getShape1();
+
+ /* Note this is backwards from normal shapes. No idea why. */
+ $s->setLeftFill($s->addFill(0xff, 0xff, 0xff));
+ $s->movePenTo(-40, -40);
+ $s->drawLine(80, 0);
+ $s->drawLine(0, 80);
+ $s->drawLine(-80, 0);
+ $s->drawLine(0, -80);
+
+ $s = $r->getShape2();
+
+ $s->setLeftFill($s->addFill(0x00, 0x00, 0x00));
+ $s->movePenTo(-1, -1);
+ $s->drawLine(2, 0);
+ $s->drawLine(0, 2);
+ $s->drawLine(-2, 0);
+ $s->drawLine(0, -2);
+
+
+ /* sprite container for morphing box -
+ this is just a timeline w/ the box morphing */
+
+ $box = new SWFSprite();
+ $box->add(new SWFAction("
+ stop();
+ "));
+ $i = $box->add($r);
+
+ for($n=0; $n<=20; ++$n)
+ {
+ $i->setRatio($n/20);
+ $box->nextFrame();
+ }
+
+
+ /* this container sprite allows us to use the same action code many times */
+
+ $cell = new SWFSprite();
+ $i = $cell->add($box);
+ $i->setName('box');
+
+ $cell->add(new SWFAction("
+
+ setTarget('box');
+
+ /* ...x means the x coordinate of the parent, i.e. (..).x */
+ dx = (/mouse.x + random(6)-3 - ...x)/5;
+ dy = (/mouse.y + random(6)-3 - ...y)/5;
+ gotoFrame(int(dx*dx + dy*dy));
+
+ "));
+
+ $cell->nextFrame();
+ $cell->add(new SWFAction("
+
+ gotoFrame(0);
+ play();
+
+ "));
+
+ $cell->nextFrame();
+
+
+ /* finally, add a bunch of the cells to the movie */
+
+ for($x=0; $x<12; ++$x)
+ {
+ for($y=0; $y<8; ++$y)
+ {
+ $i = $m->add($cell);
+ $i->moveTo(100*$x+50, 100*$y+50);
+ }
+ }
+
+ $m->nextFrame();
+
+ $m->add(new SWFAction("
+
+ gotoFrame(1);
+ play();
+
+ "));
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+ Same as above, but with nice colored balls...
+
+ swfaction example
+
+<?php
+
+ $m = new SWFMovie();
+ $m->setDimension(11000, 8000);
+ $m->setBackground(0x00, 0x00, 0x00);
+
+ $m->add(new SWFAction("
+
+this.quality = 0;
+/frames.visible = 0;
+startDrag('/mouse', 1);
+
+ "));
+
+ // mouse tracking sprite
+ $t = new SWFSprite();
+ $i = $m->add($t);
+ $i->setName('mouse');
+
+ $g = new SWFGradient();
+ $g->addEntry(0, 0xff, 0xff, 0xff, 0xff);
+ $g->addEntry(0.1, 0xff, 0xff, 0xff, 0xff);
+ $g->addEntry(0.5, 0xff, 0xff, 0xff, 0x5f);
+ $g->addEntry(1.0, 0xff, 0xff, 0xff, 0);
+
+ // gradient shape thing
+ $s = new SWFShape();
+ $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT);
+ $f->scaleTo(0.03);
+ $s->setRightFill($f);
+ $s->movePenTo(-600, -600);
+ $s->drawLine(1200, 0);
+ $s->drawLine(0, 1200);
+ $s->drawLine(-1200, 0);
+ $s->drawLine(0, -1200);
+
+ // need to make this a sprite so we can multColor it
+ $p = new SWFSprite();
+ $p->add($s);
+ $p->nextFrame();
+
+ // put the shape in here, each frame a different color
+ $q = new SWFSprite();
+ $q->add(new SWFAction("gotoFrame(random(7)+1); stop();"));
+ $i = $q->add($p);
+
+ $i->multColor(1.0, 1.0, 1.0);
+ $q->nextFrame();
+ $i->multColor(1.0, 0.5, 0.5);
+ $q->nextFrame();
+ $i->multColor(1.0, 0.75, 0.5);
+ $q->nextFrame();
+ $i->multColor(1.0, 1.0, 0.5);
+ $q->nextFrame();
+ $i->multColor(0.5, 1.0, 0.5);
+ $q->nextFrame();
+ $i->multColor(0.5, 0.5, 1.0);
+ $q->nextFrame();
+ $i->multColor(1.0, 0.5, 1.0);
+ $q->nextFrame();
+
+ // finally, this one contains the action code
+ $p = new SWFSprite();
+ $i = $p->add($q);
+ $i->setName('frames');
+ $p->add(new SWFAction("
+
+dx = (/:mousex-/:lastx)/3 + random(10)-5;
+dy = (/:mousey-/:lasty)/3;
+x = /:mousex;
+y = /:mousey;
+alpha = 100;
+
+ "));
+ $p->nextFrame();
+
+ $p->add(new SWFAction("
+
+this.x = x;
+this.y = y;
+this.alpha = alpha;
+x += dx;
+y += dy;
+dy += 3;
+alpha -= 8;
+
+ "));
+ $p->nextFrame();
+
+ $p->add(new SWFAction("prevFrame(); play();"));
+ $p->nextFrame();
+
+ $i = $m->add($p);
+ $i->setName('frames');
+ $m->nextFrame();
+
+ $m->add(new SWFAction("
+
+lastx = mousex;
+lasty = mousey;
+mousex = /mouse.x;
+mousey = /mouse.y;
+
+++num;
+
+if(num == 11)
+ num = 1;
+
+removeClip('char' & num);
+duplicateClip(/frames, 'char' & num, num);
+
+ "));
+
+ $m->nextFrame();
+ $m->add(new SWFAction("prevFrame(); play();"));
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+?>
+
+
+
+
+ This simple example will handles keyboard actions.
+ (You'll probably have to click in the window to give it focus.
+ And you'll probably have to leave your mouse in the frame, too.
+ If you know how to give buttons focus programatically, feel free
+ to share, won't you?)
+
+ swfaction example
+
+<?php
+
+ /* sprite has one letter per frame */
+
+ $p = new SWFSprite();
+ $p->add(new SWFAction("stop();"));
+
+ $chars = "abcdefghijklmnopqrstuvwxyz".
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
+ "1234567890!@#$%^&*()_+-=/[]{}|;:,.<>?`~";
+
+ $f = new SWFFont("_sans");
+
+ for($n=0; $nremove($i);
+ $t = new SWFTextField();
+ $t->setFont($f);
+ $t->setHeight(240);
+ $t->setBounds(600,240);
+ $t->align(SWFTEXTFIELD_ALIGN_CENTER);
+ $t->addString($c);
+ $i = $p->add($t);
+ $p->labelFrame($c);
+ $p->nextFrame();
+ }
+
+
+ /* hit region for button - the entire frame */
+
+ $s = new SWFShape();
+ $s->setFillStyle0($s->addSolidFill(0, 0, 0, 0));
+ $s->drawLine(600, 0);
+ $s->drawLine(0, 400);
+ $s->drawLine(-600, 0);
+ $s->drawLine(0, -400);
+
+
+ /* button checks for pressed key, sends sprite to the right frame */
+
+ $b = new SWFButton();
+ $b->addShape($s, SWFBUTTON_HIT);
+
+ for($n=0; $naddAction(new SWFAction("
+
+setTarget('/char');
+gotoFrame('$c');
+
+ "), SWFBUTTON_KEYPRESS($c));
+ }
+
+ $m = new SWFMovie();
+ $m->setDimension(600,400);
+ $i = $m->add($p);
+ $i->setName('char');
+ $i->moveTo(0,80);
+
+ $m->add($b);
+
+ header('Content-type: application/x-shockwave-flash');
+ $m->output();
+
+?>
+
+
+
+
+
+
+