开发者

Rotation + Matrix + JSFL

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.


Have you tried with radians instead of degrees?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜