-
[F8] Center Dyanmic Images xml
I have a xml image gallery with different sized images, and instead of the images coming in from the top left corner I wanted to make them centered in the movieclip they load into. To do this I am just going to add -x and -y based on half of the image height/width. I have everything working I think but for some reason I cant get the movie to find the demensions of the dynamically loaded jpgs. Does anyone have a tutorial for this?
I tried a setInterval function to keep checking as the image loads but that didnt work.
Thanks
-
Developing For Dunkets
are you using MovieClipLoader? If you are not, you should. And you are, use onLoadInit and then check the dimensions.
-
Code:
var timer=setInterval(imageReload, 33);
var _loc2;
function imageReload() {
_loc2._x -= (_loc2._width)/2;
_loc2._y -= (_loc2._height)/2;
}
function getFirst(thePicPath, theLinkURL, theImageName, theImageDesc)
{
_root.main.big_mc.big_mc_image.textLoader._visible = false;
var _loc2 = _root.main.big_mc.big_mc_image.createEmptyMovieClip("container", "100");
trace(_loc2._width);
_loc2._x -= (_loc2._width)/2;
_loc2._y -= (_loc2._height)/2;
_root.main.big_mc.big_mc_image.my_mc = new MovieClipLoader();
preload = new Object();
_root.main.big_mc.big_mc_image.my_mc.addListener(preload);
preload.onLoadStart = function (targetMC)
{
_root.main.big_mc.big_mc_image.container._alpha = 0;
_root.main.big_mc.big_mc_image.textLoader._visible = true;
};
preload.onLoadProgress = function (targetMC, lBytes, tBytes)
{
percentage = int(lBytes / tBytes * 100);
_root.main.big_mc.big_mc_image.textLoader.loader.gotoAndStop(percentage);
_root.main.big_mc.big_mc_image.textLoader.loader.autoSize = true;
_root.main.big_mc.big_mc_image.textLoader.loader.text = Math.round(lBytes / tBytes * 100);
};
preload.onLoadComplete = function (targetMC)
{
changeColor();
_root.main.big_mc.big_mc_image.container._alpha = 100;
_root.main.big_mc.big_mc_image.textLoader._visible = false;
};
_root.main.big_mc.big_mc_image.my_mc.loadClip(thePicPath, "_root.main.big_mc.big_mc_image.container");
_root.main.big_mc.onRelease = function ()
{
getURL(theLinkURL, "_blank");
};
var _loc4 = 0;
var percentage = 0;
var _loc3 = 0;
if (theImageName != undefined)
{
_root.main.txtImageTitle.text = theImageName;
}
else
{
_root.main.txtImageTitle.text = "";
} // end else if
if (theImageDesc != undefined)
{
_root.main.InstanceName_0.text = theImageDesc;
}
else
{
_root.main.InstanceName_0.text = "";
} // end else if
Heres the code I tried a few different things with the moviecliploader but nothing worked so i took them out, any ideas?
-
Developing For Dunkets
Okay, you've got some seriously long paths and a lot of roots so I think I'll just write a small one and you can implement it into that code how you see fit...
PHP Code:
var hold:MovieClip = this.createEmptyMovieClip("holder", "100"); hold._visible = false; var mcList:Object = new Object(); var mcLoad:MovieClipLoader = new MovieClipLoader(); mcLoad.loadClip('myImage.jpg', hold); mcList.onLoadStart = function(){ hold._x = (Stage.width - hold._width)/2; hold._y = (Stage.height - hold._height)/2; } mcList.onLoadComplete = function(){ hold._visible = true; }
-
OK, I also want you to look at a few sample source files below.
060_photo_gallery for multi-albums.
or
034_photo_gallery for single album.
-
Thanks for the replys, I will go through the fla's and see if I cant get this thing working. mneil I see what you did and added that but for some reason my movie still isnt getting the demensions of the dynamic image. Maybe I just have downsyndrome but this isnt working ahhhhhhhhh.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|