あるフレックスモジュールから別のフレックスモジュールにカスタムイベントをディスパッチしようとしています。
イベントをディスパッチするコードは以下のとおりです
Application.application.Destination.child.dispatchEvent(
new AlgoEvent(AlgoEvent.GETFROMPARENT_LOCAL_EVENT));
ここでAlgoEventはカスタムイベントです
反対側では、イベントをキャッチして処理するモジュールに次のコードがあります。
public function sendParametersToChild(e:AlgoEvent):void
{
//some codes
}
ただし、ステートメントApplication.application.Destination.child.dispatchEvent(new AlgoEvent(AlgoEvent.GETFROMPARENT_LOCAL_EVENT));
が実行されると、デバッガーは次の実行時例外を発生させます。
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]
ここで何が問題になっているのか特定できません。この問題の解決にご協力ください
これは私のイベントクラスです
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;
}
}
デバッグ中に、UIComponentクラスのこの機能でエラーが発生します
override public function dispatchEvent(event:Event):Boolean
{
if (dispatchEventHook != null)
dispatchEventHook(event, this);
return super.dispatchEvent(event);
}
まさにこの行はエラーを出します:dispatchEventHook(event, this);