Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    motionTween per colori con AS

    Ciao a tutti,
    sto cercando di fare del motionTween random per i colori con AS.
    ci sono quasi, ma ogni tanto mi sa' che succede qualchecosa di strano...in piu' secondo voi con questo script ho la possibilità di ottenere tutta la gamma di colori? o me ne taglio fuori qualcuno?

    ecco lo script al frame 1:

    colore = new Color (mc);
    if (!pippo) {
    r = random (255);
    g = random (255);
    b = random (255);
    pippo = true;
    }
    r2 = random (255);
    g2 = random (255);
    b2 = random (255);
    time = 20;
    mc.onEnterFrame = function () {
    nr = r - ((r - r2) / time);
    ng = g - ((g - g2) / time);
    nb = b - ((b - b2) / time);
    colorHexString = nr.toString (16) + ng.toString (16) + nb.toString (16);
    colorHex = parseInt (colorHexString, 16);
    colore.setRGB (colorHex);
    r = nr;
    g = ng;
    b = nb;
    };

    el al frame 100:

    r = r2;
    g = g2;
    b = b2;


    dove mc e' il mio bel rettangolone di sfondo.
    grazieeee!!!

  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);
    };
    Ciao
    Consulenza aziendale a 360° http://www.gruppodg.it http://www.gruppodg.it/3d
    Realizzazione siti internet, Siti Flash, Ricerca Location per bar negozi , esercizi commerciali, sviluppo pratiche e allestimento

  3. #3
    lo conosco questo script, ma non fa' al caso mio....
    lui cambia continuamente il colore a face, io invece faccio una pausa tra un cambiamento e l'altro e uso colori random...
    grazie

  4. #4
    ho provato a scriverlo io ex novo... ci sono quasi, ma ogni tanto mi sa' che succede qualchecosa di strano...in piu' secondo voi con questo script ho la possibilità di ottenere tutta la gamma di colori? o me ne taglio fuori qualcuno?

    ecco lo script al frame 1:

    colore = new Color (mc);
    if (!pippo) {
    r = random (255);
    g = random (255);
    b = random (255);
    pippo = true;
    }
    r2 = random (255);
    g2 = random (255);
    b2 = random (255);
    time = 20;
    mc.onEnterFrame = function () {
    nr = r - ((r - r2) / time);
    ng = g - ((g - g2) / time);
    nb = b - ((b - b2) / time);
    colorHexString = nr.toString (16) + ng.toString (16) + nb.toString (16);
    colorHex = parseInt (colorHexString, 16);
    colore.setRGB (colorHex);
    r = nr;
    g = ng;
    b = nb;
    };

    el al frame 100:

    r = r2;
    g = g2;
    b = b2;


    dove mc e' il mio bel rettangolone di sfondo.
    grazieeee!!!

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.