| Ultrashock Tutorials > Flash5 > Creating HTML Sites from Flash Data Files | ||||
|
||||
| Creating HTML Sites from Flash Data Files | ||||
|
Today everybody has or wants a Flash site. Flash
has very cool features and capabilities but we have to acknowledge the
downside to creating a Flash only website. Users who do not have the Flash
plug-in such as Lynx (Linux shell browser) users or people who didn't
care to upgrade the plug-in cannot view the content on a site unless it
has a non-Flash HTML version along side the crazy cool Flash version.
Even if you have the plug-in, you might not want to wait for the entire
Flash site to load every time you visit the site. Your reason could be
that you need information fast or you have a slow Internet connection.
Lets face it, even today everyone does not have broadband. And in the
evenings cable modems are slow as well. So we should have HTML versions
of our Flash site. This is obviously useless if the site is promoting
Flash content. Well, the easy way to do this is to build an HTML
site. But then each time you update content you would need to modify the
Flash movies and the HTML pages. While this is manageable for a small
site, a decently sized site will be pain to update on a regular basis.
If you do not have the knowledge or the inclination to work with databases
you can still have a system by which both sites are updated simultaneously.
This is what I will show you in this tutorial using Flash with CGI/Perl
using templates. This is how it works Theres nuthing new being invented here. Most people who have programmed in CGI/Perl will recognize the code. Its just applying that code to Flash sites to help making the maintenance of the two versions (Flash and HTML) easier. There are 3 pre-requisites to this tutorial. You must be able to run/execute CGI scripts on your website, should be familiar with the Perl programming language (like using sub methods and being able to follow and modify code) and will be using the content of your Flash text files for your HTML site. What we will basically do is create a CGI script - "html.cgi", that parses the data in the text file and by the use of templates allow us to create an HTML site by small modifications to the "html.cgi" script. Since the data is pulled from the same text file that Flash reads both versions, the Flash and HTML ones, are updated simultaneously. To view a working demo version click the below links to access the specific files.
Parsing the Flash data
file e.g.. variable1=text&variable2=2ndtext&variable3=some+more+text As we can see each pair of variable/value is separated by "&", and in turn in the variable pair the variable and it's value is separated by an "=". Knowing this we can write a function/method (parseFile) in Perl that opens a specified file ($DATA_FILE), the data file; reads its contents and separates the pairs; and then separates each pair of variable/value and assigns them to an array (@Flash) from which a variables value can accessed if we know the variable name ($Flash{name}). This is what my sub method looks like.
sub parseFile {
## Define variables used to replace the newline in the flash data file,
# Set the substitution expressions
$substitute_expression_pagetitle = "< !-- INSERT PAGE TITLE HERE //-- >";
$substitute_expression_descript = "< !-- INSERT DESCRIPT HERE //-- >;";
# Get the template file using the getFile method
$templatefile_data = &getFile($template);
# substitute page title
$templatefile_data=~s/$substitute_expression_pagetitle/$Flash{'pagetitle'}/g;
# substitute description
$templatefile_data=~s/$substitute_expression_descript/$Flash{'descript'}/g;
# set HTTP text header and print content
&setHeader;
print "$templatefile_data";
Conclusion Well this is a start. Use the method I have shown you and build on it to create more sophisticated HTML versions to complement your Flash websites. This caan be used to create WAP / PDA friendly versions of your websites as well. Play with it and see what you come up with. |
||||
|
©2001 Ultrashock.com Inc.
- All rights reserved
|