Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Spostare un movie clip

  1. #1

    Spostare un movie clip

    Ciao a tutti, vorrei sapere come da un pulsante possa dire ad un movie clip di posizionarsi nelle coordinate prescelte (es.: clicco sul pulsante e una barra di posiziona sotto)... Ero riuscito a farlo ma ora non ricordo + come :master: In oltre questo movie clip dovrebbe avere la "frenata" regolabile... Spero di essere stato chiaro! Grazie per l'attenzione cià

  2. #2
    Utente di HTML.it L'avatar di gobbo89
    Registrato dal
    Jun 2006
    Messaggi
    816
    Benvenuto
    Se hai flash 8 puoi usare le easing function.
    Qui le puoi studiare e capire bene.

    Comunque il codice dovrebbe essere:
    codice:
    import mx.transitions.*;
    import mx.transitions.easing.*;
    MovieClip.prototype.sposta = function(__x:Number, __y:Number, type:Function, tempo:Number){
    	var spostX:Tween = new Tween(this, "_x", type, this._x, __x, tempo, true);
    	var spostY:Tween = new Tween(this, "_y", type, this._y, __y, tempo, true);
    }
    but_mc.onRelease = function() {
    	mc.sposta(100, 100, Regular.easeOut, 1);
    }
    Dove but_mc è il nome istanza del bottone [consiglio di usare un movieClip] e mc è il nome istanza del movieClip da spostare.


  3. #3
    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...

  4. #4
    Utente di HTML.it L'avatar di gobbo89
    Registrato dal
    Jun 2006
    Messaggi
    816
    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.


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.