El código a depurar es este...
Stage.align = "TL";
Stage.scaleMode = "noScale";
function menuChoiceOne() {
getURL("http://www.clipdepelicula.com", "_blank");
}
_quality = "best";
cmNew = new ContextMenu();
cmNew.hideBuiltInItems();
cmNew.customItems.push(new ContextMenuItem("Desarrollado por www.clipdepelicula.com", menuChoiceOne));
this.menu = cmNew;
Código :
import mx.transitions.Tween;
#include "mc_tween2.as"
ancho = 400;
alto = 400;
// posicion 'x' e 'y' inicial del borde superior izquierdo
inix = (Stage.width-ancho-40)/2;
iniy = (Stage.height-ancho-40)/2;
cuaporfila = ancho/40;
//Dividido por el ancho del clip
cuaporcolum = alto/40;
total = cuaporfila*cuaporcolum;
// incremento para crear el cuadrado
incrx = 40;
incry = 0;
incrx2 = 40;
incry2 = 0;
// distancia a la que se activa la repulsion
distancia_accion = 40;
//repele para clip
MovieClip.prototype.repele = function(dist, ind) {
this.pos_x = this._x;
this.pos_y = this._y;
this.onEnterFrame = function() {
if (Math.abs(_root._xmouse-this._x)<dist and Math.abs(_root._ymouse-this._y)<dist) {
if (this._x>_root._xmouse) {
this._x = this._x-(this._x-(this.pos_x+(this.pos_x-_root._xmouse)))/10;
} else {
this._x = this._x-(this._x-(this.pos_x-(_root._xmouse-this.pos_x)))/10;
}
//
if (this._y>_root._ymouse) {
this._y = this._y-(this._y-(this.pos_y+(this.pos_y-_root._ymouse)))/10;
} else {
this._y = this._y-(this._y-(this.pos_y-(_root._ymouse-this.pos_y)))/10;
}
} else {
this._x = this._x-(this._x-this.pos_x)/10;
this._y = this._y-(this._y-this.pos_y)/10;
Math.abs(this._x-this.pos_x)<.5 ? this._x=this.pos_x : null;
Math.abs(this._y-this.pos_y)<.5 ? this._y=this.pos_y : null;
}
//Funciones de botón
this.onRollOver = function() {
var myTween:Tween = new Tween(this, "_alpha", mx.transitions.easing.Elastic.easeOut, 100, 50, 1.5, true);
};
this.onRollOut = function() {
var myTween:Tween = new Tween(this, "_alpha", mx.transitions.easing.Elastic.easeOut, 50, 100, 1.5, true);
};
this.onPress = function() {
var myTween:Tween = new Tween(this, "_alpha", mx.transitions.easing.Elastic.easeOut, 100, 100, 1.5, true);
cargaImg(ind);
};
};
updateAfterEvent();
};
//Creando cuadrados
for (i=1; i<=total; i++) {
attachMovie("clip", "clip"+i, i);
var it = _root["clip"+i];
it._x = inix+incrx;
it._y = iniy+incry;
//Le ponemos el numero de cuadrado
it.numero = i;
incrx += 40;
if (incrx>ancho) {
//cuadporlinea entre 40 da el num de cuadrados por linea
incrx = 40;
incry += 40;
}
it.repele(distancia_accion, i);
}
//XML ------------------------------------------------------
var obj_xml:XML = new XML();
obj_xml.ignoreWhite = true;
obj_xml.onLoad = function(exito) {
if (exito) {
var fotos:Number = total;
//numero de fotos maximo
var fotonum:Number = 0;
for (var z:Number = 0; z<fotos; z++) {
//si el nodo existe
if (obj_xml.firstChild.childNodes[z] != null) {
fotonum = z+1;
foto = obj_xml.firstChild.childNodes[z].firstChild.nodeValue;
//trace(foto);
loadMovie("imagenes/"+foto, "clip"+(fotonum)+".fondo");
_root["clip"+fotonum].numero = "";
}
}
} else {
//Muestra un mensaje de error en caso de que algo fallara
texto = "Error";
}
};
obj_xml.load("fotos.xml");
//Enmascarando
for (i=1; i<=total; i++) {
attachMovie("mascara", "mascara"+i, this.getNextHighestDepth());
var ma = _root["mascara"+i];
ma._x = inix+incrx2;
ma._y = iniy+incry2;
incrx2 += 40;
if (incrx2>ancho) {
//cuadporlinea entre 40 da el num de cuadrados por linea
incrx2 = 40;
incry2 += 40;
}
var it = _root["clip"+i];
it.setMask(ma);
ma.repele(distancia_accion, i);
}
//Navegando por imagen
var mouse:Object = new Object();
mouse.onMouseMove = mouse.onEnterFrame=function () {
var Mypic:Number = 1;
//Velocidad al navegar por la imagen
var S:Number = 1;
var Ypos:Number = Stage.height+ancho/40;
var Xpos:Number = Stage.width+alto/40;
var pos:Number = 0;
var T:String = "easeoutexpo";
_root.cargador.hitTest == true;
if (_xmouse>=pos && _xmouse<=Xpos && _ymouse>=pos && _ymouse<=Ypos) {
_root.cargador._x = _root.cargador.tween("_x", (-_xmouse*(_root.cargador._width-Xpos)/Xpos)*Mypic, S, T);
_root.cargador._y = _root.cargador.tween("_y", (-_ymouse*(_root.cargador._height-Ypos)/Ypos)*Mypic, S, T);
updateAfterEvent;
}
};
Mouse.addListener(mouse);
//cargaImg
cargaImg = function (indi) {
attachMovie("cargador", "cargador", getNextHighestDepth());
attachMovie("cerrar", "cerrar"+indi, getNextHighestDepth());
var cerra = _root["cerrar"+indi];
cerra._alpha = 100;
indi2 = indi-1;
//trace(foto_gr);
fotocarga = obj_xml.firstChild.childNodes[indi2].firstChild.nodeValue;
loadMovie("imagenes/"+fotocarga, _root.cargador);
var myTween:Tween = new Tween(_root.cargador, "_alpha", mx.transitions.easing.Strong.easeOut, 0, 100, 1, true);
_root.cargador.onRollOver = function() {
};
cerra.onRelease = function() {
removeMovieClip("cerrar"+indi);
removeMovieClip("_root.cargador");
};
};
stop();
