在下面的代码中,即使“BITMAP”为null,if语句之后的行也会运行。这是为什么?
public function get BitmapHeight ()
{
if (_bitmapHeight == 0 && BITMAP != null)
_bitmapHeight = BITMAP.bitmapData.height;
return _bitmapHeight;
}
答案 0 :(得分:4)
如果BITMAP为null,则不应该运行该行代码。
试试这个:
public function get BitmapHeight (){
if (_bitmapHeight == 0 && BITMAP != null){
trace("called with null");
_bitmapHeight = BITMAP.bitmapData.height;
}
return _bitmapHeight;
}
是否会跟踪“使用null调用”?
答案 1 :(得分:0)
我在这里做了一个很长的镜头,但由于你没有任何痕迹,我认为你可能会通过使用调试器进入该行来判断编码后的行是否正在执行...
如果是这种情况,您看到的源代码可能与实际编译到swf中的代码不完全相同。例如,如果您在开始调试后删除该文件中的一行(可能是空白行),则保存在swf中的行号将与您看到的源代码文件中的行号不匹配。偶尔会发生这种情况并给我一个WTF时刻......直到我意识到我再次完成它,所以我只是重新启动调试会话。