vorrei duplicare un clip e caricarlo random (più volte lo stesso ad intervalli casuali) sull'asse delle x di un mc target.
si può fare?
Qualcuno mi suggerisce lo script per favore?
Grazie a tutti!![]()
vorrei duplicare un clip e caricarlo random (più volte lo stesso ad intervalli casuali) sull'asse delle x di un mc target.
si può fare?
Qualcuno mi suggerisce lo script per favore?
Grazie a tutti!![]()
Silvia
...e quindi uscimmo a riveder le stelle..
http://www.silviamato.it
http://alano.silviamato.it
Ciao, farlo sicuramente si può...
Ma devo capire bene cosa vuoi fare se vuoi una cosa che continua a muoversi? Se è così allora:
Crea un piccolo MC (io ho fatto un piccolo cerchietto vuoto, solo la linea) e lo metti nella libreria chiamalo "ball" (tasto destro su l'MC - linkage - export for action script)
Sul primo frame metti questo:
Se lo vuoi fermo, che solo una volta vadano random:codice:var totMC:Number = 20; for (var i = 0; i<totMC; i++) { var t = this.attachMovie("ball", "ball"+i, i+1); t._x = Math.random()*Stage.width t._y = Math.random()*Stage.height t.dx = Math.round(Math.random()*Stage.width); t.dy = Math.round(Math.random()*Stage.height); t.onEnterFrame = mover; } function mover() { this._x += (this.dx-this._x)/3; this._y += (this.dy-this._y)/3; if (Math.round(this._x) == this.dx) { this.dx = Math.round(Math.random()*Stage.width); this.dy = Math.round(Math.random()*Stage.height); } }
Altrimenti spiega meglio così capisco... Ciao!codice:var totMC:Number = 20; for (var i = 0; i<totMC; i++) { var t = this.attachMovie("ball", "ball"+i, i+1); t._x = Math.random()*Stage.width t._y = Math.random()*Stage.height t.dx = Math.round(Math.random()*Stage.width); t.dy = Math.round(Math.random()*Stage.height); t.onEnterFrame = mover; } function mover() { this._x += (this.dx-this._x)/3; this._y += (this.dy-this._y)/3; }
Ciao, Salvo.
Credo che questo sia il codice che mi interessa
ma posso chiederti ancora se è quello che hop colorato il nome del mc da duplicare e caricare random?
*Stage.width e qui inserisco cosa la larghezza totale dell'asse delle x?
Mi serve che si carichi solo su quest'asse e non anche sull'altezza...
var totMC:Number = 20;
for (var i = 0; i<totMC; i++) {
var t = this.attachMovie("ball", "ball"+i , i+1);
t._x = Math.random()*Stage.width
t._y = Math.random()*Stage.height
t.dx = Math.round(Math.random()*Stage.width);
t.dy = Math.round(Math.random()*Stage.height);
t.onEnterFrame = mover;
}
function mover() {
this._x += (this.dx-this._x)/3;
this._y += (this.dy-this._y)/3;
if (Math.round(this._x) == this.dx) {
this.dx = Math.round(Math.random()*Stage.width);
this.dy = Math.round(Math.random()*Stage.height);
}
}
Silvia
...e quindi uscimmo a riveder le stelle..
http://www.silviamato.it
http://alano.silviamato.it
Ciao,
si
Il primo "ball" è quello che va a prendere dalla libreria, e il secondo è il nuovo nome che gli assegna, in questo caso "ball"+i, cioè "ball1", "ball2", "ball3", etc..codice:var t = this.attachMovie("ball", "ball"+i , i+1);
Per usarlo solo sull'asse _x metti:
Però così ti si creeranno tutti sull'asse _y=0 quindi devi dargli almeno un indicazione e puoi mettere:codice:var totMC:Number = 20; for (var i = 0; i<totMC; i++) { var t = this.attachMovie("ball", "ball"+i , i+1); t._x = Math.random()*Stage.width t.dx = Math.round(Math.random()*Stage.width); t.onEnterFrame = mover; } function mover() { this._x += (this.dx-this._x)/3; if (Math.round(this._x) == this.dx) { this.dx = Math.round(Math.random()*Stage.width); } }
Per "t._x = Math.random()*Stage.width"codice:var totMC:Number = 20; for (var i = 0; i<totMC; i++) { var t = this.attachMovie("ball", "ball"+i , i+1); t._x = Math.random()*Stage.width t._y = 200 t.dx = Math.round(Math.random()*Stage.width); t.onEnterFrame = mover; } function mover() { this._x += (this.dx-this._x)/3; if (Math.round(this._x) == this.dx) { this.dx = Math.round(Math.random()*Stage.width); } }
Puoi mettere la distanza in numeri che ti serve, ho messo per tutta la lunghezza dell stage in questo caso.
Ma puoi benissimo mettere: t._x = Math.random()*mySize
dove "mySize" è una variabile a cui assegni il numero che vuoi e poi cambi tutti gli altri:
codice:var totMC:Number = 20; var mySize:Number = 200 for (var i = 0; i<totMC; i++) { var t = this.attachMovie("ball", "ball"+i , i+1); t._x = Math.random()*mySize t._y = 200 t.dx = Math.round(Math.random()*mySize ); t.onEnterFrame = mover; } function mover() { this._x += (this.dx-this._x)/3; if (Math.round(this._x) == this.dx) { this.dx = Math.round(Math.random()*mySize ); } }
Ciao, Salvo.