Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Actionscripting

Categories Creating dynamic charts from an external file
Author: Sas Jacobs | Website: http://www.sasjacobs.com |

 
Page 4
«prev 1 2 3 4 5 6 7 8 next»

Connecting to the data file

Now that the movie is set up, it's time to talk to the data file!

Create a third layer called Actions and enter the following on the first frame:

//load the text file
var loading = new loadVars();
loading.load("text.asp");

Replace the filename text.asp with the name of your file. When you reference the variables from the file, you'll need to refer to them using:

loading.variablename

You need to make sure that the data file has been loaded before you can start working with the variables. Add the following code on frame two of the actions layer to test whether the file is loaded.

loading.onLoad = function() {
if (loading.End == 1) {
gotoAndPlay("end");
}
else {
gotoAndPlay("start")
}
}

When the End variable has a value of 1, the whole file has been loaded. If the file is loaded, we move to the end frame with the chart.

Place a stop action on frame three.

Note: If you want to check that your data has loaded successfully into Flash, use trace to display a variable as shown below. Replace ChartValues with the name of one of your data file variables and add to the third frame. The value of the variable should display. If you see the word undefined, you know that something has gone wrong and that the data hasn't loaded!
trace(loading.ChartValues);

«prev 1 2 3 4 5 6 7 8 next»

» Level Intermediate

Added: : 2002-07-14
Rating: 7.65 Votes: 27
Hits: 1752
» Author
Applications Developer Marconi Australia
» Download
Download the files used in this tutorial.
Download (107 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers