[edit] Arg! Someone beats me to it again. :P
These lines:
cause the button image to be constantly freed and loaded. This is a very bad idea. While not syntactically wrong, it's probably causing chaos because it's being done so frequently.
The best way is to load all your images outside of the main loop and then just display the correct image depending on whether you're pointing on the button, or not.
Also, using global variable names of 'p' and 'n' is not such a good idea. They're not descriptive and simple variable names like this are often used for other things, like For/Next loops.
These lines:
If ImagesOverlap(pointer, p_x#, p_y#, n, 101, 582) Then buttonon(n) If Not ImagesOverlap(pointer, p_x#, p_y#, n, 101, 582) Then buttonoff(n)
cause the button image to be constantly freed and loaded. This is a very bad idea. While not syntactically wrong, it's probably causing chaos because it's being done so frequently.
The best way is to load all your images outside of the main loop and then just display the correct image depending on whether you're pointing on the button, or not.
Also, using global variable names of 'p' and 'n' is not such a good idea. They're not descriptive and simple variable names like this are often used for other things, like For/Next loops.