object constructor

Moderators: Disciple, zlovatt

Post Reply
jus2poubelle
Posts: 6
Joined: July 1st, 2013, 3:38 am

Hi everybody,
I'm having trouble with object constructors inside expressions. AE crashs every time I try to use one. Is there an explanation?

just a simple example:

Code: Select all

function CurveItem( A, B, C, D){
	this.A = A;
	this.B = B;
	this.C = C;
	this.D = D;
}
var theCurve = new CurveItem(a,b c d);
(well, I could use a simple array instead, but I'd like to understand why I can't use this method).
Thx
beginUndoGroup
Posts: 81
Joined: November 27th, 2012, 6:41 am

I just tried one (never did before) and there was no problem. I copied this expression in a position property and everything went fine:

Code: Select all

function Translation(v){this.v = v;}
Translation.prototype.pow = function(n){return new Translation (n*this.v);}
Translation.prototype["+"] = function(x)
{
        // x: translation or array
	if (x instanceof Translation) return new Translation (this.v+x.v);
	return x+this.v;
	}
	
new Translation([60,79]).pow(5) + new Translation([-8,-10]).pow(20) + value;
Not talking about this particular exemple which is pretty idiotic all in all, constructors are probably not the best way to speed up expressions...
jus2poubelle
Posts: 6
Joined: July 1st, 2013, 3:38 am

it must be my after effect version. It doesn't work either.

i'll try with another version some day.
Thx for the answer.
Post Reply