Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple? action script error

Status
Not open for further replies.

puppet

IS-IT--Management
Dec 13, 2001
140
I got this preloader from this site a couple of years ago and it works great but I have just copied it from my original movie to a new one I am creating and I get errors when I check the syntax. Exactly the same as far as I can see as the one I copied that checks fine..... ANy ideas would be greatly appreciated.

-----------------------------------------------------------
Action Script
-----------------------------------------------------------

// The time, K-loaded and K-total are obtained straight away as soon as the movie loads.
// This forms the basis of all calcs in the main actionscripting in frame 3.
/:time0 = getTimer ();
/:loaded0 = _root.getBytesLoaded();
/:total = _root.getBytesTotal();
//
// Note that this frame contains the label "loop"


-----------------------------------------------------------
Error Message Below
-----------------------------------------------------------

**Error** Scene=Scene 2, layer=Layer 4, frame=1:Line 3: Unexpected '/' encountered
/:time0 = getTimer ();

Total ActionScript Errors: 1 Reported Errors: 1
 
That's old Flash syntax, and I guess Davedesign's...

Replace /: with _level0

_level0.time0 = getTimer();

Are you on MX2004, using AS2.0?


Regards.

An expert is someone who learns more and more about less and less, eventually knows everything about nothing, and becomes a biased & useless moderator in Flashkit's Coffee Lounge!
 
I'm using mx2004 - not sure what version of AS - how do i tell? Yep quite right I got this from the DaveDesign FAQ ages ago - pity none of the links to his stuff seem to work anymore....

could I trouble you for help with the next two bits of the preloader?


-----------------------------------------------------------
// The iteration number is incremented by one.
// This is essential for calculating the averages in the main actionsripting.
_level0.iteration = number(/:iteration)+1;

-----------------------------------------------------------
// The current Time and K-loaded is calculated for the next stage
/:time1 = getTimer ();
/:loaded1 = _root.getBytesLoaded();
//
// The following line sets the value of the 'K-loaded' dynamic variable on the main stage
/:loaded2 = int(number(/:loaded1)/1000);
//
// The difference between start-Time and current-Time,
// and start-K-loaded and current-K-loaded
/:timesum = number(/:time1)-number(/:time0);
/:loadsum = number(/:loaded1)-number(/:loaded0);
//
// The average Time and K-loaded values are calculated based on
// the number of times the calc has performed the 'loop'
/:avtimesum = number(/:timesum)/number(/:iteration);
/:avloadsum = number(/:loadsum)/number(/:iteration);
//
// The following line calculates the connection speed of the user.
// The *10 and /10 in the following line merely ensures you
// get a rounded value to 1 decimal place.
/:connectionspeed = int((number(/:avloadsum)/number(/:avtimesum))*10)/10;
//
// The percentage loaded is calculated, and the scale of the loader-bar is adjusted accordingly
/:percent = int((_root.getBytesLoaded()/_root.getBytesTotal())*100);
setProperty ("_root.loadbar", _yscale, number(/:percent));
//
// The following line calculates the time remaining to load the movie
// based on the size of the movie and the calculated average connection rate of the user
/:timeleft = (int((number(/:total)-number(/:loaded1))/number(/:connectionspeed)/100))/10;
//
// The 'if' statement tells the movie to go to the frame labelled "site"
// if the whole movie is loaded and ready to go, if it isn't loaded completely
// the movie is redirected back to the frame labelled "loop" to allow
// the calculation of another iteration.
// Also included is a statement to set the Alpha of the 'success' mc to 100.
if (_root.getBytesLoaded()==_root.getBytesTotal()) {
_root.gotoAndStop("main", 1);
setProperty ("_root.success", _alpha, "100");
} else {
gotoAndPlay ("loop");
}


 
No offense to Dave, but that preloading code was shaky then, and even more so today. I'd find myself another more current preloading code.

I'm still on MX only, so can't really say anything about MX2004's syntax, but I believe you must set variables differently, specifying if it's a string or number, among other things...

Regards. Affiliate Program - Web Hosting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top