Results 1 to 4 of 4
-
December 19th, 2009, 08:10 AM #168Registered User
postscan't get height of image inside an mc
HI
I am trying to get at the properties (eg height) of an jpeg that I have loaded into a movieclip at runtime. Here's the code
Sadly whilst the image loads correctly if I tryCode:var introImageHolder:MovieClip = new MovieClip(); : : var j =new Loader(); j.load(new URLRequest(imgUrl)); introImageHolder.addChild(j) introImageHolder.x=245; introImageHolder.y=108;
trace (introImageHolder.height) I get 0, which is odd - I would have thought that the mc would take on the size of its contents, but I guess I am missing something! Also trace (introImageHolder.j.height) throws errors
How do I get at the height of the image please?
Thanks
E
-
December 19th, 2009, 08:14 PM #2
You have to wait until the image loads. Even if it takes just a split second, it still hasn't loaded at the time you run the code following the load method. You have to use an event listener.
Code:j.contentLoaderInfo.addEventListener(Event.COMPLETE, methodToAccessImageHeight);
-
December 20th, 2009, 05:03 AM #368Registered User
postsAh yes, that makes sense!
Should have tought of it - works fine now!
Thanks for the reply
E
-
December 21st, 2009, 08:09 AM #4
cant get height of image inside an mc
thank you very much for the help.If image1 is a MovieClip, how would the code change?Also, how does it change if the Mc does not exist in the library, but is created when compiling? ex bitmaps added as children to an empty mcthanks a lot

Reply With Quote

Bookmarks