xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark"
initialize="initData();" height="600">
duration="300" minimumElementDuration="0" />
import mx.collections.ArrayCollection;
[Bindable]
public var dataSet:ArrayCollection;
[Bindable]
public var revenue:Number = 100;
private var t:Timer;
private function initData():void {
dataSet = new ArrayCollection();
t = new Timer(500);
}
private function startApp():void {
t.addEventListener(TimerEvent.TIMER, addData);
t.start();
}
private function addData(e:Event):void {
/* Add a maximum of 100 data points before user has to click
the Start button again. */
if (dataSet.length > 100) {
stopApp();
}
dataSet.addItem( { revenue: revenue } );
revenue += Math.random() * 10 - 5;
}
private function stopApp():void {
t.stop();
t.removeEventListener(TimerEvent.TIMER, addData);
}
displayName="Revenue" />