Visualizzazione dei risultati da 1 a 3 su 3

Discussione: cambiamento tinta

  1. #1

    cambiamento tinta

    ho un simbolo grafico a cui è applicata una tinta. qualcuno sa indicarmi una funzione che faccia cambiare la tinta (per non creare un movieclip che se no rallenta tutto)

  2. #2
    supponiamo che il tuo rettangolone si chiami come nome istanza "face"

    sul frame avrai

    codice:
    // blendRGB uses this Number prototype
    // converts a (hex) number to r,g, and b.
    Number.prototype.HEXtoRGB = function(){
    	return {rb:this >> 16, gb : (this >> 8) & 0xff, bb:this & 0xff};
    };
    Color.prototype.blendRGB = function(c1,c2,t){
    	if (arguments.length == 2){
    		t = c2;
    		c2 = this.getRGB();
    	}
    	if (t<-1) t=-1;
    	else if (t>1) t=1;
    	if (t<0) t=1+t;
    	c1 = c1.HEXtoRGB();
    	c2 = c2.HEXtoRGB();
    	var ct = (c1.rb+(c2.rb-c1.rb)*t) << 16 | (c1.gb+(c2.gb-c1.gb)*t) << 8 | (c1.bb+(c2.bb-c1.bb)*t);
    	this.setRGB(ct);
    	return ct;
    };
    
    
    // array of colors to cycle through
    colorSeletction = [0x006699, 0x663333, 0xCC6666, 0x669900];//questi sono i tuoi colori
    // value to determine tweening between
    // 2 colors.  0 is fully the first color
    // 1 is fully the second color
    colorTween = 0;
    // speed for how fast the tween will progress
    tweenSpeed = .05;
    // color object to control the face movieclip
    faceColor = new Color(face);
    
    // enterFrame to handle face's color blend
    face.onEnterFrame = function(){
    	// increase tween by speed
    	colorTween += tweenSpeed;
    	// check to see if the color tween has passed
    	// 1 or 0, if so, offset it to be back in 
    	// range and shift the elements in the array
    	// to allow for a blend with a new color
    	if (colorTween > 1){
    		colorTween--;
    		colorSeletction.push(colorSeletction.shift());
    	}else if (colorTween < 0){
    		colorTween++;
    		colorSeletction.unshift(colorSeletction.pop());
    	}
    	// use blend RGB to blend between the first two
    	// elements in the color array.  The previous if
    	// statements keeps them changing when the color
    	// tween reaches the end of a tween (1 or 0)
    	faceColor.blendRGB(colorSeletction[0], colorSeletction[1], colorTween);
    };

    -Nextart.it Graphic Solutions

  3. #3
    ok... funziona, ma se volessi la tinta al 40% invece che al 100%? altrimenti mi viene fuori una tinta piatta e spariscono le ombre del clip

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.