开发者

&& operation in actionscript

开发者 https://www.devze.com 2023-01-03 05:43 出处:网络
In the following code the line after the if 开发者_运维问答statement gets run even when \"BITMAP\" is null.Why is this?

In the following code the line after the if 开发者_运维问答statement gets run even when "BITMAP" is null. Why is this?

public function get BitmapHeight ()
      {
        if (_bitmapHeight == 0 && BITMAP != null)
          _bitmapHeight = BITMAP.bitmapData.height;
        return _bitmapHeight;
      }


That line of code should never be run if BITMAP is null.

Try this:

public function get BitmapHeight (){
    if (_bitmapHeight == 0 && BITMAP != null){
        trace("called with null");
        _bitmapHeight = BITMAP.bitmapData.height;
    }
    return _bitmapHeight;
}

Does 'called with null' ever get traced?


I'm taking a long shot here, but since you have no trace in place, I think it's possible that you're a judging whether the line after the codition is being executed or not by stepping into that line with the debugger...

If that's the case, it's possible that the source code you are seeing is not exactly the same code that was actually compiled into the swf. If you, for example, delete one line in that file (could be a blank line) once you've started debugging, the line numbers saved in the swf won't match the line numbers in the source code file you're seeing. This happens to me occasionally and gives me one of those WTF moments... until I realize I have done it again, so I just re-launch the debugging session.

0

精彩评论

暂无评论...
验证码 换一张
取 消