Re: ayuda con galeria xml MovieClip.prototype.DistortImage = function(ptexture, vseg:Number, hseg:Number) {
if (ptexture instanceof BitmapData) {
this.texture = ptexture;
} else if (ptexture instanceof MovieClip) {
this.texture = new BitmapData(ptexture._width, ptexture._height);
this.texture.draw(ptexture);
}
this._w = this.texture.width;
this._h = this.texture.height;
this._aMcs = [];
this._p = [];
this._tri = [];
this.init();
};
MovieClip.prototype.setTransform = function(x0:Number, y0:Number, x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number):Void {
this.dx30 = x3-x0;
this.dy30 = y3-y0;
this.dx21 = x2-x1;
this.dy21 = y2-y1;
for (var l in this._p) {
this.point = this._p[l];
var gx = (this.point.x-this._xMin)/this._w;
var gy = (this.point.y-this._yMin)/this._h;
var bx = x0+gy*(this.dx30);
var by = y0+gy*(this.dy30);
this.point.sx = bx+gx*((x1+gy*(this.dx21))-bx);
this.point.sy = by+gx*((y1+gy*(this.dy21))-by);
}
this.render();
};
MovieClip.prototype.init = function(Void):Void {
this._p = [];
this._tri = [];
this.w2 = this._w/2;
this.h2 = this._h/2;
this._xMin = this._yMin=0;
this._xMax = this._w;
this._yMax = this._h;
this._hsLen = this._w/2;
this._vsLen = this._h/2;
for (ix=0; ix<3; ix++) {
for (iy=0; iy<3; iy++) {
x = ix*this._hsLen;
y = iy*this._vsLen;
this._p.push({x:x, y:y, sx:x, sy:y});
}
}
for (ix=0; ix<2; ix++) {
for (iy=0; iy<2; iy++) {
this.p0 = this._p[iy+ix*3];
this.p1 = this._p[iy+ix*3+1];
this.p2 = this._p[iy+(ix+1)*3];
this.addTriangle(this.p0, this.p1, this.p2);
this.p0 = this._p[iy+(ix+1)*3+1];
this.p1 = this._p[iy+(ix+1)*3];
this.p2 = this._p[iy+ix*3+1];
this.addTriangle(this.p0, this.p1, this.p2);
}
}
this.render();
};
MovieClip.prototype.addTriangle = function(p0:Object, p1:Object, p2:Object):Void {
this.tMat = {};
this.u0 = p0.x;
this.v0 = p0.y;
this.u1 = p1.x;
this.v1 = p1.y;
this.u2 = p2.x;
this.v2 = p2.y;
this.tMat.tx = -this.v0*(this._w/(this.v1-this.v0));
this.tMat.ty = -this.u0*(this._h/(this.u2-this.u0));
this.tMat.a = this.tMat.d=0;
this.tMat.b = this._h/(this.u2-this.u0);
this.tMat.c = this._w/(this.v1-this.v0);
this._tri.push([p0, p1, p2, this.tMat]);
};
MovieClip.prototype.render = function(Void):Void {
this.clear();
this.ih = 1/this._h;
this.iw = 1/this._w;
this.tM = this.sM={};
for (var l in this._tri) {
a = this._tri[l];
this.p0 = a[0];
this.p1 = a[1];
this.p2 = a[2];
this.tM = a[3];
this.sM.a = (this.p1.sx-(this.x0=this.p0.sx))*this.iw;
this.sM.b = (this.p1.sy-(this.y0=this.p0.sy))*this.iw;
this.sM.c = (this.p2.sx-this.x0)*this.ih;
this.sM.d = (this.p2.sy-this.y0)*this.ih;
this.sM.tx = this.x0;
this.sM.ty = this.y0;
this.sM = concat(this.sM, this.tM);
this.beginBitmapFill(this.texture, this.sM, false, false);
this.moveTo(this.x0, this.y0);
this.lineTo(this.p1.sx, this.p1.sy);
this.lineTo(this.p2.sx, this.p2.sy);
this.endFill();
}
};
function loadPlayList(url:String) {
delete myMO.onMouseWheel;
delete myKO.onKeyDown;
for (var i in infostruc) {
root["_ref"+i] = root["_bmd"+i]=false;
}
loadedAll = false;
infostruc = [];
for (var i in root) {
if ((root[i]._name.substr(0, 3) == "art" || root[i]._name.substr(0, 10) == "reflection") && (parseInt(root[i]._name.split("art")[1]) || parseInt(root[i]._name.split("reflection")[1]))) {
root[i].swapDepths(root.getNextHighestDepth());
root[i].removeMovieClip();
}
}
current = 1;
root.createEmptyMovieClip("loader", root.getNextHighestDepth());
xmlData.load(url);
}
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);
root["_shelveCDWidth"+i] = shelveCDWidth;
root["_shelveCDHeight"+i] = shelveCDHeight;
root["_frontCDWidth"+i] = frontCDWidth;
root["_frontCDHeight"+i] = 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);
}
for (var i:Number = count=0; count<Stage.width-(centerDistance*3); count += shelveCDSpacing, i++) {
var cArt:MovieClip = this.createEmptyMovieClip("art"+this.getNextHighes tDepth(), this.getNextHighestDepth());
var rArt:MovieClip = this.createEmptyMovieClip("reflection"+(this.getNe xtHighestDepth()-1), this.getNextHighestDepth());
rArt.id = cArt.id=rArt.cid=cArt.cid=Number(i)+1;
rArt._x = cArt._x=Stage.width;
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 = cArt.filterArray=[];
rArt.filterArray[0] = tmpFilter;
rArt.filters = rArt.filterArray;
tmask = mask.duplicateMovieClip("_mask"+cArt.id, this.getNextHighestDepth(), {_x:mask._x, _y:mask._y});
rmask = mask.duplicateMovieClip("_rmask"+cArt.id, this.getNextHighestDepth(), {_x:mask._x, _y:mask._y});
cArt.setMask(tmask);
rArt.setMask(rmask);
rArt._visible = cArt._visible=false;
}
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._widt h) {
next();
shifter = setInterval(next, clickDelay);
}
}
};
goto.restrict = "0-9";
goto.onKillFocus = function():Void {
if (!isNaN(Number(this.text)+1)) {
if (this.text>infostruc.length) {
this.text = infostruc.length;
}
if (this.text<1) {
this.text = 1;
}
current = Number(this.text);
} else {
this.text = current;
}
updateInfo();
};
fscreen.onPress = function():Void {
fscommand("fullscreen", !(this._currentframe-1));
this.gotoAndStop(!(this._currentframe-1)+1);
};
slideShow.onPress = function():Void {
if (this._currentframe == 1) {
sliderShow = setInterval(function ():Void {
if (current<infostruc.length) {
next();
} else if (slideshowLooping) {
current = 0;
next();
}
}, slideshowSpeed);
} else {
clearInterval(sliderShow);
}
this.gotoAndStop(!(this._currentframe-1)+1);
};
distance = Number(i);
mask.removeMovieClip();
fscreen.swapDepths(1102);
slideShow.swapDepths(1103);
scrollBar.swapDepths(1101);
i2.swapDepths(1105);
i1.swapDepths(1106);
loader.removeMovieClip();
loadNext();
updateInfo();
} |