Re-Direct

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.

<html>
<body bgColor="#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 using Trebuchet_MS font (or shapes if you like) to our movie as always

$myFont=new SWFFont("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.LingoLinda.com/ming/Lessons/MingLessons.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");
?>

<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="lesson12.swf">
<EMBED src="lesson12.swf" WIDTH=460 HEIGHT=80 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</EMBED>
</OBJECT>
</BODY>
</html>

Next lesson, we will learn to use action scripting to animate.

Code summary for lesson 12:

Result:

Click for WebWizard Ways!