Pagina 1 di 5 1 2 3 ... ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 43

Discussione: cerco effetto acqua

  1. #1

    cerco effetto acqua

    chiedo scusa se questo non è il forum giusto..

    un cliente dice di aver visto sul web un effetto acqua che all'over del mouse sembra che veramente l'immagine è sommersa.

    ho cercato ovunque ma ancora non riesco a trovare niewnte su cui lavorare.
    sapreste darmi una dritta?

    grazz
    ang
    non si finisce mai di sperare...

  2. #2
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182

    Re: cerco effetto acqua

    Originariamente inviato da angelaca2
    chiedo scusa se questo non è il forum giusto..

    un cliente dice di aver visto sul web un effetto acqua che all'over del mouse sembra che veramente l'immagine è sommersa.

    ho cercato ovunque ma ancora non riesco a trovare niewnte su cui lavorare.
    sapreste darmi una dritta?

    grazz
    ang
    forse è il famoso effetto fatto con un'applet java, però ricordo che andr3a ne aveva fatto uno con flash, era una classe...

    ecco... ho ritrovato l'esempio --> http://www.3site.it/ESEMPI/WaterEffect.html

    e qui il riferimento della classe --> http://www.devpro.it/as2_id_82.html

  3. #3
    grazie.
    ma... hai visto che code??


    spero di riuscire a capirci qlcosa.

    vabbè.
    tocca a me, no?
    ang
    non si finisce mai di sperare...

  4. #4
    AIUTOOO!!!
    non riesc a capire nulla!!!
    come faccio ad adattarla alle mie esigenze?

    codice:
    /**
     * Class WaterEffect :: WaterEffect.as :: by Andrea Giammarchi
     * This class generates a kind of water effect, with mouse movements
     * or with automatic generation.
     * __________________________________________________
     * EXAMPLE WITH MOUSE MOVEMENT:
     * 		var waterEffect:Object = new WaterEffect( this, 'FISH' );
     * 		Mouse.addListener( waterEffect );
     *
     * EXAMPLE WITH AUTOMATIC GENERATION:
     * 		var waterEffect:Object = new WaterEffect( this, 'FISH' );
     * 		waterEffect.start( 30 );
     * --------------------------------------------------
     * @type	ActionScript 2.0 class file
     * @version	1.0 ( CPU centrino 1.6 tested )
     * @author	Andrea Giammarchi
     * @date	02/04/2005
     * @lastMod 02/04/2005 09:00
     * @site	http://www.devpro.it/
     */
    class WaterEffect {
    	
    	/** private variables */
    	private var CopyRight:String = 'Andrea Giammarchi [ www.3site.it ]';
    	
    	private var __diameter:Number;						// circles diameter
    	private var __levelSaver:Number;					// moveiLevel counter
    	private var __intervall:Number = new Number( 0 );	// internal interval
    	private var __math:Object;							// internal Math object ( faster! )
    	private var __path:Object;							// internal path remember
    	
    	/**
    	 * public constructor
    	 * 		new WaterEffect( pathReferer:Object, imageLinkage:String[, circleDiameter:Number] )
    	 * @param		Object		path where you want to create a water effect 
    	 *							( level or MovieClip )
    	 * @param		String		the name of the linkage of the image to waterEffect
    	 *							( linkage an image movieClip and export for ActionScript )
    	 * @param		Number		the diameter of generated circles [ DEFAULT: 8 ]
    	 *							( smallest => faster effect, try with 4 )
    	 */
    	function WaterEffect( __path:Object, __id:String, __diameter:Number ) {
    		this.__diameter = __diameter == undefined ? 8 : __diameter;
    		this.__math = Math;
    		this.__path = __path;
    		this.__createMask( __id );
    	}
    	
    	/**
    	 * public method
    	 *	Starts automatic water effect with a frequency to generate circles.
    	 *	NOTE: frequency should be in a range 20 <= frequency <= 50
    	 *
    	 * 		this.start( frequency:Number ):Void
    	 *
    	 * @param		Number		interval to generate random circles
    	 * @return		Void
    	 */
    	public function start( frequency:Number ):Void {
    		if( this.__intervall > 0 ) {
    			clearInterval( this.__intervall );
    		}
    		this.__intervall = setInterval( this, '__waterEffect', frequency, true );
    	}
    	
    	/**
    	 * public method
    	 *	Delete automatic water effect
    	 *
    	 * 		this.end():Void
    	 *
    	 * @return		Void
    	 */
    	public function end():Void {
    		clearInterval( this.__intervall );
    		this.__intervall = 0;
    	}
    
    	/**
    	 * public method
    	 *	Called from Mouse event if it's used as Mouse listener.
    	 * 	( for example: Mouse.addListener( waterObject ) )
    	 *	Generates water effect on every mouse movement
    	 *	NOTE: use this method with a framerate range < 60 or CPU will be hot!
    	 *
    	 * 		this.onMouseMove():Void
    	 *
    	 * @return		Void
    	 */
    	public function onMouseMove():Void {
    		if( this.__intervall > 0 ) {
    			clearInterval( this.__intervall );
    		}
    		this.__waterEffect( false );
    	}
    	
    	/**
    	 * private methods ( uncommented, sorry )
    	 * 		Used to generate all movieClips that will create a water effect
    	 */
    	private function __nextDepth():Number {
    		return this.__path['__water_effect__']['imask'].getNextHighestDepth();
    	}
    	
    	private function __waterEffect( randomMouse:Boolean ):Void {
    		var x:Number;
    		var y:Number;
    		if( randomMouse === false ) {
    			x = this.__path._xmouse;
    			y = this.__path._ymouse;
    		}
    		else {
    			x = this.__math.round( this.__math.random() * this.__path['__water_mask__']._width );
    			y = this.__math.round( this.__math.random() * this.__path['__water_mask__']._height );
    		}
    		var nd:Number = this.__nextDepth();
    		var mname:String = 'circle_' + String( nd );
    		this.__path['__water_effect__']['imask'].createEmptyMovieClip( mname, nd );
    		this.__path['__water_effect__']['imask'][mname]._x = x;
    		this.__path['__water_effect__']['imask'][mname]._y = y;
    		this.__path['__water_effect__']['imask'][mname].__diameter = this.__diameter;
    		this.__path['__water_effect__']['imask'][mname].__line = 
    		this.__math.ceil( this.__math.random() * this.__diameter );
    		this.__path['__water_effect__']['imask'][mname].__moveInterval = 
    		setInterval( this, '__move', 20, this.__path['__water_effect__']['imask'][mname] );
    	}
    	
    	private function __remove( who:MovieClip ):Void {
    		clearInterval( who.__moveInterval );
    		who.swapDepths( ( this.__levelSaver + 1 ) );
    		who.removeMovieClip();
    	}
    	
    	private function __move( who:MovieClip ):Void {
    		var __or:Number = who.__diameter;
    		var __ir:Number = who.__diameter - who.__line;
    		who.clear();
    		with( who ) {
    			beginFill( 0x000000, 100 );
    			moveTo( 0, __or );
    			curveTo(__or, __or, __or, 0);
    			curveTo(__or, -__or, 0, -__or);
    			curveTo(-__or, -__or, -__or, 0);
    			curveTo(-__or, __or, 0, __or);
    			moveTo(0, __ir);
    			curveTo(-__ir, __ir, -__ir, 0);
    			curveTo(-__ir, -__ir, 0, -__ir);
    			curveTo(__ir, -__ir, __ir, 0);
    			curveTo(__ir, __ir, 0, __ir);
    			endFill();
    		}
    		if( who.__line <= 0 ) {
    			this.__remove( who );
    		}
    		else {
    			who.__diameter += 0.5;
    			who.__line -= 0.05;
    		}
    	}
    	
    	private function __createMask( __id:String ):Void {
    		this.__levelSaver = this.__path.getNextHighestDepth();
    		this.__path.createEmptyMovieClip( '__water_effect__', this.__levelSaver );
    		this.__path['__water_effect__'].createEmptyMovieClip( 'image', this.__levelSaver++ );
    		this.__path['__water_effect__'].createEmptyMovieClip( 'imask', this.__levelSaver++ );
    		this.__path['__water_effect__'].createEmptyMovieClip( 'umask', this.__levelSaver++ );
    		this.__path.createEmptyMovieClip( '__water_mask__', this.__levelSaver++ );
    		this.__path['__water_effect__']['image'].attachMovie( __id, __id, this.__levelSaver++ );
    		this.__path['__water_effect__']['umask'].attachMovie( __id, __id, this.__levelSaver++ );
    		this.__path['__water_mask__'].attachMovie( __id, __id, this.__levelSaver++ );
    		var __rx:Number = this.__path['__water_effect__']['umask'][__id]._width;
    		var __ry:Number = this.__path['__water_effect__']['umask'][__id]._height;
    		this.__path['__water_effect__']['umask'][__id]._xscale = 102;
    		this.__path['__water_effect__']['umask'][__id]._yscale = 102;
    		__rx = ( this.__path['__water_effect__']['umask'][__id]._width - __rx ) / 2;
    		__ry = ( this.__path['__water_effect__']['umask'][__id]._height - __ry ) / 2;
    		this.__path['__water_effect__']['umask'][__id]._x -= __rx;
    		this.__path['__water_effect__']['umask'][__id]._y -= __ry;
    		this.__path['__water_effect__'].setMask( this.__path['__water_mask__'] );
    		this.__path['__water_effect__']['umask'].setMask( this.__path['__water_effect__']['imask'] );
    	}
    }
    ho capito che per richiamare la class, devo dirlo al momento dell'esportazione e non con l'include... ma poi?
    dove devo dirgli il nomeimmagine?
    non si finisce mai di sperare...

  5. #5
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    calma, non era necessario riportare tutto il codice nel thread

    allora, scarichi la classe il cui file dovrebbe chiamarsi come la classe stessa, con estensione .as, poi metti questo file nella stessa cartella del filmato e poi nel .fla scrivi il tuo cidce per caricare la classe e applicarla, come c'è scritto nell'esempio alle prime righe commentate della classe
    codice:
    //EXAMPLE WITH MOUSE MOVEMENT:
    var waterEffect:Object = new WaterEffect( this, 'FISH' );
    Mouse.addListener( waterEffect );
    //EXAMPLE WITH AUTOMATIC GENERATION:
    var waterEffect:Object = new WaterEffect( this, 'FISH' );
    waterEffect.start( 30 );
    a occhio credo che il parametro che indica il nome dell'immagine (del clip che la carica) è quello tra virgolette "FISH", lì devi mettere il nome del tuo clip...

    ps. il codice della classe non lo devi proprio toccare, è fatto apposta

  6. #6
    ok adesso provo...
    ma tutti quei public constructor ? Non bisogna compilarli?
    non si finisce mai di sperare...

  7. #7
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Originariamente inviato da angelaca2
    ok adesso provo...
    ma tutti quei public constructor ? Non bisogna compilarli?
    nella classe non bisogna toccare nulla, di solito le classi vengono create con routine preimpostate che fanno tutto quello che necessita per avere determinati effetti, in questo caso quello dell'acqua, l'unica cosa che si deve fare è quella di richiamare la classe nel nostro fla, dove ci necessita e passargli i parametri richiesti... ora io questa classe non l'ho mai provata, ma penso che andr3a abbia tenuto conto di tutto... conoscendo i suoi script


    [edit] oops ho preso un granchio grosso grosso, il secondo parametro non è il nome del movieclip presente sullo stage ma il nome di linkage del clip che contiene l'immagine, presente in libreria e concatenato per Actionscript

  8. #8
    non si finisce mai di sperare...

  9. #9
    oops ho preso un granchio grosso grosso, il secondo parametro non è il nome del movieclip presente sullo stage ma il nome di linkage del clip che contiene l'immagine, presente in libreria e concatenato per Actionscript
    infatti..... ho provato e ti "attacca" l'mc in liberia da solo in (0,0) senza dove scrivere l'istruzione attachMovie....

    ciao
    -Nextart.it Graphic Solutions

  10. #10
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Originariamente inviato da angelaca2
    seguimi...

    1- importi un'immagine sullo stage, una qualsiasi va bene
    2- clicchi il destro sull'immagine e dai "Converti in simbolo", e lo trasformi in movieclip
    3- cancelli il file dallo stage, apri la libreria e te lo ritrovi dentro, tasto destro e "Concatenamento"
    4- sputi la casella "Esporta per ActionScript", e gli dai il nome che vuoi, ad esempio FISH

    ora torni sulla timeline principale e scrivi il codice già affrontato, provi il filmato... dovrebbe andare

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.