![]() |
|
|
Send More Variables to Flash 6 Player Using New ParameterBy Robert M. Hall of Feasible Impossibilities
I saw that Macromedia is running a contest in their Designer Developer
Area where you can submit tips for using Macromedia products and possibly
win an iMac! Well I tried to think of something I could submit and came
up with this and submitted it a few minutes ago. Hope its useful! <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ID=sign_on WIDTH=100% HEIGHT=100%> <PARAM NAME=movie VALUE="document.swf"> <PARAM NAME=FlashVars VALUE="foo=bar"> <PARAM NAME=quality VALUE=high> <PARAM NAME=menu VALUE=false> <PARAM NAME=bgcolor VALUE=#000000> <EMBED src="document.swf" FlashVars="foo=bar" quality=high menu=false bgcolor=#000000 WIDTH=100% HEIGHT=100% TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED> </OBJECT> This new method is especially handy when used with server side scripting such as ColdFusion MX or PHP to dynamically create the values of FlashVars that will be embedded in the HTML document and in turn passed into the .swf document we refer to in the object and embed tags. You could pass in data from a cookie in this method or other personalized information. Below is an example using PHP that would assign the current GMT date & time from your server to the variable "gmt" and the visitors IP address to the variable "ip" which in turn would be placed in the FlashVars parameter and passed into your flash document being referenced by the object and embed tag in question. <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ID=sign_on WIDTH=100% HEIGHT=100%> <PARAM NAME=movie VALUE="document.swf"> <PARAM NAME=FlashVars VALUE="<? echo "gmt=".urlencode(gmdate("D, d M Y H:i:s"))."&ip=".$REMOTE_ADDR; ?>"> <PARAM NAME=quality VALUE=high> <PARAM NAME=menu VALUE=false> <PARAM NAME=bgcolor VALUE=#000000> <EMBED src="document.swf" FlashVars="<? echo "gmt=".urlencode(gmdate("D, d M Y H:i:s"))."&ip=".$REMOTE_ADDR; ?>" quality=high menu=false bgcolor=#000000 WIDTH=100% HEIGHT=100% TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED> </OBJECT> Here is an example of what that would end up looking like after being processed by the server: <PARAM NAME=FlashVars VALUE="gmt=Sun%2C+26+May+2002+17%3A22%3A03&ip=192.168.0.1"> <PARAM NAME=quality VALUE=high> <PARAM NAME=menu VALUE=false> <PARAM NAME=bgcolor VALUE=#000000> <EMBED src="document.swf" FlashVars="gmt=Sun%2C+26+May+2002+17%3A22%3A03&ip=192.168.0.1" quality=high menu=false bgcolor=#000000 WIDTH=100% HEIGHT=100% TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED> </OBJECT> The thing to note is that any variables passed into Flash using this method appear on the main timeline or _level0 of your movie. Using the FlashVars parameter you can avoid the initiations imposed on the GET request by various browsers and servers, thus you are able to pass much more information into your Flash .swf document. Another benefit for webmasters is that if you are recording the data from GET request in your web server log files, they wont be clogged up with extra data in the url fields. This might be especially attractive to webmasters who filter certain types of GET request from their server for security reasons, or for webmasters who run IDS (Intrusion Detection systems) such as Snort or other fingerprint based IDS's that may have false positives triggered by large GET requests. Happy Coding! -Rob |
Archives
|
Copyright 1997-2006 Robert M. Hall, II, Inc. DBA Feasible Impossibilities All Rights Reserved