Re: [Flashcoders] Loading string data in a file from a server

2009-04-22 Thread Sidney de Koning
No i cant use XML since eventually it will be a PLS file (Winamp  
Shoutcast), I wrote a library that parses a PLS file (Playlist file  
from Winamp Shoutcast server) (http://code.google.com/p/as3plsreader/)  
this all works fine from with AIR, IF I have the file already saved to  
local disk.


So my final test is to directly load the PLS from the shoutcast server.
That why i need to convert the event.target.data to a File... Cant i do:

var f:File = new File(event.target.data) ?

Do you have any other suggestion on how to do this?

Greets Sid


On Apr 21, 2009, at 11:58 PM, Muzak wrote:


And when you trace out you do get the contents of the file?


Yup, I saw file content in debug window.


If it does work, my question becomes something different;
How do i convert the loaded in data (one big string) to a File  
object ?


Use xml instead of text?


- Can i add data to a File Object?
- Can i create a new temporary File Object and and string data to it?


Nope and nope.
The data property of a File object is read only. Check the docs.
You typically use a File object in combination with a FileStream  
instance to read/write to disk.

http://livedocs.adobe.com/flex/3/langref/flash/filesystem/File.html
http://livedocs.adobe.com/flex/3/langref/flash/filesystem/FileStream.html


I save it in memory and pass it through to the rest.


Depends on what the rest is, but you can pass a File object  
around, just like any other object.


regards,
Muzak

- Original Message - From: Sidney de Koning sid...@funky-monkey.nl 


To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Tuesday, April 21, 2009 4:49 PM
Subject: Re: [Flashcoders] Loading string data in a file from a server



Hi Muzak,
And when you trace out you do get the contents of the file?
Sid


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading string data in a file from a server

2009-04-22 Thread Karl DeSaulniers
Just a thought, but if it works when saved locally, could you maybe  
save it as a cookie on the users computer?

That may be a nice shortcut, since its just a playlist.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com

On Apr 22, 2009, at 2:44 AM, Sidney de Koning wrote:

No i cant use XML since eventually it will be a PLS file (Winamp  
Shoutcast), I wrote a library that parses a PLS file (Playlist file  
from Winamp Shoutcast server) (http://code.google.com/p/ 
as3plsreader/) this all works fine from with AIR, IF I have the  
file already saved to local disk.


So my final test is to directly load the PLS from the shoutcast  
server.
That why i need to convert the event.target.data to a File... Cant  
i do:


var f:File = new File(event.target.data) ?

Do you have any other suggestion on how to do this?

Greets Sid


On Apr 21, 2009, at 11:58 PM, Muzak wrote:


And when you trace out you do get the contents of the file?


Yup, I saw file content in debug window.


If it does work, my question becomes something different;
How do i convert the loaded in data (one big string) to a File  
object ?


Use xml instead of text?


- Can i add data to a File Object?
- Can i create a new temporary File Object and and string data to  
it?


Nope and nope.
The data property of a File object is read only. Check the docs.
You typically use a File object in combination with a FileStream  
instance to read/write to disk.

http://livedocs.adobe.com/flex/3/langref/flash/filesystem/File.html
http://livedocs.adobe.com/flex/3/langref/flash/filesystem/ 
FileStream.html



I save it in memory and pass it through to the rest.


Depends on what the rest is, but you can pass a File object  
around, just like any other object.


regards,
Muzak

- Original Message - From: Sidney de Koning  
sid...@funky-monkey.nl

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Tuesday, April 21, 2009 4:49 PM
Subject: Re: [Flashcoders] Loading string data in a file from a  
server




Hi Muzak,
And when you trace out you do get the contents of the file?
Sid


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading string data in a file from a server

2009-04-22 Thread Sidney de Koning

Thanks for the tip, i'll try this out.

Thanks, Sid


On Apr 22, 2009, at 10:36 AM, Karl DeSaulniers wrote:

Just a thought, but if it works when saved locally, could you maybe  
save it as a cookie on the users computer?

That may be a nice shortcut, since its just a playlist.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com

On Apr 22, 2009, at 2:44 AM, Sidney de Koning wrote:

No i cant use XML since eventually it will be a PLS file (Winamp  
Shoutcast), I wrote a library that parses a PLS file (Playlist file  
from Winamp Shoutcast server) (http://code.google.com/p/ 
as3plsreader/) this all works fine from with AIR, IF I have the  
file already saved to local disk.


So my final test is to directly load the PLS from the shoutcast  
server.
That why i need to convert the event.target.data to a File... Cant  
i do:


var f:File = new File(event.target.data) ?

Do you have any other suggestion on how to do this?

Greets Sid


On Apr 21, 2009, at 11:58 PM, Muzak wrote:


And when you trace out you do get the contents of the file?


Yup, I saw file content in debug window.


If it does work, my question becomes something different;
How do i convert the loaded in data (one big string) to a File  
object ?


Use xml instead of text?


- Can i add data to a File Object?
- Can i create a new temporary File Object and and string data to  
it?


Nope and nope.
The data property of a File object is read only. Check the docs.
You typically use a File object in combination with a FileStream  
instance to read/write to disk.

http://livedocs.adobe.com/flex/3/langref/flash/filesystem/File.html
http://livedocs.adobe.com/flex/3/langref/flash/filesystem/FileStream.html


I save it in memory and pass it through to the rest.


Depends on what the rest is, but you can pass a File object  
around, just like any other object.


regards,
Muzak

- Original Message - From: Sidney de Koning sid...@funky-monkey.nl 


To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Tuesday, April 21, 2009 4:49 PM
Subject: Re: [Flashcoders] Loading string data in a file from a  
server




Hi Muzak,
And when you trace out you do get the contents of the file?
Sid


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading string data in a file from a server

2009-04-22 Thread Muzak

Well it depends on what you're trying to do with the loaded data.
If all you want is to load it and write to disk, then the format doesn't really 
matter.

As mentioned earlier, to write the loaded data to disk you use a combination of 
a File instance and a FileStream instance.
Should be examples of that in the docs.

http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7e4a.html

The following will load the data, when loaded, ask where to save it, and then 
write that data to the file you selected.

  private var plsData:String;

  private function appInit():void {
   trace(Application ::: appInit);
   var plsURL:String = 
http://www.funky-monkey.nl/air/stringtest/serveFile.php;;
   var plsReq:URLRequest = new URLRequest( plsURL );
   var plsLoader:URLLoader = new URLLoader( plsReq );
   plsLoader.addEventListener( Event.COMPLETE , plsLoaded );
  }
  
  private function plsLoaded(evt:Event):void {

   trace(Application ::: plsLoaded);
   var value:String = plsData = evt.currentTarget.data;
   trace(value);
   var f:File = new File();
   f.addEventListener(Event.SELECT, fileSelectHandler);
   f.browseForSave(Save Data);
  }
  
  private function fileSelectHandler(evt:Event):void {

   trace(Application ::: fileSelectHandler);
   var f:File = evt.currentTarget as File;
   trace(- nativePath: , f.nativePath);
   // create filestream, open it and write data to file
   var fs:FileStream = new FileStream();
   fs.open(f, FileMode.WRITE);
   fs.writeUTFBytes(plsData);
   fs.close();
  }


- Original Message - 
From: Sidney de Koning sid...@funky-monkey.nl

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Wednesday, April 22, 2009 9:44 AM
Subject: Re: [Flashcoders] Loading string data in a file from a server


No i cant use XML since eventually it will be a PLS file (Winamp  
Shoutcast), I wrote a library that parses a PLS file (Playlist file  
from Winamp Shoutcast server) (http://code.google.com/p/as3plsreader/)  
this all works fine from with AIR, IF I have the file already saved to  
local disk.


So my final test is to directly load the PLS from the shoutcast server.
That why i need to convert the event.target.data to a File... Cant i do:

var f:File = new File(event.target.data) ?

Do you have any other suggestion on how to do this?

Greets Sid




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading string data in a file from a server

2009-04-22 Thread Sidney de Koning

Hi Muzak,

This is not exactly what i want to do but it comes close (and i cant  
test right now since i'm at work)
The whole 'prompt user for saving a file' i want to avoid, but the  
below code looks like what i wan to do:



  var f:File = evt.currentTarget as File;
  trace(- nativePath: , f.nativePath);
  // create filestream, open it and write data to file
  var fs:FileStream = new FileStream();
  fs.open(f, FileMode.WRITE);
  fs.writeUTFBytes(plsData);
  fs.close();


Thanks for the help, will let you know if it worked.

Sid


On Apr 22, 2009, at 2:32 PM, Muzak wrote:


Well it depends on what you're trying to do with the loaded data.
If all you want is to load it and write to disk, then the format  
doesn't really matter.


As mentioned earlier, to write the loaded data to disk you use a  
combination of a File instance and a FileStream instance.

Should be examples of that in the docs.

http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7e4a.html

The following will load the data, when loaded, ask where to save it,  
and then write that data to the file you selected.


 private var plsData:String;

 private function appInit():void {
  trace(Application ::: appInit);
  var plsURL:String = http://www.funky-monkey.nl/air/stringtest/serveFile.php 
;

  var plsReq:URLRequest = new URLRequest( plsURL );
  var plsLoader:URLLoader = new URLLoader( plsReq );
  plsLoader.addEventListener( Event.COMPLETE , plsLoaded );
 }
   private function plsLoaded(evt:Event):void {
  trace(Application ::: plsLoaded);
  var value:String = plsData = evt.currentTarget.data;
  trace(value);
  var f:File = new File();
  f.addEventListener(Event.SELECT, fileSelectHandler);
  f.browseForSave(Save Data);
 }
   private function fileSelectHandler(evt:Event):void {
  trace(Application ::: fileSelectHandler);
  var f:File = evt.currentTarget as File;
  trace(- nativePath: , f.nativePath);
  // create filestream, open it and write data to file
  var fs:FileStream = new FileStream();
  fs.open(f, FileMode.WRITE);
  fs.writeUTFBytes(plsData);
  fs.close();
 }


- Original Message - From: Sidney de Koning sid...@funky-monkey.nl 


To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Wednesday, April 22, 2009 9:44 AM
Subject: Re: [Flashcoders] Loading string data in a file from a server


No i cant use XML since eventually it will be a PLS file (Winamp   
Shoutcast), I wrote a library that parses a PLS file (Playlist  
file  from Winamp Shoutcast server) (http://code.google.com/p/as3plsreader/ 
)  this all works fine from with AIR, IF I have the file already  
saved to  local disk.
So my final test is to directly load the PLS from the shoutcast  
server.
That why i need to convert the event.target.data to a File... Cant  
i do:

var f:File = new File(event.target.data) ?
Do you have any other suggestion on how to do this?
Greets Sid


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading string data in a file from a server

2009-04-22 Thread Muzak

Well that was just an example :)

Here's how to do it without the save file dialog:

  private function plsLoaded(evt:Event):void {
   trace(Application ::: plsLoaded);
   var value:String = evt.currentTarget.data;
   trace(value);
   var f:File = File.desktopDirectory;
   f.url += /playlist.pls;
   trace(- url: , f.url);
   trace(- nativePath: , f.nativePath);
   var fs:FileStream = new FileStream();
   fs.open(f, FileMode.WRITE);
   fs.writeUTFBytes(plsData);
   fs.close();
  }

The above will create a file called playlist.pls on your desktop.

Some stuff on security:
http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7e5b.html
http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7e59.html


From the above:

quote
AIR applications cannot modify content using the app: URL scheme.
Also, the application directory may be read only because of administrator 
settings.

Unless there are administrator restrictions to the user's computer, AIR applications are privileged to write to any location on the 
user's hard drive.

Developers are advised to use the app-storage:/ path for local storage related 
to their application.
/quote

To get to the application storage directory rather than the desktop, in the 
above example, use:
   var f:File = File.applicationStorageDirectory;

regards,
Muzak

- Original Message - 
From: Sidney de Koning sid...@funky-monkey.nl

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Wednesday, April 22, 2009 3:37 PM
Subject: Re: [Flashcoders] Loading string data in a file from a server



Hi Muzak,

This is not exactly what i want to do but it comes close (and i cant  test 
right now since i'm at work)
The whole 'prompt user for saving a file' i want to avoid, but the  below code 
looks like what i wan to do:


  var f:File = evt.currentTarget as File;
  trace(- nativePath: , f.nativePath);
  // create filestream, open it and write data to file
  var fs:FileStream = new FileStream();
  fs.open(f, FileMode.WRITE);
  fs.writeUTFBytes(plsData);
  fs.close();


Thanks for the help, will let you know if it worked.

Sid




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading string data in a file from a server

2009-04-22 Thread Sidney de Koning
Then 'f' is the reference to the playlist.pls right? That one i can  
than pass through to my PLS reader?


This really helped me alot!
May I refer you to this image: 
http://www.aperturaphoto.com/blog/wp-content/uploads/2008/03/you-rock-you-rule.bmp

Thanks!
Sid

On Apr 22, 2009, at 5:25 PM, Muzak wrote:


Well that was just an example :)

Here's how to do it without the save file dialog:

 private function plsLoaded(evt:Event):void {
  trace(Application ::: plsLoaded);
  var value:String = evt.currentTarget.data;
  trace(value);
   var f:File = File.applicationStorageDirectory;
  f.url += /playlist.pls;
  trace(- url: , f.url);
  trace(- nativePath: , f.nativePath);
  var fs:FileStream = new FileStream();
  fs.open(f, FileMode.WRITE);
  fs.writeUTFBytes(plsData);
  fs.close();
 }

The above will create a file called playlist.pls on your desktop.

Some stuff on security:
http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7e5b.html
http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7e59.html


From the above:

quote
AIR applications cannot modify content using the app: URL scheme.
Also, the application directory may be read only because of  
administrator settings.


Unless there are administrator restrictions to the user's computer,  
AIR applications are privileged to write to any location on the  
user's hard drive.
Developers are advised to use the app-storage:/ path for local  
storage related to their application.

/quote

To get to the application storage directory rather than the desktop,  
in the above example, use:

  var f:File = File.applicationStorageDirectory;

regards,
Muzak

- Original Message - From: Sidney de Koning sid...@funky-monkey.nl 


To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Wednesday, April 22, 2009 3:37 PM
Subject: Re: [Flashcoders] Loading string data in a file from a server



Hi Muzak,

This is not exactly what i want to do but it comes close (and i  
cant  test right now since i'm at work)
The whole 'prompt user for saving a file' i want to avoid, but the   
below code looks like what i wan to do:



 var f:File = evt.currentTarget as File;
 trace(- nativePath: , f.nativePath);
 // create filestream, open it and write data to file
 var fs:FileStream = new FileStream();
 fs.open(f, FileMode.WRITE);
 fs.writeUTFBytes(plsData);
 fs.close();


Thanks for the help, will let you know if it worked.

Sid




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading string data in a file from a server

2009-04-21 Thread Sidney de Koning

Anybody?

I just want to know how to load an file from a server that holds  
string data (xml or txt file) without getting the 2032 error.


Please help,

Sid


On Apr 20, 2009, at 4:14 PM, Sidney de Koning wrote:


Hi List,

I want to load textfile from my own server from an AIR app but i  
keep getting a 2032 Error, a Stream Error. Event though when i load  
this from the browser it works.
The docs about this on the net are very limited. This is what i  
thought of so far:


- It could be a crossdomain error?
- I do handle all events?
- I tried a loading in a PHP file that uses fopen to serve me the file

Do anyone have any ideas? I just want to read in this text file ( or  
any other file with string data from my server ) or should i use  
FileStream to read in the file? Eventually the contents of the file  
i load in will will need to be a File Object ().


Thanks in advance,

Sidney

Below is my code:


var xmlURL:String = http://www.funky-monkey.nl/air/stringtest/serveFile.php 
;


var xmlReq:URLRequest = new URLRequest( xmlURL );
var xmlLoader:URLLoader = new URLLoader( xmlReq );

//listen for error events
xmlLoader.addEventListener( IOErrorEvent.IO_ERROR , onIOError );
xmlLoader.addEventListener( SecurityErrorEvent.SECURITY_ERROR ,  
onSecurityError );

xmlLoader.addEventListener( Event.COMPLETE , xmlLoaded );

function xmlLoaded(evt:Event):void {
trace( evt.target.data)
}

function onIOError(evt:IOErrorEvent):void {
trace( evt.text)
}

function onSecurityError(evt:SecurityErrorEvent):void {
trace( evt.text )
}


Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading string data in a file from a server

2009-04-21 Thread Ian Thomas
Hi Sid,
   It might be worth using a web traffic proxy such as Charles to make
sure that your AIR app is issuing a sensible HTTP request to the web
server i.e. that the thing you have which works in the browser is
actually the same as the request issued by the AIR app. I'm not sure
this can be a security error if you're not getting a security error
thrown?

  It's not something like the web server issuing a redirect, is it? So
browsing to that URL works fine, but accessing via a request from AIR
fails? Again, Charles could tell you.

http://www.charlesproxy.com/

HTH,
   Ian

On Tue, Apr 21, 2009 at 2:41 PM, Sidney de Koning
sid...@funky-monkey.nl wrote:
 Anybody?

 I just want to know how to load an file from a server that holds string data
 (xml or txt file) without getting the 2032 error.

 Please help,

 Sid


 On Apr 20, 2009, at 4:14 PM, Sidney de Koning wrote:

 Hi List,

 I want to load textfile from my own server from an AIR app but i keep
 getting a 2032 Error, a Stream Error. Event though when i load this from the
 browser it works.
 The docs about this on the net are very limited. This is what i thought of
 so far:

 - It could be a crossdomain error?
 - I do handle all events?
 - I tried a loading in a PHP file that uses fopen to serve me the file

 Do anyone have any ideas? I just want to read in this text file ( or any
 other file with string data from my server ) or should i use FileStream to
 read in the file? Eventually the contents of the file i load in will will
 need to be a File Object ().

 Thanks in advance,

 Sidney

 Below is my code:


 var xmlURL:String =
 http://www.funky-monkey.nl/air/stringtest/serveFile.php;;

 var xmlReq:URLRequest = new URLRequest( xmlURL );
 var xmlLoader:URLLoader = new URLLoader( xmlReq );

 //listen for error events
 xmlLoader.addEventListener( IOErrorEvent.IO_ERROR , onIOError );
 xmlLoader.addEventListener( SecurityErrorEvent.SECURITY_ERROR ,
 onSecurityError );
 xmlLoader.addEventListener( Event.COMPLETE , xmlLoaded );

 function xmlLoaded(evt:Event):void {
        trace( evt.target.data)
 }

 function onIOError(evt:IOErrorEvent):void {
        trace( evt.text)
 }

 function onSecurityError(evt:SecurityErrorEvent):void {
        trace( evt.text )
 }


 Sidney de Koning - be a geek, in rockstar style!
 Flash / AIR Developer @ www.funky-monkey.nl
 Technical Writer @ www.insideria.com

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Sidney de Koning - be a geek, in rockstar style!
 Flash / AIR Developer @ www.funky-monkey.nl
 Technical Writer @ www.insideria.com

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading string data in a file from a server

2009-04-21 Thread Muzak

Works fine here (Flex+Air).

- Original Message - 
From: Sidney de Koning sid...@funky-monkey.nl

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Tuesday, April 21, 2009 3:41 PM
Subject: Re: [Flashcoders] Loading string data in a file from a server



Anybody?

I just want to know how to load an file from a server that holds  
string data (xml or txt file) without getting the 2032 error.


Please help,

Sid


On Apr 20, 2009, at 4:14 PM, Sidney de Koning wrote:


Hi List,

I want to load textfile from my own server from an AIR app but i  
keep getting a 2032 Error, a Stream Error. Event though when i load  
this from the browser it works.
The docs about this on the net are very limited. This is what i  
thought of so far:


- It could be a crossdomain error?
- I do handle all events?
- I tried a loading in a PHP file that uses fopen to serve me the file

Do anyone have any ideas? I just want to read in this text file ( or  
any other file with string data from my server ) or should i use  
FileStream to read in the file? Eventually the contents of the file  
i load in will will need to be a File Object ().


Thanks in advance,

Sidney

Below is my code:


var xmlURL:String = http://www.funky-monkey.nl/air/stringtest/serveFile.php 
;


var xmlReq:URLRequest = new URLRequest( xmlURL );
var xmlLoader:URLLoader = new URLLoader( xmlReq );

//listen for error events
xmlLoader.addEventListener( IOErrorEvent.IO_ERROR , onIOError );
xmlLoader.addEventListener( SecurityErrorEvent.SECURITY_ERROR ,  
onSecurityError );

xmlLoader.addEventListener( Event.COMPLETE , xmlLoaded );

function xmlLoaded(evt:Event):void {
trace( evt.target.data)
}

function onIOError(evt:IOErrorEvent):void {
trace( evt.text)
}

function onSecurityError(evt:SecurityErrorEvent):void {
trace( evt.text )
}




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading string data in a file from a server

2009-04-21 Thread Sidney de Koning

Hi Muzak,

And when you trace out you do get the contents of the file?

Sid

On Apr 21, 2009, at 4:38 PM, Muzak wrote:


Works fine here (Flex+Air).

- Original Message - From: Sidney de Koning sid...@funky-monkey.nl 


To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Tuesday, April 21, 2009 3:41 PM
Subject: Re: [Flashcoders] Loading string data in a file from a server



Anybody?
I just want to know how to load an file from a server that holds   
string data (xml or txt file) without getting the 2032 error.

Please help,
Sid
On Apr 20, 2009, at 4:14 PM, Sidney de Koning wrote:

Hi List,

I want to load textfile from my own server from an AIR app but i   
keep getting a 2032 Error, a Stream Error. Event though when i  
load  this from the browser it works.
The docs about this on the net are very limited. This is what i   
thought of so far:


- It could be a crossdomain error?
- I do handle all events?
- I tried a loading in a PHP file that uses fopen to serve me the  
file


Do anyone have any ideas? I just want to read in this text file  
( or  any other file with string data from my server ) or should i  
use  FileStream to read in the file? Eventually the contents of  
the file  i load in will will need to be a File Object ().


Thanks in advance,

Sidney

Below is my code:


var xmlURL:String = http://www.funky-monkey.nl/air/stringtest/serveFile.php 
 ;


var xmlReq:URLRequest = new URLRequest( xmlURL );
var xmlLoader:URLLoader = new URLLoader( xmlReq );

//listen for error events
xmlLoader.addEventListener( IOErrorEvent.IO_ERROR , onIOError );
xmlLoader.addEventListener( SecurityErrorEvent.SECURITY_ERROR ,   
onSecurityError );

xmlLoader.addEventListener( Event.COMPLETE , xmlLoaded );

function xmlLoaded(evt:Event):void {
trace( evt.target.data)
}

function onIOError(evt:IOErrorEvent):void {
trace( evt.text)
}

function onSecurityError(evt:SecurityErrorEvent):void {
trace( evt.text )
}




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading string data in a file from a server

2009-04-21 Thread Sidney de Koning

If it does work, my question becomes something different;

How do i convert the loaded in data (one big string) to a File object ?

Greet Sidney

On Apr 21, 2009, at 4:38 PM, Muzak wrote:


Works fine here (Flex+Air).

- Original Message - From: Sidney de Koning sid...@funky-monkey.nl 


To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Tuesday, April 21, 2009 3:41 PM
Subject: Re: [Flashcoders] Loading string data in a file from a server



Anybody?
I just want to know how to load an file from a server that holds   
string data (xml or txt file) without getting the 2032 error.

Please help,
Sid
On Apr 20, 2009, at 4:14 PM, Sidney de Koning wrote:

Hi List,

I want to load textfile from my own server from an AIR app but i   
keep getting a 2032 Error, a Stream Error. Event though when i  
load  this from the browser it works.
The docs about this on the net are very limited. This is what i   
thought of so far:


- It could be a crossdomain error?
- I do handle all events?
- I tried a loading in a PHP file that uses fopen to serve me the  
file


Do anyone have any ideas? I just want to read in this text file  
( or  any other file with string data from my server ) or should i  
use  FileStream to read in the file? Eventually the contents of  
the file  i load in will will need to be a File Object ().


Thanks in advance,

Sidney

Below is my code:


var xmlURL:String = http://www.funky-monkey.nl/air/stringtest/serveFile.php 
 ;


var xmlReq:URLRequest = new URLRequest( xmlURL );
var xmlLoader:URLLoader = new URLLoader( xmlReq );

//listen for error events
xmlLoader.addEventListener( IOErrorEvent.IO_ERROR , onIOError );
xmlLoader.addEventListener( SecurityErrorEvent.SECURITY_ERROR ,   
onSecurityError );

xmlLoader.addEventListener( Event.COMPLETE , xmlLoaded );

function xmlLoaded(evt:Event):void {
trace( evt.target.data)
}

function onIOError(evt:IOErrorEvent):void {
trace( evt.text)
}

function onSecurityError(evt:SecurityErrorEvent):void {
trace( evt.text )
}




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading string data in a file from a server

2009-04-21 Thread Sidney de Koning

Some things that pop to mind;

- Can i add data to a File Object?
- Can i create a new temporary File Object and and string data to it?  
I save it in memory and pass it through to the rest.


Hope you can hel me with this,

Greets,

Sid

On Apr 21, 2009, at 4:38 PM, Muzak wrote:


Works fine here (Flex+Air).

- Original Message - From: Sidney de Koning sid...@funky-monkey.nl 


To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Tuesday, April 21, 2009 3:41 PM
Subject: Re: [Flashcoders] Loading string data in a file from a server



Anybody?
I just want to know how to load an file from a server that holds   
string data (xml or txt file) without getting the 2032 error.

Please help,
Sid
On Apr 20, 2009, at 4:14 PM, Sidney de Koning wrote:

Hi List,

I want to load textfile from my own server from an AIR app but i   
keep getting a 2032 Error, a Stream Error. Event though when i  
load  this from the browser it works.
The docs about this on the net are very limited. This is what i   
thought of so far:


- It could be a crossdomain error?
- I do handle all events?
- I tried a loading in a PHP file that uses fopen to serve me the  
file


Do anyone have any ideas? I just want to read in this text file  
( or  any other file with string data from my server ) or should i  
use  FileStream to read in the file? Eventually the contents of  
the file  i load in will will need to be a File Object ().


Thanks in advance,

Sidney

Below is my code:


var xmlURL:String = http://www.funky-monkey.nl/air/stringtest/serveFile.php 
 ;


var xmlReq:URLRequest = new URLRequest( xmlURL );
var xmlLoader:URLLoader = new URLLoader( xmlReq );

//listen for error events
xmlLoader.addEventListener( IOErrorEvent.IO_ERROR , onIOError );
xmlLoader.addEventListener( SecurityErrorEvent.SECURITY_ERROR ,   
onSecurityError );

xmlLoader.addEventListener( Event.COMPLETE , xmlLoaded );

function xmlLoaded(evt:Event):void {
trace( evt.target.data)
}

function onIOError(evt:IOErrorEvent):void {
trace( evt.text)
}

function onSecurityError(evt:SecurityErrorEvent):void {
trace( evt.text )
}




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Loading string data in a file from a server

2009-04-21 Thread Muzak

And when you trace out you do get the contents of the file?


Yup, I saw file content in debug window.


If it does work, my question becomes something different;
How do i convert the loaded in data (one big string) to a File object ?


Use xml instead of text?


- Can i add data to a File Object?
- Can i create a new temporary File Object and and string data to it?  


Nope and nope.
The data property of a File object is read only. Check the docs.
You typically use a File object in combination with a FileStream instance to 
read/write to disk.
http://livedocs.adobe.com/flex/3/langref/flash/filesystem/File.html
http://livedocs.adobe.com/flex/3/langref/flash/filesystem/FileStream.html


I save it in memory and pass it through to the rest.


Depends on what the rest is, but you can pass a File object around, just like 
any other object.

regards,
Muzak

- Original Message - 
From: Sidney de Koning sid...@funky-monkey.nl

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Tuesday, April 21, 2009 4:49 PM
Subject: Re: [Flashcoders] Loading string data in a file from a server



Hi Muzak,

And when you trace out you do get the contents of the file?

Sid



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Loading string data in a file from a server

2009-04-20 Thread Sidney de Koning

Hi List,

I want to load textfile from my own server from an AIR app but i keep  
getting a 2032 Error, a Stream Error. Event though when i load this  
from the browser it works.
The docs about this on the net are very limited. This is what i  
thought of so far:


- It could be a crossdomain error?
- I do handle all events?
- I tried a loading in a PHP file that uses fopen to serve me the file

Do anyone have any ideas? I just want to read in this text file ( or  
any other file with string data from my server ) or should i use  
FileStream to read in the file? Eventually the contents of the file i  
load in will will need to be a File Object ().


Thanks in advance,

Sidney

Below is my code:


var xmlURL:String = http://www.funky-monkey.nl/air/stringtest/serveFile.php 
;


var xmlReq:URLRequest = new URLRequest( xmlURL );
var xmlLoader:URLLoader = new URLLoader( xmlReq );

//listen for error events
xmlLoader.addEventListener( IOErrorEvent.IO_ERROR , onIOError );
xmlLoader.addEventListener( SecurityErrorEvent.SECURITY_ERROR ,  
onSecurityError );

xmlLoader.addEventListener( Event.COMPLETE , xmlLoaded );

function xmlLoaded(evt:Event):void {
trace( evt.target.data)
}

function onIOError(evt:IOErrorEvent):void {
trace( evt.text)
}

function onSecurityError(evt:SecurityErrorEvent):void {
trace( evt.text )
}


Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders