who can help me with these 2 things. i downloaded the tip of the week at macromedia.com (about loading images dynamically into a movieclip) and i like to change several things. i like to trigger it from a button instead of a listbox. this i already implemented. you can download the fla file and images (82kb) at :
1) what i want to do is to load the image into the movieclip and center the image in such a way that the reference point of the movieclip is in the middle of the loaded image. right now the reference point is in the top-left position.
2) i like to put a preloader in front so that people know how much percentage is done.
1. get the width and heigth of your MC using _width and _heigth. Than get the middle of the MC by dividing these values by 2. Reposition the MC as you like.
2. Search through the forums: loads of people already asked this question...
how can i know the width and height if the different images are loaded dynamically into an empty movieclip that i create with the createEmptyMovieclip action?
i'm not so good with actionscript, so this is a tough one for me.
this is the code i put on the button :
on (release) {
gotoAndStop(10);
// create an empty movieclip
_root.createEmptyMovieClip("jpgmovieclip", 1001);
// place the movieclip coordinates
jpgmovieclip._x = 197.7;
jpgmovieclip._y = 27.4;
// load the images in the emptymovieclip from a specified directory
jpgmovieclip.loadMovie("images/picture03.jpg");
// how to center the image over the _y in the movieclip ??
_root.jpgmovieclip.onEnterFrame = function() {
if (this._width>0) {
trace("Loading Done.......... "+this._width+" : "+this._height);
delete this.onEnterFrame;
} else {
trace("Loading In Progress... "+this._width+" : "+this._height);
}
};
}
but how do i center it? do you center the image in the movieclip or do you have to reposition the movieclip on the stage?
when i preload the dynamically loaded image with this code, it works fine.
*********************************
* in frame 1 :
stop();
images._visible = false;
frame preloadit :
preload = _root.images.replacedbyimage.getBytesLoaded()+" bytes loaded of total ("+images.replacedbyimage.getBytesTotal()+")";
frame checkit :
if (_root.images.replacedbyimage.getBytesLoaded() == _root.images.replacedbyimage.getBytesTotal()) {
gotoAndPlay("doneloading");
} else {
// leave this empty and put the gotoAndPlay action in the next line behind the }
// don't ask me why, but only then the bytes are shown correct in the dynamic textfield???
}
gotoAndPlay("preloadit");
* in frame "doneloading" :
x = 200;
y = 200;
// now we get the image size
imgwidth = images._width;
imgheight = images._height;
// finally, set new _x and _y position to center the image to the centerpoint
// images._x = x-(imgwidth/2);
images._y = y-(imgheight/2);
// set the "images" movieclip visible
images._visible = true;
stop();
* the push button :
on (release) {
images.createEmptyMovieClip("replacedbyimage", 1);
images.replacedbyimage.loadMovie("image1.jpg");
gotoAndPlay("preloadit");
}
*********************************************
I want to make use of a preloader beam. not only the bytes.
but when i preload it like this, then it doesn't work and i don't have a clue why?
*********************************************
* in frame "preloadit" :
// size
total = _root.images.replacedbyimage.getBytesTotal();
loadedbytes = _root.images.replacedbyimage.getBytesLoaded();
// preloader beam, a movieclip with instance name "mcpreloading"
mcpreloading._xscale = Math.floor((loadedbytes/total)*100);
// percentage dynamic txt field
perc = mcpreloading._xscale+"%";
* in frame "checkit" :
if (total>loadedbytes) {
gotoAndPlay("preloadit");
} else {
gotoAndStop("doneloading");
}
you can check out the file at: //members.tripod.com./gelectronics0/twan/preloadit-image.zip
Sorry for the late reply. Just came back from a week in the French Alpes -> snowboarding! And it was great!
OK back to the real world...
When I make a preloader I don't put my code in frames but in a MC and use onEnterFrame.
Maybe this isn't much help but I'm just gonna run through my mails now and if you still need some help just let me know...