my slow script

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Kyori
Forum Newbie
Posts: 23
Joined: Mon Oct 14, 2002 5:23 am
Contact:

my slow script

Post by Kyori »

below is my script (JS). It makes 72x72 number of objects and they are preloaded on the parent frame(code below) so it won't have to be reloaded with every click. Prob is, it takes 3-4 sec per click for the page to load. Any way to speed this up w/o having need to lower object count (like 48x48)? I've tried arrays over Objects but it's still the same.


Even when I do something that has nothing to do about the script below, loading time is still long. When I set it to 48x48, it takes much less time. My PC is Duron 1.3Ghz (137fsb). I've tested on a 750Mhz CPU and it's even slower.

Code: Select all

function createBlockObject(walk,img, name)
{
	this.img = new Image();
	this.img.src=img;
	this.walk = walk;
	this.name=name;
	return this;
}

var mapBlocks = new Array();
for(x=2;x!=72;x++)
{
	mapBlocks[x] = Array();
	for(y=1;y!=72;y++)
		mapBlocks[x][y]= new createBlockObject(1,grass2,"Grasses");
	
}
mapBlocks[1] = Array();
for(y=1;y!=72;y++)
{
	
	if((y%3==0) || (y%7==0))
		mapBlocks[1][y]= new createBlockObject(0,tree1,0);
	else
		mapBlocks[1][y]= new createBlockObject(0,tree2,0);
}

thanks in advanced
Post Reply