Actionscript 3 与命名空间内部错误中的定义_反弹存在冲突

Actionscript 3 与命名空间内部错误中的定义_反弹存在冲突,actionscript-3,flash-cs4,adobe-flash-cs3,Actionscript 3,Flash Cs4,Adobe Flash Cs3,您好,我正在尝试在Flash CS3动作脚本上创建一个游戏,并且在第13-15行中不断出现错误,说存在与定义冲突的名称空间内部反弹,与定义冲突的名称空间内部高分,与定义冲突的名称空间内部球???请帮忙 package { import flash.display.MovieClip import flash.text.TextField import flash.events.Event import flash.events.MouseEvent pu

您好,我正在尝试在Flash CS3动作脚本上创建一个游戏,并且在第13-15行中不断出现错误,说存在与定义冲突的名称空间内部反弹,与定义冲突的名称空间内部高分,与定义冲突的名称空间内部球???请帮忙

package
{
    import flash.display.MovieClip
    import flash.text.TextField
    import flash.events.Event
    import flash.events.MouseEvent

    public class DocumentMain extends MovieClip
    {
        public const Gravity:Number = 2;
        public const Bounce_Factor:Number = 0.8;

        public var _bounces:TextField;
        public var _highscore:TextField;
        public var _ball:Ball;

        public var _vx:Number;
        public var _vy:Number;


        public function DocumentMain():void
        {
            _vx = 0;
            _vy = 0;
            addEventListener(Event.ENTER_FRAME, enterFrameHandler);
            addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
        }

        private function enterFrameHandler(e:Event):void
        {
            //gravitate the ball
            _vy += Gravity;
            //move the ball
            _ball.x += _vx;
            _ball.y += _vy;
            //check stage boundaries for collision
            checkBoundaryCollision();
        }
        private function mouseDownHandler(e:MouseEvent):void
        {
            //Hit the ball if it has been clicked
        }

        private function checkBoundaryCollision():void
        {
            var left:Number;
            var right:Number;
            var bottom:Number;
            var Top:Number;
            left = _ball.x -(_ball.width / 2);
            right = _ball.x +(_ball.width / 2);
            bottom = _ball.y +(_ball.height / 2);
            top = _ball.y + (_ball.height / 2);

            if (left < 0 && _vx < 0)
            {
                _ball.x = _ball.width/2;
                _vx *= -1;
            }
            else if (right > stage.stageWidth && _vx > 0)
            {
                _ball.x = stage.stageWidth -(_ball.width /2);
                _vx *= -1;
            }
            if (top < 0 && _vy < 0)
            {
                _ball.y = _ball.height / 2;
                _vy *= -1;
                }
            else if (bottom > stage.stageHeight && _vy > 0)
            {
                _ball.y =stage.stageHeight -(_ball.height / 2);
                _vy *=Bounce_Factor;
            }

        }
    }
}
包
{
导入flash.display.MovieClip
导入flash.text.TextField
导入flash.events.Event
导入flash.events.MouseEvent
公共类DocumentMain扩展了MovieClip
{
公共常数:数量=2;
公共常数反弹系数:数字=0.8;
公共变量反弹:TextField;
公共变量高分:文本字段;
公共变量球:球;
公共变量vx:编号;
公共变量:数字;
公共函数DocumentMain():void
{
_vx=0;
_vy=0;
addEventListener(Event.ENTER_FRAME,enterFrameHandler);
addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
}
私有函数enterFrameHandler(e:事件):void
{
//吸引球
_vy+=重力;
//移动球
_ball.x+=\uVx;
_ball.y+=\u vy;
//检查舞台边界是否存在碰撞
checkBoundaryCollision();
}
私有函数mouseDownHandler(e:MouseEvent):void
{
//如果球已被点击,则击球
}
私有函数checkBoundaryCollision():void
{
变量左:数字;
右:数字;
var底部:数字;
var Top:数字;
左=_ball.x-(_ball.width/2);
右=_ball.x+(_ball.width/2);
底部=_ball.y+(_ball.height/2);
顶部=_ball.y+(_ball.height/2);
如果(左<0&&U vx<0)
{
_ball.x=_ball.width/2;
_vx*=-1;
}
否则,如果(右>stage.stageWidth&&U vx>0)
{
_ball.x=stage.stageWidth-(_ball.width/2);
_vx*=-1;
}
如果(顶部<0&&U vy<0)
{
_ball.y=_ball.height/2;
_vy*=-1;
}
否则如果(底部>舞台高度>0)
{
_ball.y=舞台高度-(_ball.height/2);
_vy*=反弹系数;
}
}
}
}
通过文件->发布设置->动作脚本设置转到“高级动作脚本3.0设置”-我使用的是CS5.5,没有CS3(但应该相同),然后取消选中“自动声明阶段实例”(这是默认设置)

或者不要在类中定义它们


您可能有重复的定义

例如:

 var _bounces:TextField;

在与上面的类相同的目录/包中是否有名为TextField的文件/类?如何检查?不确定我打赌您已在发布属性(对于ActionScript 3.0设置)中选择自动命名阶段实例。