ALSANTSU 0 Denunciar post Postado Março 13, 2009 Bom dia! Estou tentado inserir um Label via código: lb:Label = new Label(); Mas gera o erro "1180: Call to a possibly undefined method Label." Como proceder? Compartilhar este post Link para o post Compartilhar em outros sites
Thiago de Oliveira Cruz 21 Denunciar post Postado Março 13, 2009 Ai vai um exemplo do proprio flash -.- import flash.text.TextFieldAutoSize; import fl.controls.Label; var testString:String = "Lorem ipsum dolor sit amet."; var label1:Label = new Label(); var label2:Label = new Label(); var label3:Label = new Label(); label1.move(10,10); label2.move(10,50); label3.move(10,90); label1.width = stage.stageWidth - 20; label2.width = stage.stageWidth - 20; label3.width = stage.stageWidth - 20; label1.text = testString; label2.text = testString; label3.text = testString; label1.autoSize = TextFieldAutoSize.LEFT; label2.autoSize = TextFieldAutoSize.CENTER; label3.autoSize = TextFieldAutoSize.RIGHT; addChild(label1); addChild(label2); addChild(label3); Help do flash é uma ferramenta muito util... sugiro você ler ele um pouco sobre cada classe quando puder :) Ajuda muito... As vezes é confuso mesmo, mas da pra ter uma ideia mais ou menos de como funciona ;) E no seu código faltou só colocar var na frente do lb var lb:Label = new Label(); Abraços Compartilhar este post Link para o post Compartilhar em outros sites
ALSANTSU 0 Denunciar post Postado Março 13, 2009 Cara, eu esqueci de transcrever o "var" aqui, mas ele já estava no código. Eu olhei o contrutor do Label e tudo mais, mas continua a resultar em erro, pensei que fosse por eu não estar usando o import flash.text.TextFieldAutoSize; e import fl.controls.Label; mas quando os coloco aí aparece um novo erro: 1172: Definition fl.controls:Label could not be found. | Source: import fl.controls.Label; E o erro anterior muda para: 1046:Type was not found or was not a compile-time constant: Label. | Source: var lbY:Label = new Label(); 1180: Call ro a possibly undefined method Label. | Source: var lbY:Label = new Label(); Compartilhar este post Link para o post Compartilhar em outros sites
Thiago de Oliveira Cruz 21 Denunciar post Postado Março 13, 2009 err.......... Você colocou o component label no biblioteca? Se não colocou tem de colocar... Abraços Compartilhar este post Link para o post Compartilhar em outros sites
ALSANTSU 0 Denunciar post Postado Março 13, 2009 Esse tipo de componente tem que ser obrigatoriamente colocado na blibioteca, não é igual a um mc onde construo o seu conteúdo e o insiro diretamente via AS? Compartilhar este post Link para o post Compartilhar em outros sites
ALSANTSU 0 Denunciar post Postado Março 13, 2009 Cara obrigado pelo esforço, mas consegui resolver meu problema usando TextField. Obrigado! Compartilhar este post Link para o post Compartilhar em outros sites
Thiago de Oliveira Cruz 21 Denunciar post Postado Março 13, 2009 Label é um tipo de componente. Você deve colocar ele na biblioteca para que ele funcione corretamente. Não é o tipo de coisa que você possa colocar apenas por código na página. Abraços Compartilhar este post Link para o post Compartilhar em outros sites