AS2:attachmovie无法正常工作

时间:2011-06-03 15:23:03

标签: actionscript actionscript-2

目前为止的好代码:

var Graphs:Array = new Array(contentMain.graph1, contentMain.graph2, contentMain.graph3, contentMain.graph4, contentMain.graph5, contentMain.graph6, contentMain.graph7, contentMain.graph8, contentMain.graph9);
var Xcoords:Array = new Array(new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array());
var Ycoords:Array = new Array(new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array());
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<Graphs.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++) {
        Slide_y = 100-Slide_Tracker[i].val_arr[s]
        with (Graphs[s].chart) {
            beginFill(0x000066,80);
            lineStyle(2,0x000066,80);
            if (i == 0) {
                moveTo(0,Slide_y);
                Xcoords[s].push(0);
                Ycoords[s].push(Slide_y);
            } else if (i>0) {
                var index:Number = Xcoords[s].length-1;
                var prevX:Number = Xcoords[s][index];
                var prevY:Number = Ycoords[s][index];
                moveTo(prevX,prevY);
                var newX:Number = prevX+(date_diff*30);
                var newY:Number = Slide_y;
                lineTo(newX,newY);
                Xcoords[s].push(newX);
                Ycoords[s].push(newY);
            }
            endFill();
        }
        var dotObj:Object = new Object();
        dotObj._x = Xcoords[s][index];
        dotObj._y = Ycoords[s][index];
        Graphs[s].chart.attachMovie("dot",eval("dot"+s),Graphs[s].chart.getNextHighestDepth(),dotObj);
        trace(eval(Graphs[s].chart+".dot"+s));
    }
}

这里我尝试附加一部电影(它使用的所有变量):

var dotObj:Object = new Object();
            dotObj._x = Xcoords[s][index];
            dotObj._y = Ycoords[s][index];
            Graphs[s].chart.attachMovie("dot",eval("dot"+s),Graphs[s].chart.getNextHighestDepth(),dotObj);
            trace(eval(Graphs[s].chart+".dot"+s));

但没有任何内容出现,并且它的痕迹是未定义的。我的movieclip的链接ID是“dot”。 (没有语音标记)。

1 个答案:

答案 0 :(得分:0)

似乎实例名称"dot"是为某些东西保留的,因为只要我将链接更改为graph_dot并使用它们就会开始出现。