[F8] 'Centering An External Image To Empty MC' Problem.
Hi everyone,
I'm working on customising an open source Flash/XML gallery, and I've almost got it how I want, but seem to be stuck on what I think could be a very simple problem, which I'm hoping some kind soul here will be able to point out, so I can slap my forehead in a d'oh kind of way.
I'm trying to get the empty MC called 'holder', to instead of the default top/left corner, to load the image in it's centre. I can get the 'clicked' images to do so, but it's just the initial/first image that still loads the default way.
I've copy/pasted the part of the code which I think is the place to look. And I've RoyalBlue'd the part of the code I changed to make the 'clicked' image to do what I want.
Code: imageWidth = 55; imageHeight = 50;
var cx = holder._x; var cy = holder._y;
clickAction = function (_arg2) { loadMovie (_arg2.large, this.holder); this.info_mc._alpha = 0; this.holder._alpha = 0; if (holder._width) { holder._x = cx-holder._width/2; holder._y = cy-holder._height/2; } this.info_mc.info = _arg2.txt; this.info_mc.num = (_arg2.i + " af ") + total; }; loadMovie (large[0], this.holder); this.info_mc.info = txt[0]; this.info_mc.num = "1 af " + total; i = 0; Many many thanks in advance for any help given.
FlashKit > Flash Help > Flash ActionScript
Posted on: 04-20-2008, 01:17 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
'Centering An External Image To Empty MC' Problem.
Hi everyone,
I'm working on customising an open source Flash/XML gallery, and I've almost got it how I want, but seem to be stuck on what I think could be a very simple problem, which I'm hoping some kind soul here will be able to point out, so I can slap my forehead in a d'oh kind of way.
I'm trying to get the empty MC called 'holder', to instead of the default top/left corner, to load the image in it's centre. I can get the 'clicked' images to do so, but it's just the initial/first image that still loads the default way.
I've copy/pasted the part of the code which I think is the place to look. And I've RoyalBlue'd the part of the code I changed to make the 'clicked' image to do what I want.
Code:
imageWidth = 55;
imageHeight = 50;
var cx = holder._x;
var cy = holder._y;
clickAction = function (_arg2) {
loadMovie (_arg2.large, this.holder);
this.info_mc._alpha = 0;
this.holder._alpha = 0;
if (holder._width) {
holder._x = cx-holder._width/2;
holder._y = cy-holder._height/2;
}
this.info_mc.info = _arg2.txt;
this.info_mc.num = (_arg2.i + " af ") + total;
};
loadMovie (large[0], this.holder);
this.info_mc.info = txt[0];
this.info_mc.num = "1 af " + total;
i = 0;
Many many thanks in advance for any help given.
External Image Centering Problem With Actionscript
Hi Everone!
I've tried everything I can think of but for some reason my images won't center correctly when I uploade my swf file to the internet. they're all being externally loaded. it works fine on my hard drive but when i upload it to my website it gives me problems. The website can be viewed here:
http://www.mailelani.com/index2.htm
In case you don't understand the navigation system the white flowers on the dandilion are the menu items and the images appear in "photography" "graphic design" and "drawings". when you get to the image pages the little transparent squares at the bottom are the links to load the images
this is the link to the SWF file
http://www.mailelani.com/Untitled-5.zip
and here is the code i use to link the buttons:
ActionScript Code:
btn01.onRelease = function(){ containerMCc.loadPic("drawings/images/01.jpg");}
and the code that the image loader uses:
ActionScript Code:
stop();spacing = 10;containerMCc._alpha = 0;MovieClip.prototype.loadPic = function(pic){ _root.containerMCc._alpha = 0; this.loadMovie(pic); _root.onEnterFrame = function(){ var t = containerMCc.getBytesTotal(), l = containerMCc.getBytesLoaded(); if (t != 0 && Math.round(l/t) == 1){ var w = containerMCc._width + spacing, h = containerMCc._height + spacing; borderc.resizeMe(w, h); delete _root.onEnterFrame; } }};MovieClip.prototype.resizeMe = function(w, h){ var speed = 1; this.onEnterFrame = function(){ this._width += (w - this._width)/speed; this._height += (h - this._height)/speed; if( Math.abs(this._width-w)<1){ this._width = w; this._height = h; _root.containerMCc._x = this._x - this._width/2 + spacing/2; _root.containerMCc._y = this._y - this._height/2 + spacing/2; _root.containerMCc._alpha = 100; delete this.onEnterFrame; } }};
i'm really stuck on this and have no idea even where to start i've been able to tweek and figure out mostly everything else on my own but this is too much becaue i can't even begin to figure out the problem as i really don't know actionscript
thanks in advance
maile
Positioning Empty Movie Clip External Image Loader
Hello (again),
I am building a gallery for a photographer.
The setup: one large mc loader on mainstage (myLoader_mc). Several movie clip thumbnails contained in one large movie clip. You click on the thumbnail, large image loads into myLoader_mc. I am using a purchased component from extend studios for my transitions.
The problem: my jpgs are of different height and width. I want to keep using the same movie clip to load the images (myLoader_mc) but position the loader with different x and y coordinates for each loaded image so that it is centered on the stage. I am using the following script but the loader clip is stuck in the position defined by the first thumbnail. the script is in layer 1, frame 1 of the movie clip containing all of the thumbnail movie clips.
th1_mc.onRelease = function(){
_parent.myLoader_mc.loadMovie("/assets/family/1b.jpg");
myLoader_mc._x = 162;
myLoader_mc._y = 5;
}
th2_mc.onRelease = function(){
_parent.myLoader_mc.loadMovie("/assets/family/2b.jpg");
myLoader_mc._x = 282;
myLoader_mc._y = 5;
}
The image loaded by thumbnail 2 is stuck in position on thumbnail 1. Need to change this dynamically no matter which thumb is clicked.
Any help is appreciated and I hope I have explained this clearly enough. If you help me solve this, i will toast my next drink to you.
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
Loading External SWF From External SWF Onto An Empty MC On Main Timeline?
Hi Everyone,
Please bear with me while I explain. I have an external swf that loads into a frame in the main timeline, into an empty MC. I can do this just fine. Once this clip is loaded, I have a button in this clip that loads another external swf into a different empty MC on the main timeline. I'm using loadMovie, and I need to load these movies into specific empty MCs. In other words,
I have the following:
MainStage: frame 5, contains empty MC "ClipA"; frame 6, contains empty MC "ClipB"
External swf: "Movie1"
External swf: "Movie2"
"Movie1" goes into "ClipA" of frame 5 on Main Timeline; and "Movie1" has a button that loads "Movie2" into "ClipB" of frame 6 on Main Timeline. I need help loading "Clip B" into "Movie2" from a button in "ClipA."
I'm sorry my message is so roundabout - it's not really a complicated situation, but explaining it makes it seem so.
Thank you in advance for any help - I'm assuming it's some sort of _root or _parent issue things I'm not quite understanding.
Thanks!
macgirl
Centering Image In The Xml Image Gallery...
did the tutorial on this site for an xml image gallery - it worked great... My question would be is there a way to accomodate for multiple image sizes that would allow the image displayed to be centered?
Thanks!
Centering An Image With AS2
Hey there guys, I'm having a slight problem centering images in an xml image gallery on my website:
www.trilogyproductions.com.au
If you go to the "Propaganda" page and click on the design link you will see what I mean. To start with the first image is not being centered even though i call the centreImg(); function when it loads up.
I have tried to center the host movie clip that loads the images every time a choice is made. But the damn thing doesn't center properly. And when you click on the thumbs, the image will load in an off spot. However when the same thumb is clicked again, the image is centred properly. (???) Though when the user goes through the images using the left and right buttons in the top right.. the next image will load from the top left registration point of the last one. I have tried putting the centreImg(); function in various places but nothing seems to work the way it should.
Can anyone please help? I am not an expert with AS and most of the code I've borrowed and tweaked from various tutorials, and I've almost got it right but now I'm stuck and frustrated. And I know I'll most likely get told to look at more tutorials and try and figure it out myself, but thing is I don't have the time!
Anyways, the code I have is:
ActionScript Code:
function centreImg() {
picture._x = -(picture._width/1.9);
picture._y = -(picture._height/2) - 20;
}
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("xml/designimages.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._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 5;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
centreImg();
}
}
function thumbNailScroller() {
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 22;
tscroller.onEnterFrame = function() {
if ((_ymouse>=thumbnail_mc._y) && (_ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
if ((_xmouse>=(hit_right._x-15)) && (thumbnail_mc.hitTest(hit_right))) {
thumbnail_mc._x -= scroll_speed;
} else if ((_xmouse<=(hit_left._x+15)) && (thumbnail_mc.hitTest(hit_left))) {
thumbnail_mc._x += scroll_speed;
}
} else {
delete tscroller.onEnterFrame;
}
}
}
scrollUp_BTN.onPress = function() {
thumbnail_mc._y -= scroll_speed;
}
scrollDn_BTN.onPress = function() {
thumbnail_mc._y += scroll_speed;
}
function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._y = scrollUp_BTN._x+(target_mc._width+1)*k;
target_mc.pictureValue = k;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
centreImg(); <----- THIS SHOULD WORK YEAH???
};
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);
}
Sorry, it's a bit wordy, but didn't want to omit anything in case there's something not right elsewhere. Hope someone who knows what they're doing and has some spare time can help, or maybe point me to a similar gallery I can use that will definately work.
Cheers!
Centering An Image
I am using the following tutorial to build my own photogallery.
http://www.kirupa.com/developer/mx20...otogallery.htm
However, I have both horizontal and vertical images, so the horizontal image looks centered but the vertical image looks left aligned because the common point for all images is in the upper left corner.
Any suggestions on how I can center the images within my movieclip? Thank you.
Centering A Loaded Image.
My movie clip loads an external image to the screen. The image is loaded onto a movie clip located in the upper left corner of the screen xy cordinates 0,0.
code:
_root.image.loadMovie("imageName");
Now I want to center the image to the middle of the screen.
code:
_root.image._x = ( 400 - (_root.image.width/2) )
This should center the image horizontally considering that the screen is 800 pixels wide. It does not seem to work for some reason. Could anyone help?
Centering An Image In A MovieClip
Hi,
I read the posts on here regarding Registration Points and Centering movieClips, and haven't found anything to work.
I'm trying to center loaded images into the center of a movieClip, which is in the dimensions of the stage (550x400). I have mages that will fit within those dimensions. The problem is that the registration point only reads the top-left corner of the image, and thus all the images line up "top-left style". I have images that are primarily-horizontal or primarily-vertical in nature. I'm looking for a script the allows my images to dynamically load and center in the middle of the stage. I was given the script below as a work around:
//load image into movieClip called 'place'
place.loadMovie("image3.jpg");
//center 'place' on main stage
place._x = 550-(place._width/2);
place._y = 400-(place._height/2);
//"place" is INSTANCE NAME of 'Square' movie clip;
stop();
First, the images ended up mostly in the lower right hand corner of the stage, and they never really centered (just sporadic positions). I split the stage-dimensions in half in the script (place._x = 275, place._y=200) and the images were still sporadic positioning (but centered here and there) [kind of the same thing as the 550x400 dimensions, but closer to the middle of the stage where I want it]. I split the dimensions in the script again (137.5x100), and they did the same thing, though more up in the upper left-hand corner of the stage. Just wondering if someone could tell what I am missing here?
I would love to send anyone a copy of the .fla to show of the problem, if possible.
Anything you could tell me would be a big help. Thanks.
Mark
Centering A Loaded JPG Image
i'm having a real problem centering a loaded jpg after it's aleady been loaded. i have it loading centrally at a smaller scale using this script:
Code:
//Step1
createEmptyMovieClip("img002", 0);
img002._visible = false;
//Step2
img002.loadMovie("photos/01/03.jpg");
//Step3
this.onEnterFrame = function() {
BLoaded = img002.getBytesLoaded();
BTotal = img002.getBytesTotal();
percent = BLoaded/BTotal*100;
//Step4
if (BLoaded == BTotal && BLoaded>0) {
img002._width = _width/10;
img002._height = _height/10;
img002._visible = true;
delete this.onEnterFrame;
img002._x = 0-_width/2;
img002._y = 0-_height/2;
img002._alpha = 50;
}
};
but i then want it to appear full size, centred to the other images on the page.
i don't want to use specific coordinates to do this as the jpg images will vary in size and will be changed in the future.
i've been trying all day to do this with "photo 3" in my library (see attached file), using this script:
Code:
on (release) {
img002._width = _width*10;
img002._height = _height*10;
// THIS IS WHERE I'M HAVING PROBLEMS:
img002._x = (_root.fullimage._width/2);
img002._y = (_root.fullimage._height/2);
_root.gotoAndStop("f3");
gotoAndStop(4);
}
and i then want it to return to the original position once it is reduced again in scale.
please help!
thanks
Image Centering An Stuff
Hi
Im really a new on this stuff so please be patient...hehe
im trying to to a image loaded into a movie ..then create the bitmap ...etc and attachBitmap to another movie ...so far so good ..but im having problems with the Center image on the movie.
This is the messy code i guess so far:
Code:
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Matrix;
import flash.geom.ColorTransform;
_quality = "BEST";
this.onEnterFrame = function() {
MainFileSize = Holder.getBytesTotal();
MainLoaded = Holder.getBytesLoaded();
remaining_bytes = MainFileSize-MainLoaded;
percent_done = int((MainLoaded/MainFileSize)*100);
if (MainLoaded != MainFileSize) {
clearInterval(this.intCheck);
} else {
if (Holder._alpha<100) {
Holder._alpha += 10;
Holder._x = (600-Holder._width)/2;
Holder._y = (600-Holder._height)/2;
}
}
};
//the function that creates the new image
function checkLoaded() {
if (HolderGost._width>0) {
clearInterval(this.intCheck);
var GostImage:BitmapData = new BitmapData(HolderGost._width, HolderGost._height, false);
GostImage.draw(HolderGost);
var scaleMatrix:Matrix = new Matrix();
scaleMatrix.scale(Scale/100, Scale/100);
var scaleBitmapData:BitmapData = new BitmapData(HolderGost._width, HolderGost._height, false);
scaleBitmapData.draw(GostImage, scaleMatrix, new ColorTransform(), "normal", undefined, true);
Holder.attachBitmap(scaleBitmapData, this.getNextHighestDepth());
Holder._alpha = 0;
HolderGost._visible = false;
HolderGost.dispose();
delete HolderGost;
}
}
var intCheck:Number = setInterval(this, "MainFirstImage", 0);
this.createEmptyMovieClip("HolderGost", this.getNextHighestDepth());
HolderGost.loadMovie("td20k.jpg", 1);
//something to calculate the scale
function MainFirstImage() {
Scale = Math.floor(Math.min((600/HolderGost._width), (600/HolderGost._height))*100);
HolderGost._visible = false;
if (MainLoaded == MainFileSize) {
Holder._alpha = 0;
//Holder.loadMovie(ImagePath, 1);
checkLoaded();
}
}
UpButton.onPress = function() {
if (Scale<100) {
Scale = Scale+10;
checkLoaded();
Holder._x = (600-Holder._width)/2;
Holder._y = (600-Holder._height)/2;
}
};
ButtonDown.onPress = function() {
if (Scale>=50) {
Scale = Scale-10;
checkLoaded();
Holder._x = (600-Holder._width)/2;
Holder._y = (600-Holder._height)/2;
}
};
i attached also the .fla file
Please give me a hand on this
Cheers
Centering Image With Html
I can't seem to get an image to center in a dynamic (html) text field. I've tried encapsulating it in a <p align="center"> tag but it has no effect. Any help would be appreciated.
Problems In Centering Image
Hi all
I've been working on a dynamic slideshow for some time now. I create an empty Movie Clip imgMC and then load pictures into it. Everything worked fine when the images were all the same size, and the dimensions were hardcoded.
Today I tried the same thing with different size images. I'm calculating the position of my imgMC like so:
imgMC._x = (640 - imgMC._width)/2;
imgMC._y = (800 - imgMC._height)/2;
Say, picture A is currently loaded in imgMC and is 180 px wide. When I click on link for picture B (160 px wide), and do a trace on imgMC._width just after I do a loadMovie, it shows 180 instead of 160.
This basically means that the first time I load an image, there is nothing there, and it always shows 0 on trace. This really throws the X and Y coords way off, and my image isn't centered on the page. Any pointers anyone?
TIA
Centering Image--urgent
please can someone help me--i need to make sure the crosshair, and everything about my images are centered, so when they are employed, the are used with the center as center.
how do i do th is?
thanks
disfasia
HTML - Centering An Image On A Page
I'm working on a page that contains several images contained in one table(nested tables). How do I get this image to center on the page, regardless of screen rez? It's centered at 800x600 but is not vertically centered at any other resoultion. any suggestions?
Centering An Image Loaded As A Movie
Hi there
I've built a slide show for a gallery. The images are brought in to an empty sldeshow movie placed on the main timeline. Naturally the images are all aligned to the slidesow movie clip at the topleft. As i have both portrait and landscape pictures of varying sizes. how can i bring the image in using the centre of the imge as the location reference. All starts getting a bit too maths on me.
Any offer a solution
thanks in advance
ash
Problem With Centering Image On Stage
I am dynamically loading an image onto the stage. I load the image from an XML file into an empty MC. Inorder to center it I get the width of the empty MC with the loaded image, subtract that from the stage width, then divide by 2. The math works, but for some reason its saying the width of the empty MC is 0. So this isn't working. Any suggestions.
Here is my code:
Code:
_parent._parent.attachMovie("mainPhoto","mainPhoto",1000);
_parent._parent.mainPhoto.loadMovie(picture);
_parent._parent.mainPhoto._x = (650 - _parent._parent.mainPhoto._width) / 2;
_parent._parent.mainPhoto._y = 85;
Loading And Centering A Image At Height X
Hello Flash-Kit Community,
I have come in seeking help to how to place a image at such height. Regardless of the image composition or size, I like to center it on the site evenly and distributively.
I am trying to extend my method of using a placeholder image that the action script loads the movie on to.
This is where I am stuck on.
After loading the Image onto the Placeholder, I like to have it center on the website at a positioned height, which is a few margins from the top of site. Can anyone help?
The ideal concept of this is an image gallery that doesn't use a set of image sizes and position. I like to have a Center position image regardless of its size.
Your help is very appreciated. Thank you!
Problem Centering The Image Loaded
Problem centering the image loaded
I can’t configure this thing and I need help…
The problem is that I load the image from an xml so I thought that the only way to get the values of height and width is when the image is loaded.
The movie is loaded but invisible
PHP Code:
this.thumbHolder.onRelease = function() {
_root.imagen._alpha = 0;
_root.imagen.loadMovie(this.main);
Get the values
PHP Code:
h = this._root.imagen._height;
w = _root.imagen._width;
trace(h+" height x "+w “width”);
The movie is visible just when the operation for center the image is applied
PHP Code:
_root.imagen._x = 300-(w/2);
_root.imagen._y = 300-(h/2);
_root.imagen._alpha += 100;
}
BUT when I click the thumb the trace show the values of “0 height x 0 width” and the result is wrong but if I click again the thumb the values are correct “200 height x 154 width” and image is centered but if I click on other thumb the values of “200 height x 154 width” remains and image is not centered but if I click again in this new thumb the values will be correct “120 height x 234 width” and centered.
My code is this one...
PHP Code:
var path = this;
//===========================================
var movieLoader:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
path._parent.vScrollPolicy = "auto";
path.setStyle("backgroundColor", "transparent");
};
movieLoader.addListener(mclListener);
//===========================================
//*****
///***
fotos = new XML();
fotos.ignoreWhite = true;
fotos.onLoad = function(success) {
numimages = this.firstChild.childNodes.length;
spacing = 75;
for (i=0; i<numimages; i++) {
this.picHolder = this.firstChild.childNodes[i];
this.thumbHolder = thumbMc.createEmptyMovieClip("thumbnail"+i, i);
this.thumbHolder._y = i*spacing;
this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 1);
this.thumbHolder.title = this.picHolder.attributes.title;
this.thumbHolder.main = this.picHolder.attributes.main;
//trace(this.thumbHolder.title._name + " = " + this.main._width + " X " + this._height + " pixels");
this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
movieLoader.loadClip(this.picHolder.attributes.thmb, this.thumbLoader);
//**************************
this.thumbHolder.onRelease = function() {
_root.imagen._alpha = 0;
_root.imagen.loadMovie(this.main);
h = this._root.imagen._height;
w = _root.imagen._width;
trace(h+"x"+w);
_root.imagen._x = 300-(w/2);
_root.imagen._y = 290-(h/2);
_root.imagen._alpha += 100;
_root.nombre.text = this.title;
}
}
};
fotos.load("xmlfile.xml");
Please help….
[FMX] Gallery->centering Main Image
Hi all.
I didn't find a solution for my problem.I have set up a gallery (from sources around the net) and i want the main image (the big version of thumnails) to be centerd in an area of 350*350 if the image width or height is <350.I have 3 sorts of image size : 350*350, <350*350, 350*<350. The thing is that with the code below when i trace the clip width it gives me the right value only after 2 cliks on the thumbnails. I can't get rid of that...
On my scene : thums container named "thumbnails", image container named "loader"
Here's the code:
_global.limitebas = -1000;
_global.limitehaut = 150;
var x_orig = 18;
var y_orig = 156;
var xSpace = 60;
var ySpace = 60;
var col = 3;
var num_col = 0;
var x_or= 395;
var b_or = 395;
var num_ligne = 0;
myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
//portfolioTag = this.firstChild;
numimages = this.firstChild.childNodes.length;
spacing = 120;
for (i=0; i<numimages; i++) {
picHolder = this.firstChild.childNodes[i];
thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
if (num_col>col-1) {
num_col = 0;
num_ligne++;
}
thumbHolder._x = 12.2 +(num_col*xSpace);
thumbHolder._y = 29 +(num_ligne*ySpace);
num_col++;
thumbLoader = thumbHolder.createEmptyMovieClip("thumbnail_image" , 0);
thumbLoader.loadMovie(picHolder.attributes.thmb);
thumbHolder.main = picHolder.attributes.main;
thumbHolder.onRollOver = function () {
this._alpha = 50;
}
thumbHolder.onRollOut = function () {
this._alpha = 100;
}
thumbHolder.onRelease = function() {
loader.loadMovie(this.main);
w = loader._width;
h = loader._height;
loader._x = 390 + 350-w/2;
trace(w);
}
}
};
myPhoto.load("beauty.xml");
Any help appreciated!
Than you
Centering A Loaded Image/Movie
I am needing to load an external image (probably jpg) into a movie. I am using an empty movie clip, giving it an instance name and the code:
Code:
instance1.loadMovie("image.jpg");
What I also need to do is be able to either place that image in a specific location on the stage or just center it. Any advice you can give me on that?
I am attempting to do something like this: Use two movie clips. One is a holder that contains the second movie clip, which is where the image is actually being loaded. Then, I am using the following math:
Code:
instance1.isntance2.x - instance1._width/2 instance1.isntance2.y - instance1._width/2
Does this look like it would work? Is there anyway I can set instance1 to have a width that is equal to the size of the main movie (1024 x 768)?
XML Gallery Image Centering In Flash
I'm using parital XML code found on Kirupa earlier this year but I'm having problems centering the image in the middle of the screen after the target thumbnail is clicked. I've found a prototype code to handle this but it produces unexpected results on the server side-- everything in the Flash/IE/Mozilla preview browsers work perfectly fine 'offline'. As soon as I place it on the server the movieclip will sometimes center tiny in the middle of the screen forcing the image off to the bottom right!??
http://johnsolskei.com/suhrtest/thumb_resize.html
Does anyone know why this would occur? This is tough to troubleshoot because the movie loads just fine in the Flash 8 preview browser. Maybe someone has had similar problems or knows why it would react this way in the online browser? Any help is greatly appreciated! -John
Code:
//////XML acknoledgements to Kirupa Chinnathambi///////
///////////////////////////////////////////////////////
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);
}
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
///////////////////////////////////////////////////////
border_mc._visible=false;
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);
picture.loadPic(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
//picture.loadMovie(image[p], 1);
picture.loadPic(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._x = (target_mc._width-45)*k;
target_mc.pictureValue = k;
if ((k+5)%2 == 0) {
target_mc._x = ((target_mc._width-45)*k)+75;
target_mc._y += 75;
} else {
target_mc._x += 100+30;
}
target_mc.onRelease = function() {
dimmer_mc._visible=true;
dimmer_mc.gotoAndPlay("on");
border_mc._visible=true;
p = this.pictureValue-1;
nextImage();
};
target_mc.onRollOver = function() {
this._alpha = 50;
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}
//////resizing border and moving the image to the center///////////
///////////////////////////////////////////////////////////////////
spacing = 10;
MovieClip.prototype.loadPic = function(pic){
_root.picture._alpha = 0;
this.loadMovie(pic);
_root.onEnterFrame = function(){
var t = picture.getBytesTotal(), l = picture.getBytesLoaded();
if (t != 0 && Math.round(l/t) == 1){
var w = picture._width + spacing, h = picture._height + spacing;
border_mc.resizeMe(w, h);
delete _root.onEnterFrame;
}
}
};
MovieClip.prototype.resizeMe = function(w, h){
var speed = 3;
this.onEnterFrame = function(){
this._width += (w - this._width)/speed;
this._height += (h - this._height)/speed;
if( Math.abs(this._width-w)<1){
this._width = w;
this._height = h;
_root.picture._x = this._x - this._width/2 + spacing/2;
_root.picture._y = this._y - this._height/2 + spacing/2;
_root.picture._alpha = 100;
delete this.onEnterFrame;
}
}
};
Need To Instantiate An Image In An Empty Mc Within A Button
Hi,
I dont know why I cant access an instance of a mc within a button.
I have an empty mc called "theEmpty" and another one containing a image called "theImageA" (exported to ActionScript). I have a button called "theButton" too.
I instantiated the mc "theEmpty" within first frame of "theButton" and named its instance as "TheEmpty1".
Then, I instantiated "theButton" in the first frame of the timeline and named its instance as "TheButton1".
In the first frame of the timeline, I coded the following:
theButton1.theEmpty1.attachMovie("theImageA","theI mageA1",2);
The idea should load the mc "theImageA" in the mc "theEmpty" that is within the button "theButton". Why it dont works????
Thanks!
Load Single Image Into Empty MC Using XML
Hey I just wanted to know if anybody can point me to a tutorial or code I can use to load a single image into an empty MC from an XML file, I already tried altering code from slideshows available at kirupa, but can't get it to work.
For your help Thanks
Get The Size Of An Empty MC After Loading An Image, How?
Hi!
I have an empty MClip which loads a jpg image. Once it's loaded, I'd like to know the resulting size of the MClip.
However, whenever I trace it, it always returns 0.
This is what I'm doing:
I load my jpg image to my empty MC called DummyMC.
loadMovie(JPGimage,"DummyMC");
If now I trace the width or height, it returns 0:
trace (DummyMC._width);
trace (DummyMC._height);
I guess it's easy to solve...can anybody give me some light please?
Thank you!
Easing A Empty Mc With A Dynamic Image
I've worked on this for far to long to know success and it's probably something really simple that I am forgetting
I currently have a empty movieclip created that loads the image from the url. This image_mc is given a actionscript tween from left to right. The problem is that it doesn't move left to right. When you take of the loadMovie function it works as it should. any help would be appreciated.
Code:
this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
image_mc.loadMovie("http://www.macromedia.com/images/shared/product_boxes/80x92/studio_flashpro.jpg");
var currentFrame = 0;
image_mc.onEnterFrame = function() {
currentFrame++;
this._x = currentFrame*11;
if (currentFrame>50) {
delete this.onEnterFrame;
}
};
Centering Image Within Movie In Photo Gallery
So I'm teaching myself flash, and created a photo gallery based on a tutorial from this site, but i was wondering if anyone new how to center an image within a movie clip when displaying the gallery. All of my images are different sizes b/c its for an art gallery, so i can't set a static size for the clip. if anyone knows how to center an image inside a movie clip, any help would be greatly appreciated.
Here's a link to the gallery so you get an idea what i'm talking about:
link
Centering Loader Component Image Content
Here is a little bit of as2 code how to centering Loader Component:
var mainw:Number = Stage.width/2;
var mainh:Number = Stage.height/2;
myLoader.scaleContent = false;
myLoader.visible = false;
var ldrlistenerObject = new Object();
ldrlistenerObject.complete = function(evt_obj:Object) {
myLoader.visible = true;
var imagew:Number = myLoader._width/2;
var imageh:Number = myLoader._height/2;
myLoader._x = mainw-imagew;
myLoader._y = mainh-imageh-60;
};
myLoader.addEventListener("complete", ldrlistenerObject);
Centering And External Jpg
i'm trying to center an externally loaded jpg... I heard that I could find the width of the mcContainer that holds the loaded file, but only after it is completely loaded.. so here's my code:
mcContainer.loadMovie("myPic.jpg");
percent = 0;
while (percent < 100) {
percent = (mcContainer.getBytesLoaded()/mcContainer.getBytesTotal())*100;
}
mcContainer._x = ( stage.width - mcContainer._width ) / 2;
Using traces I found that the While loop does work, but mcContainer._width is still 0 after the file is completely loaded! What gives?
External Swf's Not Centering
Hi,
I am trying to center external swf's and photos.
I bought a Loader Component, and it works some of the time.
The file - clients.swf - does not center when it's loaded into FINAL.swf.
Can anyone help take a look? Thanks!
The files are here:
ftp.fatcow.com
username and password: dgc
Empty Movieclip Properties (image Holders)
Hi Everyone
I am developing a scrollable image viewer. The user clicks the thumb and the main image is displayed in an empty movie clip called holder. How do I code it so the images fade in rather than appear straight away. Do I need to convert the images to swf's or can I assign actionscript to the movieclip named holder.
Thanks in advance
Center Image Within Empty Movie Clip?
Hello, I have been following this tuorial for creating a dynamic photo gallery using xml.
right now, when loaded, the top left hand corner of each image is aligned to the 0,0 coordiante of the empty movieclip. My images vary in size and shape so I would rather that they were aligned centrally to the 0,0 coridinate. is this possible?
I hope I've explained myself ok, any help would be greatly appreciated
Here is the actionscript.
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;
}
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;
}
Loading Image Onto Empty Movie Clip
hey all
just a quick question.
shown in the code below i am dynamically creating buttons. the buttons load an image and text into another clip above. what i need help with is; i need the image to ALSO be displayed on the button. :confused
so instead of the button filling with it's color (CCCCCC) i need it to fill with the corresponding image or part of the corresponding image.
any ideas?
thanks in advance!!
PHP Code:
// create a blank text box and set its parameters// first is movie depth, second is x coordinate, third is y coordinate, then width followed by height_root.createTextField("theTextBox", 20, 100, 110, 245, 75);theTextBox.background = true;theTextBox.border = false;theTextBox.backgroundColor = 0xFFFFFF;// whitetheTextBox.multiline = true;theTextBox.wordWrap = true;theTextBox.html = true;theTextBox.scroll = true;theTextBox.scrollbar = true;theTextBox.variable = "myText";// load our textloadVariables("welcome.txt", "_root");//set up dynamic buttons and parameters//for(i=1;i<11;i++) where i<8 represents max number of buttons (so 10 buttons total)//_x=i*37 where 37 represents width of button plus space between buttons (so 27+10=37)for(i=1;i<11;i++){ _root.createEmptyMovieClip("button"+i, 100+i); _root["button"+i].beginFill(0xCCCCCC, 100); _root["button"+i].moveTo(-25, -10); _root["button"+i].lineTo(25, -10); _root["button"+i].lineTo(25, 10); _root["button"+i].lineTo(-25, 10); _root["button"+i].endFill(-25, -10); _root["button"+i]._x=i*37; _root["button"+i]._y=215; _root["button"+i]._width=27; _root["button"+i]._height=27; //create, add, delete buttons}button1.onRelease=function(){ loadVariables("text1.txt", "_root"); loadMovie("showcase1.jpg","imageHolder");}button2.onRelease=function(){ loadVariables("text2.txt", "_root"); loadMovie("showcase2.jpg","imageHolder");}button3.onRelease=function(){ loadVariables("text3.txt", "_root"); loadMovie("showcase3.jpg","imageHolder");}button4.onRelease=function(){ loadVariables("text4.txt", "_root"); loadMovie("showcase4.jpg","imageHolder");}button5.onRelease=function(){ loadVariables("text5.txt", "_root"); loadMovie("showcase5.jpg","imageHolder");}button6.onRelease=function(){ loadVariables("text6.txt", "_root"); loadMovie("showcase6.jpg","imageHolder");}button7.onRelease=function(){ loadVariables("text7.txt", "_root"); loadMovie("showcase7.jpg","imageHolder");}button8.onRelease=function(){ loadVariables("text8.txt", "_root"); loadMovie("showcase8.jpg","imageHolder");}button9.onRelease=function(){ loadVariables("text9.txt", "_root"); loadMovie("showcase9.jpg","imageHolder");}button10.onRelease=function(){ loadVariables("text10.txt", "_root"); loadMovie("showcase10.jpg","imageHolder");}// create variable graphic content holder_root.createEmptyMovieClip("imageHolder", 377, 88);imageHolder._x=15;imageHolder._y=15;loadMovie("showcase_default.jpg","imageHolder");imageLoaded=true;
Kirupa Photo Slideshow Tute - Centering Image
Hi, this is my first post on this forum. I've been going through the tutorials and forum trying to build a photo slideshow. I managed to get the slideshow working with buttons, ( http://www.kirupa.com/developer/mx20..._slideshow.htm ) but am really stuck with trying to center the images ... I'm using portrait and lanscape images, and want them both to be vertically and horizontally centered in a 504x504 moive.
I'm a AS noob, and I know i've bitten off more than I can chew, but if anyone could give me a few pointers it would be much appriciated.
thanks
Centering External Loaded .swf
hello all, here's my question???
i have learn to load external swf's but for some reason its on the top left corner. i would to center these swf in the middle can some one help pls.
Centering External Loaded .swf
hello all,
i understand how to load an external .swf, but i don't want it to be in the left hand corner of my movie
i know that i have to create a movie clip to hold the newly loaded movie, but where do i create the the mc and how??
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.
[AS3]Centering External Sprite
I have a button.
It is 64x64
I also have sprites to load into those buttons
These sprites are inconsistent in dimensions
I load those buttons in.
I scale them down to fit in the 64x64 buttons.
Now the question is , how do i centre those sprites? I want them right smack in the middle of the button.
It is also important to note that these sprites are in the form of swfs. And also, the sprite itself can be anywhere in the swf, are of any size, and also extend into negative coodinate spaces.
Please help thanks.
edit:never mind... i think i got it...getBounds / getRect should do the trick...
Centering External SWF On Page
Hello and if anyone can help, I'm stuck with external SWF loading in middle of the page, I mean this.
1. I have designed flash full browser page according to LEE's tutorial.
2. I'm importing external SWF into the movieclip that's supposed to be centered on page regardless how you stretch the browser window and the "holder" movieclip where everything gets loaded in is centered.
3. problem is that whenever I import external SWF it starts appearinf from center meanin its top left corner starts loading from center of the page , but I need it to load center to center.
how can I do it?
here link. http://verbotten.drivehq.com/main.html
[MX04] Loading Preloader And Image Inside Empty MC
I'm creating a photogallery, and I'm thinking of creating the thumbs of an array.
Now doing this would be rather simple with using loops and creating empty movieclips and just puttting the images inside them. But what do I do if I want custom preloaders for each thumb?
The way I'm doing it now is that inside flash each thumb is a different movieclip that loads in the image "full with preloader" via actionscript. Now this is ok for 10 or so pictures, but when filling the gallery with about 100 images, it's very timeconsuming...
so basically I'm aksing how do attach custom made preloaders into empty movieclips and having that preloader preload another loaded image...
If I made enough sence and if it's even possible?
Loading External .SWF Into Empty MC
I've working on a site w/ thumbnails that when clicked load an external swf file into an empty MovieClip.... I've been able to get this to work no problem until I pushed the site up to the server...
Now the external swf loads only after the thumbnail is clicked TWICE. Initially this was working on the first click....
Any advice?
Here's the site:
www.isaacpierro.com
(some of the imagery is a little dark, so don't visit if you're easily offended)
Thanks in advance...
Importing External Swf Into Empty MC
Im trying to load and play an external swf in my main swf within an empty MC depending which code I use the results are
1) loadMovieNum("intro.swf", holderclip);
loaded swf plays over top of everything and i lose the text and navigation
2)onClipEvent(load/OR/enterFrame) {
loadMovie("intro.swf",_root.holderClip);
}
nothing happens at all
has anyone got any ideas??
Where To Put Empty _mc To Load External .swf
I need to know the best place to put an empty _mc to load external .swf's on each grey background for each seperate button. I also would like to know how to slow down the first window drop a bit. I got this as a stripped down .fla and added the design elements myself but thats as far as I can get I am fairly new at this. Just tryin' to learn. I got the .fla from somone on here but I can't remember who so thanks if it was you.
Thanks
Sorry the fla was too big to send, Here is the link. i put it on my server http://www.nucklewebdesign.com/dload.htm
Loadn External Swf Into Empty MC?
Hey for the life of my i cant figure this out.
I have a swf called news, it loads all my news from a XML document and puts it behind a mask so i can scroll and organizes everything. That all works fine.
But as soon as i load news.swf into my flash index and try and put it into a MC i cant see anything under my mask?? WTF?. Okay so after i calm down i try loading news.swf it into a level, bang! works fine!
Only thats not going to b good enough, i need to turn its visibilty on and off, so i NEEED it in a MC..
Whats going on here, please help? I can post fla files if I need to, but would prefer not to..
Centering A Dynamically Loaded Image File In A Movie Clip
Hi all,
I followed a tutorial on kirupa.com (this is the link to the tutorial http://www.kirupa.com/developer/mx2004/thumbnails.htm)
I've learned from that and created my own image gallery, the only problem is that when the image loads, it loads to the top left, so my image hangs off the side of the page.
All my images are different sizes, so i firstly need the thumbnail pannel to recognise the size of each thumbnail and bunch them up centre aligned (on the horizontal axis) so that there are no massive black gaps in between.
Second, i need the image in the main 'picture' movie clip to aligne to the centre registration point instead of its top left corner aligning to the reg point.
This is the code that I am using at the moment
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
picname = [];
thumbnails = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
picname [i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[3].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);
//
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];
name_txt.text = picname [p];
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
name_txt.text = picname [p];
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
name_txt.text = picname [0];
}
}
function thumbNailScroller() {
// thumbnail code!
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 5;
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<=(hit_left._x+40)) && (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+(target_mc._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);
}
I understand that this is all about timing or somethign as the image has to load before it can be centered. But this is starting to annoy me now.
I've seen some topics on this on other pages, but they make no sense... i need to know where the code goes and how it works etc... i'm not a total actionscript wizz (as you might have noticed).
This is the rough layout of the scene if you need it.
On the left is two dynamic text boxes which load with the information for the image, then all the way along the bottom is the thumbnail slider with the image box beign at the right of the stage.
In time i'd like to put effects and more animated things on the gallery, but right now i just need to get this sorted before it drives me totally mad.
thanks
Desperately needing help
CI
Centering Loaded External Jpegs
I've seen similar questions to this here, but I couldn't find any clear answers. I am loading external jpegs into my site and I want to get their size (width, height) so I can position them appropriately once they're loaded. How do I get their size and re-position them? I've been trying to use getProperty, but I can't seem to get that to work. Any help would be greatly appreciated - I'm stumped. This is basically how I am loading the jpegs.
Code:
_root.holderMC.loadMovie("products/image.jpg);
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
|