undefined error in Safari but working fine on others

2,640 views
Skip to first unread message

nardove

unread,
Dec 12, 2013, 3:27:28 PM12/12/13
to pap...@googlegroups.com
I'm getting the following error in Safari:

TypeError: 'undefined' is not a function (evaluating 'this.path.add( point )')

But it works fine on Chrome, this is a very old code and I only spot that error after updating Safari.

Any help will be much appreciated

nick hulea

unread,
Dec 12, 2013, 4:02:51 PM12/12/13
to pap...@googlegroups.com
It would seem that you have an undefined variable or object being passed. 
Do you have more code ?

thanks 

Nick

nardove

unread,
Dec 12, 2013, 4:19:02 PM12/12/13
to pap...@googlegroups.com
Hi Nick,

This is the bulk of it:
function Jelly() {
this.path = new Path();
this.location = new Point( -100 , Math.random() * (view.size.height * 0.5) );
this.velocity = new Point( 0, 0 );
this.acceleration = new Point( 0, 0 );
....

this.init = function() {
// Creates body path
for ( var i = 0; i < pathRes; i++ ) {
var theta = angle * i;
var thetaUp = theta - (Math.PI / 2);
var point = new Point({x: 0, y: 0});
// Upper side of the body
if ( theta < wrapAngle ) {
point.x = Math.cos( thetaUp ) * pathRadius;
point.y = Math.sin( thetaUp ) * pathRadius;
}
// Inner side
else if ( theta > wrapAngle && theta + (angle * 2) < wrapAngle + Math.PI ) {
point.x = Math.cos( thetaUp ) * pathRadius;
point.y = Math.sin( thetaUp ) * ((-pathRadius * 0.85) + pathRadius * 1.25);
}
// The other upper side of the body
else {
point.x = Math.cos( thetaUp ) * pathRadius;
point.y = Math.sin( thetaUp ) * pathRadius;
}
pathPoints[i] = point;
this.path.add( point );
}

nick hulea

unread,
Dec 12, 2013, 4:26:16 PM12/12/13
to pap...@googlegroups.com
Hi Nardove,

What is pathRes?

thanks 

Nick

nardove

unread,
Dec 12, 2013, 4:30:32 PM12/12/13
to pap...@googlegroups.com
Its a variable that contains the resolution or number of points of the path shape I'm trying to draw, hte weird thing is why it works in Chrome and used to work in Safari until I update it, still need to make it work in it ;)

nick hulea

unread,
Dec 12, 2013, 4:44:25 PM12/12/13
to pap...@googlegroups.com
I think somehow the object is not returning but only for safari
what is pathPoints[i]?
I feel like somehow its returning a string not an object but I am on a pc so I literally never use safari. 
thanks 

nardove

unread,
Dec 12, 2013, 4:48:14 PM12/12/13
to pap...@googlegroups.com
pathPoints is an array that contains all the points that the form the shape, I use it to do other calculations later on for other stuff ;)

Jürg Lehni

unread,
Dec 12, 2013, 8:51:19 PM12/12/13
to pap...@googlegroups.com
Are you using PaperScript or JavaSCript? If JavaScript, are you injecting your code into the global scope through paper.install(window)? And what version of Paper.js are you using?
> --
> You received this message because you are subscribed to the Google Groups "Paper.js" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to paperjs+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

nardove

unread,
Dec 13, 2013, 2:15:39 AM12/13/13
to pap...@googlegroups.com
OK, solve the issue by updating paper.js, it used to work on previous versions thats why I didn't think about updating the lib 

Thanks!

Jürg Lehni

unread,
Dec 13, 2013, 7:39:56 AM12/13/13
to pap...@googlegroups.com
Yeah Apple introduced a change in Safari 7 that broke older versions of Paper.js if you injected into the global scope (which isn't really such good practise, so we should perhaps stop recommending it :).

Updating solves it.

J

On Dec 13, 2013, at 08:15 , nardove <nar...@yahoo.com> wrote:

> OK, solve the issue by updating paper.js, it used to work on previous versions thats why I didn't think about updating the lib
>
> Thanks!
>
Reply all
Reply to author
Forward
0 new messages