Skip to main content
Known Participant
January 29, 2009
Question

create custom matrix transform

  • January 29, 2009
  • 3 replies
  • 802 views
hi, i want to assign a transform matrix to an object, but i want to assign the values myself (as in, no 'rotate, scale etc'), but for example, set a matrix like

[1, 0
0, 1]

which if applied, would have no effect, but would be valid (actually not exactly that matrix, but you get the idea). i want to set the values of the matrix and the object should be affected by those values that i set by myself, no ´scale´, ´rotate´ or any predefined operations. how can i set my own matrix? tnx
This topic has been closed for replies.

3 replies

Participant
July 3, 2009

Actually according to the ActionScript Language Reference the Matrix properties in Matrix notation look like this:

[ a  b  tx ]

[ c  d  ty ]

[ 0  0  1 ]

so if you want the equivalent of the 2x2 matrix you should just change the a,b,c,d properties.

kglad
Community Expert
Community Expert
January 30, 2009
the flash matrix class can perform all 2d linear transformations just like 2x2 mathematical matices can perform all linear transformations in 2d space. but instead of adding and multiplying by 2x2 matrices in mathematics to achieve those transformations, in flash you multiply by a 3x3 matrix (with the last row 0,0,1).
Inspiring
January 29, 2009
You can just set them in the constructor or via the a-d, tx,ty properties:
var m:Matrix=new Matrix(.5,.3,-.6,1.5,-50,100)
trace(m)

m.a=4.5;
m.b=0;
m.c=0;
m.d=0.5;
m.tx=0;
m.ty=0;
trace(m)

//traces:
//(a=0.5, b=0.3, c=-0.6, d=1.5, tx=-50, ty=100)
//(a=4.5, b=0, c=0, d=0.5, tx=0, ty=0)
Known Participant
January 30, 2009
hi, tnx, umm.. but that does not help much.

i mean, if i want a matrix to transform xy, a 2 column 2 rows would be enough (if there are more they would have identity fixed values), so if there are more than the four values x1y1, x1y2, x2y1, x2y2 values it means: the other values are affected by those values, or those extra values don't mean a thing. i need to assign 4 values, there are 6 values in a, b, c, d, tx, ty. how do i assign a 4 value custom transform matrix to an object?

(well, what i post this so i don't remain with the doubt, i found out i can not do what i was looking for this way but tnx)