5 Replies Latest reply on May 16, 2009 11:02 AM by clbeech

    as2.0 help,Is there a equivalent to Lingo PASS in actionscript2.0?

    cuixin2009

      I'm new to flash,and I'm using actionscript2.0,I use Lingo before.

       

      In lingo. the Pass Command passes an event message to the next location

      in the message hierarchy and enables execution of more than one handler for a given event.

       

      My question is:

      I have a movieClip, and there is some button in the movie clip,I put the movie clip into the timeline,

      it works well,but when I attach a rollOver event handler to the movie clip, the buttons don't work.

       

      I think the movieclip's rollover event handler blocked the mouse message.

      so is there a actionscript2.0 command just like the Pass lingo command,

      to let the mouse message goto inside the movie clip?

       

       

      my movie clip all_mc is like this:

       

      in all_mc, I attached:

      on(rollOut){
        trace("roll out");
      }

      and in all_mc there is a button,red_btn

      in red_btn, I attached

      on(press){
      trace("red pressed");
      }

       

      when I tested the movie the on(press) does'nt work

       

      when I delete the on(rollOut) ,the on(press) works

       

       

      why? how can I get them work together?

        • 1. Re: as2.0 help,Is there a equivalent to Lingo PASS in actionscript2.0?
          clbeech Level 3

          this is an old problem in AS2 - handlers assigned to 'children' of a parent that also has a handler, will not receive event notifications.  there are a few tricks to get around this, depending on the situation.  the most common is to use a hitTest for the child objects rather than assigning handlers - so in your parent all_mc use an onPress handler, within the handler run a hitTest to check for a click on the button instance, if true, then perform the button's response action.  so something like this:

           

          //in all_mc

          on(rollOut) {

               trace('roll out');

          }

           

          on(press) {

               if(red_btn.hitTest(_xmouse, _ymouse, false)) trace('red button');

          }

           

           

          however, i would recomend *not* using 'object attachment' of your handlers (ie. on(...){...} ) it is considered to be not a 'best practice' for many reasons - instead you should work to place all of your code on the timeline or within class files.

          1 person found this helpful
          • 2. Re: as2.0 help,Is there a equivalent to Lingo PASS in actionscript2.0?
            cuixin2009 Level 1

            thanks clbeech,

            you  recomend *not* using 'object attachment',

            and you said that it is considered to be not a 'best practice' for many reasons.

             

            why?what's the reason?

             

            thank you again

            • 3. Re: as2.0 help,Is there a equivalent to Lingo PASS in actionscript2.0?
              kglad Adobe Community Professional & MVP

              it makes it hard to debug your code because it's located in multiple places.  especially if someone else has to edit your work or you have to edit your own work a year or two after you complete it.

              • 4. Re: as2.0 help,Is there a equivalent to Lingo PASS in actionscript2.0?
                cuixin2009 Level 1

                //in all_mc

                on(rollOut) {

                     trace('roll out');

                }

                 

                on(press) {

                     if(red_btn.hitTest(_xmouse, _ymouse, false)) trace('red button');

                }

                 

                 

                the button does'nt have a bitTest mehod,so I use red_mc.  it works.

                But I've lost the buttons down,over,hit states

                 

                so I still need help

                • 5. Re: as2.0 help,Is there a equivalent to Lingo PASS in actionscript2.0?
                  clbeech Level 3

                  ah yes - wasn't thinking that it was an actual button instance.  ok well under AS2 there is some good news for you - what you need to do is create two new layers in the red_btn (mc) timeline, one being 'actions' the other being 'labels' - now you shouldn't need the 'hit' state and when it's an mc you need to do that differently, so ace it's frame.  create a keyframe above the 'up' state frame on both layers - in the 'actions' layer, select the frame, open the actions panel and place a stop(); there - do the same for each 'state' frame (make sure to make more keyframes)  now select the 'up' state frame in the labels layer - in the properties panel in the <frame name> box type '_up' (with the underscore) - do the same (making more keyframes) for each 'state' of the button (ie. _up, _over, _down)   Under AS2, Flash will 'recognize' that the mc is being 'used' as a button instance, and it will now act just like a Button symbol without having to add the onRollOver, onRollOut, onPress handlers to your code and navigating to those frames - it will do it automatically

                   

                   

                  attaching handlers:

                  in addition to kgs comment, another reason has to do with scope.  it can become complicated to keep track of your variables and target them, when they are local to the instance in this manner, from 'other' areas of your code.  whereas if all of your variables and instance properties are within the same scope, paths to get values from instances are much easier to manage.

                  1 person found this helpful