Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

things start before variables have been loaded from a text file

Posted on 2002-07-10
5
Medium Priority
?
173 Views
Last Modified: 2010-04-03
I am loading around 1,000 variables from a text file. I am copying a movieclip 1,000 times and assigning the copied movieclips with a variable from the text file.

ie: mc1    varBat = 1
    mc2    varBat = 45
    mc1000 varBat = 12.5

varbat is taken from the text file.

my problem is flash starts to assign the variables before the text file is loaded (see code below). At the moment I load the text file and then have to click a button to copy the variables to the movieclips. I would like to do this as the movieloads.

loadVariables ("flash/1998bathy.txt","_root.mcChart");

var i = 0;

 do {
      i++;

      varBatNew = "varbat" + i
     newClip = "mc"+i;
      duplicateMovieClip ("_parent.mc", newClip, 2000-i);
      varSound = _root.mcchart[varBatNew].split(",");
      _root.mcChart[newClip]._x = convertE(varSound[0]);
      _root.mcChart[newClip]._y = convertN(varSound[1]);
      _root.mcChart[newClip].varDepth = varSound[2];
 } while (i<1071);

as you can see from my code my do loop isn't very effective. I know I have 1071 variables. Is there any way I van find out how many variables are stored in the text file as this fingure may change.

Any help greatly appreciated

0
Comment
Question by:neilwhite
  • 3
  • 2
5 Comments
 
LVL 2

Expert Comment

by:mousefist
ID: 7143728
hey again!  this may not be the best way, but try this:

put a variable at the very end of the text file named "finishedLoading", and set it to some value ...
&finishedLoading=yes&
or something to that effect.  in flash, load the text file:
_root.mcChart.finishedLoading = "no";
loadVariables ("flash/1998bathy.txt","_root.mcChart");

and then loop around waiting for finishedLoading == "yes".  this way you won't have to guess how many variables are in the file, because finishedLoading will always be the last one.  just make sure that when you loop around, you don't loop back to the point where you loaded the textfile.  

you'll probably have to have the loop inside of mcChart, because you have to have the instance of it available to load the variables into it, but you don't want to start executing the rest of it (the part that uses the variables) until they're loaded.  in that case, the load stuff can go into the movieclip's onLoad event, and you don't have to worry about calling it twice.  good luck,

b!
0
 

Author Comment

by:neilwhite
ID: 7145407
Unfortunaetly this does work.

When I do the Do Loop the flash gives me the message, A script in this movie is Cause flash to run slowly...

Am I doing anything wrong?

_root.mcChart.varFinished = "no";

loadVariables ("flash/1998bathy.txt","_root.mcChart");

var i = 0;

 do {
 
     if (_root.mcChart.varFinished == "yes"){
           //Stuff

     }

 } while (_root.mcChart.varFinished == "no");
0
 
LVL 2

Accepted Solution

by:
mousefist earned 800 total points
ID: 7148364

you don't want to use a statement to loop around and wait for something, flash doesn't like that.  it could take several seconds to load a large file in, and flash will think you've stuck it in an infinite loop by that time.  instead, put on frame 3:

if (_root.mcChart.varFinished != "yes") {
    this.gotoAndPlay(2);
} else {
    this.gotoAndPlay(4);
}

... really this is overkill to show you what's happening, all you really need to say is

if (_root.mcChart.varFinished != "yes") {
    this.gotoAndPlay(2);
}

the rest is implied.  sorry i wasn't clear about that ... timeline loops are your friend!  remember to put the loadVariables call outside of this timeline loop so that you don't loop back around and re-call that statement.  hope that helps,

m!  b?
0
 

Author Comment

by:neilwhite
ID: 7148456
Excellent again!!! Many thanks!
0
 

Author Comment

by:neilwhite
ID: 7332889
A bit late
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
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 how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
Suggested Courses

886 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