Skip to main content
Participant
June 8, 2015
Answered

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

  • June 8, 2015
  • 6 replies
  • 588 views

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.

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer kglad

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.)

6 replies

kglad
Community Expert
Community Expert
June 8, 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

}

xXsim00XxAuthor
Participant
June 9, 2015

Thanks man