Flex Type Coercion, it was smart, I think

I have a class essentially:

public class WindowEvent extends Event
{
    public static const WARNEVENT:String = "warnEvent";
    public static const TASKREQEVENT:String = "taskRequestEvent";
    public static const TASKANNOUNCE:String = "taskAnnounce";
    public static const WINDOWCHANGE:String = "windowChange";
    public static const ILLEGALPOSITION:String = "illegalPosition";

    // insert brevity   
}

The first four events worked fine, but I just added ILLEGALPOSITIONand tried this:

    // inside Window.as
    private function checkDimensions():void {
       if(!Window._legalBoundaryEnable)
           return;
...    var pass:Boolean = Window.legalBoundary.containsRect(
455        this.getBounds(stage));
456    if(!pass) {
457        this.dispatchEvent(new WindowEvent(WindowEvent.ILLEGALPOSITION,
...           "Illegal Position etc."));
       }
    }

So Flex hit this stack with me when I hit the send method:

TypeError: Error # 1034: Type Coercion failed: cannot convert Β¬
        flex.utils.ui :: WindowEvent @ 511dce41 to flash.events.MouseEvent.
    at flash.events::EventDispatcher/dispatchEventFunction ()
    at flash.events::EventDispatcher/dispatchEvent ()
    at mx.core :: UIComponent / dispatchEvent () Β¬
        [C: \ autobuild \ ~ \ UIComponent.as: 9298]
    at flex.utils.ui :: Window / checkDimensions () [C: \ Users \ ~ \ Window.as: 457]
    at flex.utils.ui :: Window / stageResized () [C: \ Users \ ~ \ Window.as: 220]

, Window.as:457 - . , WTF flash.events.EventDispatcher.dispatchEventFunction MouseEvent?

+5
2

- , . , .

, , ,

someFunction(event : WindowEvent) : void
+5

ILLEGALPOSITION, "illegalPosition" Flex ( ) . , , MouseEvent, , .

+3

All Articles