Skip to main content
Multoman
Inspiring
Mar 5, 2023 7:03 PM UTC
Answered

how do I find the coordinates of a figure relative to the scene ?

How to use JSFL to calculate the coordinates of the figure relative to the center of the scene, given that the figure is in the symbol and the symbol has its own center?

 

This topic is closed to new replies. Start a new post to keep the conversation going.
Vladin M. Mitov
Vladin M. MitovCorrect answer
Inspiring
Mar 6, 2023 10:59 AM UTC

Hi,
To obtain the "screen" coordinates of a given element, you can multiply its matrix with the document.viewMatrix and then take the tx and ty of the resulting product. Alternatively, you can use the fl.Math.transformPoint() method.

 

 

// Method 1:
var doc = fl.getDocumentDOM();
var el = doc.selection[0];
var m = fl.Math.concatMatrix( el.matrix, doc.viewMatrix );
fl.trace( "x: " + m.tx + ", y: " + m.ty );


// Method 2:
var doc = fl.getDocumentDOM();
var el = doc.selection[0];
var pos = fl.Math.transformPoint( doc.viewMatrix, {x:el.matrix.tx, y:el.matrix.ty} );
fl.trace( "x: " + pos.x + ", y: " + pos.y );

 

 



- Vlad: UX and graphic design, Flash user since 1998Member of Flanimate Power Tools team - extensions for character animation

2 replies

Vladin M. Mitov
Vladin M. MitovCorrect answer
Inspiring
Mar 6, 2023 10:59 AM UTC

Hi,
To obtain the "screen" coordinates of a given element, you can multiply its matrix with the document.viewMatrix and then take the tx and ty of the resulting product. Alternatively, you can use the fl.Math.transformPoint() method.

 

 

// Method 1:
var doc = fl.getDocumentDOM();
var el = doc.selection[0];
var m = fl.Math.concatMatrix( el.matrix, doc.viewMatrix );
fl.trace( "x: " + m.tx + ", y: " + m.ty );


// Method 2:
var doc = fl.getDocumentDOM();
var el = doc.selection[0];
var pos = fl.Math.transformPoint( doc.viewMatrix, {x:el.matrix.tx, y:el.matrix.ty} );
fl.trace( "x: " + pos.x + ", y: " + pos.y );

 

 



Translate
- Vlad: UX and graphic design, Flash user since 1998Member of Flanimate Power Tools team - extensions for character animation
Multoman
MultomanAuthor
Inspiring
Mar 6, 2023 11:31 AM UTC

Thank you Vladin. As always you are the best!

Translate