Skip to main content
Participating Frequently
July 5, 2022
Question

Snap position and scale to round numbers

  • July 5, 2022
  • 1 reply
  • 257 views

Hi all,
I'm trying to create a jsfl scirpt that changes the element by:

1. Rounding the scaleX and scaleY to a number with 2 decimal places (i.e. integer percent)

2. Rounding the position x and y to a integer number (i.e. snap to pixel)

 

I've tried round/ceil/floor/toFixed, but everytime I end up with a float number similar to .9978.

I'm aware by the JS limitations when working with float numbers, but everything is OK when trying to set up the values manually from the Animate's UI.

Does anyone know a proper solution for doing this through script?

 

Thank you very much.

    This topic has been closed for replies.

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    July 5, 2022

    Hi.

     

    This is actually a bug that has been happening in recent years. The Animate team has already been made aware of the issue, but so far no solution has been given.

     

    You can let them know about this problem via this link:

    https://www.adobe.com/products/wishform.html

     

    Regards,

    JC

    Participating Frequently
    July 5, 2022

    Hi, thank you very much!