Page 1 of 1

object constructor

Posted: August 14th, 2013, 6:32 am
by jus2poubelle
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

Re: object constructor

Posted: August 18th, 2013, 1:12 am
by beginUndoGroup
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...

Re: object constructor

Posted: August 20th, 2013, 6:30 am
by jus2poubelle
it must be my after effect version. It doesn't work either.

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