3 Replies Latest reply on Sep 9, 2009 1:31 PM by Rothrock

    onPress action being triggered automatically

    image_dr

      I have a scrolling navigation bar and two buttons on either side to move it left and right. I created functions to handle moving the navigation MC left and right, and they work just fine.

       

      My problem is, I'm trying to set my buttons up using onPress, like this:

       

      function ScrollForward()

      {

        //  function contents

      }

       

      function ScrollBack()

      {

        // function contents

      }

       

      btn_advance.onPress = ScrollForward();

      btn_retreat.onPress = ScrollBack();

       

       

      The problem is, when I create the .swf, the functions placed in the onPress events automatically run. And neither button triggers the "onPress" events. I have removed the last two lines with the onPress events and the functions do not run, so the way I've set them up is obviously wrong.

       

      The problem is obviously the onPress lines because the functions do not run without those lines, and if I simply put the full function within the onPress event rather than separate, they both run correctly. I want to call these functions elsewhere, so I don't want to simply include them solely within the onPress event.

       

      What is wrong with what I've done?