5 Replies Latest reply on Mar 12, 2011 8:21 PM by Skoolbus777

    Seemingly easy AS2 code that I can't figure out...

    Skoolbus777 Level 1

      Long story short, I simply want a mc (acting as a button) that when I click it tells a instanced mc to advance a frame, and if I click the button again the instanced mc goes back a frame. Another way to look at it is, click once advance a frame, click again go back a frame. Clicking repeatedly alternates.

       

      Using AS2 I'm a little confused, and I definitely tried to Google this and I ask my friend who's more of a AS3 coder. Originally I put the var function within the event after the on(release) which gave me no errors. My friend says that if the var statement is within the result will always be true.

       

      I will admit that I'm definitely not familiar with conditional statements and this will be my first attempt at doing so. My confusion was how does the button know what true and false is. I was told putting forward=!forward would inherent the switching mechanism based on the active boolean statement.

       

       

       

      var forward:Boolean = true;

       

      on(release)

      {

         if (forward = true) {

      _parent.keyboards.nextFrame();

      } else {

      _parent.keyboards.prevFrame();

      }

      forward=!forward

      }