9 Replies - 40931 Views - Last Post: 12 May 2009 - 04:40 AM

#1 Alinu  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 25-June 05

Passing Variables to Flash Using HTML

Posted 04 October 2005 - 05:38 PM

Hi,

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!
Is This A Good Question/Topic? 1

Replies To: Passing Variables to Flash Using HTML

#2 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1858
  • View blog
  • Posts: 20,275
  • Joined: 17-March 01

Re: Passing Variables to Flash Using HTML

Posted 04 October 2005 - 05:45 PM

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>


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 <, >, /, ?.
Was This Post Helpful? 0
  • +
  • -

#3 FlashNewUser  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 41
  • Joined: 23-April 07

Re: Passing Variables to Flash Using HTML

Posted 11 May 2007 - 03:21 AM

[quote name='skyhawk133' post='127703' date='4 Oct, 2005 - 05:45 PM']
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

Was This Post Helpful? 0
  • +
  • -

#4 red01  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 12
  • View blog
  • Posts: 204
  • Joined: 08-May 06

Re: Passing Variables to Flash Using HTML

Posted 13 May 2007 - 02:06 PM

flash vars should work fine.... we use them all the time, unless you use a server side scripting language such as php, flash vars are the way to do it.

post your html with the flash var you want and we will see if we can help you
Was This Post Helpful? 0
  • +
  • -

#5 jpendergraft  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-June 07

Re: Passing Variables to Flash Using HTML

Posted 13 June 2007 - 02:29 PM

I have the following code that loads a flash file and passes some variables to it I was wondering if any one knows how to get a variable from the flash file:


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
	  }
}




B)
I was wondering if any one knows how to get a variable from the flash file:
Was This Post Helpful? 0
  • +
  • -

#6 red01  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 12
  • View blog
  • Posts: 204
  • Joined: 08-May 06

Re: Passing Variables to Flash Using HTML

Posted 14 June 2007 - 06:23 PM

there are no flash vars in this tag

<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
Was This Post Helpful? 0
  • +
  • -

#7 jpendergraft  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-June 07

Re: Passing Variables to Flash Using HTML

Posted 15 June 2007 - 01:00 PM

hmm I used an example I found and it didnt have any flash vars in the object tag. It passed a string to the htmlgeneric control.

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 :) Have a good weekend!


View Postred01, on 14 Jun, 2007 - 06:23 PM, said:

there are no flash vars in this tag

<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

Was This Post Helpful? 0
  • +
  • -

#8 rockychamp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-May 09

Re: Passing Variables to Flash Using HTML

Posted 12 May 2009 - 03:20 AM

i can pass a value for a flash file from asp page..
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

Was This Post Helpful? 0
  • +
  • -

#9 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: Passing Variables to Flash Using HTML

Posted 12 May 2009 - 03:49 AM

How is the text being written to the text box? If it's put there dynamically by asp, can't you use the same asp call to write the value into the flashvar?

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).
Was This Post Helpful? 0
  • +
  • -

#10 rockychamp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-May 09

Re: Passing Variables to Flash Using HTML

Posted 12 May 2009 - 04:40 AM

text is entered by user in asp page's text box and i want that value in flash swf object on every button click in which button is onasp page.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1