AS2:数组中的字符串未定义

时间:2011-06-02 13:47:17

标签: arrays actionscript multidimensional-array actionscript-2 undefined

我在时间轴上有以下代码,但是当我尝试从date_string数组输出Slider_Tracker时,它表示未定义。

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 = 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);
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();

};

任何人都可以看到我的垮台吗?感谢。

1 个答案:

答案 0 :(得分:1)

您的意思是trace中的this._parent.saver.onRelease

不幸的是,这是一个不同的范围,它将与您的this._parent.saver MovieClip相关,因此无法访问您在此处定义的date_stringSlide_Tracker