View Full Version : Position Dynamic Image
alwaysdrifting
April 12th, 2004, 08:04 AM
I have a MC called image_mc. When I load an image from XML, I want the centre of the image to be over the MC.
Here is my code which isn't working. Currently, it positions the top left of the image at the MC regardless if the image is portrait or landscape.
pic = portfolioTag.childNodes[num].attributes.IMAGE;
// LOAD IN FIRST PICTURE IN XML FILE, first occurance of IMAGE NODE
image_mc.loadMovie(pic);
image_mc._x = image_mc._x-pic._width/2;
image_mc._y = image_mc._y-pic._height/2;
Thanks guys
kode
April 12th, 2004, 08:39 AM
You must wait until the image has been fully loaded into the movie clip in order to get its dimensions.
pic = portfolioTag.childNodes[num].attributes.IMAGE;
image_mc.createEmptyMovieClip("container_mc", 9876);
image_mc.container_mc.loadMovie(pic);
image_mc.createEmptyMovieClip("preloader_mc", 98765);
image_mc.preloader_mc.onEnterFrame = function() {
var container_mc = this._parent.container_mc;
var loaded = container_mc.getBytesLoaded();
var total = container_mc.getBytesTotal();
if (total>0 && loaded>=total) {
container_mc._x -= container_mc._width/2;
container_mc._y -= container_mc._height/2;
this.removeMovieClip();
}
};
alwaysdrifting
April 12th, 2004, 09:06 AM
Legend.! Thanks Kode
kode
April 12th, 2004, 09:10 AM
Anytime. ;)
alwaysdrifting
April 12th, 2004, 10:15 AM
Kode,
Any idea how to put a fade in with the code you gave me?
Thanks
flaxcreatures
April 12th, 2004, 10:39 AM
you can download my slideshow @ http://flaxcreatures.acehosts.net
just choose [MENU > WORK > DOWNLOADS]
source code is included
kode
April 12th, 2004, 10:41 AM
pic = portfolioTag.childNodes[num].attributes.IMAGE;
image_mc.createEmptyMovieClip("container_mc", 9876);
image_mc.container_mc._alpha = 0;
image_mc.container_mc.loadMovie(pic);
image_mc.createEmptyMovieClip("preloader_mc", 98765);
image_mc.preloader_mc.onEnterFrame = function() {
var container_mc = this._parent.container_mc;
var loaded = container_mc.getBytesLoaded();
var total = container_mc.getBytesTotal();
if (total>0 && loaded>=total) {
container_mc._x -= container_mc._width/2;
container_mc._y -= container_mc._height/2;
container_mc.onEnterFrame = function() {
this._alpha += (100-this._alpha)/4;
if (Math.abs(100-this._alpha)<1) {
delete this.onEnterFrame;
}
};
this.removeMovieClip();
}
};
There you go. ;)
alwaysdrifting
April 12th, 2004, 10:50 AM
Thanks a million. I'd buy you a pint if you lived closer!
kode
April 12th, 2004, 10:52 AM
No problem. :P
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.