Javascript Game, Module Raphael Not Defined
Solution 1:
The block of load_script
calls loads the scripts asynchronously. This is why there appears to be no clear pattern.
There is no guarantee that raphael.js is loaded (and therefore, that Raphael
is defined) by the time that the line:
var playing_area = Raphael(0,50,1600,1600);
is called.
You should wait until the whole document is ready before attempting to use variables defined in external scripts. Under normal circumstances, this is the onload
event of the document. Various libraries like jquery also offer their own "ready" event, that you could tie to if you use them.
Is there any reason why you load the scripts in the way you do, rather than simply using markup, as below?
<script src="raphael.js"></script>
Solution 2:
Have you tried moving 'raphael.js' to be included before anything else? It may be that Raphael is not defined at the point a script above it needs it.
Post a Comment for "Javascript Game, Module Raphael Not Defined"