Posted By

jknight42 on 09/23/10


flash round jsfl

Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


JSFL: Round the x and y values of any selected objects

 / Published in: JavaScript


This code is pretty simple but massively useful. You can select any number of elements on the stage in Flash, then run this JSFL Command and it will round their x and y values to the nearest whole number. It's very handy when you want things to be on the whole pixel to prevent blurring or other wierdness.

  1. var curr_doc = fl.getDocumentDOM();
  3. for(i=0 ; i<curr_doc.selection.length ; i++ ) {
  4. curr_doc.selection[i].x = Math.round(curr_doc.selection[i].x);
  5. curr_doc.selection[i].y = Math.round(curr_doc.selection[i].y);
  7. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: smokin2008 on October 16, 2010

I tried adding this code to a jsfl and ran the jsfl from a document. i also added a trace at the end of the document before the closing parathesis - fl.trace(curr_doc.selection[i].x);

for which i get a 'undefined' error

but if it works, it will be great help to flash designers. thanks in advance

Posted By: jknight42 on August 13, 2011

Hi smokin2008, not sure if I understand your question exactly. Also, I realize I'm a little late responding. (like 10 months or so, apologies)

You need to login to post a comment.