Skip to main content
Participating Frequently
January 27, 2008
Question

Image size..

  • January 27, 2008
  • 7 replies
  • 486 views
I was wonder if it's possible to grab the size of the image in pixel in actionscript..??
This topic has been closed for replies.

7 replies

kglad
Community Expert
Community Expert
January 29, 2008
you're welcome.
mkayyali
Inspiring
January 28, 2008
thanks kglad , u r true
kglad
Community Expert
Community Expert
January 28, 2008
you must use preloader code or the onLoadInit() method of a moviecliploader listener to ensure your image has completely loaded before trying to access its _width and _height.

using different frames for code is very poor coding for a number of reasons.
mkayyali
Inspiring
January 28, 2008
Dear Headful,
i think that u have a slow connection , so please try these options ,

One :
replace the image url by a image in ur hard disk ("images/test.jpg") or ("test.jpg")

Two :
instead frame 3 make it 20 if option one dosent work

headfulAuthor
Participating Frequently
January 27, 2008
it still gives me the value of 0..
mkayyali
Inspiring
January 27, 2008
create a new file , in frame # 1 put this action then F5 in frame # 3 :

// Creates a movie clip to hold the container.
this.createEmptyMovieClip("image_mc",9);
// Loads an image into image_mc.
image_mc.loadMovie(" http://www.helpexamples.com/flash/images/image1.jpg");
image_mc._x = 75;
image_mc._y = 60;

and in new layer click F6 on frame # 3 and put this action :

stop();
trace("W: " + image_mc._width + " H: " + image_mc._height);
headfulAuthor
Participating Frequently
January 27, 2008
errr i just get the value 0 if i try this on a loader component... should I ...put the image in a blinkmovie clip save the image size then, load it into the loader then rescale the loader according to the height and width?
Inspiring
January 27, 2008
Not without loading the image in, or using a server-side script.

--
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/


headfulAuthor
Participating Frequently
January 27, 2008
how do you do it with the image loaded?