标签:
flex中我们有时并不想一开始就设置某个组件的宽度和高度,而想动态获取某个组件经填充后的width和height,但是会发现width和height均为0,这时我们可以注册一下两个事件之一来解决。
1 import mx.events.FlexEvent; 2 import mx.events.ResizeEvent; 3 //video为组件VideoPlayer的实例 4 video.addEventListener(FlexEvent.UPDATE_COMPLETE, onUpdateComplete); 5 video.addEventListener(ResizeEvent.RESIZE,onResize); 6 private function onUpdateComplete(e:FlexEvent):void 7 { 8 trace(video.width,video.height); 9 } 10 private function onResize(e:ResizeEvent):void 11 { 12 trace(video.width,video.height); 13 }
标签:
原文地址:http://www.cnblogs.com/frost-yen/p/4667678.html