AS3 Error 1067 (coerción implícita) al intentar agregarEventListener

So I'm developing a sorting game for a game jam, and my AS3 skills are still a bit unrefined.

I have an InputManager.as that determines whether the device is touch-capable or not, and then in the classes that need it, grabbing that info.

Problem I'm having is:

C:\GameDev\Progressive Bytes\Dan\Scripts\Screens\Buttons.as, Line 55 1067: Implicit coercion of a value of type String to an unrelated type Function.

Aquí es donde está el problema:

        if(InputManager.isTouch){
            this.addEventListener(TouchEvent.TOUCH_BEGIN, TouchEventHandler);
        } else {
            this.addEventListener(MouseEvent.MOUSE_OVER, over);
        }

This is in the Button's constructor.

I've done a bit of searching around, but I can't seem to find any answers about a 1067 on an event listener that are relevant to this problem. But, as I said, kind of a noob with AS3.

¡¡Gracias!!

preguntado el 05 de mayo de 13 a las 15:05

Could you mark which line exactly is causing the error? Thanks -

Got it. Turns out the addEventListener thought the over function was a string, because (though I haven't located it yet), a public var over:String was declared somewhere else. I just changed the name of the function to Over() and it works now. -

Naming conventions for handlers keep code straightforward, such as: onTouchBegin or touchBeginHandler y onMouseOver or mouseOverHandler. -

1 Respuestas

Esta es la línea con el error:

this.addEventListener(TouchEvent.TOUCH_BEGIN, TouchEventHandler);

You have to understand that the first parameter is a string with the name of the event, the second parameter must be a function and you pass a class reference.

Asumo que el encima parameter in the 4 line is a function and will work's fine for you. Also I'm assuming that the TouchEvent.TOUCH_BEGIN propiedad es una cadena.

contestado el 05 de mayo de 13 a las 17:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.