actionscript-3datagridflash-cs5.5

Flash Actionscript3: How to reset datagrid between frames


I use ActionScript3 in Flash Professional to build an animation in multiple frames.

The user has forward and back buttons to navigate between frames. At a certain time, I introduce a datagrid (inserted from the editor) fill it with data and everything goes OK.

//Example frame 9

stop();

r7.removeAllColumns()

r7.addColumn("column1");
r7.addColumn("column2");
r7.addColumn("column3");

r7.addItem({column1:"A", "column2":"a1", "comumn3":"1"});
r7.addItem({column1:"B", "column2":"b1", "comumn3":"1"});

But each time the user goes back to the previous frame (frame 9) from (frame 10), the datagrid is refilled with the same rows again.
I used removeAllColumns() because without it, the same columns are appended to the existing ones.

Still the issues of rows not solved.

Here is the illustration:

frame9 from frame8:

enter image description here

frame9 from frame10:

enter image description here


Solution

  • Neither removeAll() alone nor removeAllColumns() alone will work.

    This is what solved my issue:

    r7.removeAll();
    r7.removeAllColumns();
    

    Here is the tests:
    1- Using only "removeAll()" enter image description here

    2- Using only "removeAllColumns()" enter image description here

    3- Using both "removeAll()" & "removeAllColumns()" enter image description here