Test Your Work (Cont.) - Page 10
May 22, 2002
Listing 5.2 Frame 2 ActionScript
if (LIST_ORIENTATION == "horizontal") {
var isOver = _root._ymouse >= gTopBounds && root._ymouse <= gBottomBounds;
} else {
var isOver = _root._xmouse >= gLeftBounds && root._xmouse <= gRightBounds;
}
if (isOver) {
var oldMouseDeltaX = gMouseDeltaX;
var oldMouseDeltaY = gMouseDeltaY;
if (SMOOTH) {
gMouseDeltaX = oldMouseDeltaX + ((_root._xmouse - gMovieCenterX -
oldMouseDeltaX) / (gFriction * 2))
gMouseDeltaY = oldMouseDeltaY + ((_root._ymouse - gMovieCenterY -
oldMouseDeltaY) / (gFriction * 2))
} else {
gMouseDeltaX = _root._xmouse - gMovieCenterX;
gMouseDeltaY = _root._ymouse - gMovieCenterY;
}
} else {
if (SMOOTH) {
gMouseDeltaX = gMouseDeltaX / gFriction;
gMouseDeltaY = gMouseDeltaY / gFriction;
} else {
gMouseDeltaX = 0;
gMouseDeltaY = 0;
}
}
if (LIST_ORIENTATION == "horizontal" && gMouseDeltaX != 0) {
gOriginX = gOriginX - Math.pow(gMouseDeltaX * SCROLL_SPEED, 3) / gConstX;
var clipOffsetX = 0;
for (var i = 0; i < gClipArray.length; i++) { if (gOriginX < -
gTotalWidth) {
gOriginX = gOriginX % gTotalWidth;
} else if (gOriginX > gTotalWidth) {
gOriginX = gOriginX % gTotalWidth;
}
if (!LOOPING) {
if (gOriginX > 1) {
gOriginX = 1;
} else if (gOriginX < MOVIE_WIDTH - gTotalWidth + 1 + CLIP_SPACING) {
gOriginX = MOVIE_WIDTH - gTotalWidth + 1 + CLIP_SPACING;
}
}
var newX = gOriginX + clipOffsetX;
if (newX + gClipArray[i]._width < 0) {
newX = gTotalWidth + newX;
} else if (newX > MOVIE_WIDTH) {
newX = newX - gTotalWidth;
}
gClipArray[i]._x = newX + getClipOffset(gClipArray[i], "x");
clipOffsetX += gClipArray[i]._width + CLIP_SPACING;
}
} else if (LIST_ORIENTATION == "vertical" && gMouseDeltaY != 0) {
gOriginY = gOriginY - Math.pow(gMouseDeltaY * SCROLL_SPEED, 3) /
gConstY;
var clipOffsetY = 0;
for (var i = 0; i < gClipArray.length; i++) {
if (gOriginY < -gTotalHeight) {
gOriginY = gOriginY % gTotalHeight;
} else if (gOriginY > gTotalHeight) {
gOriginY = gOriginY % gTotalHeight;
}
if (!LOOPING) {
if (gOriginY > 1) {
gOriginY = 1;
} else if (gOriginY < MOVIE_HEIGHT - gTotalHeight + 1 + CLIP_SPACING) {
gOriginY = MOVIE_HEIGHT - gTotalHeight + 1 + CLIP_SPACING;
}
}
var newY = gOriginY + clipOffsetY;
if (newY + gClipArray[i]._height < 0) {
newY = gTotalHeight + newY;
} else if (newY > MOVIE_HEIGHT) {
newY = newY - gTotalHeight;
}
gClipArray[i]._y = newY + getClipOffset(gClipArray[i], "y");
clipOffsetY += gClipArray[i]._height + CLIP_SPACING;
}
}
Listing 5.3 Frame 3 ActionScript
gotoAndPlay(2);
Test Your Work - Page 9
Skip Intro: Flash Usability and Interface Design
Making the Component - Page 11
|