在我正在使用的图片库中,我正在发送一个flashvar来设置显示的“当前”图片。 该图库与iTunes和其他Apple的封面效果类似。
在我的动作脚本代码中,我有这个var var current:Number = 1;
当我改变它以将我的flashvar设置为这样的值时:var current:Number = currentPicture;
奇怪的是它工作所以我得到想要的图片作为当前,但当我滚动显示下一张图片时,(那当我向下滚动到上一个时不要出错。所有下一张图片都消失了,..
我在这里粘贴你的代码(修剪为注释中的问题,这里你有init()和next()和previous()函数..我猜问题是在init()函数中的某个地方,但我不是肯定):
/*/
iTunes Album Art Viewer
/*/
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
//Change these values below to customize the viewer functionality
var root:MovieClip = this;
var myMO:Object;
var myKO:Object;
var maxSlide:Number = 100;
var current:Number = currentPicture;
var scrollBarStart:Number = 0;
var scrollerDelay:Number = 150;
var scrollBarStop:Number = scrollBar.scroller._width + 49;
function init(Void):Void {
myMO = {};
myKO = {};
Mouse.addListener(myMO);
Key.addListener(myKO);
for (var i in infostruc) {
loader.clear();
loader.gradient_mc.removeMovieClip();
loader.attachMovie("default","art",1);
loader._width = frontCDWidth;
loader._height = frontCDHeight;
this["_bmd" + i] = new BitmapData(loader._width, loader._height);
this["_ref" + i] = new BitmapData(loader._width, loader._height);
this["_bmd" + i].draw(loader);
var mc:MovieClip = loader.createEmptyMovieClip("gradient_mc", loader.getNextHighestDepth());
matrix = new Matrix();
matrix.createGradientBox(loader._width,loader._height,reflectionRotation / 180 * Math.PI,0,0);
mc.beginGradientFill(reflectionFillType,reflectionColors,reflectionAlphas,reflectionRatios,matrix,reflectionSpreadMethod,reflectionInterpolationMethod,reflectionFocalPointRatio);
mc.moveTo(0,0);
mc.lineTo(0,loader._height);
mc.lineTo(loader._width,loader._height);
mc.lineTo(loader._width,0);
mc.lineTo(0,0);
mc.endFill();
loader.art._alpha = reflectionAlpha;
loader.beginFill(reflectionBackgroundColour);
loader.moveTo(0,0);
loader.lineTo(0,loader._height);
loader.lineTo(loader._width,loader._height);
loader.lineTo(loader._width,0);
loader.lineTo(0,0);
loader.endFill();
this["_ref" + i].draw(loader);
}
// Edit by Matth, Alhadef
// "The Elevator Door 2"
for (var i :Number; i <= infostruc.length;i++){
var cArt:MovieClip = this.createEmptyMovieClip("art" + this.getNextHighestDepth(), this.getNextHighestDepth());
var rArt:MovieClip = this.createEmptyMovieClip("reflection" + (this.getNextHighestDepth() - 1), this.getNextHighestDepth());
rArt.id = cArt.id = rArt.cid = cArt.cid = Number(i) + 1;
cArt.DistortImage(this["_bmd" + cArt.id]);
controlTheObject(cArt);
rArt.DistortImage(this["_ref" + cArt.id]);
controlTheObject(rArt);
var tmpFilter:BlurFilter = new BlurFilter(reflectionBlurX, reflectionBlurY, reflectionQuality);
rArt.filterArray = [];
rArt.filterArray.push(tmpFilter);
rArt.filters = rArt.filterArray;
}
myMO.onMouseWheel = function(delta:Number):Void {
if (delta > 0) {
next();
} else if (delta <= 0) {
previous();
}
};
myKO.onKeyDown = function():Void {
if (Selection.getFocus() != "_level0.goto") {
if (Key.isDown(Key.RIGHT)) {
next();
} else if (Key.isDown(Key.LEFT)) {
previous();
}
}
};
scrollBar.scroller.onPress = function():Void {
dist = this._parent._xmouse - this._x;
this.onMouseMove = function():Void {
tmp = 1 + Math.ceil(((this._parent._xmouse - dist) - scrollBarStart) / (scrollBar._width - scrollBarStop) * (infostruc.length - 1));
if (tmp > infostruc.length) {
tmp = infostruc.length;
}
if (tmp < 1) {
tmp = 1;
}
current = tmp;
updateInfo();
};
};
scrollBar.scroller.onRelease = scrollBar.scroller.onReleaseOutside = function ():Void {
stopDrag();
delete this.onMouseMove;
};
scrollBar.left.onPress = function():Void {
previous();
shifter = setInterval(previous, scrollerDelay);
};
scrollBar.right.onPress = function():Void {
next();
shifter = setInterval(next, scrollerDelay);
};
scrollBar.onMouseUp = function():Void {
clearInterval(shifter);
};
scrollBar.onMouseDown = function():Void {
if (this.hitTest(_xmouse, _ymouse, true) && !this.left.hitTest(_xmouse, _ymouse, true) && !this.right.hitTest(_xmouse, _ymouse, true)) {
if (this._xmouse < this.scroller._x) {
previous();
shifter = setInterval(previous, clickDelay);
}
if (this._xmouse > this.scroller._x + this.scroller._width) {
next();
shifter = setInterval(next, clickDelay);
}
}
};
goto.onChanged = function():Void {
if (!isNaN(Number(this.text) + 1)) {
this.text = Math.round(Number(this.text));
if (this.text > infostruc.length) {
this.text = infostruc.length;
}
if (this.text < 1) {
this.text = 1;
}
current = this.text;
} else {
this.text = current;
}
updateInfo();
};
distance = Number(i);
mask.removeMovieClip();
loader.removeMovieClip();
scrollBar.swapDepths(1101);
loadNext();
updateInfo();
}
function next():Void {
if (current < infostruc.length) {
current += 1;
}
if (current eq infostruc.length) {
// Set our autodirect switch to go back now.
autoDirect = 0;
}
updateInfo();
}
function previous():Void {
if (current > 1) {
current -= 1;
}
if (current == 1) {
// Set our autodirect switch to go forward now
autoDirect = 1;
}
updateInfo();
}
使用此代码,您会看到导致错误的行var current:Number = currentPicture;
...但是,只有当我们切换到下一张图片时才会出现错误,如果转到上一张图片,则会出现两次接下来,它没有bug。
我不熟悉AS,你可以看到,我不是这个东西的编码器,我尽力理解,我已经成功修改了一些值以放大图片等,但对于这个bug,我不喜欢不明白......