Originariamente inviato da Luca23_7
Grazie mille! Io però ricordo uno script più semplice... Del tipo: al frame mettevo un codice ke impostava velocità e frenata... Al movie clip da spostare un altro codice che (mi sembra) richiamasse quelllo del frame, e infine al pulsante un codice ke comprendeva la funzione _root per le coordinate...
Grazie per l'aiuto!
Cià
p.s.: uso Flash MX...
Beh, se usi MX non puoi usare le easing...
Per quanto riguarda il codice... E' da un po' che non faccio più una funzione a mano per lo spostamento dei mc (essendomi abituato ad usare le easing), se vuoi posso passarti un codice vecchio che usavo prima delle novità di flash 8. Però non ho nessuna azione su mc o pulsanti, ma tutto sul frame. Inoltre non gestisce la frenate, ma l'incremento di x e y. Non è il massimo dal punto di vista sintattico, ero alle prime armi quando l'ho fatto
Eccolo:
codice:
function tracciaPos(path) {
trace("X: "+path._x+"\t"+"Y: "+path._y+"\tSit:"+sit);
}
function posiziona(path, X, Y) {
path._x = X;
path._y = Y;
}
MovieClip.prototype.trasla = function(xIniz, xFin, yIniz, yFin, fattoreX, fattoreY) {
this._x = xIniz;
this._y = yIniz;
tracciaPos(this);
if(xIniz==xFin && yIniz==yFin) {
return traslato = true;
}
if(xIniz==xFin && yIniz<yFin) {
_global.sit = "=<";
}
if(xIniz==xFin && yIniz>yFin) {
_global.sit = "=>";
}
if(xIniz<xFin && yIniz==yFin) {
_global.sit = "<=";
}
if(xIniz>xFin && yIniz==yFin) {
_global.sit = ">=";
}
if (xIniz<xFin && yIniz<yFin) {
_global.sit = "<<";
}
if (xIniz>xFin && yIniz>yFin) {
_global.sit = ">>";
}
if (xIniz<xFin && yIniz>yFin) {
_global.sit = "<>";
}
if (xIniz>xFin && yIniz<yFin) {
_global.sit = "><";
}
this.onEnterFrame = function() {
//trace("onEnter");
if (sit == "=<") {
if (this._y<yFin) {
this._y += fattoreY;
}
if (this._y>=yFin) {
posiziona(this, xFin, yFin);
tracciaPos(this);
delete this.onEnterFrame;
return traslato=true;
}
tracciaPos(this);
}
if (sit == "=>") {
if (this._y>yFin) {
this._y -= fattoreY;
}
if (this._y<=yFin) {
posiziona(this, xFin, yFin);
tracciaPos(this);
delete this.onEnterFrame;
return traslato=true;
}
tracciaPos(this);
}
if (sit == "<=") {
if (this._x<xFin) {
this._x += fattoreX;
}
if (this._x>=xFin) {
posiziona(this, xFin, yFin);
tracciaPos(this);
delete this.onEnterFrame;
return traslato=true;
}
tracciaPos(this);
}
if (sit == ">=") {
if (this._x>xFin) {
this._x -= fattoreX;
}
if (this._x<=xFin) {
posiziona(this, xFin, yFin);
tracciaPos(this);
delete this.onEnterFrame;
return traslato=true;
}
tracciaPos(this);
}
if (sit == "<<") {
if (this._x<xFin) {
this._x += fattoreX;
}
if (this._y<yFin) {
this._y += fattoreY;
}
if (this._x>=xFin && this._y>=yFin) {
posiziona(this, xFin, yFin);
tracciaPos(this);
delete this.onEnterFrame;
return traslato=true;
}
tracciaPos(this);
}
if (sit == ">>") {
if (this._x>xFin) {
this._x -= fattoreX;
}
if (this._y>yFin) {
this._y -= fattoreY;
}
if (this._x<=xFin && this._y<=yFin) {
posiziona(this, xFin, yFin);
tracciaPos(this);
delete this.onEnterFrame;
return traslato=true;
}
tracciaPos(this);
}
if (sit == "<>") {
if (this._x<xFin) {
this._x += fattoreX;
}
if (this._y>yFin) {
this._y -= fattoreY;
}
if (this._x>=xFin && this._y<=yFin) {
posiziona(this, xFin, yFin);
tracciaPos(this);
delete this.onEnterFrame;
return traslato=true;
}
tracciaPos(this);
}
if (sit == "><") {
if (this._x>xFin) {
this._x -= fattoreX;
}
if (this._y<yFin) {
this._y += fattoreY;
}
if (this._x<=xFin && this._y>=yFin) {
posiziona(this, xFin, yFin);
tracciaPos(this);
delete this.onEnterFrame;
return traslato=true;
}
tracciaPos(this);
}
};
};
but_mc.onRelease = function() {
mc.trasla(mc._x, 100, mc._y, 100, 2, 2);
}
but_mc è il nome istanza del bottone.
mc è il nome istanza del movieClio.