Lesson 3 - Coding some
shapesA) Begin as always by opening our html page and begining our php code block.
<html>
<body>
<?php
B) Here is our line shape from before.
$myShape1=new SWFShape();
$myShape1->setLine(5,0,0,255);
$myShape1->drawLine(440,0);
C) Next we must define our new shape and set it's
line attributes.
$myShape2=new SWFShape();
$myShape2->setLine(1,0,0,0);
D) Next we set the color to fill our
shape with, we will cover gradient and complex fills in a future lesson, for now
we just set the color. If you draw your shapes clockwise, use setRightFill, if
you draw your shapes counter-clockwise, use setLeftFill.
$myShape2->setRightFill(0,255,0);
E) Next, we draw the lines that make up our shape.
In this case, the four sides of our square.
$myShape2->drawLine(50,0);
$myShape2->drawLine(0,50);
$myShape2->drawLine(-50,0);
$myShape2->drawLine(0,-50);
F) Now we define our movie as before.
$myMovie=new SWFMovie();
$myMovie->setDimension(460,80);
$myMovie->setBackground(255,0,0);
G) Next we add
our previous line shapes.
$firstLine=$myMovie->add($myShape1);
$firstLine->moveTo(10,10);
$secondLine=$myMovie->add($myShape1);
$secondLine->moveTo(10,70);
H) And now we add our new instances of our square
shape, moving one to the left side and one to the right.
$firstSquare=$myMovie->add($myShape2);
$firstSquare->moveTo(15,15);
$secondSquare=$myMovie->add($myShape2);
$secondSquare->moveTo(395,15);
I) And finally, save the movie, close off our php
code block, and finish our html as usual.
$myMovie->save("lesson3.swf");
?>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0"
ID=objects WIDTH=460 HEIGHT=80>
<PARAM NAME=movie
VALUE="lesson3.swf">
<EMBED src="lesson3.swf" WIDTH=460 HEIGHT=80
TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</OBJECT>
</body>
</html>
Next lesson, we will add more complex shapes such as polygons, arcs, and circles.
<html>
<body>
<?php
$myShape1=new SWFShape();
$myShape1->setLine(5,0,0,255);
$myShape1->drawLine(440,0);
$myShape2=new SWFShape();
$myShape2->setLine(1,0,0,0);
$myShape2->setRightFill(0,255,0);
$myShape2->drawLine(50,0);
$myShape2->drawLine(0,50);
$myShape2->drawLine(-50,0);
$myShape2->drawLine(0,-50);
$myMovie=new SWFMovie();
$myMovie->setDimension(460,80);
$myMovie->setBackground(255,0,0);
$firstLine=$myMovie->add($myShape1);
$firstLine->moveTo(10,10);
$secondLine=$myMovie->add($myShape1);
$secondLine->moveTo(10,70);
$firstSquare=$myMovie->add($myShape2);
$firstSquare->moveTo(15,15);
$secondSquare=$myMovie->add($myShape2);
$secondSquare->moveTo(395,15);
$myMovie->save("lesson3.swf");
?>
<OBJECT
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0"
ID=objects WIDTH=460 HEIGHT=80>
<PARAM NAME=movie
VALUE="lesson3.swf">
<EMBED src="lesson3.swf" WIDTH=460 HEIGHT=80
TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</OBJECT>
</body>
</html>