喜 我可以使用Flash CS6和as3
以阿拉伯语格式显示当前日期和时间var now:Date=new Date()
this["st_rep"+c]["date"].text=now.toDateString()
this["st_rep"+c]["time"].text=now.toTimeString().slice(0,8)
提前谢谢
答案 0 :(得分:1)
这就是我的工作
var eng_num=["0","1","2","3","4","5","6","7","8","9"]
var ara_num=["۰","۱","۲","۳","٤","٥","٦","۷","۸","۹"]
function convert_arabic(str:String)
{
var new_str=""
for(var f=0;f<str.length;f++)
{
var temp=str.slice(f,f+1)
var xx:int=int(temp)
if(String(Number(temp)) == String(temp))
{
for(var d=0;d<=eng_num.length;d++)
{
if(temp == eng_num[d])
{
new_str+=ara_num[d]
}
}
}
else
{
new_str+=temp
}
}
return new_str
}
答案 1 :(得分:0)
没有神奇的方法可以做到,你已经创建了一个格式化函数。像这样:
var now:Date = new Date()
trace(formatDate(now.toDateString()));
function formatDate(dateStr:String)
{
var dateParts:Array = dateStr.split(" ");
var dayName:String = getDayName(dateParts[0]);
var monthName:String = getMonthName(dateParts[1]);
var day:String = dateParts[2];
var year:String = dateParts[3];
return year + " " + monthName + " " + day + " " + dayName;
}
function getMonthName(month:String):String
{
switch (month)
{
case "Jan": return "يناير";
case "Feb": return "فبراير";
case "Mar": return "مارس";
case "Apr": return "إبريل";
case "May": return "مايو";
case "Jun": return "يونيو";
case "Jul": return "يوليو";
case "Aug": return "أغسطس";
case "Sep": return "سبتمبر";
case "Oct": return "أكتوبر";
case "Nov": return "نوفمبر";
case "Dec": return "ديسمبر";
}
return null;
}
function getDayName(day:String):String
{
switch (day)
{
case "Sat": return "السبت";
case "Sun": return "الأحد";
case "Mon": return "الإثنين";
case "Tue": return "الثلاثاء";
case "Wed": return "الأربعاء";
case "Thu": return "الخميس";
case "Fri": return "الجمعة";
}
return null;
}
请注意,根据我所知道的情况,您无法使用闪光灯显示阿拉伯语中的数字。如果你必须用阿拉伯语显示数字,你可以在库中创建一个10帧的动画片段,每帧保存1个阿拉伯数字图像,并创建一个格式化函数,根据每个阿拉伯数字从库中附加剪辑。
答案 2 :(得分:0)
阿拉伯数字的好解决方案:)。你可以编写一个更简单的函数版本:
function convert_arabic(str:String)
{
var eng_num = ["0","1","2","3","4","5","6","7","8","9"];
var ara_num = ["۰","۱","۲","۳","٤","٥","٦","۷","۸","۹"];
for(var f:int = 0; f < eng_num.length; f++)
str = str.replace(new RegExp(eng_num[f], "g"), ara_num[f]);
return str;
}
的问候,
答案 3 :(得分:0)
Flash Player 10.1添加了DateTimeFormatter作为flash.globalization包的一部分。它应该至少部分地帮助你。
import flash.globalization.DateTimeFormatter;
var d:Date = new Date();
// The locale for Jordan is "ar-JO"
var dtf:DateTimeFormatter = new DateTimeFormatter("ar-JO", DateTimeStyle.LONG, DateTimeStyle.LONG);
trace(dtf.format(d));
// Output on a PC running an English version of Windows:
// 11 آب, 2013 01:57:06 م
如果您使用TLF文本字段,则可以从右到左文本。但请注意,TLF已从当前版本的Flash Pro(Flash Pro CC 1.0)中删除,并且不清楚是否/何时会有替换。