PHP Doku:: The SWFMovie class - class.swfmovie.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzNon-Text MIME-AusgabenMing (flash)The SWFMovie class

Ein Service von Reinhard Neidl - Webprogrammierung.

Ming (flash)

<<SWFMorph->getShape2

SWFMovie->add>>


UnterSeiten:

The SWFMovie class

Einführung

SWFMovie is a movie object representing an SWF movie.

Klassenbeschreibung

SWFMovie {
/* Methoden */
mixed SWFMovie::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 ( resource $x [, int $compression ] )
void setbackground ( int $red , int $green , int $blue )
void setDimension ( float $width , float $height )
void setFrames ( int $number )
void setRate ( float $rate )
SWFSoundInstance startSound ( SWFSound $sound )
void stopSound ( SWFSound $sound )
int streamMP3 ( mixed $mp3file [, float $skip = 0 ] )
void writeExports ( void )
}

Inhaltsverzeichnis


4 BenutzerBeiträge:
- Beiträge aktualisieren...
mark omohundro, ajamyajax dot com
6.04.2009 17:47
<?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(500, 150);
 
$m->setBackground(255, 255, 255);

  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(15, 15, 195);
   
$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($n, 1);
     
$is->scaleTo($n, 1);

     
$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;
  }
?>
mark omohundro, ajamyajax dot com
27.02.2009 15:33
<?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(640, 480);
 
$m->setBackground(0, 255, 153);
 
$m->setRate(9);

 
$p = movieclip("First...", 0, 255, 255, 100, 50, 25, 7);
 
$i = $m->add($p);
 
$p = movieclip("Second...", 102, 0, 102, 100, 170, 18, 5);
 
$i = $m->add($p);
 
$p = movieclip("Third...", 255, 0, 51, 100, 290, 30, 6);
 
$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($moveRightValue, 0);

     
// fade text color to add to effect:
     
if ($n <= 10) {
       
$it->addColor(10*$n, 10*$n, 10*$n);
      }
     
// try to keep text in bounds
     
if ($n < $scaleLeftValue - 2) {
       
$it->move($moveRightValue, 0);
      }
     
$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;
  }
?>
mark omohundro, ajamyajax dot com
26.02.2009 16:54
<?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:
// http://www.php.net/manual/en/function.swfmorph.construct.php

$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($text, 15, $shadowred, $shadowgreen, $shadowblue));
$it = $m->add(textField($text, 15, $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.05, 0.05);  // rectangle's shadow, lengthens as it moves
 
$i->move(2,0);  // original rectangle
 
$its->move(2, 0.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($rectlinelen, 0);
 
$s->drawLine(0, $rectlinelen);
 
$s->drawLine(-$rectlinelen, 0);
 
$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+$shadowoffset, 0);
 
$s->drawLine(0, $rectlinelen+$shadowoffset);
 
$s->drawLine(-$rectlinelen-$shadowoffset, 0);
 
$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;
}
?>
askypcom at gmail dot com
13.01.2009 4:16
<?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



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)