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

发布于 2024-11-11 13:25:57 字数 2068 浏览 2 评论 0原文

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

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

};

谁能看到我的堕落吗?谢谢。

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

};

Can anyone see my downfall? thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天暗了我发光 2024-11-18 13:25:57

您指的是 this._parent.saver.onRelease 中的 trace 吗?

不幸的是,这是一个不同的范围,它将相对于您的 this._parent.saver MovieClip,因此它无法访问 date_stringSlide_Tracker 你在这里定义的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文