UIComponent.addChild(Label)无法显示Label的解决方法

来源:互联网 发布:蓝牙对码软件 编辑:程序博客网 时间:2024/05/22 01:46

今天遇到一个彼为上火的问题,在MXML中定义了一个Panel,想在as中为它加画一个标签,代码如下,可是标签就是画不上去.

main.mxml:

  

DrawGrph.as

    把第10行的dg.drawAxis(uiAxis);中的uiAxis直接改成gPa,则标签可以显示出来,换成UIComponent类型的uiAxis就显示不了,整了半天也没整明白,后来终于解决了。原来必须为Label设置width,heigth属性,“make certain that the uicomponent you are drawing in has a width”,在12行后加上lab.width=100; lab.height=100;标签就显示出来了。