_global.desplazaFoto = function(mcFoto, wBase, hBase, velScroll, direccion) { // Comprueba tipo de scroll (horizontal/vertical) if (mcFoto._height > hBase) { // Scroll vertical mcFoto.limiteAbajo = 0; mcFoto.limiteArriba = 0 - (mcFoto._height-hBase); // Coloca foto al principio o al final if (random(2) == 0) { mcFoto.y = mcFoto.limiteAbajo; mcFoto.dir = -1; } else { mcFoto.y = mcFoto.limiteArriba; mcFoto.dir = 1; } mcFoto._y = mcFoto.y; // Inicia el desplazamiento mcFoto.onEnterFrame = function() { if (this.dir == 1) { this.y += velScroll; if (this.y >= mcFoto.limiteAbajo) { this.y = mcFoto.limiteAbajo; this.dir = -1; } this._y = this.y; } else if (this.dir == -1) { this.y -= velScroll; if (this.y <= mcFoto.limiteArriba) { this.y = mcFoto.limiteArriba; this.dir = 1; } this._y = this.y; } } } else if (mcFoto._width > wBase) { // Scroll horizontal mcFoto.limiteDerecha = 0; mcFoto.limiteIzquierda = 0 - (mcFoto._width-wBase); // Coloca foto al principio o al final if (random(2) == 0) { mcFoto.x = mcFoto.limiteDerecha; mcFoto.dir = -1; } else { mcFoto.x = mcFoto.limiteIzquierda; mcFoto.dir = 1; } // Si se pone el parametro direccion, rectifica if (direccion == 1) { mcFoto.x = mcFoto.limiteIzquierda; mcFoto.dir = 1; } else if (direccion == -1){ mcFoto.x = mcFoto.limiteDerecha; mcFoto.dir = -1; } mcFoto._x = mcFoto.x; // Inicia el desplazamiento mcFoto.onEnterFrame = function() { if (this.dir == 1) { this.x += velScroll; if (this.x >= mcFoto.limiteDerecha) { this.x = mcFoto.limiteDerecha; this.dir = -1; } this._x = this.x; } else if (this.dir == -1) { this.x -= velScroll; if (this.x <= mcFoto.limiteIzquierda) { this.x = mcFoto.limiteIzquierda; this.dir = 1; } this._x = this.x; } } } }