Can't figure out this error
i'm new as3 , can't figure out error in code:
package
{
import flash.display.movieclip;
import flash.events.mouseevent;
public class main extends movieclip
{
var startmenu:startmenu;
var firstlevel:firstlevel;
public function main()
{
startmenu = new startmenu();
firstlevel = new firstlevel();
addchild(startmenu);
//event listeners
startmenu.startbutton.addeventlistener(mouseevent.click, onclick);
}
function onclick(event:mouseevent):void
{
addchild(firstlevel);
removechild(startmenu);
}
}
}
error:
---------
description --> 1119: access of possibly undefined property startbutton through reference static type class.
source --------> startmenu.startbutton.addeventlistener(mouseevent.click, onclick);
if can help, time.
error indicates there no startbutton property in start menu.
if startbutton child of startmenu - not property, , need write code like:
startmenu.getchildat(startmenu.getchildindex(startbutton)).addeventlistener(mouseevent.cli ck, onclick);
this pretty bad architecture though. should write public method/property allow access startbutton.
More discussions in ActionScript 3
adobe
Comments
Post a Comment