The SWFMovie class

Введение

SWFMovie is a movie object representing an SWF movie.

Class synopsis

SWFMovie
class SWFMovie {
/* Methods */
mixed add ( object $instance )
void addExport ( SWFCharacter $char , string $name )
mixed addFont ( SWFFont $font )
SWFMovie __construct ( int $version )
SWFSprite importChar ( string $libswf , string $name )
SWFFontChar importFont ( string $libswf , string $name )
void labelFrame ( string $label )
void nextFrame ( void )
int output ([ int $compression ] )
void remove ( object $instance )
int save ( string $filename [, int $compression ] )
int saveToFile ( stream $x [, int $compression ] )
void setbackground ( int $red , int $green , int $blue )
void setDimension ( int $width , int $height )
void setFrames ( int $number )
void setRate ( int $rate )
SWFSoundInstance startSound ( SWFSound $sound )
void stopSound ( SWFSound $sound )
int streamMP3 ( mixed $mp3file [, float $skip ] )
void writeExports ( void )
}

Содержание

Коментарии

<?php 
$myShape1
=new SWFShape(); 
$myShape1->setLine(5,0,0,255); 
$myShape1->setRightFill(255,255,0); 
$myShape1->movePen(-30,-30); 
$myShape1->drawLine(60,0); 
$myShape1->drawLine(0,60); 
$myShape1->drawLine(-60,0); 
$myShape1->drawLine(0,-60); 
$myMovie=new SWFMovie(); 
$myMovie->setDimension(460,80); 
$myMovie->setBackground(255,0,0); 
$movingSquare=$myMovie->add($myShape1); 
$movingSquare->moveTo(40,40); 
$myMovie->nextFrame(); 
$movingSquare->move(40,0); 
$myMovie->nextFrame(); 
$movingSquare->move(40,0); 
$myMovie->nextFrame(); 
$movingSquare->move(40,0); 
$myMovie->nextFrame(); 
$movingSquare->move(40,0); 
$myMovie->nextFrame(); 
$movingSquare->move(40,0); 
$myMovie->nextFrame(); 
$movingSquare->move(40,0); 
$myMovie->nextFrame(); 
$movingSquare->move(40,0); 
$myMovie->nextFrame(); 
$movingSquare->move(40,0); 
$myMovie->nextFrame(); 
$movingSquare->move(40,0); 
$myMovie->nextFrame(); 
$movingSquare->move(40,0); 
$myMovie->nextFrame(); 
$movingSquare->move(40,0); 
$myMovie->nextFrame(); 
$movingSquare->move(40,0); 
$myMovie->save("lesson.swf"); 
?> 

Sachin Akhani
http://www.askyp.com
2009-01-12 21:16:53
http://php5.kiev.ua/manual/ru/class.swfmovie.html
<?php
// php ming swf flash movie example --
// this routine simply adds a shadow, text, and movement to a rectangle shape.
// for a dissolve effect using swfmorph, see this add'l note:
// function.swfmorph.construct

$lineweight 3;
$linered 102;
$linegreen 102;
$lineblue 255;

$fillred 204;
$fillgreen 204;
$fillblue 255;
$rectlinelen 200;

$shadowred 153;
$shadowgreen 153;
$shadowblue 153;
$shadowoffset 3;

$x 100;
$y 150;

$m = new SWFMovie();
$m->setDimension(640,480);
$m->setBackground(235,235,235);
$m->setRate(65);

$is $m->add(shadowrectShape(true));
$i $m->add(rectShape(true));

$text "Shadow Play...";
$its $m->add(textField($text15$shadowred$shadowgreen$shadowblue));
$it $m->add(textField($text15$linered-25$linegreen$lineblue));

$is->moveTo($x+$shadowoffset,$y+$shadowoffset);
$i->moveTo($x,$y);  // starting x,y for rectangle
$its->moveTo($x+15+1,$y+15+1);  // only a minimal shadow for text...
$it->moveTo($x+15,$y+15);

for (
$n=0$n 75$n++) {
 
$is->move(2.050.05);  // rectangle's shadow, lengthens as it moves
 
$i->move(2,0);  // original rectangle
 
$its->move(20.01);  // text shadow
 
$it->move(2,0);  // text
 
$m->nextFrame();
}

$m->add(new SWFAction("stop();"));
$m->nextFrame();

// $m->save("shadow.swf");

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

<?php
function rectShape($addfill) {
  global 
$lineweight$linered$linegreen$lineblue;
  global 
$fillred$fillgreen$fillblue$rectlinelen;

 
$s = new SWFShape();
 
$s->setLine($lineweight$linered$linegreen$lineblue);
  if (
$addfill) {
   
$s->setRightFill($s->addFill($fillred$fillgreen$fillblue));
  }
 
$s->drawLine($rectlinelen0);
 
$s->drawLine(0$rectlinelen);
 
$s->drawLine(-$rectlinelen0);
 
$s->drawLine(0, -$rectlinelen);
  return 
$s;
}

function 
shadowrectShape($addfill) {
  global 
$lineweight$rectlinelen;
  global 
$shadowoffset$shadowred$shadowgreen$shadowblue;

 
$s = new SWFShape();
 
$s->setLine($lineweight$shadowred$shadowgreen$shadowblue);
  if (
$addfill) {
   
$s->setRightFill($s->addFill($shadowred$shadowgreen$shadowblue));
  }
 
$s->drawLine($rectlinelen+$shadowoffset0);
 
$s->drawLine(0$rectlinelen+$shadowoffset);
 
$s->drawLine(-$rectlinelen-$shadowoffset0);
 
$s->drawLine(0, -$rectlinelen-$shadowoffset);
  return 
$s;
}

function 
textField($strtext$intheight$textred$textgreen$textblue) {
 
$t = new SWFTextField();
 
$t->setFont(new SWFFont('Default'));
// or try this instead:
//  $t = new SWFText();
//  $f = new SWFFont("Bitstream Vera Sans.fdb");
//  $t->setFont($f);
 
$t->setColor($textred$textgreen$textblue);
 
$t->addString($strtext);
 
$t->setHeight($intheight);
  return 
$t;
}
?>
2009-02-26 09:54:35
http://php5.kiev.ua/manual/ru/class.swfmovie.html
<?php
// php ming swf flash movie example #2 --
// this routine displays several wipe/fade transitional effects

 
$f = new SWFFont("Bitstream Vera Serif.fdb");

 
$m = new SWFMovie();
 
$m->setDimension(640480);
 
$m->setBackground(0255153);
 
$m->setRate(9);

 
$p movieclip("First..."025525510050257);
 
$i $m->add($p);
 
$p movieclip("Second..."1020102100170185);
 
$i $m->add($p);
 
$p movieclip("Third..."255051100290306);
 
$i $m->add($p);

//  $m->save("wfeffect.swf");

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

<?php
 
function movieclip($txt$r$g$b$x$y$sv$mv) {
    global 
$f;

   
$s = new SWFShape();
   
$s->setLine(1,0,0,255); // (line weight, r, g, b)
   
$s->setRightFill(255,255,0);
   
$s->drawLine(170,0);
   
$s->drawLine(0,60);
   
$s->drawLine(-170,0);
   
$s->drawLine(0,-60);

   
$t = new SWFText();
   
$t->setFont($f);
   
$t->setColor($r$g$b);
   
$t->setHeight(17);
   
$t->addString($txt);

   
$p = new SWFSprite();
   
$is $p->add($s);
   
// works with images also:
//    $is = $p->add(new SWFBitMap(fopen("/images/yourbmp.jpg", "rb")));

   
$it $p->add($t);

   
$is->moveTo($x$y);
   
$it->moveTo($x+10$y+20);

   
// adjust movement left with a compensating move
    // right ($i->move()), to change look of this effect:
    // note: setting the scaleTo() $y parameter to 0 didn't help(?)
    // fixed in later versions?  only tested with Ming 0.3beta1.
   
$scaleLeftValue $sv;
   
$moveRightValue $scaleLeftValue/$mv;

    for (
$n=1$n $scaleLeftValue$n++) {
     
$is->scaleTo(1-($n/$scaleLeftValue), 1);
     
$it->scaleTo(1-($n/$scaleLeftValue), 1);
     
$is->move($moveRightValue0);

     
// fade text color to add to effect:
     
if ($n <= 10) {
       
$it->addColor(10*$n10*$n10*$n);
      }
     
// try to keep text in bounds
     
if ($n $scaleLeftValue 2) {
       
$it->move($moveRightValue0);
      }
     
$p->nextframe();
    }
   
$p->remove($is);  // remove() causes item to disappear
   
$p->remove($it);  // which is exactly what we want here
   
$p->nextFrame();

   
$p->add(new SWFAction("stop();"));
   
$p->nextFrame();
    return 
$p;
  }
?>
2009-02-27 08:33:28
http://php5.kiev.ua/manual/ru/class.swfmovie.html
<?php
// php ming 'challenge response' style text to graphics routine --
// (example only; any use for input validation is up to you, however
//  this image can be displayed on text pages in an html iframe)

 
$f = new SWFFont("Bitstream Vera Serif.fdb");

 
$m = new SWFMovie();
 
$m->setDimension(500150);
 
$m->setBackground(255255255);

  for (
$r=0$r 6$r++) {
   
// random char selected from range: '2-9', 'A-Z', 'a-z'
   
switch (rand(0,2)) {
      case 
0:
       
$c chr(rand(50,57));
        break;
      case 
1:
       
$c chr(rand(65,90));
        break;
      case 
2:
       
$c chr(rand(97,122));
        break;
    }
   
$p convertchar($c);
   
$i $m->add($p);
  }
 
$i->setDepth(1);

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

<?php
 
function convertchar($txt) {
    global 
$f;
    static 
$x=10$y=5;

   
$s = new SWFShape();
   
$s->setLine(rand(0,1),125,125,200); // (line weight, r, g, b)
   
$s->drawLine(rand(15,25),0);

   
$t = new SWFText();
   
$t->setFont($f);
   
$t->setColor(1515195);
   
$t->setHeight(40);
   
$t->addString($txt);

   
$p = new SWFSprite();
   
$is $p->add($s);

   
$it $p->add($t);

   
$is->move($x,$y);  // lines thru char
   
$it->move($x,$y+8);
   
$x+=75;

   
// all chars adjusted in a slightly random manner
   
$rs rand(-1,1);
    for (
$n=0$n 3$n++) {
     
$it->scaleTo($n1);
     
$is->scaleTo($n1);

     
$it->rotate($rs);
     
$is->rotate($rs);

     
$it->skewx(-$rs/10);
     
$is->skewx(-$rs/10);

     
$it->skewy($rs/10);
     
$is->skewy($rs/10);
     
$p->nextframe();
    }

   
$p->add(new SWFAction("stop();"));
   
$p->nextFrame();
    return 
$p;
  }
?>
2009-04-06 11:47:53
http://php5.kiev.ua/manual/ru/class.swfmovie.html

    Поддержать сайт на родительском проекте КГБ