2 Replies Latest reply: Aug 21, 2014 12:07 PM by rahex RSS

    Reverse mask

    rahex Community Member

      Hi,

       

      I have never used masking before in Flash.

      But now I have a case where it would be a solution.

      I have understood that in Flash everything is shown that is covered by the mask.

       

      But I would like to have the opposite - to hide the stuff under a moving mask.

       

      I have an object on stage and it has holes in it. And the object is moving on stage with AS3.

      And it would look nicer when some of the things (fully or partly) on the background would not be visible through the holes.

       

      So I thought it would be good to have a mask, which is moving together with the object and hides some of the staff on the background.

       

      Is that somehow possible in flash?

       

      Many thanks in advance!

        • 1. Re: Reverse mask
          Preran Employee Hosts

          Hi rahex,

           

          Can you check the solution in this discussion and let us know if it helped? Flash inverted mask - Stack Overflow

           

          Thanks,

          Preran

          • 2. Re: Reverse mask
            rahex Community Member

            Thank you very much Preran,

             

            the solution provided under that link is working in general.

             

            But is there a reliable way to make two movie clips which are inside different movie clips move together?

             

            I have the object, which is moving with an action script tween along the stage, x value.

            And I need to make the mask to move the same. I can make a tween as well, but the x value is a bit difficult. As I do not want it to be a fixed value, but in relation to the stage and the object movie clip it should move together with.

             

            I got it working, but its not 100% reliable.

             

            Is there a way like one movie clip following the movement of other movie clip?

             

            At the moment I have the following code, but I'm not completely happy with how the x value is defined for the mask tween.

             

            function moveGirlAwayFromStage(event: MouseEvent): void

            {

                 awayTweenGirl = new Tween(TudrukRongagaSiputab, "x", Regular.easeIn, 0, -stage.stageWidth / 2 - TudrukRongagaSiputab.width / 2, 15, true);

                 awayTweenWaterMask = new Tween(Vesi.VeePiir.VeePiirMask, "x", Regular.easeIn, 0, -stage.stageWidth / 2 + 25, 15, true);

                 awayTweenGirl.addEventListener(TweenEvent.MOTION_FINISH, moveGirlBackToStage);

            }

             

             

            function moveGirlBackToStage(event: TweenEvent): void

            {

                 TudrukRongagaSiputab.x = stage.stageWidth + TudrukRongagaSiputab.width / 2;

                 Vesi.VeePiir.VeePiirMask.x = stage.stageWidth / 1.3;

                 backTweenGirl = new Tween(TudrukRongagaSiputab, "x", Regular.easeOut, TudrukRongagaSiputab.x, 0, 15, true)

                 backTweenWaterMask = new Tween(Vesi.VeePiir.VeePiirMask, "x", Regular.easeOut, Vesi.VeePiir.VeePiirMask.x, 0, 15, true);

            }

             

            I there a better way?