code:I initialise this object in my main html:function jsProvince (px, py, n) {
this.polyx = px.slice();
this.polyy = py.slice();
this.name = n;
}
code:Now I try to use it in a function called with 'onclick':var polyx = new Array(210,220,220,210);
var polyy = new Array(10,10,20,20);
aProvince = new jsProvince(polyx, polyy, "city");
code:which is where the problem arises: The polyx array has length zero. Presumably I did not initialise it correctly, but I do not understand what I am doing wrong. Any insights?if (isPointInPoly(myProvince.polyx, myProvince.polyy, xpos, ypos)) {
// Do some thing
}
quote:The sequence is:
Is the initialization in the same script block? And is it there before the function gets called?
Do you have the script at the top of the page or the bottom?