Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Action Script 3 help me with this tutorial?

New Here ,
Jan 05, 2015 Jan 05, 2015

Can someone show me what code I am suppose to have made at the end of the tutorial. In my version the button I click doesn't work to move onto the game.

Activity 3:

Aim: Creating a new INIT function for the “Start Screen”.

1. The next step to this game is to create a “Start” screen. Now this is going to be the

first thing that loads when the game start, so the suggestion is we make some changes

to the structure of the current game. The first thing is renaming:

private function init(e:Event = null):void

To:

private function game(e:Event = null):void

This helps make the title for this function more obvious and appropriate.

2. Now that we have made this change we can recreate a brand new init function for the

start screen. We create this above the game function.

The new public function init(e:Event = null):void will contain:

• Declaring the start image as a new Go();

• add it as a child• Position it suitably in the centre of the screen.

Test and Annotate

3. Now that the start button image is displayed on the screen appropriately we need to

make it clickable. So, within the new init function add an “EventListener”, which is

a “MouseEvent” CLICK, which takes you to a new Method called “startgame()”.

4. So now that the listener is in place we need to make the new public function called

“startgame()”, for which the previous listener is pointing to. This will look like:

public function startgame(e:Event):void

{

//SOME CODE

}

This is to be placed under your init function. The “e:Event” part states that this will

have some kind of action event happening to it.

5. Within this Method we need to set up a statement that will send the player to the game

itself when the start image is clicked. This will be an “If” statement, and will look like

this:

Start => The e.target==start =(True)=> removechild(start) => game() =>stop

TOPICS
ActionScript
218
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 05, 2015 Jan 05, 2015

// that looks like a pretty poor tutorial.  but

public function init(e:Event=null):void{

go=new Go();  // you need to declare go

addChild(go);

go.addEventListener(MouseEvent.CLICK,startgame);

}

public function startgame(e:Event):void{

removeChild(start_mc);  // where start_mc is the movieclip of your start screen

addChild(game_mc);  // where game_mc is the movieclip of your game

}

Translate
Community Expert ,
Jan 05, 2015 Jan 05, 2015
LATEST

// that looks like a pretty poor tutorial.  but

public function init(e:Event=null):void{

go=new Go();  // you need to declare go

addChild(go);

go.addEventListener(MouseEvent.CLICK,startgame);

}

public function startgame(e:Event):void{

removeChild(start_mc);  // where start_mc is the movieclip of your start screen

addChild(game_mc);  // where game_mc is the movieclip of your game

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines