1 Reply Latest reply on Sep 17, 2008 3:52 AM by Mengdejun

    [mouseEvent] CPU Grab

    TonyGraham
      I have a sample application with 400 column charts below. (I am attempting to duplicate behavior noticed in a heavily databound 80-chart app.)

      If I allow my mouse pointer to hover over the application container (not the charts themselves--but the gutter to the left--a mite tricky in the sample), my CPU pegs at 50%, and the profiler indicates that most of that time is spent in [mouseEvent].

      I assume that the app is just endlessly processing mouse-over events and, perhaps, querying its 400 children to see whether any need to respond.

      Is that true? If so, how do I stop it? (The problem is more signifcant in our real application.)

      I've tried placing the charts in a container and turning off the container's mouseEnabled, focusEnabled, and mouseFocusEnabled, but this didn't help.

      Much thanks for any help!


      =====


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical"
      creationComplete="init();">

      <mx:Script>
      <![CDATA[
      import mx.core.UIComponent;
      import mx.containers.HBox;

      import mx.collections.ArrayCollection;
      import mx.charts.LinearAxis;
      import mx.charts.ColumnChart;
      import mx.charts.CategoryAxis;
      import mx.charts.series.ColumnSeries;

      //[Bindable]
      public var myData:ArrayCollection = new ArrayCollection([
      {name:"first", value:5},
      {name:"second", value:10},
      {name:"third", value:15},
      {name:"fourth", value:20},
      {name:"fifth", value:25}
      ]);
      public var myData2:ArrayCollection = new ArrayCollection([
      {name:"first", value:25},
      {name:"second", value:20},
      {name:"third", value:15},
      {name:"fourth", value:10},
      {name:"fifth", value:5}
      ]);

      private function init():void
      {
      var rows:int = 40;
      var cols:int = 10;

      rows = 40;
      cols = 10;

      for (var i:int=0; i<rows; ++i)
      {
      var hbox:HBox = new HBox();
      for (var j:int=0; j<cols; ++j)
      {
      hbox.addChild(buildColumnChart());
      }
      addToContainer(hbox);
      }
      }

      private function addToContainer(component:UIComponent):void
      {
      addChild(component);
      //testContainer.addChild(component);
      }

      public function buildColumnChart():ColumnChart
      {
      var cc:ColumnChart = new ColumnChart();
      cc.filters = [];
      cc.seriesFilters = [];
      cc.showDataTips = true;
      cc.dataProvider = myData;
      cc.width = 100; cc.height = 100;

      var axis:CategoryAxis = new CategoryAxis();
      axis.categoryField = "name";
      cc.horizontalAxis = axis;

      cc.verticalAxis = new LinearAxis();

      var series:ColumnSeries = new ColumnSeries();
      series.xField = "name";
      series.yField = "value";
      series.displayName = "Value";
      series.dataProvider = myData;
      series.filters = [];
      cc.series.push(series);

      series = new ColumnSeries();
      series.xField = "name";
      series.yField = "value";
      series.displayName = "Value";
      series.dataProvider = myData2;
      series.filters = [];
      cc.series.push(series);

      series = new ColumnSeries();
      series.xField = "name";
      series.yField = "value";
      series.displayName = "Value";
      series.dataProvider = myData;
      series.filters = [];
      cc.series.push(series);

      return cc;
      }

      ]]>
      </mx:Script>

      <mx:VBox id="testContainer"
      mouseEnabled="false" focusEnabled="false" mouseFocusEnabled="false" />

      </mx:Application>