Expressions/Scripts/Presets

Moderators: Disciple, zlovatt

 
jus2poubelle
Topic Author
Posts: 6
Joined: Mon Jul 01, 2013 3:38 am

object constructor

Wed Aug 14, 2013 6:32 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:
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: 77
Joined: Tue Nov 27, 2012 6:41 am

Re: object constructor

Sun Aug 18, 2013 1:12 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:
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
Topic Author
Posts: 6
Joined: Mon Jul 01, 2013 3:38 am

Re: object constructor

Tue Aug 20, 2013 6:30 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.

Who is online

Users browsing this forum: No registered users and 4 guests