1 Reply Latest reply on Feb 15, 2007 7:20 AM by Push76

    Should I be using setMask()


      I'm trying to achieve the technique which is applied here by some clever chuffer:


      The effect I am talking about is the image gallery and the masking that takes place here once a thumbnail graphic is clicked on. There must be some layer sorting done in actionscript and the "star" mask must be applied using actionscript somehow.

      Can anyone help me to get started with this?
      Should I be using the setMask() method?
      Should I be using attachMovie?
      Should I be using linkage on items in the library or should all items already be on the stage?

      If anyone can help then that'd be great.


        • 1. Re: Should I be using setMask()
          Push76 Level 1
          Ok, so I knocked up an example...Unfortunately I couldn't get the setMask() method to do what I wanted it to do so I've done it a different way....I'd be interested to see a code example using the setMask() method or if anyone knows a better way of doing this I'd be interested in seeing it...

          I have 5 layers (in this order):

          1. Actions.

          2. Mask (which includes my "star_mask" movie clip. This movie clip has the instance name "the_photo_mask")

          3. New Photo (which is masked by my "mask" layer and includes an empty movie clip with the instance name "new_photo")

          4. Last Photo (Not masked. This layer includes an empty movie clip with the instance name "last_photo")

          5. Buttons (which includes the thumbnail buttons). There are no actions directly on the buttons.

          Other Info:

          The main time line is 1 frame long.

          I have 3 jpgs sitting in the same folder as the .fla and .swf file. (these are glassesGirl.jpg, brownHairGirl.jpg and windyGirl.jpg)

          In the single frame on my "Actions" layer I have the following actionscript:


          var the_last_photo = "GlassesGirl.jpg";

          //Load a default image into the bottom layer (the blonde chick in the glasses)
          loadMovie(the_last_photo, last_photo_holder);

          btnGlassesGirl.onRelease = function(){
          the_last_photo = "GlassesGirl.jpg";
          loadMovie("GlassesGirl.jpg", new_photo_holder);

          btnBrownHairGirl.onRelease = function(){
          the_last_photo = "BrownHairGirl.jpg";
          loadMovie("BrownHairGirl.jpg", new_photo_holder);

          btnWindyGirl.onRelease = function(){
          the_last_photo = "WindyGirl.jpg";
          loadMovie("WindyGirl.jpg", new_photo_holder);

          function loadLastPhoto(photo){
          //trace("in loadLastPhoto function. Last Photo = " + photo);

          Info about the star_mask movie clip

          On the 1st frame of this movie clip there is a stop(); action.

          The 2nd frame is labelled "show".

          The movie clip contains several layers (on each layer there is a star animation of a start slowly growing bigger).

          Each star contributes to an animation which covers up an area the size of one of the full size jpg images)

          The last frame contains the following actionscript:


          So as you can see I haven't used setMask() method. If I want to add more thumbnails I just need to add a function of this format:

          btnThumbnailInstanceName.onRelease = function(){
          the_last_photo = "PhotoName.jpg";
          loadMovie("PhotoName.jpg", new_photo_holder);

          Does anyone have any thoughts on if this is the best/worst way to achieve the technique described in my original post?