(PHP 4 >= 4.0.5)

SWFText -- Creates a new SWFText object


SWFText swftext ( void )


本函数是实验性的。本函数的行为,包括函数名称以及其它任何关于本函数的文档可能会在没有通知的情况下随 PHP 以后的发布而改变。使用本函数风险自担。

swftext() creates a new SWFText object, fresh for manipulating.

SWFText has the following methods : swftext->setfont(), swftext->setheight(), swftext->setspacing(), swftext->setcolor(), swftext->moveto(), swftext->addstring() and swftext->getwidth().

This simple example will draw a big yellow "PHP generates Flash with Ming" text, on white background.

例子 1. swftext() example

= new SWFFont("Techno.fdb");
$t = new SWFText();
$t->moveTo(200, 2400);
$t->setColor(0xff, 0xff, 0);
$t->addString("PHP generates Flash with Ming!!");

$m = new SWFMovie();
$m->setDimension(5400, 3600);


header('Content-type: application/x-shockwave-flash');

add a note add a note User Contributed Notes
samrerb at gmail dot com
02-Aug-2006 11:19
a note to add to p_smiecho at interia dot pl's post:
when you do a $movie->add($t); it will return a SWFDisplayItem which can then be moved so your code can be simplified to this:

= new SWFFont('Arial');
$t = new SWFTextField();
$t -> setFont($f);
$t -> addString('Hello world!!!');
$m = new SWFMovie();

$ttwo->moveTo(300, 300);

(on a windows box running Ming .2)
p_smiecho at interia dot pl
01-Dec-2003 07:26
It seems to me that there is a bug: everything works perfect but only with Linux. SWFText crashes while working on Windows. So I do it that way:

   $f = new SWFFont('Arial');
   $t = new SWFTextField();
   $t -> setFont($f);
   $t -> addString('Hello world!!!');

   $p = new SWFSprite();
   $i = $p -> add($t);
   $i -> moveto(100, 100);    // Here you can move text !!
   //$p -> remove($i);

   $m = new SWFMovie();
   $m -> add($p);

Of course it writes text where I want, but I still can't get other methods of SWFText class. For example: I can't get text width (swftext->getwidth).
franky at boucheros dot com
22-Apr-2002 09:12
For windows platform :

$f=new SWFFont("_sans");
$t=new SWFTextField();

and comment the moveto line.