1 Reply Latest reply on Jul 9, 2007 9:37 AM by big4head

    Initialization and object reuse

      I am tearing my hair trying to figure out what is going on here. My main app runs the following init on creationComplete (cmp is an instance of a custom List component, ASWBox is a custom component that is also the list item renderer):

      private function init():void
      cmp.dataProvider = targetData;
      var aswb:ASWBox = new ASWBox();

      in the init for the ASWBox component, I have:
      public function init():void {

      the setId() method starts out:

      public function setId(idx:int):void {
      this.idStr = "aswb"+idx;
      this.pos = idx;

      This is the console output. Am i creating phntom copies of my objects? This is too weird:

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at ASWBox/setId()[C:\Projects\elms\src\ASWBox.mxml:155]
      at test2/test2::init()[C:\Projects\elms\src\test2.mxml:28]
      at test2/___Application1_creationComplete()[C:\Projects\elms\src\test2.mxml:2]
      (etc.- in mid error message I get)

      (then the rest of the error message)

      Any help?
      This is most frustrating.

      Thansk in advance,

        • 1. Re: Initialization and object reuse
          big4head Level 1
          Sorry, I should have been clearer. To answer a few questions, I have put the custom components (ASWBox) in the dataprovider because there is no "data" in the list items: when they are added to the List they are empty forms that can be reordered and grouped to form a complex data query. Setting it up so that the list added additional elements with no dataprovider resulted in the form elements stacking up top of one another on the first line of the list.

          The code on line line 155 of ASWBox.mxm is:

          oProx.dataProvider[idx].fn = fieldNames.selectedItem.label;

          (oProx the component owner is now null)

          however, the fact that the ASWBox's properties (this.initialized and this.owner) are accessible and set in the init() method and then seemingly unset and false in the setID() method seems to defy common sense (in the debugger the memory reference for the ASWBox is identical for both methods). As I said earlier, setting up a dynamic list of form widgets (that can be reordered through drag drop and can be added and removed dynamically) with no initial data is my goal; if there is a way to implement it that is better than a list but easier to implement than a heavily modified version of the custom DragTile/Flexible container component at http://kuwamoto.org/ (my first, abandoned choice) I would appreciate knowing what that would be.

          Sincerely, RG