Search tutorials
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 frameCode 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 |
| » Author |
| Galego (aka Jason White) is an Instructional Designer and a Capoeirista from Grupo CapuraGinga. |
| » Download |
| Download the files used in this tutorial. |
| Download (1488 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


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