flash - Easiest way to implement a game menu in ActionScript 3? -


at moment game consists of play button which, when clicked, runs game; of happens in document class follows:

stage.addchild(playbtn); playbtn.x = 0; playbtn.y = stage.stageheight/2;; playbtn.addeventlistener(mouseevent.click, playgame); 

the playgame() function removes playbtn stage , event listener, , runs game code. has been fine me until now, want implement more complex menu system, consist of many buttons, graphics, etc (basically stage select screen). question is, more efficient way of displaying menu on screen, removing when stage selected , being able return menu when game over? i'm trying of without use of timeline.

use separate classes each screen. example mainmenu screen class , game class. document class becomes simple screen switching controller, instantiates, adds , removes screen classes.

as long each screen adds content itself, , not stage, document class need not know or care what's inside screens, , removing screen not require each element in screen removed.

as how add elements each screen, let screen class handle it, or symbol linked screen class content.


Comments