if you just want to convert movieclip or sprite to bytearray.....then take the bitmap snapshot of movieclip ....convert to bytearray
LOOK HERE: http://www.adobe.com/devnet/flash/quickstart/filereference_class_as3/ this uses ByteArray with JPGEncoder class On Tue, May 25, 2010 at 3:09 PM, Arindam Mojumder <[email protected]> wrote: > > Actually I am working on a online drawing/post card design application in > Actionscript 3.0. > There has an option to save data. Next time when user will login then he can > reedit the drawing again. > So I was thinking to convert the drawing palette as a bytesArray and save it > as a .txt file. So that In future I can reload the .txt file > and convert it to original movieClip/Sprite. I just don't want to go through > xml structure, bcoz it will make the application very complecated. > Is it possible to convert MvieClip or Sprite to ByteArray??? > I have a code to convert any swf file to bytesArray. and save it as a .txt > file and again load this .txt file with all the properties. > Below is my code, just copy paste it on the first frame. > > loadSwf();//---------- loading external swf file and convert it to bytesArray > and save it as a .txt file > //loadTxt();//---------loading the .txt file and display it on the stage with > the original property. > function loadSwf():void { > var bytes:ByteArray = new ByteArray (); > var ldr:URLLoader = new URLLoader(); > ldr.dataFormat = URLLoaderDataFormat.BINARY; > var req:URLRequest = new URLRequest("sample.swf"); > ldr.addEventListener(Event.COMPLETE, completeHandler); > ldr.load(req); > > function completeHandler(e:Event):void { > bytes=ldr.data; > var s:String=""; > for (var j : int = 0; j < bytes.length; j++) { > var n:String=bytes.readUnsignedByte().toString(16); > if (n.length<2) { > n="0"+n; > } > s+=n; > } > trace(s); > } > } > function loadTxt():void { > var ldr1:URLLoader = new URLLoader(); > var ldr:Loader=new Loader(); > var req:URLRequest = new URLRequest("swfBytes.txt"); > ldr1.addEventListener(Event.COMPLETE, completeHandler1); > ldr1.load(req); > function completeHandler1(e:Event):void { > var bA =new ByteArray (); > var data1:Array=ldr1.data.split(""); > var data2:Array=[]; > for (var i : int = 0; i < data1.length; i +=2) { > data2.push("0x"+data1 [i]+data1[i+1]); > } > for (var j : int = 0; j < data2.length; j ++) { > bA[j] = data2[j]; > } > ldr = new Loader (); > //ldr.contentLoaderInfo.addEventListener (Event.COMPLETE, completeHandler); > ldr.loadBytes(bA); > addChild(ldr); > } > } > > > > ----------------------------------------------------------------------- > With best regards > Arindam Mojumder > ----------------------------------------------------------------------- > Flickr:- http://www.flickr.com/photos/arindam-mojumder/sets/ > Facebook:- http://www.facebook.com/Arinda.Mojumder > Twitter:- http://twitter.com/arindam_arindam > Google Blog:- http://scripto-mania.blogspot.com/ > Wordpress-blog:- http://nilbristi.wordpress.com/ > ----------------------------------------------------------------------- > > -- > You received this message because you are subscribed to the Google Groups > "Flex India Community" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/flex_india?hl=en. -- You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.

