Ok, this is a long story, I will try to make as clear as possible:
Flash does not validate as XHTML compliant... I am aware of the satay and javay methods... but, I have decided to use JS to get my pages past the validator.
http://www.hillmancurtis.com/ uses this simple javascript to validate :
Code: Select all
<!--this gets called within main index page-->
<script type="text/javascript">RunFoo();</script>Code: Select all
function RunFoo()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="400" height="300">\n');
document.write('<param name="movie" value="hc_web/index_page/visitors_summer04.swf" />\n');
document.write('<param name="quality" value="high">\n');
document.write('<embed src="hc_web/index_page/visitors_summer04.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="400" height="300"></embed>\n');
document.write('</object>\n');
}Code: Select all
<?php
$directory = 'img/banner/'; //Directory relative to the file
$flashfiles = list_images($directory);
srand ((float) microtime() * 10000000);
$flash = array_rand($flashfiles);
$flash = $directory.$flash;
function list_images($path)
{
//declares $flashlist as an array. good practice.
$flashlist = array();
//$dh points to the directory object for $path.
$dh = opendir($path);
//cycle through the files/directorys in the directory object
while (false !== ($file = readdir($dh)))
//for each file/directory, if *.swf, add it to the $flashlist[] array
if (preg_match( '/\.swf$/i', $file))
{
$flashlist[] = $file;
}
//sort the list
sort($flashlist, SORT_STRING);
//returns the array.
return $flashlist;
}
function echo_result($flash)
{
echo '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="800" height="250" hspace="0" vspace="0">';
echo ' <param name="movie" value="'.$flash.'.swf" /><param name="quality" value="high" /><param name="BGCOLOR" value="#333333" /><param name="LOOP" value="false" />';
echo ' <embed src="'.$flash.'.swf" width="800" height="250" hspace="0" vspace="0" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="#333333">';
echo ' </embed>';
echo '</object>';
}
/*
//Use the below code on page where you want banner to show:
//<?php include($_SERVER['DOCUMENT_ROOT']."/random.php"); ?>
*/
echo '<div id="flash_banner">';
echo_result($flash);
echo '</div>';
?>So, my question is this:
How would I pass PHP $flash var to JS file?
Here is how I would like to do it:
Code: Select all
<?php
$directory = 'img/banner/'; //Directory relative to the file
$flashfiles = list_images($directory);
srand ((float) microtime() * 10000000);
$flash = array_rand($flashfiles);
$flash = $directory.$flash;
function list_images($path)
{
//declares $flashlist as an array. good practice.
$flashlist = array();
//$dh points to the directory object for $path.
$dh = opendir($path);
//cycle through the files/directorys in the directory object
while (false !== ($file = readdir($dh)))
//for each file/directory, if *.swf, add it to the $flashlist[] array
if (preg_match( '/\.swf$/i', $file))
{
$flashlist[] = $file;
}
//sort the list
sort($flashlist, SORT_STRING);
//returns the array.
return $flashlist;
}
function echo_result($flash)
{
echo '<script type="text/javascript">RunFoo();</script>';
}
/*
//Use the below code on page where you want banner to show:
//<?php include($_SERVER['DOCUMENT_ROOT']."/random.php"); ?>
*/
echo '<div id="flash_banner">';
echo_result($flash);
echo '</div>';
?>Here is my attempt at using vars in JS (no luck):
Code: Select all
// JavaScript Document
function RunFoo()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="400" height="300">\n');
document.write('<param name="movie" value="<?php echo .$flash.; ?>.swf" /><param name="quality" value="high" /><param name="BGCOLOR" value="#333333" /><param name="LOOP" value="false" />\n');
document.write('<param name="quality" value="high">\n');
document.write('<embed src="<?php echo .$flash.; ?>.swf" width="800" height="250" hspace="0" vspace="0" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="#333333"></embed>\n');
document.write('</object>\n');
}My second guess would be to have my PHP script echo all of the document.write lines of code, but I have not had any luck either way.
Any suggestions!
Dang, maybe I should just use JS to do the whoe thing...
I wish I Flash would just #$&*(# validate!!!!!!
Thanks in advance...
Cheers
Micky