Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2003-12-02
5
Medium Priority
?
203 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 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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 last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
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.

660 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