actionscript 3 - Programatically create grid in flex -


i'm trying learn flex right , i'm having troubles. want create new grid not in xml. want create in script section.

this code wrote:

<?xml version="1.0" encoding="utf-8"?> <mx:canvas xmlns:fx="http://ns.adobe.com/mxml/2009"            xmlns:s="library://ns.adobe.com/flex/spark"            xmlns:mx="library://ns.adobe.com/flex/mx"            xmlns:flextras="http://www.flextras.com/mxml"            width="1500" height="700">     <fx:declarations>         <!-- placer ici les éléments non visuels (services et objets de valeur, par exemple). -->     </fx:declarations>      <fx:script>         <![cdata[             import flash.sampler.newobjectsample;              import mx.containers.grid;             import mx.containers.griditem;             import mx.containers.gridrow;              import spark.components.button;             import spark.components.gridclasses.gridcolumn;              private var mygrid: grid;             private var gridrow : gridrow;             private var griditem : griditem;             private var mybutton : button;               private function init():void             {                 mygrid = new grid();                 gridrow = new gridrow();                 griditem = new griditem();                 mybutton = new button();                 mybutton.label = "hi guys !";                  griditem.addchild(mybutton);                 gridrow.addchild(griditem);                 mygrid.addchild(gridrow);                 mygrid.validatenow();             }          ]]>     </fx:script>  </mx:canvas> 

could show me i've done wrong?

you've added item row , row grid, haven't added grid canvas

this.addchild(mygrid); 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -