views:

32

answers:

1

How can I find the path to the user's temp folder (e.g. C:\Users\lisnil\AppData\Local\Temp) from Flash/AS3? It needs to work on any version of Windows, at least XP, Vista and 7.

+1  A: 

You don't have access to the file system that way through Flash. You might be able to find it using Air (Look at: AIR access to file system)

CookieOfFortune
I don't know anything about AIR, can I use it from within my existing AS3 Flash?
Lizzan
AIR is a publish option in flash and it can be used to package up your swf file into something that can be ran on computers as a standalone application.
Richard
I don't want my flash as a standalone app, though, it's embedded in another app already. If I need a separated runtime for Air (which I seem to) I doubt it will work anyways. Thanks for the comment, though!
Lizzan
Then you will not, nor should you desire for any access that may compromise the security if your users.
CookieOfFortune
It's all running locally on the client's computer anyway, not even in a web page but in an AutoPlay Media Studio app (sort of like a C++ app, only easier to create and harder to get to do what I want). From what I gather from Flash's security model, I should be able to have access to the local file system or the internet, but not both. Here, I'd only need access to the file system. I'm pretty sure that I could read the text file from Flash if I could only find it, though...
Lizzan
Above referenced text file would be written by the host app in the user's temp folder as a means of communicating to the flash.
Lizzan
Hmmm... have you considered using AIR then? It might be something you can look into, otherwise you'd have to find another way to feed the file into Flash (Through localhost or something).
CookieOfFortune
If I were to use AIR I'd have to re-work the entire host app, which would probably take a lot of time, seeing as I've never worked with it before. Thanks for the suggestion, though, I may look into it in the future.
Lizzan
AIR is just Flash, but lets it run stand-alone, which sounds similar to what you're doing already.
CookieOfFortune
No, my Flash is not stand-alone, it's just one component embedded in a big .exe-file. Does AIR produce .swfs or does it have it's own format? Don't I need a special run-time for AIR? If not, I might be able to embed it in my AutoPlay Media Studio project.
Lizzan
Hmmm... I see what you mean, you might have to stick with Flash then. If your Flash has internet access, it might be easiest to send it data through localhost.
CookieOfFortune
No internet access, since it needs to be able to read XML-files which are in a defined place (actually, that exact place is what the text file would be telling the Flash about). For now, we've solved it by hard-coding several swfs with their own paths. Many thanks for your ideas CookieOfFortune, too bad that none have worked...=)
Lizzan