<?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;
}
?>
La clase SWFMovie
(No hay información de versión disponible, podría estar únicamente en SVN)
Introducción
SWFMovie es un objeto película que representa una película SWF.
Sinopsis de la Clase
Tabla de contenidos
- SWFMovie::add — Añade cualquier tipo de información a un película
- SWFMovie::addExport — Descripción
- SWFMovie::addFont — Descripción
- SWFMovie::__construct — Crea un nuevo objeto película, representando una película SWF versión 4
- SWFMovie::importChar — Descripción
- SWFMovie::importFont — Descripción
- SWFMovie::labelFrame — Etiqueta un fotograma
- SWFMovie::nextFrame — Va al siguiente fotograma de la animación
- SWFMovie::output — Vuelca su película preparada con cariño
- SWFMovie::remove — Elimina la instancia del objeto de la lista de muestras
- SWFMovie::save — Guarda la película SWF en un archivo
- SWFMovie::saveToFile — Descripción
- SWFMovie::setbackground — Establece el color de fondo
- SWFMovie::setDimension — Establece el ancho y alto de la película
- SWFMovie::setFrames — Establece el número total de fotogramas de la animación
- SWFMovie::setRate — Establece la velocidad de animación de los fotogramas
- SWFMovie::startSound — Descripción
- SWFMovie::stopSound — Descripción
- SWFMovie::streamMP3 — Transfiere un archivo MP3
- SWFMovie::writeExports — Descripción
mark omohundro, ajamyajax dot com ¶
4 years ago
mark omohundro, ajamyajax dot com ¶
4 years ago
<?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 ¶
4 years ago
<?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 ¶
4 years ago
<?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
