This is a discussion on Magnifying Glass Effect within the Flash Actionscript Programming forums, part of the Web Development category; To create a Magnifying Glass Effect: Magnifying glass is not just in the real world. In Flash, we can also ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| To create a Magnifying Glass Effect: 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. Create a new Movie Clip and draw your magnifying glass; fill the glass part with any color you want (for example "Red"). 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); } |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| tint effect | nssukumar | Flash Actionscript Programming | 1 | 02-26-2008 10:05 PM |
| Cause-Effect Graphing Techniques | Shanthi | Software Testing | 1 | 11-16-2007 04:39 AM |
| Put the glass down | Sabari | The Lounge | 1 | 09-10-2007 09:34 AM |
| Drop shadow effect using css | muthukumar | HTML, CSS and Javascript Coding Techniques | 0 | 07-17-2007 12:43 PM |
| Project Looking Glass | drecko | Java Programming | 3 | 02-17-2007 09:11 AM |