• Home
  • Free Tutorials
  • Free Video Tutorials

Adobe Photoshop
Autodesk 3ds Max
CSS
Flash
Help Center Live
iPhone
Joomla
Make Money Online!
Mambo
mIRC
Outlook Express
SEO / SEM
Simple Machine Forum
Target Explorer

Magnifying Glass

Category : Flash Views : 37068
Version : 8 Rating : 
3.0/5 (55 votes)
  • Currently 3.02/5
  • 1
  • 2
  • 3
  • 4
  • 5
Type : Text Source File: magnifying-glass.zip
Result: See the result


Previous | 1 | 2 | Next

Magnifying glass is not just in the real world. In Flash, we can also create a magnifying glass. You can zoom a picture or even text. Maybe you can even use this for disability people that are using your computer.

Free Flash Tutorials, Actionscript, Magnifying Glass

Create a new Movie Clip and draw your magnifying glass; fill the glass part with any color you want.
Free Flash Tutorials, Actionscript, Magnifying Glass

Select the red and press F8, this will create a new Movie Clip that we will use as a mask.

After converting, delete it from the magnifying glass Movie Clip.

Drag both Movie Clip to the stage, one with the instance "imgMask" and the other "magGlass".

Now create a new Movie Clip just to hold our image, drag it to the stage and give the instance name "imgHolder".

Paste this on the first frame:
//load an image named "image.jpg" to the imgHolder Movie Clip loadMovie('image.jpg', imgHolder); //new Movie Clip just to hold the zoomed image this.createEmptyMovieClip("zoomImg", 33); //Set a mask inside the Movie Clip so the zoomed image is rounded zoomImg.setMask(imgMask); // bitmap object to zoom the image var zoomBitmap = new flash.display.BitmapData(155, 155, false, 0xEAEAEA); //attach the bitmap to the" zoomImg" Movie Clip zoomImg.attachBitmap(zoomBitmap, 5); //zoom power, increase this to zoom more var magPower = 2; //matrix object to position the zoomed bitmap inside the magnifier var zoomMtx = new flash.geom.Matrix(); //scale the image using the "magPower" zoomMtx.scale(magPower, magPower); //swap depths for the magnifier Movie Clip so it is on top magGlass.swapDepths(_root.getNextHighestDepth()); _root.onEnterFrame = function() { //hide the mouse Mouse.hide(); //set the magnifier Movie Clip to the position of the mouse magGlass._x = _xmouse - 70; //so the mouse is in the middle of the lens magGlass._y = _ymouse - 70; //zoomed image Movie Clip zoomImg._x = magGlass._x; zoomImg._y = magGlass._y; //Mask Movie Clip imgMask._x = magGlass._x; imgMask._y = magGlass._y; //where to draw the zoomed image zoomMtx.tx = -_xmouse * magPower; zoomMtx.ty = -_ymouse * magPower; //draw zoomed image using the image in the //holder and the position of the matrix. zoomBitmap.draw(imgHolder, zoomMtx); }
It works for any image, choose a different picture and name it "image1.jpg" to test.


More cool tech articles from other blogs.

Place your ad here
Loading...


Previous | 1 | 2 | Next
How to Video Tutorials on software by Helpvids.com

Sponsors





Web Design
Flash Application Development
Studio | Advertisement | About Webzo | Contact Webzo | Terms of Use | Free Video Tutorials by Helpivds

Copyright © 2007 NR Concepts Ltd. All rights reserved.