Who has the biggest brain?

rudesgeiger
rudesgeiger used Ask the Experts™
on
let's see you has the big brains?  What is wrong with my code.  Why does the bytes come back undefined...

var movieArray = ["volume.swf", "yellowdogworks.swf", "main.swf", "pricing.swf", "gallery.swf"];
var i = 0;

while(i < 5){
     loadMovie(movieArray[i], _root);
     trace(i);
     trace(movieArray[i]);

     bytesLoaded = eval(_root.getBytesLoaded());
     bytesTotal = eval(_root.getBytesTotal());
     trace(bytesLoaded);
     trace(bytesTotal);
     
     if (bytesTotal > 0 && bytesTotal == bytesLoaded){
          movieArray[i].stop();
          trace("stop");
          i++;
     }
     getURL("index.htm");
}
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Hi,
actually there are some problems here...

first of all try not to use while to check when loading is finished, fast machines die, instead use evens and event handlers to detect when it's loaded, 'EnterFrame' is suitable to your code, while you can use 'load' and 'data' too

why all the movies are loaded in the _root? _root is the main part of movie and loading anything in it will replace any contents of it including yous past loadings, ie. when 'main.swf' is loaded it replaces the 'yellowdogworks.swf' and so on...

you don't need to use eval when you are running a method or property of an object and so is getBytesLoaded()...simply write:

bytesLoaded = _root.getBytesLoaded();

in the end of your code, where you put stop is where you need eval because movieArray[i] returns a string while you need an instance of a movieClip so should write eval(movieArray[i]).stop()

I guess getURL must be used when your loadings are finished so place as a result of an IF statement

one more thing, since flash codes are run very quickly they are always faster than your computer's HDD speed, so whenever you use load actions (loadMovie, loadVariables, xml.load etc etc) you don't have access to the loaded stuff in the same block of codes with load action, try to put those actins one or two frames afterwards (depends on fps of your movie)


cheers

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial