php-doc-en/reference/ming/swfbutton/construct.xml
Torben Wilson af4410a7e1 Normalized the sgml-default-dtd-file local-variable line for those
still using this, after discussion on the phpdoc list.
From now on, manual.ced will need to be found at ~/.phpdoc/manual.ced.



git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@288721 c90b9560-bf6c-de11-be94-00142212c4b1
2009-09-25 07:04:39 +00:00

187 lines
4.2 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<refentry xml:id="function.swfbutton.construct" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>SWFButton->__construct</refname>
<refpurpose>Creates a new Button</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<classsynopsis>
<ooclass><classname>SWFButton</classname></ooclass>
<methodsynopsis>
<type>SWFButton</type><methodname>__construct</methodname>
<void/>
</methodsynopsis>
</classsynopsis>
&warn.experimental.func;
<para>
Creates a new Button.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
This simple example will show your usual interactions with buttons :
rollover, rollon, mouseup, mousedown, noaction.
<example>
<title>Usual interactions with buttons</title>
<programlisting role="php">
<![CDATA[
<?php
$f = new SWFFont("_serif");
$p = new SWFSprite();
function label($string)
{
global $f;
$t = new SWFTextField();
$t->setFont($f);
$t->addString($string);
$t->setHeight(200);
$t->setBounds(3200, 200);
return $t;
}
function addLabel($string)
{
global $p;
$i = $p->add(label($string));
$p->nextFrame();
$p->remove($i);
}
$p->add(new SWFAction("stop();"));
addLabel("NO ACTION");
addLabel("SWFBUTTON_MOUSEUP");
addLabel("SWFBUTTON_MOUSEDOWN");
addLabel("SWFBUTTON_MOUSEOVER");
addLabel("SWFBUTTON_MOUSEOUT");
addLabel("SWFBUTTON_MOUSEUPOUTSIDE");
addLabel("SWFBUTTON_DRAGOVER");
addLabel("SWFBUTTON_DRAGOUT");
function rect($r, $g, $b)
{
$s = new SWFShape();
$s->setRightFill($s->addFill($r, $g, $b));
$s->drawLine(600, 0);
$s->drawLine(0, 600);
$s->drawLine(-600, 0);
$s->drawLine(0, -600);
return $s;
}
$b = new SWFButton();
$b->addShape(rect(0xff, 0, 0), SWFBUTTON_UP | SWFBUTTON_HIT);
$b->addShape(rect(0, 0xff, 0), SWFBUTTON_OVER);
$b->addShape(rect(0, 0, 0xff), SWFBUTTON_DOWN);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(1);"),
SWFBUTTON_MOUSEUP);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(2);"),
SWFBUTTON_MOUSEDOWN);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(3);"),
SWFBUTTON_MOUSEOVER);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(4);"),
SWFBUTTON_MOUSEOUT);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(5);"),
SWFBUTTON_MOUSEUPOUTSIDE);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(6);"),
SWFBUTTON_DRAGOVER);
$b->addAction(new SWFAction("setTarget('/label'); gotoFrame(7);"),
SWFBUTTON_DRAGOUT);
$m = new SWFMovie();
$m->setDimension(4000, 3000);
$i = $m->add($p);
$i->setName("label");
$i->moveTo(400, 1900);
$i = $m->add($b);
$i->moveTo(400, 900);
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
]]>
</programlisting>
</example>
</para>
<para>
This simple example will enables you to drag draw a big red button
on the windows. No drag-and-drop, just moving around.
<example>
<title>Drag example</title>
<programlisting role="php">
<![CDATA[
<?php
$s = new SWFShape();
$s->setRightFill($s->addFill(0xff, 0, 0));
$s->drawLine(1000,0);
$s->drawLine(0,1000);
$s->drawLine(-1000,0);
$s->drawLine(0,-1000);
$b = new SWFButton();
$b->addShape($s, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER);
$b->addAction(new SWFAction("startDrag('/test', 0);"), // '0' means don't lock to mouse
SWFBUTTON_MOUSEDOWN);
$b->addAction(new SWFAction("stopDrag();"),
SWFBUTTON_MOUSEUP | SWFBUTTON_MOUSEUPOUTSIDE);
$p = new SWFSprite();
$p->add($b);
$p->nextFrame();
$m = new SWFMovie();
$i = $m->add($p);
$i->setName('test');
$i->moveTo(1000,1000);
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<!-- 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:"~/.phpdoc/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
-->