Reputation: 13476
I am using the following code...
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++) {
}
}
the problematic code is this:
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;
}
While this if statement exists (even when empty) it causes a perpetual loop and the "a script is causing this movie to run slow" message to appear.
Can anyone tell me why this is happening?
Upvotes: 0
Views: 291
Reputation: 2286
The issue is that "i" will always equal zero as its not being set to anything else, s is the value you are ascending
Inside the if just put:
i = 1;
or whatever you want to set it to. Alternatively how about
if (i==0 && s==0) {
(I think thats how you do an 'and' in ActionScript.)
Upvotes: -1
Reputation: 6689
I think you wanted if (i==0)
because this just sets i
to 0 and always returns true
?
Upvotes: 2