-
Trying to stop a gallery cycling..?
Hi all,
I have a swf gallery (it's actually part of a larger swf that does other things). I send an array of image url's the swf and it will fade them in and out to display them in turn.
The problem I have is that if there is just 1 image it just keeps fading in and out and looks a bit silly. I would just like to have the one image displayed statically if there's only 1 image.
The code that is under the 'gallery' heading in the actionscript is:
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var bgChange = new Color("bg");
bgChange.setRGB(_root.background_swf.colourArray[0]);
var maxWidth:Number = 545;
var maxHeight:Number = 341;
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
container.load_txt.text = "";
target_mc._xscale = 100;
target_mc._yscale = 100;
// determine which is the longest side
var smallNum:Number;
var largeNum:Number;
if (target_mc._width>target_mc._height) {
smallNum = maxWidth;
largeNum = target_mc._width;
} else {
smallNum = maxHeight;
largeNum = target_mc._height;
}
// now resize the clip
var myScale:Number = smallNum/largeNum;
if (target_mc._width>maxWidth || target_mc._height>maxHeight) {
target_mc._xscale = myScale*100;
target_mc._yscale = myScale*100;
}
target_mc._x = 545/2-target_mc._width/2;
target_mc._y = 341/2-target_mc._height/2;
};
mclListener.onLoadProgress = function(mc, loadedBytes, totalBytes) {
//container.load_txt.text = Math.floor(loadedBytes/totalBytes*100)+"%";
};
mclListener.onLoadError = function() {
//container.load_txt.text = "Error:"+count;
};
mclListener.onLoadComplete = function(target_mc) {
fadeGallery(1);
container.load_txt.text = "";
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
var count:Number = 0;
slideDur = 5000;
fadeInDur = 2;
fadeOutDur = 4000;
//fadeInDur = 1;
//fadeOutDur = 5000-(fadeInDur*2000);
var imgTwn:Tween = new Tween(container, "_alpha", Strong.easeOut, 0, 0, fadeInDur, true);
var galleryTwn:Tween = new Tween(this, "_alpha", Strong.easeOut, 0, 0, fadeInDur, true);
function render_gallery() {
pc = _root["pcArray"+count];
var galleryTimeout:Number = setTimeout(fadeGallery, fadeOutDur, 0);
if (count<_root.imageArray.length) {
//do nothing;
} else {
count = 0;
}
container.link = _root.imageArray[count].comment_url;
image_mcl.loadClip(_root.imageArray[count].picture_url,container.imgHolder);
if (pc[pc.count] != undefined) {
// Uncommenting the next line will display the comment but it needs to be bigger and a nicer font etc.
//container.comment = pc[pc.count];
} else {
container.comment = "";
//container.comment = "Add a Comment to this Photo.";
}
if (pc.count<pc.length-1) {
pc.count++;
} else {
pc.count = 0;
}
count++;
}//end function
function open_gallery() {
container.comment = "";
galleryTwn.continueTo(100);
galleryTwn.onMotionFinished = function() {
render_gallery();
delete this.onMotionFinished;
};
galleryInterval = setInterval(this, "render_gallery", slideDur);
}
function close_gallery() {
clearInterval(galleryInterval);
clearTimeout(galleryTimeout);
galleryTwn.continueTo(0);
galleryTwn.onMotionFinished = function() {
image_mcl.unloadClip(container.imgHolder);
delete this.onMotionFinished;
};
}
function fadeGallery(temp) {
if (temp == 0) {
imgTwn.continueTo(0);
} else {
imgTwn.continueTo(100);
}
}
There's also some associated code in the main 'scene' that is here:
Code:
var imageArray:Array = new Array();
var imageA:Array = new Array();
var gallery_xml = new XML();
gallery_xml.ignoreWhite = true;
gallery_xml.load(siteurl+"/gallery-xml.php?memorial_ID="+memorial_ID);
gallery_xml.onLoad = function(success) {
var _loc4 = gallery_xml.idMap.root.childNodes;
if (_loc4[0].attributes.value == undefined) {
_root.tabGallery = false;
} else {
_root.tabGallery = true;
}
for (var _loc3 = 1; _loc3<_loc4.length; ++_loc3) {
if (_loc4[_loc3].nodeType == 1) {
var _loc2 = Array();
_root["pcArray"+(_loc3-1)] = new Array();
var _loc5 = _loc4[_loc3].childNodes;
for (var _loc1 = _loc5[0]; _loc1; _loc1=_loc1.nextSibling) {
if (_loc1.nodeName == "picture_url" || _loc1.nodeName == "comment_url") {
_loc2[_loc1.nodeName] = _loc1.attributes.value;
} else if (_loc1.attributes.value != "") {
_root["pcArray"+(_loc3-1)].push(_loc1.attributes.value);
_root["pcArray"+(_loc3-1)].count = 0;
}
}//end of for
imageArray.push(_loc2);
}
}//end of for
testField.text = imageA;
};
Hope this makes sense to someone.
If you need the fla file then I'll happily send it over.
I'm thinking that the 'length' of the array containing the image urls is held in:
_root.imageArray.length ??
So I should be able to write something like:
if(_root.imageArray.length < 2) {
// JUST DISPLAY THE 1 IMAGE STATICALLY
} else // do your normal thing....
Any help would be gratefully received.
Cheers
John ;-))
-
Prid - Outing
WOW, that's one complex pile of code, lol, is it a template or something that you're editing? Send the FLA
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
PM on its way! Thanks once again ;-))
-
fadeGallery(0);
Developers don't help on Decompiled Code. Why are you doing this types of thing, and ask for help to someone?
Post all the source in zip over here, if it is not a decompiled one.
arkitx
-
arkitx,
It's not 'decompiled' code. It's from a website I own and I can assure you that I have the full .fla file (not decompiled).
In fact, it was a member of this forum (Steven FN) who wrote most of it for me (I'm sure he'll attest to this).
Nig 13 is kindly looking at the .fla for me as we speak ;-))
What do you mean by:
fadeGallery(0);
Is that what I need to put in, in order to stop the gallery trying to refresh itself ?
Thanks for all your help.
Cheers
John ;-))
-
If someone helped you to do your work then could you bother to post your source? So that I can see how the code are structured. Steven FN might developed the above code for you but it seems a decompiled code. That is the reason I told you not to post such things. BTW, if Steven FN do work for you, then why don't you ask him to do this? Or even direct you how to do that.
Yes, probably fadeGallery(0); will do work for this.
Best of luck
arkitx
-
Hi arkitx,
I will happily email you the fla file (I presume that's what you mean by the source?). Just send me a PM with your email address and I'll fire it over.
I tried to contact Steven but he wasn't responding to his email. I'm not sure whether he's moved email addys perhaps?
There's not really much 'work' as such. Just a couple of small changes including stopping the gallery cycling when there's less than 2 piccies in the array.
I'm a php programmer and so have an idea about scripting languages but there's quite a lot of actionscript that I'm unsure of (although I'm keen to learn) hence me asking questions on this forum.
Just drop me a PM if you want the fla.
Cheers mate
John ;-)
-
Hi,
Firstly, sorry for the late reply but I've been chocker block with work and haven't had a chance to get back to this.
I've implemented the "fadeGallery(0);" and it doesn't seem to work. If there is only 1 picture the picture doesn't show at all now?
Code:
mclListener.onLoadComplete = function(target_mc) {
if(_root.imageArray.length < 2) {
fadeGallery(0);
} else {
fadeGallery(1);
}
container.load_txt.text = "";
};
Anyone any ideas on why this is? I'm presuming I've put the fadegallery call in the wrong bit but I'm a bit stuck?
Many thanks for all your help so far.
Cheers
John ;-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|