A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Simple if or boolean statement? I think?

  1. #1
    Junior Member
    Join Date
    Dec 2018
    Posts
    4

    Question Simple if or boolean statement? I think?

    Hi! I'm totally new to Animate but excited about getting to know it better. My friend who's been on here a long long time recommended I check it out, so I hope I'm in the right place. Hi.

    I'm building a 5 room escape game, kind of like an escape room, except there's 5. It's set on a space station.

    I want to have two instances of conditional statements, which I *think* would work with an if or a boolean but I'm a code novice. For example, I have a helmet button, and an airlock button. What I'd like to have happen is the airlock button (butt_airlock) isn't active until the user clicks the helmet button (butt_helmet). (The other one is the fridge (butt_fridge) isn't open until the user reveals the food's code (butt_food))

    My current code is really basic:

    //CODE THAT MAKES FRAMES STOP
    this.stop();

    // R O O M 1
    // Code that makes this button live
    this.butt_hatch.addEventListener("click", butt_hatchAction.bind(this));

    // Code that makes this button work
    function butt_hatchAction() {
    this.gotoAndStop(1)
    }



    // R O O M 2
    // Code that makes this button live
    this.butt_fridge.addEventListener("click", butt_fridgeAction.bind(this));

    // Code that makes this button work
    function butt_fridgeAction() {
    this.gotoAndStop(2)
    }



    // R O O M 3
    // Code that makes this button live
    this.butt_ladder.addEventListener("click", butt_ladderAction.bind(this));

    // Code that makes this button work
    function butt_ladderAction() {
    this.gotoAndStop(3)
    }



    // R O O M 4
    // Code that makes this button live
    this.butt_airlock.addEventListener("click", butt_airlockAction.bind(this));

    // Code that makes this button work
    function butt_airlockAction() {
    this.gotoAndStop(4)
    }



    // R O O M 5


    I hope this makes sense! If you have any questions please don't hesitate to ask. Thank you so much!!

  2. #2
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    send me fla

  3. #3
    Junior Member
    Join Date
    Dec 2018
    Posts
    4
    Thank you! I'll message you right now

  4. #4
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    ok this is the helmet condition, if you click helmet than you can leave.

    Instead of adding an eventlistener for each movieclip you should use the click function with e.target.name to check for movieclips clicked on. Actionscript 3.0 is faster than this javascript language
    PHP Code:
        //CODE THAT MAKES FRAMES STOP
        
    this.stop();
        
    // R O O M   1    
    // Code that makes this button live
    this.butt_hatch.addEventListener("click"butt_hatchAction.bind(this));

    // Code that makes this button work
    function butt_hatchAction() {
    this.gotoAndStop(1)
    }



    // R O O M   2    
    // Code that makes this button live
    this.butt_fridge.addEventListener("click"butt_fridgeAction.bind(this));

    // Code that makes this button work
    function butt_fridgeAction() {
    this.gotoAndStop(2)
    }



    // R O O M   3
    // Code that makes this button live
    this.butt_ladder.addEventListener("click"butt_ladderAction.bind(this));

    // Code that makes this button work
    function butt_ladderAction() {
    this.gotoAndStop(3)
    }



    // R O O M   4
    // Code that makes this button live



    // R O O M   5
    var mainStage=this
    var helmet_clicked=false


    this
    .stage.on("click", function(e) {
    if(
    e.target.name=="helmet"){
    helmet_clicked=true
    }

    if(
    e.target.name=="butt_airlock"&&helmet_clicked==true){
    mainStage.gotoAndStop(4)
    }

    }); 
    Last edited by AS3.0; 12-06-2018 at 07:50 PM.

  5. #5
    Junior Member
    Join Date
    Dec 2018
    Posts
    4
    Wow, thank you so much!! I'll try that out.

  6. #6
    Junior Member
    Join Date
    Dec 2018
    Posts
    4
    It works!! And I managed to recreate the effect for the fridge, which is awesome. Thank you so, so much!

  7. #7
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    no problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center