Solved

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

Posted on 2003-12-02
5
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
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…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

623 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