0 Replies Latest reply on Jul 7, 2010 5:22 PM by Malena Mesarina

    How to add and retrive multiple components to Panel (spark version)

    Malena Mesarina



      I wonder if someone could clarify some things about how to add components to a panel in actionscript.


      I have a panel, a chart and a legend component.

      I want to add the Chart and the Legend to the Panel in actionscript. I have done the following :



      var chart1:ColumnChart  = new ColumChart();

      var legend1: Legend = new Legend();


      panel1.addElementAt(chart1, 0);




      I retrieved them as follows:



      var tmpChar:ColumnChart = panel1.getElementAt(0);

      var tmpLegend:Legend = pane1.getElementAt(1);



      Now, I think the 'index' specification in the addElementAt() function is specifying DEPTH and NOT the number of the component I am adding.

      So I am seeing that my Legend component is ON TOP of my chart component.


      So how can I add an Element to the spark Panel component and have the Panel component automatically layout out the components Vertically?

      And how do I retrieve the chart and Legend from the Panel?


      The spark Panel class has the "getChildByName()" function to retrieve a component by name but this is NOT working, I tried it many times and is not working, it returns a NULL reference, eventhough i had given my chart and Legend components a "name" property value.


      Then I see that the Panel class has the "getElementAt()" function but this only seems to retrieve an element from a specified DEPTH index.

      How could I retrieve several elements on the same depth?


      I am probably not understanding these functions correctly.


      Could someone please give me an example of how to do what I want?

      and explain the DEPTH issue?