View Full Version : Photo Gallery Help
SlowRoasted
March 13th, 2006, 08:38 PM
I have a photo gallery for a client where you can zoom in and scroll around on a photo. I can't seem to get the scrolling to stop when the image edge hits the mask edge. I thought I had it but everything I try sooms to not work. Can anyone give me a little help.
Thx
SR:smirk:
www.worldslargestforum.com/upward/OlympusFlashtestzoomfix.fla
TheCanadian
March 13th, 2006, 09:24 PM
Here's the code for the nav.arrowLeft movie clip, if you need help with the others I'd be glad to:
nav.arrowLeft.onPress = function():Void {
//function to execute when left arrow is released
if (zoom > 1) {
//if the zoom variable is greater than 1. Makes it so you can't move when zoomed out all the way.
onEnterFrame = function () {
//Makes the continuous scroll on press.
if (gallery._x - gallery._width / 2 < galleryMask._x) {
var moveLeft:Tween = new Tween(_root.gallery, "_x", Regular.easeOut, _root.gallery._x, _root.gallery._x + 20, .5, true);
//moves the gallery mc left using the tween class
} else {
var moveLeft:Tween = new Tween(_root.gallery, "_x", Regular.easeOut, _root.gallery._x, galleryMask._x + gallery._width/2, .5, true);
}
};
}
};
:disco:
SlowRoasted
March 13th, 2006, 10:27 PM
Thanks man you're awesome. Could you make the others plz? I'm working on doing the other buttons but it's not working.
TheCanadian
March 14th, 2006, 08:32 PM
Hope this is what you are looking for :hoser:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var zoom:Number = 1;
var speed:Number = 20;
var startx:Number = gallery._x;
var starty:Number = gallery._y;
var xMove:Tween = new Tween(gallery, "_x", Regular.easeOut, gallery._x, gallery._x, 1, true);
var yMove:Tween = new Tween(gallery, "_y", Regular.easeOut, gallery._y, gallery._y, 1, true);
var xScale:Tween = new Tween(gallery, "_xscale", Regular.easeOut, gallery._xscale, gallery._xscale, 1, true);
var yScale:Tween = new Tween(gallery, "_yscale", Regular.easeOut, gallery._yscale, gallery._yscale, 1, true);
var alpha:Tween = new Tween(nav, "_alpha", Regular.easeOut, 0, 0, 1, true);
nav.arrowDown.onPress = function():Void {
if (zoom > 1) {
onEnterFrame = function () {
if (gallery._y + gallery._height / 2 > galleryMask._y + galleryMask._height + speed) {
yMove.continueTo(gallery._y - speed, .5);
} else {
yMove.continueTo(galleryMask._y + galleryMask._height - gallery._height / 2, .5);
}
};
}
};
nav.arrowDown.onRelease = nav.arrowDown.onReleaseOutside = function ():Void {
delete onEnterFrame;
};
nav.arrowLeft.onPress = function():Void {
if (zoom > 1) {
onEnterFrame = function () {
if (gallery._x - gallery._width / 2 < galleryMask._x - speed) {
xMove.continueTo(gallery._x + speed, .5);
} else {
xMove.continueTo(galleryMask._x + gallery._width / 2, .5);
}
};
}
};
nav.arrowLeft.onRelease = nav.arrowLeft.onReleaseOutside = function ():Void {
delete onEnterFrame;
};
nav.arrowRight.onPress = function():Void {
if (zoom > 1) {
onEnterFrame = function () {
if (gallery._x + gallery._width / 2 > galleryMask._x + galleryMask._width + speed) {
xMove.continueTo(gallery._x - speed, .5);
} else {
xMove.continueTo(galleryMask._x + galleryMask._width - gallery._width / 2, .5);
}
};
}
};
nav.arrowRight.onRelease = nav.arrowRight.onReleaseOutside = function ():Void {
delete onEnterFrame;
};
nav.arrowUp.onPress = function():Void {
if (zoom > 1) {
onEnterFrame = function () {
if (gallery._y - gallery._height / 2 < galleryMask._y - speed) {
yMove.continueTo(gallery._y + speed, .5);
} else {
yMove.continueTo(galleryMask._y + gallery._height / 2, .5);
}
};
}
};
nav.arrowUp.onRelease = nav.arrowUp.onReleaseOutside = function ():Void {
delete onEnterFrame;
};
zoomIn.onRelease = function():Void {
if (zoom < 4) {
if (zoom == 1) {
alpha.continueTo(100, .5);
}
zoom++;
xScale.continueTo(gallery._xscale * 1.5, .5);
yScale.continueTo(gallery._yscale * 1.5, .5);
}
};
zoomOut.onRelease = function():Void {
if (zoom > 1) {
if (zoom == 2) {
alpha.continueTo(0, .5);
xMove.continueTo(startx, .5);
yMove.continueTo(starty, .5);
}
xScale.continueTo(gallery._xscale / 1.5, .5);
yScale.continueTo(gallery._yscale / 1.5, .5);
zoom--;
}
};
Sorry but I deleted all of the comments so I could work with code easier :be:
And for the record, strict data typing is not required (yet) :)
SlowRoasted
March 15th, 2006, 01:27 PM
Thanks man, you are my hero:P
TheCanadian
March 16th, 2006, 03:38 PM
Glad to help :mountie:
TheCanadian
March 21st, 2006, 12:44 AM
The quick fix would be to move the picture back to the centre:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var speed:Number = 50;
var zoomLevels:Array = new Array();
zoomLevels[0] = gallery._xscale;
zoomLevels[1] = zoomLevels[0] * 1.5;
zoomLevels[2] = zoomLevels[1] * 1.5;
zoomLevels[3] = zoomLevels[2] * 1.5;
var zoom:Number = 0;
nav._visible = false;
var startx:Number = gallery._x;
var starty:Number = gallery._y;
var xMove:Tween = new Tween(gallery, "_x", Regular.easeOut, gallery._x, gallery._x, 1, true);
var yMove:Tween = new Tween(gallery, "_y", Regular.easeOut, gallery._y, gallery._y, 1, true);
var xScale:Tween = new Tween(gallery, "_xscale", Regular.easeOut, gallery._xscale, gallery._xscale, 1, true);
var yScale:Tween = new Tween(gallery, "_yscale", Regular.easeOut, gallery._yscale, gallery._yscale, 1, true);
var alpha:Tween = new Tween(nav, "_alpha", Regular.easeOut, 0, 0, 1, true);
nav.arrowDown.onPress = function():Void {
if (zoom > 0) {
onEnterFrame = function () {
if (gallery._y + gallery._height / 2 > galleryMask._y + galleryMask._height + speed) {
yMove.continueTo(gallery._y - speed, .5);
} else {
yMove.continueTo(galleryMask._y + galleryMask._height - gallery._height / 2, .5);
}
};
}
};
nav.arrowDown.onRelease = nav.arrowDown.onReleaseOutside = function ():Void {
delete onEnterFrame;
};
nav.arrowLeft.onPress = function():Void {
if (zoom > 0) {
onEnterFrame = function () {
if (gallery._x - gallery._width / 2 < galleryMask._x - speed) {
xMove.continueTo(gallery._x + speed, .5);
} else {
xMove.continueTo(galleryMask._x + gallery._width / 2, .5);
}
};
}
};
nav.arrowLeft.onRelease = nav.arrowLeft.onReleaseOutside = function ():Void {
delete onEnterFrame;
};
nav.arrowRight.onPress = function():Void {
if (zoom > 0) {
onEnterFrame = function () {
if (gallery._x + gallery._width / 2 > galleryMask._x + galleryMask._width + speed) {
xMove.continueTo(gallery._x - speed, .5);
} else {
xMove.continueTo(galleryMask._x + galleryMask._width - gallery._width / 2, .5);
}
};
}
};
nav.arrowRight.onRelease = nav.arrowRight.onReleaseOutside = function ():Void {
delete onEnterFrame;
};
nav.arrowUp.onPress = function():Void {
if (zoom > 0) {
onEnterFrame = function () {
if (gallery._y - gallery._height / 2 < galleryMask._y - speed) {
yMove.continueTo(gallery._y + speed, .5);
} else {
yMove.continueTo(galleryMask._y + gallery._height / 2, .5);
}
};
}
};
nav.arrowUp.onRelease = nav.arrowUp.onReleaseOutside = function ():Void {
delete onEnterFrame;
};
zoomIn.onRelease = function():Void {
if (zoom < 3) {
if (zoom == 0) {
nav._visible = true;
alpha.continueTo(100, .5);
}
zoom++;
xScale.continueTo(zoomLevels[zoom], .5);
yScale.continueTo(zoomLevels[zoom], .5);
}
};
zoomOut.onRelease = function():Void {
if (zoom > 0) {
if (zoom == 1) {
alpha.continueTo(0, .5);
alpha.onMotionFinished = function():Void {
nav._visible = false;
delete this.onMotionFinished;
};
}
zoom--;
xMove.continueTo(startx, .5);
yMove.continueTo(starty, .5);
xScale.continueTo(zoomLevels[zoom], .5);
yScale.continueTo(zoomLevels[zoom], .5);
}
};
:thumb:
SlowRoasted
March 21st, 2006, 12:54 PM
Thanks again bro:P
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.