Hi,
This isn't really too difficult, but there's a couple of things to bare in mind:
1) loadMovie executes last in a statement block, regardless of where you place it, so that what you've actually written is:
function releace(whichPic){
// note the switch of position
image._x = horizontalMiddle - (image._width / 2);
loadMovie("pictures/recentPaintings/picture" + whichPic + ".jpg", "image");
}
meaning that your script is evaluating prior to the image being loaded.
2) You need to wait until the image is loaded before calculating the position. Even if you're loading it off your machine, the actionscript will still execute faster.
The two obvious solutions are onLoad and onData for example:
image.onLoad = function(){
//position code here
}
However, this won't work because loadMovie removes everything in the target movie clip. On top of which, you can't place the onLoad after the loadMovie because, as I said further up the post loadMovie ALWAYS executes last in the statement block.
There's three possible solutions to this, 1) Use prototype (illegal in AS2.0 and complex) , 2) Use setInterval or 3) Use onEnetrFrame to keep checking if the jpg is loaded.
_______________________________________________
So...now I've said that here's what I'd suggest you use:
function releace(whichPic){
loadMovie("pictures/recentPaintings/picture" + whichPic + ".jpg", "image");
_root.onEnterFrame = function(){
if(image.getBytesLoaded()>=image.getBytesTotal){
image._x = (Stage.width/2)-(image._width/2);
delete this.onEnterFrame;
}
}
}
Note that this assumes that you don't currently have an onEnterFrame running on the _root if you do, either put it somewhere else (except on the image mc for the same reasons outlined above for the onLoad) or createEmptyMovieClip() and stick it on there.
If you want the thing centered in the browser window instead of the stage take a look at this tutorial:
http://www.actionscripts.co.uk/tutor...b04/stage.html
cheers.