Comunidad de diseño web y desarrollo en internet online

Flex 3: No funciona el textWidth y textHeight en Text.

Citar            
MensajeEscrito el 03 Nov 2008 01:45 pm
Hola , tengo un problema que la verdad no encuentro la solucion en ningun lado, alguien usa Text , supongo que si.
bueno la cuestion es que estoy usando Text para generar una ventanita informativa y en ese Text se cargan diferentes textos , por lo que presiso de la funcion textHeight para poder desplazar los objetos que están debajo del mismo dependiendo de la altura del texto. pero el textHeight y el textWidth tiran NaN... :? osea que no andan.

Código ActionScript :

//texto
var MsgTexto:Text= new Text();
MsgTexto.styleName="MsgBoxText";
MsgTexto.selectable=false;
MsgTexto.x=60;
MsgTexto.y=5;
MsgTexto.width=150;
MsgTexto.text=msg;
MsgBox.addChild(MsgTexto);
   
//msgbox height
trace("h: "+MsgTexto.textHeight) // h: NaN


bueno, si a alguien le paso lo mismo y supo como resolverlo le agradecería su ayuda... ^^

Por phoxer

Claber

827 de clabLevel

4 tutoriales

Genero:Masculino  

Ing en Sistemas

firefox
Citar            
MensajeEscrito el 03 Nov 2008 04:31 pm

phoxer escribió:

Hola , tengo un problema que la verdad no encuentro la solucion en ningun lado, alguien usa Text , supongo que si.

Yo usaría Textfield

Por Eliseo2

710 de clabLevel



 

firefox
Citar            
MensajeEscrito el 03 Nov 2008 04:38 pm

Eliseo2 escribió:

phoxer escribió:

Hola , tengo un problema que la verdad no encuentro la solucion en ningun lado, alguien usa Text , supongo que si.

Yo usaría Textfield


Gracias Eliseo2 pero el TextField tira error.. por eso usi Text que es el Textfield de Flex. (tengo entendido capas me equivoco)..

Código ActionScript :

TypeError: Error #1034: Error de conversión forzada: no se puede convertir flash.text::TextField@1877299 en mx.core.IUIComponent.
   at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChild()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\Container.as:3251]
   at mx.core::Container/addChildAt()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\Container.as:2200]
   at mx.core::Container/addChild()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\Container.as:2140]
   at xesh/setMsgBox()[D:\www\Xesh\src\xesh\MsgBox.as:36]
   at xesh/getConfig()[D:\www\Xesh\src\xesh\Xesh.as:58]
   at xesh/onComplete()[D:\www\Xesh\src\xesh\Xesh.as:31]
   at xesh/___xesh_Application1_applicationComplete()[D:\www\Xesh\src\xesh.mxml:3]
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at mx.core::UIComponent/dispatchEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:9051]
   at mx.managers::SystemManager/preloader_preloaderDoneHandler()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:2251]
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at mx.preloaders::Preloader/displayClassCompleteHandler()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\preloaders\Preloader.as:434]
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at XeshPreloader/onInitComplete()[D:\www\Xesh\src\XeshPreloader.as:41]
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at mx.preloaders::Preloader/dispatchAppEndEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\preloaders\Preloader.as:291]
   at mx.preloaders::Preloader/appCreationCompleteHandler()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\preloaders\Preloader.as:442]
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at mx.core::UIComponent/dispatchEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:9051]
   at mx.core::UIComponent/set initialized()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:1167]
   at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:698]
   at Function/http://adobe.com/AS3/2006/builtin::apply()
   at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8460]
   at mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8403]

Por phoxer

Claber

827 de clabLevel

4 tutoriales

Genero:Masculino  

Ing en Sistemas

firefox
Citar            
MensajeEscrito el 03 Nov 2008 06:57 pm
Eso es porque en flex el textfield no se cataloga como componente. Prueba con un textArea a ver si te va mejor.

Por Lunaty

Claber

118 de clabLevel



Genero:Femenino  

Flash Developer & RM Email Support for Google

firefox
Citar            
MensajeEscrito el 03 Nov 2008 08:09 pm

Lunaty escribió:

Eso es porque en flex el textfield no se cataloga como componente. Prueba con un textArea a ver si te va mejor.


Ya probé con el textArea también pero lo malo del TextArea es que no tiene la posibilidad del autoSize.. :cry:
y también tira NaN en el textHeight.. :|

voy aprobar de usar TextField incluido en un UIMovieclip. a ver que onda.
Es rarisimo que no funcione en el Text simple... :(

Gracias igualmente.

Por phoxer

Claber

827 de clabLevel

4 tutoriales

Genero:Masculino  

Ing en Sistemas

firefox
Citar            
MensajeEscrito el 03 Nov 2008 08:38 pm
Bueno ahora tengo otro problema jajajaj ..

Hice una clase para esto que extiende UIMovieClip para poder utilizar TextField en flex.. aquí la pongo..

Código ActionScript :

package phoxer.Sprites{
   import flash.text.TextField;
   import flash.text.TextFieldAutoSize;
   
   import mx.flash.UIMovieClip;

   public class TextBox extends UIMovieClip{
      private var texto:TextField;
      public function TextBox(cont:Object,x:int=0, y:int=0) {
              this.x=x;
              this.y=y;
              cont.addChild(this);
         super();
      }
      public function setTexto(txt:String,w:int=0):TextField{
         texto= new TextField();
            texto.width = w;
            texto.text=txt;
            texto.selectable=false;
            texto.multiline=true;
            texto.autoSize=TextFieldAutoSize.LEFT;
            this.addChild(texto);
            return texto;
      }
      public function getHeight():Number{
         return texto.textHeight;
      }
      public function getWidth():Number{
         return texto.textWidth;
      }
   }
}


La cosa que ahora anda bien, me devuelve el textHeight, pero no me esta respetando del Multiline :twisted:
ya que hace solo una sola linea de texto a lo largo y eso que le estoy poniendo texto.width y un valor...
ufff porque siempre existen estos problemitas estupidos jajaja.

Por phoxer

Claber

827 de clabLevel

4 tutoriales

Genero:Masculino  

Ing en Sistemas

firefox
Citar            
MensajeEscrito el 03 Nov 2008 09:05 pm
Prueba agregando texto.wordWrap = true;

Por Lunaty

Claber

118 de clabLevel



Genero:Femenino  

Flash Developer & RM Email Support for Google

firefox
Citar            
MensajeEscrito el 03 Nov 2008 09:08 pm

Lunaty escribió:

Prueba agregando texto.wordWrap = true;


Excelente Lunaty ahí funciona perfecto ^^
Muchas gracias.

Por phoxer

Claber

827 de clabLevel

4 tutoriales

Genero:Masculino  

Ing en Sistemas

firefox

 

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