7 Replies Latest reply: Jun 18, 2014 6:44 AM by kglad RSS

    setMask() using loadMovie()

    Ron Colmen Community Member

      I need to load an external swf in to a movieclip and use setMask() to mask another movieclip. This is not working. Is it possible to do this in AS2?

       

      example:

      loadMovie("http://www.example.com/swfFile.swf", _root.mc1_mc.mc2_mc); //this external swf's instance name is clip1

       

      abc_btn.onRelease=function(){

          _root.mc1_mc.mc2_mc.createEmptyMovieClip("clip0", _root.mc1_mc.mc2_mc.getNextHighestDepth());

          _root.mc1_mc.mc2_mc.clip0.setMask( _root.mc1_mc.mc2_mc.clip1);

      }

        • 1. Re: setMask() using loadMovie()
          kglad CommunityMVP

          that will work, but it doesn't make much sense and probably does not do what you want.  ie, you're masking an empty movieclip.  so, you would expect to see clip1 'disappear' when it's set as a mask and nothing revealed because clip0 is an empty movieclip.

           

          what is it that you want to do?

          • 2. Re: setMask() using loadMovie()
            Ron Colmen Community Member

            Yes, you're correct 'clip0' is empty in my sample code. I'm using the empty movieclip with attachMovie() to tile a background.

             

            This is what I want to be able to do. This works if I manually add the "clip1" movieclip instead of using loadMovie()

             

            But I want to use loadMovie to import external swfs

             

            loadMovie("http://www.example.com/swfFile.swf", _root.mc1_mc.mc2_mc); //this external swf's instance name is clip1

             

            abc_btn.onRelease=function(){

            NuX = NuY = 0;

                    for(j=0;j<296;j++){

                        if(NuX>=650){

                            NuX=0;

                            NuY=NuY+50;

                        }

                 _root.mc1_mc.mc2_mc.createEmptyMovieClip("clip0", _root.mc1_mc.mc2_mc.getNextHighestDepth());

                 _root.mc1_mc.mc2_mc.clip0.attachMovie(attX[this.pvar], "tileB"+j, _root.mc1_mc.mc2_mc.clip0.getNextHighestDepth(), {_x:NuX, _y:NuY});

                                //trace(_root.mc1_mc.mc2_mc.clip0["tileB"+j]) //undefined when loadMovie() is used.

                                NuX=NuX+50;

                                 if(j==296){

                                     _root.mc1_mc.mc2_mc.clip0.setMask( _root.mc1_mc.mc2_mc.clip1);

                            }

            }

            • 3. Re: setMask() using loadMovie()
              kglad CommunityMVP

              you can't use attachMovie applied to a load target or child of a load target.

              • 4. Re: setMask() using loadMovie()
                Ron Colmen Community Member

                Thanks Kglad.

                 

                Instead of using attachMovie() to the load target will it work if I apply the attachMovie() within the loadMovie() swf? so once it's loaded the tile effect could be achieved?

                • 5. Re: setMask() using loadMovie()
                  kglad CommunityMVP

                  you can use attachMovie in the loaded swf.  i'm not sure what you'll try and do after that.

                  • 6. Re: setMask() using loadMovie()
                    Ron Colmen Community Member

                    Thanks Kglad.

                    • 7. Re: setMask() using loadMovie()
                      kglad CommunityMVP

                      you're welcome.