33 Replies Latest reply on Nov 13, 2012 11:31 AM by kglad

    Question concerning clicking object behind a mask effect

    Fayze93

      First of all, sorry for the indescriptive title, couldn't really think of something.

      Okay, so I want an effect done for my Flash project. Basically I have a black background and a simple mask effect that follows the mouse, so you move the mouse and it shows you the layer behind the black background.. The script looks like this:

       

      color_mc.mask = mask_mc;

      mask_mc.cacheAsBitmap = true;

      color_mc.cacheAsBitmap = true;

       

      mask_mc.addEventListener(Event.ENTER_FRAME, moveMask);

       

      function moveMask(e:Event):void

      {

                mask_mc.x = mouseX;

                mask_mc.y = mouseY;

      }

       

      And this works fine, but it's not all I intend to do. In short, the user has to move the mask using the mouse and find several colored objects hidden behind it (this works fine), then I want to make all the object clickable and I want the object to change shapes when they're clicked on. I'm pretty new at Flash, but I've fiddled around with it and couldn't come up with a solution that worked.

      I have tried labelling different frames on the timeline; "color1", "color2", and then doing a

       

      color_mc.color1.buttonMode=true

      color_mc.color1.addEventListener(MouseEvent.CLICK, COLOR1);

       

      function COLOR1 (e:MouseEvent) {

      gotoAndPlay("color1");

      }

       

      This then goes to that frame, but it's probably not the right way to do it, because the mask effect doesn't work anymore (I even tried copying the action script to the "color1" frame), plus I think if you'd clicked the "color1" object first and then the "color2" object after

      I think it'd reverse the "color1" action (but I'm not sure)

       

      *note* color_mc is the background with the objects on it that I want clickable and the objects are called "color1", "color2" etc.

       

      Oh and one more thing, I also want it to recognize when all the objects are clicked and then move to a new frame/scene.

       

      Sorry, if I couldn't explain it properly; as I said I'm not that experienced in Flash and I'd really appreciate it if someone could help me. If there's anything you wanna know or if you wanna see my flash file, just let me know.

        • 1. Re: Question concerning clicking object behind a mask effect
          Ned Murphy Adobe Community Professional & MVP

          If you move away from the frame that contains the mask then it will stop working.  To overcome this you need to extend the layer for the mask (and the color_mc) to wherever else you want the mask to still work.

          • 2. Re: Question concerning clicking object behind a mask effect
            kglad Adobe Community Professional & MVP

            make sure mask_mc and color_mc are on layers that exist across all frames where you want it to continue masking color_mc.  eg, in "color1" etc

            • 3. Re: Question concerning clicking object behind a mask effect
              Fayze93 Level 1

              I see, but the problem still stands. I want to make all the objects clickable (the object should grow large when clicked on) and I want it to remember the objects that have been clicked on, so eventually every object will be large (at the same time). Then I want it to progress to a new scene. The problem now is that if I click an object, say "color1" and it then goes to "color1" on the timeline it'll do the animation, but if I then click "color2", it'll go to "color2" on the timeline it'll forget "color1" ever happened. Anyway if my explanation is bad, I'll provide the Flash file I work with. I would really appreciate it if you could help here, I've been messing around with this for some time now.

              http://http://www.2shared.com/file/-XOtDj-w/maskonmouse2.html

              • 4. Re: Question concerning clicking object behind a mask effect
                kglad Adobe Community Professional & MVP

                you should not be using the timeline to display that animation otherwise, you'll need 2**n animations if you have n objects.  ie, if you have 10 objects, you'll need over 1,000 distinct timeline animations.

                 

                you should be using actionscript to tween your objects:

                 

                var t1:Tween;

                var t2:Tween;

                var colorNum:int = 10;

                for(var i:int=1;i<=colorNum;i++){

                color_mc["color"+i].buttonMode=true;

                color_mc["color"+i].addEventListener(MouseEvent.CLICK,tweenF);

                }

                 

                function tweenF(e:MouseEvent):void{

                t1=new Tween(e.currentTarget,"scaleX",Regular.easeNone,1,1.5,true);

                t2=new Tween(e.currentTarget,"scaleY",Regular.easeNone,1,1.5,true);

                }

                1 person found this helpful
                • 5. Re: Question concerning clicking object behind a mask effect
                  Fayze93 Level 1

                  Ah thanks, I knew there was a proper way to do it, however I'm getting a few errors;

                  1046: Type was not found or was not a compile-time constant: Tween

                  1180: Call to a possibly undefined method Tween

                  1120: Access of undefined property Regular

                   

                  Should I replace anything in the action script?

                  Oh and just to be clear, I'll need to Tween the animations I want the objects to be doing, name the Tweens and then refer to them in the action script?

                  • 6. Re: Question concerning clicking object behind a mask effect
                    kglad Adobe Community Professional & MVP

                    you don't need to change anything.  just add the needed classes:

                     

                     

                    import fl.transitions.Tween;

                    import fl.transitions.easing.Regular;

                     

                    var t1:Tween;

                    var t2:Tween;

                    var colorNum:int = 10;

                    for(var i:int=1;i<=colorNum;i++){

                    color_mc["color"+i].buttonMode=true;

                    color_mc["color"+i].addEventListener(MouseEvent.CLICK,tweenF);

                    }

                     

                    function tweenF(e:MouseEvent):void{

                    t1=new Tween(e.currentTarget,"scaleX",Regular.easeNone,1,1.5,true);

                    t2=new Tween(e.currentTarget,"scaleY",Regular.easeNone,1,1.5,true);

                    }

                    p.s.  please mark helpful/correct responses.

                    1 person found this helpful
                    • 7. Re: Question concerning clicking object behind a mask effect
                      Fayze93 Level 1

                      It's coming up with some errors.

                      1119: Access of possibly undefined property easeNone through a reference with static type Class

                      1067: Implicit coercion of a value of type Boolean to an unrelated type Number

                      on the lines

                      t1=new Tween(e.currentTarget,"scaleX",Regular.easeNone,1,1.5,true);

                      t2=new Tween(e.currentTarget,"scaleY",Regular.easeNone,1,1.5,true);

                       

                       

                      Also, I'm not entirely sure I understand the script. Is t1 and t2 the names of the Tweens, or how do I tell it which Tweens to interact with? And do I change scaleX and scaleY?

                      I would really appreciate it if you could explain the script.

                      • 8. Re: Question concerning clicking object behind a mask effect
                        kglad Adobe Community Professional & MVP

                        my error.  use:

                         

                         

                        import fl.transitions.Tween;

                        import fl.transitions.easing.None;

                         

                        var t1:Tween;

                        var t2:Tween;

                        var colorNum:int = 10;

                        for(var i:int=1;i<=colorNum;i++){

                        color_mc["color"+i].buttonMode=true;

                        color_mc["color"+i].addEventListener(MouseEvent.CLICK,tweenF);

                        }

                         

                        function tweenF(e:MouseEvent):void{

                        t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                        t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                        }

                         

                        1 person found this helpful
                        • 9. Re: Question concerning clicking object behind a mask effect
                          Fayze93 Level 1

                          It's gives output error on the lines:

                          color_mc["color"+i].buttonMode=true;

                          color_mc["color"+i].addEventListener(MouseEvent.CLICK,tweenF);

                           

                          TypeError: Error #1010: A term is undefined and has no properties.

                           

                          Do I have to type something else instead of "color"? What exactly should be there?

                          • 10. Re: Question concerning clicking object behind a mask effect
                            kglad Adobe Community Professional & MVP

                            you need 10 child movieclips named color1,color2,...,color10 of the parent movieclip color_mc.  if you do not have 10 movieclips, define colorNum to match the number you do have.

                            1 person found this helpful
                            • 11. Re: Question concerning clicking object behind a mask effect
                              Fayze93 Level 1

                              So with 5 colors it should something like this? It still gives the same error though, what am I doing wrong?

                               

                              import fl.transitions.Tween;

                              import fl.transitions.easing.None;

                               

                              var t1:Tween;

                              var t2:Tween;

                               

                              var colorNum:int = 5;

                              for(var i:int=1;i<=colorNum;i++){

                              color_mc["color1"+i].buttonMode=true;

                              color_mc["color1"+i].addEventListener(MouseEvent.CLICK,tweenA);

                              color_mc["color2"+i].buttonMode=true;

                              color_mc["color2"+i].addEventListener(MouseEvent.CLICK,tweenB);

                              color_mc["color3"+i].buttonMode=true;

                              color_mc["color3"+i].addEventListener(MouseEvent.CLICK,tweenC);

                              color_mc["color4"+i].buttonMode=true;

                              color_mc["color4"+i].addEventListener(MouseEvent.CLICK,tweenD);

                              color_mc["color5"+i].buttonMode=true;

                              color_mc["color5"+i].addEventListener(MouseEvent.CLICK,tweenE);

                               

                              }

                               

                              function tweenA(e:MouseEvent):void{

                              t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                              t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                              }

                               

                              function tweenB(e:MouseEvent):void{

                              t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                              t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                              }

                               

                              function tweenC(e:MouseEvent):void{

                              t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                              t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                              }

                               

                               

                              function tweenD(e:MouseEvent):void{

                              t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                              t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                              }

                               

                               

                              function tweenE(e:MouseEvent):void{

                              t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                              t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                              }

                               

                              stop();

                              • 12. Re: Question concerning clicking object behind a mask effect
                                kglad Adobe Community Professional & MVP

                                you're lacking one (or more) of color_mc.color1,...,color_mc.color5.

                                 

                                to find the first use the trace function:

                                 

                                 

                                import fl.transitions.Tween;

                                import fl.transitions.easing.None;

                                 

                                var t1:Tween;

                                var t2:Tween;

                                 

                                var colorNum:int = 5;

                                for(var i:int=1;i<=colorNum;i++){

                                trace(i);  // the last value of i you see in the output panel is the first movieclip that isn't defined.

                                color_mc["color1"+i].buttonMode=true;

                                color_mc["color1"+i].addEventListener(MouseEvent.CLICK,tweenA);

                                color_mc["color2"+i].buttonMode=true;

                                color_mc["color2"+i].addEventListener(MouseEvent.CLICK,tweenB);

                                color_mc["color3"+i].buttonMode=true;

                                color_mc["color3"+i].addEventListener(MouseEvent.CLICK,tweenC);

                                color_mc["color4"+i].buttonMode=true;

                                color_mc["color4"+i].addEventListener(MouseEvent.CLICK,tweenD);

                                color_mc["color5"+i].buttonMode=true;

                                color_mc["color5"+i].addEventListener(MouseEvent.CLICK,tweenE);

                                 

                                }

                                 

                                function tweenA(e:MouseEvent):void{

                                t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                                t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                                }

                                 

                                function tweenB(e:MouseEvent):void{

                                t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                                t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                                }

                                 

                                function tweenC(e:MouseEvent):void{

                                t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                                t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                                }

                                 

                                 

                                function tweenD(e:MouseEvent):void{

                                t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                                t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                                }

                                 

                                 

                                function tweenE(e:MouseEvent):void{

                                t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                                t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                                }

                                 

                                stop();

                                • 13. Re: Question concerning clicking object behind a mask effect
                                  Fayze93 Level 1

                                  It says 1 in the output. I don't get it though, the background with the colors on it, is called color_mc. When I double click on color_mc, I can then click on the colors that I have given the instance names color1, color2, color3, color4 and color5. It should be named correctly.

                                  I've screenshotted it

                                   

                                   

                                  colormc.png

                                  color1.png

                                  • 14. Re: Question concerning clicking object behind a mask effect
                                    kglad Adobe Community Professional & MVP

                                    it doesn't exist when the code executes.  to ensure that, use color1 in only one keyframe.  ie, it should not be part of a tween.

                                     

                                    to confirm it's the problem, use:

                                     

                                    trace(color_mc.color1)

                                     

                                    instead of trace(i)

                                    • 15. Re: Question concerning clicking object behind a mask effect
                                      Fayze93 Level 1

                                      When doing trace(color_mc.color1) it says [object MovieClip] (it says the same on color1...color5)

                                      I've also removed the Tween on color1, however it still gives the same Error #1010: A term is undefined and has no properties.

                                      • 16. Re: Question concerning clicking object behind a mask effect
                                        Fayze93 Level 1

                                        I've been trying different stuff, but I honestly don't know what to do now. Also I still don't understand the "i". Do I exchange that "i" with some value or name? And the same with ScaleX and ScaleY, do I change those?

                                        • 17. Re: Question concerning clicking object behind a mask effect
                                          kglad Adobe Community Professional & MVP

                                          click file/publish settings/swf and tick "permit debugging".  retest.

                                           

                                          copy and paste the complete error message.  also, indicate which line of code corresponds to the top-most line number mentioned in the error message.

                                          • 18. Re: Question concerning clicking object behind a mask effect
                                            Fayze93 Level 1

                                            [object MovieClip]

                                            TypeError: Error #1010: A term is undefined and has no properties.

                                                      at maskonmouse3temp_fla::MainTimeline/frame1()[maskonmouse3temp_fla.MainTimeline::frame1:23]

                                             

                                             

                                            line 23 is

                                            color_mc["color1"+i].buttonMode=true;

                                            • 19. Re: Question concerning clicking object behind a mask effect
                                              kglad Adobe Community Professional & MVP

                                              where'd that code come from??????????

                                               

                                              ok, i see you added the erroneous code to the code i suggested and i copied that error without realizing it.

                                               

                                              USE:

                                               

                                              import fl.transitions.Tween;

                                              import fl.transitions.easing.None;

                                               

                                              var t1:Tween;

                                              var t2:Tween;

                                              var colorNum:int = 5;

                                              for(var i:int=1;i<=colorNum;i++){

                                              color_mc["color"+i].buttonMode=true;  // SEE THE DIFFERENCE??  it's not "color1"+i, it's "color"+i in those brackets.  this codes all colorNum of your buttons.

                                              color_mc["color"+i].addEventListener(MouseEvent.CLICK,tweenF);

                                              }

                                               

                                              function tweenF(e:MouseEvent):void{

                                              t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                                              t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                                              }

                                              • 20. Re: Question concerning clicking object behind a mask effect
                                                Fayze93 Level 1

                                                Ah, I see. There are no errors now.

                                                 

                                                They all work, however I'm still not sure how to specify what in the script makes them move, when I click color1 it moves slightly to the right.

                                                There's also one more thing I need done, I need the mask to disappear on the colors that are clicked. So if I click color1, I can't click it again and it permanently becomes visible.

                                                Then when they all have been clicked, it should progress to a new frame. Can you tell me how to do that?

                                                • 21. Re: Question concerning clicking object behind a mask effect
                                                  kglad Adobe Community Professional & MVP

                                                  the tweens make them scale.  i'm not sure what you want to move.  if it's the same color1,.. movieclips, use more tweens in tweenF.

                                                   

                                                  for the rest:

                                                   

                                                  import fl.transitions.Tween;

                                                  import fl.transitions.easing.None;

                                                   

                                                  //color_mc.mask = mask_mc;

                                                  mask_mc.cacheAsBitmap = true;

                                                  color_mc.cacheAsBitmap = true;

                                                   

                                                  mask_mc.addEventListener(Event.ENTER_FRAME, moveMask);

                                                   

                                                  function moveMask(e:Event):void

                                                  {

                                                            mask_mc.x = mouseX;

                                                            mask_mc.y = mouseY;

                                                  }

                                                   

                                                  var t1:Tween;

                                                  var t2:Tween;

                                                  var colorNum:int = 5;

                                                  for(var i:int=1;i<=colorNum;i++){

                                                  color_mc["color"+i].buttonMode=true;  // SEE THE DIFFERENCE??  it's not "color1"+i, it's "color"+i in those brackets.  this codes all colorNum of your buttons.

                                                  color_mc["color"+i].addEventListener(MouseEvent.CLICK,tweenF);

                                                  color_mc["color"+i].mask = mask_mc;

                                                  }

                                                   

                                                  function tweenF(e:MouseEvent):void{

                                                  t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                                                  t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                                                  e.currentTarget.mouseEnabled=false;

                                                  }

                                                  • 22. Re: Question concerning clicking object behind a mask effect
                                                    Fayze93 Level 1

                                                    Okay so the "e.currentTarget.mouseEnabled=false;" works fine, however writing "color_mc["color"+i].mask = mask_mc;" and commenting //color_mc.mask = mask_mc; causes the mask to disappear completely. I only want the colors that are clicked on to be visible, the mask still has to be there. Only when all the object are clicked, do I want the mask to disappear and it should go to a new frame.

                                                    • 23. Re: Question concerning clicking object behind a mask effect
                                                      kglad Adobe Community Professional & MVP

                                                      try:

                                                       

                                                       

                                                      import fl.transitions.Tween;

                                                      import fl.transitions.easing.None;

                                                       

                                                      color_mc.mask = mask_mc;

                                                      mask_mc.cacheAsBitmap = true;

                                                      color_mc.cacheAsBitmap = true;

                                                       

                                                      mask_mc.addEventListener(Event.ENTER_FRAME, moveMask);

                                                       

                                                      function moveMask(e:Event):void

                                                      {

                                                                mask_mc.x = mouseX;

                                                                mask_mc.y = mouseY;

                                                      }

                                                       

                                                      var t1:Tween;

                                                      var t2:Tween;

                                                      var colorNum:int = 5;

                                                      for(var i:int=1;i<=colorNum;i++){

                                                      color_mc["color"+i].buttonMode=true;  // SEE THE DIFFERENCE??  it's not "color1"+i, it's "color"+i in those brackets.  this codes all colorNum of your buttons.

                                                      color_mc["color"+i].addEventListener(MouseEvent.CLICK,tweenF);

                                                      }

                                                       

                                                      function tweenF(e:MouseEvent):void{

                                                      t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                                                      t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                                                      e.currentTarget.mouseEnabled=false;

                                                      addChild(e.currentTarget);

                                                      }

                                                      • 24. Re: Question concerning clicking object behind a mask effect
                                                        Fayze93 Level 1

                                                        It gives the error message

                                                         

                                                        1118. Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject.

                                                         

                                                        on the line addChild(e.currentTarget);

                                                        • 25. Re: Question concerning clicking object behind a mask effect
                                                          kglad Adobe Community Professional & MVP

                                                          use:

                                                           

                                                           

                                                           

                                                           

                                                          import fl.transitions.Tween;

                                                          import fl.transitions.easing.None;

                                                           

                                                          color_mc.mask = mask_mc;

                                                          mask_mc.cacheAsBitmap = true;

                                                          color_mc.cacheAsBitmap = true;

                                                           

                                                          mask_mc.addEventListener(Event.ENTER_FRAME, moveMask);

                                                           

                                                          function moveMask(e:Event):void

                                                          {

                                                                    mask_mc.x = mouseX;

                                                                    mask_mc.y = mouseY;

                                                          }

                                                           

                                                          var t1:Tween;

                                                          var t2:Tween;

                                                          var colorNum:int = 5;

                                                          for(var i:int=1;i<=colorNum;i++){

                                                          color_mc["color"+i].buttonMode=true;  // SEE THE DIFFERENCE??  it's not "color1"+i, it's "color"+i in those brackets.  this codes all colorNum of your buttons.

                                                          color_mc["color"+i].addEventListener(MouseEvent.CLICK,tweenF);

                                                          }

                                                           

                                                          function tweenF(e:MouseEvent):void{

                                                          t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                                                          t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                                                          e.currentTarget.mouseEnabled=false;

                                                          addChild(MovieClip(e.currentTarget));

                                                          }

                                                          • 26. Re: Question concerning clicking object behind a mask effect
                                                            Fayze93 Level 1

                                                            Ah okay, but clicking the colors now makes them disappear. I want each of the colors that I click on to grow large, move a bit and then be permanently visible (and not hidden by the mask effect). So in the end all the colors will be visible and the screen will be filled with colors.

                                                            • 27. Re: Question concerning clicking object behind a mask effect
                                                              kglad Adobe Community Professional & MVP

                                                              make sure you're using

                                                               

                                                              color_mc.mask = mask_mc;

                                                               

                                                              again, and not masking any of color1,...

                                                              • 28. Re: Question concerning clicking object behind a mask effect
                                                                Fayze93 Level 1

                                                                Hm, my script looks exactly like the one you wrote above:

                                                                 

                                                                import fl.transitions.Tween;

                                                                import fl.transitions.easing.None;

                                                                 

                                                                color_mc.mask = mask_mc;

                                                                mask_mc.cacheAsBitmap = true;

                                                                color_mc.cacheAsBitmap = true;

                                                                 

                                                                mask_mc.addEventListener(Event.ENTER_FRAME, moveMask);

                                                                 

                                                                function moveMask(e:Event):void

                                                                {

                                                                          mask_mc.x = mouseX;

                                                                          mask_mc.y = mouseY;

                                                                }

                                                                 

                                                                var t1:Tween;

                                                                var t2:Tween;

                                                                var colorNum:int = 5;

                                                                for(var i:int=1;i<=colorNum;i++){

                                                                color_mc["color"+i].buttonMode=true;  // SEE THE DIFFERENCE??  it's not "color1"+i, it's "color"+i in those brackets.  this codes all colorNum of your buttons.

                                                                color_mc["color"+i].addEventListener(MouseEvent.CLICK,tweenF);

                                                                }

                                                                 

                                                                function tweenF(e:MouseEvent):void{

                                                                t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                                                                t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                                                                e.currentTarget.mouseEnabled=false;

                                                                addChild(MovieClip(e.currentTarget));

                                                                }

                                                                 

                                                                And what do you mean with "and not masking any of color1,..."?

                                                                • 29. Re: Question concerning clicking object behind a mask effect
                                                                  kglad Adobe Community Professional & MVP

                                                                  if color_mc's not at 0,0, use the following.  if it is at 0,0, you're doing something wrong.

                                                                   

                                                                  import fl.transitions.Tween;

                                                                  import fl.transitions.easing.None;

                                                                   

                                                                  color_mc.mask = mask_mc;

                                                                  mask_mc.cacheAsBitmap = true;

                                                                  color_mc.cacheAsBitmap = true;

                                                                   

                                                                  mask_mc.addEventListener(Event.ENTER_FRAME, moveMask);

                                                                   

                                                                  function moveMask(e:Event):void{

                                                                      mask_mc.x = mouseX;

                                                                      mask_mc.y = mouseY;

                                                                  }

                                                                   

                                                                  var t1:Tween;

                                                                  var t2:Tween;

                                                                  var colorNum:int = 5;

                                                                  for(var i:int=1;i<=colorNum;i++){

                                                                      color_mc["color"+i].buttonMode=true; 

                                                                      color_mc["color"+i].addEventListener(MouseEvent.CLICK,tweenF);

                                                                  }

                                                                   

                                                                  function tweenF(e:MouseEvent):void{

                                                                      t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                                                                      t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                                                                      e.currentTarget.mouseEnabled=false;

                                                                      addChild(MovieClip(e.currentTarget));

                                                                      e.currentTarget.x+=color_mc.x;

                                                                      e.currentTarget.y+=color_mc.y;

                                                                  }

                                                                  • 30. Re: Question concerning clicking object behind a mask effect
                                                                    Fayze93 Level 1

                                                                    Awesome, that worked.

                                                                    Thanks a lot.

                                                                    There's just one more thing I need. When all the object are clicked I want it to go to a new frame.

                                                                    • 31. Re: Question concerning clicking object behind a mask effect
                                                                      kglad Adobe Community Professional & MVP

                                                                      use:

                                                                       

                                                                       

                                                                      import fl.transitions.Tween;

                                                                      import fl.transitions.easing.None;

                                                                       

                                                                      color_mc.mask = mask_mc;

                                                                      mask_mc.cacheAsBitmap = true;

                                                                      color_mc.cacheAsBitmap = true;

                                                                       

                                                                      mask_mc.addEventListener(Event.ENTER_FRAME, moveMask);

                                                                       

                                                                      function moveMask(e:Event):void{

                                                                          mask_mc.x = mouseX;

                                                                          mask_mc.y = mouseY;

                                                                      }

                                                                       

                                                                      var t1:Tween;

                                                                      var t2:Tween;

                                                                      var colorNum:int = 5;

                                                                      var numClicked:int = 0;

                                                                      for(var i:int=1;i<=colorNum;i++){

                                                                          color_mc["color"+i].buttonMode=true; 

                                                                          color_mc["color"+i].addEventListener(MouseEvent.CLICK,tweenF);

                                                                      }

                                                                       

                                                                      function tweenF(e:MouseEvent):void{

                                                                          t1=new Tween(e.currentTarget,"scaleX",None.easeNone,1,1.5,.5,true);

                                                                          t2=new Tween(e.currentTarget,"scaleY",None.easeNone,1,1.5,.5,true);

                                                                          e.currentTarget.mouseEnabled=false;

                                                                          addChild(MovieClip(e.currentTarget));

                                                                          e.currentTarget.x+=color_mc.x;

                                                                          e.currentTarget.y+=color_mc.y;

                                                                      numClicked++;

                                                                      if(numClicked==colorNum){

                                                                      gotoAndStop("new frame");

                                                                      }

                                                                      }

                                                                      • 32. Re: Question concerning clicking object behind a mask effect
                                                                        Fayze93 Level 1

                                                                        Great, that works!

                                                                        I know I've been asking a lot of questions but I really appreciate you taking the time to answer them.

                                                                        Thanks a lot.