<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:michaelvandaniker="com.michaelvandaniker.visualization.*" layout="vertical" enterFrame="handleEnterFrame(event)" viewSourceURL="srcview/index.html"> <mx:Script> <![CDATA[ import com.michaelvandaniker.visualization.GradientDictionary; import mx.collections.ArrayCollection; [Bindable] private var points:ArrayCollection = new ArrayCollection(); private const gradients:Array = [ GradientDictionary.THERMAL, GradientDictionary.RAINBOW, GradientDictionary.RED_WHITE_BLUE ]; private function handleEnterFrame(event:Event):void { if(heatMap.hitTestPoint(mouseX,mouseY)) { points.addItem(new Point(heatMap.mouseX,heatMap.mouseY)); if(points.length > 1000) points.removeItemAt(0); } } private function handleComboBoxChange(event:Event):void { heatMap.gradientArray = gradients[event.target.selectedIndex]; } ]]> </mx:Script> <michaelvandaniker:HeatMap id="heatMap" dataProvider="{points}" width="100%" height="100%" backgroundColor="0" backgroundAlpha="1"/> <mx:HBox> <mx:ComboBox id="gradientComboBox" dataProvider="{['Thermal','Rainbow','Happy Fourth of July']}" change="handleComboBoxChange(event)"/> <mx:Button click="{points.removeAll()}" label="Clear"/> </mx:HBox> <mx:HBox> <mx:Label text="Radius"/> <mx:HSlider id="slider" minimum="1" maximum="50" value="{heatMap.itemRadius}" snapInterval="1" liveDragging="true" change="heatMap.itemRadius = slider.value;"/> </mx:HBox> <mx:Label text="{points.length+' points'}"/> </mx:Application>