1 Reply Latest reply on Feb 11, 2010 5:01 PM by timoxley

    Defining a Non-Visual MXML Component in MXML

    timoxley Level 1



      We have a bunch of (MVC) models which are aggregates of other models.

      This definition process seemed to make a lot of sense to do in mxml, but I'm having a bunch of issues. I'm not sure if these are bugs or features due to the fact my objects aren't visual components.


      The root node of my mxml file is defined in actionscript. It's a non-visual model. Let's call the root "Node" and the extending class in mxml "PizzaNode".

      Node implements IMXMLObject, and I defined an initialize() method.

      At runtime, initialize() is not being called on this class. Reading the generated actionscript, I think this is because it only works for child classes.


      I just want to be able to perform actions once the object is set up.

      So to workaround, I add a

      [Event(name="creationComplete", type="mx.events.FlexEvent")]

      before the class definition for Node.

      Fixed Node so it implements IEventDispatcher.
      In the constructor for Node, I'm dispatching a

      dispatchEvent(new FlexEvent("creationComplete", true, false))

      In the root tag for PizzaNode, I use Flashbuilder autocompletion to generate:


      public function node1_creationCompleteHandler(event:FlexEvent):void {
           trace("pizza node creation complete");


      But this handler is never called. What's going on? I suspect I have issues because the component isn't a visual component. Correct?

      Is my description clear enough?

      Thanks for your help!