Tuesday, February 22, 2011

Get html query string with Flashbuilder 4

In the html page that hosts the swf object. Required addition.  located in c:\.....\html-template folder.
 <script type="text/javascript" src="swfobject.js"></script>
        <script type="text/javascript">
            <!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. -->
            var swfVersionStr = "${version_major}.${version_minor}.${version_revision}";
            <!-- To use express install, set to playerProductInstall.swf, otherwise the empty string. -->
            var xiSwfUrlStr = "${expressInstallSwf}";
            var flashvars = {};
var queryString = window.location.search.substring(1);
if (queryString != null & queryString.length > 0)
{
    var keyValuePairs = queryString.split("&");
    for (var i = 0; i < keyValuePairs.length; i++)
    {
        var keyValuePair = keyValuePairs[i].split("=");

        if (keyValuePair.length == 2)
        {
            flashvars[keyValuePair[0]] = keyValuePair[1];
        }
    }
}

            var params = {};
            params.quality = "high";
            params.bgcolor = "${bgcolor}";
            params.allowscriptaccess = "sameDomain";
            params.allowfullscreen = "true";
            var attributes = {};
            attributes.id = "${application}";
            attributes.name = "${application}";
            attributes.align = "middle";
            swfobject.embedSWF(
                "${swf}.swf", "flashContent",
                "${width}", "${height}",
                swfVersionStr, xiSwfUrlStr,
                flashvars, params, attributes);
            <!-- JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. -->


//in the mxml file
protected function lblTest_mouseOverHandler(event:MouseEvent):void
            {
                // TODO Auto-generated method stub
                var someVariable:String = this.parameters["url"];
            lblTest.text=someVariable;
            }

No comments:

Post a Comment