# Bitmapdata array live updating

**URL:** <https://forum.kirupa.com/t/bitmapdata-array-live-updating/331676>\
**Category:** flash\
**Created:** [September 25, 2013, 8:11am UTC](https://forum.kirupa.com/t/bitmapdata-array-live-updating/331676 "2013-09-25T08:11:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![twigenator](https://avatars.discourse-cdn.com/v4/letter/t/a9adbd/32.png) [@twigenator](https://forum.kirupa.com/u/twigenator)\
**Post date:** [September 25, 2013, 8:11am UTC](https://forum.kirupa.com/t/bitmapdata-array-live-updating/331676/1 "2013-09-25T08:11:42Z")

</div>

explanation: im working on a drawing app for android and im stuck on a undo feature.  
the feature relies on a array of my layer arrays, each one added whenever someone makes a “pencil” stroke

I then, when the back button is pressed, delete my canvas and its data, then redraw with a old version(from the past) then delete the old version.

My problem is, whenever I add a new stroke every single, every value of my undo array is replaced with the new version.

my code:  
code for the adding of the stroke to the undo list:

```auto
stage.removeChild(temp);                    
this.addChild(path);
startdrawing=true
layerarray[0].draw(path,null,null,null,null,true);
path.parent.removeChild(path);
var templayers:Array= new Array(layerarray[0],layerarray[1])
undolist[undolist.length]=templayers

```

code for the canvas update:

```auto
if(e.keyCode==Keyboard.BACK){                
trace(undolist.length)
 trace(undolist[undolist.length-1])
trace(undolist[undolist.length-1][0].getPixel(0,0))

layerarray=new Array();
layerarray=undolist.pop()
display.parent.removeChild(display)
display=new MovieClip();
disparray=new Array();
disparray[0]=new Bitmap(layerarray[0]);
disparray[1]=new Bitmap(layerarray[1]);
display.name='hello world'
display.x=330;
display.y=100;
display.scaleX=0.7;
display.scaleY=0.7;
display.addChildAt(disparray[0],0)
display.addChildAt(disparray[1],1)
this.addChildAt(display,0); 
 }

```
