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

how to check if a button is clicked in an if statement

New Here ,
Sep 10, 2015 Sep 10, 2015

Alright so, I'm making a game. I forgot how to do some coding over the year and I'm starting up back again. So here's the deal; I can't remember how to check if a button has been clicked in an if statement. For example, if button1 is down, than invoke this function.

Anyone got any ideas? Here's what I have:

package{

  import flash.display.MovieClip;

  import flash.text.TextField;

  public class FirstClass extends MovieClip {//

  public var b1:TextField = new TextField

  public var pic1:picture1 = new picture 1

  public var background:BG = new BG

 

  private function summonGabe(){//assigns properties to b1 and adds it

  b1.addEventListener(MouseEvent. CLICK, clickHandler);

  function ClickHandler(event:MouseEvent){

  b1.boarder = true

  b1.text = Summon Lord Gaben 

  b1.x = 300

  b1.y = 350

  b1.height = 100

  }

  }

 

  private function stateOne(){//the function in which i want to check if the button is pressed, if so than invoke summonGabe

  if( ){

      summonGabe();

      trace("You have awoken the one and only, Lord Gaben!")

    }

  }

  private function FirstClass(){//constructor

  addChild(background);

  trace(“Welcome to the Land of Lord Gaben”);

  summonGabe();

  }

  }//end of class

}//end of package


Help please  ^^

TOPICS
ActionScript
278
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 ,
Sep 10, 2015 Sep 10, 2015
LATEST

package{

  import flash.display.MovieClip;

  import flash.text.TextField;

  public class FirstClass extends MovieClip {//

  public var b1:TextField = new TextField

  public var pic1:picture1 = new picture 1

  public var background:BG = new BG

 

  private function summonGabe(){//assigns properties to b1 and adds it

  b1.addEventListener(MouseEvent. CLICK, clickHandler);

  }


// never nest named functions

private function clickHandler(event:MouseEvent){  // case counts since fp 6, as2.

  b1.boarder = true; 

  b1.text = Summon Lord Gaben 

  b1.x = 300

  b1.y = 350

  b1.height = 100

  }

 

  private function stateOne(){//the function in which i want to check if the button is pressed, if so than invoke summonGabe

if(b1.boader ){

      summonGabe(); 

      trace("You have awoken the one and only, Lord Gaben!")

    }

  }

  private function FirstClass(){//constructor

  addChild(background);

  trace(“Welcome to the Land of Lord Gaben”);

  summonGabe();

  }

  }//end of class

}//end of package



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