Lesson 12 - Make a Splash
Page with a re-directActions 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.
<html>
<body
color="#000000">
<?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("ParkAvenue_BT.fdb");
$myText1=new SWFText();
$myText1->setFont($myFont);
$myText1->setColor(10,10,10,10);
$myText1->setHeight(40);
$myText1->moveTo(-($myFont->getWidth(""))/3,0);
$myText1->addString("JerryScript");
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://jerryscript.hostrocket.com/php/ming/lessons', '_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");
?>
<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=560 HEIGHT=380>
<PARAM NAME=movie VALUE="lesson12.swf">
<EMBED src="lesson12.swf" WIDTH=560 HEIGHT=380 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 learn to use action scripting to animate.
<html>
<body bgcolor="#000000">
<?php
//Ming_useSWFVersion(4);
$myFont=new SWFFont("ParkAvenue_BT.fdb");
$myText1=new SWFText();
$myText1->setFont($myFont);
$myText1->setColor(10,10,10,10);
$myText1->setHeight(40);
$myText1->moveTo(-($myFont->getWidth("JerryScript"))/3,0);
$myText1->addString("JerryScript");
$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://jerryscript.hostrocket.com',
'_top');"));
$myMovie->nextFrame();
$myMovie->save("lesson12.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=560 HEIGHT=380>
<PARAM NAME=movie
VALUE="lesson12.swf">
<EMBED src="lesson12.swf" WIDTH=560 HEIGHT=380
TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</OBJECT>
</body>
</html>