Real Time ArrayCollection : ArrayCollection « Data Model « Flex






Real Time ArrayCollection

Real Time ArrayCollection
            

<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->



    <!-- charts/RealTimeArrayCollection.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark"
    initialize="initTimer()" height="600">
    <fx:Script> 
        import flash.utils.Timer; 
        import flash.events.TimerEvent; 
        import mx.collections.ArrayCollection; 
        [Bindable] 
        public var memoryUsage:ArrayCollection = new ArrayCollection(); 
        public function initTimer():void { 
            // The first parameter in the Timer constructor 
            // is the interval, in milliseconds. 
            // The second parameter is how many times to run (0 is 
            // infinity). 
            var myTimer:Timer = new Timer(1000, 0); 
            // Add the listener for the timer event. 
            myTimer.addEventListener("timer", timerHandler); 
            myTimer.start(); 
        } 
        public function timerHandler(event:TimerEvent):void { 
            var o:Object = new Object(); 
            // Get the number of milliseconds since Flash Player or AIR started. 
            o.time = getTimer(); 
            // Get the total memory Flash Player or AIR is using. 
            o.memory = flash.system.System.totalMemory; 
            trace(o.time + ":" + o.memory); 
            // Add new object to the ArrayCollection, which is bound 
            // to the chart's data provider. 
            memoryUsage.addItem(o); 
        } 
      </fx:Script>
    <s:layout>
        <s:VerticalLayout />
    </s:layout>
    <s:Panel title="Memory Usage">
        <s:layout>
            <s:VerticalLayout />
        </s:layout>
        <mx:LineChart id="chart" dataProvider="{memoryUsage}"
            showDataTips="true">
            <mx:horizontalAxis>
                <mx:LinearAxis />
            </mx:horizontalAxis>
            <mx:verticalAxis>
                <mx:LinearAxis minimum="5000000" />
            </mx:verticalAxis>
            <mx:series>
                <mx:LineSeries yField="memory" />
            </mx:series>
        </mx:LineChart>
    </s:Panel>
</s:Application>

   
    
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Add element to ArrayCollection and bind to DataGridAdd element to ArrayCollection and bind to DataGrid
2.Define Array object and use it as source for ArrayCollectionDefine Array object and use it as source for ArrayCollection
3.Using an array of components to dispaly ButtonsUsing an array of components to dispaly Buttons
4.Initializing an ArrayCollection using MXML with embedded data
5.ArrayCollection is initialized with ActionScript
6.Using an ArrayCollection to feed the DataGrid's dataProviderUsing an ArrayCollection to feed the DataGrid's dataProvider
7.Using nested data in an ArrayCollection to display hierarchicallyUsing nested data in an ArrayCollection to display hierarchically
8.Filter and refresh function for ArrayCollectionFilter and refresh function for ArrayCollection
9.ArrayCollection data providerArrayCollection data provider
10.Use ActionScript to declare and create the ArrayCollection objectUse ActionScript to declare and create the ArrayCollection object
11.Insertion on the Array and ArrayCollectionInsertion on the Array and ArrayCollection
12.Sort ArrayCollectionSort ArrayCollection
13.Add item to ArrayCollectionAdd item to ArrayCollection
14.Remove item from ArrayCollection by indexRemove item from ArrayCollection by index
15.Update item in ArrayCollectionUpdate item in ArrayCollection
16.ArrayCollection collectionChange eventArrayCollection collectionChange event
17.Create ArrayCollection from ArrayCreate ArrayCollection from Array
18.Use Timer to add data to ArrayCollectionUse Timer to add data to ArrayCollection
19.Put random value to ArrayCollectionPut random value to ArrayCollection
20.Bind ArrayCollection to List and update ArrayCollection to change ListBind ArrayCollection to List and update ArrayCollection to change List
21.Use individual ArrayCollection elements as the source or a binding expressionUse individual ArrayCollection elements as the source or a binding expression
22.Get data from ArrayCollection by label fieldGet data from ArrayCollection by label field
23.Use Model as the source for ArrayCollection
24.Create ArrayCollection from Model with ActionScriptCreate ArrayCollection from Model with ActionScript
25.Get data frolm ArrayCollection by using index and property nameGet data frolm ArrayCollection by using index and property name
26.Using ArrayCollection to handle complex dataUsing ArrayCollection to handle complex data
27.Converting an MXML data model into an ArrayCollectionConverting an MXML data model into an ArrayCollection
28.Simple ArrayCollection
29.Add filter to ArrayCollectionAdd filter to ArrayCollection
30.Spark DropDownList with Static String ArrayCollectionSpark DropDownList with Static String ArrayCollection
31.An ArrayCollection object that is populated from a remote data sourceAn ArrayCollection object that is populated from a remote data source
32.Define ArrayCollection Of ObjectsDefine ArrayCollection Of Objects
33.Create an Array, and then converts it to an ArrayCollectionCreate an Array, and then converts it to an ArrayCollection
34.Use an tag to perform the conversionUse an <s:ArrayCollection> tag to perform the conversion
35.defines data providers as ArrayCollections.defines data providers as ArrayCollections.
36.Use ArrayCollection to store controlsUse ArrayCollection to store controls
37.A sorted view of a collectionA sorted view of a collection
38.Set item at third position to new valueSet item at third position to new value
39.Result of using insert() and remove() on the current propertyResult of using insert() and remove() on the current property