2 Replies Latest reply on Mar 6, 2012 9:20 AM by sinious

    Basic problem with buttons & scripting

    euler271

      I just got the trial of Flash Cs5 and haven't used Flash since MX back in 04-06. Having an issue with buttons now in context of a scrolling text area. My code is set up as such:

       

      stop();

       

       

      import flash.events.MouseEvent;

       

       

      up.addEventListener(MouseEvent.CLICK,upscroll);

       

       

      function upscroll(event:MouseEvent):void{

                maintext.prevFrame();

      }

       

       

      down.addEventListener(MouseEvent.CLICK,dwscroll);

       

       

      function dwscroll(event:MouseEvent):void{

                maintext.nextFrame();

      }

       

       

      Where up is the button to scroll upwards and down is...(you guessed it). Maintext is the movieclip in which my text is which each frame being the text "scrolled" further.

       

      My issue IS: This was working just fine UNTIL I added "Over", "Down", and "Hit" frames into my buttons (whereas previously they were just single frame arrows), and then when previewing my flash the cursor doesn't even recognize the buttons as such, and nothing happens if you click on either...

       

      ...If I got back and delete the over, down, and hit frames, BOOM, problem goes away. This seems very strange to me, I never had a problem like this in MX...

       

      Advice please? Thank you

        • 1. Re: Basic problem with buttons & scripting
          Ned Murphy Adobe Community Professional & MVP

          Show the code that you remove that makes the problem go away.

          • 2. Re: Basic problem with buttons & scripting
            sinious Most Valuable Participant

            So you're using the 'Button' symbol and when you remove the on/over/hit frames (empty them) it works?

             

            Sounds like your 'hit' frame isn't correct. 'hit' isn't displayed so you should generally draw a new rectangle in that frame that covers the whole graphic. Delete the outline over the rectangle as well as I found that in previous versions of flash to interfere.

             

            Otherwise I see no issue with what you're doing outside you're not checking if there is a next or previous frame to go to.

             

            The as3 way to enable a mouse cursor and make something clickable (although a button symbol should have this by default) would be:

             

            up.buttonMode = true;

            up.useHandCursor = true;

            down.buttonMode = true;

            down.useHandCursor = true;

             

            In the future try to stay away from such common names for instances like 'up' and 'down'. You're liable to use a reserved word and spend an hour trying to figure out why it errors. Adding a suffix that describes the object can help such as up_btn down_btn, etc.

             

            Also make sure your instance name is set properly in the properties panel to what your code states.

            1 person found this helpful