2 Replies Latest reply on Jul 14, 2011 2:59 PM by WilMcGee

    parentApplication in .as script file


      I have simple project I am working on, and in a few of my components I use parentApplication  in my linked .as file, to reference a few vars in my main application. Everything works as expected, but i get a warning that says "-Access of undefined property parentApplication" also if i use inline script i do not get this message.


      This is not a major issue as the code works, but is there something I can do to clear this warning?

        • 1. Re: parentApplication in .as script file
          Rangora Level 3

          You must use a getter  for your variable and set the variable private. If you want to have a setter, you must add the [Bindable] annotation to the getter.


          private var _parentApplication:yourType;



          public function get parentApplication():yourType


               return _parentApplication;



          public function set parentApplication(data:yourType):void


               _parentApplication = data;



          I'm not sure I understood your question so give me a feedback please

          • 2. Re: parentApplication in .as script file
            WilMcGee Level 1

            I guess i could of done a little better job of wording my issue.


            I have a flex website I am working on, and in one of my componets I had allot of action script so i moved it to an external file myas.as it looks like this.



            <fx:Script source="myas.as" />

            Then in myas.as file I have:


            // It works but Flash builder flags it with a warning

            myVar = parentApplication.MyPublicVar;


            Flash builder produces a warning saying that parentApplication is undefined, but when i run the application it works fine no problems and pulls the var no problem, Wouldn't that mean that it is defined already?


            Also when I remove the .as file and do inline script it works with no warnings






            //Works with no warnings.

            myVar = parentApplication.MyPublicVar;