Also you seem to be relying on the javascript semi-colon insertion "feature". the language does require semi-colons at the end of every statement. It's just that it will supply them for you if you omit them. This can cause bugs when it gets it wrong. they can be very hard bugs to figure out. Don't rely on it and supply all semicolons yourself. And also you might want to consider using Rollimage = []; instead of Rollimage=new Array(); . This is (i believe) faster. Because Array is a built in class, you do not need to call its constructor.