Flash var/Functions

Out of context: Reply #18

  • Started
  • Last post
  • 18 Responses
  • trintaetres0

    Try this:
    Create 2 buttons on stage, then instancename them "btn_01" and "btn_02" ,then paste the code at the first frame:

    var btnPressed:String;

    btn_01.onRelease = function(){
    btnPressed = "btn_01";
    executer();
    }

    btn_02.onRelease = function(){
    btnPressed = "btn_02";
    executer();
    }

    executer();
    function executer(){
    switch (btnPressed) {
    case "btn_01":
    function01();
    break;
    case "btn_02":
    function02();
    break;
    default: function01();
    }
    }

    function function01(){
    trace("function01 executed")
    };

    function function02(){
    trace("function02 executed")
    };

    tell me if it helps you!

View thread