mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-19 10:28:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@47614 c90b9560-bf6c-de11-be94-00142212c4b1
4158 lines
127 KiB
XML
Executable file
4158 lines
127 KiB
XML
Executable file
<reference id="ref.ming">
|
|
<title>Ming functions for Flash</title>
|
|
<titleabbrev>Ming (flash)</titleabbrev>
|
|
|
|
<partintro>
|
|
<sect1 id="ming.intro">
|
|
<title>Introduction</title>
|
|
<simpara>
|
|
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.
|
|
</simpara>
|
|
<simpara>
|
|
Ming is not an acronym.
|
|
</simpara>
|
|
<simpara>
|
|
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.
|
|
</simpara>
|
|
<simpara>
|
|
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 <ulink url="mailto:&email.ming;">&email.ming;</ulink>.
|
|
</simpara>
|
|
<simpara>
|
|
Ming was added in PHP 4.0.5.
|
|
</simpara>
|
|
</sect1>
|
|
|
|
<sect1 id="ming.install">
|
|
<title>Installation</title>
|
|
<para>
|
|
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 : <ulink url="&url.ming;">&url.ming;</ulink>
|
|
along with examples, a small tutorial, and the latest news.
|
|
</para>
|
|
<para>
|
|
Download the ming archive. Unpack the archive. Go in the
|
|
Ming directory. make. make install.
|
|
</para>
|
|
<para>
|
|
This will build <filename>libming.so</filename> and install it
|
|
into <filename>/usr/lib/</filename>, and copy
|
|
<filename>ming.h</filename> into <filename>/usr/include/</filename>.
|
|
Edit the <literal>PREFIX=</literal> line in the
|
|
<filename>Makefile</filename> to change the installation directory.
|
|
</para>
|
|
<sect2 id="ming.install.php.unix">
|
|
<title>built into php (unix)</title>
|
|
<para>
|
|
<literallayout>
|
|
mkdir <phpdir>/ext/ming
|
|
cp php_ext/* <phpdir>/ext/ming
|
|
cd <phpdir>
|
|
./buildconf
|
|
./configure --with-ming <other config options>
|
|
</literallayout>
|
|
Build and install php as usual,
|
|
Restart web server if necessary
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="ming.install.php_module.unix">
|
|
<title>built into php (unix)</title>
|
|
<para>
|
|
download <filename>php_ming.so.gz</filename>.
|
|
uncompress it and copy it to your php modules directory.
|
|
(you can find your php module directory by running
|
|
<command>php-config --extension-dir</command>).
|
|
Now either just add <literal>extension=php_ming.so</literal>
|
|
to your <filename>php.ini</filename> file, or put
|
|
<literal>dl('php_ming.so');</literal> at the head of all of your
|
|
Ming scripts.
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="ming.use">
|
|
<title>How to use Ming</title>
|
|
<simpara>
|
|
Ming introduces 13 new object in PHP, all with matching methods and
|
|
attributes. To use them, you need to know about
|
|
<link linkend="language.oop">objects</link>.
|
|
</simpara>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
<function>swfmovie</function>.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<function>swfshape</function>.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<function>swfdisplayitem</function>.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<function>swfgradient</function>.
|
|
</simpara>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<simpara>
|
|
<function>swfbitmap</function>.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<function>swffill</function>.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<function>swfmorph</function>.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<function>swftext</function>.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<function>swffont</function>.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<function>swftextfield</function>.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<function>swfsprite</function>.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<function>swfbutton</function>.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<function>swfaction</function>.
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</sect1>
|
|
</partintro>
|
|
|
|
<!-- SWFMovie -->
|
|
|
|
<refentry id="function.swfmovie">
|
|
<refnamediv>
|
|
<refname>SWFMovie</refname>
|
|
<refpurpose>Creates a new movie object, representing an SWF version 4 movie.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>new <function>swfmovie</function></funcdef>
|
|
<void/>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmovie</function> creates a new movie object,
|
|
representing an SWF version 4 movie.
|
|
</para>
|
|
<simpara>
|
|
SWFMovie has the following methods :
|
|
<function>swfmovie->output</function>,<function>swfmovie->save</function>,
|
|
<function>swfmovie->add</function>, <function>swfmovie->remove</function>,
|
|
<function>swfmovie->nextframe</function>, <function>swfmovie->setbackground</function>,
|
|
<function>swfmovie->setrate</function>, <function>swfmovie->setdimension</function>,
|
|
<function>swfmovie->setframes</function> and <function>swfmovie->streammp3</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See examples in :
|
|
<function>swfdisplayitem->rotateto</function>, <function>swfshape->setline</function>,
|
|
<function>swfshape->addfill</function>... Any example will use this object.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfmovie.output">
|
|
<refnamediv>
|
|
<refname>SWFMovie->output</refname>
|
|
<refpurpose>Dumps your lovingly prepared movie out.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfmovie->output</function></funcdef>
|
|
<paramdef>void</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmovie->output</function> dumps your lovingly prepared movie out.
|
|
In PHP, preceding this with the command
|
|
<programlisting role="php">
|
|
<?php
|
|
header('Content-type: application/x-shockwave-flash');
|
|
?>
|
|
</programlisting>
|
|
convinces the browser to display this as a flash movie.
|
|
</para>
|
|
<simpara>
|
|
See also
|
|
<function>swfmovie->save</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See examples in :
|
|
<function>swfmovie->streammp3</function>,
|
|
<function>swfdisplayitem->rotateto</function>,
|
|
<function>swfaction</function>...
|
|
Any example will use this method.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfmovie.save">
|
|
<refnamediv>
|
|
<refname>SWFMovie->save</refname>
|
|
<refpurpose>Saves your movie in a file.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfmovie->save</function></funcdef>
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmovie->save</function> saves your movie to the
|
|
file named <parameter>filename</parameter>.
|
|
</para>
|
|
<simpara>
|
|
See also
|
|
<function>output</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfmovie.add">
|
|
<refnamediv>
|
|
<refname>SWFMovie->add</refname>
|
|
<refpurpose>Adds any type of data to a movie.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfmovie->add</function></funcdef>
|
|
<paramdef>ressource <parameter>instance</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmovie->add</function> adds <parameter>instance</parameter> to
|
|
the current movie. <parameter>instance</parameter> is any type of data :
|
|
Shapes, text, fonts, etc. must all be add'ed to the movie to make this work.
|
|
</para>
|
|
<para>
|
|
For displayable types (shape, text, button, sprite), this returns an
|
|
<function>SWFDisplayItem</function>, 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.
|
|
</para>
|
|
<simpara>
|
|
See also all other objects (adding this later), and
|
|
<function>swfmovie->remove</function>
|
|
</simpara>
|
|
<simpara>
|
|
See examples in :
|
|
<function>swfdisplayitem->rotateto</function> and
|
|
<function>swfshape->addfill</function>.
|
|
</simpara>
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfmovie.remove">
|
|
<refnamediv>
|
|
<refname>SWFMovie->remove</refname>
|
|
<refpurpose>Removes the object instance from the display list.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfmovie->remove</function></funcdef>
|
|
<paramdef>ressource <parameter>instance</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmovie->remove</function> removes the object instance
|
|
<parameter>instance</parameter> from the display list.
|
|
</para>
|
|
<simpara>
|
|
See also
|
|
<function>swfmovie->add</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfmovie.setbackground">
|
|
<refnamediv>
|
|
<refname>SWFMovie->setbackground</refname>
|
|
<refpurpose>Sets the background color.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfmovie->setbackground</function></funcdef>
|
|
<paramdef>int <parameter>red</parameter></paramdef>
|
|
<paramdef>int <parameter>green</parameter></paramdef>
|
|
<paramdef>int <parameter>blue</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmovie->setbackground</function> 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
|
|
<ulink url="&url.macromedia;">&url.macromedia;</ulink> site for
|
|
details.)
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfmovie.setrate">
|
|
<refnamediv>
|
|
<refname>SWFMovie->setrate</refname>
|
|
<refpurpose>Sets the animation's frame rate.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfmovie->setrate</function></funcdef>
|
|
<paramdef>int <parameter>rate</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmovie->setrate</function> sets the frame rate to
|
|
<parameter>rate</parameter>, 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.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfmovie.setdimension">
|
|
<refnamediv>
|
|
<refname>SWFMovie->setdimension</refname>
|
|
<refpurpose>Sets the movie's width and height.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfmovie->setdimension</function></funcdef>
|
|
<paramdef>int <parameter>width</parameter></paramdef>
|
|
<paramdef>int <parameter>height</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmovie->setdimension</function> sets the movie's width
|
|
to <parameter>width</parameter> and height to <parameter>height</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfmovie.setframes">
|
|
<refnamediv>
|
|
<refname>SWFMovie->setframes</refname>
|
|
<refpurpose>Sets the total number of frames in the animation.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfmovie->setframes</function></funcdef>
|
|
<paramdef>string <parameter>numberofframes</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmovie->setframes</function> sets the total number of frames
|
|
in the animation to <parameter>numberofframes</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfmovie.nextframe">
|
|
<refnamediv>
|
|
<refname>SWFMovie->nextframe</refname>
|
|
<refpurpose>Moves to the next frame of the animation.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfmovie->nextframe</function></funcdef>
|
|
<paramdef>void </paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmovie->setframes</function> moves to the next frame of
|
|
the animation.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.swfmovie.streammp3">
|
|
<refnamediv>
|
|
<refname>SWFMovie->streammp3</refname>
|
|
<refpurpose>Streams a MP3 file.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfmovie->streammp3</function></funcdef>
|
|
<paramdef>string <parameter>mp3FileName</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmovie->streammp3</function> streams the mp3 file
|
|
<parameter>mp3FileName</parameter>. Not very robust in dealing with
|
|
oddities (can skip over an initial ID3 tag, but that's about it).
|
|
Like <function>SWFShape->addJpegFill</function>, this isn't a stable function- we'll
|
|
probably need to make a separate SWFSound object to contain sound types.
|
|
</para>
|
|
<para>
|
|
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.
|
|
</para>
|
|
<para>
|
|
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.
|
|
<example>
|
|
<title><function>swfmovie->streammp3</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- SWFDisplayItem -->
|
|
|
|
<refentry id="function.swfdisplayitem">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem</refname>
|
|
<refpurpose>Creates a new displayitem object.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>new <function>swfdisplayitem</function></funcdef>
|
|
<paramdef>void</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem</function> creates a new swfdisplayitem object.
|
|
</para>
|
|
<para>
|
|
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.
|
|
</para>
|
|
<simpara>
|
|
SWFDisplayItem has the following methods : <function>swfdisplayitem->move</function>,
|
|
<function>swfdisplayitem->moveto</function>, <function>swfdisplayitem->scaleto</function>,
|
|
<function>swfdisplayitem->scale</function>, <function>swfdisplayitem->rotate</function>,
|
|
<function>swfdisplayitem->rotateto</function>, <function>swfdisplayitem->skewxto</function>,
|
|
<function>swfdisplayitem->skewx</function>, <function>swfdisplayitem->skewyto</function>
|
|
<function>swfdisplayitem->skewyto</function>, <function>swfdisplayitem->setdepth</function>
|
|
<function>swfdisplayitem->remove</function>, <function>swfdisplayitem->setname</function>
|
|
<function>swfdisplayitem->setratio</function>, <function>swfdisplayitem->addcolor</function>
|
|
and <function>swfdisplayitem->multcolor</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.moveto">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->moveTo</refname>
|
|
<refpurpose>Moves object in global coordinates.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->moveto</function></funcdef>
|
|
<paramdef>int <parameter>x</parameter></paramdef>
|
|
<paramdef>int <parameter>y</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->moveto</function> moves the current object to
|
|
(<parameter>x</parameter>,<parameter>y</parameter>) in global coordinates.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfdisplayitem->move</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.move">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->move</refname>
|
|
<refpurpose>Moves object in relative coordinates.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->move</function></funcdef>
|
|
<paramdef>int <parameter>dx</parameter></paramdef>
|
|
<paramdef>int <parameter>dy</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->move</function> moves the current object by
|
|
(<parameter>dx</parameter>,<parameter>dy</parameter>) from its
|
|
current position.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfdisplayitem->moveto</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.scaleto">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->scaleTo</refname>
|
|
<refpurpose>Scales the object in global coordinates.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->scaleto</function></funcdef>
|
|
<paramdef>int <parameter>x</parameter></paramdef>
|
|
<paramdef>int <parameter>y</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->scaleto</function> scales the current object to
|
|
(<parameter>x</parameter>,<parameter>y</parameter>) in global coordinates.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfdisplayitem->scale</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.scale">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->scale</refname>
|
|
<refpurpose>Scales the object in relative coordinates.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->scale</function></funcdef>
|
|
<paramdef>int <parameter>dx</parameter></paramdef>
|
|
<paramdef>int <parameter>dy</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->scale</function> scales the current object by
|
|
(<parameter>dx</parameter>,<parameter>dy</parameter>) from its
|
|
current size.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfdisplayitem->scaleto</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.rotateto">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->rotateTo</refname>
|
|
<refpurpose>Rotates the object in global coordinates.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->rotateto</function></funcdef>
|
|
<paramdef>double <parameter>degrees</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->rotateto</function> set the current object
|
|
rotation to <parameter>degrees</parameter> degrees in global coordinates.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
<para>
|
|
This example bring three rotating string from the background to the
|
|
foreground. Pretty nice.
|
|
<example>
|
|
<title><function>swfdisplayitem->rotateto</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<simpara>
|
|
See also
|
|
<function>swfdisplayitem->rotate</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.rotate">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->Rotate</refname>
|
|
<refpurpose>Rotates in relative coordinates.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->rotate</function></funcdef>
|
|
<paramdef>double <parameter>ddegrees</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->rotate</function> rotates the current object
|
|
by <parameter>ddegrees</parameter> degrees from its current rotation.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfdisplayitem->rotateto</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.skewxto">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->skewXTo</refname>
|
|
<refpurpose>Sets the X-skew.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->skewxto</function></funcdef>
|
|
<paramdef>double <parameter>degrees</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->skewxto</function> sets the
|
|
x-skew to <parameter>degrees</parameter>. For <parameter>degrees</parameter>
|
|
is 1.0, it means a 45-degree forward slant. More is more forward,
|
|
less is more backward.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfdisplayitem->skewx</function>,
|
|
<function>swfdisplayitem->skewy</function> and
|
|
<function>swfdisplayitem->skewyto</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.skewx">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->skewX</refname>
|
|
<refpurpose>Sets the X-skew.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->skewx</function></funcdef>
|
|
<paramdef>double <parameter>ddegrees</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->skewx</function> adds <parameter>ddegrees</parameter>
|
|
to current x-skew.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfdisplayitem->skewx</function>,
|
|
<function>swfdisplayitem->skewy</function> and
|
|
<function>swfdisplayitem->skewyto</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.skewyto">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->skewYTo</refname>
|
|
<refpurpose>Sets the Y-skew.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->skewyto</function></funcdef>
|
|
<paramdef>double <parameter>degrees</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->skewyto</function> sets the
|
|
y-skew to <parameter>degrees</parameter>. For <parameter>degrees</parameter>
|
|
is 1.0, it means a 45-degree forward slant. More is more upward,
|
|
less is more downward.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfdisplayitem->skewy</function>,
|
|
<function>swfdisplayitem->skewx</function> and
|
|
<function>swfdisplayitem->skewxto</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.skewy">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->skewY</refname>
|
|
<refpurpose>Sets the Y-skew.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->skewy</function></funcdef>
|
|
<paramdef>double <parameter>ddegrees</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->skewy</function> adds <parameter>ddegrees</parameter>
|
|
to current y-skew.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfdisplayitem->skewyto</function>,
|
|
<function>swfdisplayitem->skewx</function> and
|
|
<function>swfdisplayitem->skewxto</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.setdepth">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->setDepth</refname>
|
|
<refpurpose>Sets z-order</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->setdepth</function></funcdef>
|
|
<paramdef>double <parameter>depth</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->rotate</function> sets the object's
|
|
z-order to <parameter>depth</parameter>. 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.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.remove">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->remove</refname>
|
|
<refpurpose>Removes the object from the movie</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->remove</function></funcdef>
|
|
<paramdef>void</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->remove</function> removes this object from
|
|
the movie's display list.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfmovie->add</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.setname">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->setName</refname>
|
|
<refpurpose>Sets the object's name</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->setname</function></funcdef>
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->setname</function> sets the object's name to
|
|
<parameter>name</parameter>, for targetting with action script.
|
|
Only useful on sprites.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.setratio">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->setRatio</refname>
|
|
<refpurpose>Sets the object's ratio.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->setratio</function></funcdef>
|
|
<paramdef>double <parameter>ratio</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->setratio</function> sets the object's ratio
|
|
to <parameter>ratio</parameter>. Obviously only useful for morphs.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
<para>
|
|
This simple example will morph nicely three concentric circles.
|
|
<example>
|
|
<title><function>swfdisplayitem->setname</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.addcolor">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->addColor</refname>
|
|
<refpurpose>Adds the given color to this item's color transform.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->addcolor</function></funcdef>
|
|
<paramdef>int <parameter><optional>red</optional></parameter></paramdef>
|
|
<paramdef>int <parameter><optional>green</optional></parameter></paramdef>
|
|
<paramdef>int <parameter><optional>blue</optional></parameter></paramdef>
|
|
<paramdef>int <parameter><optional>a</optional></parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->addcolor</function> adds the color to
|
|
this item's color transform. The color is given in its RGB form.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfdisplayitem.multcolor">
|
|
<refnamediv>
|
|
<refname>SWFDisplayItem->multColor</refname>
|
|
<refpurpose>Multiplies the item's color transform.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfdisplayitem->multcolor</function></funcdef>
|
|
<paramdef>int <parameter><optional>red</optional></parameter></paramdef>
|
|
<paramdef>int <parameter><optional>green</optional></parameter></paramdef>
|
|
<paramdef>int <parameter><optional>blue</optional></parameter></paramdef>
|
|
<paramdef>int <parameter><optional>a</optional></parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfdisplayitem->multcolor</function> multiplies the item's
|
|
color transform by the given values.
|
|
</para>
|
|
<simpara>
|
|
The object may be a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function> or a
|
|
<function>swfsprite</function> object. It must have been added using
|
|
the <function>swfmovie->add</function>.
|
|
</simpara>
|
|
<para>
|
|
This simple example will modify your picture's atmospher
|
|
to Halloween (use a landscape or bright picture).
|
|
<example>
|
|
<title><function>swfdisplayitem->multcolor</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- SWFShape -->
|
|
|
|
<refentry id="function.swfshape">
|
|
<refnamediv>
|
|
<refname>SWFShape</refname>
|
|
<refpurpose>Creates a new shape object.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>new <function>swfshape</function></funcdef>
|
|
<paramdef>void</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfshape</function> creates a new shape object.
|
|
</para>
|
|
<simpara>
|
|
SWFShape has the following methods : <function>swfshape->setline</function>,
|
|
<function>swfshape->addfill</function>, <function>swfshape->setleftfill</function>,
|
|
<function>swfshape->setrightfill</function>, <function>swfshape->movepento</function>,
|
|
<function>swfshape->movepen</function>, <function>swfshape->drawlineto</function>,
|
|
<function>swfshape->drawline</function>, <function>swfshape->drawcurveto</function>
|
|
and <function>swfshape->drawcurve</function>.
|
|
</simpara>
|
|
<para>
|
|
This simple example will draw a big red elliptic quadrant.
|
|
<example>
|
|
<title><function>swfshape</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfshape.setline">
|
|
<refnamediv>
|
|
<refname>SWFShape->setLine</refname>
|
|
<refpurpose>Sets the shape's line style.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->setline</function></funcdef>
|
|
<paramdef>int <parameter>width</parameter></paramdef>
|
|
<paramdef>int <parameter><optional>red</optional></parameter></paramdef>
|
|
<paramdef>int <parameter><optional>green</optional></parameter></paramdef>
|
|
<paramdef>int <parameter><optional>blue</optional></parameter></paramdef>
|
|
<paramdef>int <parameter><optional>a</optional></parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfshape->setline</function> sets the shape's line style.
|
|
<parameter>width</parameter> is the line's width. If <parameter>width</parameter>
|
|
is 0, the line's style is removed (then, all other arguments are ignored).
|
|
If <parameter>width</parameter> > 0, then line's color is set to
|
|
<parameter>red</parameter>, <parameter>green</parameter>, <parameter>blue</parameter>.
|
|
Last parameter <parameter>a</parameter> is optional.
|
|
</para>
|
|
<simpara>
|
|
<function>swfshape->setline</function> accepts 1, 4 or 5 arguments
|
|
(not 3 or 2).
|
|
</simpara>
|
|
<para>
|
|
You must declare all line styles before you use them (see example).
|
|
</para>
|
|
<para>
|
|
This simple example will draw a big "!#%*@", in funny colors and
|
|
gracious style.
|
|
<example>
|
|
<title><function>swfshape->setline</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfshape.addfill">
|
|
<refnamediv>
|
|
<refname>SWFShape->addFill</refname>
|
|
<refpurpose>Adds a solid fill to the shape.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->addfill</function></funcdef>
|
|
<paramdef>int <parameter>red</parameter></paramdef>
|
|
<paramdef>int <parameter>green</parameter></paramdef>
|
|
<paramdef>int <parameter>blue</parameter></paramdef>
|
|
<paramdef>int <parameter><optional>a</optional></parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->addfill</function></funcdef>
|
|
<paramdef>SWFbitmap <parameter>bitmap</parameter></paramdef>
|
|
<paramdef>int <parameter><optional>flags</optional></parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->addfill</function></funcdef>
|
|
<paramdef>SWFGradient <parameter>gradient</parameter></paramdef>
|
|
<paramdef>int <parameter><optional>flags</optional></parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfshape->addfill</function> adds a solid fill to the shape's list
|
|
of fill styles. <function>swfshape->addfill</function> accepts three different
|
|
types of arguments.
|
|
</para>
|
|
<para>
|
|
<parameter>red</parameter>, <parameter>green</parameter>, <parameter>blue</parameter>
|
|
is a color (RGB mode). Last parameter <parameter>a</parameter> is optional.
|
|
</para>
|
|
<para>
|
|
The <parameter>bitmap</parameter> argument is an <function>swfbitmap</function> object.
|
|
The <parameter>flags</parameter> argument can be one
|
|
of the following values : SWFFILL_CLIPPED_BITMAP or SWFFILL_TILED_BITMAP.
|
|
Default is SWFFILL_TILED_BITMAP. I think.
|
|
</para>
|
|
<para>
|
|
The <parameter>gradient</parameter> argument is an <function>swfgradient</function>
|
|
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.
|
|
</para>
|
|
<para>
|
|
<function>swfshape->addfill</function> returns an <function>swffill</function>
|
|
object for use with the <function>swfshape->setleftfill</function>
|
|
and <function>swfshape->setrightfill</function> functions
|
|
described below.
|
|
</para>
|
|
<simpara>
|
|
See also
|
|
<function>swfshape->setleftfill</function> and
|
|
<function>swfshape->setrightfill</function>.
|
|
</simpara>
|
|
<para>
|
|
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..
|
|
<example>
|
|
<title><function>swfshape->addfill</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfshape.setleftfill">
|
|
<refnamediv>
|
|
<refname>SWFShape->setLeftFill</refname>
|
|
<refpurpose>Sets left rasterizing color.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->setleftfill</function></funcdef>
|
|
<paramdef>swfgradient <parameter>fill</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->setleftfill</function></funcdef>
|
|
<paramdef>int <parameter>red</parameter></paramdef>
|
|
<paramdef>int <parameter>green</parameter></paramdef>
|
|
<paramdef>int <parameter>blue</parameter></paramdef>
|
|
<paramdef>int <parameter><optional>a</optional></parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
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.
|
|
</para>
|
|
<para>
|
|
<function>swfshape->setleftfill</function> 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.
|
|
</para>
|
|
<para>
|
|
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.
|
|
</para>
|
|
<simpara>
|
|
Shortcut for <literal>swfshape->setleftfill($s->addfill($r, $g, $b [, $a]));</literal>.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfshape->setrightfill</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfshape.setrightfill">
|
|
<refnamediv>
|
|
<refname>SWFShape->setRightFill</refname>
|
|
<refpurpose>Sets right rasterizing color.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->setrightfill</function></funcdef>
|
|
<paramdef>swfgradient <parameter>fill</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->setrightfill</function></funcdef>
|
|
<paramdef>int <parameter>red</parameter></paramdef>
|
|
<paramdef>int <parameter>green</parameter></paramdef>
|
|
<paramdef>int <parameter>blue</parameter></paramdef>
|
|
<paramdef>int <parameter><optional>a</optional></parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<simpara>
|
|
See also
|
|
<function>swfshape->setleftfill</function>.
|
|
</simpara>
|
|
<simpara>
|
|
Shortcut for <literal>swfshape->setrightfill($s->addfill($r, $g, $b [, $a]));</literal>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfshape.movepento">
|
|
<refnamediv>
|
|
<refname>SWFShape->movePenTo</refname>
|
|
<refpurpose>Moves the shape's pen.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->movepento</function></funcdef>
|
|
<paramdef>int <parameter>x</parameter></paramdef>
|
|
<paramdef>int <parameter>y</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<simpara>
|
|
<function>swfshape->setrightfill</function> move the shape's pen to
|
|
(<parameter>x</parameter>,<parameter>y</parameter>) in the shape's
|
|
coordinate space.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfshape->movepen</function>,
|
|
<function>swfshape->drawcurveto</function>,
|
|
<function>swfshape->drawlineto</function> and
|
|
<function>swfshape->drawline</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfshape.movepen">
|
|
<refnamediv>
|
|
<refname>SWFShape->movePen</refname>
|
|
<refpurpose>Moves the shape's pen (relative).</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->movepen</function></funcdef>
|
|
<paramdef>int <parameter>dx</parameter></paramdef>
|
|
<paramdef>int <parameter>dy</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<simpara>
|
|
<function>swfshape->setrightfill</function> move the shape's pen from
|
|
coordinates (current x,current y) to (current x + <parameter>dx</parameter>,
|
|
current y + <parameter>dy</parameter>) in the shape's coordinate space.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfshape->movepento</function>,
|
|
<function>swfshape->drawcurveto</function>,
|
|
<function>swfshape->drawlineto</function> and
|
|
<function>swfshape->drawline</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfshape.drawlineto">
|
|
<refnamediv>
|
|
<refname>SWFShape->drawLineTo</refname>
|
|
<refpurpose>Draws a line.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->drawlineto</function></funcdef>
|
|
<paramdef>int <parameter>x</parameter></paramdef>
|
|
<paramdef>int <parameter>y</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<simpara>
|
|
<function>swfshape->setrightfill</function> draws a line (using the
|
|
current line style, set by <function>swfshape->setline</function>) from the current
|
|
pen position to point (<parameter>x</parameter>,<parameter>y</parameter>)
|
|
in the shape's coordinate space.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfshape->movepento</function>,
|
|
<function>swfshape->drawcurveto</function>,
|
|
<function>swfshape->movepen</function> and
|
|
<function>swfshape->drawline</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfshape.drawline">
|
|
<refnamediv>
|
|
<refname>SWFShape->drawLine</refname>
|
|
<refpurpose>Draws a line (relative).</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->drawline</function></funcdef>
|
|
<paramdef>int <parameter>dx</parameter></paramdef>
|
|
<paramdef>int <parameter>dy</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<simpara>
|
|
<function>swfshape->setrightfill</function> draws a line (using the current line style
|
|
set by <function>swfshape->setline</function>) from the current pen position to
|
|
displacement (<parameter>dx</parameter>,<parameter>dy</parameter>).
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfshape->movepento</function>,
|
|
<function>swfshape->drawcurveto</function>,
|
|
<function>swfshape->movepen</function> and
|
|
<function>swfshape->drawlineto</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfshape.drawcurveto">
|
|
<refnamediv>
|
|
<refname>SWFShape->drawCurveTo</refname>
|
|
<refpurpose>Draws a curve.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->drawcurveto</function></funcdef>
|
|
<paramdef>int <parameter>controlx</parameter></paramdef>
|
|
<paramdef>int <parameter>controly</parameter></paramdef>
|
|
<paramdef>int <parameter>anchorx</parameter></paramdef>
|
|
<paramdef>int <parameter>anchory</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<simpara>
|
|
<function>swfshape->drawcurveto</function> draws a quadratic curve
|
|
(using the current line style, set by <function>swfshape->setline</function>)
|
|
from the current pen position to
|
|
(<parameter>anchorx</parameter>,<parameter>anchory</parameter>)
|
|
using (<parameter>controlx</parameter>,<parameter>controly</parameter>)
|
|
as a control point. That is, head towards the control point,
|
|
then smoothly turn to the anchor point.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfshape->drawlineto</function>,
|
|
<function>swfshape->drawline</function>,
|
|
<function>swfshape->movepento</function> and
|
|
<function>swfshape->movepen</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfshape.drawcurve">
|
|
<refnamediv>
|
|
<refname>SWFShape->drawCurve</refname>
|
|
<refpurpose>Draws a curve (relative).</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfshape->drawcurve</function></funcdef>
|
|
<paramdef>int <parameter>controldx</parameter></paramdef>
|
|
<paramdef>int <parameter>controldy</parameter></paramdef>
|
|
<paramdef>int <parameter>anchordx</parameter></paramdef>
|
|
<paramdef>int <parameter>anchordy</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<simpara>
|
|
<function>swfshape->drawcurve</function> draws a quadratic curve
|
|
(using the current line style,set by <function>swfshape->setline</function>)
|
|
from the current pen position to the relative position
|
|
(<parameter>anchorx</parameter>,<parameter>anchory</parameter>)
|
|
using relative control point
|
|
(<parameter>controlx</parameter>,<parameter>controly</parameter>).
|
|
That is, head towards the control point, then smoothly turn to the
|
|
anchor point.
|
|
</simpara>
|
|
<simpara>
|
|
See also
|
|
<function>swfshape->drawlineto</function>,
|
|
<function>swfshape->drawline</function>,
|
|
<function>swfshape->movepento</function> and
|
|
<function>swfshape->movepen</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- SWFGradient -->
|
|
|
|
<refentry id="function.swfgradient">
|
|
<refnamediv>
|
|
<refname>SWFGradient</refname>
|
|
<refpurpose>Creates a gradient object</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>new <function>swfgradient</function></funcdef>
|
|
<paramdef>void</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfgradient</function> creates a new SWFGradient object.
|
|
</para>
|
|
<simpara>
|
|
After you've added the entries to your gradient, you can use the gradient
|
|
in a shape fill with the <function>swfshape->addfill</function> method.
|
|
</simpara>
|
|
<simpara>
|
|
SWFGradient has the following methods : <function>swfgradient->addentry</function>.
|
|
</simpara>
|
|
<para>
|
|
This simple example will draw a big black-to-white gradient as background,
|
|
and a redish disc in its center.
|
|
<example>
|
|
<title><function>swfgradient</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfgradient.addentry">
|
|
<refnamediv>
|
|
<refname>SWFGradient->addEntry</refname>
|
|
<refpurpose>Adds an entry to the gradient list.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfgradient->addentry</function></funcdef>
|
|
<paramdef>double <parameter>ratio</parameter></paramdef>
|
|
<paramdef>int <parameter>red</parameter></paramdef>
|
|
<paramdef>int <parameter>green</parameter></paramdef>
|
|
<paramdef>int <parameter>blue</parameter></paramdef>
|
|
<paramdef>int <parameter><optional>a</optional></parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfgradient->addentry</function> adds an entry to the gradient list.
|
|
<parameter>ratio</parameter> is a number between 0 and 1 indicating where in
|
|
the gradient this color appears. Thou shalt add entries in order of increasing ratio.
|
|
</para>
|
|
<para>
|
|
<parameter>red</parameter>, <parameter>green</parameter>, <parameter>blue</parameter>
|
|
is a color (RGB mode). Last parameter <parameter>a</parameter> is optional.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- SWFBitmap -->
|
|
|
|
<refentry id="function.swfbitmap">
|
|
<refnamediv>
|
|
<refname>SWFBitmap</refname>
|
|
<refpurpose>Loads Bitmap object</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>new <function>swfbitmap</function></funcdef>
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
<paramdef>int <parameter><optional>alphafilename</optional></parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfbitmap</function> creates a new SWFBitmap object from
|
|
the Jpeg or DBL file named <parameter>filename</parameter>.
|
|
<parameter>alphafilename</parameter> indicates a MSK file to
|
|
be used as an alpha mask for a Jpeg image.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
We can only deal with baseline (frame 0) jpegs, no baseline optimized or
|
|
progressive scan jpegs!
|
|
</para>
|
|
</note>
|
|
<simpara>
|
|
SWFBitmap has the following methods : <function>swfbitmap->getwidth</function>
|
|
and <function>swfbitmap->getheight</function>.
|
|
</simpara>
|
|
<para>
|
|
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.
|
|
<example>
|
|
<title>Import PNG files</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
And you can put an alpha mask on a jpeg fill.
|
|
<example>
|
|
<title><function>swfbitmap</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfbitmap.getwidth">
|
|
<refnamediv>
|
|
<refname>SWFBitmap->getWidth</refname>
|
|
<refpurpose>Returns the bitmap's width.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>int <function>swfbitmap->getwidth</function></funcdef>
|
|
<paramdef>void</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfbitmap->getwidth</function> returns the bitmap's width in pixels.
|
|
</para>
|
|
<para>
|
|
See also
|
|
<function>swfbitmap->getheight</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfbitmap.getheight">
|
|
<refnamediv>
|
|
<refname>SWFBitmap->getHeight</refname>
|
|
<refpurpose>Returns the bitmap's height.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>int <function>swfbitmap->getheight</function></funcdef>
|
|
<paramdef>void</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfbitmap->getheight</function> returns the bitmap's height in pixels.
|
|
</para>
|
|
<para>
|
|
See also
|
|
<function>swfbitmap->getwidth</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- SWFFill -->
|
|
|
|
<refentry id="function.swffill">
|
|
<refnamediv>
|
|
<refname>SWFFill</refname>
|
|
<refpurpose>Loads SWFFill object</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<para>
|
|
The <function>swffill</function> object allows you to transform
|
|
(scale, skew, rotate) bitmap and gradient fills. <function>swffill</function>
|
|
objects are created by the <function>swfshape->addfill</function> methods.
|
|
</para>
|
|
<simpara>
|
|
SWFFill has the following methods : <function>swffill->moveto</function>
|
|
and <function>swffill->scaleto</function>, <function>swffill->rotateto</function>,
|
|
<function>swffill->skewxto</function> and <function>swffill->skewyto</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swffill.moveto">
|
|
<refnamediv>
|
|
<refname>SWFFill->moveTo</refname>
|
|
<refpurpose>Moves fill origin</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swffill->moveto</function></funcdef>
|
|
<paramdef>int <parameter>x</parameter></paramdef>
|
|
<paramdef>int <parameter>y</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swffill->moveto</function> moves fill's origin to
|
|
(<parameter>x</parameter>,<parameter>y</parameter>) in global coordinates.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swffill.scaleto">
|
|
<refnamediv>
|
|
<refname>SWFFill->scaleTo</refname>
|
|
<refpurpose>Sets fill's scale</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swffill->scaleto</function></funcdef>
|
|
<paramdef>int <parameter>x</parameter></paramdef>
|
|
<paramdef>int <parameter>y</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swffill->scaleto</function> sets fill's scale to
|
|
<parameter>x</parameter> in the x-direction,
|
|
<parameter>y</parameter> in the y-direction.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swffill.rotateto">
|
|
<refnamediv>
|
|
<refname>SWFFill->rotateTo</refname>
|
|
<refpurpose>Sets fill's rotation</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swffill->rotateto</function></funcdef>
|
|
<paramdef>double <parameter>degrees</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swffill->rotateto</function> sets fill's rotation to
|
|
<parameter>degrees</parameter> degrees.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swffill.skewxto">
|
|
<refnamediv>
|
|
<refname>SWFFill->skewXTo</refname>
|
|
<refpurpose>Sets fill x-skew</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swffill->skewxto</function></funcdef>
|
|
<paramdef>double <parameter>x</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swffill->skewxto</function> sets fill x-skew to <parameter>x</parameter>.
|
|
For <parameter>x</parameter> is 1.0, it is a is a 45-degree
|
|
forward slant. More is more forward, less is more backward.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swffill.skewyto">
|
|
<refnamediv>
|
|
<refname>SWFFill->skewYTo</refname>
|
|
<refpurpose>Sets fill y-skew</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swffill->skewyto</function></funcdef>
|
|
<paramdef>double <parameter>y</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swffill->skewyto</function> sets fill y-skew to <parameter>y</parameter>.
|
|
For <parameter>y</parameter> is 1.0, it is a is a 45-degree
|
|
upward slant. More is more upward, less is more downward.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- SWFMorph -->
|
|
|
|
<refentry id="function.swfmorph">
|
|
<refnamediv>
|
|
<refname>SWFMorph</refname>
|
|
<refpurpose>Creates a new SWFMorph object.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>new <function>swfmorph</function></funcdef>
|
|
<paramdef>void</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmorph</function> creates a new SWFMorph object.
|
|
</para>
|
|
<para>
|
|
Also called a "shape tween". This thing lets you make those tacky
|
|
twisting things that make your computer choke. Oh, joy!
|
|
</para>
|
|
<para>
|
|
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.)
|
|
</para>
|
|
<simpara>
|
|
SWFMorph has the following methods : <function>swfmorph->getshape1</function>
|
|
and <function>swfmorph->getshape1</function>.
|
|
</simpara>
|
|
<para>
|
|
This simple example will morph a big red square into a smaller
|
|
blue black-bordered square.
|
|
<example>
|
|
<title><function>swfmorph</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfmorph.getshape1">
|
|
<refnamediv>
|
|
<refname>SWFMorph->getshape1</refname>
|
|
<refpurpose>Gets a handle to the starting shape</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>mixed <function>swfmorph->getshape1</function></funcdef>
|
|
<paramdef>void</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmorph->getshape1</function> gets a handle to the morph's
|
|
starting shape. <function>swfmorph->getshape1</function> returns an
|
|
<function>swfshape</function> object.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfmorph.getshape2">
|
|
<refnamediv>
|
|
<refname>SWFMorph->getshape2</refname>
|
|
<refpurpose>Gets a handle to the ending shape</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>mixed <function>swfmorph->getshape2</function></funcdef>
|
|
<paramdef>void</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfmorph->getshape2</function> gets a handle to the morph's
|
|
ending shape. <function>swfmorph->getshape2</function> returns an
|
|
<function>swfshape</function> object.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- SWFText -->
|
|
|
|
<refentry id="function.swftext">
|
|
<refnamediv>
|
|
<refname>SWFText</refname>
|
|
<refpurpose>Creates a new SWFText object.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>new <function>swftext</function></funcdef>
|
|
<paramdef>void</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftext</function> creates a new SWFText object,
|
|
fresh for manipulating.
|
|
</para>
|
|
<simpara>
|
|
SWFText has the following methods : <function>swftext->setfont</function>,
|
|
<function>swftext->setheight</function>, <function>swftext->setspacing</function>,
|
|
<function>swftext->setcolor</function>, <function>swftext->moveto</function>,
|
|
<function>swftext->addstring</function> and <function>swftext->getwidth</function>.
|
|
</simpara>
|
|
<para>
|
|
This simple example will draw a big yellow "PHP generates Flash with Ming"
|
|
text, on white background.
|
|
<example>
|
|
<title><function>swftext</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftext.setfont">
|
|
<refnamediv>
|
|
<refname>SWFText->setFont</refname>
|
|
<refpurpose>Sets the current font</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftext->setfont</function></funcdef>
|
|
<paramdef>string <parameter>font</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftext->setfont</function> sets the current font to
|
|
<parameter>font</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftext.setheight">
|
|
<refnamediv>
|
|
<refname>SWFText->setHeight</refname>
|
|
<refpurpose>Sets the current font height</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftext->setheight</function></funcdef>
|
|
<paramdef>int <parameter>height</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftext->setheight</function> sets the current font height to
|
|
<parameter>height</parameter>. Default is 240.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftext.setspacing">
|
|
<refnamediv>
|
|
<refname>SWFText->setSpacing</refname>
|
|
<refpurpose>Sets the current font spacing</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftext->setspacing</function></funcdef>
|
|
<paramdef>double <parameter>spacing</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftext->setspacing</function> sets the current font spacing to
|
|
<parameter>spacing</parameter><parameter>spacing</parameter>. 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.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftext.setcolor">
|
|
<refnamediv>
|
|
<refname>SWFText->setColor</refname>
|
|
<refpurpose>Sets the current font color</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftext->setcolor</function></funcdef>
|
|
<paramdef>int <parameter>red</parameter></paramdef>
|
|
<paramdef>int <parameter>green</parameter></paramdef>
|
|
<paramdef>int <parameter>blue</parameter></paramdef>
|
|
<paramdef>int <parameter><optional>a</optional></parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftext->setspacing</function> changes the current text color.
|
|
Default is black. I think. Color is represented using the RGB system.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftext.moveto">
|
|
<refnamediv>
|
|
<refname>SWFText->moveTo</refname>
|
|
<refpurpose>Moves the pen</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftext->moveto</function></funcdef>
|
|
<paramdef>int <parameter>x</parameter></paramdef>
|
|
<paramdef>int <parameter>y</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftext->moveto</function> moves the pen (or cursor, if
|
|
that makes more sense) to (<parameter>x</parameter>,<parameter>y</parameter>)
|
|
in text object's coordinate space. If either is zero, though, value
|
|
in that dimension stays the same. Annoying, should be fixed.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftext.addstring">
|
|
<refnamediv>
|
|
<refname>SWFText->addString</refname>
|
|
<refpurpose>Draws a string</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftext->addstring</function></funcdef>
|
|
<paramdef>string <parameter>string</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftext->addstring</function> draws the string <parameter>string</parameter>
|
|
at the current pen (cursor) location. Pen is at the baseline of the text;
|
|
i.e., ascending text is in the -y direction.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftext.getwidth">
|
|
<refnamediv>
|
|
<refname>SWFText->getWidth</refname>
|
|
<refpurpose>Computes string's width</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftext->addstring</function></funcdef>
|
|
<paramdef>string <parameter>string</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftext->addstring</function> returns the rendered width of the
|
|
<parameter>string</parameter> string at the text object's current font,
|
|
scale, and spacing settings.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- SWFFont -->
|
|
|
|
<refentry id="function.swffont">
|
|
<refnamediv>
|
|
<refname>SWFFont</refname>
|
|
<refpurpose>Loads a font definition</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>new <function>swffont</function></funcdef>
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
If <parameter>filename</parameter> 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.
|
|
</para>
|
|
<para>
|
|
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.
|
|
</para>
|
|
<para>
|
|
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:
|
|
<programlisting role="php">
|
|
<?php
|
|
$f = newSWFFont("_sans");
|
|
?>
|
|
</programlisting>
|
|
will give you the standard sans-serif font, probably the same as what you'd get
|
|
with <literal><font name="sans-serif"></literal> in HTML.
|
|
</para>
|
|
<para>
|
|
<function>swffont</function> returns a reference to the font
|
|
definition, for use in the <function>SWFText->setFont</function>
|
|
and the <function>SWFTextField->setFont</function> methods.
|
|
</para>
|
|
<simpara>
|
|
SWFFont has the following methods : <function>swffont->getwidth</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swffont.getwidth">
|
|
<refnamediv>
|
|
<refname>swffont->getwidth</refname>
|
|
<refpurpose>Returns the string's width</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>int <function>swffont->getwidth</function></funcdef>
|
|
<paramdef>string <parameter>string</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swffont->getwidth</function> returns the string
|
|
<parameter>string</parameter>'s width, using font's default scaling.
|
|
You'll probably want to use the <function>SWFText</function> version of this method which
|
|
uses the text object's scale.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- SWFTextField -->
|
|
|
|
<refentry id="function.swftextfield">
|
|
<refnamediv>
|
|
<refname>SWFTextField</refname>
|
|
<refpurpose>Creates a text field object</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>new <function>swftextfield</function></funcdef>
|
|
<paramdef>int <parameter><optional>flags</optional></parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftextfield</function> creates a new text field object.
|
|
Text Fields are less flexible than <function>swftext</function> 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.
|
|
</para>
|
|
<para>
|
|
The optional flags change the text field's behavior. It has the following
|
|
possibles values :
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
SWFTEXTFIELD_NOEDIT indicates that the field shouldn't be user-editable
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
SWFTEXTFIELD_PASSWORD obscures the data entry
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
SWFTEXTFIELD_DRAWBOX draws the outline of the textfield
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
SWFTEXTFIELD_MULTILINE allows multiple lines
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
SWFTEXTFIELD_WORDWRAP allows text to wrap
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
SWFTEXTFIELD_NOSELECT makes the field non-selectable
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
Flags are combined with the bitwise
|
|
<link linkend="language.operators.bitwise">OR</link> operation. For example,
|
|
<programlisting role="php">
|
|
<?php
|
|
$t = newSWFTextField(SWFTEXTFIELD_PASSWORD | SWFTEXTFIELD_NOEDIT);
|
|
?>
|
|
</programlisting>
|
|
creates a totally useless non-editable password field.
|
|
</para>
|
|
<simpara>
|
|
SWFTextField has the following methods : <function>swftextfield->setfont</function>,
|
|
<function>swftextfield->setbounds</function>, <function>swftextfield->align</function>,
|
|
<function>swftextfield->setheight</function>, <function>swftextfield->setleftmargin</function>,
|
|
<function>swftextfield->setrightmargin</function>, <function>swftextfield->setmargins</function>,
|
|
<function>swftextfield->setindentation</function>, <function>swftextfield->setlinespacing</function>,
|
|
<function>swftextfield->setcolor</function>, <function>swftextfield->setname</function> and
|
|
<function>swftextfield->addstring</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftextfield.setfont">
|
|
<refnamediv>
|
|
<refname>SWFTextField->setFont</refname>
|
|
<refpurpose>Sets the text field font</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftextfield->setfont</function></funcdef>
|
|
<paramdef>string <parameter>font</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftextfield->setfont</function> sets the text field font to
|
|
the [browser-defined?] <parameter>font</parameter> font.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftextfield.setbounds">
|
|
<refnamediv>
|
|
<refname>SWFTextField->setbounds</refname>
|
|
<refpurpose>Sets the text field width and height</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftextfield->setbounds</function></funcdef>
|
|
<paramdef>int <parameter>width</parameter></paramdef>
|
|
<paramdef>int <parameter>height</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftextfield->setbounds</function> sets the text field width
|
|
to <parameter>width</parameter> and height to <parameter>height</parameter>.
|
|
If you don't set the bounds yourself, Ming makes a poor guess at what
|
|
the bounds are.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftextfield.align">
|
|
<refnamediv>
|
|
<refname>SWFTextField->align</refname>
|
|
<refpurpose>Sets the text field alignment</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftextfield->align</function></funcdef>
|
|
<paramdef>int <parameter>alignement</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftextfield->align</function> sets the text field alignment
|
|
to <parameter>alignement</parameter>. Valid values for
|
|
<parameter>alignement</parameter> are : SWFTEXTFIELD_ALIGN_LEFT,
|
|
SWFTEXTFIELD_ALIGN_RIGHT, SWFTEXTFIELD_ALIGN_CENTER and
|
|
SWFTEXTFIELD_ALIGN_JUSTIFY.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftextfield.setheight">
|
|
<refnamediv>
|
|
<refname>SWFTextField->setHeight</refname>
|
|
<refpurpose>Sets the font height of this text field font.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftextfield->setheight</function></funcdef>
|
|
<paramdef>int <parameter>height</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftextfield->setheight</function> sets the font height of this text field
|
|
font to the given height <parameter>height</parameter>. Default is 240.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftextfield.setleftmargin">
|
|
<refnamediv>
|
|
<refname>SWFTextField->setLeftMargin</refname>
|
|
<refpurpose>Sets the left margin width of the text field.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftextfield->setleftmargin</function></funcdef>
|
|
<paramdef>int <parameter>width</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftextfield->setleftmargin</function> sets the left margin width
|
|
of the text field to <parameter>width</parameter>. Default is 0.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftextfield.setrightmargin">
|
|
<refnamediv>
|
|
<refname>SWFTextField->setrightMargin</refname>
|
|
<refpurpose>Sets the right margin width of the text field.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftextfield->setrightmargin</function></funcdef>
|
|
<paramdef>int <parameter>width</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftextfield->setrightmargin</function> sets the right margin width
|
|
of the text field to <parameter>width</parameter>. Default is 0.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftextfield.setmargins">
|
|
<refnamediv>
|
|
<refname>SWFTextField->setMargins</refname>
|
|
<refpurpose>Sets the margins width of the text field.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftextfield->setmargins</function></funcdef>
|
|
<paramdef>int <parameter>left</parameter></paramdef>
|
|
<paramdef>int <parameter>right</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftextfield->setmargins</function> set both margins at once,
|
|
for the man on the go.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftextfield.setindentation">
|
|
<refnamediv>
|
|
<refname>SWFTextField->setindentation</refname>
|
|
<refpurpose>Sets the indentation of the first line.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftextfield->setindentation</function></funcdef>
|
|
<paramdef>int <parameter>width</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftextfield->setindentation</function> sets the indentation of
|
|
the first line in the text field, to <parameter>width</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftextfield.setlinespacing">
|
|
<refnamediv>
|
|
<refname>SWFTextField->setLineSpacing</refname>
|
|
<refpurpose>Sets the line spacing of the text field.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftextfield->setlinespacing</function></funcdef>
|
|
<paramdef>int <parameter>height</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftextfield->setlinespacing</function> sets the line spacing
|
|
of the text field to the height of <parameter>height</parameter>. Default is 40.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftextfield.setcolor">
|
|
<refnamediv>
|
|
<refname>SWFTextField->setcolor</refname>
|
|
<refpurpose>Sets the color of the text field. </refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftextfield->setcolor</function></funcdef>
|
|
<paramdef>int <parameter>red</parameter></paramdef>
|
|
<paramdef>int <parameter>green</parameter></paramdef>
|
|
<paramdef>int <parameter>blue</parameter></paramdef>
|
|
<paramdef>int <parameter><optional>a</optional></parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftextfield->setcolor</function> sets the color of the text field.
|
|
Default is fully opaque black. Color is represented using RGB system.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftextfield.setname">
|
|
<refnamediv>
|
|
<refname>SWFTextField->setname</refname>
|
|
<refpurpose>Sets the variable name</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftextfield->setname</function></funcdef>
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftextfield->setname</function> sets the variable name of this
|
|
text field to <parameter>name</parameter>, for form posting and action
|
|
scripting purposes.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swftextfield.addstring">
|
|
<refnamediv>
|
|
<refname>SWFTextField->addstring</refname>
|
|
<refpurpose>Concatenates the given string to the text field</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swftextfield->addstring</function></funcdef>
|
|
<paramdef>string <parameter>string</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swftextfield->setname</function> concatenates the string
|
|
<parameter>string</parameter> to the text field.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- SWFSprite -->
|
|
|
|
<refentry id="function.swfsprite">
|
|
<refnamediv>
|
|
<refname>SWFSprite</refname>
|
|
<refpurpose>Creates a movie clip (a sprite)</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>new <function>swfsprite</function></funcdef>
|
|
<paramdef>void</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfsprite</function> 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.
|
|
</para>
|
|
<simpara>
|
|
<function>swfsprite</function> has the following methods :
|
|
<function>swfsprite->add</function>,
|
|
<function>swfsprite->remove</function>, <function>swfsprite->nextframe</function>
|
|
and <function>swfsprite->setframes</function>.
|
|
</simpara>
|
|
<para>
|
|
This simple example will spin gracefully a big red square.
|
|
<example>
|
|
<title><function>swfsprite</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfsprite.add">
|
|
<refnamediv>
|
|
<refname>SWFSprite->add</refname>
|
|
<refpurpose>Adds an object to a sprite</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfsprite->add</function></funcdef>
|
|
<paramdef>ressource <parameter>object</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfsprite->add</function> adds a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function>,
|
|
a <function>swfaction</function> or a <function>swfsprite</function> object.
|
|
</para>
|
|
<para>
|
|
For displayable types (<function>swfshape</function>,
|
|
<function>swfbutton</function>, <function>swftext</function>,
|
|
<function>swfaction</function> or <function>swfsprite</function>),
|
|
this returns a handle to the object in a display list.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfsprite.remove">
|
|
<refnamediv>
|
|
<refname>SWFSprite->remove</refname>
|
|
<refpurpose>Removes an object to a sprite</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfsprite->remove</function></funcdef>
|
|
<paramdef>ressource <parameter>object</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfsprite->remove</function> remove a <function>swfshape</function>, a
|
|
<function>swfbutton</function>, a <function>swftext</function>,
|
|
a <function>swfaction</function> or a <function>swfsprite</function> object
|
|
from the sprite.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfsprite.setframes">
|
|
<refnamediv>
|
|
<refname>SWFSprite->setframes</refname>
|
|
<refpurpose>Sets the total number of frames in the animation.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfsprite->setframes</function></funcdef>
|
|
<paramdef>int <parameter>numberofframes</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfsprite->setframes</function> sets the total number of frames
|
|
in the animation to <parameter>numberofframes</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfsprite.nextframe">
|
|
<refnamediv>
|
|
<refname>SWFSprite->nextframe</refname>
|
|
<refpurpose>Moves to the next frame of the animation.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfsprite->nextframe</function></funcdef>
|
|
<paramdef>void </paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfsprite->setframes</function> moves to the next frame of
|
|
the animation.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- SWFButton -->
|
|
|
|
<refentry id="function.swfbutton">
|
|
<refnamediv>
|
|
<refname>SWFbutton</refname>
|
|
<refpurpose>Creates a new Button.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>new <function>swfbutton</function></funcdef>
|
|
<paramdef>void</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfbutton</function> creates a new Button.
|
|
Roll over it, click it, see it call action code. Swank.
|
|
</para>
|
|
<simpara>
|
|
SWFButton has the following methods : <function>swfbutton->addshape</function>,
|
|
<function>swfbutton->setup</function>, <function>swfbutton->setover</function>
|
|
<function>swfbutton->setdown</function>, <function>swfbutton->sethit</function>
|
|
<function>swfbutton->setaction</function> and
|
|
<function>swfbutton->addaction</function>.
|
|
</simpara>
|
|
<para>
|
|
This simple example will show your usual interactions with buttons :
|
|
rollover, rollon, mouseup, mousedown, noaction.
|
|
<example>
|
|
<title><function>swfbutton</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
This simple example will enables you to drag draw a big red button
|
|
on the windows. No drag-and-drop, just moving around.
|
|
<example>
|
|
<title><function>swfbutton->addaction</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfbutton.addshape">
|
|
<refnamediv>
|
|
<refname>SWFbutton->addShape</refname>
|
|
<refpurpose>Adds a shape to a button</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfbutton->addshape</function></funcdef>
|
|
<paramdef>ressource <parameter>shape</parameter></paramdef>
|
|
<paramdef>int <parameter>flags</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfbutton->addshape</function> adds the shape
|
|
<parameter>shape</parameter> to this button. The following
|
|
<parameter>flags</parameter>' 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.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfbutton.setup">
|
|
<refnamediv>
|
|
<refname>SWFbutton->setUp</refname>
|
|
<refpurpose>Alias for addShape(shape, SWFBUTTON_UP)</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfbutton->setup</function></funcdef>
|
|
<paramdef>ressource <parameter>shape</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfbutton->setup</function> alias for addShape(shape, SWFBUTTON_UP).
|
|
</para>
|
|
<para>
|
|
See also
|
|
<function>swfbutton->addshape</function> and
|
|
<function>SWFAction</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfbutton.setover">
|
|
<refnamediv>
|
|
<refname>SWFbutton->setOver</refname>
|
|
<refpurpose>Alias for addShape(shape, SWFBUTTON_OVER)</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfbutton->setover</function></funcdef>
|
|
<paramdef>ressource <parameter>shape</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfbutton->setover</function> alias for addShape(shape, SWFBUTTON_OVER).
|
|
</para>
|
|
<para>
|
|
See also
|
|
<function>swfbutton->addshape</function> and
|
|
<function>SWFAction</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfbutton.setdown">
|
|
<refnamediv>
|
|
<refname>SWFbutton->setdown</refname>
|
|
<refpurpose>Alias for addShape(shape, SWFBUTTON_DOWN))</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfbutton->setdown</function></funcdef>
|
|
<paramdef>ressource <parameter>shape</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfbutton->setdown</function> alias for addShape(shape, SWFBUTTON_DOWN).
|
|
</para>
|
|
<para>
|
|
See also
|
|
<function>swfbutton->addshape</function> and
|
|
<function>SWFAction</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfbutton.sethit">
|
|
<refnamediv>
|
|
<refname>SWFbutton->setHit</refname>
|
|
<refpurpose>Alias for addShape(shape, SWFBUTTON_HIT)</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfbutton->sethit</function></funcdef>
|
|
<paramdef>ressource <parameter>shape</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfbutton->sethit</function> alias for addShape(shape, SWFBUTTON_HIT).
|
|
</para>
|
|
<para>
|
|
See also
|
|
<function>swfbutton->addshape</function> and
|
|
<function>SWFAction</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfbutton.addaction">
|
|
<refnamediv>
|
|
<refname>SWFbutton->addAction</refname>
|
|
<refpurpose>Adds an action</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfbutton->addaction</function></funcdef>
|
|
<paramdef>ressource <parameter>action</parameter></paramdef>
|
|
<paramdef>int <parameter>flags</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfbutton->addaction</function> adds the action
|
|
<parameter>action</parameter> to this button for the given conditions.
|
|
The following <parameter>flags</parameter> are valid:
|
|
SWFBUTTON_MOUSEOVER, SWFBUTTON_MOUSEOUT, SWFBUTTON_MOUSEUP,
|
|
SWFBUTTON_MOUSEUPOUTSIDE, SWFBUTTON_MOUSEDOWN, SWFBUTTON_DRAGOUT and
|
|
SWFBUTTON_DRAGOVER.
|
|
</para>
|
|
<para>
|
|
See also
|
|
<function>swfbutton->addshape</function> and
|
|
<function>SWFAction</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.swfbutton.setaction">
|
|
<refnamediv>
|
|
<refname>SWFbutton->setAction</refname>
|
|
<refpurpose>Sets the action</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>swfbutton->setaction</function></funcdef>
|
|
<paramdef>ressource <parameter>action</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfbutton->setaction</function> sets the action to be performed
|
|
when the button is clicked. Alias for addAction(shape, SWFBUTTON_MOUSEUP).
|
|
<parameter>action</parameter> is a <function>swfaction</function>.
|
|
</para>
|
|
<para>
|
|
See also
|
|
<function>swfbutton->addshape</function> and
|
|
<function>SWFAction</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- SWFAction -->
|
|
|
|
<refentry id="function.swfaction">
|
|
<refnamediv>
|
|
<refname>SWFAction</refname>
|
|
<refpurpose>Creates a new Action.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>new <function>swfaction</function></funcdef>
|
|
<paramdef>string <parameter>script</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>swfaction</function> creates a new Action, and
|
|
compiles the given script into an SWFAction object.
|
|
</para>
|
|
<para>
|
|
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.
|
|
</para>
|
|
<para>
|
|
So what's left? The compiler recognises the following tokens:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
break
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
for
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
continue
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
if
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
else
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
do
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
while
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>
|
|
There is no typed data; all values in the SWF action machine are stored as strings.
|
|
The following functions can be used in expressions:
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term>time()</term>
|
|
<listitem>
|
|
<simpara>
|
|
Returns the number of milliseconds (?) elapsed since the movie started.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>random(seed)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Returns a pseudo-random number in the range 0-seed.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>length(expr)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Returns the length of the given expression.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>int(number)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Returns the given number rounded down to the nearest integer.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>concat(expr, expr)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Returns the concatenation of the given expressions.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>ord(expr)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Returns the ASCII code for the given character
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>chr(num)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Returns the character for the given ASCII code
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>substr(string, location, length)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Returns the substring of length length at location location of
|
|
the given string string.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
<para>
|
|
Additionally, the following commands may be used:
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term>duplicateClip(clip, name, depth)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Duplicate the named movie clip (aka sprite). The new movie clip has name name
|
|
and is at depth depth.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>removeClip(expr)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Removes the named movie clip.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>trace(expr)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Write the given expression to the trace log. Doubtful that the browser
|
|
plugin does anything with this.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>startDrag(target, lock, [left, top, right, bottom])</term>
|
|
<listitem>
|
|
<simpara>
|
|
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.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>stopDrag()</term>
|
|
<listitem>
|
|
<simpara>
|
|
Stop dragging my heart around. And this movie clip, too.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>callFrame(expr)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Call the named frame as a function.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>getURL(url, target, [method])</term>
|
|
<listitem>
|
|
<simpara>
|
|
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.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>loadMovie(url, target)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Same as above, more or less. Come to think of it, I don't quite know what
|
|
the difference is.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>nextFrame()</term>
|
|
<listitem>
|
|
<simpara>
|
|
Go to the next frame.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>prevFrame()</term>
|
|
<listitem>
|
|
<simpara>
|
|
Go to the last (or, rather, previous) frame.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>play()</term>
|
|
<listitem>
|
|
<simpara>
|
|
Start playing the movie.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>stop()</term>
|
|
<listitem>
|
|
<simpara>
|
|
Stop playing the movie.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>toggleQuality()</term>
|
|
<listitem>
|
|
<simpara>
|
|
Toggle between high and low quality.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>stopSounds()</term>
|
|
<listitem>
|
|
<simpara>
|
|
Stop playing all sounds.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>gotoFrame(num)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Go to frame number num. Frame numbers start at 0.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>gotoFrame(name)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Go to the frame named name. Which does a lot of good, since I
|
|
haven't added frame labels yet.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>setTarget(expr)</term>
|
|
<listitem>
|
|
<simpara>
|
|
Sets the context for action. Or so they say- I really have no
|
|
idea what this does.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
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.
|
|
</para>
|
|
<para>
|
|
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:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
x
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
y
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
xScale
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
yScale
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
currentFrame - (read-only)
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
totalFrames - (read-only)
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
alpha - transparency level
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
visible - 1=on, 0=off (?)
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
width - (read-only)
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
height - (read-only)
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
rotation
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
target - (read-only) (???)
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
framesLoaded - (read-only)
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
name
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
dropTarget - (read-only) (???)
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
url - (read-only) (???)
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
highQuality - 1=high, 0=low (?)
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
focusRect - (???)
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
soundBufTime - (???)
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
So, setting a sprite's x position is as simple as <literal>/box.x = 100;</literal>.
|
|
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.
|
|
</para>
|
|
<para>
|
|
This simple example will move the red square across the window.
|
|
<example>
|
|
<title><function>swfaction</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
This simple example tracks down your mouse on the screen.
|
|
<example>
|
|
<title><function>swfaction</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Same as above, but with nice colored balls...
|
|
<example>
|
|
<title><function>swfaction</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
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?)
|
|
<example>
|
|
<title><function>swfaction</function> example</title>
|
|
<programlisting role="php">
|
|
<?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();
|
|
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
</reference>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
-->
|