First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Galego | Website: http://jason.eastendinteractive.com

4. The Magnifying Glass (Part 2)

Using frames allows this update to happen while other things process in flash. Essentially the two-frame arrangment sets up a while-loop effect (just like pre-loading). Add a frame (total of 2 frames) to the movie clip. And use the following code for each frame

Code for frame 1

if (mouse_down eq "true") {
	play ();
} else {
	stop ();
This code simply uses the mouse_down variable (set to true on press and false on release) to determine whether or not it should proceed and execute the code in frame 2.

Code for frame 2

cur_x = _root.mag._x;
cur_y = _root.mag._y;
// Check to see if the magnifying glass/viewing area has moved..if so, update
if (Number(cur_x)<>Number(prev_x) or Number(cur_y)<>Number(prev_y)) {
	// This function is on the root movie clip and is used to updated the viewing window
// set the current position as the next position
prev_x = cur_x;
prev_y = cur_y;
gotoAndPlay (1);
I discovered that you can use the same toggle idea (setting a variable to true/false or 0/1) with ClipEvent instead of the two frame loop with the first frame checking conditions. So instead of using frames...you can just put frame 2's code in the MC itself, something like...
onClipEvent (enterFrame) {
	if (mouse_down == 1) {
	cur_x = _root.mag._x;
	cur_y = _root.mag._y;
// Check to see if the magnifying glass/viewing area has moved..if so, update...etc
//	etc...

Placing the magnifying glass

Return to the main timeline and place the clip at the same x,y as the thumbnail (650,10). Give it an instance name of 'mag' to match what we've put in the code (or come up with your own inventive name...just adjust the code accordingly).
» Level Advanced

Added: 2002-08-20
Rating: 8 Votes: 21
(10 being the highest)
» Author
Galego (aka Jason White) is an Instructional Designer and a Capoeirista from Grupo CapuraGinga.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.