Passing Variables to Flash Using HTML
Page 1 of 19 Replies - 39325 Views - Last Post: 12 May 2009 - 04:40 AM
#1
Passing Variables to Flash Using HTML
Posted 04 October 2005 - 05:38 PM
I'm new with Flash and I have a simple question:
How can I pass a parameter to a sfw file from html.
Can u give me an example please?
Thanks!
Replies To: Passing Variables to Flash Using HTML
#2
Re: Passing Variables to Flash Using HTML
Posted 04 October 2005 - 05:45 PM
<PARAM NAME=FlashVars VALUE=[variable1=value1&variable2=value2&variable3=value3...]
Then you'll add a parameter to the EMBED tag like this:
<EMBED .... FlashVars=[variable1=value1&variable2=value2&variable3=value3...] ...>
The end result would look something like this
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://macromedia.com/cabs/swflash.cab#version=6,0,0,0" ID=flaMovie WIDTH=250 HEIGHT=250> <PARAM NAME=movie VALUE="flaMovie.swf"> <PARAM NAME=FlashVars VALUE="userName=permadi&score=80"> <PARAM NAME=quality VALUE=medium> <PARAM NAME=bgcolor VALUE=#99CC33> <EMBED src="flaMovie.swf" FlashVars="userName=permadi&score=80" bgcolor=#99CC33 WIDTH=250 HEIGHT=250 TYPE="application/x-shockwave-flash"> </EMBED> </OBJECT>
There are a few things to note about passing variables in the HTML.
* Use only letters, underline, and numbers. There should be no reason why symbols such as '$' or '#' must be used as variable names.
* Do not start a name with a number (for example: 1message is an invalid variable name because it starts with a number; whereas message1 is a valid variable name).
Flash will certainly reject or get confused if you use a variable name that starts with a number or other special characters - except underlines (ie: _message, and _1message are valid names).
* A variable name should not contain any <space> character (ie: my message is an invalid name, my_message is a valid name).
* Characters needs to be URL encoded (see: Introduction to URL Encoding). This means that special characters, such as =, &, <SPACE>, + need to be substituted with their URL encoded form. For example: name=John Doe. Here, the <space> between John and Doe needs to be encoded with + sign, so you need to pass it as name=John+Doe or name=John%20Doe. (Flash doesn't seem to enforce this, but you should follow the proper way.) Search for URL encoding on the net for more details on this subject.
* If you need to include an & as part of a value, such as in ingredients=Beef&Pork, then you need to encode the & like this: ingredients=Beef%26Pork. The %26 is an encoded form of the & sign. The number 26 is the hexadecimal code of the character &. If you need to know the encoding value of a particular character, consult an ASCII table. There are other characters that need to be encoded, such as <, >, /, ?.
#3
Re: Passing Variables to Flash Using HTML
Posted 11 May 2007 - 03:21 AM
Sure! This is actually fairly easy to do after you've done it once or twice. If you are using the OBJECT and EMBED methods to display your movie (for cross-browser compatibility) you'll place your parameters in 2 places. First, you'll use a PARAM tag like this:
<PARAM NAME=FlashVars VALUE=[variable1=value1&variable2=value2&variable3=value3...]
Then you'll add a parameter to the EMBED tag like this:
<EMBED .... FlashVars=[variable1=value1&variable2=value2&variable3=value3...] ...>
The end result would look something like this
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://macromedia.com/cabs/swflash.cab#version=6,0,0,0" ID=flaMovie WIDTH=250 HEIGHT=250> <PARAM NAME=movie VALUE="flaMovie.swf"> <PARAM NAME=FlashVars VALUE="userName=permadi&score=80"> <PARAM NAME=quality VALUE=medium> <PARAM NAME=bgcolor VALUE=#99CC33> <EMBED src="flaMovie.swf" FlashVars="userName=permadi&score=80" bgcolor=#99CC33 WIDTH=250 HEIGHT=250 TYPE="application/x-shockwave-flash"> </EMBED> </OBJECT>
But the Flashvar is not worked in my pgm. Any other possiblity?
This post has been edited by FlashNewUser: 11 May 2007 - 03:23 AM
#4
Re: Passing Variables to Flash Using HTML
Posted 13 May 2007 - 02:06 PM
post your html with the flash var you want and we will see if we can help you
#5
Re: Passing Variables to Flash Using HTML
Posted 13 June 2007 - 02:29 PM
Here is part of my aspx page
<form id="Form2" method="post" > <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0, 0" width="700" height="470" id="landingPage" align="middle" viewastext> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="landingPage.swf" id="flashMovieParamTag" runat="server" /> <param name="quality" value="high" /> <param name="wmode" value="opaque" /> <param name="bgcolor" value="#ffffff" /> <embed src="..\Images\flash\skeleton3.swf" quality="high" wmode="opaque" bgcolor="#165BA0" width="500" height="470" name="landingPage" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" runat="server" id="flashEmbedTag" /> </object> </form>
Here is my code behind
my variables
protected HtmlGenericControl flashEmbedTag; protected HtmlGenericControl flashMovieParamTag; private string MTouch = string.Empty; private string Name = string.Empty; private string ReferringURL = string.Empty; private string Score;
private void Page_Load(object sender, System.EventArgs e)
{
imgbtnRedeem.ImageUrl = "../images/butRedeem_ez.gif";
string swfUrl = @"..\Images\flash\skeleton3.swf?";
// Put user code to initialize the page here
MTouch = "empty mtouch";
Name = "Jerry";
ReferringURL = "http://localhost/Game/Game.aspx";
string tp = Request.RequestType;
//if(!IsPostBack)
if ( Request.RequestType == "GET")
{
swfUrl = swfUrl + "Mtouch=" + MTouch + "&Name=" + Name + "&ReferringURL=" + ReferringURL;
flashEmbedTag.Attributes["src"] = swfUrl;
flashMovieParamTag.Attributes["value"] = swfUrl;
}
else
{
//get the score from the flash file
}
}
I was wondering if any one knows how to get a variable from the flash file:
#6
Re: Passing Variables to Flash Using HTML
Posted 14 June 2007 - 06:23 PM
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0, 0" width="700" height="470" id="landingPage" align="middle" viewastext>
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="landingPage.swf" id="flashMovieParamTag" runat="server" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="bgcolor" value="#ffffff" />
<embed src="..\Images\flash\skeleton3.swf" quality="high" wmode="opaque" bgcolor="#165BA0"
width="500" height="470" name="landingPage" align="middle" allowscriptaccess="sameDomain"
type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"
runat="server" id="flashEmbedTag" />
</object>
so there is no flash vars to load
#7
Re: Passing Variables to Flash Using HTML
Posted 15 June 2007 - 01:00 PM
swfUrl = swfUrl + "Mtouch=" + MTouch + "&Name=" + Name + "&ReferringURL=" + ReferringURL;
flashEmbedTag.Attributes["src"] = swfUrl;
flashMovieParamTag.Attributes["value"] = swfUrl;
The flash file will display my varibles so I thought that was the correct way. Could you give me an example of how it should look?
Oh and not sure if this is important but, when I click on a button in the flash file, it does a post back. I have seen some examples on the net of people using Request.Form["Variable"] to get a variable from
any help will be Greatly Appreciated
red01, on 14 Jun, 2007 - 06:23 PM, said:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0, 0" width="700" height="470" id="landingPage" align="middle" viewastext>
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="landingPage.swf" id="flashMovieParamTag" runat="server" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="bgcolor" value="#ffffff" />
<embed src="..\Images\flash\skeleton3.swf" quality="high" wmode="opaque" bgcolor="#165BA0"
width="500" height="470" name="landingPage" align="middle" allowscriptaccess="sameDomain"
type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"
runat="server" id="flashEmbedTag" />
</object>
so there is no flash vars to load
#8
Re: Passing Variables to Flash Using HTML
Posted 12 May 2009 - 03:20 AM
like
<OBJECT codeBase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" height="600" width="800" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="src" value="video/xx1.swf" > <param name="FlashVars" value="input1=121" > <embed src="video/xx1.swf" flashvars="input1=121" type="application/x-shockwave-flash" width="800" height="580"> </embed> </OBJECT>
but i want to pass a value of a textbox which is in asp page.
like <param name="flashvars" value="input1=textbox1.text"
any one know how to do that???
This post has been edited by rockychamp: 12 May 2009 - 03:24 AM
#9
Re: Passing Variables to Flash Using HTML
Posted 12 May 2009 - 03:49 AM
If the text is put into the box by the user then flashvars won't be a lot of use to you without reloading the page. Instead you can use External Interface (see the comments for examples).
#10
Re: Passing Variables to Flash Using HTML
Posted 12 May 2009 - 04:40 AM
|
|

New Topic/Question
Reply

MultiQuote







|