Question

hi, I am trying to create a game on Flash CS3 Action Script and keep getting error on line 13-15 saying that A conflict exists with definition _bounces in namespace internal, A conflict exists with definition _highscore in namespace internal, and A conflict exists with definition _ball in namespace internal??? and help please

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

        }
    }
}
Was it helpful?

Solution

Go to "Advanced ActionScript 3.0 Settings" - I'm using CS5.5 and don't have CS3 (but it should be same) via File -> Publish Settings -> ActionScript Settings and there uncheck the "Automatically declare stage instances" (this is default setting)

or do not define them in the class.

Detailed description of Error 1151 and resolution

OTHER TIPS

probably you have duplicated definitions.

like For example:

 var _bounces:TextField;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top