Bueno les cuento mi duda.
Estoy haciendo una pagina web, que tiene una foto panoramica, ya la hice y los controles de ella se los estoy haciendo en Flash mX.
Cree un MC y botones con las siguientes acciones:
1. El autoplay lo hice con un motion tween
2.El stop pues detener el MC (foto.stop()
3. El Zoom In con un codigo que me encontre en una pagina.
es este.
[i]incremento = 2;
function zoom(x,y,ancho,alto, aceleracion) {
mapa.onEnterFrame = function() {
this._x += (x-this._x)/aceleracion;
this._y += (y-this._y)/aceleracion;
this._width += (ancho-this._width)/aceleracion;
this._height+= (alto-this._height)/aceleracion;
if (Math.abs(x-this._x)<0.5 && Math.abs(y-this._y)<0.5 && Math.abs(ancho-this._width)<0.5 && Math.abs(alto-this._height)<0.5) {
this._x = x;
this._y = y;
this._width = ancho;
this._height = alto;
delete this.onEnterFrame;
}
};
};
onMouseDown =function(){
if (mapa.hitTest(_xmouse,_ymouse)){
Alto = incremento*mapa._height;
Ancho = incremento*mapa._width;
x = _xmouse-((_xmouse-mapa._x) * incremento);
y= _ymouse-((_ymouse-mapa._y) * incremento);
zoom(x,y,Ancho,Alto,3);
}
};[/i]
4. El zoom out con el mismo codigo pero en vez de multiplicar,dividir queda asi:
[i]on (press, release){
foto.stop();
incremento = 1.02;
function zoom(x,y,ancho,alto, aceleracion) {
foto.onEnterFrame = function() {
this._x += (x-this._x)/aceleracion;
this._y += (y-this._y)/aceleracion;
this._width += (ancho-this._width)/aceleracion;
this._height+= (alto-this._height)/aceleracion;
if (Math.abs(x-this._x)<0.5 && Math.abs(y-this._y)<0.5 && Math.abs(ancho-this._width)>0.5 && Math.abs(alto-this._height)>0.5) {
this._x = x;
this._y = y;
this._width = ancho;
this._height = alto;
delete this.onEnterFrame;
}
};
};
{
if (foto.hitTest(_xmouse,_ymouse)){
Alto = foto._height/incremento;
Ancho = foto._width/incremento;
x = _xmouse- ((_xmouse-foto._x) / incremento);
y= _ymouse- ((_ymouse-foto._y) / incremento);
zoom(x,y,Ancho,Alto,3);
zoom(x,y,Ancho,Alto,3);
}
};
}[/i]
5.Un boton que ocupe todo el escenario (obvio solamente en zona activa), para hacer un start drag
Pero me surgen los siguientes incovenientes.
Con los dos codigos anteriores no se como colocarle un limite al Zoom ya se in u out. La foto a medida que uno le da mas clicks crece mas y mas pero no tiene un limite, lo mismo sucede con el zoom out, empieza a hacerce mas y mas pequeña dejando el escenario vacio.
El otro es con el Drag, no se como controlarlo apropiadamente pues le doy valores y el MC con la foto se sale del stage o deja partes en blanco. Me gustaria que tuviera un limite tambien para que eso no sucediera.
En resumen:
1. Como hago para ponerle un limite al Zoom in y al Zoom Out?
2. Como controlo el drag para que el MC no se salga del stage?
No se si me explico.
De antemano Muchas GRACIAS!!!
