Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Pulling data from an ASP page and using the variables in ActionScript.

Posted on 2003-12-02
5
Medium Priority
?
204 Views
Last Modified: 2010-04-03
I'm building a little application in Flash MX 2004, i'm fetching information from an asp page using loadvariablesnum().  How can i take the data from the ASP page, and set this data to variables, so that i can use it in the actionscript code?

I want to grab the variables bytes and tbytes from the asp page and use it in this script.
The ASP page outputs the following: (Example)
bytes=4000&tbytes=50000

Flash ActionScript:
bytes_loaded = Math.round(bytes);
bytes_total = Math.round(tbytes);
getPercent = bytes_loaded/bytes_total;
_root.loadBar._width = getPercent*100;
_root.loadText = Math.round(getPercent*100)+"%";

Thanks!
0
Comment
Question by:magicmike
  • 3
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
negatyve earned 840 total points
ID: 9863294
data_var = new LoadVars();
data_var.path = this;
data_var.onLoad = function(success)
{
          if(success){
                    this.path.bytes_loaded = Math.round(Number(this.bytes));
                    this.path.bytes_total = Math.round(Number(tbytes));
                    // from now on, the two variables are defined in the timeline
                    // where this code lies
          } else {
                    trace("ASP PAGE NOT FOUND");
          }
};
data_var.load("your_page.asp");
0
 

Author Comment

by:magicmike
ID: 9864064
This is what i put in, and its outputting "Infinity"

data_var = new LoadVars();
data_var.path = this;
data_var.onLoad = function(success)
{
      if(success){
            this.path.bytes_loaded = Math.round(Number(this.bytes));
            this.path.bytes_total = Math.round(Number(tbytes));
            getPercent = bytes_loaded/bytes_total;
            _root.loadBar._width = getPercent*100;
            _root.loadText = Math.round(getPercent*100)+"%";
      } else {
            trace("ASP PAGE NOT FOUND");
      }
};
data_var.load("getpercent.asp?dummyVar=" add getTimer());

instead of this.bytes and tbytes, i plugged numbers in and it worked fine, just doesnt seem to get the data from the asp file correctly.  The asp file is hard coded to output the same as the example, for now:
bytes=4000&tbytes=50000

So, whats up?
0
 

Author Comment

by:magicmike
ID: 9865000
this is strange... but i changed the order...  changed it to tbytes=50000&bytes=4000 in the asp file and it started working...  no idea... lol
0
 
LVL 27

Expert Comment

by:negatyve
ID: 9865217
You should try to output something like this, just to "delimit" the values:

&bytes=4000&tbytes=50000&
0
 

Author Comment

by:magicmike
ID: 9871324
i did, didnt help
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question