Notes to Lesson 1

Jerry's codes work just fine as he has outlined them, however, I like to separate the html from the php code and create 2 separate files: One php file for the Ming movie that creates the swf file, and one html file for displaying the swf created by the Ming movie, on an html page.

There is another line of code which allows you to view your movie without creating an swf file. This is useful especially for long Ming scripts that build a complete movie. Lastly, there is another line of code which can be placed on the html page which allows you to change the background color of your swf.

First look at the php code and put it alone in a file.

<?php
$myMovie=new SWFMovie();
$myMovie->setDimension(460,80);
$myMovie->setBackground(255,0,0);
$myMovie->save("lesson1.swf");
?>

The following lines of code can be placed just before the last line which saves and names the swf.

header('Content-type: application/x-shockwave-flash');
$myMovie->output();

That last line of code should be commented out using 2 backslashes. The line can be uncommented when you are ready to create the actual swf.

The php page should now look like this:

<?php
$myMovie=new SWFMovie();
$myMovie->setDimension(460,80);
$myMovie->setBackground(255,0,0);
header('Content-type: application/x-shockwave-flash');
$myMovie->output();
//$myMovie->save("lesson1.swf");
?>

Now you can view your movie prior to creating the swf file. If you are just beginning to learn Ming, it is best to follow Jerry's instructions through the list of tutorials as written. Later, you can experiment with using separate files for php and html codes. One thing you will notice is that the size of the swf when viewed without the html code will expand to fill the screen, and it is hard to tell where the background leaves off and the movie begins. This can be worked around by uploading an image for the background and drawing the movie onto the background image. It will still expand to a larger size, but you will be able to see where the background ends and the movie begins. I will add notes on how to do that when we get to that section of the tutorials.

Next, look at the html code, and put it alone in a file.

<html>
<body>
<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="lesson1.swf">
<EMBED src="lesson1.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>

Looking at the codes, you can see that there are 2 places to insert the name of the swf file, and 2 places to insert the width and height of the swf. These should match the swf name used in the php file, as well as the SetDimension (width, height) of the movie. All other codes within the Object tags remain the same for each and every swf file. The only things that change are the swf name, width and height.

Under the line that starts with "<PARAM NAME=", you can place the following line of code, which allows you to change the background color of the swf movie.

<PARAM NAME="BGCOLOR' value="#0000ff">

Also add a line at the very end of the line that starts with <EMBED src="lesson1.swf" that declares the background color:

bgcolor="#0000ff"

The color can be one of your own choosing. This comes in handy when you have a small swf already created which you want to display in the middle of your html page, but decided the background color would not look well on that page. Otherwise, the color codes can be left out completely, as they are optional, and the swf will display in the color that it is. The complete html code would now look like:

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

Here is an example of a small swf Poodle with background codes used to change the swf background. The first Poodle is on a black background (which is the swf color) and no color codes were added to the html script. The middle poodle is the same swf but with the bgcolor code added to the html page, which had a bgcolor value of #ffffff, or white. The third poodle was changed to yellow.