Barry, thank you so very much for your willingness to help and for 
providing some code.  I tried loading this into a test project and 
ran into a number of problems/questions.  
1) I don't see in the code where you construct, write out and .flush 
any xml into your local SharedObject.  Would that be questionaire??
2) I don't understand the getNewSession method...don't know what the 
xmlLocation is, and don't see the xmlRequest instantiated anywhere, 
don't know where the .send is sending to and what I should set up 
for my test.

Again I VERY much appreciate your patience and willingness to help a 
newbie.  Hope I'm not being too dim a bulb here.

Anne


--- In [email protected], "barry.beattie" 
<[EMAIL PROTECTED]> wrote:
>
> I've just (well, 3:00 am this morning) got XML saving and re-
reading
> back in. I played it safe and .toString()'d it before save but 
it'll
> probably work without it.
> 
> here's the whole of my fetching of data, inc the getting and 
saving of
> the XML as an LocalSO.
> 
> I hope it helps you.
> 
> cheers
> b
> 
> (PS: if you see any dodgy coding and can offer advice pls do.)
> 
> <mx:Script>
>       <![CDATA[
> 
>       public var localSO:SharedObject =
> SharedObject.getLocal("lsoQuestionaire"); 
> 
>       public function init():void
>       {
>       //localSO.data.saveDate = new Date(); // testing only
>                       ExternalInterface.addCallback
("onBrowserClose", onBrowserClose);
>                       trace("init called");
>                       if (localSO.size)
>                       {
>                               Alert.yesLabel = "Use Previous 
Session";
>                               Alert.noLabel = "Replace With New 
Session";
>                               Alert.buttonWidth = 150;
>                               Alert.show("You have a previous 
session. Would you like to load
> it?","Questionaire Session Selection",Alert.YES|Alert.NO,this,
> onChoseSession);              
>                       }
>                       else
>                       {
>                               getNewSession()
>                       }
>                       // that gets the data, now lets set up the 
persist
>               }
>               
>               public function onChoseSession(event:CloseEvent):void
>               {
>                       if (event.detail == Alert.YES)
>                       {
>                               loadPreviousSession();
>                       }
>                       else
>                       {
>                               getNewSession();
>                       }
>               }
>               
>               public function getNewSession():void
>               {
>               xmlRequest.url = xmlLocation;
>               xmlRequest.method = "GET";
>               xmlRequest.resultFormat = "e4x"; 
>                       xmlRequest.addEventListener
(ResultEvent.RESULT,onResultReturn);
>                       xmlRequest.addEventListener
(FaultEvent.FAULT, onResultFault);
>               trace("5. requesting XML now from " + xmlLocation);
>               xmlRequest.send();                              
>               }
>               
>               public function loadPreviousSession():void
>               {
>                       // get XML from Local Shared Object
>                       trace("1. loadPreviousSession called");
>                       try
>                       {
>                               questionaire = new XML
(localSO.data.questionaire);
>                               trace("2. got data");
>                               trace(questionaire.toXMLString());
>                               
>                       }
>                       catch(e:Error)
>                       {
>                               trace("3. error on 
loadPreviousSession");
>                               trace(e.message.toString());
>                               trace("4. go to getNewSession()");
>                               getNewSession();                
                
>                       }
>               }
>               
>               public function onResultReturn
(event:ResultEvent):void
>               {
>                       trace("6. onResultReturn called");
>                       questionaire = new XML(event.result);
>                       trace(questionaire.toXMLString());
>                       lastIndex = 
questionaire.section.subsection.children().length()-1;
> // zero-based index/arrays!
>                       first(); // move to the first question to 
start
>               }
>       
>               public function onResultFault(event:FaultEvent):void
>               {
>                       trace("7. onResultFault called:" + 
event.toString())
>                       mx.controls.Alert("ERROR: Could not load XML 
questions");
>               }
>               private function onBrowserClose():void
>               {
>                       Alert.show("browser is closing");
>                       localSO.data.questionaire = 
questionaire.toXMLString();
>               }
>       ]]>
> </mx:Script>
>


Reply via email to