AS2: string in array is undefined
I have the following code on the timeline, but when I try and output date_string
from the Slider_Tracker
array it says it is undefined.
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();
var day_num = cu开发者_如何学Pythonrrent_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);
trace(date_string);
date_int = current_date.getTime();
trace(current_date);
trace(date_int);
var Sliders:Array = Array (slider1.slider, slider2.slider, slider3.slider, slider4.slider, slider5.slider, slider6.slider, slider7.slider, slider8.slider, slider9.slider);
var Slide_Tracker:Array = new Array();
var local_data = SharedObject.getLocal("user_data");
if (local_data.data.user_data == undefined) {
local_data.data.user_data = Slide_Tracker;
trace("fail");
} else {
Slide_Tracker = local_data.data.user_data;
for (i=0;i<Slide_Tracker.length;i++) {
trace(Slide_Tracker[i][1]);
if(Slide_Tracker[i][1] == date_string) {
index = i;
}
}
trace("success");
}
var current_time = new Date();
this._parent.fullClear.onRelease = function() {
local_data.clear();
}
this._parent.saver.onRelease = function() {
trace(date_string);
Slide_Tracker.push(new Array(date_int, date_string));
for (i=0;i<Sliders.length;i++) {
Slide_Tracker[0].push(100-Sliders[i]._y);
}
Slide_tracker.push(today_Stats);
local_data.data.user_data = Slide_Tracker;
local_data.flush();
nextFrame();
};
Can anyone see my downfall? thanks.
You mean the trace
in this._parent.saver.onRelease
?
That's a different scope unfortunately, it'll be relative to your this._parent.saver
MovieClip, so it won't have access to date_string
and Slide_Tracker
you defined here.
精彩评论