Comunidad de diseño web y desarrollo en internet online

Formatando texto com clase externa

Citar            
MensajeEscrito el 28 Nov 2008 02:21 pm
Desarrollé este código para formatar un texto simple em AS3 y lo salvé como .as

Código ActionScript :

package
{
   import flash.display.Sprite;
   import flash.text.*;
   import flash.text.TextFormat;
   
   public class MostrandoTexto extends Sprite
   {
      private var txtCampo:TextField = new TextField();
      private var myText:String = "Jesus Cristo";
      
      public function MostrandoTexto()
      {
         showingText();
         formatingText();
      }
      
      public function showingText():void
      {
         addChild(txtCampo);
         txtCampo.text = myText;
      }
      
      public function formatingText():void
      {
         var fmt:TextFormat = new TextFormat();  
         fmt.align = "center";
         fmt.bold = true;
         fmt.font = "Verdana";
         fmt.size = 20;
         fmt.color = 0xFF0000;
         
         myText.setTextFormat( fmt );
      }
   }
}


Pero cuando lo ejecuto el fla me devuelve este error:

Call to a possibly undefined method setTextFormat through a reference with static type String.

Alguien sabe dónde está el problema?

Desde ya muchas gracias.

Por Ishkandar

Claber

303 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 28 Nov 2008 02:56 pm
Lo que tienes que formatear es el campo de texto, txtCampo, no el string que le asignas (myText)

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 28 Nov 2008 02:58 pm
Si Jorge, ya había visto el error y mandé la corrección. Pero vos llegaste antes que yo.

De todas formas muchas gracias.

Claudio

Por Ishkandar

Claber

303 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 28 Nov 2008 06:47 pm
Que raro! pensé que había dejado la corrección aqui. Bueno es esta:

Código ActionScript :

package
{
   import flash.display.Sprite;
   import flash.text.*;
   import flash.text.TextFormat;
   
   public class MostrandoTexto extends Sprite
   {
      private var txtCampo:TextField = new TextField();
      private var myText:String = "Jesus Cristo";
      
      public function MostrandoTexto()
      {
         showingText();
         formatingText();
      }
      
      public function showingText():void
      {
         addChild(txtCampo);
         txtCampo.text = myText;
         txtCampo.autoSize = TextFieldAutoSize.LEFT;
      }
      
      public function formatingText():void
      {
         var fmt:TextFormat = new TextFormat();  
         fmt.align = "center";
         fmt.bold = true;
         fmt.font = "Verdana";
         fmt.size = 20;
         fmt.color = 0xFF0000;
                  
         txtCampo.setTextFormat( fmt );
      }
   }
}

Por Ishkandar

Claber

303 de clabLevel



Genero:Masculino  

firefox

 

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