作者etrexetrex (ETREX)
看板Flash
标题Re: [问题] 奇怪...
时间Sat Apr 29 16:54:23 2006
※ 引述《etrexetrex (ETREX)》之铭言:
: 我用下面四行来使用键盘控制影片位置
: if ( Key.isDown( Key.UP ) && this._y > 0 ) this._y -= speed ;
: if ( Key.isDown( Key.DOWN ) && this._y < 400 ) this._y += speed ;
: if ( Key.isDown( Key.LEFT ) && this._x > 0 ) this._x -= speed ;
: if ( Key.isDown( Key.RIGHT ) && this._x < 400 ) this._x += speed ;
: 这四行是可行的
: 但是如果我将 400 改成 _root._height
: 或 _root._width
: 实际测试的时候却可以跑出画面外
: 之後 trace ( _root._height ); 显示400没错..
: 问题到底出在哪里呢?(我使用的是FLASH MX)
整个程式码
// 键盘控制移动函数
MovieClip.prototype.keyMove=function(speed)
{
if ( Key.isDown( Key.UP ) && this._y > 0 ) this._y -= speed ;
if ( Key.isDown( Key.DOWN ) && this._y < 400 ) this._y += speed ;
if ( Key.isDown( Key.LEFT ) && this._x > 0 ) this._x -= speed ;
if ( Key.isDown( Key.RIGHT ) && this._x < 400 ) this._x += speed ;
}
我的问题点在於 为什麽 _root._height 是 400
却不能取代上述程式码的 400 呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.228.124.45