如果flash中,我们想实现一张图片随着计算机时间的变换,图片也发生变化,形成早晨,晚上等效果。(如果多个图片,也能用这个方法实现,下面,我们看一下案例):
相对应的脚本:
function times()
{
hh = new Date();
xiaoshi = hh.getHours();
mm = new Date();
fengzhong = mm.getMinutes();
nowtime = xiaoshi * 60 + fengzhong;
if (nowtime >= 0 && nowtime <= 300 || nowtime > 1200 && nowtime < 1440)
{
skycolor = [5, 18, 7, -14, 29, -10, 100, 0];
} // end if
if (nowtime > 300 && nowtime <= 330)
{
skycolor = [5 + (nowtime - 300) * 1.500000, 18 - (nowtime - 300) * 2.930000, 7 + (nowtime - 300) * 1.200000, -14 - (nowtime - 300) * 1.230000, 29 + (nowtime - 300), -10 - (nowtime - 300) * 1.330000, 100, 0];
} // end if
if (nowtime > 330 && nowtime <= 350)
{
skycolor = [49 + (nowtime - 330) * 1.050000, -70, 43 + (nowtime - 330) * 1.100000, -51, 58 + (nowtime - 330) * 0.600000, -50, 100, 0];
} // end if
if (nowtime > 350 && nowtime <= 360)
{
skycolor = [70 - (nowtime - 350) * 2.100000, -70 + (nowtime - 350) * 12.100000, 65 + (nowtime - 350) * 0.700000, -51 + (nowtime - 350) * 1.800000, 70 - (nowtime - 350) * 1.400000, -50 + (nowtime - 350) * 5, 100, 0];
} // end if
if (nowtime > 360 && nowtime <= 375)
{
skycolor = [49 + (nowtime - 361) * 0.357100, 51 + (nowtime - 361) * 3.071000, 72 - (nowtime - 361) * 1.285700, -33 + (nowtime - 361) * 5.710000, 56, 0 + (nowtime - 361) * 5, 100, 0];
} // end if
if (nowtime > 375 && nowtime <= 390)
{
skycolor = [54 + (nowtime - 375) * 3.067000, 94 - (nowtime - 375) * 5.875000, 54 + (nowtime - 375) * 3.067000, 47 - (nowtime - 375) * 3.133000, 54 + (nowtime - 375) * 3.067000, 70 - (nowtime - 375) * 4.667000, 100, 0];
} // end if
if (nowtime > 390 && nowtime <= 870)
{
skycolor = [100, (nowtime - 390) * 0.062500, 100, (nowtime - 390) * 0.062500, 100, (nowtime - 390) * 0.062500, 100, 0];
} // end if
if (nowtime > 870 && nowtime <= 990)
{
skycolor = [100, 30 - (nowtime - 870) * 0.250000, 100, 30 - (nowtime - 870) * 0.250000, 100, 30 - (nowtime - 870) * 0.250000, 100, 0];
} // end if
if (nowtime > 990 && nowtime <= 1050)
{
skycolor = [100 - (nowtime - 990) * 0.167000, (nowtime - 990) * 0.767000, 100 - (nowtime - 990) * 0.167000, 0, 100 - (nowtime - 990) * 0.167000, 0, 100, 0];
} // end if
if (nowtime > 1050 && nowtime <= 1070)
{
skycolor = [90 + (nowtime - 1050) * 0.500000, 46 + (nowtime - 1050) * 6.250000, 90 + (nowtime - 1050) * 0.500000, -(nowtime - 1050) * 0.250000, 90 - (nowtime - 1050) * 0.800000, -(nowtime - 1050) * 2.100000, 100,