SWFButton::__construct

(PHP 5 <= 5.3.0, PECL ming SVN)
Creates a new Button
SWFButton::__construct ( void )

Creates a new Button.

This function is EXPERIMENTAL. The behaviour of this function, its name, and surrounding documentation may change without notice in a future release of PHP. This function should be used at your own risk.

Examples:
Usual interactions with buttons

This simple example will show your usual interactions with buttons : rollover, rollon, mouseup, mousedown, noaction.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?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();
?>
Drag example

This simple example will enables you to drag draw a big red button on the windows. No drag-and-drop, just moving around.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?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();
?>
doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.