Skip to main content
Inspiring
June 17, 2014
Answered

setMask() using loadMovie()

  • June 17, 2014
  • 1 reply
  • 704 views

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);

}

This topic has been closed for replies.
Correct answer kglad

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?


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

1 reply

kglad
Community Expert
Community Expert
June 17, 2014

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?

Inspiring
June 17, 2014

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);

                }

}

kglad
Community Expert
Community Expert
June 17, 2014

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