Приглашаем посетить
Мандельштам (mandelshtam.lit-info.ru)

13.3 Shockwave/Flash

Previous Table of Contents Next

13.3 Shockwave/Flash

You can also create full-featured SWF-format Flash movies with the Ming extension. Example 13-3 produces a movie with a blue circle in it that you can drag around.

Example 13-3. Generating a Flash movie
// Use SWF Version 6 to enable Actionscript

ming_UseSwfVersion(6);



// Create a new movie and set some parameters

$movie = new SWFMovie( );

$movie->setRate(20.000000);

$movie->setDimension(550, 400);

$movie->setBackground(0xcc,0xcc,0xcc);



// Create the circle

$circle = new SWFShape( );

$circle->setRightFill(33,66,99);

$circle->drawCircle(40);

$sprite= new SWFSprite( );

$sprite->add($circle);

$sprite->nextFrame( );



// Add the circle to the movie

$displayitem = $movie->add($sprite);

$displayitem->setName('circle');

$displayitem->moveTo(100,100);



// Add the Actionscript that implements the dragging

$movie->add(new SWFAction("

 circle.onPress=function( ){ this.startDrag('');};

 circle.onRelease= circle.onReleaseOutside=function( ){ stopDrag( );};

"));



// Display the movie

header("Content-type: application/x-shockwave-flash");

$movie->output(1);

Save Example 13-3 as ming.php and then reference it from another page as in Example 13-4.

Example 13-4. Including the Flash movie in a web page
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"

 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.

cab#version=6,0,0,0"

 WIDTH="300" HEIGHT="300">

 <PARAM NAME=movie VALUE="ming.php">

 <PARAM NAME=bgcolor VALUE="#ffffff"> 

 <EMBED src="ming.php" bgcolor="#ffffff" WIDTH="300" HEIGHT="300"

 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/

getflashplayer"></EMBED>

</OBJECT>

Read about the Ming functions in the PHP Manual at http://www.php.net/ming. The Ming extension depends on the external Ming library, which you can download from http://ming.sourceforge.net. The site at http://ming.sourceforge.net also contains lots of documentation and examples of how to use Ming from PHP. (Example 13-3 is adapted from one of the examples on that site.)

    Previous Table of Contents Next