<HTML ><HEAD ><TITLE >SWFbutton</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Ming functions for Flash" HREF="ref.ming.html"><LINK REL="PREVIOUS" TITLE="SWFbutton->setUp" HREF="function.swfbutton.setup.html"><LINK REL="NEXT" TITLE="SWFDisplayItem->addColor" HREF="function.swfdisplayitem.addcolor.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.swfbutton.setup.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.swfdisplayitem.addcolor.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.swfbutton" ></A >SWFbutton</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN53203" ></A ><P > (PHP 4 >= 4.0.5)</P >SWFbutton -- Creates a new Button.</DIV ><DIV CLASS="refsect1" ><A NAME="AEN53206" ></A ><H2 >Description</H2 >new <B CLASS="methodname" >swfbutton</B > ( void)<BR ></BR ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Warning</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P >This function is <SPAN CLASS="emphasis" ><I CLASS="emphasis" >EXPERIMENTAL</I ></SPAN >. The behaviour of this function, the name of this function, and anything else documented about this function may change without notice in a future release of PHP. Use this function at your own risk.</P ></TD ></TR ></TABLE ></DIV ><P > <B CLASS="function" >swfbutton()</B > creates a new Button. Roll over it, click it, see it call action code. Swank. </P ><P > SWFButton has the following methods : <B CLASS="function" >swfbutton->addshape()</B >, <B CLASS="function" >swfbutton->setup()</B >, <B CLASS="function" >swfbutton->setover()</B > <B CLASS="function" >swfbutton->setdown()</B >, <B CLASS="function" >swfbutton->sethit()</B > <B CLASS="function" >swfbutton->setaction()</B > and <B CLASS="function" >swfbutton->addaction()</B >. </P ><P > This simple example will show your usual interactions with buttons : rollover, rollon, mouseup, mousedown, noaction. <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN53226" ></A ><P ><B >Example 1. <B CLASS="function" >swfbutton()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?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(); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > This simple example will enables you to drag draw a big red button on the windows. No drag-and-drop, just moving around. <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN53231" ></A ><P ><B >Example 2. <B CLASS="function" >swfbutton->addaction()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?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(); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.swfbutton.setup.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.swfdisplayitem.addcolor.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >SWFbutton->setUp</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.ming.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >SWFDisplayItem->addColor</TD ></TR ></TABLE ></DIV ></BODY ></HTML >