Skip to main content
February 25, 2013
Question

Embedding Flash swf in Google Site displays NaN output but works in Debug mode

  • February 25, 2013
  • 1 reply
  • 1144 views

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;

          }

}

;

This topic has been closed for replies.

1 reply

Nabren
Inspiring
February 25, 2013

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?

February 25, 2013

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?

February 25, 2013

Close, but how is the success boolean being set? Also, do you get that output statement when running from the Google Page?


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!