{"id":102001,"date":"2011-06-15T22:58:11","date_gmt":"2011-06-15T14:58:11","guid":{"rendered":"\/2011\/06\/15\/flashvars_variables.html"},"modified":"2011-06-15T22:58:11","modified_gmt":"2011-06-15T14:58:11","slug":"flashvars_variables","status":"publish","type":"post","link":"https:\/\/blog.zhenglei.net\/?p=102001","title":{"rendered":"Passing Variables from HTML to Flash in Adobe CS4"},"content":{"rendered":"<p>Suppose we need to pass the currnet URL from HTML to Flash:<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1.&nbsp;&nbsp; Add the following&nbsp; ActionScript into FLA:<\/strong><\/p>\n<p># #&nbsp; myVIDEO is the parameter from HTML,&nbsp; and we display it on screen<\/p>\n<p>var my_fmt = new TextFormat();<br \/>my_fmt.color = 0xFF0000;<br \/>my_fmt.underline = true;<br \/>this.createTextField(&#8220;myTxt&#8221;, 1, 320, 10, 200, 20);<br \/>myTxt.autoSize = &#8220;left&#8221;;<br \/>myTxt.setTextFormat(my_fmt);<\/p>\n<p>if (myVIDEO == undefined) {<br \/>myTxt.text = &#8220;Keynote_1.flv&#8221;;<br \/>} else {<br \/>myTxt.text = myVIDEO;<br \/>}<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.&nbsp; Generate the SWF and HTML from FLA<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>3. <strong>Modify the generated HTML to add myVIDEO parameter<\/strong>,<\/p>\n<p>&nbsp;&nbsp; 3.1 ==&gt; Add the following line in the&nbsp; <span style=\"color: #0000ff;\"><em>AC_FL_RunContent<\/em><\/span> block:<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em> &#8216;flashvars&#8217;,&#8221;,<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;&nbsp; 3.2 ==&gt; Add the handle of flashvars in function <span style=\"color: #0000ff;\"><em>AC_GetArgs<\/em><\/span>, as following:<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp; <em>case &#8220;flashvars&#8221;:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = &#8220;myVIDEO=&#8221;+window.location;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<\/em><\/p>\n<p>&nbsp; \/\/ Here myVIDEO the variable in AS2, and <em>window.location is the variable in JavaScript indicating the current URL of HTML page<br \/><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Passing variables from HTML to Flash via flashvars, Adobe CS4 <a href=\"https:\/\/blog.zhenglei.net\/?p=102001\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,13,6],"tags":[66],"class_list":["post-102001","post","type-post","status-publish","format-standard","hentry","category-flash","category-html","category-internet","tag-flashvars"],"_links":{"self":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts\/102001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=102001"}],"version-history":[{"count":0,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts\/102001\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=102001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=102001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=102001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}