Jump to content

Trying to dynamically embed flash files into my php page


Recommended Posts

Hi, I'm trying to display flash files as thumbnails on a page. I had it working absolutely fine on browsers other than IE, but because of IE's unbelievably annoying activex border around embeded objects, I have been having a lot of trouble with trying to get rid of it. When you export the html from flash it takes care of getting rid of the activex border, so I am trying to include the html file into a <div> except I have made it into a php file so that it can get the variables that it needs to send to the .swf file.The reason I am sending variables to the swf file is because the link in the flash file is a dynamic link.Here's the php file that is trying to embed the flash into it:

<?php include("connect.php"); ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Grant Portfolio: Web Design and Development</title><link href="css/styles.css" rel="stylesheet" type="text/css"><link href="css/port_styles.css" rel="stylesheet" type="text/css"><script language="javascript">AC_FL_RunContent = 0;</script><script src="AC_RunActiveContent.js" language="javascript"></script></head><body><div id="container">	<div id="top">	<img src="images/slices/top.gif" class="slice" style="padding-bottom:0px; "></div>		<div id="nav_content_contain">				<!--middle-->			<div id="middle">				<div id="spacer_nav"> </div>				<div id="nav">					<?php include("nav.php"); ?>				</div> 				<div id="spacer"> </div>				<div id="content">					<?php 						$id = $_GET['id'];						//this page data to display Section						$query_nav = mysql_query("SELECT * FROM nav WHERE id = '$id' LIMIT 1");						while ($result = mysql_fetch_array($query_nav)) {							$this_page = $result['link'];							echo "<h2>$this_page</h2>";						}						/*						$id2 is passed to swf file to create dynamic link						$title is the title of the thumbnail						$file contains the filename of the .swf						*/						$query = mysql_query("SELECT * FROM section WHERE nav_id = '$id'");						while ($result = mysql_fetch_array($query)) {							$id2 = $result['id'];							$title = $result['title'];							$file = $result['file'];							echo "<div style=\"float:left;\"><h5>$title</h5>";							echo "<div>";							include("flash/thumbs/$file");							echo "</div></div>";						}					?>				</div>			</div>			<!--bottom -->			<div id="bottom">				<img src="images/slices/bottom.gif" class="slice">			</div>		</div></div></body></html>

Here's one of the flash thumbnails:

<!--url's used in the movie--><!--text used in the movie--><!-- saved from url=(0013)about:internet --><script language="javascript">	if (AC_FL_RunContent == 0) {		alert("This page requires AC_RunActiveContent.js.");	} else {		AC_FL_RunContent(			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',			'width', '200',			'height', '150',			'src', 'th1',			'quality', 'high',			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',			'align', 'middle',			'play', 'true',			'loop', 'true',			'scale', 'showall',			'wmode', 'window',			'devicefont', 'false',			'id', 'th1',			'bgcolor', '#0f4a63',			'name', 'th1',			'menu', 'true',			'allowFullScreen', 'false',			'allowScriptAccess','sameDomain',			'movie', 'th1',			'salign', ''			); //end AC code	}</script><noscript>	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="200" height="150" id="th1" align="middle">	<param name="allowScriptAccess" value="sameDomain" />	<param name="allowFullScreen" value="false" />	<param name="movie" value="th1.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#0f4a63" />	<embed src="th1.swf" quality="high" bgcolor="#0f4a63" width="200" height="150" name="th1" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />	</object></noscript>

Here's the flash link that needs the variables:

on(press) {	getURL("selection.php?val=" + var_link + "&id=" + var_link2);}

If seeing the site helps at all, it's at www.grantportfolio.com these files are getting embedded into the Web and Illustration sections.Thanks for any help and please ask questions if anything needs to be clarified or explained further. I really appreciate your help!

Link to post
Share on other sites
$file contains the filename of the .swf
So, it looks like you are trying to just include the swf? If you are trying to make it dynamically with script, you will need to echo out javascript to run the AC_FL_RunContent() function for every swf you want to show.
Link to post
Share on other sites

include("flash/thumbs/$file"); is including the html file that is created when you export a flash file as html. That file is the code that I posted below where I wrote "Here's one of the flash thumbnails:" on my first post in this thread (sorry I wasn't very clear about that). The reason I am including the html file instead of just the swf file is because the html file has all of the javascript that is required to remove the activex border. Thanks for your help!

Link to post
Share on other sites

So what problem are you having? The way I've always passed variables to a Flash movie is to add them onto the URL of the SWF. I'm not sure what the AC_FL_RunContent function does, but it looks like it does some automatic things where you might not be able to add variables to the SWF URL. For example, you don't give the full src, only the filename sans-extension.

Link to post
Share on other sites

Everything seems fine, I guess try adding some alert statements into the AC library Javascript file to try and trace out what is happening. If the AC_GenerateObj function is being called that writes the Flash HTML code to the page then they should be showing up.

Link to post
Share on other sites

Ok, I've got the thumbnails displaying now! Except I forgot how I was passing the variables to flash before and now I've got to try to figure that out again.I was using FlashVars to pass the variables. I thought it was like this:<PARAM NAME=FlashVars VALUE="var_link=<?php echo $id2; ?>"> <embed FlashVars="var_link=<?php echo $id2; ?>" src="flash/thumbs/<?php echo "$swf"; ?>" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="200" height="150"></embed>$id2 is just a number from a mysql table, but it does not seem to work.

Link to post
Share on other sites

Do you do that in the embed tag? Like this <embed src="page.swf?id=1&val=2"The results I keep coming up with are undefined. What is supposed to happen is when someone clicks on the flash thumbnail, the link takes them to www.grantportfolio.com/selection.php?val=1(or some other #)&id=1(or some other id #), but intead it is writing the url like this http://www.grantportfolio.com/selection.ph...mp;id=undefined.Is there a way to tell whether the variable is undefined because I am passing it incorrectly or because I am doing something wrong in the action script?Do I have to load the variable somehow or declare it?Here's where I am passing the variables to flash:

<?php $no_extension = substr($swf, 0, -4); ?><script type="text/javascript">	AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','200','height','150','accesskey','grantportfolio','tabindex','1','title','flashthumbnails','src','flash/thumbs/th1','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','flash/thumbs/<?php echo $no_extension; ?>' ); //end AC code</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="200" height="150" accesskey="grantportfolio" tabindex="1" title="flashthumbnails">    <param name="movie" value="flash/thumbs/<?php echo "$swf"; ?>?var_link=<?php echo $id2; ?>&var_link2=<?php echo $id; ?>">    <param name="quality" value="high">    <PARAM NAME=FlashVars VALUE="var_link=<?php echo $id2; ?>&var_link2=<?php echo $id; ?>">    <embed src="flash/thumbs/<?php echo "$swf"; ?>" flashvars="var_link=<?php echo $id2; ?>&var_link2=<?php echo $id; ?>" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="200" height="150"></embed></object></noscript>

And here's where I am trying to use the variables to create a link in flash:

on(press) {	getURL("selection.php?val=" + var_link + "&id=" + var_link2);}

Thanks for your help.

Link to post
Share on other sites
Do I have to load the variable somehow or declare it?
Yes, you have to get the querystring yourself and break it up to save each variable. Flash has access to the URL that was used to call it, including the querystring. I can't remember the object and property names right now, but it's all in the Flash help files.Adobe also publishes a Flash/Javascript integration kit that you can use to send variables between Flash and Javascript.
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...