Comunidad de diseño web y desarrollo en internet online

attachMovie cambio color mc

Citar            
MensajeEscrito el 21 Nov 2007 11:31 am
Hola Foros,
duplico varias veces un mc por medio de attachMovie y cambio sus propiedades: posicion, escala, angulo... por medio de setProperty i con un valor aleatorio.

Algien puede decirme como puedo cambiar tambien el color de la linea (no tiene relleno) del mc.
Me bastaria poder jugar con 5 ó 6 colores.

Salut

Por loponti

51 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 21 Nov 2007 01:46 pm
Busca en la ayuda de flash el objeto Color.
Trae un ejemplo para cambiar el color de un mc

Por gabynufe

Claber

446 de clabLevel



 

México, D.F.

msie7
Citar            
MensajeEscrito el 21 Nov 2007 03:17 pm
hola,

si esto me vale para una instancia, però ¿cómo hacerlo para las instancias que se me van generando?

Por loponti

51 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 21 Nov 2007 03:33 pm
Pues cada vez que crees una instancia, tambien crea el objeto color asociado a la instancia que creas.

Por gabynufe

Claber

446 de clabLevel



 

México, D.F.

msie7
Citar            
MensajeEscrito el 21 Nov 2007 03:53 pm
Pero las instancias se generan automaticamente. Mando el codigo:

//"estrella" es clip vinculado

var valor:Number = 0;
function azar(min, max) {
return Math.round(Math.random()*(max-min)-min);
}
onEnterFrame = function () {
if (valor<50) {
valor++;
var nom:String = "estrella"+valor;
attachMovie("estrella", nom, valor);
setProperty(nom, _x, azar(10, 540));
setProperty(nom, _y, azar(10, 390));
setProperty(nom, _rotation, azar(-45, 45));
var nouAzar:Number = azar(60, 250);
setProperty(nom, _xscale, nouAzar);
setProperty(nom, _yscale, nouAzar);
setProperty(nom, _alpha, nouAzar);
//trace(color);
}
};

Por loponti

51 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 21 Nov 2007 04:22 pm

Código :

var valor:Number = 0;
function azar(min, max) {
   return Math.round(Math.random()*(max-min)-min);
}
onEnterFrame = function () {
   if (valor<50) {
      valor++;
      var nom:String = "estrella"+valor;
      objEstrella = attachMovie("estrella", nom, valor);
      objEstrella._x = azar(10, 540);
      objEstrella._y = azar(10, 390);
      objEstrella._rotation = azar(-45, 45);
      var nouAzar:Number = azar(60, 250);
      objEstrella._xscale = nouAzar;
      objEstrella._yscale = nouAzar;
      objEstrella._alpha = nouAzar;
      objEstrella.Col = new Color(objEstrella);
      objEstrella.Col.setRGB(0x993366);
      //trace(color);
   }
}

Por gabynufe

Claber

446 de clabLevel



 

México, D.F.

msie7
Citar            
MensajeEscrito el 21 Nov 2007 05:09 pm
perfecto muchas gracias

ahora he hecho un pequeño cambio

var valor:Number = 0;
function azar(min, max) {
return Math.round(Math.random()*(max-min)-min);
}

//aqui el cambio--------------------------------------------------------------------------
var canviColor:Number;
function color(){
var noucolor:Number = Math.round(Math.random()*2);
if(noucolor==0){
canviColor = 0xFF33CC;
}
if(noucolor==1){
canviColor = 0x33CCFF;
}
if(noucolor==2){
canviColor = 0xFFFF00;
}
}
//----------------------------------------------------------------------------------------------------------------
onEnterFrame = function () {
color(); //--------------------------------------------------------- cambio--------------
if (valor<50) {
valor++;
var nom:String = "estrella"+valor;
objEstrella = attachMovie("estrella", nom, valor);
objEstrella._x = azar(10, 540);
objEstrella._y = azar(10, 390);
objEstrella._rotation = azar(-45, 45);
var nouAzar:Number = azar(60, 250);
objEstrella._xscale = nouAzar;
objEstrella._yscale = nouAzar;
objEstrella._alpha = nouAzar;
objEstrella.Col = new Color(objEstrella);
objEstrella.Col.setRGB(canviColor); //--------sustituyo el color por la variable y duplica en varios colores----------------
//trace(canviColor);
}
}

Por loponti

51 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 21 Nov 2007 06:15 pm

Código :

var valor:Number = 0;
var arrColores = [0xFF33CC,0x33CCFF,0xFFFF00]; //aqui el cambio------------------------
function azar(min, max) {
   return Math.round(Math.random()*(max-min)-min);
}
onEnterFrame = function () {
   if (valor<50) {
      valor++;
      var nom:String = "estrella"+valor;
      objEstrella = attachMovie("estrella", nom, valor);
      objEstrella._x = azar(10, 540);
      objEstrella._y = azar(10, 390);
      objEstrella._rotation = azar(-45, 45);
      var nouAzar:Number = azar(60, 250);
      objEstrella._xscale = nouAzar;
      objEstrella._yscale = nouAzar;
      objEstrella._alpha = nouAzar;
      objEstrella.Col = new Color(objEstrella);
      objEstrella.Col.setRGB(arrColores[azar(0, 2)]); //aqui el cambio------------------------
   }
}

Por gabynufe

Claber

446 de clabLevel



 

México, D.F.

msie7
Citar            
MensajeEscrito el 21 Nov 2007 06:40 pm
muchisimo mejor, soy bastante novato y a veces las cosas son mas simples. asi queda perfecto

Por loponti

51 de clabLevel



Genero:Masculino  

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.