Answer the question
In order to leave comments, you need to log in
How to add a zero before a number in ActionScript 3.0?
Greetings!
Need help. How to set a condition in Action Script 3.0: if the number is less than ten, then add zero to it in front?
var date:Date = new Date();
varday = date.getDate();
if (day ???????) {day = "0" + day;}
trace (day);
Those. how to add - there is no question, here is the working code: {day = "0" + day;}
It is not clear how to make the listener understand that the number of the day, for example, 2nd, is less than ten and add zero to it in front - "02" ?
In AS 2.0, this LENGTH parameter works fine (i.e. it gives "01", "02", etc. instead of "1", "2", etc.):
onClipEvent(enterFrame)
{
day = clipDate .getDate(); // Set the Variable of the day!
if (length (day) == 1) {day = "0" + day;} // If the number is less than ten, then + 0 to it!
trace(day);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question