Código ActionScript :
Stage.scaleMode = "noScale";
// la peli se ajusta arriba a la izquierda
Stage.align = "TL";
// definimos el tamaño mínimo de la peli
ancho_minimo = 400;
alto_minimo = 180;
// en este array almaceno los clips que se tienen
// que ajustar al cambiar el tamaño de la pantalla
clips_ajustables = new Array();
// definimos el objeto que va a detectar el cambio de tamaño
myListener = new Object();
// asociamos el objeto al stage para detectar los cambios
// de tamaño del stage
Stage.addListener(myListener);
// ejecuto la función rec al cambiar el tamaño
myListener.onResize = rec;
function rec() {
// definimos el alto y ancho que queda
// después de reescalar, si no alcanza
// los mínimos, asignamos éstos
alto = Stage.height;
if (alto<alto_minimo) {
alto = alto_minimo;
}
ancho = Stage.width;
if (ancho<ancho_minimo) {
ancho = ancho_minimo;
}
for (var g = 0; clips_ajustables[g]; g++) {
clips_ajustables[g].alinear();
}
}
// resolución total
//altoTotal = System.capabilities.screenResolutionY;
//anchoTotal = System.capabilities.screenResolutionX;
//alto = stage.height;
//ancho = stage.width;
// con esta función implemento el método setTipo
// en todos los movieClip.
// Los valores para ajuste_x son "izquierda", "derecha" y "centrar"
// Los valores para ajuste_y son "arriba", "abajo" y "centrar"
// Los valores para ajuste_width son false y un número que
// indica el porcentaje de la anchura del clip respecto de la escena
// Los valores para ajuste_height son false y un número que
// indica el porcentaje de la altura del clip respecto de la escena
MovieClip.prototype.setAjuste = function(ajuste_x, ajuste_y, ajuste_width, ajuste_height) {
// estos ajustes nos dicen como se tiene modificar el
// el clip al redimensionar
this.ajuste_x = ajuste_x;
this.ajuste_y = ajuste_y;
this.ajuste_width = ajuste_width;
this.ajuste_height = ajuste_height;
// almaceno la posición y el tamaño
// iniciales de los clips ajustables
this.x0 = this._x;
this.y0 = this._y;
this.w0 = this._width;
this.h0 = this._height;
this.ajustePersonalizado = false;
// almaceno el clip en el array
clips_ajustables.push(this);
this.alinear();
};
// función para alinear los clips en funcion de su tipo
MovieClip.prototype.alinear = function() {
// si se le ha pasado el parámetro ajuste_width en la función
// setAjuste, significa que debo ajustar el ancho del clip
// cuando reescalo la pantalla
if (this.ajuste_width) {
this._width = (_root.ancho*this.ajuste_width)/100;
trace(ancho);
if (this.ajuste_width.indexOf("%") != -1) {
// si el valor de this.ajuste_width es un porcentaje
this._width = (_root.ancho*parseInt(this.ajuste_width))/100;
} else {
// si el valor de this.ajuste_width es un número de píxeles
this._width = this.ajuste_width;
}
}
// lo mismo con el ajuste del alto del clip
if (this.ajuste_height) {
if (this.ajuste_height.indexOf("%") != -1) {
this._height = (_root.alto*parseInt(this.ajuste_height))/100;
} else {
this._height = this.ajuste_height;
}
}
// ajustes de posicion de los clips
if (this.ajuste_x == "izquierda") {
this._x = this.x0;
}
if (this.ajuste_x == "derecha") {
this._x = Math.round(this.x0+(_root.ancho-_root.ancho_minimo));
}
if (this.ajuste_x == "centrar") {
this._x = Math.round((_root.ancho-this._width)*0.5);
}
if (this.ajuste_y == "arriba") {
this._y = this.y0;
}
if (this.ajuste_y == "abajo") {
this._y = Math.round(this.y0+(_root.alto-_root.alto_minimo));
}
if (this.ajuste_y == "centrar") {
this._y = Math.round((_root.alto-this._height)*0.5);
}
// si el clip tiene un ajuste especial ejecuto su función ajustar
// que hemos definido en el onClipEvent(load) del clip
if (this.ajustePersonalizado) {
this.ajustar();
}
};Y en cada clip tengo esto:
Código ActionScript :
onClipEvent (load) {
this.setAjuste("centrar", "centrar", 50, 48);}Muchas gracias
