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

I am trying to code an if statement that allows multiple conditions, but what I have tried will not work.

New Here ,
Jun 07, 2015 Jun 07, 2015

This is what I have

if((Knife2.visible=true)&&(Gun2.visible=true)&&(Note2.visible=true)&&(Phone2.visible=true)){

  Next.visible=true

}

I have different click events that makes each of these symbols visible, I want it to recognize when each of these are visible and then show "Next" could somebody please help me with this, its urgent.

TOPICS
ActionScript
536
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 , Jun 08, 2015 Jun 08, 2015

your if-statement executes before any of your buttons are clicked.  fix that:

Next01.visible=false

Knife2.visible=false

Gun2.visible=false

Note2.visible=false

Phone2.visible=false

function checkF():void{

if((Knife2.visible==true)&&(Gun2.visible==true)&&(Note2.visible==true)&&(Phone2.visible==t rue) ){

  Next01.visible=true

}

}

Knife.addEventListener(MouseEvent.CLICK, KnifeHide);

function KnifeHide(event:MouseEvent):void

{

  Knife.visible=false;

    Knife2.visible=true

checkF()

}

Gun.ad

...
Translate
Community Expert ,
Jun 07, 2015 Jun 07, 2015

use the double equal (==) to test for equality:

drew simpson wrote:

This is what I have

if((Knife2.visible==true)&&(Gun2.visible==true)&&(Note2.visible==true)&&(Phone2.visible==true) ){

  Next.visible=true

}

//or with booleans:

if((Knife2.visible)&&(Gun2.visible&&(Note2.visible)&&(Phone2.visible) ){

  Next.visible=true

}

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
New Here ,
Jun 08, 2015 Jun 08, 2015

Thanks man

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
New Here ,
Jun 08, 2015 Jun 08, 2015

Unfortunately it doesn't work, il show you my whole code, I am very new to AS.

I have this:

Next01.visible=false

Knife2.visible=false

Gun2.visible=false

Note2.visible=false

Phone2.visible=false

if((Knife2.visible==true)&&(Gun2.visible==true)&&(Note2.visible==true)&&(Phone2.visible==true) ){

  Next01.visible=true

}

Knife.addEventListener(MouseEvent.CLICK, KnifeHide);

function KnifeHide(event:MouseEvent):void

{

  Knife.visible=false;

    Knife2.visible=true

}

Gun.addEventListener(MouseEvent.CLICK, GunHide);

function GunHide(event:MouseEvent):void

{

  Gun.visible=false;

    Gun2.visible=true

}

Note.addEventListener(MouseEvent.CLICK, NoteHide);

function NoteHide(event:MouseEvent):void

{

  Note.visible=false;

    Note2.visible=true

}

Phone.addEventListener(MouseEvent.CLICK, PhoneHide);

function PhoneHide(event:MouseEvent):void

{

  Phone.visible=false;

    Phone2.visible=true

}

I cannot see why it wont work, I click on all the items to show them, but the if statement will not make the "Next01" appear.

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 ,
Jun 08, 2015 Jun 08, 2015

your if-statement executes before any of your buttons are clicked.  fix that:

Next01.visible=false

Knife2.visible=false

Gun2.visible=false

Note2.visible=false

Phone2.visible=false

function checkF():void{

if((Knife2.visible==true)&&(Gun2.visible==true)&&(Note2.visible==true)&&(Phone2.visible==t rue) ){

  Next01.visible=true

}

}

Knife.addEventListener(MouseEvent.CLICK, KnifeHide);

function KnifeHide(event:MouseEvent):void

{

  Knife.visible=false;

    Knife2.visible=true

checkF()

}

Gun.addEventListener(MouseEvent.CLICK, GunHide);

function GunHide(event:MouseEvent):void

{

  Gun.visible=false;

    Gun2.visible=true

checkF()

}

Note.addEventListener(MouseEvent.CLICK, NoteHide);

function NoteHide(event:MouseEvent):void

{

  Note.visible=false;

    Note2.visible=true

checkF()

}

Phone.addEventListener(MouseEvent.CLICK, PhoneHide);

function PhoneHide(event:MouseEvent):void

{

  Phone.visible=false;

    Phone2.visible=true

checkF()

}

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

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
New Here ,
Jun 09, 2015 Jun 09, 2015

Thank you so much for your help!!

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 ,
Jun 09, 2015 Jun 09, 2015
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