【问题标题】:A conflict exists with definition _bounces in namespace internal Error命名空间内部错误中的定义 _bounces 存在冲突
【发布时间】:2012-11-04 07:37:18
【问题描述】:

嗨,我正在尝试在 Flash CS3 动作脚本上创建一个游戏,并在第 13-15 行不断收到错误消息,说存在与内部命名空间中的定义 _bounces 冲突,与内部命名空间中的定义 _highscore 存在冲突,并且 A与命名空间内部的定义_ball存在冲突???请帮忙

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;
            }

        }
    }
}

【问题讨论】:

  • 您在与上述类相同的目录/包中是否有一个名为 TextField 的文件/类?
  • 我如何检查我是否这样做?不确定
  • 我敢打赌,您在发布属性(用于 ActionScript 3.0 设置)中选择了自动命名阶段实例。

标签: actionscript-3 flash-cs4 adobe-flash-cs3


【解决方案1】:

转到“高级 ActionScript 3.0 设置”-我使用的是 CS5.5,但没有 CS3(但应该是相同的),通过文件 -> 发布设置 -> 动作脚本设置,然后取消选中“自动声明阶段”实例”(这是默认设置)

或者不在类中定义它们。

Detailed description of Error 1151 and resolution

【讨论】:

    【解决方案2】:

    可能你有重复的定义。

    例如:

     var _bounces:TextField;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-05
      • 2015-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-19
      • 2018-03-30
      • 2010-09-20
      相关资源
      最近更新 更多