Pergunta

A matriz de transformação flash via JSFL é má para mim :(

Eu tenho que escrever um script JSFL que cria um texto na minha cena flash e girá -lo com um ângulo aleatório. Imagine que eu quero criar e girar um "Hello World!" A 45 graus, meu código se parece com isso:



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


O problema é: a rotação aplicada ao meu texto é 58,3 em vez de 45.

Eu tenho que admitir que sou meio que noob com Matrix ... então usei a "transformação da matriz para rotação" aqui: http://www.senocular.com/flash/tutorials/transformmatrix/

Ideias ?

obrigada.

Foi útil?

Solução

Você já tentou com radianos em vez de graus?

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top