Dynamic chart with Timer
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="initTimer()">
<mx:Script>
import mx.collections.ArrayCollection;
import flash.utils.Timer;
import flash.events.TimerEvent;
[Bindable]
public var memoryRecording:ArrayCollection = new ArrayCollection();
public function initTimer():void {
var myTimer:Timer = new Timer(1000, 0);
myTimer.addEventListener("timer", timerHandler);
myTimer.start();
}
public function timerHandler(event:TimerEvent):void {
memoryRecording.addItem({totalMemory:flash.system.System.totalMemory,timePoint:getTimer()});
}
</mx:Script>
<mx:Panel title="Line Chart">
<mx:LineChart dataProvider="{memoryRecording}" showDataTips="true">
<mx:series>
<mx:LineSeries yField="totalMemory" xField="timePoint"
displayName="Memory Usage" />
</mx:series>
</mx:LineChart>
</mx:Panel>
</mx:Application>
Related examples in the same category