I have this slider. It’s supposed to keep the same buffer on each side and stay centered. It works fine with this code
var myListener:Object = new Object();
myListener.onResize = function() {
updateLocations();
};
Stage.addListener(myListener);
updateLocations = function () {
// Values of the initial .swf width and height
initialWidth = 1200;
initialHeight = 450;
// Get the current stage width and height
currentWidth = Stage.width;
currentHeight = Stage.height;
// Get the content width
contentWidth = contentClip._width;
// Position content vertically
contentClip._y = Math.round((initialHeight/2)-(contentClip._height/2));
// Center the content if the content width is less than currentWidth
if (contentClip._width<currentWidth) {
newX = Math.round(initialWidth/2-contentClip._width/2);
} else {
positionContent();
newX = Math.round(initialWidth/2-contentClip._width/2);
}
};
updateLocations();
//Number of buffer pixels to add on each side of the content
buffer = 0;
//Scroll the content relative to the mouse
this.onMouseMove = function() {
//Only fire if mouse is over the content area
if ((this._xmouse>Math.floor((initialWidth-currentWidth)/2)) && (this._xmouse<Math.floor(initialWidth+2*((currentWidth-initialWidth)/2))) && (this._ymouse>contentClip._y) && (this._ymouse<(contentClip._y+contentClip._height))) {
//Make sure the content width is larger than the currentWidth
if (contentClip._width>currentWidth) {
positionContent();
}
}
};
positionContent = function () {
// Percent of mouse position on content
mousePercent = (this._xmouse+(currentWidth-initialWidth)/2)/currentWidth;
// Total available movement of the content minus screen width
availMovement = contentClip._width-currentWidth+buffer*2;
newX = Math.floor(-mousePercent*availMovement)+(currentWidth-initialWidth)/2+(buffer*2)/2;
};
//Set the initial position to the left side of the screen if content width is more than currentWidth, else center the content
if (contentClip._width>currentWidth) {
newX = Math.floor((initialWidth-currentWidth)/2)+buffer;
} else {
//Center the content
newX = Math.floor(initialWidth/2-contentClip._width/2);
}
//The following 2 functions can be rewritten to utilize the Braingiants Bounce function for improved recycling (it is presented as is for clarity of the actual movement)
holder = contentClip._x;
easeContent = function () {
// Don't fire if the destination position is met
if (newX<>contentClip._x) {
destx = newX;
posx = holder;
velx = (destx-posx)/4;
holder += velx;
contentClip._x = Math.round(holder);
}
};
contentClip.onEnterFrame = function() {
easeContent();
};
updateLocations();
stop();
but when you put this in
Stage.align = "TL";
Stage.scaleMode = "noScale";
it doesn’t work :hangover:
can someone enlighten me why this is happening and why i’m such a moron?
(the slider is from braingiants btw and is attached)