ActionScript 2.0。 FLASHLOG。警告:引用未声明的变量。为什么eval(电影+"。" +姓名)==未定义此警告?

时间:2014-10-23 04:40:28

标签: reference warnings undefined actionscript-2 flashlog

尝试为Flash Player 6.0执行优化代码。

有一个代码

if (eval(Movie + "." + NameTextField) == undefined) { // If undefined, the warning will be issued when accessing
        Movie.createTextField(NameTextField, Movie.CountDepth++ , X, Y, Width, Height);             
    }

    if (eval(Movie+"."+Name) == undefined){  //  If undefined, the warning will be issued when accessing    
        Movie.createEmptyMovieClip(Name, (NumDepth == undefined )?(Movie.CountDepth++):NumDepth );
    }

但是在第一次传递时,此代码始终在文件flashlog.txt中发出警告。

请勿正确采访但尚未声明的MovieClip或TextField?

1 个答案:

答案 0 :(得分:1)

试试这个:

var CountDepth:Number = 0; // you may already have this else where in your code
if (!Movie.NameTextField) { 
    Movie.createTextField(NameTextField, CountDepth++ , X, Y, Width, Height); 
}

if (!Movie.Name){   
    Movie.createEmptyMovieClip( Name, CountDepth++ );
}