Solved

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

Posted on 2003-12-02
5
199 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 210 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

828 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