I need to create a movieclip on the fly by coding, and then put it into datagrid.
Can anyone help me? I'll write the detail below.
On https://stackoverflow.com/a/2035638/1201144, thanks to George Profenza for providing an answer.
His answer can add predefined movieclip from library into the datagrid.
But I need to inherit that mc dynamically, then put tem into datagrid.
This is George's answer
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
var dp:DataProvider = new DataProvider();
//populate the provider, specifying the source (linkageID and frame of the clip to display)
for(var i:int = 0 ; i < 7; i++)
dp.addItem({data:{source:'Star',frame:i+1}, title:"clip Star at frame"+(i+1)+""});
var dataCol:DataGridColumn = new DataGridColumn("data");
dataCol.cellRenderer = ClipCell;var titleCol:DataGridColumn = new DataGridColumn("title");
var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn(dataCol);
myDataGrid.addColumn(titleCol);
myDataGrid.dataProvider = dp;
myDataGrid.rowHeight = 64;
myDataGrid.width = 500;
myDataGrid.rowCount = dp.length - 1;
addChild(myDataGrid);
Object Star was already designed in the library.
Let's say I need to inherit the 'Star' to 'LittleStar' and 'BigStar'. Then attach them to datagrid? The first row for littleStar and second row for the bigStar.
I have tried like:
var LittleStar:Star = new Star();
dp.addItem({data:{source:'LittleStar',frame:i+1}, title:"clip Star at frame"+(i+1)+""});
But I got error that LittleStar was not defined. What should I do?
Note: George has inherited ClipCell class from iCellRenderer. And use it to his datagrid.
Or anyone? – wily Feb 22 '12 at 19:45