Groups | Blog | Home
all groups > flash actionscript > april 2004 >

flash actionscript : Sizing dynamically-loaded JPEGS


burritobot
4/29/2004 9:44:37 PM
First, I create an empty movie clip, then I load a jpeg into it. Next, i would
like to size them, defining a width and height. However, this doesn't seem to
work. Whenever I try to size the new MC (ie. clip._width=20), I get "0" for
width + height in the debugger.

However, _xscale and _yscale params work fine. What gives? See attached code...

Thanks,
Joe

P.S. I also can't get the onMouseDown to work, but one thing at a time!

///DEFINE VARS
imageDirectory = "images/";
fileType = ".jpg";
numberOfImages = 10;
///CREATE THUMBNAILS
xPos = 0;
yPos = 0;
for (i=1; i<=numberOfImages; i++) {
thumbholder.createEmptyMovieClip("tn_"+i, i);
image = thumbholder["tn_"+i];
//LOAD JPEG
image.loadMovie(imageDirectory+i+fileType);
//SIZE IMAGE--THIS DOESN'T WORK!!!
image._width = 20;
image._height = 20;
//POSITION IMAGE
image._x = xPos;
image._y = yPos;
xPos = xPos+50;
if (xPos>=250) {
xPos = 0;
yPos = yPos+50;
}
//DEFINE BUTTON--THIS DOESN'T WORK!!!
image.onMouseDown = function() {
trace("onMouseDown called");
};
}
stop();
kglad
5/2/2004 5:46:30 AM
mark_yieh
5/2/2004 11:26:35 PM
how do you wait till the externally loaded images fully load? I've tried using
the onLoad event handler but it doesn't work. The code that I've used is as
follows.

_root.createEmptyMovieClip("myClip_mc", 0);
myClip_mc.loadMovie("myPicture.jpg");
myClip.onLoad = function(){
this._width = 550;
this._height = 400;
};

I don't understand why this doesn't work. Is there another way?
peterblaze
5/3/2004 3:14:08 AM
hi Mark,
it's better to watch e.g.: bytesLoaded>=bytesTotal or
loadedMovie._width!=undefined
search this newsgroup for 'preload' and 'jpeg', it's common question here
answered many times,
hth,
peter
[quoted text, click to view]

burritobot
5/3/2004 5:13:43 PM
peterblaze
5/3/2004 7:45:45 PM
Hi,
soory for wrong suggestion, I checked newsgroup site and search doesn't work
at all for me, Strange thing,
Use ordinary search:
http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=resize+image+actionscript
http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=resize+jpeg+actionscript
http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=resize+jpeg+flash
BTW,
Everytime I'm online I uploading messages from newsgroup, so my search was
done offline in my email client,
hth,
peter
[quoted text, click to view]
these forums searching for what you suggested.

AddThis Social Bookmark Button