3 Replies Latest reply on Jul 5, 2007 2:53 PM by Newsgroup_User

    Binding variable to custom object.

    Level 7
      Is there something different about doing this in the main, base
      application then in a custom control files?

      This code works just fine in my custom logDetails.mxml file.

      import Model.troubleLog;
      ...
      [Bindable]
      public var troubleEntry:troubleLog = new troubleLog();

      But using the exact same code in my base index.mxml file throws the
      following errors.

      1046: Type was not found or was not a compile-time constant: troubleLog.
      1180: Call to a possible undefined method troubleLog.

      import Model.troubleLog;
      ...
      [Bindable]
      public var troubleEntry:troubleLog = new troubleLog();


      Can anybody provide any insight on this situation?

      TIA
      Ian Skinner
        • 1. Re: Binding variable to custom object.
          ntsiii Level 3
          In general, you should not do any complex assignments outside of a function, due to the way the compiler generates and compiles the mxml. Instead, have the initialize or creationCOmplete events call an init() function, and do the work in there. You still declare the variable in the instance scope, just don't assign anything to it.

          I don't know why the behavior is different, perhaps a timing issue.

          Tracy
          • 2. Re: Binding variable to custom object.
            Level 7
            If I understand what you are suggesting correctly, I would just define
            the variable, and then in an init() function somewhere set it to the
            desired value.

            What does that look like? I tried simplifying my variable definition
            and I still get the same error? Do I not type the variable here?

            [Bindable]
            public var troubleEntry:troubleLog;


            ntsiii wrote:
            > In general, you should not do any complex assignments outside of a function,
            > due to the way the compiler generates and compiles the mxml. Instead, have the
            > initialize or creationCOmplete events call an init() function, and do the work
            > in there. You still declare the variable in the instance scope, just don't
            > assign anything to it.
            >
            > I don't know why the behavior is different, perhaps a timing issue.
            >
            > Tracy
            >
            • 3. Re: Binding variable to custom object.
              Level 7
              João Fernades was able to help me see that my ViewStack with an id of
              "troubleLog" was clashing with my ActionScript value object
              "troubleLog.as". My simple OO understanding would have said this would
              not have been an issue, but apparently I was not correct.

              Changing the object file to "troubleLogVO.as" and all appropriate
              references resolved my issue.