Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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 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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now