Просмотр полной версии : Убрать цифры после запятой
У меня есть переменная с числом от 1 до 20 и мувик с анимацией (20 кадров). Анимация переходит на кадр переменной... но проблема в том что эта переменная не целая, а с дробной частью, поэтому иногда глюки бывают, как это исправить?
А что ты подразмеваешь под глюками?
Вычисления с плавающей запятой никогда не бывают точными.
Math.round, Math.floor, Math.ceil, Math.abs в зависимости от того, что нужно
отбрось дробную часть с помощью Math.floor()
я не говорил глюк.. или говорил хех, мне нужно убрать все после запятой, тоесть чтоб не было 2.598 а 2
ты говорил "глюк", а "хех" не говорил.
в твоем случае - Math.floor()
да куда уж подробнее...
trace(Math.floor(2.598));
в хелпе посмотрел, не понял...
тьфу, ну я стормозил, спасибо всем
floor (Math.floor method)
public static floor(x:Number) : Number
Returns the floor of the number or expression specified in the parameter x. The floor is the closest integer that is less than or equal to the specified number or expression.
Availability: ActionScript 1.0; Flash Player 5 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non-emulated math functions that Flash Player 5 supports.
Parameters
x:Number - A number or expression.
Returns
Number - The integer that is both closest to, and less than or equal to, parameter x.
Example
The following code returns a value of 12:
Math.floor(12.5);
The following code returns a value of -7:
Math.floor(-6.5);
floor (англ. "пол") значит, что результатом вычисления будет наименьшее близжайшее к параметру целое число.
gotoAndStop(Math.floor(2.598)) - идет во 2 кадр
Работает на vBulletin ® версия 3.7.3. Copyright ©2000-2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Copyright © 1999-2008 Flasher.ru. All rights reserved.