i m trying to make a drawing application. in this i have to save my drawing to server and after some time i can reload it in flash in editable format.
i am using jpgenoder for encoding than convert that bytearry to base64 encodede string than i send it to server .
but when i reload that bytearray in flash it uneditable So plz can u tell me how to reload that bytearry in editable form
in am using this code
?public function sendToServer():String {
var canvasBmp:BitmapData=new BitmapData(_canvasWidth,_canvasHeight,false,0xFFFFFFFF);
canvasBmp.draw(container);
? var jpgEncoder:JPGEncoder=new JPGEncoder(80);
var jpgStream:ByteArray=jpgEncoder.encode(canvasBmp);
var byteArrayAsString:String=Base64.encodeByteArray(jpgStream);
return byteArrayAsString;
?}
?public function drawingCanvas(xml) {
xmlLoader = new URLLoader();
xmlData= new XML();
xmlLoader.addEventListener(Event.COMPLETE, onComplete);
xmlLoader.load(new URLRequest(''test1.xml''));
?}
?public function onComplete(event:Event) {
testtxt2.text=event.target.data;
_xmlResponse=new XML(event.target.data);
readXMLData(_xmlResponse);
?}
?public function readXMLData(xml) {
id=xml.@ID;
status=xml.@Status;
Owner=xml.@Owner;
canvasData=xml.@canvas;
for (var i=0; i%26lt;3; i++) {
?_layerId[i]=xml.Layers.Layer[i].@id;
?_OccupiedBy[i]=xml.Layers.Layer[i].@OccupiedBy;
?_HashValue[i]=xml.Layers.Layer[i].@HashValue;
?_layerContent[i]=xml.Layers.Layer[i];
?
}
var decodeStr:String=_layerContent[0].toString();
var byteArr:ByteArray=Base64.decodeToByteArray(decodeStr);
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
loader.loadBytes(byteArr);
?}
?public function onImageLoaded(e:Event):void {
container.addChild(loader);
testtxt2.text+=''\n loader.height''+loader.height;
trace(loader.width + '' : '' + loader.height);
?}
byte Arrya to bitmapHi Bindu,
I guess once loaded the Image will not be editable directly, but you can draw more over this image.
Do you want to save your Image so that you can reselect the objects like Rectangle/circle and so on???
Is that your problem? If it is then don't save the drawing as an JPG instead save the XML with the list of all shapes and their sizes and positions
and redraw them within flash when an image request is encountered. That will be more helpful
byte Arrya to bitmaphow to implement this
Tell me your requirements I will give you an Idea.
What all shapes are you?using are you using any images as objects etc...
i m not using any particular shape i have to use drawing tool like pen pencil to draw . anf drawing i have to save it on server
Whats the Idea in Editing then???
You won't be able to edit the Image directly but you can draw the lines on any movieclip.
So what I will do is add 2 movie clips in a parent movieclip. One which is below the other will have the image loaded in it and you will actaully draw the lines with paint brush/pen in the movieclip above this and when saving the image get the bitmap data for the parent movieclip thats all...
I guess this will help....
No comments:
Post a Comment