flash on 2011-8-23

by cdubois75
♥1 | Line 28 | Modified 2011-08-23 06:36:52 | MIT License
play

ActionScript3 source code

/**
 * Copyright cdubois75 ( http://wonderfl.net/user/cdubois75 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/oxC5
 */

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute">
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.rpc.events.ResultEvent;
            import com.adobe.serialization.json.JSON;

            private function loadJSON():void
            {
                var aryData:Array = new Array();
                
                for(var i:int = 0; i < 1000000; i++)
                {
                    aryData.push(new Array("one" + i,"two" + i,"This is some long text to put in here"));
                }

                

                //create a new ArrayCollection passing the de-serialized Array
                //ArrayCollections work better as DataProviders, as they can
                //be watched for changes.
                var dp:ArrayCollection = new ArrayCollection(aryData);

                //pass the ArrayCollection to the DataGrid as its dataProvider.
                grid.dataProvider = dp;

            }
        ]]>
    </mx:Script>


    <mx:DataGrid id="grid" right="10" left="10" top="30" bottom="10" >
        <mx:columns>
            <mx:DataGridColumn headerText="Column 1" dataField="0"/>
            <mx:DataGridColumn headerText="Column 2" dataField="1"/>
            <mx:DataGridColumn headerText="Column 3" dataField="2"/>         
        </mx:columns>
    </mx:DataGrid>
    <mx:Button label="Click Me" click="loadJSON()"/>
</mx:Application>