2 Replies Latest reply on Nov 28, 2007 8:33 AM by Damon Edwards

    How Apply Action On Button ?

    <<_CFMX_>>
      How Apply Action On Button ?

      I m now using CS 3. but when i try to apply Action on button the Action Screen Give this message "" Current Selection can not have actions applied to it.
      How i apply Action 1.0 at CS3.

      I want to apply following Action on Button in CS 3.

      on (rollOver) {
      tellTarget ("1") {
      gotoAndPlay(2);
      }
      }
      on (rollOut) {
      tellTarget ("1") {
      gotoAndPlay(10);
      }
      }


      Regards
        • 1. Re: How Apply Action On Button ?
          robdillon Most Valuable Participant
          The default actionscript version for CS3 is actionscript 3. You can no longer apply actions directly to objects in AS3. If you want to use the code as is, go to the publish settings for this movie and change the AS version to AS 1 & 2.
          • 2. Re: How Apply Action On Button ?
            Damon Edwards Level 3
            Or you can learn the new way, since you are using an ancient way of scripting. Give your buttons an instance name. Do this by clicking the symbol on stage, looking down in the properties inspector and seeing, <instance name>. Click there and type in a unique name, that will be your reference to that symbol for applying actions. For this example, I will use, my_btn, as the instance name. Create a new layer and label it "Actions", lock the layer. Click on the frame of that layer and open the actions panel. Note that is should say, "Actions-Frame", in the top left corner of the actions panel. Paste this in there.


            my_btn.addEventListener(MouseEvent.ROLL_OVER, btnOver);
            function btnOver(event:MouseEvent):void{
            my_mc.gotoAndPlay(2);
            }

            my_btn.addEventListener(MouseEvent.ROLL_OUT, btnOut);
            function btnOut(event:MouseEvent):void{
            my_mc.gotoandPlay(10);
            }

            So, he is an explanation..

            my_btn.addEventListener(MouseEvent.ROLL_OVER, btnOver);

            just means we are adding a listener for the symbol with the instance name of my_btn, the listener is listening for all RollOver events triggered by the mouse on the button symbol. Every time it is rolled over, it will call the function, btnOver.

            function btnOver(event:MouseEvent):void{

            Is declaring the function btnOver, for which the listener will be triggering. it is an event, and happens to be a mouse event.

            my_mc.gotoandPlay(10);

            Here we are telling the symbol with instance name, my_mc, to goto and play frame 10. Since tellTarget is ancient, and I don't believe is available in AS3 anyway, we target symbols that are on stage using an instance name.