4 Replies Latest reply on Oct 1, 2008 4:09 PM by strayhand

    Error #2007

    strayhand
      I'm having some trouble resolving this error and I could use another set of eyes on my code. It only seems to be a problem on the PC, as my Mac doesn't seem to be throwing the error. I did a Google search and there are a variety of things that will set this error message off, none of which I've been able to find in my code.

      Flash Error Message

      TypeError: Error #2007: Parameter type must be non-null.
      at flash.events::EventDispatcher/addEventListener()
      at mx.core::Container/addEventListener()
      at mx.containers::ViewStack/mx.containers:ViewStack::commitProperties()
      at mx.core::UIComponent/validateProperties()
      at mx.managers::LayoutManager/::validateProperties()
      at mx.managers::LayoutManager/::doPhasedInstantiation()
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.core::UIComponent/::callLaterDispatcher2()
      at mx.core::UIComponent/::callLaterDispatcher()

      Code's attached. Thanks for you help.
        • 1. Re: Error #2007
          Level 7

          "strayhand" <webforumsuser@macromedia.com> wrote in message
          news:gc0hij$961$1@forums.macromedia.com...
          > I'm having some trouble resolving this error and I could use another set
          > of
          > eyes on my code. It only seems to be a problem on the PC, as my Mac
          > doesn't
          > seem to be throwing the error. I did a Google search and there are a
          > variety of
          > things that will set this error message off, none of which I've been able
          > to
          > find in my code.

          You don't show your MXML code, but is it possible you've got this going on:

          Q (5): I need to set a property or add an event listener on a component
          that is in a ViewStack/TabNavigator/Accordion. When the component is not
          the first child of the Navigator Container, I get a null object error
          (#1009). What causes this, and how can I fix it?

          A: By default, the Navigator containers only create the children of
          each pane as that pane is viewed. The easy way to fix this is to set the
          creationPolicy on the Navigator to "all." However, this will cause your
          application to take longer to load. A better way to fix this is to wait for
          a later event, such as creationComplete on the component you want to access,
          or to use binding to "pull" the data into the component.
          The way I handle it is to call invalidateProperties() on change of the
          ViewStack. I then override commitProperties() and call an "initializer" for
          each pane. In the body of each initializer function, I check to see if the
          selectedItem for the viewStack is the one my initalizer cares about. If
          not, I return from the function immediately. Inside that initializer
          function, I set properties and add listeners as appropriate.


          • 2. Error #2007
            strayhand Level 1
            Amy,

            Thanks for the post. I'm not sure that I'm tracking with your suggestion. Are you saying that I could be running into an issue where I'm assigning an event handler to a display object that doesn't exist? Or in my case a canvas that's within a viewstack that isn't selected?

            I did "attach" my code. I wonder if you're unable to see it on the newsgroup. Here's the URL if you care to look at the source.
            • 3. Re: Error #2007
              Level 7

              "strayhand" <webforumsuser@macromedia.com> wrote in message
              news:gc0puo$jum$1@forums.macromedia.com...
              > Amy,
              >
              > Thanks for the post. I'm not sure that I'm tracking with your suggestion.
              > Are
              > you saying that I could be running into an issue where I'm assigning an
              > event
              > handler to a display object that doesn't exist? Or in my case a canvas
              > that's
              > within a viewstack that isn't selected?
              >
              > I did "attach" my code. I wonder if you're unable to see it on the
              > newsgroup.
              > Here it is again pasted into the message.
              >
              > Thanks.
              >
              >


              ...


              ....




              ?

              But yes, if you have a canvas that is in a viewstack pane that hasn't been
              selected ever and you use the default creationPolicy and you have never
              selected that canvas, then yes you could run into issues.

              BUT...if the code you had in that last post, which I just glanced at, was
              all of it, this only occurs when you create your components in MXML. If you
              create them in AS, then they are created at the moment you call new thing().
              I didn't see any MXML in your post. If there was no MXML, then I doubt this
              is the problem.

              Hope this clarifies.

              Amy


              • 4. Re: Error #2007
                strayhand Level 1
                Hmmm... Not to beat a dead horse, but let's assume that your example is the cause of my error. How would one code things in a way that it doesn't throw this error?

                I do have a mixture of AS and MXML. At the bottom of my post I have some empty MXML objects that I'm basically adding child objects to via Actionscript.

                Here's a snipped of the ViewStack that I've created.

                <!-- Begin Image Stack -->
                <mx:ViewStack id="imageStack" width="{imageStackWidth}" height="{imageStackHeight}" x="{imageStackPositionX}" y="{imageStackPositionY}" selectedIndex="{selectedIndex}">
                </mx:ViewStack>
                <!-- End Image Stack -->

                So basically it's an empty viewstack at first, and then on creation complete for my application the init() function in actionscript processes which then loads my XML and dynamically adds children to the viewstack.

                The thing that irks me is that I wrote an earlier version of this widget and it doesn't throw the error. Now this version is throwing an error on the PC. UGH.