• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 972
  • Last Modified:

URL parameters into flash player?

I have a flash map with hotspot locations that you can select from a drop down menu (in the swf) and then zoom to that location on the map.

I can display my flash map normally with the param and embed tags. (see code snippet "normal way")

I also found a way to display URL driven parameters via a "document.write" method (see code snippet "url driven way")

An example url  for something like the above would be:

www.blah.com/newmaps/URLDrivenPage.htm?zoomifyImagePath=image_example/&zoomifyHotspotsXMLPath=hotspots/hotspots.xml&zoomifyInitialX=500&zoomifyInitialY=1600&zoomifyInitialZoom=100


What I'd like to do is have the two merged in some way, so that if I link directly to a hotspot's coordinates it will display correctly in the same swf that it would if I just navigated to the default page.

So basically what I'm asking for is a way to display an swf with the option to accept url driven parameters.


please ask away if I need to clarify more.

thanks
--- NORMAL WAY ---
 
<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="800" height="800" id="ZoomifyHotspotViewer">
				<param name="flashvars" value="zoomifyXMLPath=ZoomifyHotspotViewer.xml">
				<param name="menu" value="false">
				<param name="src" value="ZoomifyHideShowAllHotspotsExample.swf">
				<embed flashvars="zoomifyXMLPath=ZoomifyHotspotViewer.xml" src="ZoomifyHideShowAllHotspotsExample.swf" menu="false" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash" width="800" height="800" name="ZoomifyHotspotViewer"></embed>
			 </object>
 
 
 
--- URL DRIVEN WAY ---
 
<SCRIPT type="text/javascript" >
				var urlString = document.location.href;
				var paramIndex = urlString.indexOf("?")+1;
				var paramString = urlString.substring(paramIndex,urlString.length);
				document.write("	<OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'");
				document.write("           CODEBASE='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'");
				document.write("           WIDTH='800'");
				document.write("           HEIGHT='800'");
				document.write("           ID='theMovie'>");
				document.write("			<PARAM NAME='FlashVars' VALUE='" + paramString + "'>");
				document.write("    		<PARAM NAME='src' VALUE='ZoomifyHideShowAllHotspotsExample.swf'>");
				document.write("		<EMBED SRC='ZoomifyHideShowAllHotspotsExample.swf'");
				document.write("		   FlashVars='" + paramString + "'");
				document.write("           PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'");
				document.write("           WIDTH='800'");
				document.write("           HEIGHT='800'");
				document.write("           NAME='theMovie'>");
				document.write("    	</EMBED>");
				document.write("   </OBJECT>");
			</SCRIPT>

Open in new window

0
CurtinProp
Asked:
CurtinProp
  • 5
  • 3
1 Solution
 
Antonio EstradaCommented:
swfObject can do that for you.

http://blog.deconcept.com/swfobject/

Usage:

<HTML>
<HEAD>
<TITLE>My Webpage</TITLE>
<script type="text/javascript" src="./swfobject.js"></script>
</HEAD>
<BODY>
<div id="flashcontent">
      <p>Here you type your normal html. It can be a table or whatever.</p>
</div>
<script type="text/javascript">
      // <![CDATA[
      var so = new SWFObject("myFlashMovie.swf", "Movie", "723", "600", "8", "#031A30");
      so.addVariable("variable1","value");
      so.write("flashcontent");
      // ]]>
</script>
</BODY>
</HTML>

Good Luck.

-V
0
 
CurtinPropAuthor Commented:
My swf relies on an xml file, so usually in the flash vars section I would input:

<param name="flashvars" value="zoomifyXMLPath=ZoomifyHotspotViewer.xml">

how would I write this into the above example?

I've tried

so.addParam("flashvars", "zoomifyXMLPath=ZoomifyHotspotViewer.xml");

but no luck
0
 
CurtinPropAuthor Commented:
solved the above comment, I was using the new version of swfobject, I've downgraded to 1.5 just so I can understand this and then I'll go back to new version.

Using the following code below I can display the movie no problems, I've added the flashvars to find my xml file.

But now I need to pass some variables to it, which is where im currently stuck at.

I want to pass the following url string:

URLDrivenPage.htm?zoomifyImagePath=curtin_example/&zoomifyHotspotsXMLPath=hotspots/hotspots.xml&zoomifyInitialX=500&zoomifyInitialY=1600&zoomifyInitialZoom=100

Am I on the right track in order to pass the above to my swf?

cheers for the help.
<div id="flashcontent">
 
<h2>EE test</h2>
      <p>Html content for the flash player alternative</p>
</div>
<script type="text/javascript">
      // <![CDATA[
   var so = new SWFObject("ZoomifyHideShowAllHotspotsExample.swf", "ZoomifyHotspotViewer", "800", "800", "6", "#ffffff");
   so.addParam("flashvars", "zoomifyXMLPath=ZoomifyHotspotViewer.xml");
   so.addVariable("variable1", getQueryParamValue("variable1"));
   so.addVariable("variable2", getQueryParamValue("variable2"));
   so.addVariable("variable3", getQueryParamValue("variable3"));
   so.addVariable("variable4", getQueryParamValue("variable4"));
   so.addVariable("variable5", getQueryParamValue("variable5"));
   so.write("flashcontent");
      // ]]>
</script>

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Antonio EstradaCommented:
Something like this will do it:

I'm assuming that the function getQueryParamValue("varX"); returns you a string.

<code>

Oh, and you no longer need flashvars :)

-V
<div id="flashcontent">
 
<h2>EE test</h2>
      <p>Html content for the flash player alternative</p>
</div>
<script type="text/javascript">
      // <![CDATA[
   var so = new SWFObject("ZoomifyHideShowAllHotspotsExample.swf", "ZoomifyHotspotViewer", "800", "800", "6", "#ffffff");
   so.addVariable("zoomifyXMLPath", "ZoomifyHotspotViewer.xml");
   so.addVariable("zoomifyImagePath", getQueryParamValue("variable1"));
   so.addVariable("zoomifyHotspotsXMLPath", getQueryParamValue("variable2"));
   so.addVariable("zoomifyInitialX", getQueryParamValue("variable3"));
   so.addVariable("zoomifyInitialY", getQueryParamValue("variable4"));
   so.addVariable("zoomifyInitialZoom", getQueryParamValue("variable5"));
   so.write("flashcontent");
      // ]]>
</script>

Open in new window

0
 
CurtinPropAuthor Commented:
I've made those changes and I' not sure what is wrong with the code now, everything seems logical.

If you look at the code snippet below the code entitled "original way" still works when I use the URL string.

However our new swfobject doesn't. It loads the swf fine but doesn't pass the variables.

I'm still using the following URL:

URLDrivenPage.htm?zoomifyImagePath=curtin_example/&zoomifyHotspotsXMLPath=hotspots/hotspots.xml&zoomifyInitialX=500&zoomifyInitialY=1600&zoomifyInitialZoom=100

---- Original Way ----
 
<SCRIPT type="text/javascript" >
				var urlString = document.location.href;
				var paramIndex = urlString.indexOf("?")+1;
				var paramString = urlString.substring(paramIndex,urlString.length);
				document.write("	<OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'");
				document.write("           CODEBASE='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0'");
				document.write("           WIDTH='800'");
				document.write("           HEIGHT='800'");
				document.write("           ID='theMovie'>");
				document.write("			<PARAM NAME='FlashVars' VALUE='" + paramString + "'>");
				document.write("    		<PARAM NAME='src' VALUE='ZoomifyHideShowAllHotspotsExample.swf'>");
				document.write("		<EMBED SRC='ZoomifyHideShowAllHotspotsExample.swf'");
				document.write("		   FlashVars='" + paramString + "'");
				document.write("           PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'");
				document.write("           WIDTH='800'");
				document.write("           HEIGHT='800'");
				document.write("           NAME='theMovie'>");
				document.write("    	</EMBED>");
				document.write("   </OBJECT>");
			</SCRIPT>
 
 
 
 
---- SWFobject way ----
 
 
<div id="flashcontent">
 
<h2>EE test</h2>
      <p>Html content for the flash player alternative</p>
</div>
<script type="text/javascript">
      // <![CDATA[
   var so = new SWFObject("ZoomifyHideShowAllHotspotsExample.swf", "ZoomifyHotspotViewer", "800", "800", "6", "#ffffff");
   so.addVariable("zoomifyXMLPath", "ZoomifyHotspotViewer.xml");
   so.addVariable("zoomifyImagePath", getQueryParamValue("variable1"));
   so.addVariable("zoomifyHotspotsXMLPath", getQueryParamValue("variable2"));
   so.addVariable("zoomifyInitialX", getQueryParamValue("variable3"));
   so.addVariable("zoomifyInitialY", getQueryParamValue("variable4"));
   so.addVariable("zoomifyInitialZoom", getQueryParamValue("variable5"));
   so.write("flashcontent");
      // ]]>
</script>

Open in new window

0
 
CurtinPropAuthor Commented:
hey Vulturous,

Fixed the problem I was having not passing the variables in.

All my swf's variables were listed in the xml file that I was linking to.... so we were initially linking to a list of variables, then trying to change those variables straight after.

Also I added some coldfusion to handle the url stuff.
<script type="text/javascript">
      // <![CDATA[
   var so = new SWFObject("ZoomifyHideShowAllHotspotsExample.swf", "ZoomifyHotspotViewer", "800", "800", "6", "#ffffff");
   <!--so.addVariable("zoomifyXMLPath", "ZoomifyHotspotViewer.xml");-->
   so.addVariable("zoomifyImagePath","curtin_example/");
   so.addVariable("zoomifyHotspotsXMLPath","hotspots/hotspots.xml");
   so.addVariable("zoomifyInitialX","<cfoutput>#URL.zoomifyInitialX#</cfoutput>");
   so.addVariable("zoomifyInitialY","<cfoutput>#URL.zoomifyInitialY#</cfoutput>");
   so.addVariable("zoomifyInitialZoom","<cfoutput>#URL.zoomifyInitialZoom#</cfoutput>");
   so.write("flashcontent");
      // ]]>
</script>

Open in new window

0
 
CurtinPropAuthor Commented:
thanks for putting me on the right track, much appreciated.
0
 
Antonio EstradaCommented:
I'm glad I could help :)

-V
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now