Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do i transition between game and menu without using frames in as3?
    primarykey
    data
    text
    <p>I have simplified this code for easier reading</p> <p>I have one class called LevelSelect, one class called Game, and one class called NavButtons. */</p> <pre><code>The code below i have added levelSelect MovieClip to the stage and added level numbers to level boxes onclick it goes to my selected level. public class LevelSelectPage extends Game { public var levelSelectScreen:level_selection; public var list:Array; // add movieClips to L1,L2 etc... public static var Level:String = "No Level Selected"; public static var shared:SharedObject; public function LevelSelectPage( ) { setUpLevelSelect(); } public function setUpLevelSelect():void { shared = SharedObject.getLocal("savegame"); shared.clear(); // remove when game completed if (shared.data.level_passed == undefined) { shared.data.level_passed = 3; } if (shared.data.playing_level == undefined) { shared.data.playing_level = "L0"; } else { shared.data.playing_level = "L0"; } levelSelectScreen = new level_selection(); addChild(levelSelectScreen); AddMovieClipsForLevels(); } public function AddMovieClipsForLevels():void { // array of movieClip instances... level pictures. list = [ levelSelectScreen.L1, levelSelectScreen.L2, levelSelectScreen.L3 ]; list.forEach(setupSquare); } public function setupSquare(square:MovieClip, index:int, array:Array):void { // add numbers on top of level images // get numbers of the levels... as index starts from 0, add 1 var LevelNumber:Number = index + 1; // convert number to string var imageLevelNumber:String = LevelNumber.toString(); // set textfield // get childs instance name var insertlevelNumber:TextField = square.getChildByName("levelNumberText") as TextField; // output text insertlevelNumber.text = imageLevelNumber; } public function onSquareClick(me:MouseEvent):void { switch(me.currentTarget.name) { case "L1": // trace("level 1 was selected"); // startGame(); break; } } } } public class Game { // imagen a blank screen, it doesn't matter } </code></pre> <p>The code bellow - i have added the nav buttons to the game stage, and on click of the back button it outputs a trace statment but how do i run the LevelSelectPage again instead ?</p> <pre><code>public class NavButtons { private var m_NavDisplayIcon:ReferenceArray; private var m_stage:Stage; public function NavButtons( stage:Stage ) { // add navigation to stage m_stage = stage; m_NavDisplayIcon = new ReferenceArray( navDisplayFla ); var icon:navDisplayFla = new navDisplayFla( ); icon.x = 5; icon.y = 5; m_NavDisplayIcon.Add( icon ); m_stage.addChild( icon ); // addEventlisteners for backButton, pause game and information icon.backIcon.addEventListener(MouseEvent.CLICK, goBackToLevelSelectPage); icon.pauseIcon.addEventListener(MouseEvent.CLICK, pauseGame); icon.informationIcon.addEventListener(MouseEvent.CLICK, showInformation); } public function goBackToLevelSelectPage( event:MouseEvent ):void { //var levelSelectScreen:level_selection = new LevelSelectPage(); //m_stage.addChild(levelSelectScreen); trace("you pressed the backButton"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload