Sono andato avanti su un esempio completo, ma c'è una cosa che va in errore se do un'altezza diversa da quella fissata all'inizio.
Codice PHP:
Stage.align = "TL";
Stage.scaleMode = "noScale";
Stage.showMenu = false;
var w:Number, h:Number;
var m:MovieClip = this.createEmptyMovieClip("m", this.getNextHighestDepth());
var i:MovieClip = m.createEmptyMovieClip("i", m.getNextHighestDepth());
var l:Object = new MovieClipLoader();
l.onLoadInit = function (t:MovieClip) {
t._height = (w*t._height)/t._width;
t._width = w;
t._x = -t._width/2;
t._y = -t._height/2;
}
function loadImage (u:String) {
l.loadClip(u, i);
}
this.onResize = function () {
w = Stage.width;
h = Stage.height;
m._x = w/2;
m._y = h/2;
if (i._width > 0) {
i._height = (w*i._height)/i._width;
i._width = w;
i._x = -i._width/2;
}
}
Stage.addListener(this);
this.onResize();
m.onRollOver = function () {
this.onEnterFrame = function () {
if (this._ymouse/Math.abs(this._ymouse) < 1) {
if (i._y < -h/2) {
i._y++;
}
} else {
if (i._y > (h/2)-i._height) {
i._y--;
}
}
}
}
m.onRollOut = function () {
this.onEnterFrame = null;
}
loadImage("test.jpg");