SWFbutton->setUp
<<<
SWFbutton SWFDisplayItem::addAction
>>>

6.21 Ming pour Flash
6 Référence des fonctions
 Manuel PHP

Introduction
Pré-requis
Installation
Configuration à l'exécution
Types de ressources
Constantes pré-définies
Classes pré-définies
ming_keypress
ming_setcubicthreshold
ming_setscale
ming_useConstants
ming_useswfversion
SWFAction
SWFBitmap->getHeight
SWFBitmap->getWidth
SWFBitmap
SWFbutton->addAction
SWFButton::addASound
SWFbutton->addShape
SWFbutton->setAction
SWFbutton->setdown
SWFbutton->setHit
SWFButton::setMenu
SWFbutton->setOver
SWFbutton->setUp
->SWFbutton
SWFDisplayItem::addAction
SWFDisplayItem->addColor
SWFDisplayItem::endMask
SWFDisplayItem::getRot
SWFDisplayItem::getX
SWFDisplayItem::getXScale
SWFDisplayItem::getXSkew
SWFDisplayItem::getY
SWFDisplayItem::getYScale
SWFDisplayItem::getYSkew
SWFDisplayItem->move
SWFDisplayItem->moveTo
SWFDisplayItem->multColor
SWFDisplayItem->remove
SWFDisplayItem->Rotate
SWFDisplayItem->rotateTo
SWFDisplayItem->scale
SWFDisplayItem->scaleTo
SWFDisplayItem->setDepth
SWFDisplayItem::setMaskLevel
SWFDisplayItem::setMatrix
SWFDisplayItem->setName
SWFDisplayItem->setRatio
SWFDisplayItem->skewX
SWFDisplayItem->skewXTo
SWFDisplayItem->skewY
SWFDisplayItem->skewYTo
SWFFill->moveTo
SWFFill->rotateTo
SWFFill->scaleTo
SWFFill->skewXTo
SWFFill->skewYTo
SWFFill
SWFFont::getAscent
SWFFont::getDescent
SWFFont::getLeading
SWFFont::getShape
SWFFont::getUTF8Width
swffont->getwidth
SWFFont
SWFFontChar::addChars
SWFFontChar::addUTF8Chars
SWFGradient->addEntry
SWFGradient
SWFMorph->getshape1
SWFMorph->getshape2
SWFMorph
SWFMovie->add
SWFMovie::addExport
SWFMovie::addFont
SWFMovie::importChar
SWFMovie::importFont
SWFMovie::labelFrame
SWFMovie->nextframe
SWFMovie->output
swfmovie->remove
SWFMovie->save
SWFMovie::saveToFile
SWFMovie->setbackground
SWFMovie->setdimension
SWFMovie->setframes
SWFMovie->setrate
SWFMovie::startSound
SWFMovie::stopSound
SWFMovie->streammp3
SWFMovie::writeExports
SWFMovie
SWFPrebuiltClip
SWFShape->addFill
SWFShape::drawArc
SWFShape::drawCircle
SWFShape::drawCubic
SWFShape::drawCubicTo
SWFShape->drawCurve
SWFShape->drawCurveTo
SWFShape::drawGlyph
SWFShape->drawLine
SWFShape->drawLineTo
SWFShape->movePen
SWFShape->movePenTo
SWFShape->setLeftFill
SWFShape->setLine
SWFShape->setRightFill
SWFShape
SWFSound
SWFSoundInstance::loopCount
SWFSoundInstance::loopInPoint
SWFSoundInstance::loopOutPoint
SWFSoundInstance::noMultiple
swfsprite->add
SWFSprite::labelFrame
SWFSprite->nextframe
SWFSprite->remove
SWFSprite->setframes
SWFSprite::startSound
SWFSprite::stopSound
SWFSprite
SWFText->addString
SWFText::addUTF8String
SWFText::getAscent
SWFText::getDescent
SWFText::getLeading
SWFText::getUTF8Width
SWFText->getWidth
SWFText->moveTo
SWFText->setColor
SWFText->setFont
SWFText->setHeight
SWFText->setSpacing
SWFText
SWFTextField::addChars
SWFTextField->addstring
SWFTextField->align
SWFTextField->setbounds
SWFTextField->setcolor
SWFTextField->setFont
SWFTextField->setHeight
SWFTextField->setindentation
SWFTextField->setLeftMargin
SWFTextField->setLineSpacing
SWFTextField->setMargins
SWFTextField->setname
SWFTextField::setPadding
SWFTextField->setrightMargin
SWFTextField
SWFVideoStream::getNumFrames
SWFVideoStream::setDimension
SWFVideoStream

6.21.26 SWFbutton()Crée un nouveau bouton

[ Exemples avec swfbutton ]   PHP 4 >= 4.0.5

SWFButton  swfbutton ( void )
Attention

Cette fonction est EXPERIMENTALE . Cela signifie que le comportement de cette fonction, son nom et concrètement, TOUT ce qui est documenté ici peut changer dans un futur proche, SANS PREAVIS! Soyez-en conscient, et utilisez cette fonction à vos risques et périls.

SWFbutton crée un nouveau bouton. Cliquez-le, passez la souris dessus, et appelez des actions. Facile !

SWFButton a les méthodes suivantes : SWFbutton->addShape , SWFbutton->setUp , swfbutton->setover SWFbutton->setDown , swfbutton->sethit SWFbutton->setAction et SWFbutton->addAction .

Cet exemple simplissime vous montre comme faire un roll-over, un roll-on, un clic, un relaché de souris, et rien du tout (pas d'action).
Exemple avec SWFbutton

<?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();
?>

Cet exemple simple illustre le déplacement d'un gros bouton rouge dans la fenêtre. Ce n'est pas du tirer-déposer, mais juste du tirer.
Exemple avec SWFbutton->addAction

<?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);"),
    
SWFBUTTON_MOUSEDOWN);
// '0' signifie : ne pas verrouiller la souris
$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();
?>

<< SWFbutton >>
SWFbutton->setUp Ming pour Flash SWFDisplayItem::addAction