I cannot send a custom event from one module to another as it gives a TypeError: Error # 1034: The type of forced execution failed:

I am trying to send a custom event from one flexible module to another.

The code sending the event is below

Application.application.Destination.child.dispatchEvent(
    new AlgoEvent(AlgoEvent.GETFROMPARENT_LOCAL_EVENT));

here AlgoEvent is a custom event

on the other hand, the module that catches and processes the event has this code:

public  function sendParametersToChild(e:AlgoEvent):void
{
    //some codes
}

but when the statement is executed Application.application.Destination.child.dispatchEvent(new AlgoEvent(AlgoEvent.GETFROMPARENT_LOCAL_EVENT));, the debugger provides the following runtime exception:

TypeError: Error #1034: Type Coercion failed: cannot convert resources.events::AlgoEvent@4182239 to resources.events.AlgoEvent.
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298]
    at components::Destination/sendTimeToChild()[E:\FlexProjects\MyApp\src\components\Destination.mxml:99]
    at components::Destination/updateParameters()[E:\FlexProjects\MyApp\src\components\Destination.mxml:206]
    at components::Destination/__CreateBasketButton_click()[E:\FlexProjects\MyApp\src\components\Destination.mxml:558]

I can’t determine what is going on here. Help solve this problem.

This is my Event class.

public class AlgoEvent extends Event
{
    public static const GETFROMPARENT_LOCAL_EVENT:String = "getfromparent_local";
    private var eventType:String;

    public function AlgoEvent(eventType:String, bubbles:Boolean=false, cancelable:Boolean=false)
    {
        super(eventType,bubbles,cancelable);
        this.eventType=eventType;
    }
}

During debugging, I get an error in this function of the UIComponent class

override public function dispatchEvent(event:Event):Boolean
{
    if (dispatchEventHook != null)
        dispatchEventHook(event, this);

    return super.dispatchEvent(event); 
}

Roughly this line gives an error: dispatchEventHook(event, this);

+3
source share
7 answers

AlgoEvent .

import resources.events.AlgoEvent;
private var dummyEvent: AlgoEvent;

:

- , , Event.

dispatchEvent(new Event(AlgoEvent.GETFROMPARENT_LOCAL_EVENT));
+3

, :

override public function clone():Event
{
    return new AlgoEvent(type, bubbles, cancelable);
}

override public function toString():String
{
        return formatToString("AlgoEvent","type"","bubbles","cancelable","eventPhase");
}

, :)

+2

. , :

Custum Event ( Algo Event ) .

I.e ..

β†’ , , : , , , .. Event .

Custum , Custum, . , , Custum, , .

, , :

http://www.kirupa.com/forum/showthread.php?t=320390

http://www.jeffdepascale.com/index.php/flash/custom-events-in-loaded-swf-files/

+1

Mate Framework . . http://mate.asfusion.com/

0

clone() AlgoEvent. AlgoEvent.as :

public clone(): {            AlgoEvent (eventType, bubbles, cancelable);          } .

0

:

public class AlgoEvent extends Event
{
    public static const GETFROMPARENT_LOCAL_EVENT:String = "getfromparent_local";

    public function AlgoEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
    {
        super(type, bubbles, cancelable);
    };

    override public function clone():AlgoEvent
    {
        return new AlgoEvent(type, bubbles, cancelable);
    };
};

, .

, UIComponent dispatchEvent, - - .

, Rob

0

, , , , , . Application.application , . -, , , , .

. . , Parsley. . , , , , ( 3 ).

I recommend that you watch it, as well as a presentation on the introduction to parsley .

-1
source

All Articles