ok I finally manged to resolve the issue, though I am still not sure why it was occurring.

When in the writing SWF I moved the script away from the class file it was calling and just copy-pasted it into the calling object, it no loner was persistent... how odd...
:/
??

It would make more sense to encapsulate my SO in a seperate class file... but at least I have a solution.

I was initializing my SO file like this:

//...//
import com.Data.SO;
//...//
private var mySO:SO;
//...//
mySO = new SO ("movieQ","/",true);
//where the parameters are 'name',
//'path' and a boolean for if its an AS2 SO

//and then I was calling:

mySO.addEntry (entryValue);
//where entryValue is a new item to add to the array [see code below]


PHEW!!!


Seb.



sebastian wrote:
Thank you Iam for the information.

Seeing as I was already half done portiong over my XML reader into a SharedObject reader, I just went ahead and finished the code conversion...

However I am encountering one really frustrating issue, and I can't seem to find the solution...
:(

One of my SWFs writes to a SO, the other reads and deletes entries as they are read.

When I remove an entry from the SO {=SharedObject} in the reader SWF, it is NOT updated in the SO of the writing SWF unless I completely close the writing SWF (flash player) and re-open it. But I need the writing SWF to correctly share the SO with the reader so that they can both write and delete entries in the SO...

I have tried many solutions, here is my code with my failed solutions included:

//****************
//writing SWF:
//AS3:
public function addEntry (_entry:String) {

//tried to re-assign SO to another file every time I write to make it
//'refresh' the SO's values:
so = SharedObject.getLocal("bogus",localPath);

//tried here to make it re-read the SO every time I write but it still
//refuses to read in changed values:
so = SharedObject.getLocal("movieQ",localPath="/");

//i also tried making so a "var so" so that it was not persistent, but somehow it still remembers the values... enve if i make it a var!

if (!so.data.Qlist) {
    so.data.Qlist = [];
} else {
//debug this list ALWAYS has the same values and is never updated by the writing SWF:
    trace ("Qlist entries: " + so.data.Qlist);
}

if (_entry != "") {
    so.data.Qlist.push (_entry);
}

trace ("Qlist entries AFTER push: " + so.data.Qlist);
so.flush ();//saving to disk works fine, as the reader does see changes
so.close ();//tried this command in case it made it re-load the SO next time around, but even with close() it still doesn't re-read the SO... :(

}
//****************

the reader is very simple it just does this:

//****************
//reading SWF
//AS2

var so:SharedObject = SharedObject.getLocal("movieQ",localPath="/");

trace ("reading: " + so.data.Qlist);
//this always updates correctly if the writer adds an entry

so.data.Qlist.shift();

trace ("reading after shift: " + so.data.Qlist);
//this does remove an entry successfully from the SO
//but the writer does NOT update its reference to the SO UNLESS
//I close the writing SWF completely and re-open it...

so.flush();//saving data to disk...

//****************



If anyone can help I would be very grateful, not getting any joy here...
:(((((

Sebastian.


Ian Thomas wrote:
Sebastian,

You can achieve file writing and reading using one of the many
available flash wrappers.

I'd take a look at Northcode's SWFStudio:
http://www.northcode.com/swfstudio.php

or SWHX:
http://www.haxe.org/com/libs/swhx

Or Adobe's own AIR, but you would have to wrap your AS2 application in
some AS3 code to make it work.

HTH,
   Ian

On Thu, Aug 28, 2008 at 6:05 PM, sebastian <[EMAIL PROTECTED]> wrote:
ok well I haven't found any solutions for writing XML files to disk... how
weird is that???

I've decided to go ahead and reprogram the whole XML reader so that it reads
in SharedObjects instead... as I need to finish this project by Friday.

It took a little while to figure out I had to use localPath to share between SWFs and AMF0 encoding to share between AS3 and AS2, but I am on my way to success... quite the hassle, lost hours, but I think this is the only way?

Thanks,

Sebastian.

sebastian wrote:
Hello,

Been searching for answers and I was wondering what options there was for
saving local XML files; as this seems to be a stickler... (?)

I have two flash files; the two flash applications will run on different
screens connected to the same computer.

One of them is an already built application that I don't want to edit very
much, cause it's an ugly monster. Previously it loaded XML files from a
web-server [which collected SMS/text entries from users], but now it needs to read the XML file from the local disk where it is running and there is NO internet access anymore. As it reads items from the XML it needs to delete the entries. It's display is actually a very large projector/LCD mounted on
a wall for everyone to see.

The other application, which is connected to a touchscreen interface
[replacing the need for a user's mobile/cell phone], needs to generate lines
that feed into the same XML file the beast is reading, so that it can
generate a sort of queue for it to run through.

The original beast is in AS2 and messy [read: painful to edit any code],
the new touch screen is clean and in AS3. It's running on all on local
Window computers as a pair of dual full-screen projectors [.exe files], no
PHP facilities or local DB I'm afraid.

My question is:

* is there anyway at all to have these two applications read and
write/delete entries from the XML files?

* If not, what workarounds do I have at my disposal? Can I read/write to a
text file (*.txt) instead?

* I know "shared objects" exist, am I forced to use this in this
situation?

* finally, is there any 'smart' way to "lock" a file or have one of the
flash files prevent the other from writing/reading to the same file at the
same time? I don't know if this is an issue, but I could foresee file
corruption if both flash files try and write to a file at the same instant.

Thanks for your insight!!

With kind,

Sebastian.

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to