Search code examples
actionscript-3flashdevelop

ArgumentError: Error #1063: board/remove() - no argument at all


How can there be an argument mismatch without any arguments in either caller or object function?

 this.addEventListener(MouseEvent.CLICK, remove);
        }
        private function remove():void
        { 
           trace("check");

           removeChild(start);
            start = null;

        }

Solution

  • An event listener's handler requires an event argument. The event dispatcher will pass the event itself as an argument to whatever handler has been registered.

    this.addEventListener(MouseEvent.CLICK, remove);
        }
        private function remove( e:MouseEvent ):void
        { 
           trace("check");
    
           removeChild(start);
            start = null;
    
        }
    

    The argument's type should generally match whatever event type you are using, but it can obviously be any type that it extends as well (so e:Event will always work). The e property will be the event, so you can access properties available on the event (like in ProgressEvent, you have access to bytesLoaded and bytesTotal).