3 Replies Latest reply on Oct 9, 2007 6:56 AM by tagyro

    Loading variables from a web page into Flex SWF

    andyd273
      I have a SWF that I want to load information into when the page loads (namely a username).
      However, I can't find the right way to do it, or at least not the correct way to do it.
      I've tried flashvars and <param>, but so far I can't figure out where the imported variables are located in Flex...

      Any hints are welcome.
        • 1. Re: Loading variables from a web page into Flex SWF
          GeorgeWS Level 1
          Andy,
          I have an initiVars() function kinda like this:

          [Bindable]
          public var username:String;

          public function initVars() : void {
          username= Application.application.parameters.username;
          }

          There are 3 places I add username=#username# in the html page that calls the SWF then I change the html page to a cfm page to take in the variables.

          Hope this helps

          George
          • 2. Re: Loading variables from a web page into Flex SWF
            andyd273 Level 1
            Ok, but where are the three places?
            If my webpage looks like

            <!-- saved from url=(0014)about:internet -->
            <html lang="en">
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

            <!-- BEGIN DeepLinking required section -->
            <link rel="stylesheet" type="text/css" href="deeplinking/deeplinking.css" />
            <!-- END DeepLinking required section -->

            <title></title>
            <script src="AC_OETags.js" language="javascript"></script>

            <!-- BEGIN DeepLinking required section -->
            <script src="deeplinking/deeplinking.js" language="javascript"></script>
            <!-- END DeepLinking required section -->

            <style>
            body { margin: 0px; overflow:hidden }
            </style>
            <script language="JavaScript" type="text/javascript">
            <!--
            // -----------------------------------------------------------------------------
            // Globals
            // Major version of Flash required
            var requiredMajorVersion = 9;
            // Minor version of Flash required
            var requiredMinorVersion = 0;
            // Minor version of Flash required
            var requiredRevision = 28;
            // -----------------------------------------------------------------------------
            // -->
            </script>
            </head>

            <body scroll="no">
            <script language="JavaScript" type="text/javascript">
            <!--
            // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
            var hasProductInstall = DetectFlashVer(6, 0, 65);

            // Version check based upon the values defined in globals
            var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);


            // Check to see if a player with Flash Product Install is available and the version does not meet the requirements for playback
            if ( hasProductInstall && !hasRequestedVersion ) {
            // MMdoctitle is the stored document.title value used by the installation process to close the window that started the process
            // This is necessary in order to close browser windows that are still utilizing the older version of the player after installation has completed
            // DO NOT MODIFY THE FOLLOWING FOUR LINES
            // Location visited after installation is complete if installation is required
            var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
            var MMredirectURL = window.location;
            document.title = document.title.slice(0, 47) + " - Flash Player Installation";
            var MMdoctitle = document.title;

            AC_FL_RunContent(
            "src", "playerProductInstall",
            "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"" ,
            "width", "458",
            "height", "390",
            "align", "middle",
            "id", "UserUploadApp",
            "quality", "high",
            "bgcolor", "#ffffff",
            "name", "UserUploadApp",
            "allowScriptAccess","sameDomain",
            "type", "application/x-shockwave-flash",
            "pluginspage", " http://www.adobe.com/go/getflashplayer"
            );
            } else if (hasRequestedVersion) {
            // if we've detected an acceptable version
            // embed the Flash Content SWF when all tests are passed
            AC_FL_RunContent(
            "src", "UserUploadApp-debug",
            "width", "458",
            "height", "390",
            "align", "middle",
            "id", "UserUploadApp",
            "quality", "high",
            "bgcolor", "#ffffff",
            "name", "UserUploadApp",
            "allowScriptAccess","sameDomain",
            "type", "application/x-shockwave-flash",
            "pluginspage", " http://www.adobe.com/go/getflashplayer"
            );
            } else { // flash is too old or we can't detect the plugin
            var alternateContent = 'Alternate HTML content should be placed here. '
            + 'This content requires the Adobe Flash Player. '
            + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
            document.write(alternateContent); // insert non-flash content
            }
            // -->
            </script>
            <noscript>
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
            id="UserUploadApp" width="458" height="390"
            codebase=" http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
            <param name="movie" value="UserUploadApp-debug.swf" />
            <param name="quality" value="high" />
            <param name="bgcolor" value="#ffffff" />
            <param name="allowScriptAccess" value="sameDomain" />
            <embed src="UserUploadApp-debug.swf" quality="high" bgcolor="#ffffff"
            width="458" height="390" name="UserUploadApp" align="middle"
            play="true"
            loop="false"
            quality="high"
            allowScriptAccess="sameDomain"
            type="application/x-shockwave-flash"
            pluginspage=" http://www.adobe.com/go/getflashplayer">
            </embed>
            </object>
            </noscript>
            </body>
            </html>


            Then where would I want it?
            Also, I'll be using PHP, which (hopefully) wont make a difference.
            • 3. Re: Loading variables from a web page into Flex SWF
              tagyro Level 1
              Why don;t you use IBrowserManager? you can get the "fragment" and it would also be better for deep-linking www.site.com#username=john