Flash red moving Cube in PHP

Oct 19, 2009 Author: Developer

First of all you write the function Ming_useSWFVersion(4). This function sets the SWF version to be used in the movie. This affect the bahaviour of Action Script. Only versions 4 through 8 inclusive are supported at this time. SWFShape is an construct and creates a new shape object. 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. This is a simple SWF code made in php with ming library. When you write this code you will see red cube.

When you click on the red cube with a left click and move up, down, left or right you can see that the cube is moving in the same directions where the mouse is going.

If you want to see more PHP-Ming tutorials please look out How to Create a Flash Movie.

<?php  
Ming_useSWFVersion(4);  
$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 = new SWFButton();  
$b->addShape($s, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER);  
$b->addAction(new SWFAction("startDrag('/test', 0);"),		
SWFBUTTON_MOUSEDOWN);  
$b->addAction(new SWFAction("stopDrag();"),		
SWFBUTTON_MOUSEUP | SWFBUTTON_MOUSEUPOUTSIDE);  
$p = new SWFSprite();  
$p->add($b);  
$p->nextFrame();  
$m = new SWFMovie();  
$m->setDimension(320, 240);  
$i = $m->add($p);  
$i->setName('test');  
$i->moveTo(160,120);  
header('Content-type: application/x-shockwave-flash');  
$m->output();
?>
This is very simple example of PHP-Ming and if you have any questions, please feel free to leave a comment on the tutorial.

tags: Red moving cube

views 4011
  1. Add New Comment