Calculating Text Width In ActionScript And Flex

前端 未结 8 2143
离开以前
离开以前 2020-12-30 00:47

I\'m trying to calculate how WIDE to make my button, based on the text that it will contain, and when I try to google for how to calcuate something as simplistic as the WIDT

8条回答
  •  一向
    一向 (楼主)
    2020-12-30 01:09

    Here's how you do it in Spark:

    I've modified - simplified - his example a bit here:

    var textMetrics:TextLineMetrics = label.measureText( label.text );  
    var textWidth:int = textMetrics.width; 
    

提交回复
热议问题