without seeing your code its difficult to assess what the problem may be but these options may help troubleshoot/fix it:
check that group_createdMenu.getElementAt(imageIndex) is returning an image - add trace(bgImg); after var bgImg:Image = ... - if it outputs "null" then then its not an image type (so you cant get its height)
try getting the dimensions from the bitmapData object instead: bgImg.bitmapData.height
or post the code where you create the image - are you loading a bitmap at runtime or generating it with code?
i am coding a package which can create a dynamic menu at runtime with parameters.
so i am adding buttons' background images in a folder in project and giving them sources in an array in code.
creating a group and then creating an image and adding it to created group with .addElement.
after added first image for first button, i need to change second image's x and y to add to group. (because to add them with an order consecutively)
so i need to calculate exact width and height for x and y.
as you said, i tried something like this..
var u:URLRequest = new URLRequest(imgUrl);
public function done(e:Event):void
var img:Bitmap = Bitmap(l.content);
var h:int = img.height;
now i can get the height and so width too but i am not so sure is it the correct way to handle it or can i do it in a better way?
yep - thats the best way to do it.
for completeness, i suggest adding l.contentLoaderInfo.removeEventListener(Event.COMPLETE, done); to the done method - its always best practise to remove an event listener once you no longer need it
i'm glad to hear it. thank you so much. i wish you have a perfect weekend.