Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11

Discussione: Scacchiera

  1. #1

    Scacchiera

    Ciao a tutti...
    ho cercato nel forum quello che mi interessava ma non ho trovato nulla...

    Partendo da un immagine 800 x 600 pixel vorrei che questa venisse "virtualmente" suddivisa in n-colonne e n-righe in modo da formare una schacchiera.

    Tramite ActionScript é possibile che ad ogni quadratino della scacchiera venga applicato l'effetto Alpha, passando da 100 % a 0 %.

    Dovrei avere la mia immagine principale sullo sfondo e soprai quadratini che dal bianco (effetto Alpha 100 %) passano a fare vedere una porzione di immagine dello sfondo (Alpha 0%).

    Quindi i quadratini vanno a comporre l'immagine.

    Ho cercato tra i tutorial o articoli di flash.html.it, ma non ho trovato nulla:qualcuno mi da una mano!

    Grazie

  2. #2
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    ho scritto un codice velocemente... non saprei neanche se funziona perchè non posso testarlo

    codice:
    MovieClip.prototype.fade = function(end){
    	var out = (end > this._alpha) ? false : true;
    	if(out){
    		this.onEnterFrame = function(){
    			(this._alpha <= end) ? delete this.onEnterFrame : this._alpha--;
    		}
    	} else {
    		this.onEnterFrame = function(){
    			(this._alpha >= end) ? delete this.onEnterFrame : this._alpha++;
    		}
    	}
    }
    var drawRect = function(target, name, level, width, height):MovieClip{
    	target.createEmptyMovieClip(name, level);
    	with(target[name]){
    		moveTo(0,0);
    		lineStyle(0);
    		beginFill(0xFFFFFF);
    		lineTo(width, 0);
    		lineTo(width, height);
    		lineTo(0, height);
    		lineTo(0, 0);
    		endFill();
    	}
    	return target[name];
    };
    var mcLoad = new MovieClipLoader();
    var mcList = new Object();
    mcList.onLoadInit = function(target){
    	var w = Math.ceil(target._width/10);
    	var h = Math.ceil(target._height/10);
    	var gr = w*h;
    	var mc = target._parent.createEmptyMovieClip("contRects", target._parent.getNextHighestDepth());
    	mc._x = target._x;
    	mc._y = target._y;
    	for(var i = 0; i<gr; i++){
    		var m = drawRectangle(mc, "m"+i, i, w, h);
    		var p = (i > 0) ? mc["m"+Number(i-1)]: undefined;
    		m._x = (p._x >= target._width-w) ? 0 : p._x+w;
    		m._y = (m._x == 0) ? p._y+h : p._y;
    		m.onRollOver = function(){
    			this.fade(0);
    		}
    		m.onRollOut = function(){
    			this.fade(100);
    		}
    	}	
    }
    mcLoad.addListener(mcList);
    var urlImage = "image.jpg";
    var myClip = this.createEmptyMovieClip("myClip", 1);
    mcLoad.loadClip(urlImage, myClip);
    testalo su di un nuovo fla, basta solo che modifichi il parametro nella riga in rosso con il nome della tua immagine che vuoi caricare

    ps. funziona solo da MX 2004 in sù

  3. #3
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    ho verificato... c'erano degli errori nello script

    codice:
    MovieClip.prototype.fade = function(end) {
    	var out = (end>this._alpha) ? false : true;
    	if (out) {
    		this.onEnterFrame = function() {
    			(this._alpha<=end) ? delete this.onEnterFrame : this._alpha-=10;
    		};
    	} else {
    		this.onEnterFrame = function() {
    			(this._alpha>=end) ? delete this.onEnterFrame : this._alpha++;
    		};
    	}
    };
    var drawRect = function (target, name, level, width, height):MovieClip {
    	target.createEmptyMovieClip(name, level);
    	with (target[name]) {
    		moveTo(0, 0);
    		lineStyle(0, 0x000000, 0);
    		beginFill(0xFFFFFF);
    		lineTo(width, 0);
    		lineTo(width, height);
    		lineTo(0, height);
    		lineTo(0, 0);
    		endFill();
    	}
    	return target[name];
    };
    var mcLoad = new MovieClipLoader();
    var mcList = new Object();
    mcList.onLoadInit = function(target) {
    	var w = target._width/5;
    	var h = target._height/5;
    	var gr = 25;
    	trace(w);
    	trace(h);
    	trace(gr);
    	var mc = target._parent.createEmptyMovieClip("contRects", target._parent.getNextHighestDepth());
    	mc._x = target._x;
    	mc._y = target._y;
    	for (var i = 0; i<gr; i++) {
    		var m = drawRect(mc, "m"+i, i, w, h);
    		var p = (i>0) ? mc["m"+Number(i-1)] : undefined;
    		m._x = (p._x>=target._width-w) ? 0 : p._x+w;
    		m._y = (m._x == 0) ? p._y+h : p._y;
    		m.onRollOver = function() {
    			this.fade(0);
    		};
    		m.onRollOut = function() {
    			this.fade(100);
    		};
    	}
    };
    mcLoad.addListener(mcList);
    var urlImage = "image.jpg";
    var myClip = this.createEmptyMovieClip("myClip", 1);
    mcLoad.loadClip(urlImage, myClip);

  4. #4
    Oh...caspita!
    Ora provo... grazie


  5. #5
    Allora, diciamo che non vedo l'immagine, quando effettuo una preview?

    Ho creato un keyFrame al frame 1 e ho aggiunto lo script in questo keyFrame.

    ...come posso fare?


  6. #6
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Originariamente inviato da AlbertoPicca
    Allora, diciamo che non vedo l'immagine, quando effettuo una preview?

    Ho creato un keyFrame al frame 1 e ho aggiunto lo script in questo keyFrame.

    ...come posso fare?

    hai salvato il fla/swf nella stessa cartella in cui si trova l'immagine?

  7. #7
    si
    Non vengono segnalati errori...

  8. #8
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Originariamente inviato da AlbertoPicca
    si
    mi è capitata la stessa cosa ieri sul PC di un mio amico... provavamo a fare una cosa e non gli si caricavano le immagini in "Prova filmato", ho pensato che fosse un problema di Flash Player, infatti lui ha installato ancora l'8 mentre io a casa vado regolare e ho installato il 9

    solo che, non so il motivo, ma l'ultimo player non sta installando, almeno su Firefox

  9. #9
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    comunque per essere certi... possiamo fare una prova... modifica la riga in rosso nel codice qui sotto... se nel tuo filmato vedi i quadrati neri e quando ci passi sopra "svaniscono", allora il problema è lo stesso del PC del mio amico

    codice:
    MovieClip.prototype.fade = function(end) {
    	var out = (end>this._alpha) ? false : true;
    	if (out) {
    		this.onEnterFrame = function() {
    			(this._alpha<=end) ? delete this.onEnterFrame : this._alpha-=10;
    		};
    	} else {
    		this.onEnterFrame = function() {
    			(this._alpha>=end) ? delete this.onEnterFrame : this._alpha++;
    		};
    	}
    };
    var drawRect = function (target, name, level, width, height):MovieClip {
    	target.createEmptyMovieClip(name, level);
    	with (target[name]) {
    		moveTo(0, 0);
    		lineStyle(0, 0x000000, 0);
    		beginFill(0x000000);
    		lineTo(width, 0);
    		lineTo(width, height);
    		lineTo(0, height);
    		lineTo(0, 0);
    		endFill();
    	}
    	return target[name];
    };
    var mcLoad = new MovieClipLoader();
    var mcList = new Object();
    mcList.onLoadInit = function(target) {
    	var w = target._width/5;
    	var h = target._height/5;
    	var gr = 25;
    	trace(w);
    	trace(h);
    	trace(gr);
    	var mc = target._parent.createEmptyMovieClip("contRects", target._parent.getNextHighestDepth());
    	mc._x = target._x;
    	mc._y = target._y;
    	for (var i = 0; i<gr; i++) {
    		var m = drawRect(mc, "m"+i, i, w, h);
    		var p = (i>0) ? mc["m"+Number(i-1)] : undefined;
    		m._x = (p._x>=target._width-w) ? 0 : p._x+w;
    		m._y = (m._x == 0) ? p._y+h : p._y;
    		m.onRollOver = function() {
    			this.fade(0);
    		};
    		m.onRollOut = function() {
    			this.fade(100);
    		};
    	}
    };
    mcLoad.addListener(mcList);
    var urlImage = "image.jpg";
    var myClip = this.createEmptyMovieClip("myClip", 1);
    mcLoad.loadClip(urlImage, myClip);

  10. #10
    non é che saresti così gentile da inviarmi il file in fla...
    ho paura d'aver semplicemente sbagliato ad inserire il codice..

    Ciao e e grazie

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.