Passing variables and parameters from HTML to AS3

Trust me. This is the working one. There are many examples on several web pages. However, non of them tell exactly what they do!!!! If you follow these steps you can’t miss it.

1- create a new fla file

2- type onto first frame in actions panel,

var tf:TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
tf.border = true;

var value1:String = root.loaderInfo.parameters.s0;
var value2:String = root.loaderInfo.parameters.s1;
tf.text = value1+ “\n” +value2;

3- Publish this .fla (Do not forget to check “html” from “publish setting”)

4- Open your published html file in Dreamveawer and type your two parameters(s0 and s1 which are shown in red);

<html xmlns=”” xml:lang=”en” lang=”en”>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<script language=”javascript”>AC_FL_RunContent = 0;</script>
<script src=”AC_RunActiveContent.js” language=”javascript”></script>
<body bgcolor=”#ffffff”>
<!–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 {













‘pluginspage’,’’,’movie’,’html_pass’ );

//end AC code
<object classid=”clsid:d27cdb6e-ae6d-11cf-96b8-444553540000″

codebase=”,0,0,0″ width=”550″




<param name=”allowScriptAccess” value=”always” />
<param name=”allowFullScreen” value=”false” />
<param name=”FlashVars” value=”s0=jkljkljkljkl.flv 576767&amp;s1=bbbb”>
<param name=”movie” value=”html_pass.swf” />

<param name=”quality” value=”high” />

<param name=”bgcolor” value=”#ffffff” />

<embed src=”html_pass.swf” FlashVars=”s0=jkljkljkljkl.flv 576767&amp;s1=bbbb”

quality=”high” bgcolor=”#ffffff” width=”550″ height=”400″ name=”html_pass” align=”middle” allowScriptAccess=”always” allowFullScreen=”false” type=”application/x-shockwave-flash” pluginspage=”” />

after this. Save your html file and run. The point is, you have to check your variables via html file. If you only run swf file, you can’t pass variable from html.

source: pass variable from html 2

16 thoughts on “Passing variables and parameters from HTML to AS3”

  1. It’s weird. It works for me. Anyway, I pasted into post the exact as3 code.
    There is no other thing in the fla file. Just paste the into .fla.

  2. thanks you paste the code but it is not working the error is “2007 Parameter text must be non-null.”
    please solve it.

    again thanks to you,

  3. If you try to get variables by running only swf file, you will get this message.
    You should read the post and edit your html file as I told above.

    1 – Publish your swf file and html file from Flash,
    2 – Open an editor like dreamviewer and edit your html file as I told in the post. you should edit your html file.
    3 – Test your code by this html file not with swf file.

  4. sorry but this code is not implement on flash player 7
    how can i call the parameter from html in flash player 7
    please tell me quickley..


  5. Hi! I’ve been looking around for such a nice tutorial. I visited even adobe’s page to find out how to pass variables from html/php to flash(AS3), but no one was good enough to understand how actually it works. So dude, you’re awesome! 10x

  6. Approvingly your post helped me incredibly a lot in my college assignment. Hats high to you dispatch, will seem ahead in behalf of a lot more interdependent content articles in a jiffy as its sole of my pick subject-matter to go through.

Leave a Reply

Your email address will not be published. Required fields are marked *