1 Reply Latest reply on Oct 28, 2009 3:18 AM by tegs1979

    Loading Flex app into Flash - TypeError 1009

    tegs1979

      Hi All,

       

      I have created a little Flex app that I load into Flash, and when developed earlier this year everything was hunky-dory. To fix a few problems though, I recently recompiled the Flex parts with an updated Flex Builder and for some unknown reason now get a runtime error everytime I try to popup an Alert, Title Window or Combo Box (and only when the Flex app is running in Flash - it still works fine when running standalone):

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at mx.core::UIComponent/setFocus()[UIComponent.as:6857]

       

      As I can understand from other posts on the subject, line 6857 above tries to reference the stage but, because it's running in Flash, this is null (or isn't a UIComponent)? This I half-understand, but I can't for the life of me seem to resolve it! Does anyone have any ideas?

       

      Many thanks for any help or suggestions...

       

      Kind regards,

       

      Tegs

        • 1. Re: Loading Flex app into Flash - TypeError 1009
          tegs1979 Level 1

          I think I've cracked this now.

           

          For anyone else who has this problem, one possible solution is to listen for and cancel calls made to the SystemManager from the flex app (in your Flash movie). This keeps the flex app "self-contained" and references to the stage don't then get confused:

           

          var flexLoader:Loader = new Loader();
          addChild(flexLoader);
          flexLoader.addEventListener("mx.managers.SystemManager.isBootstrapRoot", systemManagerHandler);
          flexLoader.addEventListener("mx.managers.SystemManager.isStageRoot", systemManagerHandler);
          flexLoader.load(new URLRequest("flex.swf"));
          function systemManagerHandler(event:Event):void {
            event.preventDefault();
          } 
          

           

          Many thanks to Troy Gilbert for the workaround (link).

           

          tc