3 Replies Latest reply on Oct 24, 2007 2:23 PM by jbsdesign

    condition problem

    jbsdesign
      This is in Actionscript 2.0...

      I need a button called "con1" to appear if a series of three different MC's are pressed.

      in the initial frame i have:
      con1._visible = false;

      When each MC is pressed they become disabled like this:

      on(release){
      this.enabled = false;
      }

      The MC's are called "a1","b1", and "c1".
      I want to set up a condition in the initial frame that says:
      if (a1.enabled = false)
      (b1.enabled = false)
      (c1.enabled = false){
      con1._visible = true;
      }

      I think I am approaching this totally wrong, well it isn't working anyhow.
      Does anyone have any ideas???
        • 1. Re: condition problem
          Level 7
          jbsdesign,

          > This is in Actionscript 2.0...

          Okay.

          > I need a button called "con1" to appear if a series of three
          > different MC's are pressed.

          Sure thing.

          > in the initial frame i have:
          > con1._visible = false;

          Good so far.

          > When each MC is pressed they become disabled like this:
          >
          > on(release){
          > this.enabled = false;
          > }

          ActionScript 2.0 does still support the on() and onClipEvent() functions
          (AS3 does not), but I encourage you to consider dot syntax approach outlined
          here.

          http://www.quip.net/blog/2006/flash/museum-pieces-on-and-onclipevent

          In this case, especially, it means you'll be able to reduce unnecessary
          duplication in your code. Give each of your movie clips an instance name --
          looks like you've chosen a1, b1, and c1 -- and add the following new code
          after con1._visible = false; (you can delete the existing if() statement,
          replacing it with the following).

          a1.onRelease = releaseHandler;
          b1.onRelease = releaseHandler;
          c1.onRelease = releaseHandler;

          function releaseHandler():Void {
          this.enabled = false;
          if (
          a1.enabled == false &&
          b1.enabled == false &&
          c1.enabled == false
          ) {
          con1._visible = true;
          }
          };

          The first three lines assign a custom function -- releaseHandler() -- to
          the MovieClip.onRelease event of your three movie clips. Next, the
          releaseHandler() function is defined. It sets the currently clicked movie
          clip's MovieClip.enabled property to false, then it checks if all three are
          false. If so, it sets the button's Button.on_visible property to true.

          Notice the double equals sign (==) in the if() condition. The double
          equals is the comparison operator. If you're using a single equals sign
          (=), you're actually assigning the value, rather than comparing. The
          logical AND operator (&&) allows you to string together multiple conditions.
          The combined condition is only true if all of its sub conditions evaluate as
          true.

          The combined condition could all be written on one line, but I broke it
          over several for sake of clarity.


          David Stiller
          Co-author, Foundation Flash CS3 for Designers
          http://tinyurl.com/2k29mj
          "Luck is the residue of good design."


          • 2. Re: condition problem
            MATTANDIE
            Ok, you can do it that way, but you need to add another function and fix your existing code. First you need to create a function that checks to see if a1,b1,c1 are enabled. This function is what will actually turn on your button.

            Something like

            function checker(){
            if(a1.enabled == false && b1.enabled == false && c1.enabled == false){
            con1._visible = true;
            }
            };

            Notice the " ==" you need to check for equivilance. right now you are setting the enabled state to false.

            Then all you need to do is add checker(); to your button code.

            It should work then.


            M. Anderson.

            • 3. Re: condition problem
              jbsdesign Level 1
              Thanks David,
              Your code worked.
              Now I just have to apply the logic to a bigger scenario where there are all kinds of combinations of mc that can be pressed which would make various buttons appear depending on the combo...
              Thanks again!