I am using ActiveSWF toolkit to produce dynamic Flash movies from XML. I like it, because only I need to produce new dynamic movie is new XML. PHP code is the same. Additionally, it has quite good documentation. See http://www.activeswf.com
CLV. Shockwave Flash 関数
導入
PHP は、Paul Haeberli が作成した libswf モジュールにより Shockwave Flash ファイルを作成する機能を提供します。
注意: SWF サポートは、PHP 4 RC2 で追加されました。
libswf は、Windows でサポートされていません。このライブラリの 開発は中止されており、他のシステムへ移植するためのソースは 入手できません。
最新の SWF サポートについては、 MING 関数を参照してください。
注意: この拡張モジュールは PECL レポジトリに移動 されており、以下のバージョン以降 PHP にバンドルされなくなっています。 PHP 5.0.0.
要件
PHP でこの拡張モジュールを使用するようコンパイルするためには、 libswf ライブラリを必要とします。 libswf は ftp://ftp.sgi.com/sgi/graphics/grafica/flash/ でダウンロードする ことができます。
インストール手順
libswf を入手した後にするべきことは、configure に --with-swf[=DIR] を指定すること だけです。ただし、DIR はディレクトリ include および lib を有する場所です。 ディレクトリ include にはファイル swf.h が、ディレクトリ lib には ファイル libswf.a がある必要があります。libswf の配布ファイルを展開した際には、 二つのファイルは一つのディレクトリにあります。結果的に、ファイルを 適当な場所に手動でコピーする必要があります。
実行時設定
設定ディレクティブは定義されていません。
リソース型
リソース型は定義されていません。
定義済み定数
以下の定数が定義されています。 この関数の拡張モジュールが PHP 組み込みでコンパイルされているか、 実行時に動的にロードされている場合のみ使用可能です。
- MOD_COLOR (integer)
- MOD_MATRIX (integer)
- TYPE_PUSHBUTTON (integer)
- TYPE_MENUBUTTON (integer)
- BSHitTest (float)
- BSDown (float)
- BSOver (float)
- BSUp (float)
- OverDowntoIdle (integer)
- IdletoOverDown (integer)
- OutDowntoIdle (integer)
- OutDowntoOverDown (integer)
- OverDowntoOutDown (integer)
- OverUptoOverDown (integer)
- OverUptoIdle (integer)
- IdletoOverUp (integer)
- ButtonEnter (integer)
- ButtonExit (integer)
- MenuEnter (integer)
- MenuExit (integer)
例
PHP を Shockwave Flash サポート付きでインストールした後は、 Shockwave ファイルを PHP から作成することができるようになります。 何ができるかが分かると驚かされることでしょう。次のコードを見てください。
- 目次
- swf_actiongeturl -- Shockwave Flash ムービーから URL を得る
- swf_actiongotoframe -- フレームを実行した後、停止する
- swf_actiongotolabel -- 指定したラベルを有するフレームを表示する
- swf_actionnextframe -- フレームを一つ進める
- swf_actionplay -- カレントのフレームから flash ムービーの実行を開始する
- swf_actionprevframe -- フレームを一つ戻す
- swf_actionsettarget -- アクションのコンテキストを設定する
- swf_actionstop -- カレントのフレームで flash ムービーの実行を終了する
- swf_actiontogglequality -- 低品質/高品質を切り替える
- swf_actionwaitforframe -- フレームがロードされていない場合にアクションをスキップする
- swf_addbuttonrecord -- カレントのボタンの位置、外観、アクティブエリアを制御する
- swf_addcolor -- グローバル加算色を、指定した rbga 値に設定する
- swf_closefile -- カレントの Shockwave Flash ファイルを閉じる
- swf_definebitmap -- ビットマップを定義する
- swf_definefont -- フォントを定義する
- swf_defineline -- 線を定義する
- swf_definepoly -- ポリゴンを定義する
- swf_definerect -- 長方形を定義する
- swf_definetext -- テキスト文字列を定義する
- swf_endbutton -- カレントのボタンの定義を終了する
- swf_enddoaction -- カレントのアクションを終了する
- swf_endshape -- カレントの形状の定義を完結する
- swf_endsymbol -- シンボルの定義を終了する
- swf_fontsize -- フォントの大きさを変更する
- swf_fontslant -- フォントの傾きを設定する
- swf_fonttracking -- カレントのフォントのトラッキングを設定する
- swf_getbitmapinfo -- ビットマップに関する情報を得る
- swf_getfontinfo -- 大文字の A と小文字の x の高さをピクセル単位で得る
- swf_getframe -- カレントのフレームのフレーム番号を得る
- swf_labelframe -- カレントのフレームにラベルを付ける
- swf_lookat -- 視点変換を定義する
- swf_modifyobject -- オブジェクトを修正する
- swf_mulcolor -- グローバル乗算色を指定した rbga 値に設定する
- swf_nextid -- 次の未使用のオブジェクト ID を返す
- swf_oncondition -- アクションリストのトリガとして使用されるトランジションを定義する
- swf_openfile -- 新規に Shockwave Flash ファイルをオープンする
- swf_ortho2 -- ユーザ座標の 2D 直交マッピングをカレントのビューポイントに定義する
- swf_ortho -- カレントのビューポートにおけるユーザー座標の直交マッピングを定義する
- swf_perspective -- 遠近法による投影変換を定義する
- swf_placeobject -- オブジェクトを画面に配置する
- swf_polarview -- 極座標で視点を定義する
- swf_popmatrix -- 以前の変換行列を回復する
- swf_posround -- オブジェクトを配置または移動する際の変換時の丸め処理を有効または無効にする
- swf_pushmatrix -- カレントの変換行列をスタックに入れる
- swf_removeobject -- オブジェクトを削除する
- swf_rotate -- カレントの座標を回転する
- swf_scale -- カレントの変換をスケリーングする
- swf_setfont -- カレントのフォントを変更する
- swf_setframe -- 指定したフレームに切替える
- swf_shapearc -- 円弧を描画する
- swf_shapecurveto3 -- 3 次ベジエ曲線を描画する
- swf_shapecurveto -- 2 点間に 2 次ベジエ曲線を描画する
- swf_shapefillbitmapclip -- カレントの塗りつぶしモードをクリップ付きビットマップに設定する
- swf_shapefillbitmaptile -- カレントの塗りつぶしモードをタイル状のビットマップに設定する
- swf_shapefilloff -- 塗りつぶしをオフにする
- swf_shapefillsolid -- カレントの塗りつぶし色を指定した色に設定する
- swf_shapelinesolid -- カレントの行のスタイルを設定する
- swf_shapelineto -- 線を描画する
- swf_shapemoveto -- カレントの位置を移動する
- swf_showframe -- カレントのフレームを表示する
- swf_startbutton -- ボタンの定義を開始する
- swf_startdoaction -- カレントのフレームのアクションリストの記述を開始する
- swf_startshape -- 複雑な形状を開始する
- swf_startsymbol -- シンボルを定義する
- swf_textwidth -- 文字列の幅を得る
- swf_translate -- カレントの座標軸を変換する
- swf_viewport -- 描画を行う範囲を選択する
Let's not forget to mention there IS another alternative to Swf-lib and Ming. It's called FreeMovie and is created by Jacek Artymiak from O'Reilly. This piece of art is made out of PHP-files only wich makes it suitable for many platforms. The project is also available via SourceForge as freemovie-php.
Thumbs up for that one!
Just to mention for users of SuSE 8.0. libswf is included with the distro with no fonts. Therefore you must "patch" libswf support. As I didn't find the solution here before and I found a solution I am posting this fix:
Download the libswf package and uncompress to a directory (e.g. /usr/share/php/swf). Then include
"
SWFFONTPATH=/path/to/fonts
export SWFFONTPATH
"
Then log out and in again and restart apache. Then you should be able to use flash text functions within PHP.
For those having problems with libswf fonts you can add a system wide variable to point to the fonts dir in your shell.
In linux open up /etc/profile and add the lines :
SWFFONTPATH=/path/to/fonts
export SWFFONTPATH
Please not all of that is case sensitive, so copy it carefully. Logout and log back in to see changes (should affect all users). Test it from the command line with echo $SWFFONTPATH
For windows users you should be able to add
SET SWFFONTPATH=/path/to/fonts
in your autoexec.bat or autoexec.nt. Test it with echo %SWFFONTPATH%
HTH! =)
This works also! Write into the script:
putenv ("SWFFONTPATH=/path_to_swf/fonts");
Maybe you can do the job with apache somehow, but it did't work for me. (With getenv it looked ok, but the swf failed to find the font)
isu
Writing on directory is not required. You can generate a run-time movie .. by replacing swf_openfile("<filename>", .... ) with swf_openfile("php://stdout", ....) and add before that an
Header("Content-type: application/x-shockwave-flash")
