Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent help on loadVars()

Status
Not open for further replies.

janicefoo

Programmer
Apr 17, 2003
53
0
0
MY
Dear gurus and members,

I am new in actionscript and programming. I would like to know whether is it possible to use loadVar() to load a txt file stored in user's computer. I created an application and a txt file that are stored in user's computer. When user clicks on Flash button on my website, the actionscript will load the txt file. If the txt does not exist, the actionscript will prompt a message to quest user download the application. Otherwise, the actionscript will run a javascript function which will launch the application on user's computer.

I managed to write the script but there's another problem. When I click on the button, it will open a popup window telling me that I don't have the program installed even if I have it. It can't read the text file. The script doesn't work when I browse the file through a URL. I don't know why. Could someone please guide me through? The following is the script used:

on (release) {
myLV = new LoadVars();
myLV.onLoad = function(success) {
if (success) {
//if file loaded
trace("loaded");
getURL("java script:eek:penRecorder();"); //open javascript function that calls an exe file on user's PC
} else {
//if file fails to load
trace("not loaded");
getURL("java script:dloadRecorder();");//URL to download Recorder program onto user's PC
}
};
myLV.load("file:///C:/Program%20Files/IEBAudioRecorder/test.txt");
}

This is the javascript function being called to launch the program from user's PC:

function loadRecorder() {
//loadexe()
location.href = "file:///C:/Program Files/IEBAudioRecorder/AudioRecorder.exe";
}

Looking forward to some replies soon.

Thanks in advance,
Janice
 
The problem is one of security - Flash can only load information from the same subdomain as the main movie. So trying to load of a harddrive will fail since the movie itself is on a remote server somewhere.

You could store the text as a cookie using a Flash local shared object instead though which might get you closer to a solution.
 
Hi wangbar,
Can you please explain more and detail about Flash local shared object? How can I use shared object for my problem? Looking forward to your reply soon.

Thanks in advance,
Janice
 
It works like a javascript cookie - allowing you to store a small package of data on the user's harddrive, here's a quick example which would allow you to set and retrieve a user's name for a log-in script:

Code:
setCookie = function (userName) {
	// retrieve object (create it if it's not already there)
	mySharedObject_so = SharedObject.getLocal('myData');
	// this is the data to add
	mySharedObject_so.data.userName = userName;
	// reset object with new data
	mySharedObject_so.flush();
};
//
getCookie = function () {
	// retrieve object
	mySharedObject_so = SharedObject.getLocal('myData');
	// get data
	return mySharedObject_so.data.userName;
};
 
Thanks wangbar,
So do you mean this small package of data will be removed if user clear his/her cache? Hope to hear from you soon.

Thanks in advance,
Janice
 
Hi wangbar,
What is a standard cache? Where is it stored? Is there any chance that the user might remove/delete the file? The code you posted earlier on, is a bit confusing, would appreciate if you could explain more. Sorry for the inconvenience. Looking forward to your reply soon.

Thanks in advance,
Janice
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top