(FlashMX2004) by aemkei

i've tried to use the outputPanel.save( fileURI) command and was wondering, why nothing happend. ok, it works if you use a simple URI, like "file:///D:test.log" but if there are special characters like spaces or hashs in it you will run into a problem. solution is, to break the path into different parts an make them url encoded:

function getDirectory(doc){

   var lastSlash = doc.path.lastIndexOf("\");    var temp = doc.path.substr(0, lastSlash).split("\");

   // format directory path url encoded    for (var i=1; i<temp.length; i++) temp[i] = escape(temp[i]);    return "file:///" + temp.join("/") + "/"; }

function saveTextToFile(text2save, fileName){

   var fileURI = getDirectory(flash.getDocumentDOM()) + fileName;

   var myOutput = flash.outputPanel;

   // clear, trace, save, and hide output;    myOutput.clear();    myOutput.trace(text2save);    myOutput.save(fileURI, false);    myOutput.clear();

   myOutput.trace(fileURI + " saved") }

// example, that saves a file in the document directory saveTextToFile("this is a basic jsfl example", "example.txt");


 
comment    
flashguru @  9/16/03, 12:41 AM:

u can use the encodeURI(str) command, to create an encoded uri suitable for JSFL.


 
mbd @  1/2/04, 10:27 PM:

encodeURI only works for me if the path is not very long. I haven't worked out the exact length where it fails, but if the path is too large, Flash MX Pro 2004 crashes, first complaining about out of memory and then I get the "Memory cannot be read from..." error from Windows. (Windows 2000 SP3)

I'm using a similar approach to the one documented above, in Flash.


 


Online for 7125 days
Active across Europe: Hamburg,
Weimar, Berlin, Dresden, Moscow
status
Youre not logged in ... Login
menu
... home
... bookmarks
... topics

... mizu feed
search
search
recent updates
Sebastiano Comix Damerisano rettet die Musikbranche gleich doppelt: Comixxx erfindet ein neues Vertriebsmodell für Langspielplatten. Ein wirklich genialer Schachzug des umtriebigen Berliners mit Plauener Wurzeln: Platte im Bundle mit Pizza, für Kenner kurz und schlicht "P'n'P". Die Mechanik verblüfft: ein Anruf bei der lokalen Pizzeria reicht, einfach Lieblingspizza bestellen, z.B. Nr ...
by sol @ 12/13/14, 7:50 AM
=(>.<)=
by aemkei @ 12/11/14, 5:14 PM
Great one via the stellar Boing Boing. Mizubitchy- Quality Kitten Pix since 2003.
by sol @ 12/11/14, 5:09 PM
FIXED!
by sol @ 12/4/14, 3:41 PM
Ich finde keinen Knopf die Notifications abzustellen! Hilfe!
by Malfatti @ 12/4/14, 12:53 PM
Moinsen Junkens, wie schaumer aus? Heute habe ich mal die Bildschirmlupe eingeschaltet und ich muss sagen, so gehts ganz gut. Auch voll schön mal wieder HTML Tags zu benutzen und in so ein kleines, schrubbliges HMTL Formular zu schreiben. Irgendwie süß. Aber: es geht heute um was ganz anderes. In eigener Sache. ...
by sol @ 12/4/14, 12:50 PM
Ja wie krass, oder?? THE SHOW MUST GO ON. TILDE CLUB.
by sol @ 12/4/14, 12:41 PM
OMG! Ich hab grad von hinten angefangen zu lesen. So viel cooler Stuff aus der Zukunft!
by aemkei @ 12/4/14, 11:48 AM
Du hast jetzt Rechte!
by sol @ 12/4/14, 11:32 AM
You got it, Holmes!
by sol @ 12/3/14, 9:40 PM