views:

13

answers:

2

I want to display a 20x20 grid of integer numbers in an AIR application. I am new to ActionScript and AIR, so I am not sure how I could go about doing this.

A: 

If you use Flex you could for example use a group with a tile layout. With following attributes:

requestedColumnCount="20"
requestedRowCount="20"

You could place the 400 integers as Label or use a DataGroup with this layout...

hering
Sounds interesting... Can you elaborate a little bit more? I'm a bit new to Flex and Actionscript.
samoz
+2  A: 

Because this isn't possible in a comment here a code example to elaborate it a little bit more:

Here is an example:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       creationComplete="init(event)">
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.events.FlexEvent;

        [Bindable]
        private var ints:ArrayCollection;

        protected function init(event:FlexEvent):void{
            ints = new ArrayCollection();
            for(var i:int = 0; i<199; i++){
                ints.addItem(Math.round(Math.random()*10));
            }
        }
    ]]>
</fx:Script>

<s:DataGroup width="100%" height="100%"
             dataProvider="{ints}"
             itemRenderer="spark.skins.spark.DefaultItemRenderer">
    <s:layout>
        <s:TileLayout
            requestedColumnCount="20"
            requestedRowCount="20" />
    </s:layout>
</s:DataGroup>

hering
Thanks! That helps a lot.
samoz

related questions