4 Replies Latest reply on Dec 4, 2009 12:21 PM by ice9_us

    adding a child object

    ice9_us

      trying to add a child to a panel display...

       

       

       

      <mx:Panel x="399" y="48" width="726" id="charthome" height="477" >

       

       

      </mx:Panel>

       

       

      public function buildChart(event:Event):void {

      mychart=new  LineChart();

      myChart.showDataTips=true;

      myChart.showDataTips=true;

       

       

      myChart.height=100;

      myChart.width=100;

       

       

      // myChart.dataProvider = ;

      charthome.addChild(myChart);

      }

       

      how do i add the child to chart home so it goes across.. till the vertical area is full..

      the moves down to the next line much like a grid?

        • 1. Re: adding a child object
          Gregory Lafrance Level 6

          Can't really understand what you want to do.

           

          Can you try to describe more clearly?

           

          Greg Lafrance
          www.ChikaraDev.com

          Flex Development and Support Services

          • 2. Re: adding a child object
            ice9_us Level 1

            When you run the following code.. you will see the graphs are made horiz.. or veritical..

            i want them side by side.. across.. untill they reach the end of the panel..

            then go to the next line...

             

            What to do::

            pick a class.. then pick a module.. then pick more than one counter for each module...

             

             

             

            I will at some point want to offer a selection for a  new chart.. or add a series to some chart selected...

             

             

             

             

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

            <mx:Application

             

             

            xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">

             

            <mx:Script>

            <![CDATA[

             

             

            import mx.events.ItemClickEvent;

             

            import mx.collections.ArrayCollection;

             

            import mx.states.RemoveChild;

             

            import mx.effects.Resize;

             

            import mx.rpc.events.ResultEvent;

             

            import mx.rpc.events.FaultEvent;

             

            import mx.core.Application;

             

            import mx.controls.Alert;

             

            import mx.managers.SystemManager;

             

            import mx.collections.*;

            import

             

             

             

             

             

            mx.charts.*;

            import

             

             

             

             

             

            mx.charts.series.*;

            import

             

             

             

             

             

            mx.charts.renderers.*;

            import

             

             

             

             

             

            mx.charts.events.*;

             

             

              

              

            [

            Bindable]

            public

             

             

             

             

             

            var t:XMLList = new XMLList();

            [

            Bindable]

            public

             

             

             

             

             

            var moduleA:Array = new Array();

            [

            Bindable]

            public

             

             

            public

             

             

            public

             

             

            //event.resul

            t=event.result.stat;

            for

             

             

            trace(event.result.stat.@module[N]);

            }

            module.source = moduleA;

            get_data.disconnect();

            get_data.clearResult(

            true);

             

            }

             

            [

            Bindable]

            public

             

             

            public

             

             

            Bindable]

            public

             

             

            public

             

             

            public

             

             

            Bindable]

            public

             

             

            public

             

             

            var a:int;

             

            trace( event.currentTarget.selectedItem.@mclass);

            mclass=event.currentTarget.selectedItem.@mclass.toString();

            mod=

            null;

            mStatCounter=

            null;

             

            if ( charthome.numChildren > 0 ) {

             

            charthome.removeAllChildren();

            System.gc();

            }

             

            //mclass=null;

             

            //t=null;

             

            //this.removeChild(myChart);

            get_module.send();

            }

            [

            Bindable]

            public

             

             

            public

             

             

            public var myChart:LineChart;

             

            public var series1:LineSeries;

             

            public var series2:LineSeries;

             

            public var legend1:Legend;

             

            public

             

             

            new LineChart();

            myChart.showDataTips =

            true;

             

            // myChart.x=500;

             

            // myChart.y=100;

            myChart.height=100;

            myChart.width=100;

             

             

            // myChart.dataProvider = ;

            charthome.addChild(myChart);

            }

             

            public

             

             

            public

             

             

            if ( !updateTimer.hasEventListener(TimerEvent.TIMER) ) {

            updateTimer =

            new Timer(1000);

            updateTimer.addEventListener(TimerEvent.TIMER,updateInfo,

            false, 0, true);

            updateTimer.start();

            }

             

            }

             

            public

             

             

            false);

            updateTimer.removeEventListener(TimerEvent.TIMER, updateInfo,

            true);

            updateTimer.removeEventListener(TimerEvent.TIMER_COMPLETE,updateInfo,

            true);

            updateTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, updateInfo,

            false);

             

            trace ("updateInfo");

            }

             

            ]]>

             

            </mx:Script>

             

            <mx:HTTPService

             

            id="get_data" url="http://softnetinc.net/cgi-bin/stats_by_group.cgi"

            method="

            POST" result="process_data(event)" fault="faultHandler(event)" resultFormat="e4x">

            <mx:request

             

            xmlns="">

             

            <serverName>ult10</serverName>

            </mx:request>

            </mx:HTTPService>

             

            <mx:HTTPService

             

            id="get_module" url="http://softnetinc.net/cgi-bin/get_stats_module.cgi"

            method="

            POST" result="process_module(event)" fault="faultHandler(event)" resultFormat="e4x">

            <mx:request

             

            xmlns="">

             

            <serverName>ult10</serverName>

             

            <module>{mclass}</module>

            </mx:request>

            </mx:HTTPService>

             

            <mx:HTTPService

             

            id="get_statName" url="http://softnetinc.net/cgi-bin/get_counterData.cgi"

            method="

            POST" result="process_statCounter(event)" fault="faultHandler(event)" resultFormat="e4x">

            <mx:request

             

            xmlns="">

             

            <serverName>ult10</serverName>

             

            <mclass>{mclass}</mclass>

             

            <module>{statModule}</module>

            </mx:request>

            </mx:HTTPService>

             

            <mx:HTTPService

             

            id="get_StatData" url="http://softnetinc.net/cgi-bin/get_kstatdata.cgi"

            method="

            POST" result="process_statCounter(event)" fault="faultHandler(event)" resultFormat="e4x">

            <mx:request

             

            xmlns="">

             

            <serverName>ult10</serverName>

             

            <mclass>{mclass}</mclass>

             

            <module>{statModule}</module>

            </mx:request>

            </mx:HTTPService>

             

             

            <mx:ComboBox x="53" y="32" dataProvider="{module}"></mx:ComboBox>

             

            <mx:AdvancedDataGrid x="32" y="145" id="adg1" dataProvider="{t}" designViewDataType="flat" itemClick="get_modules(event)">

             

            <mx:columns>

             

            <mx:AdvancedDataGridColumn headerText="Class" dataField="@mclass"/>

             

            </mx:columns>

             

            </mx:AdvancedDataGrid>

             

            <mx:CheckBox x="32" y="339" label="Checkbox"/>

             

            <mx:CheckBox x="120" y="339" label="Checkbox"/>

             

            <mx:AdvancedDataGrid x="120" y="369" id="mYmodule" designViewDataType="flat" dataProvider="{mod}" itemClick="get_statCounter(event)">

             

            <mx:columns>

             

            <mx:AdvancedDataGridColumn headerText="module" dataField="@module"/>

             

             

            </mx:columns>

             

            </mx:AdvancedDataGrid>

             

            <mx:HBox backgroundColor="white" x="32" y="368" width="80" >

             

            <mx:Label text="{mclass}" width="80" />

             

            </mx:HBox>

             

            <mx:AdvancedDataGrid x="251" y="369" id="counter" dataProvider="{mStatCounter}" designViewDataType="flat" itemClick="buildChart(event)" >

             

            <mx:columns>

             

            <mx:AdvancedDataGridColumn headerText="Stat Counters" dataField="@statName"/>

             

            </mx:columns>

             

            </mx:AdvancedDataGrid>

             

            <mx:Panel x="399" y="48" width="726" id="charthome" height="477" >

             

            </mx:Panel>

             

            </mx:Application>

            function updateInfo():void {

             

            updateTimer.removeEventListener(TimerEvent.TIMER, updateInfo,

            function add_time():void {

             

            var updateTimer:Timer;

            function buildChart(event:Event):void {

            myChart =

            function get_statCounter(event:Event):void {

            statModule=event.currentTarget.selectedItem.@module;

            get_statName.send();

            }

             

            var statModule:String = new String();

            function get_modules(event:Event):void {

             

            var mclass:String = new String();
            function faultHandler(event:FaultEvent):void {

            Alert.show(event.fault.faultString, event.fault.faultCode);

            }

             

            [

            function process_statCounter(event:ResultEvent):void {

            mStatCounter=event.result.stat;

             

            }

             

            var mStatCounter:XMLList = new XMLList();
            function process_module(event:ResultEvent):void {

            mod=event.result.stat;

             

            }

            [

            var mod:XMLList = new XMLList();
            ( var N:int = 0; event.result.stat.@module[N] ; N++ ) {

            moduleA.push(event.result.stat.@module[N]);

             

            function process_data(event:ResultEvent):void {
            function init():void {

            get_data.send();

            }

             

            var module:ArrayCollection = new ArrayCollection();
            • 3. Re: adding a child object
              msakrejda Level 4

              The Tile component?

              • 4. Re: adding a child object
                ice9_us Level 1

                that is my first throught.. but i was not sure if i could set something in the layout that would make it work.....