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

[AS3] How to limit wrong question ? *Inspired by Fallout Hack

Explorer ,
Feb 12, 2017 Feb 12, 2017

Hi guys, I have some problem when creating "Hacking game". Inspired by Fallout hacking, I want to limit user to click (choose password). But the problem is, my script doesn't move to frame 2, even the i reach the limit, it still stay on the frame. How to make the while works well ? So after choose 3 wrong answer, it will move to frame 2 properly ?

Thanks for your help.

====The script====

import flash.events.MouseEvent;

stop();

mc_0.visible=false;

mc_1.visible=false;

mc_2.visible=false;

mc_3.visible=false;

mc_4.visible=false;

mc_5.visible=false;

var i:int=0;

while(i<=3)

{

btn_codes.addEventListener(MouseEvent.CLICK,corr);

btn_pages.addEventListener(MouseEvent.CLICK,two);

btn_cages.addEventListener(MouseEvent.CLICK,three);

btn_trial.addEventListener(MouseEvent.CLICK,zero);

btn_trees.addEventListener(MouseEvent.CLICK,two);

btn_cares.addEventListener(MouseEvent.CLICK,three);

btn_clamp.addEventListener(MouseEvent.CLICK,one);

btn_trump.addEventListener(MouseEvent.CLICK,zero);

btn_rests.addEventListener(MouseEvent.CLICK,zero);

function zero(e:MouseEvent){

  mc_0.visible=true;

  mc_1.visible=false;

  mc_2.visible=false;

  mc_3.visible=false;

  mc_4.visible=false;

  mc_5.visible=false;

  i++;

  trace(i);

  }

function one(e:MouseEvent){

  mc_1.visible=true;

  mc_0.visible=false;

  mc_2.visible=false;

  mc_3.visible=false;

  mc_4.visible=false;

  mc_5.visible=false;

  i++;

  trace(i);

  }

function two(e:MouseEvent){

  mc_2.visible=true;

  mc_1.visible=false;

  mc_0.visible=false;

  mc_3.visible=false;

  mc_4.visible=false;

  mc_5.visible=false;

  i++;

  trace(i);

  }

function three(e:MouseEvent){

  mc_3.visible=true;

  mc_1.visible=false;

  mc_2.visible=false;

  mc_0.visible=false;

  mc_4.visible=false;

  mc_5.visible=false;

  i++;

  trace(i);

  }

function four(e:MouseEvent){

  mc_4.visible=true;

  mc_1.visible=false;

  mc_2.visible=false;

  mc_3.visible=false;

  mc_0.visible=false;

  mc_5.visible=false;

  i++;

  trace(i);

  }

function corr(e:MouseEvent){

  mc_5.visible=true;

  gotoAndPlay(3);

  }

}

gotoAndPlay(2);

=====

The screenshot

1.jpg

5.jpg

TOPICS
ActionScript
770
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 , Feb 13, 2017 Feb 13, 2017

stop();

mc_0.visible=false;

mc_1.visible=false;

mc_2.visible=false;

mc_3.visible=false;

mc_4.visible=false;

mc_5.visible=false;

var attempts:int = 0;

btn_codes.addEventListener(MouseEvent.CLICK,corr);

btn_pages.addEventListener(MouseEvent.CLICK,two);

btn_cages.addEventListener(MouseEvent.CLICK,three);

btn_trial.addEventListener(MouseEvent.CLICK,zero);

btn_trees.addEventListener(MouseEvent.CLICK,two);

btn_cares.addEventListener(MouseEvent.CLICK,three);

btn_clamp.addEventListener(MouseEvent.CLICK,one);

btn_trump

...
Translate
Community Expert ,
Feb 13, 2017 Feb 13, 2017

stop();

mc_0.visible=false;

mc_1.visible=false;

mc_2.visible=false;

mc_3.visible=false;

mc_4.visible=false;

mc_5.visible=false;

var attempts:int = 0;

btn_codes.addEventListener(MouseEvent.CLICK,corr);

btn_pages.addEventListener(MouseEvent.CLICK,two);

btn_cages.addEventListener(MouseEvent.CLICK,three);

btn_trial.addEventListener(MouseEvent.CLICK,zero);

btn_trees.addEventListener(MouseEvent.CLICK,two);

btn_cares.addEventListener(MouseEvent.CLICK,three);

btn_clamp.addEventListener(MouseEvent.CLICK,one);

btn_trump.addEventListener(MouseEvent.CLICK,zero);

btn_rests.addEventListener(MouseEvent.CLICK,zero);

function zero(e:MouseEvent){

  mc_0.visible=true;

  mc_1.visible=false;

  mc_2.visible=false;

  mc_3.visible=false;

  mc_4.visible=false;

  mc_5.visible=false;

  attempts++;

  checkForLimitF();

  }

function one(e:MouseEvent){

  mc_1.visible=true;

  mc_0.visible=false;

  mc_2.visible=false;

  mc_3.visible=false;

  mc_4.visible=false;

  mc_5.visible=false;

  attempts++;

  checkForLimitF();

  }

function two(e:MouseEvent){

  mc_2.visible=true;

  mc_1.visible=false;

  mc_0.visible=false;

  mc_3.visible=false;

  mc_4.visible=false;

  mc_5.visible=false;

  attempts++;

  checkForLimitF();

  }

function three(e:MouseEvent){

  mc_3.visible=true;

  mc_1.visible=false;

  mc_2.visible=false;

  mc_0.visible=false;

  mc_4.visible=false;

  mc_5.visible=false;

  attempts++;

  checkForLimitF();

  }

function four(e:MouseEvent){

  mc_4.visible=true;

  mc_1.visible=false;

  mc_2.visible=false;

  mc_3.visible=false;

  mc_0.visible=false;

  mc_5.visible=false;

  attempts++;

  checkForLimitF();

  }

function corr(e:MouseEvent){

  mc_5.visible=true;

  gotoAndPlay(3);

  }

function  checkForLimitF();

if(attempts>2){

gotoAndPlay(2);

}

}

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
Explorer ,
Feb 13, 2017 Feb 13, 2017

Wow thanks for your help kglad.
I Didn't think about that.

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
Community Expert ,
Feb 13, 2017 Feb 13, 2017

you're welcome

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
Explorer ,
Feb 13, 2017 Feb 13, 2017

Sorry, I have 1 question again...

How to add information for the limit ?

For example,

solution.jpg

I've tried to put

keterangan.text="3 attemps left"; on initialization and add script to the checkLimit()

function checkLimit(){

if(attemps>3){

  if(attemps==1) {

  keterangan.visible=false;

  }

  else if(attemps==2){

  keterangan.text="tried 2 of 4";

  }

  else if(attemps==3){

  keterangan.text="YOUR_LAST_CHANCE";

  }

  else if(attemps==4){

  gotoAndPlay(2);

   }

}

But still, the text not changing, only show the initalization text (3 attemps left)

What did I missed ?

Thanks

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
Community Expert ,
Feb 14, 2017 Feb 14, 2017

function  checkForLimitF();

if(attempts>3){

gotoAndPlay(2);

} else {

switch (attemps){

case 1:

keterangan.text='2 left';

break;

case 2:

keterangan.text='1 left';

}

}

}

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
Explorer ,
Feb 14, 2017 Feb 14, 2017

Thanks a lot.

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
Community Expert ,
Feb 14, 2017 Feb 14, 2017
LATEST

you're welcome.

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