# How to dispatchEvent?

**URL:** <https://forum.kirupa.com/t/how-to-dispatchevent/300594>\
**Category:** flash\
**Created:** [November 24, 2009, 10:19am UTC](https://forum.kirupa.com/t/how-to-dispatchevent/300594 "2009-11-24T10:19:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![acebuddy29](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@acebuddy29](https://forum.kirupa.com/u/acebuddy29)\
**Post date:** [November 24, 2009, 10:19am UTC](https://forum.kirupa.com/t/how-to-dispatchevent/300594/1 "2009-11-24T10:19:37Z")

</div>

Hi,  
Guys i have been trying to figure our the dispatchEvent system in as3. But am just not able to wrap my head around it. So can someone please explain and give me an example on how to dispatch custom events?

for eg: Here i just want to disptach event every 100ms and the event should give me the value of “a” . So can someone help me out?

```auto

package com 
{
    import flash.utils.Timer;
    import flash.events.TimerEvent
    import flash.events.EventDispatcher
    /**
     * ...
     * @author
     */
    
    public class test
    {
        
        private var a:Number = 0
        public function test() 
        {
            
        }
        
        private function main_loop(e:TimerEvent)
        {
            a++
            //trace(a)
        }
        
        public function goOn()
        {
        
            var newTimer:Timer = new Timer(100);
            newTimer.addEventListener(TimerEvent.TIMER, main_loop);
            newTimer.start ();
        }
        
    }

}

```
