Comunidad de diseño web y desarrollo en internet online

Borde dinamico para MC con AS. Se puede?

Citar            
MensajeEscrito el 16 May 2008 08:48 am
Hola
quiero darle un borde dinamicamente a un MC.(digamos al MC: "miMC"
Encontré esta funcion:


MovieClip.prototype.drawBorder = function(color,thickness){
var t = thickness;
with(this){
clear();
var b = getBounds(this);
var xs = 100/this._xscale;
var ys = 100/this._yscale;
lineStyle(t,color,100,true,'none','square','miter');
moveTo(b.xMin-t/2*xs,b.yMin-t/2*ys);
lineTo(b.xMin-t/2*xs,b.yMax+t/2*ys);
lineTo(b.xMax+t/2*xs,b.yMax+t/2*ys);
lineTo(b.xMax+t/2*xs,b.yMin-t/2*ys);
lineTo(b.xMin-t/2*xs,b.yMin-t/2*ys);
}
}


Luego la invocas con esta linea y debería funcionar:
miMC.drawBorder(0xffffff,4);

Pero no me funciona.

Alguna idea

Gracias

Por chefnelone

41 de clabLevel



Genero:Masculino  

safari
Citar            
MensajeEscrito el 16 May 2008 09:43 am
A mi me funciona perfecto. Recuerda que dado que usa getBounds, el borde siempre es un rectángulo no importa que forma tengan los gráficos de tu MC

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 16 May 2008 10:33 am
gracias por responder


No se si tiene que ver pero es un MC vacío que creo dinamicamente y luego cargo una foto en el :

//CREO EL MC Y CARGO LA FOTO
carga_XML();
createEmptyMovieClip("miMC", 1);
miMC._x = 0;
miMC._y = 0;
loadMovie("foto_grande/pagina_7.jpg", miMC);

//Y LUEGO EL CODIGO QUE LE DA EL BORDE
MovieClip.prototype.drawBorder = function(color,thickness){
var t = thickness;
with(this){
clear();
var b = getBounds(this);
var xs = 100/this._xscale;
var ys = 100/this._yscale;
lineStyle(t,color,100,true,'none','square','miter');
moveTo(b.xMin-t/2*xs,b.yMin-t/2*ys);
lineTo(b.xMin-t/2*xs,b.yMax+t/2*ys);
lineTo(b.xMax+t/2*xs,b.yMax+t/2*ys);
lineTo(b.xMax+t/2*xs,b.yMin-t/2*ys);
lineTo(b.xMin-t/2*xs,b.yMin-t/2*ys);
}
}


Luego la invocas con esta linea y debería funcionar:
miMC.drawBorder(0xffffff,4);

Por chefnelone

41 de clabLevel



Genero:Masculino  

safari
Citar            
MensajeEscrito el 16 May 2008 11:17 am
Nop, deberías invocarlo cuando termine de cargar, es decir, te falta la precarga

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox

 

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