Copy link to clipboard
Copied
Hello,
I am loading a text file with three variables into a flash file (CS5). The flash file then calculates and prints the three values based on some calculations. I am storing the text file as an attachment on the google page in which I am embedding the swf file. What's weird is that the flash file plays correctly in debugging mode (i.e., prints the 3 variables correctly), but as soon as I upload the swf to the Google site page (as an attachment in the same location as the text file), the flash file outputs NaN. I am stuck as to why the file works in debug mode in Flash, but not when it's uploaded to the google site page. I have tried storing the text file on SharePoint and referencing it from there, but I get the same results when viewing the swf on the Google site page.
Is it because the google site page is using SSL?
I am fairly new to flash, so any help would be appreciated.
Thanks!
Lori
________________________
Variables.txt stores this: "current=6950&goal=7175&low=6950"
Here is the code in my flash file:
_global.getPercent = "";
myvars = new LoadVars();
myvars.load("variables.txt");
myvars.onLoad = function(success){
l = Number(myvars.low);
c = Number(myvars.current);
g = Number(myvars.goal);
getPercent = (c-l)/(g-l);
if (getPercent > 0) {
colorshow._height = (getPercent*colorshow._height);
} else {
colorshow._height = 0;
}
}
;
Copy link to clipboard
Copied
Are you positive the file is loading? Have you tried debugging and seeing what it loads for the file content before you start parsing the file?
Copy link to clipboard
Copied
I think so...if I comment out the parsing and add a trace, it displays the output correctly.
if(success){
trace("The low is "+myvars.low+", the current is "+myvars.current+" and our goal is "+myvars.goal+".");
} else {
trace("there was a problem loading the variables");
}
The output in flash displays:
The low is 6950, the current is 6950 and our goal is 7175.
Is that what you mean?
Copy link to clipboard
Copied
Close, but how is the success boolean being set? Also, do you get that output statement when running from the Google Page?
Copy link to clipboard
Copied
I have this in front of the trace:
myvars.onLoad = function(success){
When I put in the full URL to the attachment on the Google page (i.e., something similar to "myvars.load("https://sites.google.com/a/..../home/department-sites/sales/variables.txt,");" - instead of just "myvars.load("variables.txt");", it doesn't work. So right now its set to just "variables.txt" and the swf file is in the same root location as the variables.txt file on the Google page. I also have a copy of the variables.txt file in the same local directly in which I am running the flash file for testing. So I think when I run it in debug mode, its referencing the variables.txt file in the local directory, rather than the one stored as an attachment on the Google page.
That's what seems so weird...it runs locally in debug mode...but not when I embed it on the Google page. I can also get it to work if I explicity define the variables in the flash file, rather than rely on the external text file. That's the only time I can get it to work on the Google page.
Thank you for your help!
Copy link to clipboard
Copied
myvars.load("https://sites.google.com/a/..../home/department-sites/sales/variables. txt,");
If that is what you are actually using you have an extra comma after the .txt extension (in the event this was more than just a rough example)
I guess I am confused what exactly you are trying to do. (Run the entire thing off the Google Page, only load the .txt file off the Google Page, etc...)
One thing to make sure of is that you are not loading a cached file. Flash Builder sometimes caches files and I haven't figured out a way to clear that/disable it other than closing Flash Builder and restarting it.
Copy link to clipboard
Copied
Sorry for being confusing!
I want to run the entire thing from a Google page. So on a specific page, I have attached two files:
1. the variables.txt file
2. the .swf file from my flash project.
Then I am inserting a Google Embed gadget on the same page and embedding the .swf file. However, the swf file is printing NaN for the three variables in the .swf. The .swf file is loading the txt file using this:
myvars = new LoadVars();
myvars.load("variables.txt");
Locally on my machine, I have my flash project in a folder on my desktop along with a copy of the swf and the same variables.txt file. When I run the project in debug mode, it works and prints the 3 values correctly. So I am trying to figure out why uploading the files to the Google page and running them from the embed gadget doesn't work. But it works when it runs locally from my machine.
Copy link to clipboard
Copied
Gotcha. One thing to try is to load the page with Firefox and Firebug and see where your .swf is actually downloading from. Make sure it is the same directory as you expect the .txt file to be in.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now