我正在使用以下代码......
var Graphs:Array = new Array(contentMain.graph1, contentMain.graph2, contentMain.graph3, contentMain.graph4, contentMain.graph5, contentMain.graph6, contentMain.graph7, contentMain.graph8, contentMain.graph9);
trace(Graphs);
function dateToString(date:Number) {
var Days:Array = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
var Months:Array = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
var current_date = new Date(date);
var day_num = current_date.getDay();
var year = current_date.getFullYear();
var month = current_date.getMonth();
var date_num:String = new String(current_date.getDate());
date_char = date_num.charAt(date_num.length-1);
if (date_char == 1) {
date_suffix = "st";
} else if (date_char == 2) {
date_suffix = "nd";
} else if (date_char == 3) {
date_suffix = "rd";
}
var date_string:String = new String(Days[day_num]+" "+date_num+date_suffix+" of "+Months[month]+" "+year);
return date_string;
}
var local_data = SharedObject.getLocal("user_data");
Slide_Tracker = local_data.data.user_data;
for (i=0; i<Slide_Tracker.length; i++) {
var current_date:Date = new Date(Slide_Tracker[i].date_int);
var date_string:String = dateToString(Slide_Tracker[i].date_int);
if (i=0) {
for (s=0; s<Slide_Tracker[i].val_arr.length; s++) {
Graphs[s].createEmptyMovieClip("chart",10);
Graphs[s].chart._x = 0;
Graphs[s].chart._y = 37.9;
}
} else if (i>0) {
var past_date:Date = new Date(Slide_Tracker[i-1].date_int);
var date_diff:Number = Math.round((current_date-past_date)/86400000);
}
for (s=0; s<Slide_Tracker[i].val_arr.length; s++) {
}
}
有问题的代码是:
if (i=0) {
for (s=0; s<Slide_Tracker[i].val_arr.length; s++) {
Graphs[s].createEmptyMovieClip("chart",10);
Graphs[s].chart._x = 0;
Graphs[s].chart._y = 37.9;
}
虽然这个if语句存在(即使是空的)但它会导致永久循环并且“脚本导致此电影运行缓慢”消息出现。
谁能告诉我为什么会这样?
答案 0 :(得分:2)
我认为您需要if (i==0)
,因为这只是将i
设置为0并始终返回true
?
答案 1 :(得分:-1)
问题是“i”总是等于零,因为它没有设置为其他任何东西,s是你提升的值
if if put:
i = 1;
或您想要设置的任何内容。或者怎么样
if (i==0 && s==0) {
(我认为你是如何在ActionScript中做'和'的。)