In the movie above, the background layer contains the photo to be distorted, and the layer above contains a movieclip with instance name magnifier. At the start of the movie, distorter contains another movieclip lens, with a center registration point, which contains inside it a mask shape (any shape can be used) in a mask layer above a layer containing the same photo that has been converted to a movieclip and called image. When the movie is run, the lens movieclip will be duplicated some specified number of times to provide a series of child lenses, each of which independently masks its own copy of the photo, and each of which will reside inside the draggable magnifier movieclip.
  1. Open Flash by clicking on the Flash Icon on the dock:



  2. Create a new document. Make sure it is Actionscript 2



  3. Save (+SHIFT+S) document in work folder:



  4. Open up the Properties window


  5. Select and import a jpeg that you want to use. Go to File menu and import to library.


  6. Drag the image from the library and place on the stage in frame 1


  7. Resize the movie to match the the size of the image

  8. Name the layer bgPhoto


  9. Select the photo and copy it (+C)

  10. Insert a new symbol (+F8) and name the new symbol imageLayer

  11. Paste the photo into this clip. It should be centered


  12. Insert a new layer in the imageLayer clip and name the layer glass

  13. Use the oval tool to create an oval without a stroke in the center of the stage on the glass layer. I created an oval using the crosshair as the upper-left hand corner, then used the property inspector to adjust the position.


  14. Click on the photo in the bottom layer and convert it to symbol (F8). Name the symbol image. In the properties Inspector, also name the instance image


  15. CTRL click on the glass layer and make it a mask


  16. Return to Scene 1


  17. Insert a new layer in scene 1 and name the layer magnifier
          
  18. Drag the imageLayer clip from the library onto this new layer in Scene 1


  19. Select the selection tool and click on the magnifier layer to select it. In the Properties Inspector, name the instance lens


  20. Select lens and press F8 to convert to a movie clip. Name the new symbol magnifier. In the Properties Inspector, also name the instance magnifier

  21. Double click on the magnifier symbol to go inside the clip

  22. Select the lens instance and center it

  23. Insert a new layer

  24. On the new layer add a stroke around the lens


  25. Return to Scene 1
    Add another layer and name it actions

  26. Copy and complete the code:
    // the more lenses, the higher precision, but more processing power is required
    //set a variable called  nLenses to a number between 20 and 30
    __________________
    
    
    /* the distortRatio = difference between middle and outer edges of the magnified image.
    Set a variable named distortRatio to a number between 3 and 12*/
    ____________________
    
    // To setup you want to create your lenses and set their sizes (and photo sizes)
    //define the setupLenses function
    function setupLenses() {
       // the lens is only used to make duplicates (not to display)
       //to start make the lens which is inside the magnifier invisible
       //to do this set the _visible property to true or false
      ____________________________
    	
       // create lenses in graduated sizes (progressively smaller)
       for(i=1; i<=nLenses; i++) {
       
          //create a variable called lensSize to hold the new sizes
          ____________ = 10 + 90*(nlenses+1-i)/nlenses;
          
          // each lens+i will be created in magnifier (not magnifier.lens)
          //on the lens clip inside magnifier call duplicateMovieClip and pass it
          //"lens"+i,i
          magnifier.lens.duplicateMovieClip( "lens"+i,i );
          
          //now set the _xscale property of the duplicated clip to the current 
          //lensSize
          magnifier["lens"+i]._xscale=lensSize;
          
          //set the _yscale property 
          _______________________________
          
          //create a variable called distortion and set it to
          //the sum of 100 plus the product of distortRatio multiplied by 
          //the current iteration of the loop (i)
         ____________________________________
         
         //set the _xscale and _yscale properties of 
         //the image of the current lens (["lens"+i] of
         //magnifier to the product of 100 times distortion divided by lensSize
         ___________________________________________
         ___________________________________________
       }
    }
    
    // makes movieclip to which this is attached draggable
    function makeDraggable() {
       this.startDrag();
    }
    
    // makes movieclip to which this is attached undraggable
    function stopDraggable() {
       this.stopDrag();
       // uncomment to figure out where to place magnifier initially:
       //trace(this._x+' '+this._y);
    }
    
    // set up magnifier position and event handlers
    function setupMagnifier() {
       // set initial position of magnifier 
       magnifier._x = 228;
       magnifier._y = 114;
    
       // set up event handlers for magnifier
       magnifier.onEnterFrame = moveLenses;
       magnifier.onPress = makeDraggable;
       magnifier.onRelease = stopDraggable;
       magnifier.onReleaseOutside = stopDraggable;
    }
    	
    // set position of each child lens (relative to magnifier position)
    // this function is attached to magnifier and called at intervals = frame rate
    function moveLenses() {
       for(i=1; i<=nlenses; i++) {
          var lensSize:Number = 10 + 90*(nlenses+1-i)/nlenses;
          distortion = 100 + distortRatio*i;
          this["lens"+i].image._y = -1*distortion/lensSize*this._y;
          this["lens"+i].image._x = -1*distortion/lensSize*this._x;
       }
    }
    
    setupLenses();
    setupMagnifier();