AS2:数组中的字符串未定义
我的时间轴上有以下代码,但是当我尝试从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您指的是
this._parent.saver.onRelease
中的trace
吗?不幸的是,这是一个不同的范围,它将相对于您的
this._parent.saver
MovieClip,因此它无法访问date_string
和Slide_Tracker 你在这里定义的。
You mean the
trace
inthis._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 todate_string
andSlide_Tracker
you defined here.