2 Replies Latest reply on Dec 19, 2007 7:00 AM by JKohn99

    Passing parameters from HTML to Flex app

    Mike8086
      It sounds so easy. :) I am able to "hard code" variables into the wrapper, thanks to this article:

      http://yakovfain.javadevelopersjournal.com/passing_parameters_to_flex_that_works.htm

      Everything he suggests works, but the problem is, that example forces you to manually edit the HTML. What if you need to dynamically assign a value? For instance:

      http://localhost:8500/flexapp.html?name1=Mike

      Or something of that nature. How do I get it to pass the name through the wrapper, and into my flex app? I've been digging around on Adobe's site, all I could find is examples on how to get the data from "Application.application.parameters".

      Thanks for any help, I'm getting nothing from Google. All blogs seem to point to Yakov Fain's article. :)

      Mike
        • 1. Re: Passing parameters from HTML to Flex app
          JKohn99
          You need to use some JavaScript to get variables passed in from the url.

          An example is:
          function getQueryVariable(variable)
          {

          var query = window.location.search.substring(1);
          var vars = query.split("&");
          for (var i=0;i<vars.length;i++)
          {
          var pair = vars .split("=");
          if (pair[0] == variable)
          {
          return pair[1];
          }
          }
          }

          Then use the exernalInterface to call this method from you flex application.

          This example gets a variable called fromPortal
          http:\\theServer:9999\myFlexApp.html?fromPortal="true"

          var fromP:String = ExternalInterface.call("getQueryVariable","fromPortal");
          • 2. Re: Passing parameters from HTML to Flex app
            JKohn99 Level 1
            Also, To include this javascript in all of you flex projects put it in then html template.