4 Replies Latest reply on Sep 18, 2007 11:30 AM by Trugriff

    Application Scope

    Trugriff
      Hi:

      I defined a variable in my MXML Application file that retrieves an array from a ColdFusion Page. It is a list that will be used visually and non-visually throughout the application. It is in a database so I don't have to hard-code values...just query database and retrieve list...which works...list (array) is populated and ready to use.

      I have a private array variable in a custom component that I want to assign the value of the application level array...but it gives me an error each time.

      MXML file:

      [Bindable]
      public var colorList:ArrayCollection;

      Custom Component File:

      import mx.core.Application;
      private var lstColors:ArrayCollection;
      lstColors = Application.application.parameters.colorList;

      results in
      1120: Access of undefined property lstColors.

      What am I missing?
      Thanks!
        • 1. Re: Application Scope
          Level 7
          Hi,
          Try this
          private var lstColors:ArrayCollection = new ArrayCollection();

          Rgds

          JFB

          "Trugriff" <rjones@solarcc.com> wrote in message
          news:fcmmcn$8ur$1@forums.macromedia.com...
          > Hi:
          >
          > I defined a variable in my MXML Application file that retrieves an array
          > from
          > a ColdFusion Page. It is a list that will be used visually and
          > non-visually
          > throughout the application. It is in a database so I don't have to
          > hard-code
          > values...just query database and retrieve list...which works...list
          > (array) is
          > populated and ready to use.
          >
          > I have a private array variable in a custom component that I want to
          > assign
          > the value of the application level array...but it gives me an error each
          > time.
          >
          > MXML file:
          >
          > [Bindable]
          > public var colorList:ArrayCollection;
          >
          > Custom Component File:
          >
          > import mx.core.Application;
          > private var lstColors:ArrayCollection;
          > lstColors = Application.application.parameters.colorList;
          >
          > results in
          > 1120: Access of undefined property lstColors.
          >
          > What am I missing?
          > Thanks!
          >


          • 2. Re: Application Scope
            Trugriff Level 1
            OK:
            When I bind my resultset (returned from ColdFusion), the event.result has the proper length but when I go to assign it to my ArrayCollection typed variable and cast it as an Array, the length after the assigment is 0 and I lose the resultset.

            [Bindable]
            public var colorList:ArrayCollection;

            public function colorListReturn(event:ResultEvent):void
            {
            trace(event.result.length); //returns 9
            colorList = new ArrayCollection(event.result as Array);
            trace(colorList.length); //RETURNS 0
            }

            Why would it wipe out the resultset?

            Thanks,
            Rhys
            • 3. Re: Application Scope
              Level 7
              Try this

              [Bindable]
              public var colorList:ArrayCollection = new ArrayCollection;

              public function colorListReturn(event:ResultEvent):void
              {
              trace(event.result.length); //returns 9
              colorList = ArrayCollection(event.result);
              trace(colorList.length); //RETURNS 0
              }

              Do you see? You are initializing the array in your fuction... I hope this
              help
              RGDS

              JFB

              "Trugriff" <rjones@solarcc.com> wrote in message
              news:fcoik1$dg3$1@forums.macromedia.com...
              > OK:
              > When I bind my resultset (returned from ColdFusion), the event.result has
              > the
              > proper length but when I go to assign it to my ArrayCollection typed
              > variable
              > and cast it as an Array, the length after the assigment is 0 and I lose
              > the
              > resultset.
              >
              > [Bindable]
              > public var colorList:ArrayCollection;
              >
              > public function colorListReturn(event:ResultEvent):void
              > {
              > trace(event.result.length); //returns 9
              > colorList = new ArrayCollection(event.result as Array);
              > trace(colorList.length); //RETURNS 0
              > }
              >
              > Why would it wipe out the resultset?
              >
              > Thanks,
              > Rhys
              >


              • 4. Re: Application Scope
                Trugriff Level 1
                worked...thanks for the info...