Estoy intentando utilizar un código de elchininet (gracias a el) que vi en este post para consegir unn listado de titulos de noticias.
Mi problema es que quiero un ancho fijo para un textfield multiline, con el alto que crece con el texto que contiene. Y no hay manera, he probado cosas con multiline, wordwrap y width, pero no lo consigo, siempre se queda el texto en una linea con el ancho que crece sin fin con el contenido.
El código es el siguiente:
Código :
this.onData = function () { import flash.filters.GlowFilter; //---Variables var boton:MovieClip; var fondo:MovieClip; var texto:TextField; var estilo:TextFormat = new TextFormat(); var ancho:Number; var alto:Number; var posY:Number = 0; with(estilo){ font = "Arial"; size = 12; color = 0x666666; border = true; } //---Ciclo de crear los botones y darle acciones //for(var i:Number = 1; i<=ligne; i++){ esto regoge el numero de lineas de la tabla de DB. Lo remplazo por un valor fijo para que lo podaís probar for(var i:Number = 1; i <= 3; i++){ boton = this.createEmptyMovieClip("boton" + i, this.getNextHighestDepth()); fondo = boton.createEmptyMovieClip("fondo", boton.getNextHighestDepth()); texto = boton.createTextField("texto", boton.getNextHighestDepth(), 0, 0, 0, 0); //---Crear el texto with(texto){ //text = this["tit_"+i]; lo que uso normalmente, que recoge los titulos de noticias a partir de un archivo php. Esto va, pero para que lo podaís probar, pongo un texto fijo text = "sfsadfads sdfgds fasf sdfg dfsg dfsg dfsg dfsg df" autoSize = true; setTextFormat(estilo); } //---Dibujar el fondo depende de las medidas del texto //ancho = texto._width; ancho = 100; alto = texto._height; with(fondo){ beginFill(0x000000, 10); moveTo(-2, -2); lineTo(ancho + 4, -2); lineTo(ancho + 4, alto + 4); lineTo(0, alto + 4); lineTo(0, 0); endFill(); } //---Situar los botones boton._y = posY; posY += boton._height + 20; //---Acción de los botones boton.onRollOver = function():Void{ var glow:GlowFilter = new GlowFilter(0x000000, 100, 3, 3, 1, 10); var filterArray:Array = new Array(); filterArray.push(glow); this.texto.filters = filterArray; } boton.onRollOut = function():Void{ this.texto.filters = []; } boton.onPress = function():Void{ this.texto.filters = []; this.texto.textColor = "0xFF0000"; } boton.onRelease = function():Void{ this.texto.filters = []; this.texto.textColor = "0x666666"; } boton.onReleaseOutside = function():Void{ this.texto.filters = []; this.texto.textColor = "0x666666"; } } } stop();
Agradezco la ayuda.
Un saludo.