actionscript 3.0 type coercion failed when dispatching error event
I try to dispatch an error event in an AS3 application:
dispatchEvent( new ErrorEvent( ErrorEvent.ERROR, false, false, "my error message"));
but I get the following runtime error:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::ErrorEvent@2c04239 to com.adobe.protocols.dict.events.ErrorEvent.
at flash.events::EventDispatcher/dispatchEven开发者_JS百科tFunction()
at flash.events::EventDispatcher/dispatchEvent()
at my line of code..
these are my import statements at the top of the file:
import flash.display.MovieClip;
import flash.events.ErrorEvent;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
import flash.security.IURIDereferencer;
import flash.security.ReferencesValidationSetting;
import flash.security.RevocationCheckSettings;
import flash.security.SignatureStatus;
import flash.security.XMLSignatureValidator;
import flash.utils.ByteArray;
import mx.utils.Base64Decoder;
import mx.utils.Base64Encoder;
import mx.utils.SHA256;
what's going on?
thanks
Sometimes that... happens. Between the IDE and Flash's ability to get confused, I'm surprised it doesn't happen more. I suspect the error is actually in your listener though.
Change your event handler to specify flash.events.ErrorEvent
.
function errorHandler( event:flash.events.ErrorEvent ):void
If that doesn't work, you can always either handle all Events or you can use the fully qualified name while constructing the ErrorEvent.
精彩评论