Need suggesstions please
Hi everyone!
After taking a break from webmastering (although i did create web sites for others) I've decided to return once again. I have a Great host lined up (DarkFire's MechHosting) and am working on a domain though will prolly just use my old one although it won't really work...
What I am planning is a Flash Games site. I can't think of a good way to do it except making every page in html and thne embedding the lash game. This will take a lot of time, and i would still lack a way to link all the pages together save adding each page to every existing page by hand. I was wondering if any of you migh have a script suggesstion or any suggestion at this point. I was about to start today doing the every page by hand technique, but i realized that the whole site woldn't be done for months... (I can only type so fast)
Thanks,
Ambrose
Please visit WuLabsWuTecH Gaming and Ultimate Forumboards
Having Technical Difficulties? Want to throw your computer out the window? Is your network a net doesn't work? Visit TechTalk. We can help!!!
Thanks!!!
Roo posted this at 06:25 — 21st February 2005.
She has: 840 posts
Joined: Apr 1999
I use Swishmax, not Flash, but it lets you load movies one on top of another...I'm sure Flash itself must allow you to 'layer' .swf's the same way?
Roo
CptAwesome posted this at 09:15 — 21st February 2005.
He has: 370 posts
Joined: Dec 2004
Wow, that would take yeah, forever, and there is frighteningly easy solution. The following into a file named game.php will do the trick
<?
//Step 1: This is the list of games, each is seperated with a | and omit the .swf when listing them.
$listofgames = "game1filename|game2filename|game3filename";
$list = explode("|",$listofgames);
//Step 1 end
// Step 2: Check if the width and height are set, if not, set a default
if(is_numeric($_GET['w'])){
$width = $_GET['w'];
}else{
$width = 640; //default
}
if(is_numeric($_GET['h'])){
$height = $_GET['h'];
}else{
$height = 480; //default;
}
// Step 3: Verify the game requested exists, output it if it does, and error if it doesn't
if(in_array($_GET['game'],$list))
{
$movie = $_GET['game'];
echo "<object width=".$width." height=".$height.">\n";
echo "<param name=\"movie\" value=\"$movie.swf\">\n";
echo "<embed src=\".$movie.swf\" width=".$width." height=".$height.">\n";
echo "</embed>\n";
echo "</object>\n";
}
else
{
echo "Game not in our database, sorry";
}
//Step 4: Thank yourself for not spending a month hardcoding a million HTML pages.
?>
All links to the games would be written as such:
game.php?game=gamename&w=400&h=550
there are ways to do this automatically as well.
WuLabsWuTecH posted this at 16:06 — 21st February 2005.
They have: 27 posts
Joined: Jun 2003
how would you go about doing it automatically? i thought that I had seen a script that would do something like this, and you just put all the swf files into a directory. then you could add descriptions and make them searchable...
Please visit WuLabsWuTecH Gaming and Ultimate Forumboards
Having Technical Difficulties? Want to throw your computer out the window? Is your network a net doesn't work? Visit TechTalk. We can help!!!
Thanks!!!
CptAwesome posted this at 03:27 — 22nd February 2005.
He has: 370 posts
Joined: Dec 2004
<?
function get_folder_contents($folder,$type)
{
if ($handle = opendir($folder))
{
while (false !== ($file = readdir($handle)))
{
if(ereg(".+\.$type",$file))
{
$file = str_replace(".$type","",$file);
$list[] = "$file";
}
}
closedir($handle);
}
}
?>
usage:
<?
$list = get_folder_contents('flashgames/','swf');
while(list($k,$v) = each($list))
{
echo "<a href=\"game.php?game=$v\">$v</a>";
}
?>
The only drawback would be the inability to get the width and height that way, but that can be fixed by naming the files like bmx.550.400.swf, with that you could:
<?
$list = get_folder_contents('flashgames/','swf');
while(list($k,$v) = each($list))
{
$varray = explode('.',$v);
echo "<a href=\"game.php?game=$v&w=$varray[1]&h=$varray[2]\">$v</a>";
}
?>
The other option with naming them like that, is you could slim it to one variable, and then do the explode('.') in the game.php file
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.