我试图让图像尺寸居中动态精灵对象,但我在高度和widh属性0。有人可以帮助我获得图像尺寸吗?我试图通过使用图像控制的各种属性,但我得到的尺寸。请参见下面的代码和内联值评论flex 4图像尺寸
MXML代码:
<mx:Image id = "imgActive" visible="false" />
事件处理程序:
private function addImageHandler(e:MyCustomeEve){
imgActive.source = e.imageUrl;
imgActive.visible = true;
GAME_STATUS = "ITEM_SELECTED";
trace(imgActive.width,
imgActive.height, // 0
imgActive.contentHeight, // 0
imgActive.contentWidth, // NaN
imgActive.content.width, // error because imgActive.content is null
imgActive.content.height // error because imgActive.contentis null);
imgActive.cacheAsBitmap = true;
}
什么是你正在收听的事件? – Kodiak