ByteArray - Save image

Saving the canvas

After creating the drawing we now want to save the canvas. We create a Button and give it some function. We have an if statement in case there is already a saved image displayed. Then we remove that. We create a SharedObject and then we save the ByteArray object bytes. Since the object may be large we use the flush() method.

var mc1:SaveBut = new SaveBut ();
mc1.x = 25;
mc1.y = 175;
this.buttonMode = true;
this.addChild (mc1);
mc1.addEventListener (MouseEvent.MOUSE_DOWN, saveHandler)
function saveHandler (event:MouseEvent):void
	if(this.getChildByName("bm") != null)
		this.removeChild (this.getChildByName("bm"));
	var my_so:SharedObject = SharedObject.getLocal ("kookie"); = bytes;

previous  |   next