views:

790

answers:

3

Hi, I am doing flash project(adobe flash cs4 proffesional) which run in browser with flsh player 10.. i need to implement error logging in text file.

in my project i have try catch statement while catching the error i need to pass that error and write in text file...

how to do it from browser. ,pls provide any example or link related to this topic.

Thanks in advance

A: 

Flash Security sandboxing means that you cannot write to an arbitrary file on the local disk.

If this is just for debugging purposes, I suggest using the old fscommand("trace",. "your message"); to post the information to the hosting browser. In the HTML page hosting your SWF, add some Javascript to listen to the OnFSCommand event from the SWF object, and then use some DIV to append the trace text, or just alert() if it is not too much info.

If you really want to write a file, consider using AIR, as then you can use the FileStream object

JBRWilkinson
The ExternalInterface class would be a much better choice here.
Lillemanden
Does that work in all browsers?
JBRWilkinson
+1  A: 

Do you want to log this information on the user's computer or on a server? Or maybe on your computer?

If you want to log onto a server, you need some kind of server-side script (php, asp, whatever) to send your data from flash to the server. This is a solution, but it's not super optimal, since you would create a http request each time there's an error.

You can also take a look at SOS from Powerflasher. I've never used it but I think it might do what you want.

Finally, if you just want to see those error as a debugging tool, well there's a bunch of option for you. Basicaly you will use the trace function and use some tool to read the file where those "traces" are logged. Such tools are ThunderboltAS3 or Flash tracer. Sometimes those tool will require you to use something else than the trace function to provide greater control over your message.

Subb
A: 

I would use a Flash-PHP interface called AMFPHP. You basically set up a PHP script which takes a string/array/object input and writes that output to a file. You can then call the PHP function and pass the data from Flash. There are some tutorials that show how easily it is to get set up with AMFPHP.

http://www.amfphp.org/

Jeremy White