5 Replies Latest reply: Aug 9, 2012 7:07 AM by rogerxzxz RSS

    Help with simple script

    rogerxzxz

      I was wondering if someone could help me with a simple bit of action script 3. I need to make a movie clip (single_mc) disappear when the user clicks on the mouse (stop_btn). Here’s what I have so far.

       

      function setProperty(event:MouseEvent):void

       


         {          

      single_mc.alpha=0;

      }

      stop_btn.addEventListener(MouseEvent.CLICK, setProperty);

       

      Also I was wonder if you could recommend an Action script 3 book for me. I would like one that is not a training book, but has situations and then the script written out. For example: I click a button and a movie symbol disappears from the stage. I am a graphic artist, that from time to time, needs simple interaction in flash, but cant justify the time to learn the script.

      Thanks for your time

        • 1. Re: Help with simple script
          Ned Murphy CommunityMVP

          Your code looks fine.  IF it is not working for you, are you getting error messages?  HAve you assigned those instance names to those objects on the stage?

          • 2. Re: Help with simple script
            kglad CommunityMVP

            use the snippets panel to help with you with sample code for basic tasks.

             

             

             

            function setProperty(event:MouseEvent):void

             


               {          

            single_mc.visible=false;

            }

            stop_btn.addEventListener(MouseEvent.CLICK, setProperty);

             

            • 3. Re: Help with simple script
              sachin_mak Community Member

              refer the below sample code.

               

              show_btn.addEventListener(MouseEvent.CLICK, showme);

              hide_btn.addEventListener(MouseEvent.CLICK, hideme);

               

              function showme(Event:MouseEvent):void

              {

                   your_mc.visible = true;

              }

               

              function hideme(Event:MouseEvent):void

              {

                   your_mc.visible = false;

              }

               

              or you can hide and show your movieclip using one button also. for this refer the below code.

               

              your_btn.addEventListener(MouseEvent.CLICK, hideshow);

               

              function hideshow(Event:MouseEvent):void

              {

                   if(your_mc.visible == true)

                   {

                        your_mc.visible = false;

                   }

                   else

                   {

                        your_mc.visible = true;

                   }

              }

               

              hope...this will help you

              • 4. Re: Help with simple script
                rogerxzxz Community Member

                Thank you very much the second script did just what I wanted.

                Also I was wonder if you could recommend an Action script 3 book for me. I would like one that is not a training book, but has situations and then the script written out. For example: How to  click a button and a movie symbol disappears from the stage. I am a graphic artist, that from time to time, needs simple interaction in flash, but cant justify the time to learn the script.

                Thanks for your time

                • 5. Re: Help with simple script
                  rogerxzxz Community Member

                  Though you might like to see the finished product