1 Reply Latest reply on Sep 4, 2010 8:15 PM by Shongrunden

    Force instantiation.  Why creationPolicy doesn't cut it?

    Daniel Freeman Level 1

      I've been in this situation before.  So I'm going around in circles obviously.  I want to force the child object of an MXML component to instantiate when the component itself is instantiated.  "Aha!" I think to myself.  "That's what the creationPolicy is for, isn't it!" - I do it, and it has no effect.  So perhaps the problem is in the details?  What I'm trying to do is hardly rocket science.  In Pure ActionScript, without the Flex components, and MXML to complicate matters, it would be easier than trivial.  So what's up?

       

      I have an old fashioned Halo Flex 3 based component inside a Spark TitleWindow.  Like so...

       

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:TitleWindow

      ..blah blah blah...

      creationPolicy="all">

      ...

       

      <views:ResultsTotalsTabsV id="totalsContent" filtersVisible = "false" leftControlsVisible = "false" />

      </s:TitleWindow>

       

       

       

      And I'm instantiating it in code, like so...

       

       

      totalsPalette = new InventoryTotalsPanel();

       

      totalsContent = _totalsPalette.totalsContent;

       

       

       

      The problem is that totalsContent is null.  It hasn't been instantiated.  How do I force it to instantiate???  I know I could rewrite my XMXL component as ActionScript.  Then I'd be able to write a constructor, and ensure that I set up totalContent so that it wasn't null.  But why doesn't the MXML work here?