|
$$::Flash
Creator:
Part 1
In this
tutorial you will learn how to create a PHP
Script that will enables users to create flash
movies from a their texts. the user will enter
any text and then choose one from multiple flash
movies and then the script will enter the text
into the selected flash movie, we will use PHP
and Swishmax..
Try Script Here
|
|
|
Overview
Our script
consists of two parts the first one depends on PHP the second depends on
Swishmax .
We will use PHP
to get the text entered by the user then typing this text in a text file.
then we will use Swishmax to create a flash movie contains a text But the
flash movie get that text from the text file created by PHP.
PART 1 (PHP Part):
We will start
from a point in which we have a flash contains animated text and this flash get
the text from a text file housing besides them (i.e. if we change the text in
the text file it will be changed in the flash )
Download this example from here And
we will learn in the part 2 how to create this types of flashes using PHP.
Now you have SWF
file named "tiger.swf" and a text file named "nametext.txt". The
SwF file displays a text "urlearn.com" and this text is typed in the text
file. Don't be worry if you don't understand the mechanism of working as we will
learn how to create this type of flash using Swishmax.
NOTE that
2files must be in the same folder.
Enter a text:
Create a new PHP
Page name it "enteratext.php"
write the
following code in the page.
<p> Please
Enter A text:</p>
<form action = "choose.php" method="post">
Enter Text :
<input name="name" type="text" value="">
<input type="submit" name="submit"
value="Proceed" /></p>
</form>
|
|
|
|
Choose:
Now we should
enable user to choose one from multiple movies. So
we will create "choose.php" Page which
contains multiple flash movies that user can choose
from.
We have one movie
"tiger.swf" So we will embed it in this page
until we we create multiple movies.
Put the following
code in the "choose.php".
<?
$text=$_POST['name'];
?>
<p>Please
Choose any one and then Press Continue </p>
<p><form method='post' action='createflash.php'>
<input type="radio" name="selected" value="tiger.swf"/>
<object width="278" height="147">
<param name="movie" value="tiger.swf">
<param name="quality" value="High">
<embed src="tiger.swf" name="obj1"
width="278" height="147">
</object>
</p>
</embed>
<br />
<input
type="hidden" name="text" value="<? echo
$text ?>"/>
<input type="submit" name="submit"
value="Continue"/>
</form>
NOTE
that we got the value of the text that entered
by user and saved this value in the $text
variable.
the radio
button will store the name of the flash So we
must put each radio button beside its flash and
change the radio value to the path of the flash
("tiger.swf" in this case).
we create a
hidden input to save the text that entered by
the user and which saved in the $text
variable.
When the user
choose his template and press "continue" button we
must copy the selected flash file with its text file
and put them in a new directory the we must replace
the text in the
"nametext.txt"
file by the text entered by the user in the "enteratext.php"
page and which we saved it in the hidden input.
Create Flash:
Create a new page
and name it "createflash.php"
Firstly: we will
need to retrieve 2 values;
the 1st is the name
of the template flash movie selected by the user.
the 2nd is the text
entered by the user.
to retrieve the
these values Write this code in the "createflash.php"
<?
$text=$_POST['text'];
$flash=$_POST['selected'];
?>
now we must
create a new directory to copy the flash
and its text file to it. but firstly we should
create a new folder which will contain all
directories that will be created So create a new
folder and name it "all".
And Also we
must determine a name for the new directory i
will use the time( ) function to generate
names for directories.
Add this chunk
to below the previous code of "createflash.php"
if
(isset($flash))
{
$dirname=time(
);
mkdir("all/".$dirname);
Now we will copy
the selected flash movie and the "nametext.txt"
file to the created dir.
$dirname=time();
$dir="all/".$dirname."/";
mkdir($dir);
copy($flash, $dir.$flash);
copy("nametext.txt", $dir."nametext.txt");
After that we must
change the text in the text file to the text entered
by the user. but Note that when we write the text we
must write "&name= " before it and "&"
at the end . (we will explain this)
$text="&name=".$text."&";
$fp=fopen($dir."nametext.txt", "w");
fwrite($fp, $text);
After that we should print the link of the
created flash to the user
echo "Congratultion..!!<br>This
is your flash:<br>";
echo "<a href='".$dir.$flash."'>"."click
here"."</a>";
}//the
end of if
|
|
|
The End
Dr Smith
urlearn@gmail.com
info@urlearn.com
|