1
votes

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/dispatchEventFunction()
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

1
The error happens where you listen for the ErrorEvent. Check the imports there. - maxmc
wow - indeed! the autocompletion of the IDE did that - if i type var e:ErrorEvent and hit enter, it adds import com.adobe.protocols.dict.events.ErrorEvent; to the top of the file. how can I change that behaviour? - Mat

1 Answers

2
votes

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.