mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-28 19:02:10 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@260655 c90b9560-bf6c-de11-be94-00142212c4b1
373 lines
7.6 KiB
XML
373 lines
7.6 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.2 $ -->
|
|
<!-- EN-Revision: 1.2 Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
|
|
<chapter xml:id="ming.examples" xmlns="http://docbook.org/ns/docbook">
|
|
&reftitle.examples;
|
|
<section xml:id="ming.examples.swfaction">
|
|
<title>Exemples avec SWFAction</title>
|
|
<para>
|
|
Cet exemple simple déplace un carré rouge dans une fenêtre.
|
|
<example>
|
|
<title>Exemple avec <function>swfaction</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$s = new SWFShape();
|
|
$f = $s->addFill(0xff, 0, 0);
|
|
$s->setRightFill($f);
|
|
|
|
$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);
|
|
$i->setDepth(1);
|
|
$p->nextFrame();
|
|
|
|
for ($n=0; $n<5; ++$n) {
|
|
$i->rotate(-15);
|
|
$p->nextFrame();
|
|
}
|
|
|
|
$m = new SWFMovie();
|
|
$m->setBackground(0xff, 0xff, 0xff);
|
|
$m->setDimension(6000, 4000);
|
|
|
|
$i = $m->add($p);
|
|
$i->setDepth(1);
|
|
$i->moveTo(-500,2000);
|
|
$i->setName("box");
|
|
|
|
$m->add(new SWFAction("/box.x += 3;"));
|
|
$m->nextFrame();
|
|
$m->add(new SWFAction("gotoFrame(0); play();"));
|
|
$m->nextFrame();
|
|
|
|
header('Content-type: application/x-shockwave-flash');
|
|
$m->output();
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Cet exemple simple va déplacer votre souris vers le bas de l'écran.
|
|
<example>
|
|
<title>Exemple avec <function>swfaction</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$m = new SWFMovie();
|
|
$m->setRate(36.0);
|
|
$m->setDimension(1200, 800);
|
|
$m->setBackground(0, 0, 0);
|
|
|
|
/* objet de suivi de la souris - vide, mais suit les mouvements de la souris
|
|
afin d'y récupérer les coordonnées x et y */
|
|
|
|
$i = $m->add(new SWFSprite());
|
|
$i->setName('mouse');
|
|
|
|
$m->add(new SWFAction("
|
|
startDrag('/mouse', 1); /* '1' signifie que l'on verrouille le sprite à la souris */
|
|
"));
|
|
|
|
/* on désactive l'antialiasing, vu que l'on souhaite juste utiliser des carrés */
|
|
|
|
$m->add(new SWFAction("
|
|
this.quality = 0;
|
|
"));
|
|
|
|
/* modification de la boite */
|
|
$r = new SWFMorph();
|
|
$s = $r->getShape1();
|
|
|
|
$s->setLeftFill($s->addFill(0xff, 0xff, 0xff));
|
|
$s->movePenTo(-40, -40);
|
|
$s->drawLine(80, 0);
|
|
$s->drawLine(0, 80);
|
|
$s->drawLine(-80, 0);
|
|
$s->drawLine(0, -80);
|
|
|
|
$s = $r->getShape2();
|
|
|
|
$s->setLeftFill($s->addFill(0x00, 0x00, 0x00));
|
|
$s->movePenTo(-1, -1);
|
|
$s->drawLine(2, 0);
|
|
$s->drawLine(0, 2);
|
|
$s->drawLine(-2, 0);
|
|
$s->drawLine(0, -2);
|
|
|
|
/* conteneur sprite, pour la modification de la boite */
|
|
|
|
$box = new SWFSprite();
|
|
$box->add(new SWFAction("
|
|
stop();
|
|
"));
|
|
$i = $box->add($r);
|
|
|
|
for ($n=0; $n<=20; ++$n) {
|
|
$i->setRatio($n/20);
|
|
$box->nextFrame();
|
|
}
|
|
|
|
/* Ce conteneur de sprite nous permet d'utiliser la même action plusieurs fois */
|
|
|
|
$cell = new SWFSprite();
|
|
$i = $cell->add($box);
|
|
$i->setName('box');
|
|
|
|
$cell->add(new SWFAction("
|
|
|
|
setTarget('box');
|
|
|
|
/* ...x signifie la coordonnée en x du parent, i.e. (..).x */
|
|
dx = (/mouse.x + random(6)-3 - ...x)/5;
|
|
dy = (/mouse.y + random(6)-3 - ...y)/5;
|
|
gotoFrame(int(dx*dx + dy*dy));
|
|
|
|
"));
|
|
|
|
$cell->nextFrame();
|
|
$cell->add(new SWFAction("
|
|
|
|
gotoFrame(0);
|
|
play();
|
|
|
|
"));
|
|
|
|
$cell->nextFrame();
|
|
|
|
/* et pour finir, ajoutons quelques cellules à notre vidéo */
|
|
|
|
for ($x=0; $x<12; ++$x) {
|
|
for ($y=0; $y<8; ++$y) {
|
|
$i = $m->add($cell);
|
|
$i->moveTo(100*$x+50, 100*$y+50);
|
|
}
|
|
}
|
|
|
|
$m->nextFrame();
|
|
|
|
$m->add(new SWFAction("
|
|
|
|
gotoFrame(1);
|
|
play();
|
|
|
|
"));
|
|
|
|
header('Content-type: application/x-shockwave-flash');
|
|
$m->output();
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Idem que l'exemple ci-dessus, mais avec de beaux ballons colorés...
|
|
<example>
|
|
<title>Exemple avec <function>swfaction</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$m = new SWFMovie();
|
|
$m->setDimension(11000, 8000);
|
|
$m->setBackground(0x00, 0x00, 0x00);
|
|
|
|
$m->add(new SWFAction("
|
|
|
|
this.quality = 0;
|
|
/frames.visible = 0;
|
|
startDrag('/mouse', 1);
|
|
|
|
"));
|
|
|
|
// la souris suit le sprite
|
|
$t = new SWFSprite();
|
|
$i = $m->add($t);
|
|
$i->setName('mouse');
|
|
|
|
$g = new SWFGradient();
|
|
$g->addEntry(0, 0xff, 0xff, 0xff, 0xff);
|
|
$g->addEntry(0.1, 0xff, 0xff, 0xff, 0xff);
|
|
$g->addEntry(0.5, 0xff, 0xff, 0xff, 0x5f);
|
|
$g->addEntry(1.0, 0xff, 0xff, 0xff, 0);
|
|
|
|
// une forme en gradient
|
|
$s = new SWFShape();
|
|
$f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT);
|
|
$f->scaleTo(0.03);
|
|
$s->setRightFill($f);
|
|
$s->movePenTo(-600, -600);
|
|
$s->drawLine(1200, 0);
|
|
$s->drawLine(0, 1200);
|
|
$s->drawLine(-1200, 0);
|
|
$s->drawLine(0, -1200);
|
|
|
|
// nous devons en faire un sprite, afin de pouvoir le colorer
|
|
$p = new SWFSprite();
|
|
$p->add($s);
|
|
$p->nextFrame();
|
|
|
|
// on y ajoute la forme, chaque frame avec une couleur différente
|
|
$q = new SWFSprite();
|
|
$q->add(new SWFAction("gotoFrame(random(7)+1); stop();"));
|
|
$i = $q->add($p);
|
|
|
|
$i->multColor(1.0, 1.0, 1.0);
|
|
$q->nextFrame();
|
|
$i->multColor(1.0, 0.5, 0.5);
|
|
$q->nextFrame();
|
|
$i->multColor(1.0, 0.75, 0.5);
|
|
$q->nextFrame();
|
|
$i->multColor(1.0, 1.0, 0.5);
|
|
$q->nextFrame();
|
|
$i->multColor(0.5, 1.0, 0.5);
|
|
$q->nextFrame();
|
|
$i->multColor(0.5, 0.5, 1.0);
|
|
$q->nextFrame();
|
|
$i->multColor(1.0, 0.5, 1.0);
|
|
$q->nextFrame();
|
|
|
|
// et pour finir, celui-ci contient le code action
|
|
$p = new SWFSprite();
|
|
$i = $p->add($q);
|
|
$i->setName('frames');
|
|
$p->add(new SWFAction("
|
|
|
|
dx = (/:mousex-/:lastx)/3 + random(10)-5;
|
|
dy = (/:mousey-/:lasty)/3;
|
|
x = /:mousex;
|
|
y = /:mousey;
|
|
alpha = 100;
|
|
|
|
"));
|
|
$p->nextFrame();
|
|
|
|
$p->add(new SWFAction("
|
|
|
|
this.x = x;
|
|
this.y = y;
|
|
this.alpha = alpha;
|
|
x += dx;
|
|
y += dy;
|
|
dy += 3;
|
|
alpha -= 8;
|
|
|
|
"));
|
|
$p->nextFrame();
|
|
|
|
$p->add(new SWFAction("prevFrame(); play();"));
|
|
$p->nextFrame();
|
|
|
|
$i = $m->add($p);
|
|
$i->setName('frames');
|
|
$m->nextFrame();
|
|
|
|
$m->add(new SWFAction("
|
|
|
|
lastx = mousex;
|
|
lasty = mousey;
|
|
mousex = /mouse.x;
|
|
mousey = /mouse.y;
|
|
|
|
++num;
|
|
|
|
if (num == 11)
|
|
num = 1;
|
|
|
|
removeClip('char' & num);
|
|
duplicateClip(/frames, 'char' & num, num);
|
|
|
|
"));
|
|
|
|
$m->nextFrame();
|
|
$m->add(new SWFAction("prevFrame(); play();"));
|
|
|
|
header('Content-type: application/x-shockwave-flash');
|
|
$m->output();
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</section>
|
|
|
|
<section xml:id="ming.examples.swfsprite-basic">
|
|
<title>Exemple avec SWFSPrite</title>
|
|
<para>
|
|
Cet exemple va faire tourner un gros carré rouge.
|
|
<example>
|
|
<title>Exemple avec <function>swfsprite</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?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();
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</section>
|
|
|
|
</chapter>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|