5 Replies Latest reply on Oct 5, 2007 8:52 AM by Gregory Lafrance

    Accessing _root variable from flex

    Denis108
      In Flex code, I am trying to access a variable that I pass to the Flash object through FlashVars argument. In Flash it is easy to do as all the variables that as passed as a part of FlashVars appear as a part of _level0 or _root. Is there any way to do it in Flex?

      I am trying pass a large dataset directly to Flash without an http call (creating a desktop application). Does anyone know if the FlashVars approach will work for a large dataset or is there a better approach?

      Thanks
        • 1. Re: Accessing _root variable from flex
          Denis108 Level 1
          I found the solution through Application.application.parameters. Thanks!
          • 2. Re: Accessing _root variable from flex
            yu.wei.qian.07 Level 1
            "In Flex code, I am trying to access a variable that I pass to the Flash object through FlashVars argument. "

            how did you do this?
            • 3. Re: Accessing _root variable from flex
              Gregory Lafrance Level 6
              From the Flex 2.0.1 help (search for Using flashVars):
              The following example sets the values of the firstname, middlename, and lastname flashVars properties inside the <object> tag in a simple wrapper:

              <?xml version="1.0"?>
              <!-- wrapper/ApplicationParameters.mxml -->
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="initVars()">
              <mx:Script><![CDATA[
              // Declare bindable properties in Application scope.
              [Bindable]
              public var myName:String;
              [Bindable]
              public var myHometown:String;

              // Assign values to new properties.
              private function initVars():void {
              myName = Application.application.parameters.myName;
              myHometown = Application.application.parameters.myHometown;
              }
              ]]></mx:Script>

              <mx:VBox>
              <mx:HBox>
              <mx:Label text="Name: "/>
              <mx:Label text="{myName}" fontWeight="bold"/>
              </mx:HBox>
              <mx:HBox>
              <mx:Label text="Hometown: "/>
              <mx:Label text="{myHometown}" fontWeight="bold"/>
              </mx:HBox>
              </mx:VBox>
              </mx:Application>
              -----------------------------------------------------------------------------------
              If you are using the wrapper that is generated by Flex Data Services or wrappers that are included in the resources/html-templates directory, your wrapper might not look the same, but the basic approach to passing the flashVars variable is. For example, you might insert flashVars variables by appending them to a function parameter, as the following example shows:

              "flashvars","historyUrl=%2Fflex%2Fflex%2Dinternal%3Faction%3Dhistory%5Fhtml&lconid=" + lc_id + "&firstName=Nick&lastName=Danger",

              • 4. Re: Accessing _root variable from flex
                yu.wei.qian.07 Level 1
                yeah, tried that.. is setting flashvars in HTML same in setting flashvars via DLL?