Hmmmm, still baffled.  I tried as you suggested and still can't seem 
to save the xml.  Also, you said "they do save the data type of a 
complext...."  Did you mean they do NOT save the type and when you 
read it back you just get type Object?  I thought that's what I read 
in the user guide and that you need to use something called 
registerClassAlias if you want to store a type.  I tried looking 
into this also and don't understand how to use this correctly.  I'm 
starting to get frustrated.

Anne
--- In [email protected], "Dimitrios Gianninas" 
<[EMAIL PROTECTED]> wrote:
>
> In your save and get methods, always init the mySO by doing "mySO 
= SharedObject.getLocal("testSO")"... I think you have to do this 
everytime.
> 
> Also I use SO as well and they do save the data type of a complex 
object when saving the object, so when u read it back, it is just of 
type Object. So careful with the XML.
> 
> Dimitrios Gianninas
> Optimal Payments Inc.
> 
> 
> 
> -----Original Message-----
> From: [email protected] on behalf of annespg
> Sent: Thu 5/24/2007 12:51 PM
> To: [email protected]
> Subject: [flexcoders] problems with storing XML in SharedObject
>  
> I just joined this forum hoping I might get an answer since 
traffic 
> on the Adobe Flex Forum seems pretty darn sparse.  I'm surprised 
> since the Flash Forum is so active one can get several answers 
> within hours and on the Flex Forum one can go months and never get 
> an answer.  At any rate...
> 
> I am trying to store some XML in the SharedObject, but it doesn't 
> seem to work. I think I'm getting it in there, but if I close the 
> app and then try to retrieve it, it is null. I have the following 
> test code. What the heck am I doing wrong?!?!?
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
> layout="absolute" creationComplete="init()">
> <mx:Script>
> <![CDATA[
> import valueObjects.CustomVO;
> import flash.net.registerClassAlias;
> 
> 
> private var mySO:SharedObject;
> private function init():void{
> mySO = SharedObject.getLocal("testSO");
> }
> 
> private function saveSO():void{
> var obj:CustomVO = new CustomVO("test string",12345);
> var tagname:String = "mytag"; 
> var x:XML = <{tagname} name={obj.name} id={obj.id}/>; 
> var test:CustomVO = CustomVO.buildCustomVOFromXML(x);
> trace (test); //this works fine, so my x:XML variable seems fine
> mySO.data.testString = obj.name;
> mySO.data.testXMLData = x;
> // the debugger shows the data is in mySO fine at this point
> mySO.flush();
> }
> private function getSO():void{
> //if I close the application and then launch again and invoke this
> //function the testString is there OK, but the testXMLData is null
> var theData:Object = mySO.data;
> var theXML:XML = mySO.data.testXMLData; //this comes back null
> trace(theData); // shows [object Object]
> trace(mySO.data.testString);// shows 'test string'
> trace("test xml data: "+theXML.toXMLString()); // shows no data 
> }
> private function removeSO():void{
> mySO.clear();
> }
> ]]>
> </mx:Script>
> <mx:Button x="175" y="101" label="Save SharedObject" click="saveSO
> ()"/>
> <mx:Button x="175" y="165" label="Retrieve SharedObject" 
click="getSO
> ()"/>
> <mx:Button x="175" y="235" label="Remove SharedObject" 
> click="removeSO()"/>
> 
> </mx:Application>
> 
> package valueObjects{
> [Bindable]
> public class CustomVO{
> public var name:String;
> public var id:Number;
> public var timeStamp:Number;
> 
> public function CustomVO(name:String,id:Number){
> this.name = name;
> this.id = id;
> this.timeStamp = new Date().milliseconds;
> }
> public function toString():String{
> return ("[CustomVO]" +name+","+id+","+timeStamp);
> }
> public static function buildCustomVOFromXML(item:XML):CustomVO{
> var v:CustomVO = new CustomVO([EMAIL PROTECTED], [EMAIL PROTECTED]);
> 
> return v;
> }
> }
> } 
> 
> 
> 
> -- 
> WARNING
> -------
> This electronic message and its attachments may contain 
confidential, proprietary or legally privileged information, which 
is solely for the use of the intended recipient.  No privilege or 
other rights are waived by any unintended transmission or 
unauthorized retransmission of this message.  If you are not the 
intended recipient of this message, or if you have received it in 
error, you should immediately stop reading this message and delete 
it and all attachments from your system.  The reading, distribution, 
copying or other use of this message or its attachments by 
unintended recipients is unauthorized and may be unlawful.  If you 
have received this e-mail in error, please notify the sender.
> 
> AVIS IMPORTANT
> --------------
> Ce message électronique et ses pièces jointes peuvent contenir des 
renseignements confidentiels, exclusifs ou légalement privilégiés 
destinés au seul usage du destinataire visé.  L'expéditeur original 
ne renonce à aucun privilège ou à aucun autre droit si le présent 
message a été transmis involontairement ou s'il est retransmis sans 
son autorisation.  Si vous n'êtes pas le destinataire visé du 
présent message ou si vous l'avez reçu par erreur, veuillez cesser 
immédiatement de le lire et le supprimer, ainsi que toutes ses 
pièces jointes, de votre système.  La lecture, la distribution, la 
copie ou tout autre usage du présent message ou de ses pièces 
jointes par des personnes autres que le destinataire visé ne sont 
pas autorisés et pourraient être illégaux.  Si vous avez reçu ce 
courrier électronique par erreur, veuillez en aviser l'expéditeur.
>


Reply via email to