Skip navigation
Currently Being Moderated

help me please error #1063

Apr 20, 2012 3:30 PM

hi guys

 

i have  3 classes in the library (external classes) and 1 document class called Main

 

and iam getting these  errors all the time i dont know why

 

ArgumentError: Error #1063: Argument count mismatch on tree1/onAdded(). Expected 0, got 1.

    at flash.display::DisplayObjectContainer/addChild()

    at Main()

ArgumentError: Error #1063: Argument count mismatch on tree1/onAdded(). Expected 0, got 1.

    at flash.display::DisplayObjectContainer/addChild()

    at Main()

ArgumentError: Error #1063: Argument count mismatch on tree1/onAdded(). Expected 0, got 1.

    at flash.display::DisplayObjectContainer/addChild()

    at Main()

ArgumentError: Error #1063: Argument count mismatch on tree1/onAdded(). Expected 0, got 1.

    at flash.display::DisplayObjectContainer/addChild()

    at Main()

ArgumentError: Error #1063: Argument count mismatch on tree1/onAdded(). Expected 0, got 1.

    at flash.display::DisplayObjectContainer/addChild()

    at Main()

ArgumentError: Error #1063: Argument count mismatch on tree1/onAdded(). Expected 0, got 1.

    at flash.display::DisplayObjectContainer/addChild()

    at Main()

 

 

 

here are the classes code (the external classes ) in the lib

 

MAINMAP1 class

package

 

{

import flash.system.System;

import flash.system.fscommand;

 

    import flash.display.MovieClip;

import flash.media.Sound;

    import flash.media.SoundChannel;

    import flash.events.KeyboardEvent;

 

    import flash.ui.Keyboard;

 

    import flash.events.Event;

 

    import flash.events.MouseEvent;

    import flash.display.Stage;

public class MAINMAP1 extends MovieClip {

    var vx:int = 0

    var vy:int = 0

   

  public function MAINMAP1(){

    addEventListener(Event.ADDED_TO_STAGE, onAdded)

   

  }

  public function onAdded (event:Event):void  {

     

}

}

}

 

tree1 class

 

package{

    import flash.system.System;

import flash.system.fscommand;

 

    import flash.display.MovieClip;

import flash.media.Sound;

    import flash.media.SoundChannel;

    import flash.events.KeyboardEvent;

 

    import flash.ui.Keyboard;

 

    import flash.events.Event;

 

    import flash.events.MouseEvent;

    import flash.display.Stage;

   

   

   

   

    public class tree1 extends MovieClip{

       

       

   

        public function tree1 (){

                addEventListener(Event.ADDED_TO_STAGE, onAdded)

 

 

        }

                public function onAdded (){

                   

                                              addEventListener(Event.ENTER_FRAME, onEnterFrame);

 

                }

    public function onEnterFrame(event:Event){

        {

         

           

        }

    }

 

}

}

      

 

HERO class

 

package{

    import flash.system.System;

import flash.system.fscommand;

 

    import flash.display.MovieClip;

import flash.media.Sound;

    import flash.media.SoundChannel;

    import flash.events.KeyboardEvent;

 

    import flash.ui.Keyboard;

 

    import flash.events.Event;

 

    import flash.events.MouseEvent;

    import flash.display.Stage;

   

   

   

   

    public class HERO extends MovieClip{

       

       

    private var vx:int = 0;

        private var vy:int = 0;

 

        public function HERO (){

                addEventListener(Event.ADDED_TO_STAGE, onAdded)

 

 

        }

               

                public function onAdded (event:Event):void  {

      gotoAndStop(3)

     

          addEventListener(Event.ENTER_FRAME, onEnterFrame);

        stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown);

            stage.addEventListener(KeyboardEvent.KEY_UP,onKeyUp);

 

 

  }

    public function onEnterFrame(event:Event){

       

        x += vx

        y += vy

       

    }

 

    public function onKeyDown(event:KeyboardEvent){

        if (event.keyCode == Keyboard.LEFT){

            gotoAndStop(2)

            vx = -5

           

           

       

        }

                if (event.keyCode == Keyboard.RIGHT){

                    gotoAndStop(1)

                                vx = 5

 

                   

                   

                }

        if (event.keyCode == Keyboard.DOWN){

           

            vy = +5

            gotoAndStop(6)

}

if (event.keyCode == Keyboard.UP){

           

            vy = -5

           

}

 

    }

public function onKeyUp(event:KeyboardEvent){

            if (event.keyCode == Keyboard.LEFT ||event.keyCode == Keyboard.RIGHT ){

                vx= 0;

               

            }

if (event.keyCode == Keyboard.UP ||event.keyCode == Keyboard.DOWN ){

                vy= 0;

            }

   

       

    }

 

         

 

}

}

 

   

 

THE DOCUMENT CLASS (Main)

 

package  {

   

    import flash.system.System;

import flash.system.fscommand;

 

    import flash.display.MovieClip;

import flash.media.Sound;

    import flash.media.SoundChannel;

    import flash.events.KeyboardEvent;

 

    import flash.ui.Keyboard;

 

    import flash.events.Event;

 

    import flash.events.MouseEvent;

    import flash.display.Stage;

       

 

   

    public class Main extends MovieClip {

       

        var mainmap1:MAINMAP1 = new MAINMAP1;

        public function Main() {

            addChild(mainmap1);

           

           

        }

    }

   

}

 

done

 

the program running but there are errors in the output i couldn.t get it

help me please

thank you

 
Replies
  • kglad
    61,985 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 20, 2012 6:34 PM   in reply to thunderxlight11111

    onAdded() is called by an event listener that's passing an event.  use:

     

    function onAdded(e:Event):void{

    //etc

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 20, 2012 6:41 PM   in reply to thunderxlight11111

    I only looked for the first I could find, so hopefully you can solve the rest if there are more...

     

    you are assigning an event listener here that will trigger the onAdded event handler

     

          addEventListener(Event.ADDED_TO_STAGE, onAdded) 

     

    But your event handler is not geared to work as an event handler because it does not provide for receiving the event argument...

     

           public function onAdded (){

     

    it needs to be

     

           public function onAdded (evt:Event){

     

     

    So reread the error message an try to understand how it is telling you exactly what the problem is... become familiar with what it means because it can be a frequent error when coding, and understanding it saves time solving it.

     

         

     
    |
    Mark as:
  • kglad
    61,985 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 21, 2012 5:34 AM   in reply to thunderxlight11111

    you're welcome.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points