4 Replies Latest reply on Nov 1, 2009 11:02 PM by BaliHi

    Creating series with effects via Actionscript causes effect to repeat endlessly

    Cashew1


      Hi,

       

      I've been trying to add effects to programmatically generated series.  I can create everything fine, but when the effect is applied, it repeats over and over.  In the example below, my line series slide on to the chart (that's good), but then disappear and slide onto the chart again, and again, and again.  It should only run the effect once, and then stop.

       

      Any ideas?  The code below reproduces the problem.


      thanks for any help,

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
          <mx:Button click="run()" />
          <mx:CartesianChart id='mainChart'>
          <mx:horizontalAxisRenderer ><mx:AxisRenderer axis="{offsetAxis}" fontWeight="bold" /></mx:horizontalAxisRenderer>
          <mx:verticalAxisRenderer><mx:AxisRenderer axis="{returnAxis}" fontWeight="bold"/></mx:verticalAxisRenderer>
          <mx:horizontalAxis ><mx:LinearAxis id="offsetAxis"/></mx:horizontalAxis>
          <mx:verticalAxis><mx:LinearAxis id='returnAxis'/></mx:verticalAxis>
          </mx:CartesianChart>
         
          <mx:Script>
              <![CDATA[
                  import mx.charts.series.LineSeries;
                  import mx.charts.effects.SeriesSlide;
                  import mx.collections.ArrayCollection;
                 
                  [Bindable] private var testData:ArrayCollection = new ArrayCollection(
                                   [{'x':1,'y':2},{'x':2,'y':4},{'x':3,'y':7},{'x':4,'y':5}]);
                 
                  private function run():void {
                      var slideIn:SeriesSlide = new SeriesSlide();
                      slideIn.duration = 2000;
                      slideIn.type = 'show';
                      slideIn.elementOffset = 0;

       

                      var ls:LineSeries = new LineSeries();
                      ls.dataProvider = new ArrayCollection();
                      ls.horizontalAxis = offsetAxis;
                      ls.verticalAxis = returnAxis;
                      ls.setStyle('showDataEffect',slideIn);
                      ls.setStyle('showEffect',null);
                      mainChart.series = [ls];              

       

                      callLater(setData,[ls,testData,'x','y']);
                  }

       

                  private function setData(obj:LineSeries,data:ArrayCollection,xField:String,yField:String):void {
                      obj.xField = xField;
                      obj.yField = yField;
                      obj.dataProvider = data;
                  }
                 
              ]]>
          </mx:Script>
         
      </mx:Application>