# Button Click problem

**URL:** <https://forum.kirupa.com/t/button-click-problem/266273>\
**Category:** flash\
**Created:** [July 17, 2008, 10:38pm UTC](https://forum.kirupa.com/t/button-click-problem/266273 "2008-07-17T22:38:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![adnan794](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@adnan794](https://forum.kirupa.com/u/adnan794)\
**Post date:** [July 17, 2008, 10:38pm UTC](https://forum.kirupa.com/t/button-click-problem/266273/1 "2008-07-17T22:38:23Z")

</div>

Hello

I have made 5 buttons and I want the first button name home to clicked when the site loads the first time. I dont know how to dipatch a click event for home button when the site loads can anyone please help. here is the code…

```auto

public function createMenus(mArray:Array)
		{
			for (var i:int = 0; i < mArray.length; i++)
			{
				var siteButton:MainMenuButton = new MainMenuButton(mArray*);
					siteButton.name = mArray*.name;
					siteButton.addEventListener(MouseEvent.CLICK,clicked);
					siteButton.x = 110 * j;
					MainNavigation.getInstance().addChild(siteButton);
					j++;
				}

		// the line below is giving an error saying Access of an undefined property Home	
   ** Home.dispatchEvent (new MouseEvent(MouseEvent.CLICK));
**
		}// end function 

		
	public function clicked(e:MouseEvent):void
	{    
	if (currentButton) 
	{   
	   currentButton.addEventListener(MouseEvent.CLICK,clicked);
            currentButton.enabledState();		 
		}    
		currentButton = MainMenuButton(e.currentTarget);
		currentButton.removeEventListener(MouseEvent.CLICK,clicked);		
		currentButton.disabledState();
		//trace(currentButton.name);
		}

```

Any help will be really appreicated  
Thanks
