SWFSprite

(PHP 4 >= 4.0.5)

SWFSprite -- Creates a movie clip (a sprite)

Description

SWFSprite swfsprite ( void )

警告

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

swfsprite() are also known as a "movie clip", this allows one to create objects which are animated in their own timelines. Hence, the sprite has most of the same methods as the movie.

swfsprite() has the following methods : swfsprite->add(), swfsprite->remove(), swfsprite->nextframe() and swfsprite->setframes().

This simple example will spin gracefully a big red square.

例子 1. swfsprite() example

<?php
  $s
= new SWFShape();
  
$s->setRightFill($s->addFill(0xff, 0, 0));
  
$s->movePenTo(-500, -500);
  
$s->drawLineTo(500, -500);
  
$s->drawLineTo(500, 500);
  
$s->drawLineTo(-500, 500);
  
$s->drawLineTo(-500, -500);

  
$p = new SWFSprite();
  
$i = $p->add($s);
  
$p->nextFrame();
  
$i->rotate(15);
  
$p->nextFrame();
  
$i->rotate(15);
  
$p->nextFrame();
  
$i->rotate(15);
  
$p->nextFrame();
  
$i->rotate(15);
  
$p->nextFrame();
  
$i->rotate(15);
  
$p->nextFrame();

  
$m = new SWFMovie();
  
$i = $m->add($p);
  
$i->moveTo(1500, 1000);
  
$i->setName("blah");

  
$m->setBackground(0xff, 0xff, 0xff);
  
$m->setDimension(3000, 2000);

  
header('Content-type: application/x-shockwave-flash');
  
$m->output();
?>


add a note add a note User Contributed Notes
o dot marce at free dot fr
04-Oct-2005 03:47
Note that when adding an sprite to a container (sprite or movie), only the object added to the sprite before the addin to the container will be displayed.

// In this case, myShape will be displayed...
$sp=new SWFSprite();
$container=new SWFSprite();
$sp->add($myShape);
$container->add($sp);

// but not in this case
$sp=new SWFSprite();
$container=new SWFSprite();
$container->add($sp);
$sp->add($myShape);