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

Popular posts from this blog

CS5 Adobe Media Encoder: Encode failed because the source duration is nil.

cf_sql_integer vs cf_sql_bigint vs cf_sql_int??

localhost/joomla15/administrator doesnt work - Joomla! Forum - community, help and support