2 Replies Latest reply on Sep 19, 2006 8:54 AM by boliz

    Problem Using FlashVars

    YossarianXOS Level 1
      I've got a strange problem that is probably straightforward to fix, but that I can't seem to find an answer to in the flex docs.

      Basically, I've got a flex app that I need initialize some variables in when the app is run. In my html I"ve added a variable into the flash vars so that it now reads like this;

      "flashvars",'OEM_ID=8800&historyUrl=history.htm%3F&lconid=' + lc_id + '',

      Now in the flex, I can successfully see this variable whenever I use it like the folowing:


      <mx:Label text="OEM is {Application.application.parameters.OEM_ID}" fontWeight="bold"/>

      But if I try to set it as a varaible in the mx:Script area like this:


      public var oemID:String = Application.application.parameters.OEM_ID;

      the swf errors out an ddoesn't show any of my application (blank blue screen).

      Anyone have any idea why? Or can anyone point out what syntax error I'm making there? I'm actually pulling this straight out of the help docs, but I can't seem to get it to work at all.
        • 1. Re: Problem Using FlashVars
          inlineblue Level 1
          I'm assuming you're declaring the oemID variable in your main application MXML file. The problem here is that when such variables are initialized, Application.application is not available (it's null). This is because the application's constructor is currently executing so the app is not yet available. If you want to initiailze such variables via flashvars, do it in the creationComplete event handler.
          • 2. Re: Problem Using FlashVars
            boliz Level 1
            i tried to init it as in the flex 2.0 example and nothing!! i did it aftr creationComplete and it doesnt work?