Flex 3 problem

  • Started
  • Last post
  • 4 Responses
  • rounce

    Dear QBN...
    /// THE OBJECTIVE ///////////////
    The application first loads and displays a PortfolioBar instance. The user clicks the a button and the application state is changed and the inital PortfolioBar is removed and another instance (which requests data, in XML format, from another table in the database) is displayed. In a nutshell, it works...
    ________________________________...
    /// THE PROBLEM /////////////////
    The first time the first instance is removed from the stage and the second one is being created I get a null object reference error when I try to access any property of the MXML created display objects. I click continue in the Flex debugger and change the application state then switch back to the problematic state and then it works.

    Yes I have tried
    accessing other Display Objects before the scrubber and it's the same error every time.

    /* KERRRRRAAAAZY SHIT HUH? */
    ________________________
    /// ERROR OUTPUT ////////////////
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at sharpedge.components.ui::Portfol... Work\Sharpedge\src\sharpedge\com...
    at sharpedge.components.ui::Portfol... Work\Sharpedge\src\sharpedge\com...
    at flash.display::DisplayObjectCont...
    at mx.core::UIComponent/http://www...
    at mx.core::Container/addChildAt()
    at mx.core::Container/addChild()
    at mx.states::AddChild/apply()
    at mx.core::UIComponent/applyState...
    at mx.core::UIComponent/commitCurre...
    at mx.core::UIComponent/setCurrentS...
    at mx.core::UIComponent/set currentState()
    at lib::Genlib$/switchState()[C:\Cl... Work\Sharpedge\src\lib\Genlib.as...
    at sharpedge.components.ui::MainMen... Work\Sharpedge\src\sharpedge\com...
    _____________________
    /// THE CODE ////////////////////
    states: http://pastebin.com/m2bfe2101
    PortfolioBar.mxml: http://pastebin.com/mb4209f3
    _____________________

  • rounce0

    guh, shoulda pastebin'd the error

    http://pastebin.com/m4045d62d

  • maximillion_0

    im not an mxml guy (im straight class based AS) but is the second instance trying to use a referenece to the stage befgore being added to stage. try adding a listener Event.ADDED_TO_STAGE listener to the object and thencalling the code in init(); (you might need to make a new method for that - is init() the constructor in mxml?)

  • maximillion_0

    something like this :http://pastebin.com/m509e3b5a

  • rounce0

    Sorry I pasted an older error by accident here's the propper one, sorry about that:
    http://pastebin.com/m37f860bd

    The init(); method is the event handler that is called when the component is added to the stage (see line 3 : col 61) and serves as an 'entry point' of sorts for the component logic (setting vars, event listeners n shit).

    Thanks max for not TL;DR'ing this.