Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Centering Images In Kirupas Xml Photogallery



Hi,

Does anyone know who to makes all of the images loaded using kirupas xml photogallery tutorial be centred in the movie rather aligned to the empty mc?

Would be great to get some advice.

Thank You,
Paul.



KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 05-10-2006, 02:15 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

MC Disappears When Using Kirupas Photogallery
Hi everybody,
I have tried to use the tutorial "Create a photogallery" here on Kirupas.
http://www.kirupa.com/developer/mx/photogallery.htm

My problem is, I am putting the whole thing (actions and clip) on a MC, not in _root. When I publish it the rest of that mc disappears!

I have checked the paths and I am pretty sure they are OK. The first picture of the photogallery also loads in fine but the rest disappears. I have also tried making the photogallery in a different document in _root and it works fine. I have also checked that I haven't accidentally masked something.

Does anybody know anything about this???

MC Disappears When Using Kirupas Photogallery
Hi everybody,
I have tried to use the tutorial "Create a photogallery" here on Kirupas.
http://www.kirupa.com/developer/mx/photogallery.htm

My problem is, I am putting the whole thing (actions and clip) on a MC, not in _root. When I publish it the rest of that mc disappears!

I have checked the paths and I am pretty sure they are OK. The first picture of the photogallery also loads in fine but the rest disappears. I have also tried making the photogallery in a different document in _root and it works fine. I have also checked that I haven't accidentally masked something.

Does anybody know anything about this???

Kirupas XML Photogallery - Picture Description
I´m using Kirupas XML Photogallery tutorial to make a portfolio, and what i want to do is add an extra textfield which gets an imagedescription from the XML file. How would I go about that?

I don't understand how the "caption" tag winds up in the "desc_txt" textfield.



Here is the FLA code:

function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
description2[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("gallery/xml/yara.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
_root.content4.onEnterFrame = function() {
filesize = _root.content4.picture.getBytesTotal();
loaded = _root.content4.picture.getBytesLoaded();
_root.content4.preloader._visible = true;
if (loaded != filesize) {
_root.content4.preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
_root.content4.preloader._visible = false;
if (_root.content4.picture._alpha<100) {
_root.content4.picture._alpha += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
_root.content4.picture._alpha = 0;
_root.content4.picture.loadMovie(image[p], 1);
_root.content4.desc_txt.text = description[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
_root.content4.picture._alpha = 0;
_root.content4.picture.loadMovie(image[p], 1);
_root.content4.desc_txt.text = description[p];
_root.content4.desc2_txt.text = description2[p];
picture_num();
}
}

function firstImage() {
if (loaded == filesize) {
p = 0;//reset it back to 0
_root.content4.picture._alpha = 0;
_root.content4.picture.loadMovie(image[0], 1);
_root.content4.desc_txt.text = description[0];
picture_num();
}
}

function picture_num() {
current_pos = p+1;
_root.content4.pos_txt.text = current_pos+" / "+total;
}

The XML:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<images>

<pic>

<image>http://www.1234.no/1234567/gallery/bilder/yara_grasaat.jpg</image>

<caption>Yara Formates</caption>

</pic>

</images>


Any help appreciated!

Stein

Problem With Centering Photogallery
somebody help me

i had to center hole the gallery so it look nice and clear but i'm not the best in actionscript yes so please help med

heres the zip

Problem With Centering Photogallery
Problem with centering photogallery
i had spend several hours on this gallery for centering it but i dont now how to do it
i will be very happy if someone can help

here's the gallery:

photogallery

I'm beginner in actionscript

Help With Centering Pics Using The XML Photogallery Tutorial...
I used the XML photogallery tutorial, (http://www.kirupa.com/developer/mx20...otogallery.htm) and everything works great except... the position of the pics. Yes, I know you can move around the empty movie clip, to center them up, but there's a problem... Some of the pictures are longer up and down, and norrower side to side, and vice verse. So if I get the onces that are longer side to side, and not as tall centered up, then the pics that are taller than they wide are not centered up.

If anyone can help me out with this I'd be very greatful. If I did not explain myself well enough let me know and I'll try again.

Thanks!!

Scale Images In The XML Photogallery?
Sorry to keep posting so many topics here...but I have another question.

I did the how XML photogallery tutorial, got it to work, tested it, added my own pics, and now I am trying to customize it. The pictures I have on my comp ar 1600x1200 pixels (pretty big, huh?). I want to shrink all the pics so they fit in the gallery window. I resized the empty movieclip and the square behind it to 400x300 and my plan was to somehow scale all the photos down 25% (which would bring them all to exactly 400x300). Is there a way to do this with AS and not have to tediously edit each individual .jpg?

Thanks,
Mordaut

Photogallery Skipping Images
Hi and thanks for the various photogallery tutorials. I've completed the xml photogallery and the automatic slideshow version of it and I am having some problems.

First, I have not altered kirupa's code, so I don't think I need to post it for you all. The tutorial can be found here with the code. My test site can be found here.

Here is my situation: I have create multiple slideshows each with their own xml, swf, and jpgs and they are being accessed through a menu in a parent movie. Everything works fine at first, but if I click on either a new or the same slideshow the interval starts skipping. So, if the News slideshow has 5 images and the Bio slideshow has 7 images this is what happens:

News (autoloaded when main site loads):
1,2,3,4,5,1....
click on Bio (under the "information" menu):
1,2,3,4,5,6,7,1....
click back on News:
1,3,5,2,4,1... (begins skipping every other one)
click back on Bio:
1,4...(usually skips every 3 but at this point the interval skip is unpredictable)

You don't even have to click on different menu item for this skipping to occur. If you just click on the "News" button repeatedly and the same skipping happens. Each time you click on it the skip grows by 1.

So, it seems that I don't quite understand something (setInterval, parent/child movies, etc). It seems like the interval isn't getting cleared or something. Please help. Thanks

Help *XML Photogallery* Resizing The Images
Hi all, I've pieced together a photo gallery based on what I learned from this tutorial:

http://www.kirupa.com/developer/mx20...otogallery.htm

Can someone tell me how I dynamically resize the images that are loaded into Flash. I want to resize the window in which they are displayed, so a 400x400px photo will display at 150x150px, for example. If you want to help but don't feel like checking out the tutorial, please let me know and I will fish out whatever code I think this solution would concern.

~Jason

Preloading Images In XML Photogallery
I'm using this photogallery

http://www.kirupa.com/developer/mx20...otogallery.htm

Is there any way to display the first image and while it is displayed preload all the remaining images to avoid any delay while viewing the rest? I've tried some actionscript but I'm new to flash and the weird results i'm getting prove just as much.

Dump Images In Photogallery
great tutorial btw....im not much of a coder but i know u can take this or a photogallery like it and make it so that uc an just dump images into the folder and ur website will always update them into the flash.. prolly need another file for this or maybe just some kinda range done in flash... to me it would make sense for the area we put ["image1.jpg". "image2.jpg", "image3.jpg"] to instead put ["image1.jpg-image3.jpg"] or somethign like that.
this way u can make it so it just looks for the next image with the next number. this would make for much easier updateing...

anyone willing to give this a shot?

Scale Images In The XML Photogallery?
Sorry to keep posting so many topics here...but I have another question.

I did the how XML photogallery tutorial, got it to work, tested it, added my own pics, and now I am trying to customize it. The pictures I have on my comp ar 1600x1200 pixels (pretty big, huh?). I want to shrink all the pics so they fit in the gallery window. I resized the empty movieclip and the square behind it to 400x300 and my plan was to somehow scale all the photos down 25% (which would bring them all to exactly 400x300). Is there a way to do this with AS and not have to tediously edit each individual .jpg?

Thanks,
Mordaut

Resize Images Of Photogallery Xml Tutorial
Hi all,

I want to change the images of http://www.kirupa.com/developer/mx20...otogallery.htm from 300x200 to 700x380 but im unsure how, ive done a search and tried changing the FLA document size but no luck.
I thought it would just automaticlly change but it doesnt. in the source files it has two layers called "area" adn "movieclip" and i guess it has something to do with it but cant find it,

any help wud be gratefully taken ! thanks

Simultaneous Displaying Of Three Images In Photogallery
Hi guys,

Basing on the following script

http://www.kirupa.com/developer/mx20...otogallery.htm

I would like to have a photogallery which instead of one picture at a time will display three pictures. Please take a look at the attached image to get a better idea about what I need.



Could you help me? Thanks a lot!

Resize Images Of Photogallery Xml Tutorial
Hi all,

I want to change the images of http://www.kirupa.com/developer/mx20...otogallery.htm from 300x200 to 700x380 but im unsure how, ive done a search and tried changing the FLA document size but no luck.
I thought it would just automaticlly change but it doesnt. in the source files it has two layers called "area" adn "movieclip" and i guess it has something to do with it but cant find it,

any help wud be gratefully taken ! thanks

Images Loading In Photogallery Tutorial Problem :(
Well, I've followed this tutorial:

http://www.kirupa.com/developer/mx/photogallery.htm

And when I play it:

http://frampa.messiahsoft.net/photogallery.html

It does that. It doesn't load it into the rectangle that I created. o.O I followed everything correctly and I've been trying to fix it but can't.

In advance, thanks! ^_^

Code To Scale Vertical Images In PhotoGallery
Hello!

I'm working with this tutorial:

http://www.kirupa.com/developer/mx/photogallery.htm

I'm trying to figure out how I tell the clip to scale the dynamically loaded images to fit. For example, I have mostly horizontal images -- no problem, the clip is set up right. Now, If I come across a vertical image-- the image doesn't scale, but instead just slops out of the MC.

I'm just trying to figure out the actionscript to get it to dynamically scale, if thats even possible?

thanks so much!!!

-MD

XML And Flash Photogallery Only Loads Odd Numbered Images
Hi folks. I'm having some trouble with the XML and flash photogallery tutorial. I downloaded the full source files for Flash MX. I made no changes to the files, but when I preview the swf the photogallery only loads the odd numbered images.

I downloaded the trial version MX 2004 and loaded the same fla file. When I preview in 2004, everything works perfectly. Just in case I downloaded the wrong version, I've already redownloaded the MX only version of the photogallery source code.

I'm running on Flash MX on a Mac running OS 10.4. Does anyone have any suggestions?

Images Loading In Photogallery Tutorial Problem :(
Well, I've followed this tutorial:

http://www.kirupa.com/developer/mx/photogallery.htm

And when I play it:

http://frampa.messiahsoft.net/photogallery.html

It does that. It doesn't load it into the rectangle that I created. o.O I followed everything correctly and I've been trying to fix it but can't.

In advance, thanks! ^_^

Code To Scale Vertical Images In PhotoGallery
Hello!

I'm working with this tutorial:

http://www.kirupa.com/developer/mx/photogallery.htm

I'm trying to figure out how I tell the clip to scale the dynamically loaded images to fit. For example, I have mostly horizontal images -- no problem, the clip is set up right. Now, If I come across a vertical image-- the image doesn't scale, but instead just slops out of the MC.

I'm just trying to figure out the actionscript to get it to dynamically scale, if thats even possible?

thanks so much!!!

-MD

Centering Images
How would I go about centering images in the Reusable Preloader tutorial. Centering vertical is no problem since my images are all the same height...but the widths differ. And since the images aren't individual swfs' I don't know how I'd get them centered on my stage.

Help With Centering Images
I have read numerous threads, tried hundreds of suggestions from those threads, but still cant get my mind around how to get my images to center based on my AS (im sure that I am not referencing things correctly). The images fade fine but they still appear based on upperleft corner.
I have changed reg point, etc but still to no avail.

If someone could assist me i would be most greatful.

Scotty...I tried to use your resize example but that didnt help either.

Thanks in advance.

I have posted the AS below:
*************************
delay = 3000;
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
description2 = [];
link = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
description2[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
}
firstImage();
} else {
content = "Please refresh your browser. XML was not loaded correctly";
}
}
usedimages = [];
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images2.xml");
basey = 0;
basex = 0;
//************************************************** ***************************
function getrandom() {
image.splice(p, 1);
p = Math.floor(Math.random()*image.length);
}
function nextImage() {
if (image.length == 0) {
getURL("http://192.168.1.31/opiwebdev/vertmenu/main.shtml", "_self");
} else {
getrandom();
}

fadeOut(image[p]);
}
function firstImage() {
getrandom();
picture._alpha = 0;
fadeOut(image[p]);
}
function fadeOut(clip) {
picture.onEnterFrame = function() {

this._alpha -= 1;
if (this._alpha<1) {
preload(clip);
delete this.onEnterFrame;
}
};
}



function preload(clip) {
trace("preload");
picture.loadMovie(clip);
var temp = this.createEmptyMovieClip("temp", 9987);

temp.onEnterFrame = function() {

filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
if (filesize>4 && filesize == loaded) {
picture._x = (temp._x+temp._width/2)-temp._width;
picture._y = temp._y;
picture._alpha += 5;
}
if (picture._alpha>100) {
picture._alpha = 100;
desc_txt.htmlText = description[p];
desc_txt2.htmlText = description2[p];
slideshow();
delete this.onEnterFrame;
}
};
}
function slideshow() {
trace("slideshow");
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
fadeOut(p);
firstImage();
} else {
nextImage();
}
}
}

Centering Images Using XML
How does one center their images when using XML???

My images seem to come in TOP LEFT justified to the pivot of my
"holder image"

Help In Makeing Autoloop Scrollable Thumbnail Images In Photogallery
hi everybody,

i have a vertical photogallary in which thumbnail images part i need auto scrollable,in which image is loading through XML,

http://www.evascrivosalon.com/salon.html

this site will take time to load be patient...friends...
this is the which i used in it........

function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
thumbnails = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
thumbnails_fn(i);
}
firstImage();
} else {
content = "file not loaded!";
}
}


xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.UP) {
prevImage();
} else if (Key.getCode() == Key.DOWN) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 100;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 50;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
function thumbNailScroller() {
// thumbnail code!
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 25;
tscroller.onEnterFrame = function() {
if ((_root._xmouse>=thumbnail_mc._x) && (_root._xmouse<=thumbnail_mc._x+thumbnail_mc._widt h)) {
if ((_root._ymouse>=(hit_right._y-40)) && (thumbnail_mc.hitTest(hit_right))) {
thumbnail_mc._y -= scroll_speed;
} else if ((_root._ymouse<=(hit_left._y+40)) && (thumbnail_mc.hitTest(hit_left))) {
thumbnail_mc._y += scroll_speed;
}
} else {
delete tscroller.onEnterFrame;
}
};
}

function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {

target_mc._y =(target_mc._height+0)*k;
///target_mc._y =(target_mc._width-5)*k;
//trace(target_mc._width+"t"+target_mc._parent._rota tion)
target_mc.pictureValue = k;
target_mc._alpha = 50;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
};

target_mc.onRollOver = function() {
this._alpha = 100;
thumbNailScroller();
};
target_mc.onRollOut = function() {
this._alpha = 50;
thumbNailScroller();
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}

///////////////////////////////////////////


and this code i used in thumbnail_mc to loop but its not looping just it just go to last image and stop there....

onClipEvent (load)
{
//ycenter=0;
speed=1/100;
}
onClipEvent (enterFrame)
{
var distance=_root._ymouse-ycenter;
_y+=(distance*speed);
if (_y > 455) _y=-123
if (_y <-455 ) _y=123;
}


so i just want to where ihave to change in the script to make it Thumbnail images AUTO loopable/ SCROLLABLE

Centering Images In Slideshow
I am trying to create a slideshow using jpegs loaded into an empty movie clip and everything is great except...
I can't figure out how to make it so that each and every image that is loaded is centered no matter if it is a horizontal or vertical image. I realize that Flash wats to put them in the absolute upper lft corner of the movie clip, but I want it to center them depending on the dimensions of the image. Below is the A.S. that I am using to load the jpegs. Can anyone help me with an "if" statement that will do what I want?

function loadFrame(){
_level0.myMCL.loadClip("images/image" + curFrameNum + ".jpg", this.framesMC);

Centering Imported Images?
Quick question:

I'm creating a photo gallery. All of the JPEGs are on the server and I'm loading them into Movie Clips via the loadMovie command. Is there a way to get the images to center in the movie clip instead of aligning at the top left corner?

Thanks in advance for any help!

[F8] Help With Centering Multiple XML Images Please
I've read several threads on centering images in a movieclip. Basically I'm loading several images dynamically into a scrolling movieclip - portfolio style in a row. When you rollover the image the image enlarges.

My problem is that the images all load at their top left hand corner so that when you rollover and enlarge the image they also enlarge the image at the top left hand corner. I need them to load at the center so when they enlarge they also enlarge from the center. I have tried many different variations in trying to make this happen but I can't seem to get it to work. I've manage to get the entire movieclip to center according to the first loaded image - but obviously that's no good.

If anyone could help, I would sooooo appreciate it! I'm a bit of a newbie at AS - I hope I explained myself. Here's my code....


Code:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
thumbnails = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
thumbnails[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
thumbnails_fn(i);
}
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images1.xml");
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._xscale = target_mc._yscale = 75;
target_mc._x = hit_left._x+(target_mc._width+5)*k;
target_mc.pictureValue = k;

smoothImageLoad(thumbnails[k], target_mc);
target_mc.onRollOver = function() {
this.swapDepths(thumbnail_mc.getNextHighestDepth());
this.onEnterFrame = function() {
this._xscale = this._yscale += 5;
if (this._xscale>101) {
delete this.onEnterFrame;
}
}
};
target_mc.onRollOut = function() {
this.onEnterFrame = function() {
this._xscale = this._yscale -= 5;
if (this._xscale<76) {
delete this.onEnterFrame;
}
}
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}

[F8] Centering Images In A Movieclip
Hi,

I'm trying to center different size images in a movieclip named "picture". The images load fine but they are not centered. Flash's registration is very limited when it comes to setting this. All the images are different sizes. I may get one to load correctly but when another image loads of a different size the images is no longer centered. I need all images to load in the center of the clip no matter what the images size is. Here is the code that I'm using:

stop();

function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images-webbanner.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {

filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {

preloader.preload_bar._xscale = 100*loaded/filesize;

} else {

preloader._visible = false;
if (picture._alpha<100) {

picture._alpha += 10;

}

}

};


function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}

Centering Loaded Images
I've been making a modified version of the Dynamic JPG image loader thing that comes with Flash MX I've got it loading captions in from a loaded textfile and then I'm pulling the captions I need from an array.

Basically I'm having a great time until.... I started pulling in pictures of that were both Landscape and Portrait in format. The problem is that they always load in the top Left corner of the clip I'm loading them into. I understand this is because of the "zero" point and the fact that the data loads into positive x and y co-ords. Is there a way to make portrait and landscpe pics load so that their center point are in the same spot regardless of the image size?

Did I explain that correctly....?
Thanks in advance,
Rupert

Centering Dynamic Images
I have a xml gallery everything on it works except a few of my picture are kinda all over the place is there anyway for my to center my images? any information would be greatly appreciated.

here is the actions im using and my MC that loads my images is on the stage should I use the createMC action to achieve this?


ActionScript Code:
cliparray = [];
columns = 4;
spacex =88
spacey=67
function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        image = [];
        description = [];
        thumbnails = [];
        total = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
            description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
            thumbnails[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
        }
        sload()
        firstImage();
    } else {
        content = "file not loaded!";
    }
}
function drawSquare(clip, depth, colour, x, y, w, h) {
    var mc = clip.createEmptyMovieClip("clip"+depth, depth);
    mc._x = x;
    mc._y = y;
    mc.lineStyle(0, 0x3F0100, 100);
    mc.beginFill(colour);
    mc.lineTo(w, 0);
    mc.lineTo(w, h);
    mc.lineTo(0, h);
    mc.endFill();
    mc._alpha = 80;
    return mc;
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
    if (Key.getCode() == Key.LEFT) {
        prevImage();
    } else if (Key.getCode() == Key.RIGHT) {
        nextImage();
    }
};
Key.addListener(listen);
previous_btn.onRelease = function() {
    prevImage();
};
next_btn.onRelease = function() {
    nextImage();
};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
    filesize = picture.getBytesTotal();
    loaded = picture.getBytesLoaded();
    preloader._visible = true;
    if (loaded != filesize) {
        preloader.preload_bar._xscale = 100*loaded/filesize;
    } else {
        preloader._visible = false;
        if (picture._alpha<100) {
            picture._alpha += 10;
        }
    }
};
function nextImage() {
    if (p<(total-1)) {
        p++;
        if (loaded == filesize) {
            picture._alpha = 0;
            picture.loadMovie(image[p], 1);
            desc_txt.text = description[p];
            picture_num();
        }
    }
}
function prevImage() {
    if (p>0) {
        p--;
        picture._alpha = 0;
        picture.loadMovie(image[p], 1);
        desc_txt.text = description[p];
        picture_num();
    }
}
function firstImage() {
    if (loaded == filesize) {
        picture._alpha = 0;
        picture.loadMovie(image[0], 1);
        desc_txt.text = description[0];
        picture_num();
    }
}
function picture_num() {
    current_pos = p+1;
    pos_txt.text = current_pos+" / "+total;
}
var ij=0
function sload() {
    for (var i = 0; i<image.length; i++) {
        var clip = drawSquare(this, i, 0, 0, 0, 64, 44);
        clip._x =536+ (i%columns)*spacex;
        clip._y =102+ Math.floor(i/columns)*spacey;
        var clap =clip.createEmptyMovieClip("tt",1)
        clap._x = 2
        clap._y = 2
        cliparray.push(clap);
        clip.pictureValue =i;
        clip.onRelease = function() {
            p = this.pictureValue-1;
            nextImage();
        };
        clip.onRollOver = function() {
            this._alpha = 70;
           
        };
        clip.onRollOut = function() {
            this._alpha = 100;
        };
    }
    startload()
   
}
this.createEmptyMovieClip("checker",1000)
function checkload() {
    checker.onEnterFrame = function() {
       
        if (cliparray[ij]._width) {
           
            delete this.onEnterFrame;
            if (ij<cliparray.length-1) {
                ij++;
                startload();
            }
        }
    };
}
function startload() {
    cliparray[ij].loadMovie(thumbnails[ij]);
    checkload();
}

Centering Images In A Movieclip
Hi,

I'm trying to center different size images in a movieclip named "picture". The images load fine but they are not centered. Flash's registration is very limited when it comes to setting this. All the images are different sizes. I may get one to load correctly but when another image loads of a different size the images is no longer centered. I need all images to load in the center of the clip no matter what the images size is. Here is the code that I'm using:

stop();

function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images-webbanner.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {

filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {

preloader.preload_bar._xscale = 100*loaded/filesize;

} else {

preloader._visible = false;
if (picture._alpha<100) {

picture._alpha += 10;

}

}

};


function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}

Centering Images In A Container
I’ve been searching to find an answer for this little problem without luck. I’m loading external jpgs into an empty movie clip. The clip is large enough to accommodate vertical as well as horizontal images. What do I need to do to have the images load in the center of the clip instead of the top left corner? Thanks for your help.
Mariusz






























Edited: 01/21/2007 at 07:51:16 AM by M_L_M

Centering Imported Images
Hello,

I am having difficulty centering jpgs that i have imported into the library with the stage. when i paste to center, the image is pasted centered to the bottom right of the canvas. when i test the video, it looks incorrect, when i post the video to website, it looks correct.

ideally, my canvas center would be my paste to center as well and would look correct in testing, and after posting it to the website.

my canvas size is 560x420.

any ideas on how to accomplish this?

Thanks!





























Edited: 11/16/2007 at 02:13:02 PM by photofl0w

Resizing And Centering The Images
hi,
can someone tell me simple basic code for resizing and centering the images on the stage while loading from xml.

i searched in the forum but many of them are using movie clip loader. so they have used getBytesLoaded or getBytesTotal for this.

And i have developed my gallery using loadMovie.

so can someone help me regarding this??

waiting for ur help

thanks a loooooooooooot:

Centering Xml Gallery Images
hello ;
ive just butchered myself a gallery together which loads different xml documents (with image references in them) into an empty movie clip on the main stage-
however- the images are all different sizes, and I cant seem to modify the script so that they will center correctly- i know I need to preload them in order to get the correct size for each image and then reload and display so that the x and y coordinates are correct-
im using this script from kirupa's xml gallery tutorial- each different section of the gallery has this script attatched to the button that displays it-
but im really stuck as to where to add a loop to ***** the images.- my brain hurts
I would attach the movie im using to show the whole thing but the files too large--

on (release) {
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("music.xml");
// ///////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
// ///////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 2;

}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[0];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[0];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
}

Centering Images In A MovieClip
Hi,

I got this far with my images display. I found code and it was able to work, but I'm not savvy enough with the code to unload images.

I have 'searched' thru kirupa to see if someone had something similar. Found other 'centering images' type .fla's, but can't connect them to mine.

I was hoping someone on here could look at it, and hopefully find that small missing link I need.

I don't want to change the navigation or the way I have it set up -- I need it scripted frame-by-frame as it is. I was hoping someone knows how to get the images to 'unload' as you press each button.

Thanks.

Centering Images In Movie
I just followed the tutorial on this website to make a photo gallery wit hthe sliding thumbnail. After completing the tutorial, I modified the layout myself to experiment. I made the whole entire thing bigger. I was wondering if anyone knew how to center the images within the movie. Thanks for any help!

Centering External Images In MC
Hello:

I have thumbnails of various dimensions that I am trying to center upon loading into a mc. I have tried other suggestions from posts on this forum, like create a container mc and load the jpg into that, then place container within the main mc, and

mc._x =- mc._width/2; //move clip to left by half its width
mc._y =- mc._height/2; //move clip up by half its height

by the way, I cannot find the =- operator in the AS dictionary, unless they mean
mc._x = -1 * mc._width/2;

None of these work properly. - I keep getting the JPG in the upper left-hand corner.

I have a blank catalogmenu_mc to which I am attaching a grid of menuitem_mc. These menuitem mc's are NOT blank - they are 100 x 100. They contain dynamic text fields, a text button, and the thumb_mc, which holds the external image. I set the coordinates for the blank thumb_mc at (50,50) - [center] within the menuitem_mc.

When I try to center the JPG after loading into the thumb_mc, it goes back to the upper-left hand corner. I think maybe it's because the clip that holds the thumb_mc is not blank and uses 100 x 100 for the dimensions and not 100 x 75 or 55 x 75, the size of my TN's.

It is frustrating that an external SWF or JPG can only load in the upper left-hand corner.
Any help or workarounds? Thanks.

Help With Centering Multiple XML Images Please
I've read several threads on centering images in a movieclip. Basically I'm loading several images dynamically into a scrolling movieclip - portfolio style in a row. When you rollover the image the image enlarges.

My problem is that the images all load at their top left hand corner so that when you rollover and enlarge the image they also enlarge the image at the top left hand corner. I need them to load at the center so when they enlarge they also enlarge from the center. I have tried many different variations in trying to make this happen but I can't seem to get it to work. I've manage to get the entire movieclip to center according to the first loaded image - but obviously that's no good.

If anyone could help, I would sooooo appreciate it! I'm a bit of a newbie at AS - I hope I explained myself. Here's my code....


Code:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
thumbnails = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
thumbnails[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
thumbnails_fn(i);
}
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images1.xml");
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._xscale = target_mc._yscale = 75;
target_mc._x = hit_left._x+(target_mc._width+5)*k;
target_mc.pictureValue = k;

smoothImageLoad(thumbnails[k], target_mc);
target_mc.onRollOver = function() {
this.swapDepths(thumbnail_mc.getNextHighestDepth() );
this.onEnterFrame = function() {
this._xscale = this._yscale += 5;
if (this._xscale>101) {
delete this.onEnterFrame;
}
}
};
target_mc.onRollOut = function() {
this.onEnterFrame = function() {
this._xscale = this._yscale -= 5;
if (this._xscale<76) {
delete this.onEnterFrame;
}
}
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}

Centering Images In A Movieclip
Hi,

I'm trying to center different size images in a movieclip named "picture". The images load fine but they are not centered. Flash's registration is very limited when it comes to setting this. All the images are different sizes. I may get one to load correctly but when another image loads of a different size the images is no longer centered. I need all images to load in the center of the clip no matter what the images size is. Here is the code that I'm using:

stop();

function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images-webbanner.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {

filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {

preloader.preload_bar._xscale = 100*loaded/filesize;

} else {

preloader._visible = false;
if (picture._alpha<100) {

picture._alpha += 10;

}

}

};


function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}

AS 2 Centering Images In An Empty Mc
g'day sirs,

i have the following code and i'm loading portrait and landscape images into an empty mc via xml but the images load to x = 0 and y = 0. is there any way to load these images "centered" into that mc ?


PHP Code:



delay = 3000;
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
}
firstImage();
} else {
content = "XML OOPS !";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("flyer.xml");
p = 0;
function preload(clip) {
picture.loadMovie(clip);
var temp = this.createEmptyMovieClip("temp", 9987);
temp.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
if (filesize>4 && filesize == loaded) {
picture._alpha += 1;
if (picture._alpha>100) {
picture._alpha = 100;
slideshow();
delete this.onEnterFrame;
}
}
};
}
function nextImage() {
if (p == (total-1)) {
p = -1;
}
if (p<(total-1)) {
p++;
fadeOut(image[p]);
}
}
function firstImage() {
picture._alpha = 0;
fadeOut(image[0]);
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
nextImage();
}
}
function fadeOut(clip) {
picture.onEnterFrame = function() {
this._alpha -= 1;
if (this._alpha<1) {
preload(clip);
delete this.onEnterFrame;
}
};





sorry if this sounds weird but i don't know how to explain it more clearly

thank you for reading

Centering External Images + Site
Hello fellow programmers.

I've developed a flash site that loads images externally and centers them on the stage. The method of centering an external image is trickey, in order to center an image on the stage you need to know the width of the image you are loading... as far as i know the only way to find the width of a movie clip is to check it after it loads completely.

In this site, I have a function that loads the external image, a function that checks to see if the image is loaded completely and then a function that waits an additional 500ms ... and finally a function that finds the width of the clip, centers it on stage, and fades it from 0 to 100.

The problem is that if you play around with the site long enough you will notice glitches... the image is not always centered before it fades in... I have no idea why this happens... has anyone had good experience with centering external images? what would be a better method of doing this?

check out the site: http://www.museniorartshow.com/xml/pages/index.html

thanks,
-Pez

Centering Images In Flash CS3 Slideshow
Hi,
I am new to AS and Flash. So, any help here would be highly appreciated.

I am trying to get an XML based Flash CS3 slideshow to work. The slideshow opens each image up like an envelope before displaying it.

I have got most of it going but have one key problem:

My stage is 320 x 240 I have a variety of images some smaller that 320 in width all being processed from the XML file. The ones less that 320 in width get drawn on the left hand side of the stage NOT the centre.

I would like all images to be drawn in the centre not on the left.

Here is the code:

Code:
private function getMask():MovieClip
{
mask_mc=new MovieClip();
mask_mc.graphics.beginFill(0xFF3366,1);
mask_mc.graphics.drawRect(-.5,-.5,1,1);
mask_mc.x=stage.stageWidth/2;
mask_mc.y=stage.stageHeight/2;


addChild(mask_mc);
masks_array.push(mask_mc);
return mask_mc;
}

private function openMask():void
{
mask_mc.addEventListener(Event.ENTER_FRAME,openX);
}

private function openX(evt:Event):void
{
var arrX:Number=clips_array[id].width/2;
var dx:Number=arrX-evt.target.width;
var ax:Number=dx*.3;

evt.target.width+=ax;
if(Math.abs(dx)<=.2)
{
mask_mc.removeEventListener(Event.ENTER_FRAME,openX);
evt.target.width=arrX;
mask_mc.addEventListener(Event.ENTER_FRAME,openY);
}
}

private function openY(evt:Event):void
{
var arrY:Number=clips_array[id].height/2;
var dy:Number=arrY-evt.target.height;
var ay:Number=dy*.2;
evt.target.height+=ay;
if(Math.abs(dy)<=.3)
{
mask_mc.removeEventListener(Event.ENTER_FRAME,openY);
evt.target.height=arrY;
mask_mc.addEventListener(Event.ENTER_FRAME,reOpenX);
}
}

private function reOpenX(evt:Event):void
{
/* var arrX:Number=clips_array[id].width; */
var arrX:Number=clips_array[id].width;
var dx:Number=arrX-evt.target.width;
var ax:Number=dx*.3;
evt.target.width+=ax;
if(Math.abs(dx)<=.2)
{
mask_mc.removeEventListener(Event.ENTER_FRAME,reOpenX);
evt.target.width=arrX;
mask_mc.addEventListener(Event.ENTER_FRAME,reOpenY);
}
}

private function reOpenY(evt:Event):void
{
var arrY:Number=clips_array[id].height;
var dy:Number=arrY-evt.target.height;
var ay:Number=dy*.3;
evt.target.height+=ay;
if(Math.abs(dy)<=.2)
{
mask_mc.removeEventListener(Event.ENTER_FRAME,reOpenY);
evt.target.height=arrY;
initTimer();
}
}
Can someone please tell me how I can get the image to be drawn in the centre and not on the left?????

Thx!

Centering Loaded Images In Movieclip
I seem to be having trouble getting these images, that are externally loaded, to load in the center of the movieclip. I know it's something simple but i've failed to get it to work so far. Help would be greatly appreciated.


this is what i have in there at the moment and it obviously just loads it into the clip but doesn't center. So if you could help me write the script off of this i would be a very happy guy. Thanks.


loadMovie("galleries/home/"+_root.poza+".jpg", "pic1");

Dynamically Centering Images In MC As They Load
I am dynamically loading images into a movie clip (MC), but as they load the images load from the MCs registration point which is fine if you want the image to load in the top left side of the MC.

What I would like to be able to dynamically change the registration point of the image to the centre when it is loaded. I would expect you would have to change the registration point of the MC (as the image takes on the properties of the MC).

Basically I would like the images to load from the left, right, top middle, botton middle etc... so that per project I can dynamically change the above.

Here is an example of what I am trying to achieve. I have everything else down pat except the images positioning....

http://www.evb.com

In the above case the images are loaded and their centre point becomes the centre of the image and the frame then expands or contracts depending on the image width and height.

Even if I could be able to make the centre point in the middle would do me...

Can anyone help??????

Centering Grid Of Images On Click
So, I have a grid of images (say 3x3 for now) and I want to be able to click on one and have the entire group slide so that the clicked image is centered.

http://www.podlob.com/ has something similar on #43 with the controls in the bottom right, but no source available.

I've got the hang of having buttons trigger sliding, but all the tutorials I've found have the buttons and the images separate and I can't figure out how to slide them all together. (Also, my images would be separate and not one vast image that gets slid around - this poses the issue of coordinating all the separate images sliding correctly.)

So far the test files I have which are importng some image from an XML are here: http://volved.com/projekt/portfolio.swf & http://volved.com/projekt/portfolio.fla

Any input much appreciated, thanks all!
-Barnz

Centering Images In Xml Gallery [renamed]
Hi

There is a great tutorial under the topic Flash MX2004 – “Adding thumbnails”.
It’s about how to make a photo slideshow with scrollable thumbnails using Flash and XML. And it’s function is simple too, just click on a thumbnail and larger image fades in above.
If photograph is taken as landscape everything is fine but if it happens to be upright or portrait, it appears on left side of the picture_MC.
Is there any way to make upright images appearing in the middle of picture_MC?
Here is the code.

function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
thumbnails = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
thumbnails_fn(i);
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
function thumbNailScroller() {
// thumbnail code!
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 10;
tscroller.onEnterFrame = function() {
if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._heig ht)) {
if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {
thumbnail_mc._x -= scroll_speed;
} else if ((_root._xmouse<=200) && (thumbnail_mc.hitTest(hit_left))) {
thumbnail_mc._x += scroll_speed;
}
} else {
delete tscroller.onEnterFrame;
}
};
}

function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._x = hit_left._x+(eval("thumbnail_mc.t"+k)._width+5)*k;
target_mc.pictureValue = k;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
};
target_mc.onRollOver = function() {
this._alpha = 50;
thumbNailScroller();
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}

Thank you for any answer.

Centering Dynamic Images In XML Gallery
Hey there folks, I'm having an issue centering dynamically loaded content, if anyone could take a look at this gallery movie I'm working on I would appreciate it.

http://www.citruswebhosting.com/web-test/imgCenter.zip

Heres the AS for the gallery, I'm trying to center each image upon loading it into the img container.

Code:
var cx = loader._x;
myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
//portfolioTag = this.firstChild;
numimages = this.firstChild.childNodes.length;
spacing = 50;
for (i=0; i<numimages; i++) {
this.picHolder = this.firstChild.childNodes[i];
this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
this.thumbHolder._x = i*spacing;
this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
this.thumbHolder.title = this.picHolder.attributes.title;
this.thumbHolder.main = this.picHolder.attributes.main;
this.thumbHolder.onRelease = function() {
loader.loadMovie(this.main);
loader._x = cx-loader._width/2;
};
}


};

myPhoto.load("xmlphoto.xml");

Photo Gallery - Centering Images
Hello, I am new to Kirupa and just starting to learn actionscripting.
I love the Thumbnail Photogallery... But I have both vertical and horizontal pictures...
The horizontal pictures work great! But what code and where would I add it if I wanted to tell Flash to center the vertical photos in the large gallery.
I would appreciate any suggestions.
Thank you

Copyright © 2005-08 www.BigResource.com, All rights reserved