Ming php - maken van 2 draggable buttons met for loop - SOLVED
Bjorn Chin Fo Sieeuw
02/03/2016 16:13:11Ik dacht een draggable button in een loop te zetten, zodat je ze allebei kan draggen. Maar je kunt alleen 1 ervan draggen met de volgende code:
Hoe kan ik beide shapes onafhankelijk van elkaar laten draggen? Oplossing:
je kunt in de name van startDrag escapen: '/test' + ".$n."
Code (php)
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
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
<?
Ming_useSWFVersion(4);
$m = new SWFMovie();
$m->setDimension(320, 240);
$s = new SWFShape();
$s->setRightFill($s->addFill(0xff, 0, 0));
$s->movePenTo(-25, -25);
$s->drawLine(50, 0);
$s->drawLine(0, 50);
$s->drawLine(-50, 0);
$s->drawLine(0, -50);
$b = array();
for($bn = 0; $bn < 2; $bn++){
$b[$bn] = new SWFButton();
$b[$bn]->addShape($s, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER);
$b[$bn]->addAction(new SWFAction("startDrag('/test', 0);"),
SWFBUTTON_MOUSEDOWN);
$b[$bn]->addAction(new SWFAction("stopDrag();"),
SWFBUTTON_MOUSEUP | SWFBUTTON_MOUSEUPOUTSIDE);
$p[$bn] = new SWFSprite();
$p[$bn]->add($b[$bn]);
$p[$bn]->nextFrame();
$i[$bn] = $m->add($p[$bn]);
$i[$bn]->setName('test');
$i[$bn]->moveTo(160,120);
}
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
Ming_useSWFVersion(4);
$m = new SWFMovie();
$m->setDimension(320, 240);
$s = new SWFShape();
$s->setRightFill($s->addFill(0xff, 0, 0));
$s->movePenTo(-25, -25);
$s->drawLine(50, 0);
$s->drawLine(0, 50);
$s->drawLine(-50, 0);
$s->drawLine(0, -50);
$b = array();
for($bn = 0; $bn < 2; $bn++){
$b[$bn] = new SWFButton();
$b[$bn]->addShape($s, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER);
$b[$bn]->addAction(new SWFAction("startDrag('/test', 0);"),
SWFBUTTON_MOUSEDOWN);
$b[$bn]->addAction(new SWFAction("stopDrag();"),
SWFBUTTON_MOUSEUP | SWFBUTTON_MOUSEUPOUTSIDE);
$p[$bn] = new SWFSprite();
$p[$bn]->add($b[$bn]);
$p[$bn]->nextFrame();
$i[$bn] = $m->add($p[$bn]);
$i[$bn]->setName('test');
$i[$bn]->moveTo(160,120);
}
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
Hoe kan ik beide shapes onafhankelijk van elkaar laten draggen? Oplossing:
je kunt in de name van startDrag escapen: '/test' + ".$n."
Gewijzigd op 03/03/2016 00:00:07 door Bjorn Chin Fo Sieeuw
Er zijn nog geen reacties op dit bericht.