First time here? First time here? Newsletter Signup Newsletter
651326 Members and growing! | Flash Jobs
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
	_root.move_panel();
}
// 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!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
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: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.