-
Hallo!
I'ld like to know if someone of you found a way to have a matrix-like variable.
Maybe I have to build a custom object, but I'm not so good with object-oriented programming. Anyway, I could try it!
Thank you in advance
Carla
-
For the OOP things, it should be something like this:
Code:
_global.Matrix = function(a1, a2, b1, b2) {
this.a1 = a1;
this.b1 = b1;
this.a2 = a2;
this.b2 = b2;
this.double = function(x) {
return x*2;
};
};
y = new Matrix(1, 2, 3, 4);
trace(y.a2);
trace(y.double(y.b2));
We can add math functions for the Matrix object.
-
Thank you Ericlin,
but this seems an array to me, not a matrix.
What I mean is to have an object whose elements can be reached by something like a[i, j], where i and j are integer indexes.
To define an object like this there should be some command like
m = new Matrix((4, 2, 7), (1, 0, 3), (5, 0, 1))
so that I have an array of arrays.
Is it possible?
-
Initially I thought you want to make a class of Matrix that you can rotate. I mean a matrix of 2x2 or 3x3 or 4x4;
If we need only arrays of arrays, Flash has already build-in functions to do multi-dimensional array; That is array of array; Only the syntax is slightly different from C language;
m = [[4, 2, 7],[1, 0, 3],[5, 0, 1]];
Then to access the third element of the first array will be:
m[0][2]; That will be 7; In C, the syntax might be m[0,2];
-
I love it!
Thank you for providing me the right sintax.
Carla
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|