Como hago?
Aqui lo pego:
Código :
//-------------------------------------------------------------------------------------
//--PANORAMIC PROTOTYPE
MovieClip.prototype.panoramic = function(p, n, d, x, y, w, h, v, preload, onLoad) {
this.createEmptyMovieClip(n, d);
this[n]._x = x;
this[n]._y = y;
this[n].width = w;
this[n].height = h;
this[n].levelDelay = 25;
this[n].loadImage = function(arg) {
this.createEmptyMovieClip("holder", 0);
this.createEmptyMovieClip("mc1", 1);
this.createEmptyMovieClip("mc2", 2);
this.tmp = arg.split(".");
if (this.tmp.length == 2) {
this.mc1.loadMovie(arg);
this.mc2.loadMovie(arg);
} else {
this.mc1.attachMovie(arg, arg, 1);
this.mc2.attachMovie(arg, arg, 1);
}
this.imageName = arg;
this.getImageName = function() {
return this.imageName;
};
this.resetSize(this.width, this.height);
this.run();
};
this[n].setSize = function(wm, hm) {
this.resetSize(wm, hm);
this.run();
};
this[n].resetSize = function(wm, hm) {
this.mc1._x = this.mc1._y=this.mc2._x=this.mc2._y=0;
this.mc1.setDynamicMask(3, 0, 0, (this.mc1._width>wm) ? wm : this.mc1._width, (this.mc1._height>hm) ? hm : this.mc1._height);
this.mc2.setDynamicMask(4, 0, 0, (this.mc2._width>wm) ? wm : this.mc2._width, (this.mc2._height>hm) ? hm : this.mc2._height);
this.xm = this.mc1.mask._width/2;
this.ym = this.mc1.mask._height/2;
this.width = wm;
this.height = hm;
if (this.mc1._height>this.mc1.mask._height) {
this.mc1._y = this.mc2._y=-this.mc1._height/2+this.mc1.mask._height/2;
}
this.getWidth = function() {
return this.mc1.mask._width;
};
this.getHeight = function() {
return this.mc1.mask._height;
};
};
this[n].setSpeed = function(arg) {
this.speed = this.maxSpeed=(arg>0) ? arg/10 : 0.1;
this.speed = this.maxSpeed=(this.speed<10) ? this.speed : 10;
this.getSpeed = function() {
return this.maxSpeed*10;
};
};
this[n].move = function() {
//-- xpan
if (this.mc1._width>this.mc1.mask._width) {
this.indX = -((this._xmouse-this.xm)*this.speed);
this.mc1._x += Math.round(this.indX);
if (this._xmouse<this.xm && this.mc1._x>=0) {
this.mc1._x = -(this.mc1._width);
}
if (this._xmouse>=this.xm && this.mc1._x<=-(this.mc1._width)) {
this.mc1._x = 0;
}
this.mc2._x = this.mc1._x+Math.round(this.mc1._width);
}
//--xpan
if (this.mc1._height>this.mc1.mask._height) {
this.indY = ((this._ymouse-this.ym)*this.speed);
this.indY = (this.indY<0) ? this.indY*-1 : this.indY;
if (this._ymouse<this.ym) {
this.mc1._y = (this.mc1._y+this.indY<0 && this.mc1._y<0) ? this.mc1._y+this.indY : 0;
}
if (this._ymouse>=this.ym) {
this.mc1._y = (this.mc1._y-this.indY>-(this.mc1._height-this.mc1.mask._height) && this.mc1._y>-(this.mc1._height-this.mc1.mask._height)) ? this.mc1._y-this.indY : -(this.mc1._height-this.mc1.mask._height);
}
this.mc2._y = this.mc1._y;
}
};
this[n].delay = function() {
this.mc1.mask.onEnterFrame = function() {
trace(this._parent.speed);
this._parent.speed -= this._parent.maxSpeed/this._parent.levelDelay;
this._parent.move();
if (this._parent.speed-this._parent.maxSpeed/this._parent.levelDelay<=0) {
this._parent.speed = this._parent.maxSpeed;
delete this.onEnterFrame;
}
};
};
this[n].run = function() {
this.holder.onEnterFrame = function() {
//-- preload
this._parent._visible = 0;
if (this._parent.mc1.getBytesTotal()>20) {
preload(this._parent.mc1.getBytesTotal()+this._parent.mc2.getBytesTotal(), this._parent.mc1.getBytesLoaded()+this._parent.mc2.getBytesLoaded());
}
if (this._parent.mc1._width>0 && this._parent.mc2._width>0) {
delete this.onEnterFrame;
this._parent.resetSize(this._parent.width, this._parent.height);
preload(this._parent.mc1.getBytesTotal(), this._parent.mc1.getBytesLoaded());
onLoad();
this._parent._visible = 1;
this._parent.mc1.mask.onRollOver = function() {
this._parent.speed = 0;
this.onEnterFrame = function() {
if (this._parent.maxSpeed>this._parent.speed+this._parent.maxSpeed/this._parent.levelDelay) {
this._parent.speed += this._parent.maxSpeed/this._parent.levelDelay;
} else {
this._parent.speed = this._parent.maxSpeed;
}
trace(this._parent.maxSpeed)
trace(this._parent.speed)
this._parent.move();
};
};
this._parent.mc1.mask.onRollOut = function() {
this._parent.delay();
};
this._parent.mc1.mask.useHandCursor = false;
}
};
};
this[n].setSpeed(v);
this[n].loadImage(p);
};
//--PANORAMIC PROTOTYPE
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
//--SET DINAMIC MASK PROTOTYPE
MovieClip.prototype.setDynamicMask = function(depth, x, y, w, h) {
//crea máscara dinámicamente
this.mask = this._parent.createEmptyMovieClip("mask"+depth, depth);
with (this._parent["mask"+depth]) {
beginFill(0x000000, 100);
moveTo(x, y);
lineTo(x+w, y);
lineTo(x+w, y+h);
lineTo(x, y+h);
lineTo(x, y);
endFill();
}
this.setMask(this.mask);
};
//myMc.setDynamicMask(depth, _x, _y, _width, _height);
//
//--SET DINAMIC MASK PROTOTYPE
//-------------------------------------------------------------------------------------
//
//--USO
//aca defino la función que se va a asociar a la precarga
myPanPreload = function (total, loaded, width) {
display.text = Math.round(100/total*loaded)+"%";
};
//aca defino la función que se va a asociar al evento onLoad
myPanOnLoad = function () {
// centra la el componente en pantalla
display.text = "";
myPanoramic._x = Stage.width/2-myPanoramic.getWidth()/2;
myPanoramic._y = Stage.height/2-myPanoramic.getHeight()/2;
};
//
this.panoramic("myImage.jpg", "myPanoramic", 1, 0, 0, 400, 200, 1, myPanPreload, myPanOnLoad);
//
//métodos públicos
//----------------
// 1 - para crear panorámica (incluye los métodos 2, 3, y 4):
// myInstance.panoramic("url" or "id", "instanceName", depth, _x, _y, _width, _height, speed, preloadFunction, onLoadFunction);
// 2 - para cambiar speedocidad (min = 0.1 / max = 10):
// myPanoramic.setSpeed(value);
// 3 - para cambiar tamaño:
// myPanoramic.setSize(_width, _height);
// 4 - para cargar una imagen:
// myPanoramic.loadImage("path or id name");
//
//return
//------
// getWidth();
// getHeight();
// getSpeed();
// getImageName();
//
button.onPress = function() {
//si la velocidad actual es 1, la sube a 2. Si es 2 la baja a 1.
myPanoramic.setSpeed((myPanoramic.getSpeed() == 1) ? 2 : 1);
};
button2.onPress = function() {
//alterna ancho entre 400 y 300 y alto entre 200 y 150 pixels
myPanoramic.setSize((myPanoramic.getWidth() == 400) ? 300 : 400, (myPanoramic.getHeight() == 200) ? 150 : 200);
//reposiciona el componente en el medio de la pantalla
myPanoramic._x = Stage.width/2-myPanoramic.getWidth()/2;
myPanoramic._y = Stage.height/2-myPanoramic.getHeight()/2;
};
button3.onPress = function() {
//carga una imagen desde la librería
myPanoramic.loadImage((myPanoramic.getImageName() == "myImage.jpg") ? "myImage" : "myImage.jpg");
}; 