# \*sigh custome events in as3 - again. :sigh:

**URL:** <https://forum.kirupa.com/t/sigh-custome-events-in-as3-again-sigh/270647>\
**Category:** flash\
**Created:** [September 11, 2008, 10:47pm UTC](https://forum.kirupa.com/t/sigh-custome-events-in-as3-again-sigh/270647 "2008-09-11T22:47:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tedc](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@tedc](https://forum.kirupa.com/u/tedc)\
**Post date:** [September 11, 2008, 10:47pm UTC](https://forum.kirupa.com/t/sigh-custome-events-in-as3-again-sigh/270647/1 "2008-09-11T22:47:03Z")

</div>

So, I am trying to pass some arguments through a custom MouseEvent. This is my code:

_Document Class (Main.as)_

```auto

package {
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import Events.MyCheckBoxEvent;
	
	/**
	* Main Class
	* @ purpose: Document class for movie
	*/
	
	public class Main extends Sprite{
		
		public function Main(){
			
			//instantiate concrete creators
			//var cable1:Page = new Cable1();
			
			var cb:CheckBox = new CustomCheckBox();
			addChild(cb);
			cb.addEventListener(MyCheckBoxEvent.CLICK, clickHandler, false, 0, ["ted","john","doug"]);			
			
		}
		private function clickHandler(e:MyCheckBoxEvent){
			trace(e.argumentArray);
		}
	}
}

```

_MyCheckBoxEvent.as_

```auto

package Events{

	import flash.events.MouseEvent;
	import flash.events.Event;
	
	public class MyCheckBoxEvent extends MouseEvent {

		public static const CLICK:String = "click";
		private var _argArray:Array;

		public function MyCheckBoxEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, argArray:Array = null) {
			super(type,bubbles,cancelable);
             _argArray = argArray;
		}

		public function get argumentArray():Array {
			return _argArray;
		}

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

```

So I dont get any compiler errors at runtime, but when I click on the checkbox I get this error:

**TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::MouseEvent@10add4a9 to Events.MyCheckBoxEvent.**

If I make the argument of the event handler function to be just MouseEvent instead of MyCheckBoxEvent then it works, but it doesnt recognize the \_argArray getter… This is driving me mad! I have spent like 3 hours on this already… I tried casting the Event as a MyCheckBoxEvent and same thing…
