Below is an example ths shows a modification of the Generated HTML wrapper:
Tracy

Modifications to generated HTML wrapper (or index.templatehtml):

<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
  var requiredMajorVersion = 9;
  ......
  var _sDataSourceUrl = "http://www.MyDomain.com/MyAppWS/";;  // Data Source Url 
for web services
  var _sAssetsUrl = "C:/dev/Flex/clients/MyApp/assets/";     // Assets url
// -----------------------------------------------------------------------------
// -->
</script>

        AC_FL_RunContent(
                        "src", "MyApp",
                        "width", "100%",
                        ...
                        "flashvars",'dataSourceUrl=' + _sDataSourceUrlRoot 
                          + '&assetsUrl=' + _sAssetsUrl, 
                        "allowScriptAccess","sameDomain",
                        ...
        );

In Flex, access the data like this:
        /**
        * init() fucntion, run by creationComplete
        */
        public function init():void
        {
          var oAppParms:Object = Application.application.parameters;
          _sDataSourceUrl = oAppParms.dataSourceUrl;
          _sSiteAssetsUrl = oAppParms.assetsUrl;
          trace("_sDataSourceUrl=" + _sDataSourceUrl + ", _sSiteAssetsUrl=" + 
_sSiteAssetsUrl);

________________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Charlie 
Hubbard
Sent: Sunday, March 02, 2008 10:54 PM
To: [email protected]
Subject: Re: [flexcoders] Re: Passing Parameters to flash file

Examples in HTML would be something like the following:

Object tag would be something like:

<PARAM NAME="FlashVars" VALUE="param1=blah&param2=blek&param3=gloub+koll">

Embed tag would be something like:

<EMBED src="display.swf"
FlashVars="param1=blah&param2=blek&param3=gloub+koll" ... (other
parameters)></EMBED>

In your flex application you would do:

var param1 : String = Application.application.parameters.param1;
var param2 : String = Application.application.parameters.param2;
var param3 : String = Application.application.parameters.param3;

Things to remember is that values must be URL encoded such that values
containing ampersands, spaces, etc must be encoded to prevent
confusing flex.

You can read about it at adobe's KB here:

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_16417&sliceId=2

Charlie

On Sun, Mar 2, 2008 at 8:59 PM, Manjith <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
> Hi Hob,
>
> Can you please send me a code sample. I tired with parameter string
> in HTML. But it didn't work.
>
> Thanks
>
> Manjith
> --- In [email protected], "Hob Spillane" <[EMAIL PROTECTED]>
> wrote:
>
> >
> > You can pass parameters to your SWF using the flashVars variable in
> > your HTML wrapper. The parameters are formatted querystring
> style.
> >
> > Once in your flex app, you can access your parameters using:
> >
> >
> Application.application.parameters.yourParamNameHere
> >
> > -Hob
> >
> >
> > --- In [email protected], "Manjith" <manjith155@> wrote:
> > >
> > > I want to pass a parameter to a flsh file and access that value
> within
> > > the code to decide a path of a xml file loacted.
> > >
> > > Could anyone suggest how to do this in flex.
> > >
> > >
> > > Thanks
> > >
> > > Manjith
> > >
> >
>
> 
 

Reply via email to