我試圖讓圖像尺寸居中動態精靈對象,但我在高度和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