Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Argument Error #1063: Argument count mismatch

Community Beginner ,
Aug 28, 2013 Aug 28, 2013

So I'm having another issue my code.  I keep getting this error whenever I test:

ArgumentError: Error #1063: Argument count mismatch on Enemy(). Expected 2, got 0.

    at flash.display::Sprite/constructChildren()

    at flash.display::Sprite()

    at flash.display::MovieClip()

    at MenuScreen()

    at DocumentClass()

Here's my code for MenuScreen:

<pre>

package

{

    import flash.display.MovieClip;

    import flash.display.SimpleButton;

    import flash.events.MouseEvent;

   

    public class MenuScreen extends MovieClip

    {

        public function MenuScreen()

        {

            var startButton:StartButton = new StartButton();

            startButton.addEventListener( MouseEvent.CLICK, onClickStart );

        }

       

        public function onClickStart( event:MouseEvent ):void

        {

            dispatchEvent( new NavigationEvent( NavigationEvent.START ) );

        }

    }

}

</pre>

And here's my code for DocumentClass:

<pre>

package

{

    import flash.display.MovieClip;

    public class DocumentClass extends MovieClip

    {

        public var menuScreen:MenuScreen;

        public var playScreen:AvoiderGame;

        public var gameOverScreen:GameOverScreen;

       

        public function DocumentClass()

            {

                super();

                menuScreen = new MenuScreen();

                menuScreen.addEventListener( NavigationEvent.START, onRequestStart );

                menuScreen.x = 0;

                menuScreen.y = 0;

                addChild( menuScreen );

               

            }

           

            public function onAvatarDeath( avatarEvent:AvatarEvent ):void

            {

                gameOverScreen = new GameOverScreen();

                gameOverScreen.addEventListener( NavigationEvent.RESTART, onRequestRestart );

                gameOverScreen.x = 0;

                gameOverScreen.y = 0;

                addChild( gameOverScreen );

               

                playScreen = null;

            }

           

            public function onRequestRestart( navigationEvent:NavigationEvent ):void

            {

                restartGame();

            }

           

            public function onRequestStart( navigationEvent:NavigationEvent ):void

            {

                playScreen = new AvoiderGame();

                playScreen.addEventListener( AvatarEvent.DEAD, onAvatarDeath );

                playScreen.x = 0;

                playScreen.y = 0;

                addChild( playScreen );

               

                menuScreen = null

            }

            public function restartGame():void

            {

                    menuScreen = new MenuScreen();

                menuScreen.addEventListener( AvatarEvent.DEAD, onAvatarDeath );

                menuScreen.x = 0;

                menuScreen.y = 0;

                addChild( menuScreen );

               

                gameOverScreen = null;

            }

           

    }

}

</pre>

Any ideas?

TOPICS
ActionScript
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 28, 2013 Aug 28, 2013

My idea is the code you're posting has nothing to do with the error. It speaks of a function called Enemy which isn't present in the code nor do any of the lines the error mention line up with the error. Are you removing anything from this code?

The basics of the error is the Enemy method (or constructor) is expecting 2 arguments. 0 were supplied. Check where you use that method and make sure it's sending the arguments it expects.

Otherwise there's plenty of other concerning things such as creating a variable in a constructor of MenuScreen but not adding it to the display list so it won't even be visible. It will still exist because a reference to a valid function is assigned however.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 28, 2013 Aug 28, 2013

Hi sinious - yeah that's what I was thinking, but why does it say in the error message that it's in these two AC3 files?  I'm very new to it too.  Here's my Enemy file:

<pre>

package

{

    import flash.display.MovieClip;

    public class Enemy extends MovieClip

    {

        public function Enemy( startX:Number, startY:Number )

        {

            x = startX;

            y = startY;

        }

       

        public function moveDownABit():void

        {

            y = y + 3;

        }

    }

}

</pre>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 28, 2013 Aug 28, 2013
LATEST

Your Enemy class is expecting an an x/y position as arguments. The question is, where is the line of code that instantiates the Enemy class? It isn't supplying those 2 values.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines