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
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.
ohh yeah i just forget that ,
the 2 answers are correct (i guess) it works now i.ve changed it in the the tree class, but i realy couldn.t understand the first answer before this
public function onAdded (){
it needs to be
public function onAdded (evt:Event){
thank you alot guys for helping me and for giving me from your time
North America
Europe, Middle East and Africa
Asia Pacific