0
votes

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.

Here's where the problem is:

        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.

Thanks!!

1
Could you mark which line exactly is causing the error? Thanksphisch
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.DanTheMan
Naming conventions for handlers keep code straightforward, such as: onTouchBegin or touchBeginHandler and onMouseOver or mouseOverHandler.Jason Sturges

1 Answers

0
votes

This is the line with the 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.

I'm assuming that the over parameter in the 4 line is a function and will work's fine for you. Also I'm assuming that the TouchEvent.TOUCH_BEGIN property is a string.