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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

While and/or duplicateMovieClip problem 1

Status
Not open for further replies.

leujel

Programmer
May 28, 2003
23
0
0
NL
This is my problem.

I've got to duplicate movieclips dynamically. This happens with the following code:
Code:
count = 0
while(count < _root.database.aantal)	{
	_root.mc_dummy.duplicateMovieClip("boxx"+count, count);
	_root["boxx"+count]._x = _root.mc_dummy._x + (20 * count);
	_root["boxx"+count]._y = _root.mc_dummy._y + (20 * count);
	count += 1;
}

This should duplicate the movieclip mc_dummy, but it doesn't. _root.database.aantal is a variable that i load from a PHP file thru
Code:
loadVariables("database.php", "_root.database");

When I replace _root.database.aantal for a number (ie 3) in the while statement it does work. I tried converting _root.database.aantal to a number (Number(_root.database.aantal)) but that didn't work either...

Can anyone help me?

---------------

Visit Stray Cats Fan!! Go Cat!! Go!!
 
If the 'database.aantal' number is being drawn in from a database (seems likely) it's probably due to the fact that you're trying to use the value before it's loaded in - this would explain why a hardcoded value works as it requires no loading time.

If you use loadVars to bring the value in then you could fire this code from the onLoad function which would mean the script won't run until there's a value there for it to work with.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top