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…
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