Lesson 8c
Now that everyone is chomping at the bit to get things moving, let's take some time to explore various types of motion. Lesson 8 will be in 3 parts, each showing different motions and/or combinations of motions. Note-I refuse to take responsibility for any motion sickness! In this version of lesson 8, we will make a box shape move across our movie screen while increasing it's size. A) Begin as always by opening our html page and begining our php code block <?php B) Next, we define our shape and set it's line and fill attributes as usual $myShape1=new SWFShape(); $myShape1->setLine(5,0,0,255); $myShape1->setRightFill(255,255,0); C) When moving shapes, it is best to try to draw them with a centered starting point. Since this square is going to be 60x60, we will move the drawing pen -30,-30 to center it, then draw it's lines as usual $myShape1->movePen(-30,-30); $myShape1->drawLine(60,0); $myShape1->drawLine(0,60); $myShape1->drawLine(-60,0); $myShape1->drawLine(0,-60); D) Next, we define our movie and it's attributes as usual $myMovie=new SWFMovie(); $myMovie->setDimension(460,80); $myMovie->setBackground(255,0,0); E) Now we define our instance of the shape we will be moving, set it's scale to the begining size for our movie, and move it to the starting point of our animation $movingSquare=$myMovie->add($myShape1); $movingSquare->scale(0.5,0.5); $movingSquare->moveTo(40,40); F) Next, we move our movie forward one frame, as if going to the next frame of a gif animation or any movie film $myMovie->nextFrame(); G) Once we are on a new movie frame, we can scale our shape to any size, and then we can move our shape to it's new position $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); H) Repeat the previous two steps, rotating and moving your shape to it's next position and advancing the frames till you are done with your animation $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); I) Once we are done moving things around, we can save and output our movie to our html tags as usual $myMovie->save("lesson8-scale.swf"); ?>
Next lesson, we will learn to change the color and transparency of our movies contents! Code summary for lesson 8c: <?php $myShape1=new SWFShape(); $myShape1->setLine(5,0,0,255); $myShape1->setRightFill(255,255,0); $myShape1->movePen(-30,-30); $myShape1->drawLine(60,0); $myShape1->drawLine(0,60); $myShape1->drawLine(-60,0); $myShape1->drawLine(0,-60); $myMovie=new SWFMovie(); $myMovie->setDimension(460,80); $myMovie->setBackground(255,0,0); $movingSquare=$myMovie->add($myShape1); $movingSquare->scale(0.5,0.5); $movingSquare->moveTo(40,40); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->nextFrame(); $movingSquare->scale(1.1,1.1); $movingSquare->move(40,0); $myMovie->save("lesson8-scale.swf"); ?>
Click
Here
to view example 8c.
Select your next page.
[
1
] [
2
] [
3
] [
4
] [
5
] [
6
] [
7
] [
8a
] [
8b
] [
8c
] [
8d
] [
9
] [
10
] [
11
] [
12
] [
13
] [
14
] [
15
]
Return to Index