Calculating Text Width In ActionScript And Flex

前端 未结 8 2137
离开以前
离开以前 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:12

    Following up my comment on quoo's answer, here's the code for same purpose, but just grabbing the width out of a TextField, using TextLineMetrics as well:

        public function mtxtWidth(container:TextField):int {
           var lineMetrics:TextLineMetrics = container.getLineMetrics(0);
           return lineMetrics.width;      
        }
    

提交回复
热议问题