Lesson 12
Now that you know how to make a button that your visitors can click like a link, let's learn how to make a splash page that will act as a redirect. Actions can be added to frames of your movie much like they can be added to buttons. Let's create an animation using what we have learned to date, and on the final frame of the movie, let's add a redirect to a URL. A) Begin as always by starting your HTML page and opening the php code block, I set the page's background to black to make the movie appear as the page itself. <?php B) Next, since we are using action scripting, we must set our version to Flash4 for WebTv users Ming_useSWFVersion(4); C) Next, we add text (or shapes if you like) to our movie as always $myFont=new SWFFont("../ming-fonts/Trebuchet_MS.fdb"); $myText1=new SWFText(); $myText1->setFont($myFont); $myText1->setColor(10,10,10,10); $myText1->setHeight(40); $myText1->moveTo(-($myFont->getWidth("WebWizardsWays"))/3,0); $myText1->addString("WebWizardsWays"); D) Now we define our movie and set it's attributes as usual $myMovie = new SWFMovie(); $myMovie->setDimension(560,380); $myMovie->setBackground(0,0,0); $myMovie->setRate(30); E) Next, we add an instance of our text (or shape) to our movie, moving it into position and manipulating it as we desire $firstText=$myMovie->add($myText1); $firstText->moveTo(260,200); $firstText->scaleTo(0.1,0.1); F) Next, we create our animation or other "splash" effect as desired for($i=0; $i<60; $i++){ $myMovie->nextFrame(); $firstText->rotate(-6); $firstText->multColor($i/3,$i/3,$i/3,$i/3); $firstText->scaleTo($i/60,$i/60); } for($i=0; $i<15; $i++){ $myMovie->nextFrame(); } for($i=0; $i<20; $i++){ $myMovie->nextFrame(); $firstText->move(-2,0); $firstText->rotate(1); } for($i=0; $i<40; $i++){ $myMovie->nextFrame(); $firstText->move(2*$i,0); if($i<10){$firstText->rotate(-2);} } G) Now, we create our redirect using action scripting added to the next movie frame $myMovie->add(new SWFAction("getURL('http://www.webwizardsways.com/index.html', '_top');")); $myMovie->nextFrame(); H) Finally, we save our movie, close our php code block, and add our object coding as usual, before closing our html document $myMovie->save("lesson12.swf"); ?>
Next lesson, we will learn to use action scripting to animate. Code summary for lesson 12: <?php Ming_useSWFVersion(4); $myFont=new SWFFont("../ming-fonts/Trebuchet_MS.fdb"); $myText1=new SWFText(); $myText1->setFont($myFont); $myText1->setColor(10,10,10,10); $myText1->setHeight(40); $myText1->moveTo(-($myFont->getWidth("WebWizardsWays"))/3,0); $myText1->addString("WebWizardsWays"); $myMovie = new SWFMovie(); $myMovie->setDimension(560,380); $myMovie->setBackground(0,0,0); $myMovie->setRate(30); $firstText=$myMovie->add($myText1); $firstText->moveTo(260,200); $firstText->scaleTo(0.1,0.1); for($i=0; $i<60; $i++){ $myMovie->nextFrame(); $firstText->rotate(-6); $firstText->multColor($i/3,$i/3,$i/3,$i/3); $firstText->scaleTo($i/60,$i/60); } for($i=0; $i<15; $i++){ $myMovie->nextFrame(); } for($i=0; $i<20; $i++){ $myMovie->nextFrame(); $firstText->move(-2,0); $firstText->rotate(1); } for($i=0; $i<40; $i++){ $myMovie->nextFrame(); $firstText->move(2*$i,0); if($i<10){$firstText->rotate(-2);} } $myMovie->add(new SWFAction("getURL('http://www.webwizardsways.com/index.html', '_top');")); $myMovie->nextFrame(); $myMovie->save("lesson12.swf"); ?>
Click
Here
to view example 12.
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