I have been creating custom event for my smart loader but somehow it got some errors like “TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@dc3a251 …” and I does override clone method to avoid this error but it doesn’t help at all.

Here is code:

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.xllusion.events {
	// Import class
	import flash.events.*;
	import flash.display.*;
	// SmartLoaderEvent
	public class SmartLoaderEvent extends Event {
		// Event constants
		public static const ITEM_ERROR:String = "itemError";
		public static const ITEM_OPEN:String = "itemOpen";
		public static const ITEM_PROGRESS:String = "itemProgress";
		public static const ITEM_COMPLETE:String = "itemComplete";
		public static const ITEM_INIT:String = "itemInit";
		public static const ITEM_REMOVE:String = "itemRemove";
		public static const ALL_COMPLETE:String = "allComplete";
		// Properties
		public var __target:Sprite;
		public var __data:Object;
  		public var __bytesLoaded:Number;
		public var __bytesTotal:Number;	
		public var __percent:int;
  		// Constructor
  		public function SmartLoaderEvent(type:String, target:Sprite = null, data:Object = null, bytesLoaded:Number = 0, bytesTotal:Number = 0, percent:int = 0,  bubbles:Boolean = false, cancelable:Boolean = false) {
   			super(type, bubbles, cancelable);
			__target = target;
			__data = data;
			__bytesLoaded = bytesLoaded;
			__bytesTotal = bytesTotal;
			__percent = percent;
   		}
		// Override clone()
		override public function clone():Event{
			return new SmartLoaderEvent(type, __target, __data, __bytesLoaded, __bytesTotal, __percent, bubbles, cancelable);
		}
	}
}

After 2 hours of testing, I have found the source problem which is:

?View Code ACTIONSCRIPT
1
public static const ALL_COMPLETE:String = "allComplete";

The string “allComplete” somehow causes compile error and I can not find if it is reserved by AS3 or not so I have to change it to “allCompletes” and everything works fine:

?View Code ACTIONSCRIPT
1
public static const ALL_COMPLETE:String = "allCompletes";