1

Flash Tranformation Matrix via JsFL are mean to me :(

I have to write a JsFL script that creates a text on my Flash scene, and rotate it with a random angle. Imagine I want to create and rotate a "Hello World!" at 45 degrees, my code looks like that :



rotateAngle = 45;

//creates my new text at x:0, y:0 coordinates
fl.getDocumentDOM().addNewText({left:0, top:0, right:10, bottom:10});
fl.getDocumentDOM().setTextString('Hello World!');

var mat = fl.getDocumentDOM().selection[0].matrix; //get the current matrix

// set rotation
mat.a = Math.cos( rotateAngle );
mat.b = Math.sin( rotateAngle);
mat.c = - Math.sin(rotateAngle);
mat.d = Math.cos( rotateAngle );

fl.getDocumentDOM().selection[0].matrix = mat; //apply new matrix


the problem is : the rotation applied to my text is 58.3 instead of 45.

I have to admit that I'm kind of noob with matrix... so I used the "matrix transformation for rotation" here : http://www.senocular.com/flash/tutorials/transformmatrix/

Ideas ?

thank you.

2 Answers 2

2

Have you tried with radians instead of degrees?

2
  • You're my super star (and I'm super ashamed of my mistake). Thanks a lot.
    – lvictorino
    Oct 27, 2010 at 20:54
  • 1
    i'll always be there for you (this website is a private chat right? :D) Oct 27, 2010 at 20:58
2

i'm pretty sure that you could also just use the following rather than go thru the matrix for the sake of simplicity.

var element = fl.getDocumentDOM().selection[0];
element.rotation = 45;

this avoids having to convert to radians as well since it takes degrees as an input value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.